@mountaya/studio 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/agent/index.cjs +2561 -2815
  3. package/dist/agent/index.cjs.map +1 -1
  4. package/dist/agent/index.d.cts +766 -786
  5. package/dist/agent/index.d.ts +766 -786
  6. package/dist/agent/index.js +2553 -2790
  7. package/dist/agent/index.js.map +1 -1
  8. package/dist/chunk-3Oi_Zrtm.js +9 -0
  9. package/dist/chunk-3Oi_Zrtm.js.map +1 -0
  10. package/dist/chunk-B18OPIu_.js +6 -0
  11. package/dist/chunk-B18OPIu_.js.map +1 -0
  12. package/dist/chunk-B5Uz3Qct.cjs +15 -0
  13. package/dist/chunk-B5Uz3Qct.cjs.map +1 -0
  14. package/dist/chunk-BBEJwkd3.d.cts +839 -0
  15. package/dist/chunk-BIEc_SkR.cjs +29 -0
  16. package/dist/chunk-BIEc_SkR.cjs.map +1 -0
  17. package/dist/chunk-BKMFOe-N.js +171 -0
  18. package/dist/chunk-BKMFOe-N.js.map +1 -0
  19. package/dist/chunk-BP4uy7E1.d.ts +11583 -0
  20. package/dist/chunk-BSHTsFiB.js +1403 -0
  21. package/dist/chunk-BSHTsFiB.js.map +1 -0
  22. package/dist/chunk-BTUUABGI.js +17 -0
  23. package/dist/chunk-BTUUABGI.js.map +1 -0
  24. package/dist/chunk-BaPiaz5X.cjs +115 -0
  25. package/dist/chunk-BaPiaz5X.cjs.map +1 -0
  26. package/dist/chunk-BeCVpkYr.cjs +542 -0
  27. package/dist/chunk-BeCVpkYr.cjs.map +1 -0
  28. package/dist/chunk-BgngsvK8.cjs +6202 -0
  29. package/dist/chunk-BgngsvK8.cjs.map +1 -0
  30. package/dist/chunk-BhInd7CJ.d.cts +253 -0
  31. package/dist/chunk-Bn6ZbxkS.cjs +27 -0
  32. package/dist/chunk-By9ZnkVI.js +60 -0
  33. package/dist/chunk-By9ZnkVI.js.map +1 -0
  34. package/dist/chunk-BzqPhxsz.cjs +367 -0
  35. package/dist/chunk-BzqPhxsz.cjs.map +1 -0
  36. package/dist/chunk-C2mMX81q.d.ts +443 -0
  37. package/dist/chunk-C2rr9Q0V.cjs +1402 -0
  38. package/dist/chunk-C2rr9Q0V.cjs.map +1 -0
  39. package/dist/{directorThreads-CqmvsV8b.d.cts → chunk-CDJCbwIQ.d.cts} +20 -22
  40. package/dist/chunk-CLGvBOVH.d.cts +1654 -0
  41. package/dist/chunk-COdw1dc6.d.ts +525 -0
  42. package/dist/chunk-CQCJnT2i.d.ts +511 -0
  43. package/dist/chunk-CSyHY67q.cjs +353 -0
  44. package/dist/chunk-CSyHY67q.cjs.map +1 -0
  45. package/dist/chunk-CiK1Iqrv.js +950 -0
  46. package/dist/chunk-CiK1Iqrv.js.map +1 -0
  47. package/dist/chunk-CmJBgSwZ.cjs +24 -0
  48. package/dist/chunk-CmJBgSwZ.cjs.map +1 -0
  49. package/dist/chunk-CnrsRK2u.cjs +83 -0
  50. package/dist/chunk-CnrsRK2u.cjs.map +1 -0
  51. package/dist/chunk-Co782_9r.js +326 -0
  52. package/dist/chunk-Co782_9r.js.map +1 -0
  53. package/dist/chunk-Csr3KDpZ.cjs +32 -0
  54. package/dist/chunk-Csr3KDpZ.cjs.map +1 -0
  55. package/dist/chunk-CwkmccXv.js +89 -0
  56. package/dist/chunk-CwkmccXv.js.map +1 -0
  57. package/dist/chunk-D0Q4iL9B.cjs +255 -0
  58. package/dist/chunk-D0Q4iL9B.cjs.map +1 -0
  59. package/dist/chunk-DFwiSzUS.cjs +72 -0
  60. package/dist/chunk-DFwiSzUS.cjs.map +1 -0
  61. package/dist/chunk-DIFayl2P.d.cts +443 -0
  62. package/dist/chunk-DIGF58ux.d.cts +525 -0
  63. package/dist/chunk-DKuuuld5.js +101 -0
  64. package/dist/chunk-DKuuuld5.js.map +1 -0
  65. package/dist/chunk-DMePkFEo.js +5054 -0
  66. package/dist/chunk-DMePkFEo.js.map +1 -0
  67. package/dist/chunk-DO5SIBgu.js +305 -0
  68. package/dist/chunk-DO5SIBgu.js.map +1 -0
  69. package/dist/chunk-DOQ_7eE5.d.ts +6662 -0
  70. package/dist/{tabs-B2nRO4p_.d.ts → chunk-DThaaNeb.d.cts} +2 -2
  71. package/dist/{tabs-B2nRO4p_.d.cts → chunk-DThaaNeb.d.ts} +2 -2
  72. package/dist/{directorThreads-CqmvsV8b.d.ts → chunk-DUQzjUJy.d.ts} +20 -22
  73. package/dist/chunk-DX37IPhV.cjs +1903 -0
  74. package/dist/chunk-DX37IPhV.cjs.map +1 -0
  75. package/dist/chunk-Damps5Tk.cjs +155 -0
  76. package/dist/chunk-Damps5Tk.cjs.map +1 -0
  77. package/dist/chunk-DbK5PhpJ.d.ts +1654 -0
  78. package/dist/chunk-De0vAASv.d.ts +253 -0
  79. package/dist/chunk-DhSZ7YZt.d.cts +6662 -0
  80. package/dist/chunk-DjEvqvPA.cjs +43 -0
  81. package/dist/chunk-DjEvqvPA.cjs.map +1 -0
  82. package/dist/{saveFile-j-1kkApx.d.cts → chunk-DkwDzwvu.d.cts} +7 -9
  83. package/dist/{saveFile-j-1kkApx.d.ts → chunk-DkwDzwvu.d.ts} +7 -9
  84. package/dist/chunk-Dmszv9If.js +71 -0
  85. package/dist/chunk-Dmszv9If.js.map +1 -0
  86. package/dist/chunk-Dp_ftNWY.d.cts +511 -0
  87. package/dist/chunk-DsHQySz0.js +31 -0
  88. package/dist/chunk-DsHQySz0.js.map +1 -0
  89. package/dist/chunk-DwoUyHHh.js +281 -0
  90. package/dist/chunk-DwoUyHHh.js.map +1 -0
  91. package/dist/chunk-IaIDQflj.d.cts +2315 -0
  92. package/dist/chunk-IaIDQflj.d.ts +2315 -0
  93. package/dist/chunk-cVXLsZfL.d.ts +839 -0
  94. package/dist/chunk-mIaCX9EJ.d.cts +11583 -0
  95. package/dist/chunk-nJQxbOwQ.cjs +8962 -0
  96. package/dist/chunk-nJQxbOwQ.cjs.map +1 -0
  97. package/dist/chunk-o9jaxhCO.js +8852 -0
  98. package/dist/chunk-o9jaxhCO.js.map +1 -0
  99. package/dist/chunk-p-Tt_Lwz.js +14 -0
  100. package/dist/chunk-p-Tt_Lwz.js.map +1 -0
  101. package/dist/engines/index.cjs +2046 -3401
  102. package/dist/engines/index.cjs.map +1 -1
  103. package/dist/engines/index.d.cts +1510 -1550
  104. package/dist/engines/index.d.ts +1510 -1550
  105. package/dist/engines/index.js +2039 -3380
  106. package/dist/engines/index.js.map +1 -1
  107. package/dist/handlers/index.cjs +47 -93
  108. package/dist/handlers/index.cjs.map +1 -1
  109. package/dist/handlers/index.d.cts +61 -103
  110. package/dist/handlers/index.d.ts +61 -103
  111. package/dist/handlers/index.js +27 -36
  112. package/dist/handlers/index.js.map +1 -1
  113. package/dist/index.cjs +3347 -4398
  114. package/dist/index.cjs.map +1 -1
  115. package/dist/index.d.cts +8 -7297
  116. package/dist/index.d.ts +8 -7297
  117. package/dist/index.js +2997 -3187
  118. package/dist/index.js.map +1 -1
  119. package/dist/plugins/index.cjs +482 -949
  120. package/dist/plugins/index.cjs.map +1 -1
  121. package/dist/plugins/index.d.cts +44 -61
  122. package/dist/plugins/index.d.ts +44 -61
  123. package/dist/plugins/index.js +471 -915
  124. package/dist/plugins/index.js.map +1 -1
  125. package/dist/seams/index.cjs +77 -140
  126. package/dist/seams/index.cjs.map +1 -1
  127. package/dist/seams/index.d.cts +125 -158
  128. package/dist/seams/index.d.ts +125 -158
  129. package/dist/seams/index.js +41 -71
  130. package/dist/seams/index.js.map +1 -1
  131. package/dist/strings/fr/index.cjs +2130 -2116
  132. package/dist/strings/fr/index.cjs.map +1 -1
  133. package/dist/strings/fr/index.d.cts +3 -5
  134. package/dist/strings/fr/index.d.ts +3 -5
  135. package/dist/strings/fr/index.js +2125 -2114
  136. package/dist/strings/fr/index.js.map +1 -1
  137. package/dist/strings/index.cjs +2331 -2625
  138. package/dist/strings/index.cjs.map +1 -1
  139. package/dist/strings/index.d.cts +3 -731
  140. package/dist/strings/index.d.ts +3 -731
  141. package/dist/strings/index.js +2324 -2615
  142. package/dist/strings/index.js.map +1 -1
  143. package/dist/testing/index.cjs +214 -276
  144. package/dist/testing/index.cjs.map +1 -1
  145. package/dist/testing/index.d.cts +61 -121
  146. package/dist/testing/index.d.ts +61 -121
  147. package/dist/testing/index.js +208 -273
  148. package/dist/testing/index.js.map +1 -1
  149. package/dist/time/index.cjs +23 -23
  150. package/dist/time/index.cjs.map +1 -1
  151. package/dist/time/index.d.cts +5 -7
  152. package/dist/time/index.d.ts +5 -7
  153. package/dist/time/index.js +18 -21
  154. package/dist/time/index.js.map +1 -1
  155. package/package.json +14 -15
  156. package/src/agent/rules/stateDelta.ts +1 -0
  157. package/src/agent/stores/agentThreads.ts +1 -4
  158. package/src/bus/rules/bus.ts +1 -2
  159. package/src/bus/rules/defineRegistry.ts +3 -5
  160. package/src/bus/rules/types.ts +6 -7
  161. package/src/chrome/stores/uiStore.ts +4 -2
  162. package/src/embed/rules/fieldDependencies.ts +2 -0
  163. package/src/embed/rules/safetyRules.ts +2 -0
  164. package/src/embed/rules/tableCode.ts +4 -3
  165. package/src/index.ts +6 -27
  166. package/src/itinerary/rules/import.ts +6 -8
  167. package/src/plugins/contracts/plugin.ts +4 -2
  168. package/src/seams/rules/formatters.ts +5 -3
  169. package/src/testing/index.ts +1 -5
  170. package/src/viewer/rules/platformViewer.ts +1 -0
  171. package/dist/bus-BwiNiXdH.d.ts +0 -514
  172. package/dist/bus-DzmhPwdK.d.cts +0 -514
  173. package/dist/chainModel-B23pEP_1.d.cts +0 -127
  174. package/dist/chainModel-B23pEP_1.d.ts +0 -127
  175. package/dist/chunk-2HFY7ETU.js +0 -5721
  176. package/dist/chunk-2HFY7ETU.js.map +0 -1
  177. package/dist/chunk-355TOXSB.js +0 -72
  178. package/dist/chunk-355TOXSB.js.map +0 -1
  179. package/dist/chunk-4ZCUZVSV.js +0 -10275
  180. package/dist/chunk-4ZCUZVSV.js.map +0 -1
  181. package/dist/chunk-6HEKY3NF.js +0 -95
  182. package/dist/chunk-6HEKY3NF.js.map +0 -1
  183. package/dist/chunk-7GFLGGBX.cjs +0 -8
  184. package/dist/chunk-7GFLGGBX.cjs.map +0 -1
  185. package/dist/chunk-7NBRCENN.cjs +0 -19
  186. package/dist/chunk-7NBRCENN.cjs.map +0 -1
  187. package/dist/chunk-AF5GCXE3.js +0 -8
  188. package/dist/chunk-AF5GCXE3.js.map +0 -1
  189. package/dist/chunk-CJDIFRGZ.cjs +0 -2005
  190. package/dist/chunk-CJDIFRGZ.cjs.map +0 -1
  191. package/dist/chunk-CNPZY7N3.js +0 -349
  192. package/dist/chunk-CNPZY7N3.js.map +0 -1
  193. package/dist/chunk-DZJHTWSF.cjs +0 -45
  194. package/dist/chunk-DZJHTWSF.cjs.map +0 -1
  195. package/dist/chunk-EABIHHWA.js +0 -42
  196. package/dist/chunk-EABIHHWA.js.map +0 -1
  197. package/dist/chunk-EKZWV6RS.cjs +0 -415
  198. package/dist/chunk-EKZWV6RS.cjs.map +0 -1
  199. package/dist/chunk-EOKRXXAC.cjs +0 -24
  200. package/dist/chunk-EOKRXXAC.cjs.map +0 -1
  201. package/dist/chunk-F73W2ZTJ.js +0 -1126
  202. package/dist/chunk-F73W2ZTJ.js.map +0 -1
  203. package/dist/chunk-H4DVOZ5O.js +0 -1897
  204. package/dist/chunk-H4DVOZ5O.js.map +0 -1
  205. package/dist/chunk-HI52PBFT.cjs +0 -10314
  206. package/dist/chunk-HI52PBFT.cjs.map +0 -1
  207. package/dist/chunk-IDBXFBLG.cjs +0 -1225
  208. package/dist/chunk-IDBXFBLG.cjs.map +0 -1
  209. package/dist/chunk-LBWTJZUJ.js +0 -297
  210. package/dist/chunk-LBWTJZUJ.js.map +0 -1
  211. package/dist/chunk-NCLA6DKD.cjs +0 -310
  212. package/dist/chunk-NCLA6DKD.cjs.map +0 -1
  213. package/dist/chunk-O4MC5DPD.js +0 -19
  214. package/dist/chunk-O4MC5DPD.js.map +0 -1
  215. package/dist/chunk-OP37FKW6.cjs +0 -98
  216. package/dist/chunk-OP37FKW6.cjs.map +0 -1
  217. package/dist/chunk-OQSYFH3Z.cjs +0 -5945
  218. package/dist/chunk-OQSYFH3Z.cjs.map +0 -1
  219. package/dist/chunk-PACIO4NS.cjs +0 -26
  220. package/dist/chunk-PACIO4NS.cjs.map +0 -1
  221. package/dist/chunk-PSZ2R3TC.cjs +0 -75
  222. package/dist/chunk-PSZ2R3TC.cjs.map +0 -1
  223. package/dist/chunk-QFO5CZG2.cjs +0 -136
  224. package/dist/chunk-QFO5CZG2.cjs.map +0 -1
  225. package/dist/chunk-QL63MUEW.cjs +0 -140
  226. package/dist/chunk-QL63MUEW.cjs.map +0 -1
  227. package/dist/chunk-RFUPPVZO.js +0 -17
  228. package/dist/chunk-RFUPPVZO.js.map +0 -1
  229. package/dist/chunk-RPG2LWMP.js +0 -23
  230. package/dist/chunk-RPG2LWMP.js.map +0 -1
  231. package/dist/chunk-TIBXK6B7.cjs +0 -12
  232. package/dist/chunk-TIBXK6B7.cjs.map +0 -1
  233. package/dist/chunk-UU65VNEV.js +0 -381
  234. package/dist/chunk-UU65VNEV.js.map +0 -1
  235. package/dist/chunk-VGX6TR2I.js +0 -209
  236. package/dist/chunk-VGX6TR2I.js.map +0 -1
  237. package/dist/chunk-WUTDDBVP.js +0 -130
  238. package/dist/chunk-WUTDDBVP.js.map +0 -1
  239. package/dist/chunk-WVQQLKCI.cjs +0 -224
  240. package/dist/chunk-WVQQLKCI.cjs.map +0 -1
  241. package/dist/chunk-WZYXG3SE.js +0 -111
  242. package/dist/chunk-WZYXG3SE.js.map +0 -1
  243. package/dist/chunk-XDI2X3KE.js +0 -6
  244. package/dist/chunk-XDI2X3KE.js.map +0 -1
  245. package/dist/chunk-XKHLRIC7.cjs +0 -381
  246. package/dist/chunk-XKHLRIC7.cjs.map +0 -1
  247. package/dist/context-DNtd2WUv.d.cts +0 -11666
  248. package/dist/context-DgB72Bur.d.ts +0 -11666
  249. package/dist/en-Bu4Ti9Ev.d.cts +0 -2315
  250. package/dist/en-Bu4Ti9Ev.d.ts +0 -2315
  251. package/dist/shareLink-B6hlt942.d.ts +0 -144
  252. package/dist/shareLink-C7rIMb7x.d.ts +0 -527
  253. package/dist/shareLink-CnTxxXjp.d.cts +0 -144
  254. package/dist/shareLink-DyZVYH2V.d.cts +0 -527
  255. package/dist/studioPlugin-C3C7VjMy.d.ts +0 -847
  256. package/dist/studioPlugin-Cf3OBNUv.d.cts +0 -847
  257. package/dist/types-BzJRV6UI.d.cts +0 -845
  258. package/dist/types-BzJRV6UI.d.ts +0 -845
  259. package/dist/zoneForm-CdYNtnnA.d.cts +0 -320
  260. package/dist/zoneForm-mG85yt5e.d.ts +0 -320
