@elytracms/studio 0.0.91 → 0.0.93

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 (353) hide show
  1. package/convex/asset-alt-migration.test.ts +127 -0
  2. package/convex/asset-replace.test.ts +168 -0
  3. package/convex/asset-revalidate.test.ts +6 -6
  4. package/convex/assets.ts +41 -5
  5. package/convex/cms.ts +537 -177
  6. package/convex/contract-parity.test.ts +173 -19
  7. package/convex/delivery.ts +26 -13
  8. package/convex/document-revalidate.test.ts +17 -16
  9. package/convex/orphan-hydration.test.ts +116 -0
  10. package/convex/presence-cost.test.ts +89 -0
  11. package/convex/rail-write-parity.test.ts +17 -14
  12. package/convex/referenceMaintenance.ts +15 -15
  13. package/convex/schema.ts +70 -5
  14. package/convex/triggers.ts +21 -8
  15. package/convex/write-limits.ts +1 -1
  16. package/dist/components/ai/ai-chat-panel.js +33 -22
  17. package/dist/components/ai/ai-chat-panel.js.map +1 -1
  18. package/dist/components/ai/proposal-card.js +2 -1
  19. package/dist/components/ai/proposal-card.js.map +1 -1
  20. package/dist/components/ai/translate-document-action.d.ts +8 -2
  21. package/dist/components/ai/translate-document-action.js.map +1 -1
  22. package/dist/components/ai/translate-document-dialog.d.ts +1 -1
  23. package/dist/components/ai/translate-document-dialog.js +14 -8
  24. package/dist/components/ai/translate-document-dialog.js.map +1 -1
  25. package/dist/components/ai/translate-skipped.d.ts +19 -0
  26. package/dist/components/ai/translate-skipped.js +46 -0
  27. package/dist/components/ai/translate-skipped.js.map +1 -0
  28. package/dist/components/app-views/default-modules.d.ts +23 -6
  29. package/dist/components/app-views/default-modules.js +33 -14
  30. package/dist/components/app-views/default-modules.js.map +1 -1
  31. package/dist/components/assets/asset-detail.js +18 -8
  32. package/dist/components/assets/asset-detail.js.map +1 -1
  33. package/dist/components/assets/asset-metadata.d.ts +15 -4
  34. package/dist/components/assets/asset-metadata.js +15 -2
  35. package/dist/components/assets/asset-metadata.js.map +1 -1
  36. package/dist/components/assets/asset-search.js +4 -1
  37. package/dist/components/assets/asset-search.js.map +1 -1
  38. package/dist/components/assets/asset-selection.d.ts +0 -8
  39. package/dist/components/assets/asset-selection.js +4 -23
  40. package/dist/components/assets/asset-selection.js.map +1 -1
  41. package/dist/components/assets/asset-thumb.js +3 -2
  42. package/dist/components/assets/asset-thumb.js.map +1 -1
  43. package/dist/components/assets/assets-collection-view-source.d.ts +3 -3
  44. package/dist/components/assets/assets-collection-view-source.js +9 -5
  45. package/dist/components/assets/assets-collection-view-source.js.map +1 -1
  46. package/dist/components/assets/assets-store.d.ts +14 -0
  47. package/dist/components/assets/assets-store.js +23 -1
  48. package/dist/components/assets/assets-store.js.map +1 -1
  49. package/dist/components/assets/replace-file.d.ts +22 -0
  50. package/dist/components/assets/replace-file.js +59 -0
  51. package/dist/components/assets/replace-file.js.map +1 -0
  52. package/dist/components/builder/blocks-model.d.ts +14 -26
  53. package/dist/components/builder/blocks-model.js +35 -41
  54. package/dist/components/builder/blocks-model.js.map +1 -1
  55. package/dist/components/builder/blocks-panel.d.ts +7 -3
  56. package/dist/components/builder/blocks-panel.js +6 -5
  57. package/dist/components/builder/blocks-panel.js.map +1 -1
  58. package/dist/components/builder/builder-store.d.ts +126 -30
  59. package/dist/components/builder/builder-store.js +169 -67
  60. package/dist/components/builder/builder-store.js.map +1 -1
  61. package/dist/components/builder/canvas-body.d.ts +30 -0
  62. package/dist/components/builder/canvas-body.js +38 -0
  63. package/dist/components/builder/canvas-body.js.map +1 -0
  64. package/dist/components/builder/canvas-chrome-css.js +7 -0
  65. package/dist/components/builder/canvas-chrome-css.js.map +1 -1
  66. package/dist/components/builder/canvas-dnd.d.ts +7 -7
  67. package/dist/components/builder/canvas-dnd.js +5 -5
  68. package/dist/components/builder/canvas-dnd.js.map +1 -1
  69. package/dist/components/builder/canvas-render-context.d.ts +30 -22
  70. package/dist/components/builder/canvas-render-context.js +44 -44
  71. package/dist/components/builder/canvas-render-context.js.map +1 -1
  72. package/dist/components/builder/canvas-runs.d.ts +45 -0
  73. package/dist/components/builder/canvas-runs.js +51 -0
  74. package/dist/components/builder/canvas-runs.js.map +1 -0
  75. package/dist/components/builder/canvas.d.ts +5 -4
  76. package/dist/components/builder/canvas.js +34 -6
  77. package/dist/components/builder/canvas.js.map +1 -1
  78. package/dist/components/builder/clipboard-actions.d.ts +15 -0
  79. package/dist/components/builder/clipboard-actions.js +50 -13
  80. package/dist/components/builder/clipboard-actions.js.map +1 -1
  81. package/dist/components/builder/composition-field-editor.d.ts +10 -16
  82. package/dist/components/builder/composition-field-editor.js +30 -40
  83. package/dist/components/builder/composition-field-editor.js.map +1 -1
  84. package/dist/components/builder/composition-patches.d.ts +7 -0
  85. package/dist/components/builder/composition-patches.js +256 -0
  86. package/dist/components/builder/composition-patches.js.map +1 -0
  87. package/dist/components/builder/delete-key.d.ts +5 -0
  88. package/dist/components/builder/delete-key.js +4 -0
  89. package/dist/components/builder/delete-key.js.map +1 -1
  90. package/dist/components/builder/insert-context.d.ts +17 -25
  91. package/dist/components/builder/insert-context.js +45 -92
  92. package/dist/components/builder/insert-context.js.map +1 -1
  93. package/dist/components/builder/page-tree.d.ts +3 -3
  94. package/dist/components/builder/page-tree.js +3 -3
  95. package/dist/components/builder/page-tree.js.map +1 -1
  96. package/dist/components/builder/placement-refusal.d.ts +18 -0
  97. package/dist/components/builder/placement-refusal.js +46 -0
  98. package/dist/components/builder/placement-refusal.js.map +1 -0
  99. package/dist/components/builder/property-inspector.js +4 -0
  100. package/dist/components/builder/property-inspector.js.map +1 -1
  101. package/dist/components/builder/reuse-context.js +65 -26
  102. package/dist/components/builder/reuse-context.js.map +1 -1
  103. package/dist/components/builder/reuse.d.ts +79 -8
  104. package/dist/components/builder/reuse.js +71 -23
  105. package/dist/components/builder/reuse.js.map +1 -1
  106. package/dist/components/builder/run-inspector.d.ts +11 -0
  107. package/dist/components/builder/run-inspector.js +33 -0
  108. package/dist/components/builder/run-inspector.js.map +1 -0
  109. package/dist/components/cms/asset-field.d.ts +38 -1
  110. package/dist/components/cms/asset-field.js +182 -58
  111. package/dist/components/cms/asset-field.js.map +1 -1
  112. package/dist/components/cms/asset-picker-core.d.ts +16 -0
  113. package/dist/components/cms/asset-picker-core.js +20 -0
  114. package/dist/components/cms/asset-picker-core.js.map +1 -1
  115. package/dist/components/cms/asset-picker.js +12 -18
  116. package/dist/components/cms/asset-picker.js.map +1 -1
  117. package/dist/components/cms/bulk-actions.d.ts +4 -20
  118. package/dist/components/cms/bulk-actions.js +3 -24
  119. package/dist/components/cms/bulk-actions.js.map +1 -1
  120. package/dist/components/cms/cell-edit.d.ts +5 -5
  121. package/dist/components/cms/cell-edit.js.map +1 -1
  122. package/dist/components/cms/cell.js.map +1 -1
  123. package/dist/components/cms/cms-store.d.ts +87 -45
  124. package/dist/components/cms/cms-store.js +347 -203
  125. package/dist/components/cms/cms-store.js.map +1 -1
  126. package/dist/components/cms/collection-table.js +7 -2
  127. package/dist/components/cms/collection-table.js.map +1 -1
  128. package/dist/components/cms/commit-policy.d.ts +24 -0
  129. package/dist/components/cms/commit-policy.js +37 -0
  130. package/dist/components/cms/commit-policy.js.map +1 -0
  131. package/dist/components/cms/detail-editor.js +83 -137
  132. package/dist/components/cms/detail-editor.js.map +1 -1
  133. package/dist/components/cms/document-diff-view.d.ts +3 -1
  134. package/dist/components/cms/document-diff-view.js +12 -7
  135. package/dist/components/cms/document-diff-view.js.map +1 -1
  136. package/dist/components/cms/draft-commit.d.ts +70 -0
  137. package/dist/components/cms/draft-commit.js +82 -0
  138. package/dist/components/cms/draft-commit.js.map +1 -0
  139. package/dist/components/cms/duplicate-document.d.ts +11 -13
  140. package/dist/components/cms/duplicate-document.js +26 -34
  141. package/dist/components/cms/duplicate-document.js.map +1 -1
  142. package/dist/components/cms/field-anchors.d.ts +7 -4
  143. package/dist/components/cms/field-anchors.js +9 -7
  144. package/dist/components/cms/field-anchors.js.map +1 -1
  145. package/dist/components/cms/field-collaboration.d.ts +47 -0
  146. package/dist/components/cms/field-collaboration.js +87 -0
  147. package/dist/components/cms/field-collaboration.js.map +1 -0
  148. package/dist/components/cms/field-control-lib.d.ts +22 -1
  149. package/dist/components/cms/field-control-lib.js +33 -4
  150. package/dist/components/cms/field-control-lib.js.map +1 -1
  151. package/dist/components/cms/field-control.js +17 -14
  152. package/dist/components/cms/field-control.js.map +1 -1
  153. package/dist/components/cms/gate-validation.d.ts +21 -30
  154. package/dist/components/cms/gate-validation.js +11 -22
  155. package/dist/components/cms/gate-validation.js.map +1 -1
  156. package/dist/components/cms/object-array-field.js +4 -4
  157. package/dist/components/cms/object-array-field.js.map +1 -1
  158. package/dist/components/cms/prop-fields.d.ts +7 -2
  159. package/dist/components/cms/prop-fields.js +13 -6
  160. package/dist/components/cms/prop-fields.js.map +1 -1
  161. package/dist/components/cms/reference-confirm.js +10 -4
  162. package/dist/components/cms/reference-confirm.js.map +1 -1
  163. package/dist/components/cms/rich-text/embed-picker.d.ts +1 -1
  164. package/dist/components/cms/rich-text/embed-picker.js.map +1 -1
  165. package/dist/components/cms/rich-text/insert.d.ts +20 -9
  166. package/dist/components/cms/rich-text/insert.js +25 -17
  167. package/dist/components/cms/rich-text/insert.js.map +1 -1
  168. package/dist/components/cms/use-document-draft.d.ts +96 -0
  169. package/dist/components/cms/use-document-draft.js +283 -0
  170. package/dist/components/cms/use-document-draft.js.map +1 -0
  171. package/dist/components/cms/use-document-versions.js +2 -2
  172. package/dist/components/cms/use-document-versions.js.map +1 -1
  173. package/dist/components/cms/use-live-url.d.ts +6 -12
  174. package/dist/components/cms/use-live-url.js +16 -15
  175. package/dist/components/cms/use-live-url.js.map +1 -1
  176. package/dist/components/cms/use-publish-controller.d.ts +13 -18
  177. package/dist/components/cms/use-publish-controller.js +24 -41
  178. package/dist/components/cms/use-publish-controller.js.map +1 -1
  179. package/dist/components/cms/use-published-perspective.d.ts +2 -3
  180. package/dist/components/cms/use-published-perspective.js +4 -3
  181. package/dist/components/cms/use-published-perspective.js.map +1 -1
  182. package/dist/components/cms/versions-pane.js +8 -1
  183. package/dist/components/cms/versions-pane.js.map +1 -1
  184. package/dist/components/collection-view/cms-collection-view-source.js +24 -7
  185. package/dist/components/collection-view/cms-collection-view-source.js.map +1 -1
  186. package/dist/components/components/transfer-dialog.js +28 -23
  187. package/dist/components/components/transfer-dialog.js.map +1 -1
  188. package/dist/components/components/transfer.d.ts +31 -21
  189. package/dist/components/components/transfer.js +49 -35
  190. package/dist/components/components/transfer.js.map +1 -1
  191. package/dist/components/project-list.js.map +1 -1
  192. package/dist/components/project-session.d.ts +6 -3
  193. package/dist/components/project-session.js +14 -8
  194. package/dist/components/project-session.js.map +1 -1
  195. package/dist/components/project-switcher.js.map +1 -1
  196. package/dist/components/rail-view-source.js +2 -1
  197. package/dist/components/rail-view-source.js.map +1 -1
  198. package/dist/components/section-nav.js +1 -1
  199. package/dist/components/section-nav.js.map +1 -1
  200. package/dist/lib/ai/apply-content.js +56 -116
  201. package/dist/lib/ai/apply-content.js.map +1 -1
  202. package/dist/lib/ai/chat-context.d.ts +8 -0
  203. package/dist/lib/ai/chat-context.js +37 -6
  204. package/dist/lib/ai/chat-context.js.map +1 -1
  205. package/dist/lib/ai/chat-state.d.ts +14 -1
  206. package/dist/lib/ai/chat-state.js.map +1 -1
  207. package/dist/lib/ai/constraints.d.ts +20 -5
  208. package/dist/lib/ai/constraints.js +125 -33
  209. package/dist/lib/ai/constraints.js.map +1 -1
  210. package/dist/lib/ai/fake-provider.d.ts +16 -3
  211. package/dist/lib/ai/fake-provider.js +22 -6
  212. package/dist/lib/ai/fake-provider.js.map +1 -1
  213. package/dist/lib/ai/index.d.ts +2 -0
  214. package/dist/lib/ai/index.js +2 -0
  215. package/dist/lib/ai/index.js.map +1 -1
  216. package/dist/lib/ai/leash.d.ts +34 -0
  217. package/dist/lib/ai/leash.js +28 -0
  218. package/dist/lib/ai/leash.js.map +1 -0
  219. package/dist/lib/ai/provenance.d.ts +1 -1
  220. package/dist/lib/ai/provenance.js.map +1 -1
  221. package/dist/lib/ai/rich-text-input.d.ts +8 -8
  222. package/dist/lib/ai/rich-text-input.js +2 -1
  223. package/dist/lib/ai/rich-text-input.js.map +1 -1
  224. package/dist/lib/ai/rich-text-translate.d.ts +27 -4
  225. package/dist/lib/ai/rich-text-translate.js +28 -10
  226. package/dist/lib/ai/rich-text-translate.js.map +1 -1
  227. package/dist/lib/ai/shape.d.ts +13 -13
  228. package/dist/lib/ai/shape.js +69 -93
  229. package/dist/lib/ai/shape.js.map +1 -1
  230. package/dist/lib/ai/tools.d.ts +36 -41
  231. package/dist/lib/ai/tools.js +85 -87
  232. package/dist/lib/ai/tools.js.map +1 -1
  233. package/dist/lib/ai/translate-document.d.ts +39 -5
  234. package/dist/lib/ai/translate-document.js +160 -51
  235. package/dist/lib/ai/translate-document.js.map +1 -1
  236. package/dist/lib/ai/types.d.ts +34 -23
  237. package/dist/lib/ai/types.js.map +1 -1
  238. package/dist/lib/ai/update-fields.d.ts +21 -12
  239. package/dist/lib/ai/update-fields.js +118 -177
  240. package/dist/lib/ai/update-fields.js.map +1 -1
  241. package/dist/lib/ai/writer-form.d.ts +116 -0
  242. package/dist/lib/ai/writer-form.js +429 -0
  243. package/dist/lib/ai/writer-form.js.map +1 -0
  244. package/dist/lib/ai-current-document.d.ts +11 -11
  245. package/dist/lib/ai-current-document.js +4 -4
  246. package/dist/lib/ai-current-document.js.map +1 -1
  247. package/dist/lib/assets/upload.d.ts +31 -2
  248. package/dist/lib/assets/upload.js +61 -6
  249. package/dist/lib/assets/upload.js.map +1 -1
  250. package/dist/lib/clipboard/os-clipboard.d.ts +10 -2
  251. package/dist/lib/clipboard/os-clipboard.js +8 -4
  252. package/dist/lib/clipboard/os-clipboard.js.map +1 -1
  253. package/dist/lib/clipboard/paste-target.d.ts +18 -9
  254. package/dist/lib/clipboard/paste-target.js +8 -7
  255. package/dist/lib/clipboard/paste-target.js.map +1 -1
  256. package/dist/lib/cms/field-patch.d.ts +15 -0
  257. package/dist/lib/cms/field-patch.js +25 -0
  258. package/dist/lib/cms/field-patch.js.map +1 -0
  259. package/dist/lib/cms/published-documents.d.ts +1 -1
  260. package/dist/lib/cms/published-documents.js +1 -1
  261. package/dist/lib/cms/published-documents.js.map +1 -1
  262. package/dist/lib/cms-views/view-model.d.ts +3 -3
  263. package/dist/lib/collection-view/__fixtures__/document-writes.d.ts +6 -0
  264. package/dist/lib/collection-view/__fixtures__/document-writes.js +23 -0
  265. package/dist/lib/collection-view/__fixtures__/document-writes.js.map +1 -0
  266. package/dist/lib/collection-view/collection-view-source.d.ts +69 -6
  267. package/dist/lib/collection-view/collection-view-source.js.map +1 -1
  268. package/dist/lib/data/collection-content.d.ts +4 -13
  269. package/dist/lib/data/collection-content.js +11 -5
  270. package/dist/lib/data/collection-content.js.map +1 -1
  271. package/dist/lib/dnd/drop-rules.d.ts +25 -31
  272. package/dist/lib/dnd/drop-rules.js +53 -59
  273. package/dist/lib/dnd/drop-rules.js.map +1 -1
  274. package/dist/lib/engine-version.d.ts +1 -1
  275. package/dist/lib/engine-version.js +1 -1
  276. package/dist/lib/engine-version.js.map +1 -1
  277. package/dist/lib/i18n/messages.de.js +72 -15
  278. package/dist/lib/i18n/messages.de.js.map +1 -1
  279. package/dist/lib/i18n/messages.en.d.ts +61 -12
  280. package/dist/lib/i18n/messages.en.js +76 -16
  281. package/dist/lib/i18n/messages.en.js.map +1 -1
  282. package/dist/lib/operations/__fixtures__/write-document.d.ts +30 -0
  283. package/dist/lib/operations/__fixtures__/write-document.js +16 -0
  284. package/dist/lib/operations/__fixtures__/write-document.js.map +1 -0
  285. package/dist/lib/operations/cms-persistence.d.ts +124 -31
  286. package/dist/lib/operations/cms-persistence.js +447 -68
  287. package/dist/lib/operations/cms-persistence.js.map +1 -1
  288. package/dist/lib/operations/config-manifest-lookup.d.ts +35 -0
  289. package/dist/lib/operations/config-manifest-lookup.js +56 -0
  290. package/dist/lib/operations/config-manifest-lookup.js.map +1 -0
  291. package/dist/lib/operations/project-runtime-config.d.ts +39 -0
  292. package/dist/lib/operations/project-runtime-config.js +54 -0
  293. package/dist/lib/operations/project-runtime-config.js.map +1 -0
  294. package/dist/lib/operations/publish-with-revision.d.ts +64 -0
  295. package/dist/lib/operations/publish-with-revision.js +66 -0
  296. package/dist/lib/operations/publish-with-revision.js.map +1 -0
  297. package/dist/lib/operations/runtime-validator.d.ts +32 -0
  298. package/dist/lib/operations/runtime-validator.js +18 -0
  299. package/dist/lib/operations/runtime-validator.js.map +1 -0
  300. package/dist/lib/operations/session-hydration.d.ts +31 -14
  301. package/dist/lib/operations/session-hydration.js +12 -16
  302. package/dist/lib/operations/session-hydration.js.map +1 -1
  303. package/dist/lib/operations/studio-operations.d.ts +59 -2
  304. package/dist/lib/operations/studio-operations.js +76 -14
  305. package/dist/lib/operations/studio-operations.js.map +1 -1
  306. package/dist/lib/persistence/convex-adapter.d.ts +13 -5
  307. package/dist/lib/persistence/convex-adapter.js +189 -74
  308. package/dist/lib/persistence/convex-adapter.js.map +1 -1
  309. package/dist/lib/persistence/convex-client.d.ts +65 -5
  310. package/dist/lib/persistence/convex-client.js +106 -3
  311. package/dist/lib/persistence/convex-client.js.map +1 -1
  312. package/dist/lib/persistence/index.js +17 -18
  313. package/dist/lib/persistence/index.js.map +1 -1
  314. package/dist/lib/persona/labels.js +4 -1
  315. package/dist/lib/persona/labels.js.map +1 -1
  316. package/dist/lib/query/operations-query.d.ts +1 -1
  317. package/dist/lib/query/operations-query.js +1 -1
  318. package/dist/lib/query/operations-query.js.map +1 -1
  319. package/dist/lib/references/impact.d.ts +21 -15
  320. package/dist/lib/references/impact.js +13 -26
  321. package/dist/lib/references/impact.js.map +1 -1
  322. package/dist/lib/references/references-store.d.ts +9 -0
  323. package/dist/lib/references/references-store.js +24 -4
  324. package/dist/lib/references/references-store.js.map +1 -1
  325. package/dist/lib/routes/route-issues.d.ts +6 -6
  326. package/dist/lib/routes/route-issues.js +26 -80
  327. package/dist/lib/routes/route-issues.js.map +1 -1
  328. package/dist/lib/workspace/config-issues.js +2 -1
  329. package/dist/lib/workspace/config-issues.js.map +1 -1
  330. package/dist/lib/workspace/index.d.ts +31 -1
  331. package/dist/lib/workspace/index.js +64 -17
  332. package/dist/lib/workspace/index.js.map +1 -1
  333. package/dist/lib/workspace/switcher-source.d.ts +3 -3
  334. package/dist/lib/workspace/switcher-source.js.map +1 -1
  335. package/dist/lib/workspace/workspace-source.d.ts +2 -2
  336. package/dist/lib/workspace/workspace-source.js +2 -1
  337. package/dist/lib/workspace/workspace-source.js.map +1 -1
  338. package/package.json +3 -3
  339. package/dist/components/cms/cms-composition-validators.d.ts +0 -16
  340. package/dist/components/cms/cms-composition-validators.js +0 -133
  341. package/dist/components/cms/cms-composition-validators.js.map +0 -1
  342. package/dist/components/cms/publish-clean.d.ts +0 -28
  343. package/dist/components/cms/publish-clean.js +0 -38
  344. package/dist/components/cms/publish-clean.js.map +0 -1
  345. package/dist/components/cms/use-save-mode.d.ts +0 -35
  346. package/dist/components/cms/use-save-mode.js +0 -54
  347. package/dist/components/cms/use-save-mode.js.map +0 -1
  348. package/dist/lib/assets/asset-placements.d.ts +0 -28
  349. package/dist/lib/assets/asset-placements.js +0 -83
  350. package/dist/lib/assets/asset-placements.js.map +0 -1
  351. package/dist/lib/cms/document-gate.d.ts +0 -47
  352. package/dist/lib/cms/document-gate.js +0 -61
  353. package/dist/lib/cms/document-gate.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"default-modules.js","sourceRoot":"","sources":["../../../src/components/app-views/default-modules.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGjC,OAAO,EACL,MAAM,EACN,QAAQ,EACR,OAAO,EACP,KAAK,EACL,UAAU,EACV,QAAQ,IAAI,YAAY,EACxB,QAAQ,EACR,KAAK,GACN,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,0BAA0B,CA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C,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAChC,OAAO,CACL,KAAC,YAAY,IAAC,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,GAAI,CAClG,CAAA;IACH,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAChC,OAAO,KAAC,eAAe,IAAC,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,GAAI,CAAA;IAC9E,CAAC;IACD,OAAO,CACL,cAAK,SAAS,EAAC,oCAAoC,YACjD,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,YACzB,SAAS,CAAC,4BAA4B,EAAE;gBACvC,KAAK,EAAE,cAAc,CAAC,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC;aAC7D,CAAC,GACG,GACH,CACP,CAAA;AACH,CAAC;AAED,yEAAyE;AACzE,SAAS,qBAAqB;IAC5B,MAAM,GAAG,GAAG,MAAM,EAAE,CAAA;IACpB,IAAI,CAAC,GAAG,CAAC,YAAY;QAAE,OAAO,IAAI,CAAA;IAClC,OAAO,CACL,cAAK,SAAS,EAAC,qCAAqC,YAClD,KAAC,oBAAoB,IAAC,KAAK,EAAE,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,GAAG,CAAC,iBAAiB,GAAI,GAC/E,CACP,CAAA;AACH,CAAC","sourcesContent":["import { useEffect } from 'react'\nimport type { ReactNode } from 'react'\nimport type { LucideIcon } from 'lucide-react'\nimport {\n Blocks,\n Database,\n FileCog,\n Image,\n LayoutGrid,\n Settings as SettingsIcon,\n Signpost,\n Users,\n} from 'lucide-react'\nimport {\n assetCollection,\n extendCollectionDef,\n isSingleton,\n parseLocaleConfig,\n resolveSingletonDocument,\n} from '@elytracms/core/cms-core'\nimport type {\n CmsDocument,\n CollectionDef,\n CollectionFieldOverride,\n CollectionFormMeta,\n LocaleConfig,\n} from '@elytracms/core/cms-core'\nimport type { CustomizationIssue, Project, SectionId, SectionState } from '@elytracms/core/studio-core'\nimport { NavigateOnce, STUDIO_PROJECT_ROUTE, studioPath } from '@elytracms/studio/router'\nimport { Text } from '@elytracms/studio/ui'\nimport { localizedLabel, translate } from '@elytracms/studio/lib/i18n'\nimport { resolveDeploymentCollections, resolveDeploymentLocaleConfig } from '@elytracms/studio/lib/workspace'\nimport type { HydratedCms } from '@elytracms/studio/lib/operations'\nimport {\n cmsDeepLink,\n componentsDeepLink,\n usersDeepLink,\n redirectsDeepLink,\n assetsDeepLink,\n groupNode,\n separatorNode,\n viewNode,\n type AppViewContext,\n type AppViewDeepLink,\n type AppViewModule,\n type DerivedViewId,\n type NavPermission,\n type SidebarViewNode,\n} from './module'\nimport { SectionSurface } from '../section-surface'\nimport { SectionStateView } from '../section-state'\nimport { SettingsForm } from '../settings-form'\nimport { AssetsModule } from '../assets/assets-module'\nimport { UsersModule } from '../users/users-module'\nimport { RedirectsModule } from '../redirects/redirects-module'\nimport { redirectsCollectionDef } from '../redirects/redirects-schema'\nimport { RegistryBrowser } from '../components/registry-browser'\nimport { ComponentsIndex } from '../components/components-index'\nimport { ComponentDetail } from '../components/component-detail'\nimport { CmsSessionGate } from '../project-session'\nimport { CmsProvider, useCms } from '../cms/cms-store'\nimport { AiCmsPanel } from '../ai/ai-cms-panel'\nimport { focusCollectionList } from '../cms/collection-focus'\nimport { CmsIndex } from '../cms/cms-index'\nimport { CollectionTable } from '../cms/collection-table'\nimport { DetailEditor } from '../cms/detail-editor'\nimport { OperationErrorBanner } from '../operation-error'\n\n/**\n * EC-237/239 — the studio's BUILT-IN views + the consumer-facing `nav` namespace,\n * an instance of the EC-236 customization seam.\n *\n * Each built-in surface (the former `StudioSectionResolver` case body) is promoted\n * to a self-contained {@link AppViewModule} factory. The `nav` namespace is the\n * single, typed builder a consuming repo's `studio.config.tsx` uses to declare its\n * section rail — `nav.cms(...)`, `nav.group(...)`, `nav.view(...)` — passing the\n * view objects (and a focus config) DIRECTLY, never a string id. The CMS surface\n * is a factory ({@link cmsView}) so a focused view (\"Catalog\", \"Categories\") is the\n * SAME surface instantiated with config, not a copy — the EC-239 reuse proof.\n */\n\n// --- The CMS surface, reusable via a config factory (the EC-239 reuse seam) ---\n\n/** Config for a CMS-backed view — `collections`/`collection` focus the lens (EC-239). */\nexport interface CmsViewConfig {\n /** Explicit stable id (the route segment). Omitted → derived from the focus. */\n id?: string\n label?: string\n description?: string\n icon?: LucideIcon\n /**\n * Scope the rail auto-expansion (EC-293) to these collection ids, in order. The\n * parent expands into one focused-lens child per id; the parent index shows the\n * same subset. Omitted → every collection. Ignored for a single-collection lens.\n *\n * A ONE-ITEM array is legal and degrades to a working (if redundant) parent+child\n * pair — the parent takes the `cms-group:<id>` id so it cannot collide with its own\n * child (EC-468). For a single collection with no group heading, prefer the\n * {@link CmsViewConfig.collection} leaf form.\n */\n collections?: readonly string[]\n /** Single-collection lens: a LEAF rail item that opens straight into this collection. */\n collection?: string\n /**\n * EC-293 escape hatch: explicit rail children for this CMS parent, overriding the\n * default per-collection auto-expansion. Ignored for a single-collection lens.\n */\n children?: SidebarViewNode[]\n /** The availability section this view rides on (EC-221); defaults to `cms`. */\n availabilitySection?: SectionId\n /** OPTIONAL, default-open nav-permission predicate (EC-240 / AD-18). See {@link BuiltinViewConfig.visible}. */\n visible?: NavPermission\n}\n\n/** Common label/icon overrides for a built-in view (`nav.redirects({ label: 'URLs' })`). */\nexport interface BuiltinViewConfig {\n label?: string\n icon?: LucideIcon\n /**\n * OPTIONAL, default-open nav-permission predicate (EC-240 / AD-18): hide this\n * rail item for principals it returns `false` for; absent → always visible. The\n * policy (which roles) lives in the consuming project, never the engine. E.g.\n * `nav.users({ visible: ({ role }) => role === 'admin' })`.\n */\n visible?: NavPermission\n}\n\n/**\n * Config for the **redirects** rail (EC-311) — a built-in view whose engine-owned\n * schema is customizable. Beyond the shared label/icon/visible, a mount may rename\n * the rail (`form`) and **override built-in fields by equal name** (`fields`):\n * naming, permissions (`form.readOnly`), rendering (`form.control` → `fieldRenderers`)\n * and validation. The canonical `from`/`to`/`permanent`/`enabled` names+types are\n * contract-locked (a type change on one is a loud config error), but a *net-new*\n * field is allowed (EC-311 Tier 2): it's appended and persists in the redirect\n * record's `meta` bag — editorial only, so it never reaches delivery/routing.\n */\nexport interface RedirectsViewConfig extends BuiltinViewConfig {\n /** Rename the rail (e.g. `{ label: 'URLs' }`). */\n form?: Partial<CollectionFormMeta>\n /** Override built-in redirect fields, matched by `name`. */\n fields?: readonly CollectionFieldOverride[]\n}\n\n/**\n * Config for the **assets** rail (EC-319), customizable by the SAME EC-311\n * mechanism as redirects (`form`/`fields`) — but the BASE schema it overrides is\n * different in kind: redirects' base is an engine-owned, fixed `CollectionDef`\n * known at config-build time; the assets base is the DEPLOYMENT's own\n * `kind:'asset'` collection (a project's `cms/collections/asset.ts`), only\n * knowable once the deployment resolves (hydrated session → playground\n * config — see {@link resolveAssetsSchema}). So the merge runs at RENDER time\n * (inside `assetsView`'s `CmsSessionGate`), not at `nav.assets(config)` call\n * time: a locked-violation override (e.g. changing a declared field's type)\n * surfaces the first time the Assets section renders, not at `defineStudio`\n * mount — the one place this rail's customization contract differs from\n * redirects', a direct consequence of its base schema being project-declared.\n */\nexport interface AssetsViewConfig extends BuiltinViewConfig {\n /** Rename the rail (e.g. `{ label: 'Media' }`). */\n form?: Partial<CollectionFormMeta>\n /** Override the project's declared asset fields, matched by `name`. */\n fields?: readonly CollectionFieldOverride[]\n}\n\n/** Config for a fully custom view (`nav.view({...})`) — the net-new surface escape hatch. */\nexport interface CustomViewConfig {\n /** Explicit stable id (the route segment). Omitted → a slug of the label. */\n id?: string\n label: string\n description?: string\n icon?: LucideIcon\n render: (ctx: AppViewContext) => ReactNode\n parsePath?: (segments: string[]) => AppViewDeepLink | null\n availabilitySection?: SectionId\n /** OPTIONAL, default-open nav-permission predicate (EC-240 / AD-18). See {@link BuiltinViewConfig.visible}. */\n visible?: NavPermission\n}\n\nfunction slugify(label: string): string {\n return label.trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'view'\n}\n\n/**\n * The auto-parent namespace for a ONE-ITEM `collections` group (EC-468).\n *\n * A PREFIX, not a suffix, and deliberately so: every other derived CMS id starts with\n * `cms:`, so the 4th character (`-` here, `:` there) makes the two namespaces disjoint\n * BY CONSTRUCTION — no collection id, whatever it contains, can forge a `cms-group:`\n * id, whereas a suffix marker (`cms:page:group`) would be forged by a collection\n * literally named `page:group` (`collectionDefSchema.id` is `z.string().min(1)` —\n * nothing reserves `:` or `-`).\n */\nconst CMS_GROUP_ID_PREFIX = 'cms-group:'\n\n/**\n * Derive a stable, deterministic id from the CMS focus (overridable via `config.id`).\n *\n * The id is the route segment, the rail's active-state key AND the override key\n * (EC-311), so it must be injective: two focuses deriving one id means\n * `resolveOverrides` drops the later view. The derived shapes:\n *\n * | focus | id |\n * | ---------------------------- | ------------------------- |\n * | none | `cms` |\n * | `collection: 'page'` (leaf) | `cms:page` |\n * | `collections: ['a','b']` | `cms:a-b` |\n * | `collections: ['page']` | `cms-group:page` |\n *\n * EC-468 — why the one-item group is its own namespace: `cms:${join(L)}` of a\n * single-element list IS that element, so the auto-generated PARENT took the very id\n * its own auto-expanded child derives (`cmsCollectionLeaf` → `cmsView({ collection })`).\n * Both landed in the one flat override list `resolveSidebar` feeds `resolveOverrides`,\n * so the child was dropped with a `duplicate-override-id` error and the parent rendered\n * childless — a forced collision no config could avoid. Nothing else changes: the leaf\n * and the multi-collection join keep their exact ids (consumer rails route on them).\n *\n * EC-477 — `-` is a SEPARATOR here, and a collection id may legally contain one, so a\n * collection literally named `a-b` derives the same `cms:a-b` as a `['a','b']` group.\n * That ambiguity is NOT closed by constraining collection ids (a permanent, repo-wide\n * naming ban to fix a two-config coincidence, when hyphenated ids are ordinary — see\n * the task's Done); it is DETECTED where both facts are known, by\n * {@link checkSidebarIdKeyspace}, which raises a `derived-id-collision` the moment a\n * group's join equals a real collection id. The escape hatch is unchanged: an explicit\n * `nav.cms({ id })` always wins, and the derivation below is untouched — consumer rails\n * route on these ids.\n */\nexport function cmsViewId(config: CmsViewConfig): string {\n if (config.id) return config.id\n if (config.collection) return `cms:${config.collection}`\n const collections = config.collections\n if (collections && collections.length > 0) {\n if (collections.length === 1) return `${CMS_GROUP_ID_PREFIX}${collections[0]}`\n return `cms:${joinCollectionIds(collections)}`\n }\n return 'cms'\n}\n\n/** The multi-collection focus join — ONE definition, so the id and the EC-477 check cannot drift. */\nfunction joinCollectionIds(collections: readonly string[]): string {\n return [...collections].join('-')\n}\n\n/**\n * The id provenance a CMS focus carries for diagnostics (EC-477) — set only for the one\n * derived shape that is genuinely ambiguous: a MULTI-collection join. An explicit `id`,\n * a single-collection leaf and the one-item `cms-group:` parent are all unambiguous by\n * construction (EC-468), so they carry nothing and are never diagnosed.\n */\nfunction cmsDerivedId(config: CmsViewConfig): DerivedViewId | undefined {\n if (config.id || config.collection) return undefined\n const collections = config.collections\n if (!collections || collections.length < 2) return undefined\n return { from: 'collection-join', collections: [...collections] }\n}\n\n/**\n * Build a CMS view — the default `cms` view, or a focused instance. Every instance\n * shares one surface ({@link CmsScreen}); `collections` narrows the sidebar + index\n * to a subset, `collection` is a single-collection lens that opens straight into\n * that collection's list. The id is derived from the focus (deterministic, stable\n * across rail reorders) unless `id` is given — see {@link cmsViewId} for the derived\n * shapes and the one keyspace ambiguity that survives.\n */\nexport function cmsView(config: CmsViewConfig = {}): AppViewModule {\n const single = config.collection\n const focus = single ? [single] : config.collections\n const derivedId = cmsDerivedId(config)\n return {\n id: cmsViewId(config),\n ...(derivedId ? { derivedId } : {}),\n // Lazy label/description (EC-241): the sidebar is built when the consumer's\n // `studio.config` module loads — BEFORE `createStudio` seeds the i18n config — so\n // resolving here would bake English. A getter defers resolution to render, when\n // the config is present and the browser locale is known.\n get label() {\n return config.label ?? translate('nav.cms.label')\n },\n get description() {\n return config.description ?? translate('nav.cms.description')\n },\n icon: config.icon ?? Database,\n availabilitySection: config.availabilitySection ?? 'cms',\n // A single-collection lens routes `[]`→that collection, `[d]`→its document;\n // an unfocused / multi-collection view uses the full index/collection/document arity.\n parsePath: single\n ? (segments) =>\n segments.length === 0\n ? { collectionId: single, documentId: null }\n : segments.length === 1\n ? { collectionId: single, documentId: segments[0]! }\n : null\n : cmsDeepLink,\n render: (ctx) => (\n <CmsScreen\n project={ctx.project}\n collectionId={ctx.deepLink.collectionId ?? null}\n documentId={ctx.deepLink.documentId ?? null}\n state={ctx.search.state}\n field={ctx.search.field}\n focusCollections={focus}\n />\n ),\n }\n}\n\n/**\n * A focused-lens rail child for one collection (EC-293) — the SAME `cms:<id>` view a\n * single-collection `nav.cms({ collection })` produces, carrying the collection's own\n * label + a singleton-aware icon (the former `CollectionsSidebar` row, lifted into\n * the rail). CMS auto-expansion maps the project's collections through this.\n */\nfunction cmsCollectionLeaf(collection: CollectionDef): SidebarViewNode {\n const singleton = isSingleton(collection)\n return viewNode(\n cmsView({\n collection: collection.id,\n // Non-hook `localizedLabel` resolves the (possibly `{ en, de }`) collection label\n // against the active UI locale, so a German editor sees German collection names.\n label: localizedLabel(collection.form?.label, collection.id),\n icon: singleton ? FileCog : collection.kind === 'asset' ? Image : Database,\n }),\n )\n}\n\n/** The components registry browser view. */\nexport function componentsView(config: BuiltinViewConfig = {}): AppViewModule {\n return {\n id: 'components',\n get label() {\n return config.label ?? translate('nav.components.label')\n },\n get description() {\n return translate('nav.components.description')\n },\n icon: config.icon ?? Blocks,\n availabilitySection: 'components',\n parsePath: componentsDeepLink,\n render: (ctx) => (\n <ComponentsScreen\n projectId={ctx.projectId}\n componentId={ctx.deepLink.componentId ?? null}\n state={ctx.search.state}\n />\n ),\n }\n}\n\n/**\n * The Redirects view (EC-303) — editorial redirects as DATA, an editor-owned CRUD\n * surface (create/edit/delete) over the portable list/edit surfaces. Routes are no\n * longer shown in the admin (they're code; native `next.config`/`vercel` own static\n * forwards, evaluated before these). Rides on the CMS availability (a content/\n * routing concern). `[]` is the list; `[redirectId]` opens that redirect's detail.\n */\nexport function redirectsView(config: RedirectsViewConfig = {}): AppViewModule {\n // EC-311: merge any field/label overrides over the engine-owned def ONCE, at config\n // build (config-as-code — a locked violation throws here, at `defineStudio` mount).\n // Tier 2: `additiveFields: 'allow'` — a net-new field is appended and persists in the\n // redirect record's `meta` bag (the canonical from/to/permanent/enabled stay locked).\n const schema = extendCollectionDef(redirectsCollectionDef, config, { additiveFields: 'allow' })\n return {\n id: 'redirects',\n get label() {\n // Prefer an explicit rail label, then a consumer-*customized* collection label,\n // else the localized catalog nav label. Never let the built-in English schema\n // label ('Redirects') preempt translation — compare against the built-in default.\n const customized = localizedLabel(schema.form?.label)\n const builtin = localizedLabel(redirectsCollectionDef.form?.label)\n return (\n config.label ??\n (customized && customized !== builtin ? customized : translate('nav.redirects.label'))\n )\n },\n get description() {\n return translate('nav.redirects.description')\n },\n icon: config.icon ?? Signpost,\n availabilitySection: 'cms',\n parsePath: redirectsDeepLink,\n render: (ctx) =>\n ctx.search.state && ctx.search.state !== 'working' ? (\n <SectionStateView state={ctx.search.state} title={translate('nav.redirects.label')} />\n ) : (\n <RedirectsModule\n projectId={ctx.projectId}\n redirectId={ctx.deepLink.redirectId ?? null}\n schema={schema}\n />\n ),\n }\n}\n\n/**\n * Resolve the assets rail's EFFECTIVE schema (EC-319/EC-311): the deployment's\n * OWN `kind:'asset'` collection — hydrated session → playground config,\n * the exact same precedence {@link resolveCmsInitialCollections} gives every\n * other CMS collection — falling back to the engine's `assetCollection` fixture\n * only when nothing resolves (mirroring `CmsProvider`'s own fallback). A mount's\n * `nav.assets({ form, fields })` then merges over THAT base (EC-311, additive\n * fields allowed — a project's asset record already carries an open `meta` bag,\n * EC-301). Pure — no React — so it's unit-testable without `CmsSessionGate`.\n */\nexport function resolveAssetsSchema(\n collections: readonly CollectionDef[] | undefined,\n config: AssetsViewConfig,\n): CollectionDef {\n const base = collections?.find((c) => c.kind === 'asset') ?? assetCollection\n return extendCollectionDef(base, config, { additiveFields: 'allow' })\n}\n\n/**\n * The Assets view (EC-319) — the universal list (+ grid/list toggle) and a\n * bespoke per-asset detail surface, over the asset library store. `[]` is the\n * list; `[assetId]` opens that asset's detail (routed via `studioPath.asset`).\n * A `?asset=` deep link (EC-172 \"used by\" links) redirects straight to the\n * asset's detail — the surface those links used to scroll a card into and\n * auto-open, now a first-class route.\n */\nexport function assetsView(config: AssetsViewConfig = {}): AppViewModule {\n return {\n id: 'assets',\n get label() {\n return config.label ?? translate('nav.assets.label')\n },\n get description() {\n return translate('nav.assets.description')\n },\n icon: config.icon ?? Image,\n availabilitySection: 'assets',\n parsePath: assetsDeepLink,\n render: (ctx) => (\n <SectionSurface project={ctx.project} section=\"assets\" forcedState={ctx.search.state}>\n {ctx.deepLink.assetId === null && ctx.search.asset ? (\n // EC-441: `NavigateOnce` — render-time redirects fire once per intent.\n <NavigateOnce\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId: ctx.projectId, _splat: studioPath.asset(ctx.search.asset) }}\n replace\n />\n ) : (\n // The AssetsProvider is mounted at the project level (EC-195).\n <CmsSessionGate>\n {(cms) => {\n const schema = resolveAssetsSchema(resolveCmsInitialCollections(cms), config)\n return (\n <AssetsModule\n projectId={ctx.projectId}\n assetId={ctx.deepLink.assetId ?? null}\n schema={schema}\n />\n )\n }}\n </CmsSessionGate>\n )}\n </SectionSurface>\n ),\n }\n}\n\n/**\n * The studio Users view (EC-240) — an admin-only roster of who has access to this\n * deployment and their role. A first-class section (its own rail entry), modeled\n * like the Assets library; the surface itself gates to admins and renders a\n * \"restricted\" state otherwise. Rides on the `settings` availability (an\n * admin/config concern, so it appears/hides with a project's settings surface).\n */\nexport function usersView(config: BuiltinViewConfig = {}): AppViewModule {\n return {\n id: 'users',\n get label() {\n return config.label ?? translate('nav.users.label')\n },\n get description() {\n return translate('nav.users.description')\n },\n icon: config.icon ?? Users,\n availabilitySection: 'users',\n // EC-240: `[]` is the roster; `[userId]` opens that member in the portable edit\n // shell (AD-19 reuse — the same `DetailEditor` body over the users source).\n parsePath: usersDeepLink,\n render: (ctx) =>\n ctx.search.state && ctx.search.state !== 'working' ? (\n <SectionStateView state={ctx.search.state} title={translate('nav.users.label')} />\n ) : (\n <UsersModule projectId={ctx.projectId} userId={ctx.deepLink.userId ?? null} />\n ),\n }\n}\n\n/** The project settings view. */\nexport function settingsView(config: BuiltinViewConfig = {}): AppViewModule {\n return {\n id: 'settings',\n get label() {\n return config.label ?? translate('nav.settings.label')\n },\n get description() {\n return translate('nav.settings.description')\n },\n icon: config.icon ?? SettingsIcon,\n availabilitySection: 'settings',\n render: (ctx) => (\n <SectionSurface project={ctx.project} section=\"settings\" forcedState={ctx.search.state}>\n <SettingsForm project={ctx.project} />\n </SectionSurface>\n ),\n }\n}\n\n/** The legacy `builder` redirect — a hidden, routable view (so `/builder?page=` still lands). */\nexport function builderView(): AppViewModule {\n return {\n id: 'builder',\n label: 'Builder',\n description: 'Legacy builder route — redirects to the page document editor.',\n icon: Blocks,\n hidden: true,\n render: (ctx) => (\n // Retired surface (EC-187 slice 6): a page is a document in the `page`\n // collection. `?page=<id>` lands on that document; else the page list.\n // EC-441: `NavigateOnce` — render-time redirects fire once per intent.\n <NavigateOnce\n to={STUDIO_PROJECT_ROUTE}\n params={{\n projectId: ctx.projectId,\n _splat: ctx.search.page\n ? studioPath.cmsDocument('page', ctx.search.page)\n : studioPath.cmsCollection('page'),\n }}\n replace\n />\n ),\n }\n}\n\n/**\n * Build a fully custom view (the `nav.view(...)` escape hatch).\n *\n * With no `id` the id is a SLUG of the label, and that slug carries a\n * {@link DerivedViewId} marker (EC-476): a label is a display string a developer picks\n * freely, so `label: 'CMS'` deriving `cms` is a coincidence, not a request to replace\n * the built-in CMS surface. {@link checkSidebarIdKeyspace} refuses the takeover and\n * says so; an explicit `id` carries no marker and keeps the documented replacement.\n */\nexport function customView(config: CustomViewConfig): AppViewModule {\n const derivedId: DerivedViewId | undefined = config.id\n ? undefined\n : { from: 'label', label: config.label }\n return {\n id: config.id ?? slugify(config.label),\n ...(derivedId ? { derivedId } : {}),\n label: config.label,\n description: config.description ?? config.label,\n icon: config.icon ?? LayoutGrid,\n render: config.render,\n ...(config.parsePath ? { parsePath: config.parsePath } : {}),\n ...(config.availabilitySection ? { availabilitySection: config.availabilitySection } : {}),\n }\n}\n\n/**\n * The studio's built-in views in canonical rail order (components · CMS · routes ·\n * assets · extensions · settings), plus the hidden `builder` redirect (routable but\n * unlisted). The default rail (no `defineStudio({ sidebar })`) is these as plain\n * entries; the router registry always includes them so deep-links resolve even\n * when a consumer's rail omits one.\n */\nexport const DEFAULT_VIEWS: readonly AppViewModule[] = [\n componentsView(),\n cmsView(),\n redirectsView(),\n assetsView(),\n usersView(),\n settingsView(),\n builderView(),\n]\n\n/**\n * Every id the engine already owns — the replacement targets of the sidebar seam,\n * INCLUDING the hidden `builder` redirect (it is in the keyspace even though the stock\n * rail does not list it, so a derived id can swallow it just the same).\n */\nexport const BUILTIN_VIEW_IDS: ReadonlySet<string> = new Set(DEFAULT_VIEWS.map((view) => view.id))\n\n/** The extension point these issues are located at — the same literal `resolveSidebar` stamps. */\nconst SIDEBAR_POINT = 'sidebar'\n\n/**\n * The catalog keys for the two keyspace findings (EC-478). This module stays pure —\n * it names a key and its identifier values; `lib/persona/labels.ts` resolves them at\n * the render site, so the rail foot localizes as one list.\n */\nconst KEYSPACE_KEYS = {\n builtinCollision: 'customization.issue.derivedIdBuiltinCollision',\n collectionCollision: 'customization.issue.derivedIdCollectionCollision',\n} as const\n\n/** The outcome of the keyspace check: the entries that may still act as overrides, plus the findings. */\nexport interface SidebarIdKeyspace {\n /**\n * The views to resolve as overrides — an ACCIDENTAL built-in takeover removed, so the\n * engine keeps its own block (the EC-236 contract for a rejected entry). Everything\n * else passes through untouched, including the merely-ambiguous EC-477 case.\n */\n views: AppViewModule[]\n /** What was found — visible at the rail foot, never silent. */\n issues: CustomizationIssue[]\n}\n\n/**\n * EC-476/477 — guard the sidebar id keyspace against ids that were DERIVED rather than\n * declared, and landed somewhere that already means something.\n *\n * The seam's replacement rule is id equality (`resolveOverrides`: an entry whose id is a\n * default's id replaces it). That is exactly right for an id the developer TYPED, and\n * exactly wrong for one a builder computed — and the generic core cannot tell them\n * apart, because by the time an entry reaches it, an id is just a string. So the rule\n * lives HERE, next to the derivations that produce it ({@link slugify},\n * {@link cmsViewId}) and next to {@link DEFAULT_VIEWS}, the set it has to protect.\n *\n * Two derived shapes, two different remedies — because the cost of being wrong differs:\n *\n * - **A slugged LABEL landing on a built-in id (EC-476) is REJECTED** (`error`). Losing\n * a whole built-in surface — the CMS, Assets, the users roster — to a coincidence of\n * spelling is far worse than one custom view not appearing, and the developer's fix is\n * a one-line explicit `id`. The built-in is kept, so nothing disappears.\n * - **A collection JOIN equal to a real collection id (EC-477) is KEPT** (`warning`).\n * Nothing here is a takeover: the group's id is legitimate, it is merely no longer\n * unique to it, so dropping the view would destroy a rail item the developer\n * explicitly declared in order to report a naming clash. Reporting is the whole fix.\n *\n * Pure and deterministic — the house \"extract the core, test the core\" shape.\n * `builtinIds` and `collections` are parameters so the rule is testable against a\n * synthetic keyspace, not just the live one.\n */\nexport function checkSidebarIdKeyspace(\n views: readonly AppViewModule[],\n collections: readonly CollectionDef[] = [],\n builtinIds: ReadonlySet<string> = BUILTIN_VIEW_IDS,\n): SidebarIdKeyspace {\n const collectionIds = new Set(collections.map((collection) => collection.id))\n const kept: AppViewModule[] = []\n const issues: CustomizationIssue[] = []\n\n for (const view of views) {\n const derived = view.derivedId\n\n // EC-476 — an auto-derived id must never claim a built-in surface.\n if (derived?.from === 'label' && builtinIds.has(view.id)) {\n issues.push({\n code: 'derived-id-collision',\n severity: 'error',\n message: `View \"${derived.label}\" for \"${SIDEBAR_POINT}\" derives the id \"${view.id}\" from its label, which is the built-in \"${view.id}\" view — the built-in is kept and this view is ignored. Pass an explicit id to replace a built-in on purpose.`,\n messageRef: {\n key: KEYSPACE_KEYS.builtinCollision,\n vars: { label: derived.label, point: SIDEBAR_POINT, id: view.id },\n },\n point: SIDEBAR_POINT,\n id: view.id,\n })\n continue\n }\n\n // EC-477 — a multi-collection join that a single collection could equally have produced.\n if (derived?.from === 'collection-join' && collectionIds.has(joinCollectionIds(derived.collections))) {\n issues.push({\n code: 'derived-id-collision',\n severity: 'warning',\n message: `View id \"${view.id}\" for \"${SIDEBAR_POINT}\" is ambiguous: it joins the collections ${quotedIds(derived.collections)} with \"-\", and a collection is literally named \"${joinCollectionIds(derived.collections)}\" — its own lens derives the same id. Pass an explicit id to this group.`,\n messageRef: {\n key: KEYSPACE_KEYS.collectionCollision,\n vars: {\n id: view.id,\n point: SIDEBAR_POINT,\n collections: quotedIds(derived.collections),\n joined: joinCollectionIds(derived.collections),\n },\n },\n point: SIDEBAR_POINT,\n id: view.id,\n })\n }\n\n kept.push(view)\n }\n\n return { views: kept, issues }\n}\n\n/** `\"a\", \"b\"` — a readable id list for an issue message (the EC-467 issue-copy shape). */\nfunction quotedIds(ids: readonly string[]): string {\n return ids.map((id) => `\"${id}\"`).join(', ')\n}\n\n/**\n * The `nav` namespace — the single typed builder for `studio.config.tsx`'s section\n * rail. Each call returns a {@link SidebarViewNode} (or a group / separator) that\n * carries its view DIRECTLY: `nav.cms({ collection })` is a focused CMS view,\n * `nav.view({ render })` a net-new surface, `nav.group(label, [...])` a header with\n * sub-views, `nav.separator()` a divider. No string ids, no `moduleId` — the rail\n * is the views.\n */\n/**\n * Forward the OPTIONAL, default-open nav-permission predicate (EC-240 / AD-18)\n * from a `nav.*` config onto the built view, so gating is settable on EVERY nav\n * item — not just Users. Absent → the view is unchanged (always visible).\n */\nfunction withNavPermission(view: AppViewModule, config: { visible?: NavPermission }): AppViewModule {\n if (!config.visible) return view\n // Copy property DESCRIPTORS (not a spread) so a built-in view's lazy `label`/\n // `description` getters (EC-241) survive — a spread would invoke them at build time,\n // baking English before `createStudio` seeds the i18n config.\n return Object.defineProperties({} as AppViewModule, {\n ...Object.getOwnPropertyDescriptors(view),\n visible: { value: config.visible, enumerable: true, configurable: true, writable: true },\n })\n}\n\nexport const nav = {\n /**\n * The CMS view. `nav.cms()` / `nav.cms({ collections })` is a PARENT that nests its\n * collections in the rail (each a focused `cms:<id>` lens); `nav.cms({ collection })`\n * is a single-collection LEAF; `nav.cms({ children })` supplies explicit children.\n * A one-item `collections` group is a parent whose id is `cms-group:<id>`, distinct\n * from its single child by construction (EC-468 — see {@link cmsViewId}).\n */\n cms: (config: CmsViewConfig = {}): SidebarViewNode => {\n const view = withNavPermission(cmsView(config), config)\n // A single-collection lens is a leaf — it opens that collection directly.\n if (config.collection) return viewNode(view)\n // Otherwise a parent that expands its collections as nested rail children (EC-293).\n const node: SidebarViewNode = { kind: 'view', view }\n if (config.children) node.children = config.children\n else\n node.expand = (collections) =>\n focusCollectionList(collections, config.collections).map(cmsCollectionLeaf)\n return node\n },\n /** The component registry browser. */\n components: (config: BuiltinViewConfig = {}): SidebarViewNode =>\n viewNode(withNavPermission(componentsView(config), config)),\n /** The assets rail — the universal list/grid + detail (EC-319); built-in\n * fields customizable by name (EC-311), the same shape as `nav.redirects`. */\n assets: (config: AssetsViewConfig = {}): SidebarViewNode =>\n viewNode(withNavPermission(assetsView(config), config)),\n /** Editorial redirects (EC-303); built-in fields customizable by name (EC-311). */\n redirects: (config: RedirectsViewConfig = {}): SidebarViewNode =>\n viewNode(withNavPermission(redirectsView(config), config)),\n /** Project settings. */\n settings: (config: BuiltinViewConfig = {}): SidebarViewNode =>\n viewNode(withNavPermission(settingsView(config), config)),\n /** The admin users roster (EC-240). */\n users: (config: BuiltinViewConfig = {}): SidebarViewNode =>\n viewNode(withNavPermission(usersView(config), config)),\n /** A fully custom view — pass your own `render` (and optional `parsePath`). */\n view: (config: CustomViewConfig): SidebarViewNode =>\n viewNode(withNavPermission(customView(config), config)),\n /** A labelled group of views (a header with sub-entries). */\n group: (label: string, children: SidebarViewNode[]) => groupNode(label, children),\n /** A divider between rail sections. */\n separator: () => separatorNode(),\n} as const\n\n// --- Surfaces (the view render bodies; CMS gains a focus lens) ---\n\n/**\n * Components section (EC-050): a registry-browser sidebar beside the active\n * screen — the index (no selection) or a component's detail. Forced states\n * (?state=) replace the whole surface.\n */\nfunction ComponentsScreen({\n projectId,\n componentId,\n state,\n}: {\n projectId: string\n componentId: string | null\n state?: SectionState\n}) {\n if (state && state !== 'working') {\n return <SectionStateView state={state} title={translate('nav.components.label')} />\n }\n return (\n <div className=\"flex h-full min-h-0\">\n <aside className=\"hidden h-full min-h-0 w-[300px] shrink-0 border-r border-border md:block\">\n <RegistryBrowser projectId={projectId} activeComponentId={componentId ?? undefined} />\n </aside>\n <div className=\"min-h-0 flex-1 overflow-auto\">\n {componentId === null ? (\n <ComponentsIndex projectId={projectId} />\n ) : (\n <ComponentDetail projectId={projectId} componentId={componentId} />\n )}\n </div>\n </div>\n )\n}\n\n/**\n * The CMS schema source for a project mount: a hydrated session wins (Convex),\n * then a kit's imported schema (EC-119), then the active project's\n * config-declared collections (AD-11, `resolveDeploymentCollections`).\n *\n * EC-479 — every rung is the PROJECT's own schema and there is no rung after\n * them. The config rung used to be gated on playground mode, because outside it\n * the `undefined` return let `CmsProvider` fall through to `cms-core`'s\n * `sampleFilterableCollections` fixture — the engine's demo schema, shown as the\n * project's, offering `filterable` fields the project's real backend would\n * reject. With that fallback retired the gate has nothing left to protect: the\n * Convex adapter is itself constructed with `resolveDeploymentCollections()`\n * (`lib/persistence/index.ts`), so config collections are what connected mode\n * serves too. Dropping it also DISSOLVES the EC-467 two-source divergence — the\n * section rail reads `resolveDeploymentCollections()` directly, and now so does\n * the store's last rung, so the two can no longer disagree.\n */\nexport function resolveCmsInitialCollections(cms: HydratedCms | null): CollectionDef[] | undefined {\n return cms?.collections ?? resolveDeploymentCollections()\n}\n\n/**\n * The CMS documents source for a project mount — the document-side twin of\n * {@link resolveCmsInitialCollections}: a hydrated session wins (Convex), then\n * **nothing**. (The middle rung, a starter kit's imported documents, went with\n * the kits — EC-574; K rebuilds starter kits as seeds, EC-200/EC-475.)\n *\n * EC-479 — the third rung used to be the engine's own `sampleDocuments` fixture,\n * reconciled against the project's schema (EC-424). Reconciling it was already an\n * admission that the content was foreign: EC-424 existed only because the demo\n * declares `post.slug` localized while the shared fixture stores it plain, so the\n * seeded posts carried standing validation noise no project had written. The\n * honest fix is not a better reconciliation but no foreign content at all — a\n * studio whose config did not arrive now shows an empty CMS and a visible issue\n * at the rail, not six documents about Ada Lovelace wearing the project's schema.\n *\n * The playground keeps its world through the ordinary path, not through here: its\n * seeded in-memory adapter IS a persisted backend behind the operations seam\n * (AD-17), so `CmsSessionGate` hydrates it and the first rung answers. What that\n * adapter seeds is `persistence/seed.ts`'s business — EC-475 (project-defined seed\n * content) owns it.\n */\nexport function resolveCmsInitialDocuments(cms: HydratedCms | null): CmsDocument[] | undefined {\n return cms?.documents\n}\n\n/**\n * The CMS locale config for a project mount (EC-357 finding #3). Locales are\n * structure and structure is code: when the active `elytra.config.ts` project\n * declares locales, they drive the ambient locale switcher in EVERY mode. The old\n * wiring only applied the project's locale settings on a HYDRATED session, so a\n * playground boot — or a connected FIRST RUN with nothing persisted yet — fell\n * back to a kit's locales or the core's sample `en/de` fixture and the switcher\n * showed `EN·/DE` against a `locales: ['de']` config.\n *\n * EC-479/EC-483 — the ladder is now TOTAL, and every rung is the project's own:\n * config-declared locales, then its settings (a starter kit's locales used to sit\n * between the two; the kits went in EC-574). A `Project` only ever exists for a\n * config-declared project (`studio-context.tsx`: `configProjects()`), so\n * `project.settings` is config-derived too — which is what lets the CMS session\n * require a locale instead of borrowing the engine's `en/de` fixture. The default\n * locale is the literal storage key for every localized value, so a guessed one is\n * a data migration. Both rungs are config-derived and pass the workspace gate\n * (`default-locale-not-in-locales` is an error there), so the value is valid by\n * construction and no reader repairs it. `configLocales` is a parameter purely so\n * the ladder is unit-testable (same seam pattern as\n * {@link resolveCmsInitialCollections}); `cms` is accepted for signature parity\n * with its twins but no longer selects a rung.\n */\nexport function resolveCmsInitialLocaleConfig(\n _cms: HydratedCms | null,\n project: Project,\n configLocales: LocaleConfig | undefined = resolveDeploymentLocaleConfig(),\n): LocaleConfig {\n if (configLocales) return configLocales\n return parseLocaleConfig({\n default: project.settings.defaultLocale,\n locales: [...project.settings.locales],\n })\n}\n\n/**\n * CMS section: hydrates the persisted (or kit-seeded) collections + documents, then\n * renders the active screen full-width (index, a collection table, or a document\n * editor). EC-293: the collection list lives in the section rail (nested under the\n * CMS view), so there is no in-surface collections sidebar. Forced states (?state=)\n * replace the whole surface. `focusCollections` (EC-239) narrows the index to a\n * subset, so a focused view (\"Catalog\") reuses this surface with config.\n */\nfunction CmsScreen({\n project,\n collectionId,\n documentId,\n state,\n field,\n focusCollections,\n}: {\n project: Project\n collectionId: string | null\n documentId: string | null\n state?: SectionState\n field?: string\n focusCollections?: readonly string[]\n}) {\n const projectId = project.id\n if (state && state !== 'working') {\n return <SectionStateView state={state} title={translate('nav.cms.label')} />\n }\n\n return (\n // EC-177 gap 1: every CMS mount loads the CURRENT persisted schema +\n // documents (both modes since EC-461). Nothing persisted — a connected first\n // run — means an EMPTY session plus the rail's visible issue (EC-479), never\n // the engine's fixtures wearing the project's schema.\n <CmsSessionGate>\n {(cms) => {\n return (\n <CmsProvider\n key={projectId}\n projectId={projectId}\n initialCollections={resolveCmsInitialCollections(cms)}\n initialDocuments={resolveCmsInitialDocuments(cms)}\n initialPublishedKeys={cms?.publishedKeys}\n initialTimestamps={cms?.timestamps}\n initialPublishTimestamps={cms?.publishTimestamps}\n initialChangedKeys={cms?.changedKeys}\n initialLocaleConfig={resolveCmsInitialLocaleConfig(cms, project)}\n // EC-461: a hydrated mount (cms non-null — both modes now) seeds the\n // CURRENT persisted state, so staged docs are superseded by it; only\n // a static kit/fixture seed lets staged entries win.\n seedReflectsWrites={cms !== null}\n >\n <div className=\"flex h-full min-h-0 flex-col\">\n <CmsPersistErrorBanner />\n {/* EC-293: the collection list now lives in the section rail (nested\n under the CMS view), so the surface is full-width — the old 240px\n CollectionsSidebar aside is gone. EC-199: the AI assistant mounts as\n a right-hand sibling (both list + editor), so the content is a row. */}\n <div className=\"flex min-h-0 flex-1 overflow-hidden\">\n <div className=\"min-w-0 flex-1 overflow-hidden\">\n <CmsContent\n projectId={projectId}\n collectionId={collectionId}\n documentId={documentId}\n field={field}\n focusCollections={focusCollections}\n />\n </div>\n <AiCmsPanel />\n </div>\n </div>\n </CmsProvider>\n )\n }}\n </CmsSessionGate>\n )\n}\n\n/** Resolves the active CMS screen inside the provider (needs the live store). */\nfunction CmsContent({\n projectId,\n collectionId,\n documentId,\n field,\n focusCollections,\n}: {\n projectId: string\n collectionId: string | null\n documentId: string | null\n field?: string\n focusCollections?: readonly string[]\n}) {\n const cms = useCms()\n\n if (collectionId === null) return <CmsIndex projectId={projectId} focusCollections={focusCollections} />\n\n if (documentId === null) {\n const collection = cms.getCollection(collectionId)\n // EC-274: a singleton is a UI lens — at the collection URL it opens its one\n // document directly *while in its expected shape*, but degrades to the list\n // (with a \"for review\" lane) on drift. SingletonGate decides per the data.\n if (collection && isSingleton(collection)) {\n return <SingletonGate projectId={projectId} collectionId={collectionId} />\n }\n return <CollectionTable projectId={projectId} collectionId={collectionId} />\n }\n\n return (\n <DetailEditor\n projectId={projectId}\n collectionId={collectionId}\n documentId={documentId}\n focusPath={field}\n />\n )\n}\n\n/**\n * EC-274 — the singleton lens gate. At a singleton collection's URL, resolve its\n * lone document and open it directly; on drift (> 1 document) fall back to the\n * list with the \"for review\" lane so an editor can resolve the conflict.\n */\nfunction SingletonGate({ projectId, collectionId }: { projectId: string; collectionId: string }) {\n const cms = useCms()\n const collection = cms.getCollection(collectionId)\n const docs = cms.documentsOf(collectionId)\n const resolution = collection\n ? resolveSingletonDocument(collection, docs)\n : ({ kind: 'empty' } as const)\n\n // Materialize the lone document on first visit (an empty draft, persisted like\n // any create). Idempotent in the store; only fires while genuinely empty.\n useEffect(() => {\n if (resolution.kind === 'empty') cms.ensureSingletonDocument(collectionId)\n }, [resolution.kind, cms, collectionId])\n\n if (resolution.kind === 'ready') {\n return (\n <DetailEditor projectId={projectId} collectionId={collectionId} documentId={resolution.doc.id} />\n )\n }\n if (resolution.kind === 'drift') {\n return <CollectionTable projectId={projectId} collectionId={collectionId} />\n }\n return (\n <div className=\"grid h-full place-items-center p-8\">\n <Text size=\"sm\" tone=\"muted\">\n {translate('appViews.singleton.opening', {\n label: localizedLabel(collection?.form?.label, collectionId),\n })}\n </Text>\n </div>\n )\n}\n\n/** Failed/denied persisted CMS mutations are always visible (EC-141). */\nfunction CmsPersistErrorBanner() {\n const cms = useCms()\n if (!cms.persistError) return null\n return (\n <div className=\"shrink-0 border-b border-border p-2\">\n <OperationErrorBanner error={cms.persistError} onDismiss={cms.clearPersistError} />\n </div>\n )\n}\n"]}
1
+ {"version":3,"file":"default-modules.js","sourceRoot":"","sources":["../../../src/components/app-views/default-modules.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGjC,OAAO,EACL,MAAM,EACN,QAAQ,EACR,OAAO,EACP,KAAK,EACL,UAAU,EACV,QAAQ,IAAI,YAAY,EACxB,QAAQ,EACR,KAAK,GACN,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,0BAA0B,CAAA;AASjC,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACzF,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,EAC7B,gCAAgC,GACjC,MAAM,iCAAiC,CAAA;AAExC,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,aAAa,E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EAAE,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,GAAI,CAClG,CAAA;IACH,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAChC,OAAO,KAAC,eAAe,IAAC,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,GAAI,CAAA;IAC9E,CAAC;IACD,OAAO,CACL,cAAK,SAAS,EAAC,oCAAoC,YACjD,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,YACzB,SAAS,CAAC,4BAA4B,EAAE;gBACvC,KAAK,EAAE,cAAc,CAAC,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC;aAC7D,CAAC,GACG,GACH,CACP,CAAA;AACH,CAAC;AAED,yEAAyE;AACzE,SAAS,qBAAqB;IAC5B,MAAM,GAAG,GAAG,MAAM,EAAE,CAAA;IACpB,IAAI,CAAC,GAAG,CAAC,YAAY;QAAE,OAAO,IAAI,CAAA;IAClC,OAAO,CACL,cAAK,SAAS,EAAC,qCAAqC,YAClD,KAAC,oBAAoB,IAAC,KAAK,EAAE,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,GAAG,CAAC,iBAAiB,GAAI,GAC/E,CACP,CAAA;AACH,CAAC","sourcesContent":["import { useEffect } from 'react'\nimport type { ReactNode } from 'react'\nimport type { LucideIcon } from 'lucide-react'\nimport {\n Blocks,\n Database,\n FileCog,\n Image,\n LayoutGrid,\n Settings as SettingsIcon,\n Signpost,\n Users,\n} from 'lucide-react'\nimport {\n defaultAssetCollection,\n extendCollectionDef,\n isSingleton,\n parseLocaleConfig,\n resolveSingletonDocument,\n} from '@elytracms/core/cms-core'\nimport type {\n CmsDocument,\n CollectionDef,\n CollectionFieldOverride,\n CollectionFormMeta,\n LocaleConfig,\n} from '@elytracms/core/cms-core'\nimport type { CustomizationIssue, Project, SectionId, SectionState } from '@elytracms/core/studio-core'\nimport { NavigateOnce, STUDIO_PROJECT_ROUTE, studioPath } from '@elytracms/studio/router'\nimport { Text } from '@elytracms/studio/ui'\nimport { localizedLabel, translate } from '@elytracms/studio/lib/i18n'\nimport {\n resolveDeploymentCollections,\n resolveDeploymentLocaleConfig,\n resolveDeploymentPageCollections,\n} from '@elytracms/studio/lib/workspace'\nimport type { HydratedCms } from '@elytracms/studio/lib/operations'\nimport {\n cmsDeepLink,\n componentsDeepLink,\n usersDeepLink,\n redirectsDeepLink,\n assetsDeepLink,\n groupNode,\n separatorNode,\n viewNode,\n type AppViewContext,\n type AppViewDeepLink,\n type AppViewModule,\n type DerivedViewId,\n type NavPermission,\n type SidebarViewNode,\n} from './module'\nimport { SectionSurface } from '../section-surface'\nimport { SectionStateView } from '../section-state'\nimport { SettingsForm } from '../settings-form'\nimport { AssetsModule } from '../assets/assets-module'\nimport { UsersModule } from '../users/users-module'\nimport { RedirectsModule } from '../redirects/redirects-module'\nimport { redirectsCollectionDef } from '../redirects/redirects-schema'\nimport { RegistryBrowser } from '../components/registry-browser'\nimport { ComponentsIndex } from '../components/components-index'\nimport { ComponentDetail } from '../components/component-detail'\nimport { CmsSessionGate } from '../project-session'\nimport { CmsProvider, useCms } from '../cms/cms-store'\nimport { AiCmsPanel } from '../ai/ai-cms-panel'\nimport { focusCollectionList } from '../cms/collection-focus'\nimport { CmsIndex } from '../cms/cms-index'\nimport { CollectionTable } from '../cms/collection-table'\nimport { DetailEditor } from '../cms/detail-editor'\nimport { OperationErrorBanner } from '../operation-error'\n\n/**\n * EC-237/239 — the studio's BUILT-IN views + the consumer-facing `nav` namespace,\n * an instance of the EC-236 customization seam.\n *\n * Each built-in surface (the former `StudioSectionResolver` case body) is promoted\n * to a self-contained {@link AppViewModule} factory. The `nav` namespace is the\n * single, typed builder a consuming repo's `studio.config.tsx` uses to declare its\n * section rail — `nav.cms(...)`, `nav.group(...)`, `nav.view(...)` — passing the\n * view objects (and a focus config) DIRECTLY, never a string id. The CMS surface\n * is a factory ({@link cmsView}) so a focused view (\"Catalog\", \"Categories\") is the\n * SAME surface instantiated with config, not a copy — the EC-239 reuse proof.\n */\n\n// --- The CMS surface, reusable via a config factory (the EC-239 reuse seam) ---\n\n/** Config for a CMS-backed view — `collections`/`collection` focus the lens (EC-239). */\nexport interface CmsViewConfig {\n /** Explicit stable id (the route segment). Omitted → derived from the focus. */\n id?: string\n label?: string\n description?: string\n icon?: LucideIcon\n /**\n * Scope the rail auto-expansion (EC-293) to these collection ids, in order. The\n * parent expands into one focused-lens child per id; the parent index shows the\n * same subset. Omitted → every collection. Ignored for a single-collection lens.\n *\n * A ONE-ITEM array is legal and degrades to a working (if redundant) parent+child\n * pair — the parent takes the `cms-group:<id>` id so it cannot collide with its own\n * child (EC-468). For a single collection with no group heading, prefer the\n * {@link CmsViewConfig.collection} leaf form.\n */\n collections?: readonly string[]\n /** Single-collection lens: a LEAF rail item that opens straight into this collection. */\n collection?: string\n /**\n * EC-293 escape hatch: explicit rail children for this CMS parent, overriding the\n * default per-collection auto-expansion. Ignored for a single-collection lens.\n */\n children?: SidebarViewNode[]\n /** The availability section this view rides on (EC-221); defaults to `cms`. */\n availabilitySection?: SectionId\n /** OPTIONAL, default-open nav-permission predicate (EC-240 / AD-18). See {@link BuiltinViewConfig.visible}. */\n visible?: NavPermission\n}\n\n/** Common label/icon overrides for a built-in view (`nav.redirects({ label: 'URLs' })`). */\nexport interface BuiltinViewConfig {\n label?: string\n icon?: LucideIcon\n /**\n * OPTIONAL, default-open nav-permission predicate (EC-240 / AD-18): hide this\n * rail item for principals it returns `false` for; absent → always visible. The\n * policy (which roles) lives in the consuming project, never the engine. E.g.\n * `nav.users({ visible: ({ role }) => role === 'admin' })`.\n */\n visible?: NavPermission\n}\n\n/**\n * Config for the **redirects** rail (EC-311) — a built-in view whose engine-owned\n * schema is customizable. Beyond the shared label/icon/visible, a mount may rename\n * the rail (`form`) and **override built-in fields by equal name** (`fields`):\n * naming, permissions (`form.readOnly`), rendering (`form.control` → `fieldRenderers`)\n * and validation. The canonical `from`/`to`/`permanent`/`enabled` names+types are\n * contract-locked (a type change on one is a loud config error), but a *net-new*\n * field is allowed (EC-311 Tier 2): it's appended and persists in the redirect\n * record's `meta` bag — editorial only, so it never reaches delivery/routing.\n */\nexport interface RedirectsViewConfig extends BuiltinViewConfig {\n /** Rename the rail (e.g. `{ label: 'URLs' }`). */\n form?: Partial<CollectionFormMeta>\n /** Override built-in redirect fields, matched by `name`. */\n fields?: readonly CollectionFieldOverride[]\n}\n\n/**\n * Config for the **assets** rail (EC-319), customizable by the SAME EC-311\n * mechanism as redirects (`form`/`fields`) — but the BASE schema it overrides is\n * different in kind: redirects' base is an engine-owned, fixed `CollectionDef`\n * known at config-build time; the assets base is the DEPLOYMENT's own\n * `kind:'asset'` collection (a project's `cms/collections/asset.ts`), only\n * knowable once the deployment resolves (hydrated session → playground\n * config — see {@link resolveAssetsSchema}). So the merge runs at RENDER time\n * (inside `assetsView`'s `CmsSessionGate`), not at `nav.assets(config)` call\n * time: a locked-violation override (e.g. changing a declared field's type)\n * surfaces the first time the Assets section renders, not at `defineStudio`\n * mount — the one place this rail's customization contract differs from\n * redirects', a direct consequence of its base schema being project-declared.\n */\nexport interface AssetsViewConfig extends BuiltinViewConfig {\n /** Rename the rail (e.g. `{ label: 'Media' }`). */\n form?: Partial<CollectionFormMeta>\n /** Override the project's declared asset fields, matched by `name`. */\n fields?: readonly CollectionFieldOverride[]\n}\n\n/** Config for a fully custom view (`nav.view({...})`) — the net-new surface escape hatch. */\nexport interface CustomViewConfig {\n /** Explicit stable id (the route segment). Omitted → a slug of the label. */\n id?: string\n label: string\n description?: string\n icon?: LucideIcon\n render: (ctx: AppViewContext) => ReactNode\n parsePath?: (segments: string[]) => AppViewDeepLink | null\n availabilitySection?: SectionId\n /** OPTIONAL, default-open nav-permission predicate (EC-240 / AD-18). See {@link BuiltinViewConfig.visible}. */\n visible?: NavPermission\n}\n\nfunction slugify(label: string): string {\n return label.trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'view'\n}\n\n/**\n * The auto-parent namespace for a ONE-ITEM `collections` group (EC-468).\n *\n * A PREFIX, not a suffix, and deliberately so: every other derived CMS id starts with\n * `cms:`, so the 4th character (`-` here, `:` there) makes the two namespaces disjoint\n * BY CONSTRUCTION — no collection id, whatever it contains, can forge a `cms-group:`\n * id, whereas a suffix marker (`cms:page:group`) would be forged by a collection\n * literally named `page:group` (`collectionDefSchema.id` is `z.string().min(1)` —\n * nothing reserves `:` or `-`).\n */\nconst CMS_GROUP_ID_PREFIX = 'cms-group:'\n\n/**\n * Derive a stable, deterministic id from the CMS focus (overridable via `config.id`).\n *\n * The id is the route segment, the rail's active-state key AND the override key\n * (EC-311), so it must be injective: two focuses deriving one id means\n * `resolveOverrides` drops the later view. The derived shapes:\n *\n * | focus | id |\n * | ---------------------------- | ------------------------- |\n * | none | `cms` |\n * | `collection: 'page'` (leaf) | `cms:page` |\n * | `collections: ['a','b']` | `cms:a-b` |\n * | `collections: ['page']` | `cms-group:page` |\n *\n * EC-468 — why the one-item group is its own namespace: `cms:${join(L)}` of a\n * single-element list IS that element, so the auto-generated PARENT took the very id\n * its own auto-expanded child derives (`cmsCollectionLeaf` → `cmsView({ collection })`).\n * Both landed in the one flat override list `resolveSidebar` feeds `resolveOverrides`,\n * so the child was dropped with a `duplicate-override-id` error and the parent rendered\n * childless — a forced collision no config could avoid. Nothing else changes: the leaf\n * and the multi-collection join keep their exact ids (consumer rails route on them).\n *\n * EC-477 — `-` is a SEPARATOR here, and a collection id may legally contain one, so a\n * collection literally named `a-b` derives the same `cms:a-b` as a `['a','b']` group.\n * That ambiguity is NOT closed by constraining collection ids (a permanent, repo-wide\n * naming ban to fix a two-config coincidence, when hyphenated ids are ordinary — see\n * the task's Done); it is DETECTED where both facts are known, by\n * {@link checkSidebarIdKeyspace}, which raises a `derived-id-collision` the moment a\n * group's join equals a real collection id. The escape hatch is unchanged: an explicit\n * `nav.cms({ id })` always wins, and the derivation below is untouched — consumer rails\n * route on these ids.\n */\nexport function cmsViewId(config: CmsViewConfig): string {\n if (config.id) return config.id\n if (config.collection) return `cms:${config.collection}`\n const collections = config.collections\n if (collections && collections.length > 0) {\n if (collections.length === 1) return `${CMS_GROUP_ID_PREFIX}${collections[0]}`\n return `cms:${joinCollectionIds(collections)}`\n }\n return 'cms'\n}\n\n/** The multi-collection focus join — ONE definition, so the id and the EC-477 check cannot drift. */\nfunction joinCollectionIds(collections: readonly string[]): string {\n return [...collections].join('-')\n}\n\n/**\n * The id provenance a CMS focus carries for diagnostics (EC-477) — set only for the one\n * derived shape that is genuinely ambiguous: a MULTI-collection join. An explicit `id`,\n * a single-collection leaf and the one-item `cms-group:` parent are all unambiguous by\n * construction (EC-468), so they carry nothing and are never diagnosed.\n */\nfunction cmsDerivedId(config: CmsViewConfig): DerivedViewId | undefined {\n if (config.id || config.collection) return undefined\n const collections = config.collections\n if (!collections || collections.length < 2) return undefined\n return { from: 'collection-join', collections: [...collections] }\n}\n\n/**\n * Build a CMS view — the default `cms` view, or a focused instance. Every instance\n * shares one surface ({@link CmsScreen}); `collections` narrows the sidebar + index\n * to a subset, `collection` is a single-collection lens that opens straight into\n * that collection's list. The id is derived from the focus (deterministic, stable\n * across rail reorders) unless `id` is given — see {@link cmsViewId} for the derived\n * shapes and the one keyspace ambiguity that survives.\n */\nexport function cmsView(config: CmsViewConfig = {}): AppViewModule {\n const single = config.collection\n const focus = single ? [single] : config.collections\n const derivedId = cmsDerivedId(config)\n return {\n id: cmsViewId(config),\n ...(derivedId ? { derivedId } : {}),\n // Lazy label/description (EC-241): the sidebar is built when the consumer's\n // `studio.config` module loads — BEFORE `createStudio` seeds the i18n config — so\n // resolving here would bake English. A getter defers resolution to render, when\n // the config is present and the browser locale is known.\n get label() {\n return config.label ?? translate('nav.cms.label')\n },\n get description() {\n return config.description ?? translate('nav.cms.description')\n },\n icon: config.icon ?? Database,\n availabilitySection: config.availabilitySection ?? 'cms',\n // A single-collection lens routes `[]`→that collection, `[d]`→its document;\n // an unfocused / multi-collection view uses the full index/collection/document arity.\n parsePath: single\n ? (segments) =>\n segments.length === 0\n ? { collectionId: single, documentId: null }\n : segments.length === 1\n ? { collectionId: single, documentId: segments[0]! }\n : null\n : cmsDeepLink,\n render: (ctx) => (\n <CmsScreen\n project={ctx.project}\n collectionId={ctx.deepLink.collectionId ?? null}\n documentId={ctx.deepLink.documentId ?? null}\n state={ctx.search.state}\n field={ctx.search.field}\n focusCollections={focus}\n />\n ),\n }\n}\n\n/**\n * A focused-lens rail child for one collection (EC-293) — the SAME `cms:<id>` view a\n * single-collection `nav.cms({ collection })` produces, carrying the collection's own\n * label + a singleton-aware icon (the former `CollectionsSidebar` row, lifted into\n * the rail). CMS auto-expansion maps the project's collections through this.\n */\nfunction cmsCollectionLeaf(collection: CollectionDef): SidebarViewNode {\n const singleton = isSingleton(collection)\n return viewNode(\n cmsView({\n collection: collection.id,\n // Non-hook `localizedLabel` resolves the (possibly `{ en, de }`) collection label\n // against the active UI locale, so a German editor sees German collection names.\n label: localizedLabel(collection.form?.label, collection.id),\n icon: singleton ? FileCog : collection.kind === 'asset' ? Image : Database,\n }),\n )\n}\n\n/** The components registry browser view. */\nexport function componentsView(config: BuiltinViewConfig = {}): AppViewModule {\n return {\n id: 'components',\n get label() {\n return config.label ?? translate('nav.components.label')\n },\n get description() {\n return translate('nav.components.description')\n },\n icon: config.icon ?? Blocks,\n availabilitySection: 'components',\n parsePath: componentsDeepLink,\n render: (ctx) => (\n <ComponentsScreen\n projectId={ctx.projectId}\n componentId={ctx.deepLink.componentId ?? null}\n state={ctx.search.state}\n />\n ),\n }\n}\n\n/**\n * The Redirects view (EC-303) — editorial redirects as DATA, an editor-owned CRUD\n * surface (create/edit/delete) over the portable list/edit surfaces. Routes are no\n * longer shown in the admin (they're code; native `next.config`/`vercel` own static\n * forwards, evaluated before these). Rides on the CMS availability (a content/\n * routing concern). `[]` is the list; `[redirectId]` opens that redirect's detail.\n */\nexport function redirectsView(config: RedirectsViewConfig = {}): AppViewModule {\n // EC-311: merge any field/label overrides over the engine-owned def ONCE, at config\n // build (config-as-code — a locked violation throws here, at `defineStudio` mount).\n // Tier 2: `additiveFields: 'allow'` — a net-new field is appended and persists in the\n // redirect record's `meta` bag (the canonical from/to/permanent/enabled stay locked).\n const schema = extendCollectionDef(redirectsCollectionDef, config, { additiveFields: 'allow' })\n return {\n id: 'redirects',\n get label() {\n // Prefer an explicit rail label, then a consumer-*customized* collection label,\n // else the localized catalog nav label. Never let the built-in English schema\n // label ('Redirects') preempt translation — compare against the built-in default.\n const customized = localizedLabel(schema.form?.label)\n const builtin = localizedLabel(redirectsCollectionDef.form?.label)\n return (\n config.label ??\n (customized && customized !== builtin ? customized : translate('nav.redirects.label'))\n )\n },\n get description() {\n return translate('nav.redirects.description')\n },\n icon: config.icon ?? Signpost,\n availabilitySection: 'cms',\n parsePath: redirectsDeepLink,\n render: (ctx) =>\n ctx.search.state && ctx.search.state !== 'working' ? (\n <SectionStateView state={ctx.search.state} title={translate('nav.redirects.label')} />\n ) : (\n <RedirectsModule\n projectId={ctx.projectId}\n redirectId={ctx.deepLink.redirectId ?? null}\n schema={schema}\n />\n ),\n }\n}\n\n/**\n * Resolve the assets rail's EFFECTIVE schema (EC-319/EC-311): the deployment's\n * OWN `kind:'asset'` collection — hydrated session → playground config,\n * the exact same precedence {@link resolveCmsInitialCollections} gives every\n * other CMS collection — falling back to the ENGINE DEFAULT asset collection\n * (`defaultAssetCollection`, the same declaration the resolver injects for a project\n * that uses asset fields, EC-257) only when nothing resolves. A mount's\n * `nav.assets({ form, fields })` then merges over THAT base (EC-311, additive\n * fields allowed — a project's asset record already carries an open `meta` bag,\n * EC-301). Pure — no React — so it's unit-testable without `CmsSessionGate`.\n *\n * EC-583 (MODE #23): the fallback used to be the engine's TEST fixture\n * (`assetCollection` — alt localized, no copyright/credit), a second \"default asset\n * collection\" beside the resolver's. Engine fixtures never stand in for project\n * structure; there is one default.\n */\nexport function resolveAssetsSchema(\n collections: readonly CollectionDef[] | undefined,\n config: AssetsViewConfig,\n): CollectionDef {\n const base = collections?.find((c) => c.kind === 'asset') ?? defaultAssetCollection()\n return extendCollectionDef(base, config, { additiveFields: 'allow' })\n}\n\n/**\n * The Assets view (EC-319) — the universal list (+ grid/list toggle) and a\n * bespoke per-asset detail surface, over the asset library store. `[]` is the\n * list; `[assetId]` opens that asset's detail (routed via `studioPath.asset`).\n * A `?asset=` deep link (EC-172 \"used by\" links) redirects straight to the\n * asset's detail — the surface those links used to scroll a card into and\n * auto-open, now a first-class route.\n */\nexport function assetsView(config: AssetsViewConfig = {}): AppViewModule {\n return {\n id: 'assets',\n get label() {\n return config.label ?? translate('nav.assets.label')\n },\n get description() {\n return translate('nav.assets.description')\n },\n icon: config.icon ?? Image,\n availabilitySection: 'assets',\n parsePath: assetsDeepLink,\n render: (ctx) => (\n <SectionSurface project={ctx.project} section=\"assets\" forcedState={ctx.search.state}>\n {ctx.deepLink.assetId === null && ctx.search.asset ? (\n // EC-441: `NavigateOnce` — render-time redirects fire once per intent.\n <NavigateOnce\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId: ctx.projectId, _splat: studioPath.asset(ctx.search.asset) }}\n replace\n />\n ) : (\n // The AssetsProvider is mounted at the project level (EC-195).\n <CmsSessionGate>\n {(cms) => {\n const schema = resolveAssetsSchema(resolveCmsInitialCollections(cms), config)\n return (\n <AssetsModule\n projectId={ctx.projectId}\n assetId={ctx.deepLink.assetId ?? null}\n schema={schema}\n />\n )\n }}\n </CmsSessionGate>\n )}\n </SectionSurface>\n ),\n }\n}\n\n/**\n * The studio Users view (EC-240) — an admin-only roster of who has access to this\n * deployment and their role. A first-class section (its own rail entry), modeled\n * like the Assets library; the surface itself gates to admins and renders a\n * \"restricted\" state otherwise. Rides on the `settings` availability (an\n * admin/config concern, so it appears/hides with a project's settings surface).\n */\nexport function usersView(config: BuiltinViewConfig = {}): AppViewModule {\n return {\n id: 'users',\n get label() {\n return config.label ?? translate('nav.users.label')\n },\n get description() {\n return translate('nav.users.description')\n },\n icon: config.icon ?? Users,\n availabilitySection: 'users',\n // EC-240: `[]` is the roster; `[userId]` opens that member in the portable edit\n // shell (AD-19 reuse — the same `DetailEditor` body over the users source).\n parsePath: usersDeepLink,\n render: (ctx) =>\n ctx.search.state && ctx.search.state !== 'working' ? (\n <SectionStateView state={ctx.search.state} title={translate('nav.users.label')} />\n ) : (\n <UsersModule projectId={ctx.projectId} userId={ctx.deepLink.userId ?? null} />\n ),\n }\n}\n\n/** The project settings view. */\nexport function settingsView(config: BuiltinViewConfig = {}): AppViewModule {\n return {\n id: 'settings',\n get label() {\n return config.label ?? translate('nav.settings.label')\n },\n get description() {\n return translate('nav.settings.description')\n },\n icon: config.icon ?? SettingsIcon,\n availabilitySection: 'settings',\n render: (ctx) => (\n <SectionSurface project={ctx.project} section=\"settings\" forcedState={ctx.search.state}>\n <SettingsForm project={ctx.project} />\n </SectionSurface>\n ),\n }\n}\n\n/** Where the legacy `/builder?page=` lands (pure): the page collection's document or list. */\nexport function legacyBuilderTarget(pageCollection: string | undefined, page: string | undefined): string {\n if (pageCollection === undefined) return ''\n return page ? studioPath.cmsDocument(pageCollection, page) : studioPath.cmsCollection(pageCollection)\n}\n\n/** The legacy `builder` redirect — a hidden, routable view (so `/builder?page=` still lands). */\nexport function builderView(): AppViewModule {\n return {\n id: 'builder',\n label: 'Builder',\n description: 'Legacy builder route — redirects to the page document editor.',\n icon: Blocks,\n hidden: true,\n render: (ctx) => (\n // Retired surface (EC-187 slice 6): a page is a document of a PAGE collection —\n // EC-590: the first collection a route addresses, never a collection named `page`.\n // `?page=<id>` lands on that document; else that collection's list; a project\n // with no routed collection lands on its root.\n // EC-441: `NavigateOnce` — render-time redirects fire once per intent.\n <NavigateOnce\n to={STUDIO_PROJECT_ROUTE}\n params={{\n projectId: ctx.projectId,\n _splat: legacyBuilderTarget(resolveDeploymentPageCollections()[0], ctx.search.page),\n }}\n replace\n />\n ),\n }\n}\n\n/**\n * Build a fully custom view (the `nav.view(...)` escape hatch).\n *\n * With no `id` the id is a SLUG of the label, and that slug carries a\n * {@link DerivedViewId} marker (EC-476): a label is a display string a developer picks\n * freely, so `label: 'CMS'` deriving `cms` is a coincidence, not a request to replace\n * the built-in CMS surface. {@link checkSidebarIdKeyspace} refuses the takeover and\n * says so; an explicit `id` carries no marker and keeps the documented replacement.\n */\nexport function customView(config: CustomViewConfig): AppViewModule {\n const derivedId: DerivedViewId | undefined = config.id\n ? undefined\n : { from: 'label', label: config.label }\n return {\n id: config.id ?? slugify(config.label),\n ...(derivedId ? { derivedId } : {}),\n label: config.label,\n description: config.description ?? config.label,\n icon: config.icon ?? LayoutGrid,\n render: config.render,\n ...(config.parsePath ? { parsePath: config.parsePath } : {}),\n ...(config.availabilitySection ? { availabilitySection: config.availabilitySection } : {}),\n }\n}\n\n/**\n * The studio's built-in views in canonical rail order (components · CMS · routes ·\n * assets · extensions · settings), plus the hidden `builder` redirect (routable but\n * unlisted). The default rail (no `defineStudio({ sidebar })`) is these as plain\n * entries; the router registry always includes them so deep-links resolve even\n * when a consumer's rail omits one.\n */\nexport const DEFAULT_VIEWS: readonly AppViewModule[] = [\n componentsView(),\n cmsView(),\n redirectsView(),\n assetsView(),\n usersView(),\n settingsView(),\n builderView(),\n]\n\n/**\n * Every id the engine already owns — the replacement targets of the sidebar seam,\n * INCLUDING the hidden `builder` redirect (it is in the keyspace even though the stock\n * rail does not list it, so a derived id can swallow it just the same).\n */\nexport const BUILTIN_VIEW_IDS: ReadonlySet<string> = new Set(DEFAULT_VIEWS.map((view) => view.id))\n\n/** The extension point these issues are located at — the same literal `resolveSidebar` stamps. */\nconst SIDEBAR_POINT = 'sidebar'\n\n/**\n * The catalog keys for the two keyspace findings (EC-478). This module stays pure —\n * it names a key and its identifier values; `lib/persona/labels.ts` resolves them at\n * the render site, so the rail foot localizes as one list.\n */\nconst KEYSPACE_KEYS = {\n builtinCollision: 'customization.issue.derivedIdBuiltinCollision',\n collectionCollision: 'customization.issue.derivedIdCollectionCollision',\n} as const\n\n/** The outcome of the keyspace check: the entries that may still act as overrides, plus the findings. */\nexport interface SidebarIdKeyspace {\n /**\n * The views to resolve as overrides — an ACCIDENTAL built-in takeover removed, so the\n * engine keeps its own block (the EC-236 contract for a rejected entry). Everything\n * else passes through untouched, including the merely-ambiguous EC-477 case.\n */\n views: AppViewModule[]\n /** What was found — visible at the rail foot, never silent. */\n issues: CustomizationIssue[]\n}\n\n/**\n * EC-476/477 — guard the sidebar id keyspace against ids that were DERIVED rather than\n * declared, and landed somewhere that already means something.\n *\n * The seam's replacement rule is id equality (`resolveOverrides`: an entry whose id is a\n * default's id replaces it). That is exactly right for an id the developer TYPED, and\n * exactly wrong for one a builder computed — and the generic core cannot tell them\n * apart, because by the time an entry reaches it, an id is just a string. So the rule\n * lives HERE, next to the derivations that produce it ({@link slugify},\n * {@link cmsViewId}) and next to {@link DEFAULT_VIEWS}, the set it has to protect.\n *\n * Two derived shapes, two different remedies — because the cost of being wrong differs:\n *\n * - **A slugged LABEL landing on a built-in id (EC-476) is REJECTED** (`error`). Losing\n * a whole built-in surface — the CMS, Assets, the users roster — to a coincidence of\n * spelling is far worse than one custom view not appearing, and the developer's fix is\n * a one-line explicit `id`. The built-in is kept, so nothing disappears.\n * - **A collection JOIN equal to a real collection id (EC-477) is KEPT** (`warning`).\n * Nothing here is a takeover: the group's id is legitimate, it is merely no longer\n * unique to it, so dropping the view would destroy a rail item the developer\n * explicitly declared in order to report a naming clash. Reporting is the whole fix.\n *\n * Pure and deterministic — the house \"extract the core, test the core\" shape.\n * `builtinIds` and `collections` are parameters so the rule is testable against a\n * synthetic keyspace, not just the live one.\n */\nexport function checkSidebarIdKeyspace(\n views: readonly AppViewModule[],\n collections: readonly CollectionDef[] = [],\n builtinIds: ReadonlySet<string> = BUILTIN_VIEW_IDS,\n): SidebarIdKeyspace {\n const collectionIds = new Set(collections.map((collection) => collection.id))\n const kept: AppViewModule[] = []\n const issues: CustomizationIssue[] = []\n\n for (const view of views) {\n const derived = view.derivedId\n\n // EC-476 — an auto-derived id must never claim a built-in surface.\n if (derived?.from === 'label' && builtinIds.has(view.id)) {\n issues.push({\n code: 'derived-id-collision',\n severity: 'error',\n message: `View \"${derived.label}\" for \"${SIDEBAR_POINT}\" derives the id \"${view.id}\" from its label, which is the built-in \"${view.id}\" view — the built-in is kept and this view is ignored. Pass an explicit id to replace a built-in on purpose.`,\n messageRef: {\n key: KEYSPACE_KEYS.builtinCollision,\n vars: { label: derived.label, point: SIDEBAR_POINT, id: view.id },\n },\n point: SIDEBAR_POINT,\n id: view.id,\n })\n continue\n }\n\n // EC-477 — a multi-collection join that a single collection could equally have produced.\n if (derived?.from === 'collection-join' && collectionIds.has(joinCollectionIds(derived.collections))) {\n issues.push({\n code: 'derived-id-collision',\n severity: 'warning',\n message: `View id \"${view.id}\" for \"${SIDEBAR_POINT}\" is ambiguous: it joins the collections ${quotedIds(derived.collections)} with \"-\", and a collection is literally named \"${joinCollectionIds(derived.collections)}\" — its own lens derives the same id. Pass an explicit id to this group.`,\n messageRef: {\n key: KEYSPACE_KEYS.collectionCollision,\n vars: {\n id: view.id,\n point: SIDEBAR_POINT,\n collections: quotedIds(derived.collections),\n joined: joinCollectionIds(derived.collections),\n },\n },\n point: SIDEBAR_POINT,\n id: view.id,\n })\n }\n\n kept.push(view)\n }\n\n return { views: kept, issues }\n}\n\n/** `\"a\", \"b\"` — a readable id list for an issue message (the EC-467 issue-copy shape). */\nfunction quotedIds(ids: readonly string[]): string {\n return ids.map((id) => `\"${id}\"`).join(', ')\n}\n\n/**\n * The `nav` namespace — the single typed builder for `studio.config.tsx`'s section\n * rail. Each call returns a {@link SidebarViewNode} (or a group / separator) that\n * carries its view DIRECTLY: `nav.cms({ collection })` is a focused CMS view,\n * `nav.view({ render })` a net-new surface, `nav.group(label, [...])` a header with\n * sub-views, `nav.separator()` a divider. No string ids, no `moduleId` — the rail\n * is the views.\n */\n/**\n * Forward the OPTIONAL, default-open nav-permission predicate (EC-240 / AD-18)\n * from a `nav.*` config onto the built view, so gating is settable on EVERY nav\n * item — not just Users. Absent → the view is unchanged (always visible).\n */\nfunction withNavPermission(view: AppViewModule, config: { visible?: NavPermission }): AppViewModule {\n if (!config.visible) return view\n // Copy property DESCRIPTORS (not a spread) so a built-in view's lazy `label`/\n // `description` getters (EC-241) survive — a spread would invoke them at build time,\n // baking English before `createStudio` seeds the i18n config.\n return Object.defineProperties({} as AppViewModule, {\n ...Object.getOwnPropertyDescriptors(view),\n visible: { value: config.visible, enumerable: true, configurable: true, writable: true },\n })\n}\n\nexport const nav = {\n /**\n * The CMS view. `nav.cms()` / `nav.cms({ collections })` is a PARENT that nests its\n * collections in the rail (each a focused `cms:<id>` lens); `nav.cms({ collection })`\n * is a single-collection LEAF; `nav.cms({ children })` supplies explicit children.\n * A one-item `collections` group is a parent whose id is `cms-group:<id>`, distinct\n * from its single child by construction (EC-468 — see {@link cmsViewId}).\n */\n cms: (config: CmsViewConfig = {}): SidebarViewNode => {\n const view = withNavPermission(cmsView(config), config)\n // A single-collection lens is a leaf — it opens that collection directly.\n if (config.collection) return viewNode(view)\n // Otherwise a parent that expands its collections as nested rail children (EC-293).\n const node: SidebarViewNode = { kind: 'view', view }\n if (config.children) node.children = config.children\n else\n node.expand = (collections) =>\n focusCollectionList(collections, config.collections).map(cmsCollectionLeaf)\n return node\n },\n /** The component registry browser. */\n components: (config: BuiltinViewConfig = {}): SidebarViewNode =>\n viewNode(withNavPermission(componentsView(config), config)),\n /** The assets rail — the universal list/grid + detail (EC-319); built-in\n * fields customizable by name (EC-311), the same shape as `nav.redirects`. */\n assets: (config: AssetsViewConfig = {}): SidebarViewNode =>\n viewNode(withNavPermission(assetsView(config), config)),\n /** Editorial redirects (EC-303); built-in fields customizable by name (EC-311). */\n redirects: (config: RedirectsViewConfig = {}): SidebarViewNode =>\n viewNode(withNavPermission(redirectsView(config), config)),\n /** Project settings. */\n settings: (config: BuiltinViewConfig = {}): SidebarViewNode =>\n viewNode(withNavPermission(settingsView(config), config)),\n /** The admin users roster (EC-240). */\n users: (config: BuiltinViewConfig = {}): SidebarViewNode =>\n viewNode(withNavPermission(usersView(config), config)),\n /** A fully custom view — pass your own `render` (and optional `parsePath`). */\n view: (config: CustomViewConfig): SidebarViewNode =>\n viewNode(withNavPermission(customView(config), config)),\n /** A labelled group of views (a header with sub-entries). */\n group: (label: string, children: SidebarViewNode[]) => groupNode(label, children),\n /** A divider between rail sections. */\n separator: () => separatorNode(),\n} as const\n\n// --- Surfaces (the view render bodies; CMS gains a focus lens) ---\n\n/**\n * Components section (EC-050): a registry-browser sidebar beside the active\n * screen — the index (no selection) or a component's detail. Forced states\n * (?state=) replace the whole surface.\n */\nfunction ComponentsScreen({\n projectId,\n componentId,\n state,\n}: {\n projectId: string\n componentId: string | null\n state?: SectionState\n}) {\n if (state && state !== 'working') {\n return <SectionStateView state={state} title={translate('nav.components.label')} />\n }\n return (\n <div className=\"flex h-full min-h-0\">\n <aside className=\"hidden h-full min-h-0 w-[300px] shrink-0 border-r border-border md:block\">\n <RegistryBrowser projectId={projectId} activeComponentId={componentId ?? undefined} />\n </aside>\n <div className=\"min-h-0 flex-1 overflow-auto\">\n {componentId === null ? (\n <ComponentsIndex projectId={projectId} />\n ) : (\n <ComponentDetail projectId={projectId} componentId={componentId} />\n )}\n </div>\n </div>\n )\n}\n\n/**\n * The CMS schema source for a project mount: the active project's config-declared\n * collections (AD-11, `resolveDeploymentCollections`) — in EVERY mode, and nothing else.\n *\n * EC-559 / EC-583 — this was a ladder whose first rung was the HYDRATED session's\n * schema (`cms?.collections ?? …`). In the playground that schema was the in-memory\n * adapter's record, a JSON projection with every config-as-code function stripped,\n * and it won over the config — so `validate`, `form.hidden` predicates and function\n * `titleField`s were undefined in the playground (connected mode's adapter served the\n * config, so it had them): one studio, two schema sources, and every playground check\n * of those features a false pass. The store holds no schema now and hydration carries\n * documents only, so the ladder collapses to its last rung. `cms` stays a parameter\n * purely for signature parity with its twins (`resolveCmsInitialDocuments`).\n *\n * EC-479 — every rung is the PROJECT's own schema and there is no rung after\n * them. The config rung used to be gated on playground mode, because outside it\n * the `undefined` return let `CmsProvider` fall through to `cms-core`'s\n * `sampleFilterableCollections` fixture — the engine's demo schema, shown as the\n * project's, offering `filterable` fields the project's real backend would\n * reject. With that fallback retired the gate has nothing left to protect: the\n * Convex adapter is itself constructed with `resolveDeploymentCollections()`\n * (`lib/persistence/index.ts`), so config collections are what connected mode\n * serves too. Dropping it also DISSOLVES the EC-467 two-source divergence — the\n * section rail reads `resolveDeploymentCollections()` directly, and now so does\n * the store's last rung, so the two can no longer disagree.\n */\nexport function resolveCmsInitialCollections(_cms: HydratedCms | null): CollectionDef[] {\n return resolveDeploymentCollections()\n}\n\n/**\n * The CMS documents source for a project mount — the document-side twin of\n * {@link resolveCmsInitialCollections}: a hydrated session wins (Convex), then\n * **nothing**. (The middle rung, a starter kit's imported documents, went with\n * the kits — EC-574; K rebuilds starter kits as seeds, EC-200/EC-475.)\n *\n * EC-479 — the third rung used to be the engine's own `sampleDocuments` fixture,\n * reconciled against the project's schema (EC-424). Reconciling it was already an\n * admission that the content was foreign: EC-424 existed only because the demo\n * declares `post.slug` localized while the shared fixture stores it plain, so the\n * seeded posts carried standing validation noise no project had written. The\n * honest fix is not a better reconciliation but no foreign content at all — a\n * studio whose config did not arrive now shows an empty CMS and a visible issue\n * at the rail, not six documents about Ada Lovelace wearing the project's schema.\n *\n * The playground keeps its world through the ordinary path, not through here: its\n * seeded in-memory adapter IS a persisted backend behind the operations seam\n * (AD-17), so `CmsSessionGate` hydrates it and the first rung answers. What that\n * adapter seeds is `persistence/seed.ts`'s business — EC-475 (project-defined seed\n * content) owns it.\n */\nexport function resolveCmsInitialDocuments(cms: HydratedCms | null): CmsDocument[] | undefined {\n return cms?.documents\n}\n\n/**\n * The CMS locale config for a project mount (EC-357 finding #3). Locales are\n * structure and structure is code: when the active `elytra.config.ts` project\n * declares locales, they drive the ambient locale switcher in EVERY mode. The old\n * wiring only applied the project's locale settings on a HYDRATED session, so a\n * playground boot — or a connected FIRST RUN with nothing persisted yet — fell\n * back to a kit's locales or the core's sample `en/de` fixture and the switcher\n * showed `EN·/DE` against a `locales: ['de']` config.\n *\n * EC-479/EC-483 — the ladder is now TOTAL, and every rung is the project's own:\n * config-declared locales, then its settings (a starter kit's locales used to sit\n * between the two; the kits went in EC-574). A `Project` only ever exists for a\n * config-declared project (`studio-context.tsx`: `configProjects()`), so\n * `project.settings` is config-derived too — which is what lets the CMS session\n * require a locale instead of borrowing the engine's `en/de` fixture. The default\n * locale is the literal storage key for every localized value, so a guessed one is\n * a data migration. Both rungs are config-derived and pass the workspace gate\n * (`default-locale-not-in-locales` is an error there), so the value is valid by\n * construction and no reader repairs it. `configLocales` is a parameter purely so\n * the ladder is unit-testable (same seam pattern as\n * {@link resolveCmsInitialCollections}); `cms` is accepted for signature parity\n * with its twins but no longer selects a rung.\n */\nexport function resolveCmsInitialLocaleConfig(\n _cms: HydratedCms | null,\n project: Project,\n configLocales: LocaleConfig | undefined = resolveDeploymentLocaleConfig(),\n): LocaleConfig {\n if (configLocales) return configLocales\n return parseLocaleConfig({\n default: project.settings.defaultLocale,\n locales: [...project.settings.locales],\n })\n}\n\n/**\n * CMS section: hydrates the persisted (or kit-seeded) collections + documents, then\n * renders the active screen full-width (index, a collection table, or a document\n * editor). EC-293: the collection list lives in the section rail (nested under the\n * CMS view), so there is no in-surface collections sidebar. Forced states (?state=)\n * replace the whole surface. `focusCollections` (EC-239) narrows the index to a\n * subset, so a focused view (\"Catalog\") reuses this surface with config.\n */\nfunction CmsScreen({\n project,\n collectionId,\n documentId,\n state,\n field,\n focusCollections,\n}: {\n project: Project\n collectionId: string | null\n documentId: string | null\n state?: SectionState\n field?: string\n focusCollections?: readonly string[]\n}) {\n const projectId = project.id\n if (state && state !== 'working') {\n return <SectionStateView state={state} title={translate('nav.cms.label')} />\n }\n\n return (\n // EC-177 gap 1: every CMS mount loads the CURRENT persisted schema +\n // documents (both modes since EC-461). Nothing persisted — a connected first\n // run — means an EMPTY session plus the rail's visible issue (EC-479), never\n // the engine's fixtures wearing the project's schema.\n <CmsSessionGate>\n {(cms) => {\n return (\n <CmsProvider\n key={projectId}\n projectId={projectId}\n initialCollections={resolveCmsInitialCollections(cms)}\n initialDocuments={resolveCmsInitialDocuments(cms)}\n initialPublishedKeys={cms?.publishedKeys}\n initialTimestamps={cms?.timestamps}\n initialPublishTimestamps={cms?.publishTimestamps}\n initialChangedKeys={cms?.changedKeys}\n initialRevisions={cms?.revisions}\n initialLocaleConfig={resolveCmsInitialLocaleConfig(cms, project)}\n // EC-461: a hydrated mount (cms non-null — both modes now) seeds the\n // CURRENT persisted state, so staged docs are superseded by it; only\n // a static kit/fixture seed lets staged entries win.\n seedReflectsWrites={cms !== null}\n >\n <div className=\"flex h-full min-h-0 flex-col\">\n <CmsPersistErrorBanner />\n {/* EC-293: the collection list now lives in the section rail (nested\n under the CMS view), so the surface is full-width — the old 240px\n CollectionsSidebar aside is gone. EC-199: the AI assistant mounts as\n a right-hand sibling (both list + editor), so the content is a row. */}\n <div className=\"flex min-h-0 flex-1 overflow-hidden\">\n <div className=\"min-w-0 flex-1 overflow-hidden\">\n <CmsContent\n projectId={projectId}\n collectionId={collectionId}\n documentId={documentId}\n field={field}\n focusCollections={focusCollections}\n />\n </div>\n <AiCmsPanel />\n </div>\n </div>\n </CmsProvider>\n )\n }}\n </CmsSessionGate>\n )\n}\n\n/** Resolves the active CMS screen inside the provider (needs the live store). */\nfunction CmsContent({\n projectId,\n collectionId,\n documentId,\n field,\n focusCollections,\n}: {\n projectId: string\n collectionId: string | null\n documentId: string | null\n field?: string\n focusCollections?: readonly string[]\n}) {\n const cms = useCms()\n\n if (collectionId === null) return <CmsIndex projectId={projectId} focusCollections={focusCollections} />\n\n if (documentId === null) {\n const collection = cms.getCollection(collectionId)\n // EC-274: a singleton is a UI lens — at the collection URL it opens its one\n // document directly *while in its expected shape*, but degrades to the list\n // (with a \"for review\" lane) on drift. SingletonGate decides per the data.\n if (collection && isSingleton(collection)) {\n return <SingletonGate projectId={projectId} collectionId={collectionId} />\n }\n return <CollectionTable projectId={projectId} collectionId={collectionId} />\n }\n\n return (\n <DetailEditor\n projectId={projectId}\n collectionId={collectionId}\n documentId={documentId}\n focusPath={field}\n />\n )\n}\n\n/**\n * EC-274 — the singleton lens gate. At a singleton collection's URL, resolve its\n * lone document and open it directly; on drift (> 1 document) fall back to the\n * list with the \"for review\" lane so an editor can resolve the conflict.\n */\nfunction SingletonGate({ projectId, collectionId }: { projectId: string; collectionId: string }) {\n const cms = useCms()\n const collection = cms.getCollection(collectionId)\n const docs = cms.documentsOf(collectionId)\n const resolution = collection\n ? resolveSingletonDocument(collection, docs)\n : ({ kind: 'empty' } as const)\n\n // Materialize the lone document on first visit (an empty draft, persisted like\n // any create). Idempotent in the store; only fires while genuinely empty.\n useEffect(() => {\n if (resolution.kind === 'empty') cms.ensureSingletonDocument(collectionId)\n }, [resolution.kind, cms, collectionId])\n\n if (resolution.kind === 'ready') {\n return (\n <DetailEditor projectId={projectId} collectionId={collectionId} documentId={resolution.doc.id} />\n )\n }\n if (resolution.kind === 'drift') {\n return <CollectionTable projectId={projectId} collectionId={collectionId} />\n }\n return (\n <div className=\"grid h-full place-items-center p-8\">\n <Text size=\"sm\" tone=\"muted\">\n {translate('appViews.singleton.opening', {\n label: localizedLabel(collection?.form?.label, collectionId),\n })}\n </Text>\n </div>\n )\n}\n\n/** Failed/denied persisted CMS mutations are always visible (EC-141). */\nfunction CmsPersistErrorBanner() {\n const cms = useCms()\n if (!cms.persistError) return null\n return (\n <div className=\"shrink-0 border-b border-border p-2\">\n <OperationErrorBanner error={cms.persistError} onDismiss={cms.clearPersistError} />\n </div>\n )\n}\n"]}
@@ -12,8 +12,9 @@ import { ReferencesPanel } from '../references/references-panel.js';
12
12
  import { useSetBreadcrumb } from '../breadcrumb-context.js';
13
13
  import { useCollectionView } from '../collection-view/collection-view-context.js';
14
14
  import { FocalCropPreviews, FocalPointPicker, useAssetRecord } from './asset-thumb.js';
15
- import { assetMetaFieldsOf, formatBytes, pruneMeta } from './asset-metadata.js';
15
+ import { assetMetaFieldsOf, assetMetaSeed, formatBytes, pruneMeta } from './asset-metadata.js';
16
16
  import { useAssets } from './assets-store.js';
17
+ import { ReplaceFileButton } from './replace-file.js';
17
18
  /**
18
19
  * The assets rail's DETAIL surface (EC-319). Pragmatic call: assets don't fit
19
20
  * the portable `PortableDetailEditor` shell cleanly — there's no dirty/Save/
@@ -69,14 +70,23 @@ function AssetDetailBody({ projectId, record, collection, }) {
69
70
  // no dirty/Save document model of its own to piggyback on. The focal point
70
71
  // commits immediately (it drives a live visual), matching the field's options
71
72
  // dialog (`field-control.tsx`).
72
- const [meta, setMeta] = useState(() => ({
73
- ...(record.alt !== undefined ? { alt: record.alt } : {}),
74
- ...(record.meta ?? {}),
75
- }));
73
+ // EC-587: the bag the editor starts from has a legacy `alt` column lifted in, so a
74
+ // not-yet-migrated asset shows its alt and the save moves it to `meta.alt`.
75
+ const [meta, setMeta] = useState(() => assetMetaSeed(record));
76
76
  const [focal, setFocal] = useState(record.focalPoint);
77
77
  const [dirty, setDirty] = useState(false);
78
78
  const [saving, setSaving] = useState(false);
79
79
  const [saveError, setSaveError] = useState(null);
80
+ // EC-568: after a file replace the focal point is KEPT (the ticket's recommendation),
81
+ // but it was chosen on the old pixels — say so beside the picker.
82
+ const [replaced, setReplaced] = useState(false);
83
+ function onReplaced(asset) {
84
+ // The new file may have brought metadata: start the buffer from the stored record.
85
+ setMeta(assetMetaSeed(asset));
86
+ setFocal(asset.focalPoint);
87
+ setDirty(false);
88
+ setReplaced(true);
89
+ }
80
90
  function setField(name, value) {
81
91
  setDirty(true);
82
92
  setMeta((m) => ({ ...m, [name]: value }));
@@ -95,13 +105,13 @@ function AssetDetailBody({ projectId, record, collection, }) {
95
105
  setFocal(point ?? undefined);
96
106
  void store.updateMetadata(record.id, { focalPoint: point });
97
107
  }
98
- return (_jsxs(Stack, { gap: "4", className: "mx-auto max-w-3xl p-4 pb-10 sm:p-6", children: [_jsx(AssetDetailHeader, { projectId: projectId, record: record }), _jsxs(Panel, { children: [_jsx(PanelHeader, { children: _jsxs(Row, { align: "center", className: "w-full", children: [_jsx(Text, { size: "xs", weight: "semibold", tone: "muted", children: translate('cms.asset.focalPoint') }), _jsx(Spacer, {}), focal ? (_jsxs(Button, { variant: "ghost", size: "sm", onClick: () => commitFocal(null), children: [_jsx(RotateCcw, {}), " ", translate('cms.asset.resetToCentre')] })) : null] }) }), _jsx(PanelBody, { children: _jsxs(Stack, { gap: "2", children: [_jsx(FocalPointPicker, { record: record, point: focal, onChange: commitFocal, onPreview: setFocal }), _jsx(Text, { size: "xs", tone: "subtle", children: translate('cms.asset.focalPointHint') }), _jsx(FocalCropPreviews, { record: record, point: focal })] }) })] }), _jsxs(Panel, { "data-testid": "asset-detail-meta", children: [_jsx(PanelHeader, { children: _jsx(Text, { size: "xs", weight: "semibold", tone: "muted", children: translate('assets.detail.metadataHeading') }) }), _jsx(PanelBody, { children: _jsxs(Stack, { gap: "3", children: [metaFields.map((f) => (_jsx(Field, { label: fieldLabel(f), hint: localizedLabel(f.form?.description) || undefined, children: _jsx(FieldControl, { id: `asset-detail-${f.name}`, field: f, value: meta[f.name], readOnly: false, onChange: (v) => setField(f.name, v) }) }, f.name))), metaFields.length === 0 ? (_jsx(Text, { size: "sm", tone: "subtle", children: translate('cms.asset.noMetaFields', { code1: 'alt', code2: 'copyright' }) })) : null, saveError ? (_jsx(Text, { size: "sm", className: "text-destructive", "data-testid": "asset-detail-save-error", children: saveError })) : null, metaFields.length > 0 ? (_jsxs(Row, { gap: "2", children: [_jsx(Spacer, {}), _jsx(Button, { size: "sm", onClick: () => void save(), disabled: !dirty || saving, "data-testid": "asset-detail-save", children: saving ? translate('common.saving') : translate('common.save') })] })) : null] }) })] })] }));
108
+ return (_jsxs(Stack, { gap: "4", className: "mx-auto max-w-3xl p-4 pb-10 sm:p-6", children: [_jsx(AssetDetailHeader, { projectId: projectId, record: record, replace: _jsx(ReplaceFileButton, { record: record, disabled: dirty, disabledHint: translate('cms.asset.replaceSaveFirst'), onReplaced: onReplaced }) }), _jsxs(Panel, { children: [_jsx(PanelHeader, { children: _jsxs(Row, { align: "center", className: "w-full", children: [_jsx(Text, { size: "xs", weight: "semibold", tone: "muted", children: translate('cms.asset.focalPoint') }), _jsx(Spacer, {}), focal ? (_jsxs(Button, { variant: "ghost", size: "sm", onClick: () => commitFocal(null), children: [_jsx(RotateCcw, {}), " ", translate('cms.asset.resetToCentre')] })) : null] }) }), _jsx(PanelBody, { children: _jsxs(Stack, { gap: "2", children: [_jsx(FocalPointPicker, { record: record, point: focal, onChange: commitFocal, onPreview: setFocal }), replaced ? (_jsx(Text, { size: "xs", className: "font-medium", "data-testid": "asset-replaced-check-focal", children: translate('cms.asset.replacedCheckFocal') })) : null, _jsx(Text, { size: "xs", tone: "subtle", children: translate('cms.asset.focalPointHint') }), _jsx(FocalCropPreviews, { record: record, point: focal })] }) })] }), _jsxs(Panel, { "data-testid": "asset-detail-meta", children: [_jsx(PanelHeader, { children: _jsx(Text, { size: "xs", weight: "semibold", tone: "muted", children: translate('assets.detail.metadataHeading') }) }), _jsx(PanelBody, { children: _jsxs(Stack, { gap: "3", children: [metaFields.map((f) => (_jsx(Field, { label: fieldLabel(f), hint: localizedLabel(f.form?.description) || undefined, children: _jsx(FieldControl, { id: `asset-detail-${f.name}`, field: f, value: meta[f.name], readOnly: false, onChange: (v) => setField(f.name, v) }) }, f.name))), metaFields.length === 0 ? (_jsx(Text, { size: "sm", tone: "subtle", children: translate('cms.asset.noMetaFields', { code1: 'alt', code2: 'copyright' }) })) : null, saveError ? (_jsx(Text, { size: "sm", className: "text-destructive", "data-testid": "asset-detail-save-error", children: saveError })) : null, metaFields.length > 0 ? (_jsxs(Row, { gap: "2", children: [_jsx(Spacer, {}), _jsx(Button, { size: "sm", onClick: () => void save(), disabled: !dirty || saving, "data-testid": "asset-detail-save", children: saving ? translate('common.saving') : translate('common.save') })] })) : null] }) })] })] }));
99
109
  }
100
110
  /** Filename/title heading + system info (content type, dimensions, size) + actions. */
101
- function AssetDetailHeader({ projectId, record }) {
111
+ function AssetDetailHeader({ projectId, record, replace, }) {
102
112
  const dims = record.width && record.height ? `${record.width}×${record.height}` : null;
103
113
  const info = [record.contentType, dims, formatBytes(record.byteSize)].filter(Boolean).join(' · ');
104
- return (_jsxs(Row, { gap: "3", align: "start", wrap: true, children: [_jsxs(Stack, { gap: "1", className: "min-w-0 flex-1", children: [_jsx(Heading, { level: 2, size: "h2", className: "truncate", title: record.title ?? record.filename, children: record.title ?? record.filename }), record.title ? (_jsx(Text, { size: "sm", tone: "muted", className: "truncate", children: record.filename })) : null, _jsx(Text, { size: "xs", tone: "subtle", children: info })] }), _jsxs(Row, { gap: "2", children: [_jsx(AssetReferencesButton, { projectId: projectId, record: record }), _jsx(AssetDeleteButton, { projectId: projectId, record: record })] })] }));
114
+ return (_jsxs(Row, { gap: "3", align: "start", wrap: true, children: [_jsxs(Stack, { gap: "1", className: "min-w-0 flex-1", children: [_jsx(Heading, { level: 2, size: "h2", className: "truncate", title: record.title ?? record.filename, children: record.title ?? record.filename }), record.title ? (_jsx(Text, { size: "sm", tone: "muted", className: "truncate", children: record.filename })) : null, _jsx(Text, { size: "xs", tone: "subtle", children: info })] }), _jsxs(Row, { gap: "2", wrap: true, children: [replace, _jsx(AssetReferencesButton, { projectId: projectId, record: record }), _jsx(AssetDeleteButton, { projectId: projectId, record: record })] })] }));
105
115
  }
106
116
  /** "Where is this asset used?" (EC-172): the shared references panel, EC-155-backed. */
107
117
  function AssetReferencesButton({ projectId, record }) {
@@ -1 +1 @@
1
- {"version":3,"file":"asset-detail.js","sourceRoot":"","sources":["../../../src/components/assets/asset-detail.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAA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,CAAC,EAAE,QAAQ,EAAE,IAAI,YAC5E,SAAS,CAAC,eAAe,CAAC,GACpB,EACT,KAAC,MAAM,IACL,OAAO,EAAC,aAAa,EACrB,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,OAAO,EAAE,EAC7B,QAAQ,EAAE,IAAI,IAAI,MAAM,KAAK,IAAI,iBACrB,sBAAsB,YAEjC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,6BAA6B,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,GAChF,IACI,IACD,GACT,IACR,CACJ,CAAA;AACH,CAAC","sourcesContent":["import { useMemo, useState } from 'react'\nimport { AlertTriangle, Link2, RotateCcw, Trash2 } from 'lucide-react'\nimport type { CollectionDef, FieldDef } from '@elytracms/core/cms-core'\nimport type { AssetRecord } from '@elytracms/core/persistence'\nimport { Link, STUDIO_PROJECT_ROUTE, useNavigate } from '@elytracms/studio/router'\nimport { localizedLabel, translate } from '@elytracms/studio/lib/i18n'\nimport { buildAssetReferenceImpact, loadInboundAssetReferenceViews } from '@elytracms/studio/lib/references'\nimport type { ReferenceEntryView } from '@elytracms/studio/lib/references'\nimport {\n Button,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Field,\n Heading,\n Panel,\n PanelBody,\n PanelHeader,\n Row,\n Spacer,\n Stack,\n Text,\n} from '@elytracms/studio/ui'\nimport { FieldControl } from '../cms/field-control'\nimport { fieldLabel } from '../cms/cms-labels'\nimport { ReferenceImpactRows } from '../cms/reference-confirm'\nimport { ReferencesPanel } from '../references/references-panel'\nimport { useSetBreadcrumb } from '../breadcrumb-context'\nimport { useCollectionView } from '../collection-view/collection-view-context'\nimport { FocalCropPreviews, FocalPointPicker, useAssetRecord } from './asset-thumb'\nimport type { FocalPoint } from './focal-point'\nimport { assetMetaFieldsOf, formatBytes, pruneMeta } from './asset-metadata'\nimport { useAssets } from './assets-store'\n\n/**\n * The assets rail's DETAIL surface (EC-319). Pragmatic call: assets don't fit\n * the portable `PortableDetailEditor` shell cleanly — there's no dirty/Save/\n * Publish document model here (an asset record isn't a `cmsDocument`), and the\n * focal-point picker is a bespoke drag interaction over the image, not a\n * scalar field value a generic form row can host without contortions. So this\n * is a bespoke surface (mirrors the CMS document editor's shape: a header +\n * panels), reached via the SAME rail-owned `detailPath`/`listPath` seam every\n * other rail uses (AD-19) — only the body differs.\n *\n * Unifies what were two divergent asset-edit UIs before this task: the plain\n * alt/title dialog on the old asset library card, and the richer schema-driven\n * + focal-point \"image options\" dialog opened from an `asset` field elsewhere\n * (`field-control.tsx`). This page reuses the LATTER (richer) content, so\n * editing an asset here is never a downgrade from editing it via a field.\n *\n * Deletion keeps the EC-202 reference-index safe-delete path (`assets-store.tsx`\n * → `deleteAsset`, keyed on `{ type: 'asset' }`). Since EC-433 the universal\n * table's row/bulk delete runs the SAME asset-shaped reference check (the\n * source's `referenceTarget`) and the same confirmed store delete — the two\n * surfaces share one delete semantics, not two divergent ones.\n */\nexport function AssetDetail({ projectId, assetId }: { projectId: string; assetId: string }) {\n const source = useCollectionView()\n const store = useAssets()\n const record = useAssetRecord(assetId)\n const collection = source.schema\n\n const collectionLabel = localizedLabel(collection.form?.label, collection.id)\n useSetBreadcrumb(\n useMemo(() => {\n if (source.listPath === undefined) return [{ label: collectionLabel }]\n const title = record?.title ?? record?.filename ?? assetId\n return [\n { label: collectionLabel, to: STUDIO_PROJECT_ROUTE, params: { projectId, _splat: source.listPath } },\n { label: title },\n ]\n }, [collectionLabel, source.listPath, record, projectId, assetId]),\n )\n\n if (record === undefined) {\n if (store.status === 'loading') {\n return (\n <Stack className=\"h-full place-items-center p-8\" align=\"center\" justify=\"center\">\n <Text size=\"sm\" tone=\"muted\">\n {translate('assets.loading')}\n </Text>\n </Stack>\n )\n }\n return (\n <div className=\"grid h-full place-items-center p-8\">\n <Stack gap=\"3\" align=\"center\" className=\"text-center\">\n <Heading level={2} size=\"h2\">\n {translate('cms.editor.notFoundTitle')}\n </Heading>\n {source.listPath !== undefined ? (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: source.listPath }}\n className=\"text-sm text-primary hover:underline\"\n >\n {translate('cms.editor.backToList', { label: collectionLabel })}\n </Link>\n ) : null}\n </Stack>\n </div>\n )\n }\n\n // Remount per asset (the surface's own key, set by the caller) resets every\n // local buffer below cleanly when navigating from one asset's detail to\n // another — no stale-state carryover to guard against by hand.\n return <AssetDetailBody projectId={projectId} record={record} collection={source.schema} />\n}\n\nfunction AssetDetailBody({\n projectId,\n record,\n collection,\n}: {\n projectId: string\n record: AssetRecord\n collection: CollectionDef\n}) {\n const store = useAssets()\n const metaFields = useMemo(() => assetMetaFieldsOf(collection), [collection])\n\n // Metadata buffers locally and commits explicitly (Save) — an asset record has\n // no dirty/Save document model of its own to piggyback on. The focal point\n // commits immediately (it drives a live visual), matching the field's options\n // dialog (`field-control.tsx`).\n const [meta, setMeta] = useState<Record<string, unknown>>(() => ({\n ...(record.alt !== undefined ? { alt: record.alt } : {}),\n ...(record.meta ?? {}),\n }))\n const [focal, setFocal] = useState<FocalPoint | undefined>(record.focalPoint)\n const [dirty, setDirty] = useState(false)\n const [saving, setSaving] = useState(false)\n const [saveError, setSaveError] = useState<string | null>(null)\n\n function setField(name: string, value: unknown) {\n setDirty(true)\n setMeta((m) => ({ ...m, [name]: value }))\n }\n\n async function save() {\n setSaving(true)\n setSaveError(null)\n const result = await store.updateMetadata(record.id, { meta: pruneMeta(meta) })\n setSaving(false)\n if (result.ok) setDirty(false)\n else setSaveError(result.message)\n }\n\n function commitFocal(point: FocalPoint | null) {\n setFocal(point ?? undefined)\n void store.updateMetadata(record.id, { focalPoint: point })\n }\n\n return (\n <Stack gap=\"4\" className=\"mx-auto max-w-3xl p-4 pb-10 sm:p-6\">\n <AssetDetailHeader projectId={projectId} record={record} />\n\n <Panel>\n <PanelHeader>\n <Row align=\"center\" className=\"w-full\">\n <Text size=\"xs\" weight=\"semibold\" tone=\"muted\">\n {translate('cms.asset.focalPoint')}\n </Text>\n <Spacer />\n {focal ? (\n <Button variant=\"ghost\" size=\"sm\" onClick={() => commitFocal(null)}>\n <RotateCcw /> {translate('cms.asset.resetToCentre')}\n </Button>\n ) : null}\n </Row>\n </PanelHeader>\n <PanelBody>\n <Stack gap=\"2\">\n <FocalPointPicker record={record} point={focal} onChange={commitFocal} onPreview={setFocal} />\n <Text size=\"xs\" tone=\"subtle\">\n {translate('cms.asset.focalPointHint')}\n </Text>\n <FocalCropPreviews record={record} point={focal} />\n </Stack>\n </PanelBody>\n </Panel>\n\n <Panel data-testid=\"asset-detail-meta\">\n <PanelHeader>\n <Text size=\"xs\" weight=\"semibold\" tone=\"muted\">\n {translate('assets.detail.metadataHeading')}\n </Text>\n </PanelHeader>\n <PanelBody>\n <Stack gap=\"3\">\n {metaFields.map((f: FieldDef) => (\n <Field\n key={f.name}\n label={fieldLabel(f)}\n hint={localizedLabel(f.form?.description) || undefined}\n >\n <FieldControl\n id={`asset-detail-${f.name}`}\n field={f}\n value={meta[f.name]}\n readOnly={false}\n onChange={(v) => setField(f.name, v)}\n />\n </Field>\n ))}\n {metaFields.length === 0 ? (\n <Text size=\"sm\" tone=\"subtle\">\n {translate('cms.asset.noMetaFields', { code1: 'alt', code2: 'copyright' })}\n </Text>\n ) : null}\n {saveError ? (\n <Text size=\"sm\" className=\"text-destructive\" data-testid=\"asset-detail-save-error\">\n {saveError}\n </Text>\n ) : null}\n {metaFields.length > 0 ? (\n <Row gap=\"2\">\n <Spacer />\n <Button\n size=\"sm\"\n onClick={() => void save()}\n disabled={!dirty || saving}\n data-testid=\"asset-detail-save\"\n >\n {saving ? translate('common.saving') : translate('common.save')}\n </Button>\n </Row>\n ) : null}\n </Stack>\n </PanelBody>\n </Panel>\n </Stack>\n )\n}\n\n/** Filename/title heading + system info (content type, dimensions, size) + actions. */\nfunction AssetDetailHeader({ projectId, record }: { projectId: string; record: AssetRecord }) {\n const dims = record.width && record.height ? `${record.width}×${record.height}` : null\n const info = [record.contentType, dims, formatBytes(record.byteSize)].filter(Boolean).join(' · ')\n return (\n <Row gap=\"3\" align=\"start\" wrap>\n <Stack gap=\"1\" className=\"min-w-0 flex-1\">\n <Heading level={2} size=\"h2\" className=\"truncate\" title={record.title ?? record.filename}>\n {record.title ?? record.filename}\n </Heading>\n {record.title ? (\n <Text size=\"sm\" tone=\"muted\" className=\"truncate\">\n {record.filename}\n </Text>\n ) : null}\n <Text size=\"xs\" tone=\"subtle\">\n {info}\n </Text>\n </Stack>\n <Row gap=\"2\">\n <AssetReferencesButton projectId={projectId} record={record} />\n <AssetDeleteButton projectId={projectId} record={record} />\n </Row>\n </Row>\n )\n}\n\n/** \"Where is this asset used?\" (EC-172): the shared references panel, EC-155-backed. */\nfunction AssetReferencesButton({ projectId, record }: { projectId: string; record: AssetRecord }) {\n const [open, setOpen] = useState(false)\n return (\n <>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => setOpen(true)}\n data-testid=\"asset-detail-references\"\n >\n <Link2 /> {translate('assets.references.buttonLabel')}\n </Button>\n <Dialog open={open} onOpenChange={setOpen}>\n <DialogContent className=\"max-w-lg\">\n <DialogHeader>\n <DialogTitle>\n {translate('assets.references.title', { name: record.title ?? record.filename })}\n </DialogTitle>\n <DialogDescription>{translate('assets.references.description')}</DialogDescription>\n </DialogHeader>\n {open ? (\n <ReferencesPanel projectId={projectId} target={{ type: 'asset', id: record.id }} />\n ) : null}\n </DialogContent>\n </Dialog>\n </>\n )\n}\n\n/**\n * Reference-respecting delete (EC-151, EC-202): enumerates the exact inbound\n * references — index-accurate, with deep links to the field/node — before\n * removing. Deleting a referenced asset is weak-by-default (allowed with an\n * explicit \"delete anyway\"); every reference dangles into a visible validation\n * issue rather than silently breaking. On success, returns to the list.\n */\nfunction AssetDeleteButton({ projectId, record }: { projectId: string; record: AssetRecord }) {\n const source = useCollectionView()\n const store = useAssets()\n const navigate = useNavigate()\n const [open, setOpen] = useState(false)\n const [usages, setUsages] = useState<ReferenceEntryView[] | null>(null)\n const [error, setError] = useState<string | null>(null)\n const [busy, setBusy] = useState(false)\n\n const openDialog = async () => {\n setOpen(true)\n setError(null)\n setUsages(null)\n try {\n setUsages(await loadInboundAssetReferenceViews(projectId, record.id))\n } catch (cause) {\n setError(cause instanceof Error ? cause.message : String(cause))\n }\n }\n\n const confirm = async () => {\n setBusy(true)\n setError(null)\n // The dialog has already enumerated usages (or shown there are none) and the\n // user is confirming either way — confirm unconditionally, skipping the\n // redundant inbound re-check (EC-301 perf). Weak-by-default: a still-\n // referenced asset deletes anyway, dangling into a visible issue.\n const result = await store.remove(record.id, { confirmInUse: true })\n setBusy(false)\n if (result.outcome === 'deleted' || result.outcome === 'not-found') {\n setOpen(false)\n if (source.listPath !== undefined) {\n void navigate({ to: STUDIO_PROJECT_ROUTE, params: { projectId, _splat: source.listPath } })\n }\n } else if (result.outcome === 'blocked') {\n setError(\n translate(\n result.usageCount === 1 ? 'assets.delete.raceError.one' : 'assets.delete.raceError.other',\n { count: result.usageCount },\n ),\n )\n } else {\n setError(result.message)\n }\n }\n\n const impact = usages ? buildAssetReferenceImpact(usages) : null\n const usageCount = impact?.broken.length ?? 0\n return (\n <>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => void openDialog()}\n data-testid=\"asset-detail-delete\"\n >\n <Trash2 /> {translate('common.delete')}\n </Button>\n <Dialog open={open} onOpenChange={setOpen}>\n <DialogContent className=\"max-h-[80vh] max-w-md overflow-y-auto\">\n <DialogHeader>\n <DialogTitle>{translate('assets.delete.title', { filename: record.filename })}</DialogTitle>\n <DialogDescription>{translate('assets.delete.description')}</DialogDescription>\n </DialogHeader>\n {usages === null && error === null ? (\n <Text size=\"sm\" tone=\"muted\">\n {translate('assets.delete.checking')}\n </Text>\n ) : usageCount > 0 ? (\n <Stack gap=\"2\" data-testid=\"asset-usage-warning\">\n <Row gap=\"2\">\n <AlertTriangle className=\"size-4 text-warning\" />\n <Text size=\"sm\" weight=\"semibold\">\n {translate(usageCount === 1 ? 'assets.delete.inUse.one' : 'assets.delete.inUse.other', {\n count: usageCount,\n })}\n </Text>\n </Row>\n <ReferenceImpactRows\n projectId={projectId}\n broken={impact!.broken}\n onNavigate={() => setOpen(false)}\n />\n <Text size=\"xs\" tone=\"muted\">\n {translate('assets.delete.brokenWarning')}\n </Text>\n </Stack>\n ) : (\n <Text size=\"sm\" tone=\"muted\">\n {translate('assets.delete.noReferences')}\n </Text>\n )}\n {error ? (\n <Text size=\"sm\" className=\"text-destructive\" data-testid=\"asset-delete-error\">\n {error}\n </Text>\n ) : null}\n <DialogFooter>\n <Button variant=\"ghost\" size=\"sm\" onClick={() => setOpen(false)} disabled={busy}>\n {translate('common.cancel')}\n </Button>\n <Button\n variant=\"destructive\"\n size=\"sm\"\n onClick={() => void confirm()}\n disabled={busy || usages === null}\n data-testid=\"asset-delete-confirm\"\n >\n {usageCount > 0 ? translate('assets.delete.confirmAnyway') : translate('common.delete')}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </>\n )\n}\n"]}
1
+ {"version":3,"file":"asset-detail.js","sourceRoot":"","sources":["../../../src/components/assets/asset-detail.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAGtE,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAClF,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAA;AAE5G,OAAO,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,KAAK,EACL,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AAC,CAAC,CACP,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,kBAAkB,iBAAa,oBAAoB,YAC1E,KAAK,GACD,CACR,CAAC,CAAC,CAAC,IAAI,EACR,MAAC,YAAY,eACX,KAAC,MAAM,IAAC,OAAO,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,YAC5E,SAAS,CAAC,eAAe,CAAC,GACpB,EACT,KAAC,MAAM,IACL,OAAO,EAAC,aAAa,EACrB,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,OAAO,EAAE,EAC7B,QAAQ,EAAE,IAAI,IAAI,MAAM,KAAK,IAAI,iBACrB,sBAAsB,YAEjC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,6BAA6B,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,GAChF,IACI,IACD,GACT,IACR,CACJ,CAAA;AACH,CAAC","sourcesContent":["import { useMemo, useState } from 'react'\nimport type { ReactNode } from 'react'\nimport { AlertTriangle, Link2, RotateCcw, Trash2 } from 'lucide-react'\nimport type { CollectionDef, FieldDef } from '@elytracms/core/cms-core'\nimport type { AssetRecord } from '@elytracms/core/persistence'\nimport { Link, STUDIO_PROJECT_ROUTE, useNavigate } from '@elytracms/studio/router'\nimport { localizedLabel, translate } from '@elytracms/studio/lib/i18n'\nimport { buildAssetReferenceImpact, loadInboundAssetReferenceViews } from '@elytracms/studio/lib/references'\nimport type { ReferenceEntryView } from '@elytracms/studio/lib/references'\nimport {\n Button,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Field,\n Heading,\n Panel,\n PanelBody,\n PanelHeader,\n Row,\n Spacer,\n Stack,\n Text,\n} from '@elytracms/studio/ui'\nimport { FieldControl } from '../cms/field-control'\nimport { fieldLabel } from '../cms/cms-labels'\nimport { ReferenceImpactRows } from '../cms/reference-confirm'\nimport { ReferencesPanel } from '../references/references-panel'\nimport { useSetBreadcrumb } from '../breadcrumb-context'\nimport { useCollectionView } from '../collection-view/collection-view-context'\nimport { FocalCropPreviews, FocalPointPicker, useAssetRecord } from './asset-thumb'\nimport type { FocalPoint } from './focal-point'\nimport { assetMetaFieldsOf, assetMetaSeed, formatBytes, pruneMeta } from './asset-metadata'\nimport { useAssets } from './assets-store'\nimport { ReplaceFileButton } from './replace-file'\n\n/**\n * The assets rail's DETAIL surface (EC-319). Pragmatic call: assets don't fit\n * the portable `PortableDetailEditor` shell cleanly — there's no dirty/Save/\n * Publish document model here (an asset record isn't a `cmsDocument`), and the\n * focal-point picker is a bespoke drag interaction over the image, not a\n * scalar field value a generic form row can host without contortions. So this\n * is a bespoke surface (mirrors the CMS document editor's shape: a header +\n * panels), reached via the SAME rail-owned `detailPath`/`listPath` seam every\n * other rail uses (AD-19) — only the body differs.\n *\n * Unifies what were two divergent asset-edit UIs before this task: the plain\n * alt/title dialog on the old asset library card, and the richer schema-driven\n * + focal-point \"image options\" dialog opened from an `asset` field elsewhere\n * (`field-control.tsx`). This page reuses the LATTER (richer) content, so\n * editing an asset here is never a downgrade from editing it via a field.\n *\n * Deletion keeps the EC-202 reference-index safe-delete path (`assets-store.tsx`\n * → `deleteAsset`, keyed on `{ type: 'asset' }`). Since EC-433 the universal\n * table's row/bulk delete runs the SAME asset-shaped reference check (the\n * source's `referenceTarget`) and the same confirmed store delete — the two\n * surfaces share one delete semantics, not two divergent ones.\n */\nexport function AssetDetail({ projectId, assetId }: { projectId: string; assetId: string }) {\n const source = useCollectionView()\n const store = useAssets()\n const record = useAssetRecord(assetId)\n const collection = source.schema\n\n const collectionLabel = localizedLabel(collection.form?.label, collection.id)\n useSetBreadcrumb(\n useMemo(() => {\n if (source.listPath === undefined) return [{ label: collectionLabel }]\n const title = record?.title ?? record?.filename ?? assetId\n return [\n { label: collectionLabel, to: STUDIO_PROJECT_ROUTE, params: { projectId, _splat: source.listPath } },\n { label: title },\n ]\n }, [collectionLabel, source.listPath, record, projectId, assetId]),\n )\n\n if (record === undefined) {\n if (store.status === 'loading') {\n return (\n <Stack className=\"h-full place-items-center p-8\" align=\"center\" justify=\"center\">\n <Text size=\"sm\" tone=\"muted\">\n {translate('assets.loading')}\n </Text>\n </Stack>\n )\n }\n return (\n <div className=\"grid h-full place-items-center p-8\">\n <Stack gap=\"3\" align=\"center\" className=\"text-center\">\n <Heading level={2} size=\"h2\">\n {translate('cms.editor.notFoundTitle')}\n </Heading>\n {source.listPath !== undefined ? (\n <Link\n to={STUDIO_PROJECT_ROUTE}\n params={{ projectId, _splat: source.listPath }}\n className=\"text-sm text-primary hover:underline\"\n >\n {translate('cms.editor.backToList', { label: collectionLabel })}\n </Link>\n ) : null}\n </Stack>\n </div>\n )\n }\n\n // Remount per asset (the surface's own key, set by the caller) resets every\n // local buffer below cleanly when navigating from one asset's detail to\n // another — no stale-state carryover to guard against by hand.\n return <AssetDetailBody projectId={projectId} record={record} collection={source.schema} />\n}\n\nfunction AssetDetailBody({\n projectId,\n record,\n collection,\n}: {\n projectId: string\n record: AssetRecord\n collection: CollectionDef\n}) {\n const store = useAssets()\n const metaFields = useMemo(() => assetMetaFieldsOf(collection), [collection])\n\n // Metadata buffers locally and commits explicitly (Save) — an asset record has\n // no dirty/Save document model of its own to piggyback on. The focal point\n // commits immediately (it drives a live visual), matching the field's options\n // dialog (`field-control.tsx`).\n // EC-587: the bag the editor starts from has a legacy `alt` column lifted in, so a\n // not-yet-migrated asset shows its alt and the save moves it to `meta.alt`.\n const [meta, setMeta] = useState<Record<string, unknown>>(() => assetMetaSeed(record))\n const [focal, setFocal] = useState<FocalPoint | undefined>(record.focalPoint)\n const [dirty, setDirty] = useState(false)\n const [saving, setSaving] = useState(false)\n const [saveError, setSaveError] = useState<string | null>(null)\n // EC-568: after a file replace the focal point is KEPT (the ticket's recommendation),\n // but it was chosen on the old pixels — say so beside the picker.\n const [replaced, setReplaced] = useState(false)\n\n function onReplaced(asset: AssetRecord) {\n // The new file may have brought metadata: start the buffer from the stored record.\n setMeta(assetMetaSeed(asset))\n setFocal(asset.focalPoint)\n setDirty(false)\n setReplaced(true)\n }\n\n function setField(name: string, value: unknown) {\n setDirty(true)\n setMeta((m) => ({ ...m, [name]: value }))\n }\n\n async function save() {\n setSaving(true)\n setSaveError(null)\n const result = await store.updateMetadata(record.id, { meta: pruneMeta(meta) })\n setSaving(false)\n if (result.ok) setDirty(false)\n else setSaveError(result.message)\n }\n\n function commitFocal(point: FocalPoint | null) {\n setFocal(point ?? undefined)\n void store.updateMetadata(record.id, { focalPoint: point })\n }\n\n return (\n <Stack gap=\"4\" className=\"mx-auto max-w-3xl p-4 pb-10 sm:p-6\">\n <AssetDetailHeader\n projectId={projectId}\n record={record}\n replace={\n <ReplaceFileButton\n record={record}\n disabled={dirty}\n disabledHint={translate('cms.asset.replaceSaveFirst')}\n onReplaced={onReplaced}\n />\n }\n />\n\n <Panel>\n <PanelHeader>\n <Row align=\"center\" className=\"w-full\">\n <Text size=\"xs\" weight=\"semibold\" tone=\"muted\">\n {translate('cms.asset.focalPoint')}\n </Text>\n <Spacer />\n {focal ? (\n <Button variant=\"ghost\" size=\"sm\" onClick={() => commitFocal(null)}>\n <RotateCcw /> {translate('cms.asset.resetToCentre')}\n </Button>\n ) : null}\n </Row>\n </PanelHeader>\n <PanelBody>\n <Stack gap=\"2\">\n <FocalPointPicker record={record} point={focal} onChange={commitFocal} onPreview={setFocal} />\n {replaced ? (\n <Text size=\"xs\" className=\"font-medium\" data-testid=\"asset-replaced-check-focal\">\n {translate('cms.asset.replacedCheckFocal')}\n </Text>\n ) : null}\n <Text size=\"xs\" tone=\"subtle\">\n {translate('cms.asset.focalPointHint')}\n </Text>\n <FocalCropPreviews record={record} point={focal} />\n </Stack>\n </PanelBody>\n </Panel>\n\n <Panel data-testid=\"asset-detail-meta\">\n <PanelHeader>\n <Text size=\"xs\" weight=\"semibold\" tone=\"muted\">\n {translate('assets.detail.metadataHeading')}\n </Text>\n </PanelHeader>\n <PanelBody>\n <Stack gap=\"3\">\n {metaFields.map((f: FieldDef) => (\n <Field\n key={f.name}\n label={fieldLabel(f)}\n hint={localizedLabel(f.form?.description) || undefined}\n >\n <FieldControl\n id={`asset-detail-${f.name}`}\n field={f}\n value={meta[f.name]}\n readOnly={false}\n onChange={(v) => setField(f.name, v)}\n />\n </Field>\n ))}\n {metaFields.length === 0 ? (\n <Text size=\"sm\" tone=\"subtle\">\n {translate('cms.asset.noMetaFields', { code1: 'alt', code2: 'copyright' })}\n </Text>\n ) : null}\n {saveError ? (\n <Text size=\"sm\" className=\"text-destructive\" data-testid=\"asset-detail-save-error\">\n {saveError}\n </Text>\n ) : null}\n {metaFields.length > 0 ? (\n <Row gap=\"2\">\n <Spacer />\n <Button\n size=\"sm\"\n onClick={() => void save()}\n disabled={!dirty || saving}\n data-testid=\"asset-detail-save\"\n >\n {saving ? translate('common.saving') : translate('common.save')}\n </Button>\n </Row>\n ) : null}\n </Stack>\n </PanelBody>\n </Panel>\n </Stack>\n )\n}\n\n/** Filename/title heading + system info (content type, dimensions, size) + actions. */\nfunction AssetDetailHeader({\n projectId,\n record,\n replace,\n}: {\n projectId: string\n record: AssetRecord\n replace?: ReactNode\n}) {\n const dims = record.width && record.height ? `${record.width}×${record.height}` : null\n const info = [record.contentType, dims, formatBytes(record.byteSize)].filter(Boolean).join(' · ')\n return (\n <Row gap=\"3\" align=\"start\" wrap>\n <Stack gap=\"1\" className=\"min-w-0 flex-1\">\n <Heading level={2} size=\"h2\" className=\"truncate\" title={record.title ?? record.filename}>\n {record.title ?? record.filename}\n </Heading>\n {record.title ? (\n <Text size=\"sm\" tone=\"muted\" className=\"truncate\">\n {record.filename}\n </Text>\n ) : null}\n <Text size=\"xs\" tone=\"subtle\">\n {info}\n </Text>\n </Stack>\n <Row gap=\"2\" wrap>\n {replace}\n <AssetReferencesButton projectId={projectId} record={record} />\n <AssetDeleteButton projectId={projectId} record={record} />\n </Row>\n </Row>\n )\n}\n\n/** \"Where is this asset used?\" (EC-172): the shared references panel, EC-155-backed. */\nfunction AssetReferencesButton({ projectId, record }: { projectId: string; record: AssetRecord }) {\n const [open, setOpen] = useState(false)\n return (\n <>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => setOpen(true)}\n data-testid=\"asset-detail-references\"\n >\n <Link2 /> {translate('assets.references.buttonLabel')}\n </Button>\n <Dialog open={open} onOpenChange={setOpen}>\n <DialogContent className=\"max-w-lg\">\n <DialogHeader>\n <DialogTitle>\n {translate('assets.references.title', { name: record.title ?? record.filename })}\n </DialogTitle>\n <DialogDescription>{translate('assets.references.description')}</DialogDescription>\n </DialogHeader>\n {open ? (\n <ReferencesPanel projectId={projectId} target={{ type: 'asset', id: record.id }} />\n ) : null}\n </DialogContent>\n </Dialog>\n </>\n )\n}\n\n/**\n * Reference-respecting delete (EC-151, EC-202): enumerates the exact inbound\n * references — index-accurate, with deep links to the field/node — before\n * removing. Deleting a referenced asset is weak-by-default (allowed with an\n * explicit \"delete anyway\"); every reference dangles into a visible validation\n * issue rather than silently breaking. On success, returns to the list.\n */\nfunction AssetDeleteButton({ projectId, record }: { projectId: string; record: AssetRecord }) {\n const source = useCollectionView()\n const store = useAssets()\n const navigate = useNavigate()\n const [open, setOpen] = useState(false)\n const [usages, setUsages] = useState<ReferenceEntryView[] | null>(null)\n const [error, setError] = useState<string | null>(null)\n const [busy, setBusy] = useState(false)\n\n const openDialog = async () => {\n setOpen(true)\n setError(null)\n setUsages(null)\n try {\n setUsages(await loadInboundAssetReferenceViews(projectId, record.id))\n } catch (cause) {\n setError(cause instanceof Error ? cause.message : String(cause))\n }\n }\n\n const confirm = async () => {\n setBusy(true)\n setError(null)\n // The dialog has already enumerated usages (or shown there are none) and the\n // user is confirming either way — confirm unconditionally, skipping the\n // redundant inbound re-check (EC-301 perf). Weak-by-default: a still-\n // referenced asset deletes anyway, dangling into a visible issue.\n const result = await store.remove(record.id, { confirmInUse: true })\n setBusy(false)\n if (result.outcome === 'deleted' || result.outcome === 'not-found') {\n setOpen(false)\n if (source.listPath !== undefined) {\n void navigate({ to: STUDIO_PROJECT_ROUTE, params: { projectId, _splat: source.listPath } })\n }\n } else if (result.outcome === 'blocked') {\n setError(\n translate(\n result.usageCount === 1 ? 'assets.delete.raceError.one' : 'assets.delete.raceError.other',\n { count: result.usageCount },\n ),\n )\n } else {\n setError(result.message)\n }\n }\n\n const impact = usages ? buildAssetReferenceImpact(usages) : null\n const usageCount = impact?.broken.length ?? 0\n return (\n <>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => void openDialog()}\n data-testid=\"asset-detail-delete\"\n >\n <Trash2 /> {translate('common.delete')}\n </Button>\n <Dialog open={open} onOpenChange={setOpen}>\n <DialogContent className=\"max-h-[80vh] max-w-md overflow-y-auto\">\n <DialogHeader>\n <DialogTitle>{translate('assets.delete.title', { filename: record.filename })}</DialogTitle>\n <DialogDescription>{translate('assets.delete.description')}</DialogDescription>\n </DialogHeader>\n {usages === null && error === null ? (\n <Text size=\"sm\" tone=\"muted\">\n {translate('assets.delete.checking')}\n </Text>\n ) : usageCount > 0 ? (\n <Stack gap=\"2\" data-testid=\"asset-usage-warning\">\n <Row gap=\"2\">\n <AlertTriangle className=\"size-4 text-warning\" />\n <Text size=\"sm\" weight=\"semibold\">\n {translate(usageCount === 1 ? 'assets.delete.inUse.one' : 'assets.delete.inUse.other', {\n count: usageCount,\n })}\n </Text>\n </Row>\n <ReferenceImpactRows\n projectId={projectId}\n broken={impact!.broken}\n onNavigate={() => setOpen(false)}\n />\n <Text size=\"xs\" tone=\"muted\">\n {translate('assets.delete.brokenWarning')}\n </Text>\n </Stack>\n ) : (\n <Text size=\"sm\" tone=\"muted\">\n {translate('assets.delete.noReferences')}\n </Text>\n )}\n {error ? (\n <Text size=\"sm\" className=\"text-destructive\" data-testid=\"asset-delete-error\">\n {error}\n </Text>\n ) : null}\n <DialogFooter>\n <Button variant=\"ghost\" size=\"sm\" onClick={() => setOpen(false)} disabled={busy}>\n {translate('common.cancel')}\n </Button>\n <Button\n variant=\"destructive\"\n size=\"sm\"\n onClick={() => void confirm()}\n disabled={busy || usages === null}\n data-testid=\"asset-delete-confirm\"\n >\n {usageCount > 0 ? translate('assets.delete.confirmAnyway') : translate('common.delete')}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </>\n )\n}\n"]}
@@ -30,9 +30,7 @@ export declare function formatBytes(byteSize: number): string;
30
30
  * stored value untouched, `null` clears it, a value sets it.
31
31
  */
32
32
  export interface AssetMetadataPatch {
33
- /** New alt text: a value sets (trimmed), `null` or a trimmed-empty string clears. */
34
- alt?: string | null;
35
- /** New display title; same semantics as `alt`. */
33
+ /** New display title: a value sets (trimmed), `null` or a trimmed-empty string clears. */
36
34
  title?: string | null;
37
35
  /**
38
36
  * New focal point (EC-248), the normalized 0–1 hotspot threaded to delivery's
@@ -46,16 +44,29 @@ export interface AssetMetadataPatch {
46
44
  /**
47
45
  * Schema-driven asset metadata bag (EC-301): alt, copyright, credit, … keyed by
48
46
  * the asset collection's `fields`. An object **replaces** the whole bag (the
49
- * image options dialog holds the complete edited meta); `null` clears it.
47
+ * image options dialog holds the complete edited meta, seeded through
48
+ * {@link assetMetaSeed}); `null` clears it. `meta.alt` is the asset's ONE alt
49
+ * (EC-587) — there is no separate alt key.
50
50
  */
51
51
  meta?: Record<string, unknown> | null;
52
52
  }
53
+ /**
54
+ * The meta bag an editor starts from (EC-587): the stored `meta` with a legacy `alt`
55
+ * column lifted in (core `liftLegacyAlt`), so a not-yet-migrated asset shows the alt
56
+ * every reader shows — and the save writes it to `meta`, its home.
57
+ */
58
+ export declare function assetMetaSeed(record: Pick<AssetRecord, 'alt' | 'meta'>): Record<string, unknown>;
53
59
  /**
54
60
  * The asset write for a metadata edit (EC-577): ONLY the keys the editor changed,
55
61
  * with `null` for a clear. It deliberately restates nothing else — not the
56
62
  * upload-owned columns, and never `thumb`/`lqip`: a stale copy of those would
57
63
  * overwrite a preview backfill that finished while the dialog was open, and a
58
64
  * clear expressed as an omitted key is exactly what never persisted on Convex.
65
+ *
66
+ * EC-587: a `meta` write also clears the legacy `alt` column. The bag was seeded with
67
+ * that column lifted in ({@link assetMetaSeed}), so the alt the editor saw is in the bag
68
+ * (or was deliberately cleared): the column has nothing left to say, and leaving it
69
+ * would re-surface a cleared alt through the read fallback (ASSETS D21).
59
70
  */
60
71
  export declare function assetMetadataWrite(assetId: string, patch: AssetMetadataPatch): AssetWriteInput;
61
72
  export type UpdateAssetMetadataResult = {