@@ -0,0 +1,1654 @@
1
+ import { t as StudioStrings } from "./chunk-IaIDQflj.cjs";
2
+ import * as z$1 from "zod";
3
+ import { RestSchema, Zone } from "@mountaya/client";
4
+ import { CameraFps, CameraOutput, CameraOutputFormat, CameraResolution, Quality } from "@mountaya/elements/camera";
5
+ import { ItinerarySegment as ItinerarySegment$1, ItinerarySegmentGroup as ItinerarySegmentGroup$1, ItineraryWithDetails as ItineraryWithDetails$1 } from "@mountaya/elements/data";
6
+ import { BundleLanguageOverrides, MapLanguage, PartialDeep, Translations } from "@mountaya/elements/i18n";
7
+ /**
8
+ * The vocabulary a studio mutation surface is spoken in.
9
+ *
10
+ * Everything here is generic over `TCtx`, the execution context a host threads into its
11
+ * handlers. That parameter is the whole reason this module can be published: the context is
12
+ * the one part of a tool bus that is irreducibly the host's (Mountaya's studio threads a map
13
+ * client, a UI store and a query cache through it, an integrator will thread whatever their
14
+ * application holds), while the dispatch machinery, the capability gate, the confirmation
15
+ * protocol and the result shape are the same for everyone.
16
+ *
17
+ * Nothing here imports a renderer or React, and `@mountaya/client` is named for one type, the
18
+ * wire's failure codes, which erases. A tool is a name, a Zod schema and a function;
19
+ * `boundary.test.ts` keeps it that way.
20
+ */
21
+ /**
22
+ * toolCapabilitySchema is the capabilities this package can mean on its own behalf.
23
+ *
24
+ * `authenticated` is "there is a session"; `editor` is "this surface may change the resource".
25
+ * They are Zod-first because a host derives them from an auth context and may want to parse
26
+ * what it derived.
27
+ *
28
+ * The set is deliberately small. A vocabulary is only useful where both sides agree on what a
29
+ * word denotes, and these are the only ones a package that knows nothing about a host's
30
+ * authorization model can define. Anything past them, such as a surface class, what an
31
+ * agreement covers or a membership role, belongs to whoever grants it.
32
+ */
33
+ declare const toolCapabilitySchema: z$1.ZodEnum<{
34
+ authenticated: "authenticated";
35
+ editor: "editor";
36
+ }>;
37
+ /**
38
+ * ToolCapability gates which tools are available to a surface: the ones above, plus whatever a
39
+ * host's own model adds.
40
+ *
41
+ * The `(string & {})` arm is what makes the union open while keeping the published values in
42
+ * autocomplete: a host declaring `capability: "embedding"` on its own tool is legal, and a host
43
+ * reaching for `"editor"` still gets it offered. The gate itself is a `Set.has` over strings and
44
+ * never narrows, so an unknown capability is refused rather than mistaken for a known one.
45
+ *
46
+ * A host with a closed vocabulary of its own states it in one place: declare a Zod enum over
47
+ * every capability it grants and thread it through its own tool type, which is how a host
48
+ * names the surfaces this package has no business naming.
49
+ */
50
+ type ToolCapability = z$1.infer<typeof toolCapabilitySchema> | (string & {});
51
+ /**
52
+ * confirmationToneSchema is the closed vocabulary of confirm treatments a tool may
53
+ * ask its prompt to wear. It names the CONSEQUENCE, and the confirm surface owns the
54
+ * paint, so a tool never hard-codes a color:
55
+ *
56
+ * - "destructive": data is removed or a grant is revoked.
57
+ * - "cautionary": nothing is lost, but a live side effect follows that the user
58
+ * cannot silently walk back (a chain re-shape, a re-route).
59
+ * - "affirmative": a benign confirmation the user is simply being asked to own.
60
+ *
61
+ * Zod-first because it is a value enum shared across the tool definitions, the bus,
62
+ * and the confirm surface. Absent on a policy, the tone is "destructive": the confirm
63
+ * gate exists for consequential verbs, so the loudest treatment is the safe default and
64
+ * a softer one is an explicit opt-in.
65
+ */
66
+ declare const confirmationToneSchema: z$1.ZodEnum<{
67
+ affirmative: "affirmative";
68
+ cautionary: "cautionary";
69
+ destructive: "destructive";
70
+ }>;
71
+ /**
72
+ * ConfirmationTone is the treatment a confirm prompt wears, derived from
73
+ * {@link confirmationToneSchema}. See the schema's JSDoc for each member's meaning.
74
+ */
75
+ type ConfirmationTone = z$1.infer<typeof confirmationToneSchema>;
76
+ /**
77
+ * ConfirmationValues are the interpolation values a confirm prompt's copy keys are
78
+ * resolved with, so a body can name the entities it is about to act on ("Merge
79
+ * {{name}} into {{nextName}}") instead of describing them generically. A value the
80
+ * entry does not reference is ignored, and a placeholder with no value renders as-is
81
+ * rather than throwing.
82
+ */
83
+ type ConfirmationValues = Record<string, string | number>;
84
+ /**
85
+ * toolConfirmationSchema is the Zod source of truth for a tool's confirmation
86
+ * policy. Every copy field is a key the confirm surface resolves, never raw copy:
87
+ * this package carries no strings and does not translate.
88
+ *
89
+ * - acknowledgeLabel, when present, demands the user tick an "I understand…"
90
+ * checkbox before the confirm control enables, reserved for the highest-stakes
91
+ * tools so a stray click cannot destroy something.
92
+ * - titleLabel / descriptionLabel override the dialog's title and body so each
93
+ * destructive tool reads with its own resource-specific copy; absent, the surface
94
+ * falls back to the tool's description and a generic title.
95
+ * - confirmLabel overrides the confirm button's label.
96
+ * - tone selects the prompt's treatment (see {@link confirmationToneSchema}) and
97
+ * defaults to "destructive" when absent.
98
+ *
99
+ * A tool that supplies an empty object keeps the generic prompt; the empty form is the
100
+ * explicit declaration that the generic prompt is the intended experience. A host may
101
+ * introspect this schema at manifest time, so the contract is machine-readable rather
102
+ * than implicit.
103
+ */
104
+ declare const toolConfirmationSchema: z$1.ZodObject<{
105
+ acknowledgeLabel: z$1.ZodOptional<z$1.ZodString>;
106
+ confirmLabel: z$1.ZodOptional<z$1.ZodString>;
107
+ descriptionLabel: z$1.ZodOptional<z$1.ZodString>;
108
+ titleLabel: z$1.ZodOptional<z$1.ZodString>;
109
+ tone: z$1.ZodOptional<z$1.ZodEnum<{
110
+ affirmative: "affirmative";
111
+ cautionary: "cautionary";
112
+ destructive: "destructive";
113
+ }>>;
114
+ }, z$1.core.$strip>;
115
+ /**
116
+ * ToolConfirmation is the confirmation policy a destructive tool attaches to
117
+ * itself, derived from toolConfirmationSchema.
118
+ */
119
+ type ToolConfirmation = z$1.infer<typeof toolConfirmationSchema>;
120
+ /**
121
+ * ConfirmationRequest describes a destructive (requiresConfirmation) tool the
122
+ * bus is about to run. The bus passes it to the context's confirm gate so the
123
+ * application (or an agent host) can prompt for approval before the handler runs.
124
+ *
125
+ * The bus forwards the tool's policy two ways: `acknowledge` carries the whole policy
126
+ * object, and the policy's display keys are also flattened onto the request as
127
+ * `titleLabel` / `descriptionLabel` / `confirmLabel` so a surface resolves the dialog's
128
+ * copy without reaching into the nested policy. `cancelLabel` optionally overrides the
129
+ * cancel copy. All are keys, absent for a tool that keeps the generic prompt; a host
130
+ * that builds a request by hand supplies a pre-resolved `description` and omits them.
131
+ */
132
+ interface ConfirmationRequest {
133
+ acknowledge?: ToolConfirmation | undefined;
134
+ cancelLabel?: string | undefined;
135
+ confirmLabel?: string | undefined;
136
+ description: string;
137
+ descriptionLabel?: string | undefined;
138
+ input: unknown;
139
+ name: string;
140
+ titleLabel?: string | undefined;
141
+ tone?: ConfirmationTone | undefined;
142
+ values?: ConfirmationValues | undefined;
143
+ }
144
+ /**
145
+ * TabSurface is the narrow window onto a host's tab strip a tool handler needs: reveal
146
+ * the co-pilot panel, switch the active tab, open a new one (returning its id), or close
147
+ * one. A host injects it so the tab tools never reach into a specific store: the bus
148
+ * stays the single mutation surface and the tab state stays a host detail. Optional,
149
+ * since a surface with no tab strip omits it and those tools return a structured failure
150
+ * rather than throwing.
151
+ */
152
+ interface TabSurface {
153
+ addCopilotTab: () => string;
154
+ closeCopilotTab: (tabId: string) => void;
155
+ /** countOpen returns the number of co-pilot tabs currently open. */
156
+ countOpen: () => number;
157
+ /**
158
+ * hasTab reports whether the strip holds a tab under `tabId`: a conversation that is open, or
159
+ * a pseudo-tab the strip shows.
160
+ *
161
+ * It is what lets `studio.tabs.switch` and `studio.tabs.close` answer `not-found` for an id
162
+ * that names no tab, where `setActiveTab` and `closeCopilotTab` report nothing
163
+ * back. A strip that states none is not asked, and the two verbs answer success for an id
164
+ * they could not check. The search pseudo-tab is always there, so `studio.tabs.switch` shows
165
+ * it without asking.
166
+ *
167
+ * @default undefined, and no id is refused as unknown
168
+ */
169
+ hasTab?: ((tabId: string) => boolean) | undefined;
170
+ /**
171
+ * openCopilot reveals the co-pilot and returns the id of the tab it
172
+ * activated. Idempotent focus-or-open: it activates an existing conversation when one
173
+ * is open and opens one when none is, so a repeated request always lands on the panel
174
+ * rather than silently hitting the open-tab cap.
175
+ */
176
+ openCopilot: () => string;
177
+ /**
178
+ * reset clears the co-pilot for a switched-to resource: it closes every thread so the
179
+ * leaving resource's conversation cannot leak into the next one, then lands on the
180
+ * default tab so the panel stays closed until asked again.
181
+ */
182
+ reset: () => void;
183
+ setActiveTab: (tabId: string) => void;
184
+ }
185
+ /**
186
+ * ViewerPreferences is how the person reading this studio wants measurements and copy
187
+ * rendered. Every field is optional because a host hydrates them from a profile that may
188
+ * carry none of them, and each consumer falls back to its own default rather than to a
189
+ * shared one: an absent `length` is "this viewer has not said", not "metric".
190
+ *
191
+ * `UnitFormatOptions` on `@mountaya/elements` is the resolved form of every field: a formatter
192
+ * needs an answer for each, so `resolveViewerUnits` fills the gaps and the sparse shape never
193
+ * reaches one.
194
+ */
195
+ interface ViewerPreferences {
196
+ /** A BCP 47 tag. Chooses the decimal separator and the localized unit name. */
197
+ language?: string | undefined;
198
+ length?: "metric" | "imperial" | undefined;
199
+ /** The FORM a travel rate is stated in. The system still comes from `length`. */
200
+ pace?: "per-time" | "per-distance" | undefined;
201
+ slope?: "degrees" | "percentage" | undefined;
202
+ temperature?: "celsius" | "fahrenheit" | undefined;
203
+ }
204
+ /**
205
+ * ViewerSeam is the narrow window onto whoever is reading this studio: who they are, what
206
+ * the host currently extends to them, and how they want measurements rendered.
207
+ *
208
+ * Three questions, one answer a surface can change, and a subscription. `setPreferences` is
209
+ * the one WRITE.
210
+ *
211
+ * The questions: `getUserId` answers "is this mine?" (an edit lock's holder, a collection's
212
+ * author, the creator of a personal resource). `hasEntitlement` answers "does this person's
213
+ * agreement cover this surface?".
214
+ * `getPreferences` lets a confirm prompt state a distance in the units the rest of the editor
215
+ * shows. Nothing else about a session belongs to a tool.
216
+ *
217
+ * The write belongs HERE rather than on a seam of its own, and the reason is `subscribe`. It
218
+ * writes exactly the state the reads read, and that state is the one thing on this interface
219
+ * that changes under a session that stays put, so a second seam would be one object a host
220
+ * wires separately, notifying listeners registered on the first. What would be wrong is a write
221
+ * to something this seam does not also READ; there is none, and a reviewer adding one should
222
+ * treat this paragraph as the argument against it.
223
+ *
224
+ * It is deliberately NOT a store. A host's identity store also carries how the session was
225
+ * established (an email-verification flag, an identity provider's traits and metadata, the
226
+ * setters a bootstrap calls), and none of that is a studio concern. Publishing the store
227
+ * would put one identity provider's session vocabulary in every consumer's types; publishing
228
+ * the three questions instead lets a host answer them from whatever it already has.
229
+ *
230
+ * Every member is a FUNCTION, not a value, and that is the load-bearing part. A host builds
231
+ * its context once and hands the same object to every dispatch, so anything captured by
232
+ * value is captured at mount, and entitlement is precisely what is not settled then, since
233
+ * membership in an organization resolves from a lookup that lands after bootstrap. A
234
+ * handler that read a snapshot would refuse a member the surface already offers.
235
+ */
236
+ interface ViewerSeam<TEntitlement extends string = string> {
237
+ getPreferences: () => ViewerPreferences | null;
238
+ getUserId: () => string | null;
239
+ /**
240
+ * hasEntitlement asks whether the host extends a named entitlement to this viewer right
241
+ * now, such as a product the viewer's agreement covers or a membership.
242
+ *
243
+ * Distinct from `ToolBusContext.capabilities`, and the difference is what each describes.
244
+ * `capabilities` is what the SURFACE is: an embed grants `embedding` for as long as it is an
245
+ * embed, so the bus can settle it once and gate on a `Set`. This is what the PERSON
246
+ * holds, which changes under a session that stays put.
247
+ *
248
+ * The vocabulary belongs to the host, for the same reason `ToolCapability` leaves what an
249
+ * agreement covers to whoever grants it. A host with a closed set of its own states it once
250
+ * as a Zod enum and binds it through `TEntitlement`, so a typo is a type error rather than a
251
+ * silent `false`.
252
+ */
253
+ hasEntitlement: (entitlement: TEntitlement) => boolean;
254
+ /**
255
+ * setPreferences records a viewer's measurement choices, as a PARTIAL: a surface changing
256
+ * the length system says only that, and the host folds it onto whatever it already held.
257
+ *
258
+ * The one member that is not a question, and it is on this interface because it writes the
259
+ * state `getPreferences` reads and `subscribe` reports, as {@link ViewerSeam} argues. Where the
260
+ * host PUTS it is the host's business: a signed-in studio persists it against the account, an
261
+ * embed keeps it for the session, and a viewer built by `createStaticViewer` drops it.
262
+ *
263
+ * Total, like every seam in this family: a host that cannot store a preference does nothing
264
+ * rather than throwing, and "the choice did not stick" is a state the surface already renders
265
+ * by reading the value back.
266
+ */
267
+ setPreferences: (partial: ViewerPreferences) => void;
268
+ /**
269
+ * subscribe registers a listener for any change to the answers above, and returns the
270
+ * unsubscribe.
271
+ *
272
+ * Every other member is a function so it can be READ late: the context is built once per
273
+ * mount and a membership resolves after it. That is exactly right for a handler, which runs on
274
+ * demand and wants the answer as of now. It is not enough for a surface: a component that
275
+ * calls `hasEntitlement` during render is correct once and then stale, and the surfaces that
276
+ * gate on this are the ones a session changes underneath (an invitation accepted in another
277
+ * tab, an agreement that starts covering a product, a membership that resolves a beat after
278
+ * the studio mounts).
279
+ *
280
+ * The signature is `useSyncExternalStore`'s deliberately, so a host holding this in any store
281
+ * passes its own `subscribe` unchanged and a host holding constants passes one that never
282
+ * fires. Required rather than optional: an optional subscription is one a component cannot
283
+ * rely on, so every reader would need a stale path as well as a live one.
284
+ */
285
+ subscribe: (onChange: () => void) => () => void;
286
+ }
287
+ /**
288
+ * ToolBusContext is the minimum a host's execution context must provide for the bus to do
289
+ * its job, and the only part of that context this package is entitled to know about.
290
+ *
291
+ * Its members are what the bus itself reads of a context before a handler runs: `capabilities`,
292
+ * to refuse a tool the caller was never granted, and `confirm`, called before a destructive one.
293
+ * A tool's `precondition` and everything a handler touches (a map, a store, a cache) read the
294
+ * host's own context, and none of it appears here.
295
+ *
296
+ * `confirm` is optional, and its absence is a REFUSAL rather than a bypass: a bus with no
297
+ * confirm gate declines every tool that requires confirmation. That is what lets a read-only
298
+ * surface omit the gate entirely and still be safe by construction, instead of relying on
299
+ * nobody having registered a destructive tool.
300
+ */
301
+ interface ToolBusContext {
302
+ capabilities: ReadonlySet<ToolCapability>;
303
+ confirm?: ((request: ConfirmationRequest) => Promise<boolean>) | undefined;
304
+ }
305
+ /**
306
+ * ToolDispatchRegistry maps every registered tool name to its raw (pre-parse) input
307
+ * type. It is declared empty here and populated by a host via interface augmentation
308
+ * (`declare module "@mountaya/studio"`), so this module stays a leaf (it never
309
+ * imports the registry that knows the tools) while a handler chaining through the
310
+ * context's bus still sees the full name union and each tool's input shape. Without an
311
+ * augmentation present it is empty: {@link KnownToolInput} answers `unknown` for every name,
312
+ * and the typed `dispatch` of a {@link ToolBusDispatch} left at this default takes no name, so
313
+ * `dispatchUnsafe` is the entry point until the registry is augmented or the inputs are named.
314
+ */
315
+ interface ToolDispatchRegistry {}
316
+ /**
317
+ * KnownToolInput resolves a tool name to its raw (pre-parse) input type from the
318
+ * augmented registry, or `unknown` for a name the registry does not carry (the
319
+ * loose-seam fallback, and the type a dynamically-built name resolves to).
320
+ */
321
+ type KnownToolInput<TName> = TName extends keyof ToolDispatchRegistry ? ToolDispatchRegistry[TName] : unknown;
322
+ /**
323
+ * ToolOutputRegistry maps every registered tool name to the `data` its answer holds. It is the
324
+ * second augmentation seam, beside {@link ToolDispatchRegistry} and declared empty for the same
325
+ * reason: a host fills it by interface augmentation (`declare module "@mountaya/studio"`), so
326
+ * this module names no tool and a dispatch through the context's bus still answers each verb's
327
+ * own data.
328
+ *
329
+ * A registry of its own, because what a tool takes and what it answers are separate questions. A
330
+ * host that augments the inputs alone has its names and payloads checked and reads every
331
+ * answer's `data` as `unknown`, which is what a dispatch answers wherever this map does not hold
332
+ * the name.
333
+ */
334
+ interface ToolOutputRegistry {}
335
+ /**
336
+ * KnownToolOutput resolves a tool name to the `data` its answer holds, read from the augmented
337
+ * {@link ToolOutputRegistry}, or `unknown` for a name the registry does not carry: a tool whose
338
+ * contract states no output, and every name while the registry is not augmented.
339
+ */
340
+ type KnownToolOutput<TName> = TName extends keyof ToolOutputRegistry ? ToolOutputRegistry[TName] : unknown;
341
+ /**
342
+ * unstated keys the answer of a name an outputs map does not hold. A symbol, so no tool name can
343
+ * spell it, and declared only: it names a type and no value exists behind it.
344
+ */
345
+ declare const unstated: unique symbol;
346
+ /**
347
+ * ToolSuccess is the `ok` arm of {@link ToolResult}: a summary, and the data of type `TData`.
348
+ */
349
+ type ToolSuccess<TData = unknown> = Extract<ToolResult<TData>, {
350
+ ok: true;
351
+ }>;
352
+ /**
353
+ * ToolSuccessByName is an outputs map read as `ok` answers: each name to the {@link ToolSuccess}
354
+ * holding its data, and {@link unstated} to the `ok` answer of every other name.
355
+ *
356
+ * A mapped type rather than `ToolResult<TOutputs[TName]>` written at the dispatch itself, because
357
+ * each entry here is resolved once per name. A result parameterised by a name still to be
358
+ * inferred stays unresolved, and nothing but the bus's own answer is assignable to it.
359
+ */
360
+ type ToolSuccessByName<TOutputs> = { [K in keyof TOutputs]: ToolSuccess<TOutputs[K]>; } & {
361
+ [unstated]: ToolSuccess;
362
+ };
363
+ /**
364
+ * ToolResultOf is what a dispatch of `TName` answers on a bus whose outputs are `TOutputs`: the
365
+ * {@link ToolResult} of that verb's data, and a plain {@link ToolResult} for a name the map does
366
+ * not hold.
367
+ *
368
+ * The arms ahead of the lookup are the names the compiler cannot match. No name at all is the
369
+ * typed dispatch of a bus whose registry is not augmented, and the whole of `string` is a name
370
+ * built at run time. Each answers `data` as `unknown`, whatever the map holds.
371
+ *
372
+ * The refusal is an arm of its own beside the lookup, and the lookup holds the `ok` arms alone.
373
+ * A {@link ToolFailure} is therefore the answer of every verb while the name is still to be
374
+ * resolved: a wrapper generic in the name returns a refusal of its own as written, and so does a
375
+ * hand-written dispatch that refuses everything. A value that answers one `ok` shape under every
376
+ * name is held to the lookup, and is refused with the two types named where a verb states data
377
+ * it does not carry. A refusal held inside each entry would cost both: to relate such a value the
378
+ * compiler intersects every verb's whole result, and over a map of many data types it gives up
379
+ * with TS2590, which names neither type and is reported for the first such value of a program
380
+ * alone.
381
+ *
382
+ * The `string` arm is also what makes `TOutputs` a way of READING a bus and no part of its
383
+ * identity. TypeScript compares two instantiations of one generic interface with the method's
384
+ * own type parameter erased, where every dispatch answers the plain result, so a dispatch slice
385
+ * typed with one outputs map is assignable to a slot typed with another. A host that names no
386
+ * outputs hands its `bus.dispatcher` to a studio context as it stands. A value of another type,
387
+ * a bus instance or an object literal among them, is compared member by member, and there the
388
+ * answers have to agree.
389
+ *
390
+ * Published for a wrapper that forwards a name it has not resolved. A function generic in the
391
+ * name returns this type to hand its caller what the bus answered: a `ToolResult` written over
392
+ * `TOutputs[TName]` is another unresolved type, and the bus's answer is not assignable to it.
393
+ *
394
+ * @example
395
+ * ```ts
396
+ * interface Inputs {
397
+ * "acme.route.measure": { routeId: string };
398
+ * }
399
+ * interface Outputs {
400
+ * "acme.route.measure": { meters: number };
401
+ * }
402
+ * declare const dispatcher: ToolBusDispatch<ToolBusContext, Inputs, Outputs>;
403
+ * declare const context: ToolBusContext;
404
+ *
405
+ * const dispatch = <TName extends keyof Inputs & string>(
406
+ * name: TName,
407
+ * input: Inputs[TName],
408
+ * ): Promise<ToolResultOf<Outputs, TName>> => dispatcher.dispatch(context, name, input);
409
+ *
410
+ * const measured = await dispatch("acme.route.measure", { routeId: "r-1" });
411
+ * console.log(measured.ok ? measured.data.meters : measured.error);
412
+ * ```
413
+ */
414
+ type ToolResultOf<TOutputs, TName> = [TName] extends [never] ? ToolResult : string extends TName ? ToolResult : ToolFailure | ToolSuccessByName<TOutputs>[[TName] extends [keyof TOutputs] ? TName & keyof TOutputs : typeof unstated];
415
+ /**
416
+ * ToolBusDispatch is the structural slice of the bus a chained handler reaches for: the
417
+ * dispatch surface alone. Declared here rather than imported from the bus so this
418
+ * module stays a leaf: a context shapes how the bus looks to a handler without inverting
419
+ * the dependency edge that would make the two a circular pair.
420
+ *
421
+ * `TInputs` maps each tool name to its raw input, defaulting to
422
+ * {@link ToolDispatchRegistry} (the map a host augments), so a handler reaching the
423
+ * context's bus sees the full name union and each tool's input on `dispatch`. Until a host
424
+ * augments it that map is empty, and `dispatch` takes no name.
425
+ *
426
+ * `TOutputs` maps each tool name to the `data` its answer holds, defaulting to
427
+ * {@link ToolOutputRegistry}, the second map a host augments. `dispatch` answers the
428
+ * {@link ToolResult} of the named verb's data, so a reader takes a member of it after `ok` with
429
+ * no narrowing of its own, and a name the map does not hold answers `data` as `unknown`. The
430
+ * bus parses no answer: the type is held by each handler being typed by its contract's `output`,
431
+ * and by the testing bus, which checks every answer against that schema.
432
+ *
433
+ * `dispatch` is the typed entry point: a known literal name and its matching raw input,
434
+ * with a stray field or wrong name a compile error at the call site. `dispatchUnsafe` is
435
+ * the escape hatch for a dynamically-built name (an agent routing a model's
436
+ * tool-call, a bridge mapping a postMessage type) where the name is a runtime `string`
437
+ * the compiler cannot match against the union, and its answer is a plain {@link ToolResult}.
438
+ * A concrete bus always provides both, so the member is required, not optional.
439
+ */
440
+ interface ToolBusDispatch<TCtx, TInputs extends object = ToolDispatchRegistry, TOutputs extends object = ToolOutputRegistry> {
441
+ dispatch<TName extends keyof TInputs & string>(ctx: TCtx, name: TName, rawInput: TInputs[TName]): Promise<ToolResultOf<TOutputs, TName>>;
442
+ dispatchUnsafe(ctx: TCtx, name: string, rawInput: unknown): Promise<ToolResult>;
443
+ }
444
+ /**
445
+ * toolErrorCodeSchema is the closed vocabulary of machine-readable failure codes a
446
+ * ToolResult may carry, the Zod source of truth so a consumer branches on a stable code
447
+ * rather than substring-matching the human-readable message. Its members are
448
+ * {@link toolErrorCodes}, and every one has a real producer:
449
+ *
450
+ * - "canceled": the run was ended by its caller before it produced its answer, such as a
451
+ * recording a cancel, a close or a newer recording stopped. Its own code rather than
452
+ * "internal" because nothing went wrong, and apart from "confirmation-denied", which is a
453
+ * prompt declined before anything ran.
454
+ * - "capability-denied": the context lacks the tool's capability gate.
455
+ * - "collab-locked": a collaborator holds the entity's soft-lock (a REMOTE peer),
456
+ * distinct from "edit-in-progress", which is the LOCAL one-edit-at-a-time gate.
457
+ * - "confirmation-denied": the confirm gate rejected, or was absent for a destructive tool.
458
+ * - "confirmation-timeout": a destructive server-side confirmation window elapsed with no
459
+ * answer. Separate from "confirmation-denied" because nobody refused: re-asking is
460
+ * reasonable here and rude after a refusal.
461
+ * - "conflict": a write lost a revision race (a 409), or a segment's or a waypoint's commit
462
+ * was asked with another draft while the create of that entity is still out, in which case
463
+ * no request is made.
464
+ * - "draft-open": a persisted-only verb was asked for while a draft owns the editor.
465
+ * - "edit-in-progress": another authoring engine is already armed, or a split pick is.
466
+ * - "forbidden": the caller is not allowed to perform the action (a 403).
467
+ * - "internal": an unclassified handler throw or failure (the catch-all).
468
+ * - "invalid-input": the schema rejected the raw input, or a server validation did (a 400).
469
+ * - "limit-reached": a ceiling was reached: one the agreement sets (its seats, its published
470
+ * itineraries, its monthly allowance), the itineraries a personal space keeps, or the co-pilot
471
+ * tabs the studio keeps open. An API refusal is one when an entry carries `LIMIT_REACHED` (a
472
+ * 429 naming no wait) or when a 429 names a wait longer than a minute, and a retry soon does
473
+ * not lift it.
474
+ * - "no-api": the handler needs a data seam the host did not supply. It, "no-map" and
475
+ * "no-session" are the only refusals that describe the STUDIO rather than the request, and
476
+ * they are codes for the same reason every other member is: a surface that can name the
477
+ * category can say something useful ("the studio isn't connected"), where a handler's own
478
+ * `error` string is written for a log and an agent, and a surface rendering it would be
479
+ * showing a reader a sentence nobody translated.
480
+ * - "no-map": the action drives the map and no map is mounted. Transient by nature: the
481
+ * canvas is still loading, so the surface answers "try again in a moment" rather than
482
+ * reporting a fault.
483
+ * - "no-session": the session, draft, wizard or pick the action acts on is not open. The
484
+ * editor is one-at-a-time in several places, and a verb aimed at a closed one is an
485
+ * ordering mistake rather than a failure of the thing it names.
486
+ * - "not-found": the targeted resource does not exist (a 404).
487
+ * - "rate-limited": the caller exceeded a per-minute rate limit (a 429 not coded `LIMIT_REACHED`
488
+ * naming no wait, or a wait of a minute or less), which a moment's wait clears.
489
+ * - "split-on-end": a split point resolved to the very start or end of a segment, where
490
+ * cutting would produce an empty half. Its own code because the surface answers it with
491
+ * "aim further along the line", which a category alone cannot say.
492
+ * - "split-too-far": a split point landed further from the line than the pointing
493
+ * tolerance allows. The fix is "click nearer the itinerary", not "aim elsewhere along it".
494
+ * - "timeout": the request outlived its budget (a 504). Its own code rather than
495
+ * "internal" because nothing is broken: the work was too large, so the surface answers
496
+ * with what would make it smaller.
497
+ * - "unavailable": the device or the page does not give what the action needs, such as a
498
+ * position the device cannot determine or a page with no geolocation. Its own code rather
499
+ * than "internal" because the studio is whole, and apart from "forbidden", which is a
500
+ * permission the reader or the device refused.
501
+ * - "unknown-tool": the dispatched name is not registered.
502
+ * - "upgrade-required": the action needs a product the caller's agreement does not include.
503
+ *
504
+ * The gate codes reuse the spellings the bus's own dispatch event carries, so telemetry
505
+ * and the structured result speak one vocabulary.
506
+ *
507
+ * One spelling, the contract's: every code is kebab-case. A code the contract's
508
+ * `AgentToolErrorCode` also declares is spelled exactly as it is there, because an agent run
509
+ * copies it onto the model's tool result verbatim. The ones {@link busOnlyToolErrorCodes} holds
510
+ * (`no-api`, `no-map`, `no-session`, `split-on-end`, `split-too-far`) never reach the wire at
511
+ * all: `toWireErrorCode` reports each as `internal`, the contract's code for a failure with no
512
+ * more specific one.
513
+ */
514
+ declare const toolErrorCodeSchema: z$1.ZodEnum<{
515
+ readonly canceled: "canceled";
516
+ readonly "capability-denied": "capability-denied";
517
+ readonly "collab-locked": "collab-locked";
518
+ readonly "confirmation-denied": "confirmation-denied";
519
+ readonly "confirmation-timeout": "confirmation-timeout";
520
+ readonly conflict: "conflict";
521
+ readonly "draft-open": "draft-open";
522
+ readonly "edit-in-progress": "edit-in-progress";
523
+ readonly forbidden: "forbidden";
524
+ readonly internal: "internal";
525
+ readonly "invalid-input": "invalid-input";
526
+ readonly "limit-reached": "limit-reached";
527
+ readonly "no-api": "no-api";
528
+ readonly "no-map": "no-map";
529
+ readonly "no-session": "no-session";
530
+ readonly "not-found": "not-found";
531
+ readonly "rate-limited": "rate-limited";
532
+ readonly "split-on-end": "split-on-end";
533
+ readonly "split-too-far": "split-too-far";
534
+ readonly timeout: "timeout";
535
+ readonly unavailable: "unavailable";
536
+ readonly "unknown-tool": "unknown-tool";
537
+ readonly "upgrade-required": "upgrade-required";
538
+ }>;
539
+ /**
540
+ * ToolErrorCode is the machine-readable failure code a ToolResult may carry, derived
541
+ * from {@link toolErrorCodeSchema}.
542
+ */
543
+ type ToolErrorCode = z$1.infer<typeof toolErrorCodeSchema>;
544
+ /**
545
+ * ToolResult is the structured outcome every handler returns: success carries a
546
+ * human/model-readable summary (and optional data); failure carries an error string and,
547
+ * when classified, a machine-readable {@link ToolErrorCode}. `code` is optional and
548
+ * additive: an unclassified failure omits it, while a classified one carries it so a
549
+ * consumer branches on the code rather than substring-matching the message. The bus
550
+ * boundary stamps the gate codes; a handler stamps the codes it knows.
551
+ *
552
+ * **`summary` and `error` are MACHINE NARRATION and must never be rendered to a user.** They
553
+ * are written for three readers and a person is none of them: a model deciding what to do next,
554
+ * an event log, and whoever is reading that log. They are in English because this package has no
555
+ * language (it ships no strings and takes no locale), so a surface that put one on screen would
556
+ * be showing a French reader an English sentence nobody translated, in a voice written for a
557
+ * model. What a surface renders instead is `detail` when the server supplied one, and otherwise
558
+ * its own copy for the `code`. `studio-react`'s boundary test refuses a render of either field.
559
+ *
560
+ * `detail` is the server's own already-localized sentence for the failure, lifted off the
561
+ * error envelope. It is deliberately separate from `error`, which stays the technical
562
+ * string analytics and an agent read. A code alone can only say a category
563
+ * (`invalid-input`), while `detail` says which input and why, so a surface prefers it when
564
+ * present and falls back to its own per-code copy when it is not. This package carries NO
565
+ * strings: it forwards the server's verbatim and never translates.
566
+ *
567
+ * `data` is a required member where `TData` leaves `undefined` out, and an optional one
568
+ * otherwise. So a reader of a verb whose data is an object takes a member of it after `ok` with
569
+ * no narrowing of its own, and a handler that leaves the data out does not compile. A bare
570
+ * `ToolResult`, whose data is `unknown`, and a `ToolResult<undefined>`, the answer of a verb with
571
+ * no data, both hold it as optional: neither says there is anything to read.
572
+ *
573
+ * The condition tests the whole of `TData` at once, so a union is one answer and never one
574
+ * result per member. It is written with `TData` on the checked side, against every value but
575
+ * `undefined`, which is what lets TypeScript relate the results of two unresolved data types by
576
+ * relating the data: a {@link Tool} stating an `output` is assignable to a bare one on that
577
+ * account. The same test written as `undefined extends TData` puts the type on the far side,
578
+ * where two unresolved types have to be identical.
579
+ */
580
+ type ToolResult<TData = unknown> = ([TData] extends [NonNullable<unknown> | null] ? {
581
+ data: TData;
582
+ ok: true;
583
+ summary: string;
584
+ } : {
585
+ data?: TData | undefined;
586
+ ok: true;
587
+ summary: string;
588
+ }) | {
589
+ code?: ToolErrorCode | undefined;
590
+ detail?: string | undefined;
591
+ error: string;
592
+ ok: false;
593
+ };
594
+ /**
595
+ * ToolFailure is the refusal arm of {@link ToolResult}: an `error`, with a {@link ToolErrorCode}
596
+ * when the failure is classified and the server's `detail` when it sent one.
597
+ *
598
+ * Named so a signature that can only fail says so: `isConfirmationWithheld` narrows to it, and a
599
+ * handler's guard returns the failure, or null to carry on. An inline
600
+ * `{ error: string; ok: false }` is the same shape only until the arm grows a member: a copy
601
+ * without `code` fails to compile at the guard that sets one, which is the good case, and drops
602
+ * the code from a refusal that passes through it, which is the silent one.
603
+ */
604
+ type ToolFailure = Extract<ToolResult, {
605
+ ok: false;
606
+ }>;
607
+ /**
608
+ * Tool is the unit of the bus: a stable namespaced name, a model-facing description, a
609
+ * Zod input schema (→ runtime validation + types + JSON Schema), a capability gate, an
610
+ * optional destructive-confirmation flag, an optional confirmation policy, and a handler
611
+ * taking (ctx, input). `confirmation` is honored only when `requiresConfirmation` is set.
612
+ *
613
+ * `TCtx` is the execution context the host threads through: the one part of a tool that
614
+ * cannot be published, and therefore the parameter that lets the rest of it be.
615
+ *
616
+ * The optional `TName` parameter pins `name` to a string literal. A bare `Tool<Ctx>`
617
+ * leaves it the open `string`, while a definition supplying its own name lets a registry
618
+ * require, at compile time, that each entry's key equals the tool's own name, so a typo
619
+ * in either is a type error rather than a runtime drift a test has to catch.
620
+ *
621
+ * `agentHidden` opts a tool out of the model-facing manifest: a hidden tool stays fully
622
+ * registered and dispatchable (a human click or an internal chain runs it as it runs
623
+ * any other) and is refused only at the model entry point. It marks the tools a system
624
+ * prompt categorically forbids, so the model is never even offered them rather than the
625
+ * prompt alone holding the line.
626
+ *
627
+ * `TCapability` is how a host closes {@link ToolCapability} again on its own side. The published
628
+ * union is open, because the words this package can define are not an authorization model;
629
+ * a host that has one binds its own enum here once (`Tool<Ctx, TSchema, TName, MyCapability>`),
630
+ * and a mistyped capability is then a compile error at the definition rather than a refusal at
631
+ * runtime. It has to be a parameter rather than something a host narrows by intersecting: an
632
+ * intersection stops being the same generic interface, and the comparison falls off the variance
633
+ * path onto a structural one that `confirmationValues` cannot satisfy.
634
+ *
635
+ * `TOutput` is the Zod schema of the `data` the tool answers, and it types the handler: one that
636
+ * returns other data, or none where the schema asks for some, does not compile. Left at its
637
+ * default the data is `unknown` and the handler answers a plain {@link ToolResult}, so a tool
638
+ * declared as a bare `Tool<Ctx>` compiles with or without an `output`.
639
+ */
640
+ interface Tool<TCtx, TSchema extends z$1.ZodTypeAny = z$1.ZodTypeAny, TName extends string = string, TCapability extends ToolCapability = ToolCapability, TOutput extends z$1.ZodTypeAny = z$1.ZodTypeAny> {
641
+ agentHidden?: boolean | undefined;
642
+ capability: TCapability;
643
+ confirmation?: ToolConfirmation | undefined;
644
+ /**
645
+ * confirmationValues resolves the interpolation values the confirm surface fills this
646
+ * tool's policy keys with, so a prompt can name the entities it is about to act on. It
647
+ * runs AFTER the input parses and BEFORE the handler, with the same context the handler
648
+ * will get, so it may read state to turn ids into names.
649
+ *
650
+ * It must produce a plain record and nothing else: no writes, no dispatch. A resolver
651
+ * that throws costs only the interpolation: the prompt still opens, rendering its
652
+ * placeholders verbatim, so a bad resolver can never turn a confirmable action into a
653
+ * rejected dispatch.
654
+ *
655
+ * @default undefined, and the prompt renders its placeholders verbatim
656
+ */
657
+ confirmationValues?: ((ctx: TCtx, input: z$1.infer<TSchema>) => ConfirmationValues) | undefined;
658
+ description: string;
659
+ handler: (ctx: TCtx, input: z$1.infer<TSchema>) => ToolResult<z$1.infer<TOutput>> | Promise<ToolResult<z$1.infer<TOutput>>>;
660
+ input: TSchema;
661
+ name: TName;
662
+ /**
663
+ * output is the Zod schema of the `data` an `ok` answer holds, stated beside `input`.
664
+ *
665
+ * It is what the handler is typed by, and the bus that ships never parses with it: what a
666
+ * handler returns is what a reader reads. The testing bus is where it runs, against every
667
+ * answer of the tool. A verb that answers no data states `toolNoDataSchema`.
668
+ *
669
+ * It is transform-free for that reason. A schema that changes what it parses describes a value
670
+ * no reader receives.
671
+ *
672
+ * @default undefined, and the data is `unknown`
673
+ */
674
+ output?: TOutput | undefined;
675
+ /**
676
+ * precondition answers what the tool refuses before it asks: a {@link ToolFailure} for a call
677
+ * the tool can already tell it refuses, or null to carry on.
678
+ *
679
+ * The bus runs it after the input parses and before the confirmation, with the context the
680
+ * handler gets, and runs it for a tool that asks nothing as well. A failure it answers is the
681
+ * dispatch's answer: no prompt is raised and the handler never runs, so a reader is never asked
682
+ * to approve what the tool then refuses. One that throws is answered as a handler that throws
683
+ * is.
684
+ *
685
+ * It reads state and writes nothing, as `confirmationValues` does, and it answers at once: a
686
+ * check that waits on a request is the handler's. The handler keeps every refusal it states
687
+ * here, because what a precondition read can change while the reader is asked.
688
+ *
689
+ * @default undefined, and nothing is refused ahead of the confirmation
690
+ */
691
+ precondition?: ((ctx: TCtx, input: z$1.infer<TSchema>) => ToolFailure | null) | undefined;
692
+ requiresConfirmation?: boolean | undefined;
693
+ }
694
+ /**
695
+ * JsonSchema is a JSON Schema object as produced by `z.toJSONSchema`: the shape a
696
+ * manifest renders a tool's input into for a model or a documentation page. Reusing Zod's
697
+ * own type keeps a manifest entry assignable to a gateway's `parameters` object with no
698
+ * cast.
699
+ */
700
+ type JsonSchema = z$1.core.JSONSchema.BaseSchema;
701
+ /**
702
+ * StudioToolManifestEntry is the model/UI-facing description of one of the STUDIO's tools, with
703
+ * the input schema rendered as JSON Schema.
704
+ *
705
+ * `Studio` in the name because `@mountaya/elements/agent` publishes a `ToolManifestEntry` of its
706
+ * own, and the two are not the same shape: that one is what the agent SESSION consumes, typed
707
+ * against the agent service's `parameters`, where this is what a studio PRODUCES, typed against
708
+ * the studio's capability vocabulary and Zod's JSON Schema. One name for both would hand a
709
+ * consumer importing the obvious one a type error several frames from the import.
710
+ */
711
+ interface StudioToolManifestEntry {
712
+ capability: ToolCapability;
713
+ description: string;
714
+ inputSchema: JsonSchema;
715
+ name: string;
716
+ /**
717
+ * Whether the tool only reads state and changes nothing. Absent means unknown, which
718
+ * every consumer must treat as "may mutate": a run uses it to decide what its
719
+ * transcript may safely drop, and guessing wrong there erases the record of a real
720
+ * change.
721
+ */
722
+ readOnly?: boolean | undefined;
723
+ requiresConfirmation: boolean;
724
+ }
725
+ /** Activity is an activity of the contract's catalog: the contract's `RestSchema.Activity`. */
726
+ type Activity = RestSchema.Activity;
727
+ /**
728
+ * ActivityCapabilities is what an activity can be planned with: the contract's
729
+ * `RestSchema.ActivityCapabilities`.
730
+ */
731
+ type ActivityCapabilities = RestSchema.ActivityCapabilities;
732
+ /**
733
+ * CategoryActivities is the activities of one catalog category: the contract's
734
+ * `RestSchema.CategoryActivities`.
735
+ */
736
+ type CategoryActivities$1 = RestSchema.CategoryActivities;
737
+ /**
738
+ * CollabEntityKind is the kinds of entity a collaborator locks: the contract's
739
+ * `RestSchema.CollabEntityKind`.
740
+ */
741
+ type CollabEntityKind = RestSchema.CollabEntityKind;
742
+ /**
743
+ * Collection is a folder of itineraries and zones: the contract's `RestSchema.Collection`.
744
+ */
745
+ type Collection$1 = RestSchema.Collection;
746
+ /**
747
+ * EmbeddedStudioDefaultProps is an organization's default embed configuration: the contract's
748
+ * `RestSchema.EmbeddedStudioDefaultProps`.
749
+ */
750
+ type EmbeddedStudioDefaultProps = RestSchema.EmbeddedStudioDefaultProps;
751
+ /**
752
+ * EmbeddedStudioSafetyRules is the safety rules an embed is held to: the contract's
753
+ * `RestSchema.EmbeddedStudioSafetyRules`.
754
+ */
755
+ type EmbeddedStudioSafetyRules = RestSchema.EmbeddedStudioSafetyRules;
756
+ /**
757
+ * ExportFormat is a file format an itinerary exports to: the contract's
758
+ * `RestSchema.ExportFormat`.
759
+ */
760
+ type ExportFormat$1 = RestSchema.ExportFormat;
761
+ /** ExportVariant is a variant of an export format: the contract's `RestSchema.ExportVariant`. */
762
+ type ExportVariant$1 = RestSchema.ExportVariant;
763
+ type ImportGranularity = RestSchema.ImportGranularity;
764
+ /**
765
+ * ImportRecommendationReason is why an import preview recommends a granularity: the contract's
766
+ * `RestSchema.ImportRecommendationReason`.
767
+ */
768
+ type ImportRecommendationReason = RestSchema.ImportRecommendationReason;
769
+ /**
770
+ * ImportWarning is a warning an import preview raises: the contract's `RestSchema.ImportWarning`.
771
+ */
772
+ type ImportWarning = RestSchema.ImportWarning;
773
+ /** Itinerary is an itinerary as the REST API answers it: the contract's `RestSchema.Itinerary`. */
774
+ type Itinerary = RestSchema.Itinerary;
775
+ type ItineraryImportPreview = RestSchema.ItineraryImportPreview;
776
+ /** Locales is the REST API's locale vocabulary: the contract's `RestSchema.Locales`. */
777
+ type Locales = RestSchema.Locales;
778
+ /** ManeuverType is a routing maneuver: the contract's `RestSchema.ManeuverType`. */
779
+ type ManeuverType = RestSchema.ManeuverType;
780
+ /**
781
+ * OrganizationRole is a member's role in an organization: the contract's
782
+ * `RestSchema.OrganizationRole`.
783
+ */
784
+ type OrganizationRole = RestSchema.OrganizationRole;
785
+ /**
786
+ * RestLanguage is the contract's `RestSchema.Language`: the lowercase REST spelling (`"en"`),
787
+ * named apart from the Data API's uppercase vocabulary, which this package spells
788
+ * `dataLanguageSchema`.
789
+ */
790
+ type RestLanguage = RestSchema.Language;
791
+ /** SurfaceType is a surface type of the analysis: the contract's `RestSchema.SurfaceType`. */
792
+ type SurfaceType = RestSchema.SurfaceType;
793
+ /**
794
+ * TrailDifficultyType is a trail difficulty grade of the analysis: the contract's
795
+ * `RestSchema.TrailDifficultyType`.
796
+ */
797
+ type TrailDifficultyType = RestSchema.TrailDifficultyType;
798
+ type UnitLength = RestSchema.UnitLength;
799
+ /** UnitPace is the form a travel rate is stated in: the contract's `RestSchema.UnitPace`. */
800
+ type UnitPace = RestSchema.UnitPace;
801
+ type UnitSlope = RestSchema.UnitSlope;
802
+ /** UnitTemperature is a temperature unit: the contract's `RestSchema.UnitTemperature`. */
803
+ type UnitTemperature = RestSchema.UnitTemperature;
804
+ /** WaypointAmenity is an amenity a waypoint lists: the contract's `RestSchema.WaypointAmenity`. */
805
+ type WaypointAmenity = RestSchema.WaypointAmenity;
806
+ /** WaypointIcon is a waypoint's glyph: the contract's `RestSchema.WaypointIcon`. */
807
+ type WaypointIcon = RestSchema.WaypointIcon;
808
+ /**
809
+ * WaypointPropertyFormat is the format of a customer-defined waypoint field: the contract's
810
+ * `RestSchema.WaypointPropertyFormat`.
811
+ */
812
+ type WaypointPropertyFormat = RestSchema.WaypointPropertyFormat;
813
+ /**
814
+ * WaypointTiming is a waypoint's cut-off and stop timing: the contract's
815
+ * `RestSchema.WaypointTiming`.
816
+ */
817
+ type WaypointTiming = RestSchema.WaypointTiming;
818
+ type WaypointUpdateParams$1 = RestSchema.WaypointUpdateParams;
819
+ /** WayType is a way type of the analysis: the contract's `RestSchema.WayType`. */
820
+ type WayType = RestSchema.WayType;
821
+ /** Zone is a zone as the REST API answers it: the contract's `RestSchema.Zone`. */
822
+ type Zone$1 = RestSchema.Zone;
823
+ type ZoneSource = RestSchema.ZoneSource;
824
+ /**
825
+ * The chain a segment list renders, folded once into the models its rows and gutters read.
826
+ *
827
+ * Every one of these is derived from the COMMITTED chain rather than from whatever a list happens
828
+ * to be showing, and that is the rule the whole module keeps: a list also renders the segment
829
+ * currently being drawn and the one being inserted into a gap, neither of which the API knows
830
+ * about. Answering "which row is the tail" positionally over the rendered list is what lets a real
831
+ * tail offer a merge it has no successor for and lose its own Delete.
832
+ *
833
+ * They are folds rather than per-row lookups for a second reason, and it is a performance one that
834
+ * shows up as correctness: a list re-renders on every peer-lock frame and on every throttled tick
835
+ * of an open edit, and a per-row derivation would rescan the chain once per row. Each of these
836
+ * walks it once and hands back objects a memoised row can compare by reference.
837
+ */
838
+ /**
839
+ * SegmentMergeRefusal names why two adjacent segments cannot be fused: they are drawn by different
840
+ * engines, they sit on either side of a group boundary, the fused itinerary would ask the router
841
+ * for more waypoints than it accepts, or a collaborator holds one of them.
842
+ *
843
+ * Each is a condition the merge tool refuses on, which is the point: surfacing one turns a round
844
+ * trip into an explanation the user reads before reaching for the verb.
845
+ *
846
+ * The order below is the order they are evaluated in: the structural reasons first, because none of
847
+ * them resolves on its own and each names a fix (change the engine, leave the group, simplify one
848
+ * of the two), then the lock, which clears when the peer moves on.
849
+ *
850
+ * One refusal of the API has no reason here: a freehand pair whose joined line holds more drawn
851
+ * vertices than a segment stores (`segments.merge_positions_max`). The API counts them after its
852
+ * own cleaning pass over the joined line, which drops the vertices that sit within a few meters of
853
+ * the line through their neighbours, and the studio holds no copy of that pass. A count taken
854
+ * before it would grey out merges the API makes. So the merge stays offered, and a refused one
855
+ * answers with the API's own sentence, which the verb's failure carries as its `detail`.
856
+ */
857
+ type SegmentMergeRefusal = "engine" | "group" | "waypointsMax" | "locked";
858
+ /**
859
+ * SegmentChainMerge is one fusion the chain offers: the segment folded into its successor, the
860
+ * successor it folds into, and why the verb is inert when it is. A null reason is a live merge.
861
+ *
862
+ * `intoSegmentId` rides alongside the id the verb acts on because a surface previews its own
863
+ * operands (reaching for the control lights BOTH segments), so the pair is resolved with the model
864
+ * rather than read back out of the list at pointer time.
865
+ */
866
+ interface SegmentChainMerge {
867
+ readonly disabledReason: SegmentMergeRefusal | null;
868
+ readonly intoSegmentId: string;
869
+ readonly segmentId: string;
870
+ }
871
+ /**
872
+ * SegmentChainMerges is the same merge objects indexed twice: by the segment that FOLDS DOWN and by
873
+ * the one that ABSORBS it.
874
+ *
875
+ * A row's two menu items ask opposite questions about one pair ("can I fold into the row below" and
876
+ * "can the row above fold into me"), and a gutter asks the first of them about the row above it.
877
+ * Deriving both indexes in the single walk that already builds the merges is what makes those three
878
+ * readings unable to disagree.
879
+ *
880
+ * A MISSING entry is itself an answer, and the two ends are asymmetric: no `byFolded` entry means
881
+ * there is nothing below to fold into (the tail), and no `byAbsorber` entry means there is nothing
882
+ * above to be folded into it (the head).
883
+ */
884
+ interface SegmentChainMerges {
885
+ readonly byAbsorber: ReadonlyMap<string, SegmentChainMerge>;
886
+ readonly byFolded: ReadonlyMap<string, SegmentChainMerge>;
887
+ }
888
+ /**
889
+ * buildSegmentChainMerges resolves every adjacent pair of the committed chain into the merge it
890
+ * offers, or into the reason it does not.
891
+ *
892
+ * `lockedSegmentIds` is the set a collaborator currently holds. It arrives resolved rather than
893
+ * as a lock map because who holds what is a session concern and the shape of that session is the
894
+ * host's; what this needs to know is only whether either side of a pair is spoken for.
895
+ */
896
+ declare const buildSegmentChainMerges: (segments: readonly ItinerarySegment$1[], lockedSegmentIds?: ReadonlySet<string>) => SegmentChainMerges;
897
+ /**
898
+ * SegmentChainEnds is which rows the API knows about, and which two of them are the real ends of
899
+ * the chain: the facts every chain verb is gated on.
900
+ */
901
+ interface SegmentChainEnds {
902
+ readonly committedIds: ReadonlySet<string>;
903
+ readonly firstCommittedId: string | null;
904
+ readonly lastCommittedId: string | null;
905
+ }
906
+ /** segmentChainEnds folds the committed chain into {@link SegmentChainEnds}. */
907
+ declare const segmentChainEnds: (segments: readonly ItinerarySegment$1[]) => SegmentChainEnds;
908
+ /**
909
+ * SegmentGroupRun is one row's place in the chain's grouping.
910
+ *
911
+ * `group` is the group it belongs to, or null. `isFirst` / `isLast` are the ends of the RUN,
912
+ * which is what lets only those two leave without splitting it. `memberCount` is the run's size,
913
+ * so a surface can say that leaving a two-member group dissolves it rather than offering the
914
+ * same wording for an act that also destroys the group's name and colour. `hasFreeNeighbour`
915
+ * answers the other direction: grouping needs an ungrouped segment beside this one, and with
916
+ * none the verb is shown refused rather than hidden, so the absence explains itself.
917
+ */
918
+ interface SegmentGroupRun {
919
+ readonly group: ItinerarySegmentGroup$1 | null;
920
+ readonly hasFreeNeighbour: boolean;
921
+ readonly isFirst: boolean;
922
+ readonly isLast: boolean;
923
+ readonly memberCount: number;
924
+ }
925
+ /**
926
+ * buildSegmentGroupRuns folds the chain's grouping into a per-segment model, keyed by segment id.
927
+ *
928
+ * The membership counts come from ONE pass over the chain rather than from asking it per row: doing
929
+ * that inside the per-row walk rescans it once per member, which is quadratic on exactly the
930
+ * itineraries grouping exists for: a long chain where most rows belong to a run.
931
+ *
932
+ * A segment whose `group_id` names no group in `groups` reads as ungrouped, which is the honest
933
+ * answer while a group delete and the chain that referenced it are landing a frame apart. It reads
934
+ * so to its neighbours too: it is a free neighbour to the rows either side of it.
935
+ */
936
+ declare const buildSegmentGroupRuns: (segments: readonly ItinerarySegment$1[], groups: readonly ItinerarySegmentGroup$1[]) => ReadonlyMap<string, SegmentGroupRun>;
937
+ /**
938
+ * segmentGroupDissolvesOnLeave says whether one member leaving takes the whole group with it.
939
+ *
940
+ * Leaving is a range change, not a delete, unless it would leave a single member behind, which is
941
+ * not a group at all. Both are the same user intent expressed against the floor the rule imposes,
942
+ * and stating the test once here is what keeps the menu's wording and the verb's behaviour from
943
+ * answering it differently.
944
+ */
945
+ declare const segmentGroupDissolvesOnLeave: (memberCount: number) => boolean;
946
+ /**
947
+ * The sections the table reads, named so a caller can scope to exactly them.
948
+ *
949
+ * Narrow rather than the whole bundle, because the surfaces that raise these prompts resolve a
950
+ * SCOPED bundle (the confirmation gate reads `confirm`, the agent's own turn reads `prompt`), and
951
+ * neither of them holds the sections it never renders. Written as a `Pick` over the groups the
952
+ * entries below actually name, so an entry that names another group is a compile error here
953
+ * rather than a blank sentence in a dialog asking the user to approve an irreversible act.
954
+ */
955
+ type ConfirmSentenceStrings = Pick<StudioStrings, "confirm" | "editing" | "editor" | "share">;
956
+ /** CONFIRM_COPY_LABELS is the set the table answers, for the gate that holds it to the registry. */
957
+ declare const CONFIRM_COPY_LABELS: readonly string[];
958
+ /**
959
+ * confirmSentence resolves one label a confirmation policy named, or `undefined` when the policy
960
+ * did not name that field, which is how a tool asks for the generic prompt, so the caller's
961
+ * fallback is the intended answer and not an error.
962
+ *
963
+ * An UNKNOWN label answers `undefined` too, and that is deliberate: a generic prompt is a worse
964
+ * dialog than a specific one but it is still a true one, where an echoed identifier is neither.
965
+ * `confirmCopy.test.ts` is what stops a label reaching here unknown in the first place.
966
+ *
967
+ * @param copy The studio's copy the sentence is read from.
968
+ * @param label The label the policy named, such as `share.rotateConfirm.title`.
969
+ * @param values The values the sentence interpolates.
970
+ * @default values {}
971
+ * @returns The sentence, or `undefined` for a label that is absent or unknown.
972
+ */
973
+ declare const confirmSentence: (copy: ConfirmSentenceStrings, label: string | undefined, values?: ConfirmationValues) => string | undefined;
974
+ /**
975
+ * DraftEditorFlow names which flow's draft a draft surface edits: `import` or
976
+ * `suggest`. It is the ONE axis the two flows differ on: it selects the per-flow
977
+ * tool names the name/organization/privacy/collections fields and the commit
978
+ * button dispatch through, while every read goes through the neutral active-draft
979
+ * session selector. So a draft form renders identically for both flows and only
980
+ * the dispatch targets differ.
981
+ */
982
+ type DraftEditorFlow = "import" | "suggest";
983
+ /**
984
+ * DraftEditorToolNames is the per-flow bundle of mutation tool names a draft
985
+ * surface dispatches: the name/organization/privacy/collections setters that
986
+ * write the draft session's commit-time fields, and the commit verb that persists
987
+ * the draft. It also carries the studio-namespace i18n key for the commit button's
988
+ * label so the per-flow copy stays centralized here rather than branching at the
989
+ * footer. Resolved from the flow once during render so a draft surface never
990
+ * branches on the flow past that one resolution. The values are tool-NAME string
991
+ * literals (and one i18n key) only, with no import of a tool contract, so this
992
+ * module stays a leaf the bus boundary still validates each name against when a
993
+ * field dispatches it.
994
+ */
995
+ interface DraftEditorToolNames {
996
+ /**
997
+ * setActivity re-scopes the draft's routing profile. Only the import flow's
998
+ * chooser is live in staging (it re-previews from the retained source), but both
999
+ * namespaces carry the verb, so the bundle names it for either.
1000
+ */
1001
+ setActivity: "studio.itinerary.import.setActivity" | "studio.itinerary.suggest.setActivity";
1002
+ commit: "studio.itinerary.import.confirm" | "studio.itinerary.suggest.commit";
1003
+ /**
1004
+ * commitLabel names the Create button's wording on the copy bundle's itinerary
1005
+ * form group: `createDraft` for the import flow and `createFromSuggestion` for the
1006
+ * suggest flow, a key each, so a host words the two apart. A property name rather than
1007
+ * a sentence, so the two flows stay one line apart here and the wording stays where
1008
+ * every other word lives.
1009
+ */
1010
+ commitLabel: Extract<keyof StudioStrings["itineraryForm"], "createDraft" | "createFromSuggestion">;
1011
+ setCollections: "studio.itinerary.import.setCollections" | "studio.itinerary.suggest.setCollections";
1012
+ setName: "studio.itinerary.import.setName" | "studio.itinerary.suggest.setName";
1013
+ setOrganization: "studio.itinerary.import.setOrganization" | "studio.itinerary.suggest.setOrganization";
1014
+ setPrivate: "studio.itinerary.import.setPrivate" | "studio.itinerary.suggest.setPrivate";
1015
+ }
1016
+ /**
1017
+ * EMPTY_STRINGS is the one empty list a draft-session selector answers for the collections and
1018
+ * the warnings of a session, or of a preview, that carries none.
1019
+ *
1020
+ * One reference for every reader: a fresh `[]` per call is a new value each time, which defeats a
1021
+ * shallow equality and spins a store snapshot into a render loop. Frozen and typed `readonly`
1022
+ * because it is shared: a write throws a `TypeError` and does not compile, where a push that
1023
+ * landed would be read by every other selector as an entry nobody stated. A caller that needs a
1024
+ * list it can write to copies it (`[...EMPTY_STRINGS]`).
1025
+ */
1026
+ declare const EMPTY_STRINGS: readonly string[];
1027
+ /**
1028
+ * toolNamesFor resolves the per-flow tool names a draft surface dispatches. The
1029
+ * two flows expose the same setter + commit verbs under their own namespaces, so
1030
+ * a draft surface reads the active draft session generically and only the
1031
+ * dispatch targets switch on the flow.
1032
+ *
1033
+ * @param flow The flow whose draft the surface edits.
1034
+ * @returns The flow's setter and commit verbs, and its commit button's key.
1035
+ */
1036
+ declare const toolNamesFor: (flow: DraftEditorFlow) => DraftEditorToolNames;
1037
+ /**
1038
+ * failureAlertFor turns a refused dispatch into the alert to raise for it, or `null` for the
1039
+ * cases that are not failures at all.
1040
+ *
1041
+ * The answer is what `studio.alert.show` takes: an `info` or `error` level and a message of at
1042
+ * most 280 characters ({@link MAP_ALERT_MESSAGE_MAX}). A rule rather than a binding's own logic,
1043
+ * because every surface that reports a refused dispatch asks the same question; a binding decides
1044
+ * only where the alert goes, and a surface reading this can see the whole decision at once.
1045
+ *
1046
+ * The line is clamped to that limit, because it ends with the SERVER's own sentence, which
1047
+ * carries no client-side length bound: a long refusal would otherwise fail the alert tool's own
1048
+ * boundary parse and show the reader nothing at all. Clamping keeps the worst case a truncated
1049
+ * sentence rather than a silent one.
1050
+ *
1051
+ * `action` is the already-localized sentence for what the user just tried ("This segment could
1052
+ * not be saved."), resolved by the caller rather than named as a key here. A key would have to
1053
+ * be a key of SOMETHING (one i18n namespace, one string table), and the callers do not share
1054
+ * one: a map surface reads the published `ElementsStrings`, the studio's own surfaces read its
1055
+ * copy bundle. A resolved string is the one shape both can supply.
1056
+ *
1057
+ * The reason is resolved most specific first:
1058
+ *
1059
+ * 1. `result.detail`, the server's own already-localized sentence lifted off the REST envelope.
1060
+ * It names the actual refusal ("The split point is too close to the start or the end of the
1061
+ * segment"), which no per-code copy can reproduce, so it wins when present and not blank;
1062
+ * 2. `failure[code]` for the classified failure code: the category, when the server gave no
1063
+ * prose;
1064
+ * 3. `failure.generic`, when the failure carries no code, or a code the copy holds no sentence
1065
+ * for (a host's own tool may answer one).
1066
+ *
1067
+ * These outcomes are handled apart from that chain, because none of them is something that went
1068
+ * wrong:
1069
+ *
1070
+ * - a successful result answers `null`, so a caller can hand this every result rather than
1071
+ * branching first;
1072
+ * - a withheld confirmation answers `null` too, for the reason {@link isConfirmationWithheld}
1073
+ * gives;
1074
+ * - `edit-in-progress` is the one-edit-at-a-time gate refusing a second session. It answers at
1075
+ * `info` with the shared "finish or cancel your current edit first" copy, so the block reads as
1076
+ * a rule of the editor rather than a fault, and it drops the action prefix: the rule is the
1077
+ * whole message, and naming what it refused would read as a fault report for something the
1078
+ * editor is simply not doing yet.
1079
+ * - a refusal met while a create's request is out ({@link refusedForCreate}: the one-edit
1080
+ * refusal of a create, or the `conflict` of a staged draft's held session) answers at `info`
1081
+ * with `failure.createInProgress`, since nothing is for the reader to finish, cancel or reload.
1082
+ * - a refusal that answers the write's `Idempotency-Key` ({@link keyedWriteOf}) answers at
1083
+ * `info` with `failure.writeRunning` for a write still being made and `failure.writeMade` for
1084
+ * one the API made: the write is being saved, or was, so nothing is to be asked for again.
1085
+ *
1086
+ * It classifies on the structured `code` rather than on the message text, which is what lets the
1087
+ * reason chain and the carve-outs read the same vocabulary the bus stamps; the one `error` it
1088
+ * reads is that of a refusal met while a create is out ({@link refusedForCreate}), and the tag
1089
+ * the bus opens a keyed write's refusal with ({@link keyedWriteOf}). The copy for
1090
+ * that vocabulary is keyed by the code itself, and a code it holds no sentence for reads as
1091
+ * `failure.generic`.
1092
+ *
1093
+ * @example
1094
+ * ```ts
1095
+ * declare const itineraryId: string;
1096
+ * declare const segmentId: string;
1097
+ *
1098
+ * const result = await bus.dispatch(ctx, "studio.itinerary.segment.remove", {
1099
+ * itineraryId,
1100
+ * segmentId,
1101
+ * });
1102
+ * const alert = failureAlertFor(
1103
+ * result,
1104
+ * "This segment could not be deleted.",
1105
+ * studioStrings.en.failure,
1106
+ * );
1107
+ * if (alert !== null) {
1108
+ * void bus.dispatch(ctx, "studio.alert.show", alert);
1109
+ * }
1110
+ * ```
1111
+ */
1112
+ declare const failureAlertFor: (result: ToolResult, action: string, failure: StudioStrings["failure"]) => {
1113
+ level: "error" | "info";
1114
+ message: string;
1115
+ } | null;
1116
+ /**
1117
+ * The alert/field split a studio form shows when an action did not take, resolved from the
1118
+ * published copy.
1119
+ *
1120
+ * It sits beside the copy bundle it reads, and every import in this module resolves inside its
1121
+ * own package. Nothing here renders. A refusal maps to a sentence and a field the same way for a
1122
+ * React dialog, a Flutter form and a command-line tool, which is what makes this the studio's
1123
+ * business rather than a binding's.
1124
+ */
1125
+ /**
1126
+ * FormErrorCopy is the `formError` section of the studio's published copy, and the whole of
1127
+ * what these mappers read.
1128
+ *
1129
+ * Narrow rather than the whole bundle, and the copy rather than an i18next `t`: the section
1130
+ * already has the shape the resolution needs (a message per code, plus a nested object per
1131
+ * resource for the codes whose wording differs by entity), so a lookup reads a property
1132
+ * instead of building a dotted key that nothing checks.
1133
+ */
1134
+ type FormErrorCopy = StudioStrings["formError"];
1135
+ /**
1136
+ * FormErrorResource names the entity a form governs, which selects the
1137
+ * resource-specific error copy when a code has a per-resource message (a name
1138
+ * `conflict` reads differently for an itinerary than a collection). It is open to
1139
+ * the families the studio forms and the dialogs cover; a resource with no
1140
+ * specialized copy for a given code falls back to the generic per-code message.
1141
+ */
1142
+ type FormErrorResource = "collection" | "itinerary" | "organization" | "zone";
1143
+ /**
1144
+ * FormErrorOptions carry the copy section the message resolves through and, where the form governs
1145
+ * a resource's name, the resource it is specialized for. Kept a small config object (not React) so
1146
+ * the mapper is a pure function a panel, a dialog, or a unit test can call the same way.
1147
+ */
1148
+ interface FormErrorOptions {
1149
+ /** The section the message is read from. */
1150
+ copy: FormErrorCopy;
1151
+ /**
1152
+ * The resource whose own `conflict` sentence a conflict reads: that sentence speaks of the
1153
+ * resource's name. Omitted for a refusal about no resource's name (a share link), which reads
1154
+ * the shared `conflict` line.
1155
+ */
1156
+ resource?: FormErrorResource | undefined;
1157
+ }
1158
+ /**
1159
+ * mapToolError turns a failed `ToolResult` into the one sentence a form shows above its footer.
1160
+ *
1161
+ * It reads the failure's machine-readable `code` and its `detail`, most specific first:
1162
+ *
1163
+ * 1. for a refusal met while a create's request is out (the one-edit refusal of a create, or
1164
+ * the `conflict` of a staged draft's held session), `formError.createInProgress`
1165
+ * ({@link refusedForCreate});
1166
+ * 2. for a refusal that answers the write's `Idempotency-Key` ({@link keyedWriteOf}),
1167
+ * `formError.writeRunning` for a write still being made and `formError.writeMade` for one
1168
+ * the API made, neither of which asks for the write again;
1169
+ * 3. for a write made conditional on a version the resource has moved past ({@link
1170
+ * versionMoved}), the shared `formError.conflict` line: the resource changed since the reader
1171
+ * opened it, and no name of theirs is taken;
1172
+ * 4. for any other `conflict`, the resource's own conflict copy, which names what the reader
1173
+ * can correct (a taken name), whatever the server said of it; with no `resource`, the
1174
+ * shared `formError.conflict` line;
1175
+ * 5. the server's `detail`, its already-localized sentence for this refusal, which names the
1176
+ * actual problem where a per-code line can only name the category;
1177
+ * 6. the copy's sentence for the code, the same across every resource;
1178
+ * 7. the last-resort line, `formError.generic`.
1179
+ *
1180
+ * {@link mapRestError} reads a thrown REST error by the same chain, the create hold aside (no
1181
+ * request answers it), with the code the tool bus classifies that error by. So a refusal reads as
1182
+ * one sentence whether a panel met it through a tool or a dialog through a request. A `detail`
1183
+ * that is empty or blank is read as absent, there as here: a blank line is a form that refused and
1184
+ * would not say why. The sentence is answered without the space around it.
1185
+ *
1186
+ * It never shows the result's own `error`, and reads it only to recognise a refusal met while a
1187
+ * create is out ({@link refusedForCreate}) and the tags the bus opens a keyed write's refusal
1188
+ * ({@link keyedWriteOf}) and a moved version's ({@link versionMoved}) with. That string is narration written for a model and an
1189
+ * event log, in the one language this package has, so showing it to a reader is showing a French
1190
+ * reader an English sentence in a voice written for something that is not a person.
1191
+ *
1192
+ * @param result The tool's result. A successful one answers the empty string, so a caller
1193
+ * renders its alert only for a sentence that is not empty.
1194
+ * @param options The `formError` copy, and the resource whose name the form governs where it
1195
+ * governs one.
1196
+ * @returns The sentence, or the empty string for a result that is no failure.
1197
+ */
1198
+ declare const mapToolError: (result: ToolResult, options: FormErrorOptions) => string;
1199
+ /**
1200
+ * RestFormError splits a mapped REST failure into the two slots a dialog surfaces
1201
+ * it through: a `fieldError` shown under the offending input (a conflict-like
1202
+ * rejection the user can correct in place) or a `formError` shown in the inline
1203
+ * alert above the footer (everything else). Exactly one is non-null on a failure,
1204
+ * matching how the studio panels split a tool failure between a field and the
1205
+ * alert. The two slots let a dialog drive the same field/alert split a ToolResult
1206
+ * caller gets, so a REST-backed dialog and a tool-backed panel read identically.
1207
+ */
1208
+ interface RestFormError {
1209
+ fieldError: string | null;
1210
+ formError: string | null;
1211
+ }
1212
+ /**
1213
+ * mapRestError turns a thrown REST mutation error into the field/alert split a dialog surfaces,
1214
+ * so a REST-backed dialog reads as a tool-backed panel does through {@link mapToolError}. The
1215
+ * classification, most specific first:
1216
+ *
1217
+ * 1. a 409 that answers the request's `Idempotency-Key` rather than the write maps, in the
1218
+ * alert, to `formError.writeRunning` (coded `IDEMPOTENCY_KEY_IN_USE`: the first request is
1219
+ * still running) or `formError.writeMade` (coded `IDEMPOTENCY_ANSWER_UNAVAILABLE`: the write
1220
+ * was made and its answer cannot be given again), read through the classification the tool
1221
+ * bus gives the same throw ({@link keyedWriteOf}). Neither asks for the write again, which
1222
+ * under a new key would make it twice, and neither names a field;
1223
+ * 2. a conflict-like envelope (a 409, or an entry coded CONFLICT) maps, on the field, to the
1224
+ * resource's conflict copy (a taken name), or to the shared `formError.conflict` line where
1225
+ * the options name no resource;
1226
+ * 3. any other envelope surfaces, in the alert, the message of its first entry that is an
1227
+ * object, without the space around it, so the API's specific wording (an invalid field,
1228
+ * a refused value) reads as the server wrote it. A message that is absent, no string, empty
1229
+ * or blank is read as none: a blank alert is a form that refused and would not say why;
1230
+ * 4. an envelope with no sentence to read answers the copy's sentence for the code the tool bus
1231
+ * classifies the thrown error by (`codeForThrown`: a 403 is `forbidden`, a 404 `not-found`,
1232
+ * a 429 `rate-limited`), which is the line {@link mapToolError} answers for the same
1233
+ * refusal met through a tool;
1234
+ * 5. anything else (a network or parse failure, a status the bus names no code for, a code the
1235
+ * copy holds no sentence for) falls to the generic alert line.
1236
+ *
1237
+ * Pure: it takes the copy, and a resource where the form governs one, and reads no React state,
1238
+ * so every REST dialog shares one mapping.
1239
+ */
1240
+ declare const mapRestError: (error: unknown, options: FormErrorOptions) => RestFormError;
1241
+ /**
1242
+ * ManeuverCopy is the `maneuver` section this module reads: one entry per maneuver, plus a
1243
+ * `Plain` twin for the case where the router named no road.
1244
+ *
1245
+ * The named entries take the road name, so they are FUNCTIONS rather than strings with a
1246
+ * token in them, which is what lets a language put the name somewhere English does not.
1247
+ */
1248
+ type ManeuverCopy = StudioStrings["maneuver"];
1249
+ /**
1250
+ * ManeuverGlyph is the vector shape a maneuver renders as on the directions sheet:
1251
+ * a set of 24x24 stroke paths and an optional clockwise rotation (degrees) applied
1252
+ * about the icon center. Most maneuvers are one upward arrow rotated to the turn
1253
+ * direction; the destination gets its own flag.
1254
+ */
1255
+ interface ManeuverGlyph {
1256
+ paths: string[];
1257
+ rotate?: number | undefined;
1258
+ }
1259
+ /**
1260
+ * maneuverIcon maps each ManeuverType to its glyph. It is exhaustive over
1261
+ * ManeuverType (`Record<ManeuverType, …>`), so a maneuver added to the enum fails
1262
+ * the type here until it is given a glyph. The turn family reuses ARROW at a compass
1263
+ * angle (clockwise from straight up); depart/continue, the roundabout entries, and
1264
+ * unknown fall back to a forward arrow with the instruction text carrying the nuance;
1265
+ * goal is the flag.
1266
+ */
1267
+ declare const maneuverIcon: Record<ManeuverType, ManeuverGlyph>;
1268
+ /**
1269
+ * maneuverText resolves the localized instruction for a step from its maneuver
1270
+ * type, way name, and (for a roundabout) the exit to take.
1271
+ *
1272
+ * Which sentence is said is the geo layer's rule, `stepInstruction` of
1273
+ * `@mountaya/elements/navigation`, and this resolves the copy key it answers with the arguments
1274
+ * it names. When the step names a way (not empty and not the "-" the router writes for an
1275
+ * unnamed one) it reads the named sentence, `copy[type](name)` ("Turn left onto Main Street");
1276
+ * otherwise the nameless variant ("Turn left"). A roundabout carrying an exit number surfaces it
1277
+ * through the shared `roundaboutExit` pair ("At the roundabout, take exit 2 onto Main Street").
1278
+ * The keys live under `maneuver.*`, one pair (`<TYPE>` / `<TYPE>Plain`) per ManeuverType, so
1279
+ * every maneuver has both forms in every language.
1280
+ *
1281
+ * @param exitNumber The roundabout exit to take. 0, the default, names none.
1282
+ */
1283
+ declare const maneuverText: (copy: ManeuverCopy, type: ManeuverType, name: string, exitNumber?: number) => string;
1284
+ /**
1285
+ * The Custom matrix's value sets (FORMAT_OPTIONS, RESOLUTION_OPTIONS, FPS_OPTIONS,
1286
+ * QUALITY_OPTIONS, ASPECT_OPTIONS), hoisted so the static option lists are not rebuilt per
1287
+ * render and shared between the Format step (which renders the matrix) and the Review step
1288
+ * (which resolves a chosen value back to its label). Resolution and aspect are
1289
+ * self-labelling literals (720p, 16:9) so they carry no locale key; format, fps, and quality
1290
+ * carry a `labelKey` naming an entry of the published video.format.matrix namespace at
1291
+ * render. Each value is exactly the cameraOutput field it sets, so a matrix change spreads
1292
+ * straight over the output.
1293
+ *
1294
+ * Each list is held to the vocabulary `@mountaya/elements/camera` closes, both ways and by the
1295
+ * compiler: {@link wholeVocabulary} refuses a list short of a member as the element type refuses
1296
+ * a wrong one, and a labelled list takes its keys from a record with one entry per member. The
1297
+ * tie is in the types, so this entry imports no value from the camera's.
1298
+ */
1299
+ /**
1300
+ * MatrixBank is the published format-matrix copy bank, and MatrixLabel a key of it. Typing
1301
+ * the tables against MatrixLabel is what makes them checkable. A dotted path
1302
+ * ("matrix.fps24") would index the nested copy object with nothing: a lookup that compiles
1303
+ * and renders as `undefined`, with nothing anywhere failing.
1304
+ *
1305
+ * MatrixLabel is narrowed to the entries that ARE a string. The bank also holds templates
1306
+ * (`bitrateValue(count)`), and a key union covering those widens every lookup to
1307
+ * `string | ((count: number) => string)`, which a label prop rejects, so the whole table
1308
+ * would have to be cast back to what it already was.
1309
+ */
1310
+ type MatrixBank = StudioStrings["video"]["format"]["matrix"];
1311
+ type MatrixLabel = { [K in keyof MatrixBank]: MatrixBank[K] extends string ? K : never; }[keyof MatrixBank];
1312
+ /**
1313
+ * FORMAT_OPTIONS is the Custom matrix's container set, each labelled under the studio
1314
+ * video.format.matrix namespace at render.
1315
+ */
1316
+ declare const FORMAT_OPTIONS: readonly {
1317
+ labelKey: MatrixLabel;
1318
+ value: CameraOutputFormat;
1319
+ }[];
1320
+ /**
1321
+ * RESOLUTION_OPTIONS is the Custom matrix's resolution set, self-labelling literals the
1322
+ * segmented control renders directly.
1323
+ */
1324
+ declare const RESOLUTION_OPTIONS: readonly CameraResolution[];
1325
+ /**
1326
+ * FPS_OPTIONS is the Custom matrix's frame-rate set, each labelled under the studio
1327
+ * video.format.matrix namespace at render.
1328
+ */
1329
+ declare const FPS_OPTIONS: readonly {
1330
+ labelKey: MatrixLabel;
1331
+ value: CameraFps;
1332
+ }[];
1333
+ /**
1334
+ * QUALITY_OPTIONS is the Custom matrix's quality set, each labelled under the studio
1335
+ * video.format.matrix namespace at render.
1336
+ */
1337
+ declare const QUALITY_OPTIONS: readonly {
1338
+ labelKey: MatrixLabel;
1339
+ value: Quality;
1340
+ }[];
1341
+ /**
1342
+ * ASPECT_OPTIONS is the Custom matrix's aspect set, self-labelling literals the segmented
1343
+ * control renders directly.
1344
+ */
1345
+ declare const ASPECT_OPTIONS: readonly CameraOutput["aspect"][];
1346
+ /**
1347
+ * PublicationState is the one question every publication surface asks: what does the
1348
+ * PUBLIC see right now? Never published, published and current, or published and
1349
+ * behind the editor. "loading" is a state of its own so neither wizard flashes the
1350
+ * never-published panel in the frame between opening and the detail landing, and
1351
+ * "error" is its own so a detail that will NEVER land is not shown as one that has
1352
+ * not landed YET: a spinner that cannot resolve is the worst of the four.
1353
+ */
1354
+ type PublicationState = "dirty" | "error" | "loading" | "published" | "unpublished";
1355
+ /**
1356
+ * publicationStateOf folds the two publication fields an itinerary's detail or a zone
1357
+ * already carries into the single state every publication surface branches on. A zone
1358
+ * is published as an itinerary is, so the two read alike.
1359
+ *
1360
+ * It must be given the DRAFT. A publication snapshot reports itself as published and
1361
+ * never as behind, so the draft is the only surface that can answer "has the editor
1362
+ * moved past what is live?", which is also why the wizards keep reading the draft for
1363
+ * this while their preview reads the publication.
1364
+ *
1365
+ * `failed` separates the two reasons the record can be missing. A caller reading it
1366
+ * off a query passes that query's own error flag, so a refused or unreachable fetch
1367
+ * resolves to "error" instead of parking on "loading" for as long as the surface
1368
+ * stays open. It defaults to false for the callers that hold the record already (the
1369
+ * store's active itinerary or zone), where absence can only ever mean "not yet".
1370
+ *
1371
+ * @param resource The DRAFT itinerary detail or zone, or undefined while it has not landed.
1372
+ * @param failed Whether the read of the record was refused.
1373
+ * @default failed false
1374
+ * @returns The state every publication surface branches on.
1375
+ */
1376
+ declare const publicationStateOf: (resource: ItineraryWithDetails$1 | Zone | undefined, failed?: boolean) => PublicationState;
1377
+ /**
1378
+ * PublicationCopy is the slice of the copy bundle that names a publication state.
1379
+ */
1380
+ type PublicationCopy = StudioStrings["publish"];
1381
+ /**
1382
+ * publicationLabel names a state in one word, read off the `publish` section of the copy.
1383
+ *
1384
+ * One word on purpose: it is read at a glance beside a coloured mark, and the sentence that
1385
+ * explains the state belongs in the hint next to it. A longer label truncates, in French first,
1386
+ * and the state is unreadable exactly when it matters.
1387
+ *
1388
+ * Every state has its own word. A detail that has not landed reads as loading and never as a
1389
+ * draft, so a badge painted before the detail arrives does not tell the owner of a published
1390
+ * itinerary that the public sees nothing.
1391
+ *
1392
+ * It lives here and not in a surface that paints it, so the editor's status line and the
1393
+ * unpublished panel's badge call one state one thing. The copy is read by property, so a word
1394
+ * that moves is a compile error here and not a blank badge.
1395
+ *
1396
+ * @param copy The `publish` section of the language the label reads in.
1397
+ * @param state The publication state to name.
1398
+ * @returns The state's word.
1399
+ */
1400
+ declare const publicationLabel: (copy: PublicationCopy, state: PublicationState) => string;
1401
+ /**
1402
+ * publicationColor is the one place a publication state becomes a colour. Every
1403
+ * surface that paints the state reads it here rather than deciding it again, so a badge in
1404
+ * the editor and a notice on a wizard preview cannot drift into saying the same thing
1405
+ * in two hues. Grey for never published (inert, nothing is live), orange for behind
1406
+ * (the state that needs an act), teal for current (settled). "loading" borrows grey
1407
+ * because it renders nothing until the detail lands; "error" is red, the one state
1408
+ * that is a fault rather than a stage of the publication.
1409
+ */
1410
+ declare const publicationColor: Record<PublicationState, string>;
1411
+ /**
1412
+ * SearchLabelCopy is the `search.labels` section this module reads: the word each wire value of
1413
+ * a search result reads as, by the kind of value it is.
1414
+ */
1415
+ type SearchLabelCopy = StudioStrings["search"]["labels"];
1416
+ /**
1417
+ * searchLabelWord answers the word a reader reads for one wire value of a search result, in the
1418
+ * language `copy` is in, or `undefined` for a value the copy has no word for.
1419
+ *
1420
+ * It is the body of the `resolveLabel` a `SearchWording` of `@mountaya/elements/search` takes: a
1421
+ * surface that mounts a search hands over `(label) => searchLabelWord(copy, label)` beside the
1422
+ * viewer's units, and every row's category and way tags read in the language of the studio
1423
+ * instead of as English titles of the wire values.
1424
+ *
1425
+ * A place's and a POI's category always have a word, since the copy holds every member of both
1426
+ * vocabularies. A way's `highway`, `sac_scale` and `surface` tags are open, so a tag the copy
1427
+ * does not hold answers `undefined` and the describer words the tag itself. The value is read as
1428
+ * an own property of the copy, so a tag spelled like a member every object inherits
1429
+ * (`constructor`) answers `undefined` too.
1430
+ *
1431
+ * The label is stated by the copy's own kinds, and every `SearchLabel` of
1432
+ * `@mountaya/elements/search` is one. That type is not named here: the declarations of the
1433
+ * search entry reach the map's shared types, and with them the DOM library, which a program
1434
+ * that reads this entry for its words does not name.
1435
+ *
1436
+ * @param copy The `search.labels` section of the language the row reads in.
1437
+ * @param label The wire value to word, with the kind of value it is.
1438
+ * @returns The word, or `undefined` when the copy holds none for the value.
1439
+ *
1440
+ * @example
1441
+ * ```ts
1442
+ * import { frStudioStrings } from "@mountaya/studio/strings/fr";
1443
+ *
1444
+ * const labels = frStudioStrings.search.labels;
1445
+ *
1446
+ * searchLabelWord(labels, { kind: "poiCategory", value: "HUT" }); // "Refuge"
1447
+ * searchLabelWord(labels, { kind: "highway", value: "corridor" }); // undefined
1448
+ * ```
1449
+ */
1450
+ declare const searchLabelWord: (copy: SearchLabelCopy, label: {
1451
+ readonly kind: keyof SearchLabelCopy;
1452
+ readonly value: string;
1453
+ }) => string | undefined;
1454
+ /**
1455
+ * The words a chain verb's refusal is quoted with, filed beside the words rather than beside
1456
+ * the chain.
1457
+ *
1458
+ * Every name here resolves a STATE into a copy key, which is what `@mountaya/studio/strings`
1459
+ * is for, and it is also what keeps it off the root barrel. `keyof StudioStrings["segmentMenu"]`
1460
+ * makes the whole bundle part of this module's declarations, so filing it on the root would
1461
+ * have every consumer who imports a tool contract type-check all of it to reach a merge hint.
1462
+ * `barrelParity.test.ts`'s declaration ceiling holds the root to that; the entry doc one
1463
+ * directory up states the rule.
1464
+ */
1465
+ /**
1466
+ * SegmentMergeDisabledReason is what a ROW's menu explains: the refusals the chain model
1467
+ * derives ({@link SegmentMergeRefusal}), plus the two ends of the chain, which no gutter can
1468
+ * carry.
1469
+ *
1470
+ * The tail row has no successor to fold into and the head row has no predecessor, and neither
1471
+ * has a gutter on that side to say so, so the row is the only surface that has to word them,
1472
+ * which is why they widen the union here rather than in the rule that produces the others.
1473
+ */
1474
+ type SegmentMergeDisabledReason = SegmentMergeRefusal | "head" | "tail";
1475
+ /**
1476
+ * mergeDisabledHintKey pairs each refusal with the KEY of the line that explains it, so the
1477
+ * gutter's disabled pill and the row menu's disabled item quote the same sentence
1478
+ * for the same condition rather than drifting into two vocabularies for one rule.
1479
+ */
1480
+ declare const mergeDisabledHintKey: Record<SegmentMergeDisabledReason, keyof StudioStrings["segmentMenu"]>;
1481
+ /**
1482
+ * SegmentSplitDisabledReason names why a row's Split verb is inert for a reason of its
1483
+ * OWN: an authoring edit already owns the map, so the split's point-pick gesture cannot
1484
+ * arm over it.
1485
+ */
1486
+ type SegmentSplitDisabledReason = "editing";
1487
+ /**
1488
+ * splitDisabledHintKey pairs each split refusal with the line that explains it, the
1489
+ * twin of mergeDisabledHintKey. The "editing" line is the one the blocked add
1490
+ * control and the blocked row click already raise, so all three name the open edit
1491
+ * with one sentence.
1492
+ */
1493
+ declare const splitDisabledHintKey: Record<SegmentSplitDisabledReason, keyof StudioStrings["segmentMenu"]>;
1494
+ /**
1495
+ * studioStrings is the studio's copy built in, keyed by language: English, the language every
1496
+ * other one falls back to.
1497
+ *
1498
+ * The studio's half of the family's two bundles. `elementsStrings` of `@mountaya/elements/i18n`
1499
+ * carries what the ELEMENTS say (a control's label, a table's header, the sentence a refused edit
1500
+ * reports), and this carries what the STUDIO says: its dialogs, its wizards, its panels, its
1501
+ * publish and share flows. They are two bundles rather than one because they are read by
1502
+ * different things and overridden for different reasons, and one merged object would hand every
1503
+ * control's `useMountayaStrings()` the whole of the studio's copy, which it has no surface for.
1504
+ *
1505
+ * Every other language Mountaya translates the studio into is an entry of its own a host imports
1506
+ * and hands over among the {@link Translations} (`frStudioStrings` of
1507
+ * `@mountaya/studio/strings/fr`), so a page that reads in English loads no other language's
1508
+ * words. Everything else about the two bundles is deliberately identical: the same leaf shape,
1509
+ * the same partial override, the same per-language form, the same merge.
1510
+ */
1511
+ declare const studioStrings: Readonly<{
1512
+ en: StudioStrings;
1513
+ }>;
1514
+ /**
1515
+ * studioLanguageOptions is the option list a language picker of the studio offers: English, then
1516
+ * every language a host handed over among `translations`, each labelled with its own endonym.
1517
+ *
1518
+ * Published as a list rather than left to each surface to build, because "which languages this
1519
+ * studio is available in" is one answer and a surface that derives it separately is a surface
1520
+ * that can offer a different set. It offers only languages whose words the page loaded, so a
1521
+ * picker never switches the studio into a language it would read in English.
1522
+ *
1523
+ * @param translations The studio's words a host imported, keyed by language.
1524
+ * @returns English first, then each language handed over, in the order `MAP_LANGUAGES` states.
1525
+ *
1526
+ * @example
1527
+ * ```ts
1528
+ * import { studioLanguageOptions } from "@mountaya/studio/strings";
1529
+ * import { frStudioStrings } from "@mountaya/studio/strings/fr";
1530
+ *
1531
+ * const options = studioLanguageOptions({ fr: frStudioStrings });
1532
+ * // options is [{ label: "English", value: "en" }, { label: "Français", value: "fr" }]
1533
+ * ```
1534
+ */
1535
+ declare const studioLanguageOptions: (translations?: Translations<StudioStrings>) => readonly {
1536
+ label: string;
1537
+ value: MapLanguage;
1538
+ }[];
1539
+ /**
1540
+ * A partial override, at whatever depth it reaches.
1541
+ *
1542
+ * An alias for `PartialDeep` in `@mountaya/elements/i18n`, kept as a name because it is what a
1543
+ * consumer reads in the override prop's type. One spelling of "an override at any depth" serves
1544
+ * the studio's copy and the elements' alike, since there is one depth rule.
1545
+ */
1546
+ type PartialCopy<T = StudioStrings> = PartialDeep<T>;
1547
+ /**
1548
+ * StudioStringsOverrides is a consumer's override of the studio's copy, in one of two shapes.
1549
+ *
1550
+ * A flat {@link PartialCopy} overrides whichever language is selected. A
1551
+ * `BundleLanguageOverrides` names each language it overrides and leaves the rest alone, and its
1552
+ * members state `undefined`, so a consumer under `exactOptionalPropertyTypes` forwards a
1553
+ * translation it may not hold. They are the two shapes `ElementsStringsOverrides` offers, for
1554
+ * the same reason: a consumer replacing one sentence in its own product's voice thinks in one
1555
+ * language, and a consumer shipping a language Mountaya does not carry thinks in all of them.
1556
+ *
1557
+ * An override is one shape or the other, never both: {@link resolveStudioStrings} refuses an
1558
+ * object that names a language and a section together.
1559
+ */
1560
+ type StudioStringsOverrides = PartialCopy | BundleLanguageOverrides<StudioStrings>;
1561
+ /**
1562
+ * resolveStudioStrings selects a language's copy and folds a consumer's overrides onto it.
1563
+ *
1564
+ * It is `resolveBundle` of `@mountaya/elements/i18n` over {@link studioStrings} and the
1565
+ * translations a host handed over, so the fallback, the two override shapes and the merge are
1566
+ * the ones every bundle of the family resolves by. A language with no words reads in English: a
1567
+ * studio in the wrong language is usable, and one that refuses to mount is not. French asked for
1568
+ * and not handed over reads the same way, and says so once in development, naming the import.
1569
+ *
1570
+ * It returns the built-in or handed-over bundle itself when there is nothing to fold, which
1571
+ * includes an override aimed at another language, so a provider that compares the result by
1572
+ * reference re-renders nothing for a patch that changes nothing.
1573
+ *
1574
+ * @param language The language to resolve. Defaults to `"en"`.
1575
+ * @param overrides The consumer's override, in either shape of {@link StudioStringsOverrides}.
1576
+ * @param translations The studio's words a host imported, keyed by language.
1577
+ * @returns The resolved copy: the bundle's own object when no override folds, a new object
1578
+ * otherwise.
1579
+ * @throws {MountayaElementsError} When `overrides` names a language and a section together, with
1580
+ * both lists in the message.
1581
+ *
1582
+ * @example
1583
+ * ```ts
1584
+ * import { resolveStudioStrings } from "@mountaya/studio/strings";
1585
+ * import { frStudioStrings } from "@mountaya/studio/strings/fr";
1586
+ *
1587
+ * const words = resolveStudioStrings("fr", { fr: { share: { copy: "Copier" } } }, {
1588
+ * fr: frStudioStrings,
1589
+ * });
1590
+ * ```
1591
+ */
1592
+ declare const resolveStudioStrings: (language?: MapLanguage, overrides?: StudioStringsOverrides, translations?: Translations<StudioStrings>) => StudioStrings;
1593
+ /**
1594
+ * UnitCopy is the `preferences.units` slice these builders read, and nothing else.
1595
+ *
1596
+ * Narrow rather than the whole bundle for the reason the bundle itself is split from the
1597
+ * elements' strings: a builder that names the whole of the copy to reach a handful of keys is
1598
+ * harder to read for nobody's benefit, and a reader of this signature learns exactly which copy
1599
+ * moves it.
1600
+ */
1601
+ type UnitCopy = StudioStrings["preferences"]["units"];
1602
+ /**
1603
+ * UnitOption is one selectable unit in a unit picker: the localized `name` shown
1604
+ * below the card, the `symbol` shown as the card's media (°, %, km, …), and the
1605
+ * domain `value` dispatched on selection. The value defaults to a plain string so
1606
+ * a grid can hold mixed unit families through `UnitOption`, while each builder
1607
+ * narrows it to its own unit union (UnitOption&lt;UnitLength&gt; and friends).
1608
+ */
1609
+ interface UnitOption<V extends string = string> {
1610
+ name: string;
1611
+ symbol: string;
1612
+ value: V;
1613
+ }
1614
+ /**
1615
+ * lengthUnitOptions builds the metric/imperial length options from the shared
1616
+ * preferences unit copy, the same `preferences.units.*` keys the preferences
1617
+ * panel and the overlay step render. It is a pure function of the copy (not a
1618
+ * hook), so the same array drives any unit grid and stays unit-testable without
1619
+ * a React tree.
1620
+ */
1621
+ declare const lengthUnitOptions: (units: UnitCopy) => readonly UnitOption<UnitLength>[];
1622
+ /**
1623
+ * paceUnitOptions builds the speed/pace options (the FORM a travel rate is stated in)
1624
+ * from the shared preferences unit copy. Pure, like lengthUnitOptions.
1625
+ *
1626
+ * It is the one builder that takes a SECOND preference, and it has to: this choice does not
1627
+ * pick a unit, it picks a form, and the unit that form resolves to is the product of this
1628
+ * choice and `length`. So the card states what the reader will actually see (`km/h` and
1629
+ * `min/km` for a metric reader, `mph` and `min/mi` for an imperial one) rather than listing
1630
+ * both systems and leaving them to work out which half applies to them.
1631
+ *
1632
+ * Naming both (`km/h · mph`) would be wrong for a second reason beyond the noise: it reads as
1633
+ * a second, contradicting way to ask for imperial, on a card that cannot change the system at
1634
+ * all.
1635
+ *
1636
+ * @param units The `preferences.units` copy the cards are worded from.
1637
+ * @param length The reader's length system, which picks the symbol each card states.
1638
+ * @returns The per-time card, then the per-distance card.
1639
+ */
1640
+ declare const paceUnitOptions: (units: UnitCopy, length: UnitLength) => readonly UnitOption<UnitPace>[];
1641
+ /**
1642
+ * slopeUnitOptions builds the degrees/percentage slope options from the shared
1643
+ * preferences unit copy. Pure, like lengthUnitOptions.
1644
+ */
1645
+ declare const slopeUnitOptions: (units: UnitCopy) => readonly UnitOption<UnitSlope>[];
1646
+ /**
1647
+ * temperatureUnitOptions builds the celsius/fahrenheit options from the shared
1648
+ * preferences unit copy. Pure, like lengthUnitOptions. The preferences panel is the one
1649
+ * picker of a temperature unit, and the builder sits beside its siblings so another
1650
+ * temperature picker reuses the same copy.
1651
+ */
1652
+ declare const temperatureUnitOptions: (units: UnitCopy) => readonly UnitOption<UnitTemperature>[];
1653
+ export { segmentGroupDissolvesOnLeave as $, ViewerSeam as $t, maneuverIcon as A, WaypointUpdateParams$1 as At, DraftEditorToolNames as B, TabSurface as Bt, ASPECT_OPTIONS as C, UnitSlope as Ct, RESOLUTION_OPTIONS as D, WaypointIcon as Dt, QUALITY_OPTIONS as E, WaypointAmenity as Et, RestFormError as F, ConfirmationValues as Ft, SegmentChainEnds as G, ToolConfirmation as Gt, toolNamesFor as H, ToolBusContext as Ht, mapRestError as I, JsonSchema as It, SegmentGroupRun as J, ToolFailure as Jt, SegmentChainMerge as K, ToolDispatchRegistry as Kt, mapToolError as L, KnownToolInput as Lt, FormErrorCopy as M, ZoneSource as Mt, FormErrorOptions as N, ConfirmationRequest as Nt, ManeuverCopy as O, WaypointPropertyFormat as Ot, FormErrorResource as P, ConfirmationTone as Pt, segmentChainEnds as Q, ViewerPreferences as Qt, failureAlertFor as R, KnownToolOutput as Rt, publicationStateOf as S, UnitPace as St, FPS_OPTIONS as T, WayType as Tt, CONFIRM_COPY_LABELS as U, ToolBusDispatch as Ut, EMPTY_STRINGS as V, Tool as Vt, confirmSentence as W, ToolCapability as Wt, buildSegmentChainMerges as X, ToolResult as Xt, SegmentMergeRefusal as Y, ToolOutputRegistry as Yt, buildSegmentGroupRuns as Z, ToolResultOf as Zt, searchLabelWord as _, OrganizationRole as _t, slopeUnitOptions as a, EmbeddedStudioDefaultProps as at, publicationColor as b, TrailDifficultyType as bt, StudioStringsOverrides as c, ExportVariant$1 as ct, studioStrings as d, ImportWarning as dt, confirmationToneSchema as en, Activity as et, SegmentMergeDisabledReason as f, Itinerary as ft, SearchLabelCopy as g, ManeuverType as gt, splitDisabledHintKey as h, Locales as ht, paceUnitOptions as i, Collection$1 as it, maneuverText as j, Zone$1 as jt, ManeuverGlyph as k, WaypointTiming as kt, resolveStudioStrings as l, ImportGranularity as lt, mergeDisabledHintKey as m, ItinerarySegmentGroup$1 as mt, UnitOption as n, toolConfirmationSchema as nn, CategoryActivities$1 as nt, temperatureUnitOptions as o, EmbeddedStudioSafetyRules as ot, SegmentSplitDisabledReason as p, ItineraryImportPreview as pt, SegmentChainMerges as q, ToolErrorCode as qt, lengthUnitOptions as r, toolErrorCodeSchema as rn, CollabEntityKind as rt, PartialCopy as s, ExportFormat$1 as st, UnitCopy as t, toolCapabilitySchema as tn, ActivityCapabilities as tt, studioLanguageOptions as u, ImportRecommendationReason as ut, PublicationCopy as v, RestLanguage as vt, FORMAT_OPTIONS as w, UnitTemperature as wt, publicationLabel as x, UnitLength as xt, PublicationState as y, SurfaceType as yt, DraftEditorFlow as z, StudioToolManifestEntry as zt };
1654
+ //# sourceMappingURL=chunk-CLGvBOVH.d.cts.map