@elytracms/studio 0.0.93 → 0.0.94

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 (481) hide show
  1. package/convex/analytics-cost.test.ts +817 -0
  2. package/convex/auth.ts +5 -2
  3. package/convex/authority.ts +35 -11
  4. package/convex/contract-parity.test.ts +7 -0
  5. package/convex/delivery.ts +12 -9
  6. package/convex/guard.ts +9 -7
  7. package/convex/http-routes.test.ts +18 -8
  8. package/convex/http.ts +23 -17
  9. package/convex/ingest.test.ts +326 -0
  10. package/convex/ingest.ts +281 -0
  11. package/convex/invites.ts +13 -5
  12. package/convex/members.ts +10 -4
  13. package/convex/record-functions.ts +325 -0
  14. package/convex/records.test.ts +156 -0
  15. package/convex/redirect-migration.test.ts +205 -0
  16. package/convex/redirect-revalidate.test.ts +5 -1
  17. package/convex/redirects.ts +120 -79
  18. package/convex/role-policy.test.ts +315 -0
  19. package/convex/roles.ts +83 -0
  20. package/convex/schema.ts +30 -0
  21. package/convex/triggers.ts +21 -1
  22. package/dist/addon.d.ts +71 -0
  23. package/dist/addon.js +67 -0
  24. package/dist/addon.js.map +1 -0
  25. package/dist/components/account/account-settings.js +2 -2
  26. package/dist/components/account/account-settings.js.map +1 -1
  27. package/dist/components/account/credential-panel.js +2 -2
  28. package/dist/components/account/credential-panel.js.map +1 -1
  29. package/dist/components/account/self-account-schema.d.ts +6 -15
  30. package/dist/components/account/self-account-schema.js +52 -34
  31. package/dist/components/account/self-account-schema.js.map +1 -1
  32. package/dist/components/account/self-account-view-source.d.ts +1 -1
  33. package/dist/components/account/self-account-view-source.js +6 -4
  34. package/dist/components/account/self-account-view-source.js.map +1 -1
  35. package/dist/components/ai/ai-chat-panel-lazy.js +1 -1
  36. package/dist/components/ai/ai-chat-panel-lazy.js.map +1 -1
  37. package/dist/components/ai/ai-chat-panel.js +6 -6
  38. package/dist/components/ai/ai-chat-panel.js.map +1 -1
  39. package/dist/components/ai/ai-cms-panel.js +2 -2
  40. package/dist/components/ai/ai-cms-panel.js.map +1 -1
  41. package/dist/components/ai/ai-panel-toggle.js +4 -4
  42. package/dist/components/ai/ai-panel-toggle.js.map +1 -1
  43. package/dist/components/ai/chat-ui.js +2 -2
  44. package/dist/components/ai/chat-ui.js.map +1 -1
  45. package/dist/components/ai/proposal-card.d.ts +2 -2
  46. package/dist/components/ai/proposal-card.js +2 -2
  47. package/dist/components/ai/proposal-card.js.map +1 -1
  48. package/dist/components/ai/proposal-issues.js +2 -2
  49. package/dist/components/ai/proposal-issues.js.map +1 -1
  50. package/dist/components/ai/translate-document-action.js +2 -2
  51. package/dist/components/ai/translate-document-action.js.map +1 -1
  52. package/dist/components/ai/translate-document-dialog.js +6 -6
  53. package/dist/components/ai/translate-document-dialog.js.map +1 -1
  54. package/dist/components/ai/translate-skipped.d.ts +1 -1
  55. package/dist/components/ai/translate-skipped.js +2 -2
  56. package/dist/components/ai/translate-skipped.js.map +1 -1
  57. package/dist/components/app-views/default-modules.d.ts +50 -2
  58. package/dist/components/app-views/default-modules.js +65 -20
  59. package/dist/components/app-views/default-modules.js.map +1 -1
  60. package/dist/components/app-views/module.d.ts +53 -3
  61. package/dist/components/app-views/module.js +14 -7
  62. package/dist/components/app-views/module.js.map +1 -1
  63. package/dist/components/app-views/sidebar.js +1 -1
  64. package/dist/components/app-views/sidebar.js.map +1 -1
  65. package/dist/components/app-views/studio-config.d.ts +11 -2
  66. package/dist/components/app-views/studio-config.js.map +1 -1
  67. package/dist/components/assets/asset-detail.js +2 -2
  68. package/dist/components/assets/asset-detail.js.map +1 -1
  69. package/dist/components/assets/asset-grid.js +2 -2
  70. package/dist/components/assets/asset-grid.js.map +1 -1
  71. package/dist/components/assets/asset-thumb.js +3 -3
  72. package/dist/components/assets/asset-thumb.js.map +1 -1
  73. package/dist/components/assets/assets-collection-view-source.d.ts +2 -2
  74. package/dist/components/assets/assets-collection-view-source.js.map +1 -1
  75. package/dist/components/assets/assets-module.js +1 -1
  76. package/dist/components/assets/assets-module.js.map +1 -1
  77. package/dist/components/assets/assets-store.d.ts +2 -2
  78. package/dist/components/assets/assets-store.js +6 -6
  79. package/dist/components/assets/assets-store.js.map +1 -1
  80. package/dist/components/assets/assets-view-preference.js +1 -1
  81. package/dist/components/assets/assets-view-preference.js.map +1 -1
  82. package/dist/components/assets/replace-file.js +1 -1
  83. package/dist/components/assets/replace-file.js.map +1 -1
  84. package/dist/components/auth-context.d.ts +1 -1
  85. package/dist/components/auth-context.js +6 -6
  86. package/dist/components/auth-context.js.map +1 -1
  87. package/dist/components/builder/blocks-model.d.ts +1 -1
  88. package/dist/components/builder/blocks-model.js +3 -3
  89. package/dist/components/builder/blocks-model.js.map +1 -1
  90. package/dist/components/builder/blocks-panel.d.ts +1 -1
  91. package/dist/components/builder/blocks-panel.js +4 -4
  92. package/dist/components/builder/blocks-panel.js.map +1 -1
  93. package/dist/components/builder/builder-store.js +2 -2
  94. package/dist/components/builder/builder-store.js.map +1 -1
  95. package/dist/components/builder/canvas-breakpoints.js +1 -1
  96. package/dist/components/builder/canvas-breakpoints.js.map +1 -1
  97. package/dist/components/builder/canvas-dnd.d.ts +2 -2
  98. package/dist/components/builder/canvas-dnd.js +1 -1
  99. package/dist/components/builder/canvas-dnd.js.map +1 -1
  100. package/dist/components/builder/canvas-inline-editing.d.ts +1 -1
  101. package/dist/components/builder/canvas-inline-editing.js.map +1 -1
  102. package/dist/components/builder/canvas-overlay-geometry.d.ts +1 -1
  103. package/dist/components/builder/canvas-overlay-geometry.js.map +1 -1
  104. package/dist/components/builder/canvas-render-context.d.ts +1 -1
  105. package/dist/components/builder/canvas-render-context.js +4 -4
  106. package/dist/components/builder/canvas-render-context.js.map +1 -1
  107. package/dist/components/builder/canvas-theme-notice.js +2 -2
  108. package/dist/components/builder/canvas-theme-notice.js.map +1 -1
  109. package/dist/components/builder/canvas.js +3 -3
  110. package/dist/components/builder/canvas.js.map +1 -1
  111. package/dist/components/builder/clipboard-actions.d.ts +2 -2
  112. package/dist/components/builder/clipboard-actions.js +4 -4
  113. package/dist/components/builder/clipboard-actions.js.map +1 -1
  114. package/dist/components/builder/composition-field-editor-lazy.js +1 -1
  115. package/dist/components/builder/composition-field-editor-lazy.js.map +1 -1
  116. package/dist/components/builder/composition-field-editor.d.ts +1 -1
  117. package/dist/components/builder/composition-field-editor.js +3 -3
  118. package/dist/components/builder/composition-field-editor.js.map +1 -1
  119. package/dist/components/builder/drag-session.d.ts +1 -1
  120. package/dist/components/builder/drag-session.js.map +1 -1
  121. package/dist/components/builder/fixture-thumbnail.js +1 -1
  122. package/dist/components/builder/fixture-thumbnail.js.map +1 -1
  123. package/dist/components/builder/insert-context.d.ts +1 -1
  124. package/dist/components/builder/insert-context.js +3 -3
  125. package/dist/components/builder/insert-context.js.map +1 -1
  126. package/dist/components/builder/layout-inspector.js +1 -1
  127. package/dist/components/builder/layout-inspector.js.map +1 -1
  128. package/dist/components/builder/node-title.js +1 -1
  129. package/dist/components/builder/node-title.js.map +1 -1
  130. package/dist/components/builder/page-tree.d.ts +1 -1
  131. package/dist/components/builder/page-tree.js +5 -5
  132. package/dist/components/builder/page-tree.js.map +1 -1
  133. package/dist/components/builder/placement-refusal.js +3 -3
  134. package/dist/components/builder/placement-refusal.js.map +1 -1
  135. package/dist/components/builder/property-inspector.js +4 -4
  136. package/dist/components/builder/property-inspector.js.map +1 -1
  137. package/dist/components/builder/reuse-context.js +4 -4
  138. package/dist/components/builder/reuse-context.js.map +1 -1
  139. package/dist/components/builder/reuse.js +1 -1
  140. package/dist/components/builder/reuse.js.map +1 -1
  141. package/dist/components/builder/rich-text-toolbar.js +1 -1
  142. package/dist/components/builder/rich-text-toolbar.js.map +1 -1
  143. package/dist/components/builder/run-inspector.js +1 -1
  144. package/dist/components/builder/run-inspector.js.map +1 -1
  145. package/dist/components/builder/selection-overlay.js +3 -3
  146. package/dist/components/builder/selection-overlay.js.map +1 -1
  147. package/dist/components/builder/spacing-handles.d.ts +2 -2
  148. package/dist/components/builder/spacing-handles.js +3 -3
  149. package/dist/components/builder/spacing-handles.js.map +1 -1
  150. package/dist/components/cms/asset-field.js +2 -2
  151. package/dist/components/cms/asset-field.js.map +1 -1
  152. package/dist/components/cms/asset-picker.js +2 -2
  153. package/dist/components/cms/asset-picker.js.map +1 -1
  154. package/dist/components/cms/bulk-actions.d.ts +1 -1
  155. package/dist/components/cms/bulk-actions.js +2 -2
  156. package/dist/components/cms/bulk-actions.js.map +1 -1
  157. package/dist/components/cms/bulk-bar.d.ts +2 -2
  158. package/dist/components/cms/bulk-bar.js +2 -2
  159. package/dist/components/cms/bulk-bar.js.map +1 -1
  160. package/dist/components/cms/cell-edit.d.ts +1 -1
  161. package/dist/components/cms/cell-edit.js +1 -1
  162. package/dist/components/cms/cell-edit.js.map +1 -1
  163. package/dist/components/cms/cell.d.ts +1 -1
  164. package/dist/components/cms/cell.js +3 -3
  165. package/dist/components/cms/cell.js.map +1 -1
  166. package/dist/components/cms/cms-index.js +2 -2
  167. package/dist/components/cms/cms-index.js.map +1 -1
  168. package/dist/components/cms/cms-labels.js +2 -2
  169. package/dist/components/cms/cms-labels.js.map +1 -1
  170. package/dist/components/cms/cms-store.d.ts +2 -2
  171. package/dist/components/cms/cms-store.js +10 -10
  172. package/dist/components/cms/cms-store.js.map +1 -1
  173. package/dist/components/cms/collection-table.js +7 -7
  174. package/dist/components/cms/collection-table.js.map +1 -1
  175. package/dist/components/cms/detail-editor.d.ts +5 -2
  176. package/dist/components/cms/detail-editor.js +20 -14
  177. package/dist/components/cms/detail-editor.js.map +1 -1
  178. package/dist/components/cms/details-pane.js +1 -1
  179. package/dist/components/cms/details-pane.js.map +1 -1
  180. package/dist/components/cms/doc-state.js +1 -1
  181. package/dist/components/cms/doc-state.js.map +1 -1
  182. package/dist/components/cms/document-diff-view.js +5 -5
  183. package/dist/components/cms/document-diff-view.js.map +1 -1
  184. package/dist/components/cms/document-editor-context.js +1 -1
  185. package/dist/components/cms/document-editor-context.js.map +1 -1
  186. package/dist/components/cms/document-staging.js +1 -1
  187. package/dist/components/cms/document-staging.js.map +1 -1
  188. package/dist/components/cms/document-url-path.js +2 -2
  189. package/dist/components/cms/document-url-path.js.map +1 -1
  190. package/dist/components/cms/duplicate-document.d.ts +1 -1
  191. package/dist/components/cms/duplicate-document.js.map +1 -1
  192. package/dist/components/cms/editable-cell.js +3 -3
  193. package/dist/components/cms/editable-cell.js.map +1 -1
  194. package/dist/components/cms/field-collaboration.d.ts +1 -1
  195. package/dist/components/cms/field-collaboration.js +1 -1
  196. package/dist/components/cms/field-collaboration.js.map +1 -1
  197. package/dist/components/cms/field-connection.d.ts +1 -1
  198. package/dist/components/cms/field-connection.js +2 -2
  199. package/dist/components/cms/field-connection.js.map +1 -1
  200. package/dist/components/cms/field-control-lib.js +1 -1
  201. package/dist/components/cms/field-control-lib.js.map +1 -1
  202. package/dist/components/cms/field-control.js +4 -4
  203. package/dist/components/cms/field-control.js.map +1 -1
  204. package/dist/components/cms/field-renderer.d.ts +1 -1
  205. package/dist/components/cms/field-renderer.js +2 -2
  206. package/dist/components/cms/field-renderer.js.map +1 -1
  207. package/dist/components/cms/filter-builder.d.ts +1 -1
  208. package/dist/components/cms/filter-builder.js +3 -3
  209. package/dist/components/cms/filter-builder.js.map +1 -1
  210. package/dist/components/cms/gate-validation.js +1 -1
  211. package/dist/components/cms/gate-validation.js.map +1 -1
  212. package/dist/components/cms/import-export.js +2 -2
  213. package/dist/components/cms/import-export.js.map +1 -1
  214. package/dist/components/cms/issue-copy.js +1 -1
  215. package/dist/components/cms/issue-copy.js.map +1 -1
  216. package/dist/components/cms/issues-pane.js +3 -3
  217. package/dist/components/cms/issues-pane.js.map +1 -1
  218. package/dist/components/cms/object-array-field.js +2 -2
  219. package/dist/components/cms/object-array-field.js.map +1 -1
  220. package/dist/components/cms/prop-fields.js +2 -2
  221. package/dist/components/cms/prop-fields.js.map +1 -1
  222. package/dist/components/cms/reference-confirm.d.ts +1 -1
  223. package/dist/components/cms/reference-confirm.js +2 -2
  224. package/dist/components/cms/reference-confirm.js.map +1 -1
  225. package/dist/components/cms/relation-picker.js +2 -2
  226. package/dist/components/cms/relation-picker.js.map +1 -1
  227. package/dist/components/cms/rich-text/block-style.js +1 -1
  228. package/dist/components/cms/rich-text/block-style.js.map +1 -1
  229. package/dist/components/cms/rich-text/component-embed.js +4 -4
  230. package/dist/components/cms/rich-text/component-embed.js.map +1 -1
  231. package/dist/components/cms/rich-text/editor.js +3 -3
  232. package/dist/components/cms/rich-text/editor.js.map +1 -1
  233. package/dist/components/cms/rich-text/embed-picker.js +3 -3
  234. package/dist/components/cms/rich-text/embed-picker.js.map +1 -1
  235. package/dist/components/cms/rich-text/embed-props.js +3 -3
  236. package/dist/components/cms/rich-text/embed-props.js.map +1 -1
  237. package/dist/components/cms/rich-text/extensions.js +1 -1
  238. package/dist/components/cms/rich-text/extensions.js.map +1 -1
  239. package/dist/components/cms/rich-text/font-size-control.d.ts +1 -1
  240. package/dist/components/cms/rich-text/font-size-control.js +2 -2
  241. package/dist/components/cms/rich-text/font-size-control.js.map +1 -1
  242. package/dist/components/cms/rich-text/lazy.js +1 -1
  243. package/dist/components/cms/rich-text/lazy.js.map +1 -1
  244. package/dist/components/cms/rich-text/link-control.js +2 -2
  245. package/dist/components/cms/rich-text/link-control.js.map +1 -1
  246. package/dist/components/cms/rich-text/slash-command.js +3 -3
  247. package/dist/components/cms/rich-text/slash-command.js.map +1 -1
  248. package/dist/components/cms/rich-text/toolbar.js +1 -1
  249. package/dist/components/cms/rich-text/toolbar.js.map +1 -1
  250. package/dist/components/cms/rich-text/unknown-node.js +2 -2
  251. package/dist/components/cms/rich-text/unknown-node.js.map +1 -1
  252. package/dist/components/cms/rich-text-preview.js +2 -2
  253. package/dist/components/cms/rich-text-preview.js.map +1 -1
  254. package/dist/components/cms/row-actions.d.ts +1 -1
  255. package/dist/components/cms/row-actions.js.map +1 -1
  256. package/dist/components/cms/scalar-value-editor.d.ts +1 -1
  257. package/dist/components/cms/scalar-value-editor.js +2 -2
  258. package/dist/components/cms/scalar-value-editor.js.map +1 -1
  259. package/dist/components/cms/use-discard-controller.d.ts +1 -1
  260. package/dist/components/cms/use-discard-controller.js +1 -1
  261. package/dist/components/cms/use-discard-controller.js.map +1 -1
  262. package/dist/components/cms/use-document-draft.d.ts +7 -1
  263. package/dist/components/cms/use-document-draft.js +16 -2
  264. package/dist/components/cms/use-document-draft.js.map +1 -1
  265. package/dist/components/cms/use-document-versions.js +1 -1
  266. package/dist/components/cms/use-document-versions.js.map +1 -1
  267. package/dist/components/cms/use-field-focus.d.ts +1 -1
  268. package/dist/components/cms/use-field-focus.js +2 -2
  269. package/dist/components/cms/use-field-focus.js.map +1 -1
  270. package/dist/components/cms/use-live-url.d.ts +1 -1
  271. package/dist/components/cms/use-live-url.js +3 -3
  272. package/dist/components/cms/use-live-url.js.map +1 -1
  273. package/dist/components/cms/use-publish-controller.d.ts +1 -1
  274. package/dist/components/cms/use-publish-controller.js +1 -1
  275. package/dist/components/cms/use-publish-controller.js.map +1 -1
  276. package/dist/components/cms/use-published-perspective.d.ts +1 -1
  277. package/dist/components/cms/use-published-perspective.js.map +1 -1
  278. package/dist/components/cms/use-restore-version.d.ts +1 -1
  279. package/dist/components/cms/use-restore-version.js +1 -1
  280. package/dist/components/cms/use-restore-version.js.map +1 -1
  281. package/dist/components/cms/version-compare-lazy.js +1 -1
  282. package/dist/components/cms/version-compare-lazy.js.map +1 -1
  283. package/dist/components/cms/version-compare.js +1 -1
  284. package/dist/components/cms/version-compare.js.map +1 -1
  285. package/dist/components/cms/versions-pane.js +3 -3
  286. package/dist/components/cms/versions-pane.js.map +1 -1
  287. package/dist/components/cms/view-bar.js +3 -3
  288. package/dist/components/cms/view-bar.js.map +1 -1
  289. package/dist/components/collection-view/cms-collection-view-source.d.ts +1 -1
  290. package/dist/components/collection-view/cms-collection-view-source.js +2 -2
  291. package/dist/components/collection-view/cms-collection-view-source.js.map +1 -1
  292. package/dist/components/collection-view/collection-view-context.d.ts +1 -1
  293. package/dist/components/collection-view/collection-view-context.js +1 -1
  294. package/dist/components/collection-view/collection-view-context.js.map +1 -1
  295. package/dist/components/collection-view/collection-view-surface.d.ts +13 -0
  296. package/dist/components/collection-view/collection-view-surface.js +18 -0
  297. package/dist/components/collection-view/collection-view-surface.js.map +1 -0
  298. package/dist/components/components/component-detail.js +10 -10
  299. package/dist/components/components/component-detail.js.map +1 -1
  300. package/dist/components/components/component-preview.d.ts +2 -2
  301. package/dist/components/components/component-preview.js +5 -5
  302. package/dist/components/components/component-preview.js.map +1 -1
  303. package/dist/components/components/component-status.d.ts +1 -1
  304. package/dist/components/components/component-status.js +1 -1
  305. package/dist/components/components/component-status.js.map +1 -1
  306. package/dist/components/components/components-index.js +2 -2
  307. package/dist/components/components/components-index.js.map +1 -1
  308. package/dist/components/components/field-inspector.js +1 -1
  309. package/dist/components/components/field-inspector.js.map +1 -1
  310. package/dist/components/components/registry-browser.js +3 -3
  311. package/dist/components/components/registry-browser.js.map +1 -1
  312. package/dist/components/components/taxonomy.d.ts +1 -1
  313. package/dist/components/components/taxonomy.js.map +1 -1
  314. package/dist/components/components/transfer-dialog.js +3 -3
  315. package/dist/components/components/transfer-dialog.js.map +1 -1
  316. package/dist/components/current-user-menu.js +1 -1
  317. package/dist/components/current-user-menu.js.map +1 -1
  318. package/dist/components/delivery-health-banner.js +2 -2
  319. package/dist/components/delivery-health-banner.js.map +1 -1
  320. package/dist/components/deployment-setup-gate.js +3 -3
  321. package/dist/components/deployment-setup-gate.js.map +1 -1
  322. package/dist/components/dev-login-badge.js +2 -2
  323. package/dist/components/dev-login-badge.js.map +1 -1
  324. package/dist/components/guards.js +1 -1
  325. package/dist/components/guards.js.map +1 -1
  326. package/dist/components/inspector/document-panes.d.ts +54 -0
  327. package/dist/components/inspector/document-panes.js +41 -0
  328. package/dist/components/inspector/document-panes.js.map +1 -0
  329. package/dist/components/inspector/inspector-sidebar.js +1 -1
  330. package/dist/components/inspector/inspector-sidebar.js.map +1 -1
  331. package/dist/components/nav-issues-registry.d.ts +53 -0
  332. package/dist/components/nav-issues-registry.js +69 -0
  333. package/dist/components/nav-issues-registry.js.map +1 -0
  334. package/dist/components/nav-issues.js +4 -4
  335. package/dist/components/nav-issues.js.map +1 -1
  336. package/dist/components/operation-error.d.ts +1 -1
  337. package/dist/components/operation-error.js +4 -4
  338. package/dist/components/operation-error.js.map +1 -1
  339. package/dist/components/playground-badge.js +2 -2
  340. package/dist/components/playground-badge.js.map +1 -1
  341. package/dist/components/project-list.js +3 -3
  342. package/dist/components/project-list.js.map +1 -1
  343. package/dist/components/project-session.d.ts +2 -2
  344. package/dist/components/project-session.js +5 -5
  345. package/dist/components/project-session.js.map +1 -1
  346. package/dist/components/project-switcher.js +2 -2
  347. package/dist/components/project-switcher.js.map +1 -1
  348. package/dist/components/rail-store-status.js +1 -1
  349. package/dist/components/rail-store-status.js.map +1 -1
  350. package/dist/components/rail-view-source.d.ts +6 -5
  351. package/dist/components/rail-view-source.js +4 -3
  352. package/dist/components/rail-view-source.js.map +1 -1
  353. package/dist/components/records/record-lens.d.ts +51 -0
  354. package/dist/components/records/record-lens.js +156 -0
  355. package/dist/components/records/record-lens.js.map +1 -0
  356. package/dist/components/records/record-rail.d.ts +86 -0
  357. package/dist/components/records/record-rail.js +241 -0
  358. package/dist/components/records/record-rail.js.map +1 -0
  359. package/dist/components/redirects/redirects-schema.js +1 -1
  360. package/dist/components/redirects/redirects-schema.js.map +1 -1
  361. package/dist/components/references/references-panel.js +2 -2
  362. package/dist/components/references/references-panel.js.map +1 -1
  363. package/dist/components/section-nav.js +27 -11
  364. package/dist/components/section-nav.js.map +1 -1
  365. package/dist/components/section-state.js +2 -2
  366. package/dist/components/section-state.js.map +1 -1
  367. package/dist/components/section-surface.js +2 -2
  368. package/dist/components/section-surface.js.map +1 -1
  369. package/dist/components/session-expired-overlay.js +3 -3
  370. package/dist/components/session-expired-overlay.js.map +1 -1
  371. package/dist/components/settings-form.js +1 -1
  372. package/dist/components/settings-form.js.map +1 -1
  373. package/dist/components/sign-in-needed-badge.js +1 -1
  374. package/dist/components/sign-in-needed-badge.js.map +1 -1
  375. package/dist/components/sign-in-view.d.ts +2 -2
  376. package/dist/components/sign-in-view.js +5 -5
  377. package/dist/components/sign-in-view.js.map +1 -1
  378. package/dist/components/studio-context.js +3 -3
  379. package/dist/components/studio-context.js.map +1 -1
  380. package/dist/components/studio-project-screen.js +30 -3
  381. package/dist/components/studio-project-screen.js.map +1 -1
  382. package/dist/components/studio-shell.js +6 -5
  383. package/dist/components/studio-shell.js.map +1 -1
  384. package/dist/components/theme-context.d.ts +1 -1
  385. package/dist/components/theme-context.js +2 -2
  386. package/dist/components/theme-context.js.map +1 -1
  387. package/dist/components/use-hydration-phase.d.ts +1 -1
  388. package/dist/components/use-hydration-phase.js +1 -1
  389. package/dist/components/use-hydration-phase.js.map +1 -1
  390. package/dist/components/users/invite-user-bar.d.ts +27 -0
  391. package/dist/components/users/invite-user-bar.js +25 -9
  392. package/dist/components/users/invite-user-bar.js.map +1 -1
  393. package/dist/components/users/role-policy-drift-issues.d.ts +38 -0
  394. package/dist/components/users/role-policy-drift-issues.js +71 -0
  395. package/dist/components/users/role-policy-drift-issues.js.map +1 -0
  396. package/dist/components/users/users-collection-view-source.d.ts +1 -1
  397. package/dist/components/users/users-collection-view-source.js +4 -2
  398. package/dist/components/users/users-collection-view-source.js.map +1 -1
  399. package/dist/components/users/users-module.js +1 -1
  400. package/dist/components/users/users-module.js.map +1 -1
  401. package/dist/components/users/users-schema.d.ts +10 -1
  402. package/dist/components/users/users-schema.js +45 -25
  403. package/dist/components/users/users-schema.js.map +1 -1
  404. package/dist/components/users/users-store.js +3 -3
  405. package/dist/components/users/users-store.js.map +1 -1
  406. package/dist/components/workspace-projects.d.ts +1 -1
  407. package/dist/components/workspace-projects.js +1 -1
  408. package/dist/components/workspace-projects.js.map +1 -1
  409. package/dist/lib/ai/index.d.ts +1 -1
  410. package/dist/lib/ai/index.js +1 -1
  411. package/dist/lib/ai/index.js.map +1 -1
  412. package/dist/lib/ai/node-handler.d.ts +1 -1
  413. package/dist/lib/ai/node-handler.js.map +1 -1
  414. package/dist/lib/ai/translate-document.js +1 -1
  415. package/dist/lib/ai/translate-document.js.map +1 -1
  416. package/dist/lib/clipboard/paste-issues.js +1 -1
  417. package/dist/lib/clipboard/paste-issues.js.map +1 -1
  418. package/dist/lib/clipboard/paste-target.js +2 -2
  419. package/dist/lib/clipboard/paste-target.js.map +1 -1
  420. package/dist/lib/cms/published-documents.js +1 -1
  421. package/dist/lib/cms/published-documents.js.map +1 -1
  422. package/dist/lib/cms-views/view-model.d.ts +12 -12
  423. package/dist/lib/cms-views/view-model.js +2 -2
  424. package/dist/lib/cms-views/view-model.js.map +1 -1
  425. package/dist/lib/collection-view/collection-view-source.d.ts +7 -2
  426. package/dist/lib/collection-view/collection-view-source.js.map +1 -1
  427. package/dist/lib/data/content-session-refresh.d.ts +1 -1
  428. package/dist/lib/data/content-session-refresh.js.map +1 -1
  429. package/dist/lib/data/playground-unload-guard.d.ts +1 -1
  430. package/dist/lib/data/playground-unload-guard.js +1 -1
  431. package/dist/lib/data/playground-unload-guard.js.map +1 -1
  432. package/dist/lib/engine-version.d.ts +1 -1
  433. package/dist/lib/engine-version.js +1 -1
  434. package/dist/lib/engine-version.js.map +1 -1
  435. package/dist/lib/i18n/i18n.js +1 -1
  436. package/dist/lib/i18n/i18n.js.map +1 -1
  437. package/dist/lib/i18n/messages.de.js +4 -0
  438. package/dist/lib/i18n/messages.de.js.map +1 -1
  439. package/dist/lib/i18n/messages.en.d.ts +4 -0
  440. package/dist/lib/i18n/messages.en.js +8 -0
  441. package/dist/lib/i18n/messages.en.js.map +1 -1
  442. package/dist/lib/operations/project-runtime-config.d.ts +9 -0
  443. package/dist/lib/operations/project-runtime-config.js +13 -0
  444. package/dist/lib/operations/project-runtime-config.js.map +1 -1
  445. package/dist/lib/operations/studio-operations.d.ts +9 -1
  446. package/dist/lib/operations/studio-operations.js +6 -1
  447. package/dist/lib/operations/studio-operations.js.map +1 -1
  448. package/dist/lib/persistence/convex-adapter.d.ts +16 -3
  449. package/dist/lib/persistence/convex-adapter.js +78 -47
  450. package/dist/lib/persistence/convex-adapter.js.map +1 -1
  451. package/dist/lib/persistence/index.js +14 -1
  452. package/dist/lib/persistence/index.js.map +1 -1
  453. package/dist/lib/persona/labels.js +1 -1
  454. package/dist/lib/persona/labels.js.map +1 -1
  455. package/dist/lib/query/operations-query.d.ts +1 -1
  456. package/dist/lib/query/operations-query.js +1 -1
  457. package/dist/lib/query/operations-query.js.map +1 -1
  458. package/dist/lib/references/reference-model.js +1 -1
  459. package/dist/lib/references/reference-model.js.map +1 -1
  460. package/dist/lib/references/references-store.js +1 -1
  461. package/dist/lib/references/references-store.js.map +1 -1
  462. package/dist/lib/workspace/index.d.ts +6 -0
  463. package/dist/lib/workspace/index.js +8 -0
  464. package/dist/lib/workspace/index.js.map +1 -1
  465. package/dist/mount.d.ts +28 -0
  466. package/dist/mount.js +27 -0
  467. package/dist/mount.js.map +1 -0
  468. package/dist/router/root.js +10 -10
  469. package/dist/router/root.js.map +1 -1
  470. package/dist/ui/badge.d.ts +1 -1
  471. package/dist/ui/button.d.ts +2 -2
  472. package/package.json +15 -11
  473. package/dist/components/redirects/redirects-collection-view-source.d.ts +0 -53
  474. package/dist/components/redirects/redirects-collection-view-source.js +0 -146
  475. package/dist/components/redirects/redirects-collection-view-source.js.map +0 -1
  476. package/dist/components/redirects/redirects-module.d.ts +0 -21
  477. package/dist/components/redirects/redirects-module.js +0 -40
  478. package/dist/components/redirects/redirects-module.js.map +0 -1
  479. package/dist/components/redirects/redirects-store.d.ts +0 -68
  480. package/dist/components/redirects/redirects-store.js +0 -132
  481. package/dist/components/redirects/redirects-store.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ai-cms-panel.js","sourceRoot":"","sources":["../../../src/components/ai/ai-cms-panel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,IAAI,GAAG,cAAc,EAAE,CAAA;IAC7B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE;QAC9B,MAAM,EAAE,GAAG,mBAAmB,EAAE,CAAA;QAChC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,OAAO,KAAK,KAAK,CAAA;IACrC,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IACrC,OAAO,KAAC,WAAW,KAAG,CAAA;AACxB,CAAC","sourcesContent":["import { useMemo } from 'react'\nimport { resolveDeploymentAi } from '@elytracms/studio/lib/workspace'\nimport { useAiPanelOpen } from '@elytracms/studio/lib/ai-panel'\nimport { AiChatPanel } from './ai-chat-panel-lazy'\n\n/**\n * The CMS-area mount of the AI assistant (EC-199): a right-hand sibling of the CMS\n * content, shown on BOTH the collection list and the document editor. Gated twice —\n * the studio must be `ai`-configured (EC-331 presence-enable) AND the panel open — so\n * the lazy `AiChatPanel` chunk is requested only when a configured studio actually\n * opens it. Sits inside `CmsProvider`, so the panel reads the live CMS store\n * (collections, active locale) for its tools and applies drafts through it.\n */\nexport function AiCmsPanel() {\n const open = useAiPanelOpen()\n const configured = useMemo(() => {\n const ai = resolveDeploymentAi()\n return !!ai && ai.enabled !== false\n }, [])\n if (!configured || !open) return null\n return <AiChatPanel />\n}\n"]}
1
+ {"version":3,"file":"ai-cms-panel.js","sourceRoot":"","sources":["../../../src/components/ai/ai-cms-panel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,IAAI,GAAG,cAAc,EAAE,CAAA;IAC7B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE;QAC9B,MAAM,EAAE,GAAG,mBAAmB,EAAE,CAAA;QAChC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,OAAO,KAAK,KAAK,CAAA;IACrC,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IACrC,OAAO,KAAC,WAAW,KAAG,CAAA;AACxB,CAAC","sourcesContent":["import { useMemo } from 'react'\nimport { resolveDeploymentAi } from '../../lib/workspace'\nimport { useAiPanelOpen } from '../../lib/ai-panel'\nimport { AiChatPanel } from './ai-chat-panel-lazy'\n\n/**\n * The CMS-area mount of the AI assistant (EC-199): a right-hand sibling of the CMS\n * content, shown on BOTH the collection list and the document editor. Gated twice —\n * the studio must be `ai`-configured (EC-331 presence-enable) AND the panel open — so\n * the lazy `AiChatPanel` chunk is requested only when a configured studio actually\n * opens it. Sits inside `CmsProvider`, so the panel reads the live CMS store\n * (collections, active locale) for its tools and applies drafts through it.\n */\nexport function AiCmsPanel() {\n const open = useAiPanelOpen()\n const configured = useMemo(() => {\n const ai = resolveDeploymentAi()\n return !!ai && ai.enabled !== false\n }, [])\n if (!configured || !open) return null\n return <AiChatPanel />\n}\n"]}
@@ -2,10 +2,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useMemo } from 'react';
3
3
  import { Sparkles } from 'lucide-react';
4
4
  import { Button } from '@elytracms/studio/ui';
5
- import { translate } from '@elytracms/studio/lib/i18n';
6
- import { cn } from '@elytracms/studio/lib/utils';
7
- import { resolveDeploymentAi } from '@elytracms/studio/lib/workspace';
8
- import { toggleAiPanel, useAiPanelOpen } from '@elytracms/studio/lib/ai-panel';
5
+ import { translate } from '../../lib/i18n/index.js';
6
+ import { cn } from '../../lib/utils.js';
7
+ import { resolveDeploymentAi } from '../../lib/workspace/index.js';
8
+ import { toggleAiPanel, useAiPanelOpen } from '../../lib/ai-panel.js';
9
9
  /**
10
10
  * The workspace-header toggle for the AI assistant (EC-199). Renders ONLY when the
11
11
  * studio config carries an `ai` block that is not kill-switched (`enabled: false`) —
@@ -1 +1 @@
1
- {"version":3,"file":"ai-panel-toggle.js","sourceRoot":"","sources":["../../../src/components/ai/ai-panel-toggle.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,EAAE,EAAE,MAAM,6BAA6B,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAE9E;;;;;;GAMG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,IAAI,GAAG,cAAc,EAAE,CAAA;IAC7B,iFAAiF;IACjF,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE;QAC9B,MAAM,EAAE,GAAG,mBAAmB,EAAE,CAAA;QAChC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,OAAO,KAAK,KAAK,CAAA;IACrC,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAA;IAC5B,OAAO,CACL,KAAC,MAAM,IACL,IAAI,EAAC,SAAS,EACd,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,kBACrB,IAAI,EAClB,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,gBACvB,SAAS,CAAC,iBAAiB,CAAC,EACxC,SAAS,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,uBAAuB,CAAC,YAE/C,KAAC,QAAQ,KAAG,GACL,CACV,CAAA;AACH,CAAC","sourcesContent":["import { useMemo } from 'react'\nimport { Sparkles } from 'lucide-react'\nimport { Button } from '@elytracms/studio/ui'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { cn } from '@elytracms/studio/lib/utils'\nimport { resolveDeploymentAi } from '@elytracms/studio/lib/workspace'\nimport { toggleAiPanel, useAiPanelOpen } from '@elytracms/studio/lib/ai-panel'\n\n/**\n * The workspace-header toggle for the AI assistant (EC-199). Renders ONLY when the\n * studio config carries an `ai` block that is not kill-switched (`enabled: false`) —\n * the EC-331 presence-enable, checked here without touching the AI runtime (it reads\n * only the config object; the heavy panel stays behind its own lazy boundary). When\n * `ai` is absent, no toggle renders and no AI chunk is ever requested.\n */\nexport function AiPanelToggle() {\n const open = useAiPanelOpen()\n // Config is seeded at `createStudio` before mount, so a one-shot read is stable.\n const configured = useMemo(() => {\n const ai = resolveDeploymentAi()\n return !!ai && ai.enabled !== false\n }, [])\n if (!configured) return null\n return (\n <Button\n size=\"icon-sm\"\n variant={open ? 'default' : 'ghost'}\n aria-pressed={open}\n onClick={toggleAiPanel}\n title={translate('ai.panel.toggle')}\n aria-label={translate('ai.panel.toggle')}\n className={cn(!open && 'text-muted-foreground')}\n >\n <Sparkles />\n </Button>\n )\n}\n"]}
1
+ {"version":3,"file":"ai-panel-toggle.js","sourceRoot":"","sources":["../../../src/components/ai/ai-panel-toggle.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAElE;;;;;;GAMG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,IAAI,GAAG,cAAc,EAAE,CAAA;IAC7B,iFAAiF;IACjF,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE;QAC9B,MAAM,EAAE,GAAG,mBAAmB,EAAE,CAAA;QAChC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,OAAO,KAAK,KAAK,CAAA;IACrC,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAA;IAC5B,OAAO,CACL,KAAC,MAAM,IACL,IAAI,EAAC,SAAS,EACd,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,kBACrB,IAAI,EAClB,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,SAAS,CAAC,iBAAiB,CAAC,gBACvB,SAAS,CAAC,iBAAiB,CAAC,EACxC,SAAS,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,uBAAuB,CAAC,YAE/C,KAAC,QAAQ,KAAG,GACL,CACV,CAAA;AACH,CAAC","sourcesContent":["import { useMemo } from 'react'\nimport { Sparkles } from 'lucide-react'\nimport { Button } from '@elytracms/studio/ui'\nimport { translate } from '../../lib/i18n'\nimport { cn } from '../../lib/utils'\nimport { resolveDeploymentAi } from '../../lib/workspace'\nimport { toggleAiPanel, useAiPanelOpen } from '../../lib/ai-panel'\n\n/**\n * The workspace-header toggle for the AI assistant (EC-199). Renders ONLY when the\n * studio config carries an `ai` block that is not kill-switched (`enabled: false`) —\n * the EC-331 presence-enable, checked here without touching the AI runtime (it reads\n * only the config object; the heavy panel stays behind its own lazy boundary). When\n * `ai` is absent, no toggle renders and no AI chunk is ever requested.\n */\nexport function AiPanelToggle() {\n const open = useAiPanelOpen()\n // Config is seeded at `createStudio` before mount, so a one-shot read is stable.\n const configured = useMemo(() => {\n const ai = resolveDeploymentAi()\n return !!ai && ai.enabled !== false\n }, [])\n if (!configured) return null\n return (\n <Button\n size=\"icon-sm\"\n variant={open ? 'default' : 'ghost'}\n aria-pressed={open}\n onClick={toggleAiPanel}\n title={translate('ai.panel.toggle')}\n aria-label={translate('ai.panel.toggle')}\n className={cn(!open && 'text-muted-foreground')}\n >\n <Sparkles />\n </Button>\n )\n}\n"]}
@@ -2,8 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useRef } from 'react';
3
3
  import { FileText, Images, Languages, PencilLine, Search, Sparkles, TriangleAlert } from 'lucide-react';
4
4
  import { Button, Row, Stack, Text } from '@elytracms/studio/ui';
5
- import { translate } from '@elytracms/studio/lib/i18n';
6
- import { cn } from '@elytracms/studio/lib/utils';
5
+ import { translate } from '../../lib/i18n/index.js';
6
+ import { cn } from '../../lib/utils.js';
7
7
  /** The terminal tools whose `output-available` part is a reviewable proposal. */
8
8
  const TERMINAL_TOOLS = new Set(['createDocument', 'translateDocument', 'updateFields']);
9
9
  /** The tool name behind a tool part's `type` (`tool-<name>` / `dynamic-tool`). */
@@ -1 +1 @@
1
- {"version":3,"file":"chat-ui.js","sourceRoot":"","sources":["../../../src/components/ai/chat-ui.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,cAAc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AI,EACT,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAC/C,KAAK,EAAE,SAAS,CAAC,eAAe,CAAC,gBACrB,SAAS,CAAC,eAAe,CAAC,YAErC,SAAS,CAAC,eAAe,CAAC,GACpB,IACL,GACF,CACP,CAAA;AACH,CAAC","sourcesContent":["import { useCallback, useEffect, useRef } from 'react'\nimport type { KeyboardEvent, ReactNode } from 'react'\nimport { FileText, Images, Languages, PencilLine, Search, Sparkles, TriangleAlert } from 'lucide-react'\n// Type-only (erased at compile; `verbatimModuleSyntax`): the UIMessage part shapes.\nimport type { UIMessage } from 'ai'\nimport { Button, Row, Stack, Text } from '@elytracms/studio/ui'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { cn } from '@elytracms/studio/lib/utils'\n\n/**\n * AI-Elements-style chat primitives (EC-199, reworked for EC-334), vendored as\n * local shadcn-style components (named, Tailwind-token) rather than a package\n * dependency. The conversation now renders the AI SDK's UIMessages directly:\n * streaming text parts grow token-by-token, tool parts render as the ToolStatus\n * affordance (`input-streaming → input-available → output-available`), and the\n * terminal tools' parts render as `ProposalCard` (the panel wires that — this\n * module stays purely presentational; pure part-mapping cores are exported for\n * direct node tests, house pattern).\n */\n\n// --- UIMessage part mapping (pure cores) --------------------------------------------\n\n/** One UIMessage part, viewed structurally (the fields the chat surface reads). */\nexport interface MessagePartView {\n type: string\n text?: string\n toolCallId?: string\n state?: string\n input?: unknown\n output?: unknown\n errorText?: string\n}\n\n/** The terminal tools whose `output-available` part is a reviewable proposal. */\nconst TERMINAL_TOOLS = new Set(['createDocument', 'translateDocument', 'updateFields'])\n\n/** The tool name behind a tool part's `type` (`tool-<name>` / `dynamic-tool`). */\nexport function toolPartName(part: MessagePartView): string | null {\n if (part.type === 'dynamic-tool') {\n return typeof (part as { toolName?: unknown }).toolName === 'string'\n ? ((part as { toolName?: string }).toolName ?? null)\n : null\n }\n return part.type.startsWith('tool-') ? part.type.slice('tool-'.length) : null\n}\n\n/** A rendered segment of one assistant message. */\nexport type MessageSegment =\n | { kind: 'text'; text: string }\n | { kind: 'tools'; parts: MessagePartView[] }\n | { kind: 'proposal'; toolCallId: string }\n\n/**\n * Fold an assistant UIMessage's parts into render segments: consecutive tool\n * parts group into ONE ToolStatus block (the EC-199 affordance), a terminal\n * tool part with a registered proposal becomes a `proposal` segment, and text\n * parts pass through (empty ones dropped). Pure — tested directly.\n */\nexport function segmentMessageParts(\n parts: readonly MessagePartView[],\n hasProposal: (toolCallId: string) => boolean,\n): MessageSegment[] {\n const segments: MessageSegment[] = []\n for (const part of parts) {\n if (part.type === 'text') {\n const text = part.text ?? ''\n if (text.length > 0) segments.push({ kind: 'text', text })\n continue\n }\n const tool = toolPartName(part)\n if (tool === null) continue // step-start / reasoning / data-* — not rendered\n if (\n TERMINAL_TOOLS.has(tool) &&\n part.toolCallId !== undefined &&\n part.state === 'output-available' &&\n hasProposal(part.toolCallId)\n ) {\n segments.push({ kind: 'proposal', toolCallId: part.toolCallId })\n continue\n }\n const last = segments.at(-1)\n if (last?.kind === 'tools') last.parts.push(part)\n else segments.push({ kind: 'tools', parts: [part] })\n }\n return segments\n}\n\n/** One presentational tool-status line. */\nexport interface ChatToolStep {\n icon: 'search' | 'assets' | 'document' | 'draft' | 'translate' | 'edit'\n label: string\n /** Still running (no output yet) — renders the pulse affordance. */\n running: boolean\n}\n\nfunction inputField(part: MessagePartView, field: string): string | undefined {\n const input = part.input\n if (typeof input !== 'object' || input === null) return undefined\n const value = (input as Record<string, unknown>)[field]\n return typeof value === 'string' ? value : undefined\n}\n\n/**\n * Map one tool part onto its status line (`input-streaming → input-available →\n * output-available | output-error`). Pure — tested directly.\n */\nexport function describeToolPart(part: MessagePartView): ChatToolStep {\n const tool = toolPartName(part) ?? 'tool'\n const running = part.state === 'input-streaming' || part.state === 'input-available'\n const failed = part.state === 'output-error'\n if (failed) {\n return {\n icon: 'draft',\n label: part.errorText ?? translate('ai.error.generic'),\n running: false,\n }\n }\n switch (tool) {\n case 'searchDocuments': {\n const collection = inputField(part, 'collection') ?? '…'\n if (running) return { icon: 'search', label: translate('ai.step.searchRunning', { collection }), running }\n const count = Array.isArray(part.output) ? part.output.length : 0\n return { icon: 'search', label: translate('ai.step.search', { collection, count }), running }\n }\n case 'listAssets': {\n if (running) return { icon: 'assets', label: translate('ai.step.listAssetsRunning'), running }\n const count = Array.isArray(part.output) ? part.output.length : 0\n return { icon: 'assets', label: translate('ai.step.listAssets', { count }), running }\n }\n case 'getDocument':\n return {\n icon: 'document',\n label: running\n ? translate('ai.step.getDocumentRunning')\n : translate('ai.step.getDocument'),\n running,\n }\n case 'createDocument':\n return {\n icon: 'draft',\n label: translate('ai.step.drafting', { collection: inputField(part, 'collection') ?? '…' }),\n running,\n }\n case 'translateDocument': {\n const output = part.output as { status?: unknown } | undefined\n if (!running && output?.status === 'nothing-to-translate') {\n return { icon: 'translate', label: translate('ai.step.translateNothing'), running: false }\n }\n return { icon: 'translate', label: translate('ai.step.translatingDoc'), running }\n }\n case 'updateFields': {\n const output = part.output as { status?: unknown } | undefined\n if (!running && output?.status === 'no-change') {\n return { icon: 'edit', label: translate('ai.step.updateNoChange'), running: false }\n }\n return { icon: 'edit', label: translate('ai.step.updatingDoc'), running }\n }\n default:\n return { icon: 'draft', label: tool, running }\n }\n}\n\n/** Join a UIMessage's text parts (the user-turn renderer). */\nexport function messageText(message: Pick<UIMessage, 'parts'>): string {\n return (message.parts as MessagePartView[])\n .filter((part) => part.type === 'text')\n .map((part) => part.text ?? '')\n .join('\\n')\n}\n\n// --- Presentational components -------------------------------------------------------\n\n/** The scrolling conversation column; auto-scrolls to the newest turn. */\nexport function Conversation({ children, atBottomKey }: { children: ReactNode; atBottomKey: unknown }) {\n const ref = useRef<HTMLDivElement>(null)\n useEffect(() => {\n const el = ref.current\n if (el) el.scrollTop = el.scrollHeight\n }, [atBottomKey])\n return (\n <div ref={ref} className=\"min-h-0 flex-1 overflow-auto\">\n <Stack gap=\"3\" className=\"p-3\">\n {children}\n </Stack>\n </div>\n )\n}\n\n/** A user turn — a right-aligned bubble. */\nexport function UserTurn({ text }: { text: string }) {\n return (\n <Row justify=\"end\">\n <div className=\"max-w-[85%] rounded-2xl rounded-br-sm bg-primary px-3 py-2 text-primary-foreground\">\n <Text size=\"sm\" className=\"whitespace-pre-wrap break-words text-primary-foreground\">\n {text}\n </Text>\n </div>\n </Row>\n )\n}\n\n/** An assistant text turn — a left-aligned calm block. */\nexport function AssistantTurn({ children }: { children: ReactNode }) {\n return (\n <Row justify=\"start\" align=\"start\" gap=\"2\">\n <div className=\"mt-0.5 grid size-6 shrink-0 place-items-center rounded-full bg-muted text-muted-foreground\">\n <Sparkles className=\"size-3.5\" />\n </div>\n <div className=\"min-w-0 flex-1\">{children}</div>\n </Row>\n )\n}\n\n/** The empty-state prompt shown before the first message. */\nexport function ConversationEmpty() {\n return (\n <Stack gap=\"2\" align=\"center\" className=\"px-4 py-10 text-center\">\n <div className=\"grid size-10 place-items-center rounded-full bg-muted text-muted-foreground\">\n <Sparkles className=\"size-5\" />\n </div>\n <Text size=\"sm\" weight=\"medium\">\n {translate('ai.panel.emptyTitle')}\n </Text>\n <Text size=\"xs\" tone=\"muted\" className=\"max-w-[24rem]\">\n {translate('ai.panel.emptyHint')}\n </Text>\n </Stack>\n )\n}\n\n/** The tool-status affordance — the tool steps of one segment, as calm status lines. */\nexport function ToolStatus({ steps }: { steps: ChatToolStep[] }) {\n if (steps.length === 0) return null\n return (\n <Stack gap=\"1\" className=\"rounded-lg border border-border/60 bg-muted/30 px-2.5 py-2\">\n {steps.map((step, i) => (\n <Row key={i} gap=\"2\" align=\"center\">\n <StepIcon icon={step.icon} />\n <Text size=\"xs\" tone=\"muted\">\n {step.label}\n </Text>\n {step.running ? (\n <span\n className=\"inline-block size-1.5 animate-pulse rounded-full bg-muted-foreground\"\n aria-hidden\n />\n ) : null}\n </Row>\n ))}\n </Stack>\n )\n}\n\n/** The busy indicator shown while the route request is in flight (pre-stream). */\nexport function WorkingIndicator() {\n return (\n <Row gap=\"2\" align=\"center\">\n <span className=\"inline-block size-1.5 animate-pulse rounded-full bg-muted-foreground\" aria-hidden />\n <Text size=\"xs\" tone=\"muted\">\n {translate('ai.panel.working')}\n </Text>\n </Row>\n )\n}\n\n/** A blocking-error note (route/provider failure, step cap) — visible, never silent. */\nexport function ChatErrorNote({ message }: { message: string }) {\n return (\n <Row gap=\"2\" align=\"start\" className=\"rounded-lg border border-destructive/30 bg-destructive/5 px-2.5 py-2\">\n <TriangleAlert className=\"mt-0.5 size-3.5 shrink-0 text-destructive\" />\n <Text size=\"xs\" className=\"text-destructive\">\n {message}\n </Text>\n </Row>\n )\n}\n\nfunction StepIcon({ icon }: { icon: ChatToolStep['icon'] }) {\n const className = 'size-3.5 shrink-0 text-muted-foreground'\n if (icon === 'search') return <Search className={className} />\n if (icon === 'assets') return <Images className={className} />\n if (icon === 'translate') return <Languages className={className} />\n if (icon === 'edit') return <PencilLine className={className} />\n if (icon === 'document') return <FileText className={className} />\n return <FileText className={className} />\n}\n\n/** The prompt input — a growing textarea + send button; Enter sends, Shift+Enter newline. */\nexport function PromptInput({\n value,\n onChange,\n onSubmit,\n disabled,\n}: {\n value: string\n onChange: (value: string) => void\n onSubmit: () => void\n disabled: boolean\n}) {\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault()\n if (!disabled && value.trim().length > 0) onSubmit()\n }\n },\n [disabled, value, onSubmit],\n )\n return (\n <div className=\"border-t border-border p-2.5\">\n <div\n className={cn(\n 'flex items-end gap-2 rounded-xl border border-border bg-background px-2.5 py-2',\n 'focus-within:border-primary/60',\n )}\n >\n <textarea\n value={value}\n onChange={(event) => onChange(event.target.value)}\n onKeyDown={handleKeyDown}\n rows={1}\n placeholder={translate('ai.panel.placeholder')}\n aria-label={translate('ai.panel.placeholder')}\n className=\"max-h-40 min-h-[1.5rem] flex-1 resize-none bg-transparent text-sm outline-none placeholder:text-muted-foreground\"\n />\n <Button\n size=\"sm\"\n onClick={onSubmit}\n disabled={disabled || value.trim().length === 0}\n title={translate('ai.panel.send')}\n aria-label={translate('ai.panel.send')}\n >\n {translate('ai.panel.send')}\n </Button>\n </div>\n </div>\n )\n}\n"]}
1
+ {"version":3,"file":"chat-ui.js","sourceRoot":"","sources":["../../../src/components/ai/chat-ui.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGvG,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AA0BpC,iFAAiF;AACjF,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE,mBAAmB,EAAE,cAAc,CAAC,CAAC,CAAA;AAEvF,kFAAkF;AAClF,MAAM,UAAU,YAAY,CAAC,IAAqB;IAChD,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;QACjC,OAAO,OAAQ,IAA+B,CAAC,QAAQ,KAAK,QAAQ;YAClE,CAAC,CAAC,CAAE,IAA8B,CAAC,QAAQ,IAAI,IAAI,CAAC;YACpD,CAAC,CAAC,IAAI,CAAA;IACV,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,I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AAC,EACD,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAC5B,CAAA;IACD,OAAO,CACL,cAAK,SAAS,EAAC,8BAA8B,YAC3C,eACE,SAAS,EAAE,EAAE,CACX,gFAAgF,EAChF,gCAAgC,CACjC,aAED,mBACE,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EACjD,SAAS,EAAE,aAAa,EACxB,IAAI,EAAE,CAAC,EACP,WAAW,EAAE,SAAS,CAAC,sBAAsB,CAAC,gBAClC,SAAS,CAAC,sBAAsB,CAAC,EAC7C,SAAS,EAAC,kHAAkH,GAC5H,EACF,KAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAC/C,KAAK,EAAE,SAAS,CAAC,eAAe,CAAC,gBACrB,SAAS,CAAC,eAAe,CAAC,YAErC,SAAS,CAAC,eAAe,CAAC,GACpB,IACL,GACF,CACP,CAAA;AACH,CAAC","sourcesContent":["import { useCallback, useEffect, useRef } from 'react'\nimport type { KeyboardEvent, ReactNode } from 'react'\nimport { FileText, Images, Languages, PencilLine, Search, Sparkles, TriangleAlert } from 'lucide-react'\n// Type-only (erased at compile; `verbatimModuleSyntax`): the UIMessage part shapes.\nimport type { UIMessage } from 'ai'\nimport { Button, Row, Stack, Text } from '@elytracms/studio/ui'\nimport { translate } from '../../lib/i18n'\nimport { cn } from '../../lib/utils'\n\n/**\n * AI-Elements-style chat primitives (EC-199, reworked for EC-334), vendored as\n * local shadcn-style components (named, Tailwind-token) rather than a package\n * dependency. The conversation now renders the AI SDK's UIMessages directly:\n * streaming text parts grow token-by-token, tool parts render as the ToolStatus\n * affordance (`input-streaming → input-available → output-available`), and the\n * terminal tools' parts render as `ProposalCard` (the panel wires that — this\n * module stays purely presentational; pure part-mapping cores are exported for\n * direct node tests, house pattern).\n */\n\n// --- UIMessage part mapping (pure cores) --------------------------------------------\n\n/** One UIMessage part, viewed structurally (the fields the chat surface reads). */\nexport interface MessagePartView {\n type: string\n text?: string\n toolCallId?: string\n state?: string\n input?: unknown\n output?: unknown\n errorText?: string\n}\n\n/** The terminal tools whose `output-available` part is a reviewable proposal. */\nconst TERMINAL_TOOLS = new Set(['createDocument', 'translateDocument', 'updateFields'])\n\n/** The tool name behind a tool part's `type` (`tool-<name>` / `dynamic-tool`). */\nexport function toolPartName(part: MessagePartView): string | null {\n if (part.type === 'dynamic-tool') {\n return typeof (part as { toolName?: unknown }).toolName === 'string'\n ? ((part as { toolName?: string }).toolName ?? null)\n : null\n }\n return part.type.startsWith('tool-') ? part.type.slice('tool-'.length) : null\n}\n\n/** A rendered segment of one assistant message. */\nexport type MessageSegment =\n | { kind: 'text'; text: string }\n | { kind: 'tools'; parts: MessagePartView[] }\n | { kind: 'proposal'; toolCallId: string }\n\n/**\n * Fold an assistant UIMessage's parts into render segments: consecutive tool\n * parts group into ONE ToolStatus block (the EC-199 affordance), a terminal\n * tool part with a registered proposal becomes a `proposal` segment, and text\n * parts pass through (empty ones dropped). Pure — tested directly.\n */\nexport function segmentMessageParts(\n parts: readonly MessagePartView[],\n hasProposal: (toolCallId: string) => boolean,\n): MessageSegment[] {\n const segments: MessageSegment[] = []\n for (const part of parts) {\n if (part.type === 'text') {\n const text = part.text ?? ''\n if (text.length > 0) segments.push({ kind: 'text', text })\n continue\n }\n const tool = toolPartName(part)\n if (tool === null) continue // step-start / reasoning / data-* — not rendered\n if (\n TERMINAL_TOOLS.has(tool) &&\n part.toolCallId !== undefined &&\n part.state === 'output-available' &&\n hasProposal(part.toolCallId)\n ) {\n segments.push({ kind: 'proposal', toolCallId: part.toolCallId })\n continue\n }\n const last = segments.at(-1)\n if (last?.kind === 'tools') last.parts.push(part)\n else segments.push({ kind: 'tools', parts: [part] })\n }\n return segments\n}\n\n/** One presentational tool-status line. */\nexport interface ChatToolStep {\n icon: 'search' | 'assets' | 'document' | 'draft' | 'translate' | 'edit'\n label: string\n /** Still running (no output yet) — renders the pulse affordance. */\n running: boolean\n}\n\nfunction inputField(part: MessagePartView, field: string): string | undefined {\n const input = part.input\n if (typeof input !== 'object' || input === null) return undefined\n const value = (input as Record<string, unknown>)[field]\n return typeof value === 'string' ? value : undefined\n}\n\n/**\n * Map one tool part onto its status line (`input-streaming → input-available →\n * output-available | output-error`). Pure — tested directly.\n */\nexport function describeToolPart(part: MessagePartView): ChatToolStep {\n const tool = toolPartName(part) ?? 'tool'\n const running = part.state === 'input-streaming' || part.state === 'input-available'\n const failed = part.state === 'output-error'\n if (failed) {\n return {\n icon: 'draft',\n label: part.errorText ?? translate('ai.error.generic'),\n running: false,\n }\n }\n switch (tool) {\n case 'searchDocuments': {\n const collection = inputField(part, 'collection') ?? '…'\n if (running) return { icon: 'search', label: translate('ai.step.searchRunning', { collection }), running }\n const count = Array.isArray(part.output) ? part.output.length : 0\n return { icon: 'search', label: translate('ai.step.search', { collection, count }), running }\n }\n case 'listAssets': {\n if (running) return { icon: 'assets', label: translate('ai.step.listAssetsRunning'), running }\n const count = Array.isArray(part.output) ? part.output.length : 0\n return { icon: 'assets', label: translate('ai.step.listAssets', { count }), running }\n }\n case 'getDocument':\n return {\n icon: 'document',\n label: running\n ? translate('ai.step.getDocumentRunning')\n : translate('ai.step.getDocument'),\n running,\n }\n case 'createDocument':\n return {\n icon: 'draft',\n label: translate('ai.step.drafting', { collection: inputField(part, 'collection') ?? '…' }),\n running,\n }\n case 'translateDocument': {\n const output = part.output as { status?: unknown } | undefined\n if (!running && output?.status === 'nothing-to-translate') {\n return { icon: 'translate', label: translate('ai.step.translateNothing'), running: false }\n }\n return { icon: 'translate', label: translate('ai.step.translatingDoc'), running }\n }\n case 'updateFields': {\n const output = part.output as { status?: unknown } | undefined\n if (!running && output?.status === 'no-change') {\n return { icon: 'edit', label: translate('ai.step.updateNoChange'), running: false }\n }\n return { icon: 'edit', label: translate('ai.step.updatingDoc'), running }\n }\n default:\n return { icon: 'draft', label: tool, running }\n }\n}\n\n/** Join a UIMessage's text parts (the user-turn renderer). */\nexport function messageText(message: Pick<UIMessage, 'parts'>): string {\n return (message.parts as MessagePartView[])\n .filter((part) => part.type === 'text')\n .map((part) => part.text ?? '')\n .join('\\n')\n}\n\n// --- Presentational components -------------------------------------------------------\n\n/** The scrolling conversation column; auto-scrolls to the newest turn. */\nexport function Conversation({ children, atBottomKey }: { children: ReactNode; atBottomKey: unknown }) {\n const ref = useRef<HTMLDivElement>(null)\n useEffect(() => {\n const el = ref.current\n if (el) el.scrollTop = el.scrollHeight\n }, [atBottomKey])\n return (\n <div ref={ref} className=\"min-h-0 flex-1 overflow-auto\">\n <Stack gap=\"3\" className=\"p-3\">\n {children}\n </Stack>\n </div>\n )\n}\n\n/** A user turn — a right-aligned bubble. */\nexport function UserTurn({ text }: { text: string }) {\n return (\n <Row justify=\"end\">\n <div className=\"max-w-[85%] rounded-2xl rounded-br-sm bg-primary px-3 py-2 text-primary-foreground\">\n <Text size=\"sm\" className=\"whitespace-pre-wrap break-words text-primary-foreground\">\n {text}\n </Text>\n </div>\n </Row>\n )\n}\n\n/** An assistant text turn — a left-aligned calm block. */\nexport function AssistantTurn({ children }: { children: ReactNode }) {\n return (\n <Row justify=\"start\" align=\"start\" gap=\"2\">\n <div className=\"mt-0.5 grid size-6 shrink-0 place-items-center rounded-full bg-muted text-muted-foreground\">\n <Sparkles className=\"size-3.5\" />\n </div>\n <div className=\"min-w-0 flex-1\">{children}</div>\n </Row>\n )\n}\n\n/** The empty-state prompt shown before the first message. */\nexport function ConversationEmpty() {\n return (\n <Stack gap=\"2\" align=\"center\" className=\"px-4 py-10 text-center\">\n <div className=\"grid size-10 place-items-center rounded-full bg-muted text-muted-foreground\">\n <Sparkles className=\"size-5\" />\n </div>\n <Text size=\"sm\" weight=\"medium\">\n {translate('ai.panel.emptyTitle')}\n </Text>\n <Text size=\"xs\" tone=\"muted\" className=\"max-w-[24rem]\">\n {translate('ai.panel.emptyHint')}\n </Text>\n </Stack>\n )\n}\n\n/** The tool-status affordance — the tool steps of one segment, as calm status lines. */\nexport function ToolStatus({ steps }: { steps: ChatToolStep[] }) {\n if (steps.length === 0) return null\n return (\n <Stack gap=\"1\" className=\"rounded-lg border border-border/60 bg-muted/30 px-2.5 py-2\">\n {steps.map((step, i) => (\n <Row key={i} gap=\"2\" align=\"center\">\n <StepIcon icon={step.icon} />\n <Text size=\"xs\" tone=\"muted\">\n {step.label}\n </Text>\n {step.running ? (\n <span\n className=\"inline-block size-1.5 animate-pulse rounded-full bg-muted-foreground\"\n aria-hidden\n />\n ) : null}\n </Row>\n ))}\n </Stack>\n )\n}\n\n/** The busy indicator shown while the route request is in flight (pre-stream). */\nexport function WorkingIndicator() {\n return (\n <Row gap=\"2\" align=\"center\">\n <span className=\"inline-block size-1.5 animate-pulse rounded-full bg-muted-foreground\" aria-hidden />\n <Text size=\"xs\" tone=\"muted\">\n {translate('ai.panel.working')}\n </Text>\n </Row>\n )\n}\n\n/** A blocking-error note (route/provider failure, step cap) — visible, never silent. */\nexport function ChatErrorNote({ message }: { message: string }) {\n return (\n <Row gap=\"2\" align=\"start\" className=\"rounded-lg border border-destructive/30 bg-destructive/5 px-2.5 py-2\">\n <TriangleAlert className=\"mt-0.5 size-3.5 shrink-0 text-destructive\" />\n <Text size=\"xs\" className=\"text-destructive\">\n {message}\n </Text>\n </Row>\n )\n}\n\nfunction StepIcon({ icon }: { icon: ChatToolStep['icon'] }) {\n const className = 'size-3.5 shrink-0 text-muted-foreground'\n if (icon === 'search') return <Search className={className} />\n if (icon === 'assets') return <Images className={className} />\n if (icon === 'translate') return <Languages className={className} />\n if (icon === 'edit') return <PencilLine className={className} />\n if (icon === 'document') return <FileText className={className} />\n return <FileText className={className} />\n}\n\n/** The prompt input — a growing textarea + send button; Enter sends, Shift+Enter newline. */\nexport function PromptInput({\n value,\n onChange,\n onSubmit,\n disabled,\n}: {\n value: string\n onChange: (value: string) => void\n onSubmit: () => void\n disabled: boolean\n}) {\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault()\n if (!disabled && value.trim().length > 0) onSubmit()\n }\n },\n [disabled, value, onSubmit],\n )\n return (\n <div className=\"border-t border-border p-2.5\">\n <div\n className={cn(\n 'flex items-end gap-2 rounded-xl border border-border bg-background px-2.5 py-2',\n 'focus-within:border-primary/60',\n )}\n >\n <textarea\n value={value}\n onChange={(event) => onChange(event.target.value)}\n onKeyDown={handleKeyDown}\n rows={1}\n placeholder={translate('ai.panel.placeholder')}\n aria-label={translate('ai.panel.placeholder')}\n className=\"max-h-40 min-h-[1.5rem] flex-1 resize-none bg-transparent text-sm outline-none placeholder:text-muted-foreground\"\n />\n <Button\n size=\"sm\"\n onClick={onSubmit}\n disabled={disabled || value.trim().length === 0}\n title={translate('ai.panel.send')}\n aria-label={translate('ai.panel.send')}\n >\n {translate('ai.panel.send')}\n </Button>\n </div>\n </div>\n )\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { CollectionDef } from '@elytracms/core/cms-core';
2
- import type { ProposalOrigin, ProposalReview } from '@elytracms/studio/lib/ai';
3
- import type { CollectionViewSource } from '@elytracms/studio/lib/collection-view/collection-view-source';
2
+ import type { ProposalOrigin, ProposalReview } from '../../lib/ai/index.js';
3
+ import type { CollectionViewSource } from '../../lib/collection-view/collection-view-source.js';
4
4
  /**
5
5
  * The AI proposal review (EC-199, extended by EC-332/EC-378): a valid,
6
6
  * leash-compliant proposal the editor reviews as a DIFF (the shared EC-317
@@ -4,8 +4,8 @@ import { ArrowUpRight, Check, Maximize2, Sparkles, X } from 'lucide-react';
4
4
  import { diffDocuments } from '@elytracms/core/content';
5
5
  import { resolveLabel } from '@elytracms/core/cms-core';
6
6
  import { Badge, Button, ExpandableSurface, Row, Spacer, Stack, Text } from '@elytracms/studio/ui';
7
- import { translate } from '@elytracms/studio/lib/i18n';
8
- import { proposalDocuments } from '@elytracms/studio/lib/ai';
7
+ import { translate } from '../../lib/i18n/index.js';
8
+ import { proposalDocuments } from '../../lib/ai/index.js';
9
9
  import { useCms } from '../cms/cms-store.js';
10
10
  import { useCmsCollectionViewSource } from '../collection-view/cms-collection-view-source.js';
11
11
  import { CollectionViewProvider } from '../collection-view/collection-view-context.js';
@@ -1 +1 @@
1
- {"version":3,"file":"proposal-card.js","sourceRoot":"","sources":["../../../src/components/ai/proposal-card.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AACjG,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAG5D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAA;AAC1F,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAA;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuC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0BAA0B,aACvC,KAAC,sBAAsB,IAAC,MAAM,EAAE,MAAM,YACpC,KAAC,gBAAgB,IAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,GAAI,GAC/D,EACzB,KAAC,cAAc,IAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAC,MAAM,GAAG,IAC/C,GACF,EAEL,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CACtB,MAAC,GAAG,IAAC,GAAG,EAAC,GAAG,EAAC,KAAK,EAAC,QAAQ,EAAC,SAAS,EAAC,2CAA2C,aAC/E,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,gBAAgB,YACpD,SAAS,CAAC,wBAAwB,CAAC,GAC/B,EACP,MAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAC,OAAO,EACf,OAAO,EAAE,GAAG,EAAE;4BACZ,SAAS,EAAE,CAAA;4BACX,OAAO,EAAE,CAAA;wBACX,CAAC,aAED,KAAC,CAAC,KAAG,OAAE,SAAS,CAAC,qBAAqB,CAAC,IAChC,EACT,MAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,GAAG,EAAE;4BACZ,OAAO,EAAE,CAAA;4BACT,OAAO,EAAE,CAAA;wBACX,CAAC,aAED,KAAC,KAAK,KAAG,OAAE,SAAS,CAAC,mBAAmB,CAAC,IAClC,IACL,CACP,CAAC,CAAC,CAAC,IAAI,IACU,CACrB,CAAA;AACH,CAAC","sourcesContent":["import { useMemo, useState } from 'react'\nimport { ArrowUpRight, Check, Maximize2, Sparkles, X } from 'lucide-react'\nimport { diffDocuments } from '@elytracms/core/content'\nimport type { DocumentDiff } from '@elytracms/core/content'\nimport { resolveLabel } from '@elytracms/core/cms-core'\nimport type { CmsValidationIssue, CollectionDef } from '@elytracms/core/cms-core'\nimport { Badge, Button, ExpandableSurface, Row, Spacer, Stack, Text } from '@elytracms/studio/ui'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { proposalDocuments } from '@elytracms/studio/lib/ai'\nimport type { ProposalOrigin, ProposalReview } from '@elytracms/studio/lib/ai'\nimport type { CollectionViewSource } from '@elytracms/studio/lib/collection-view/collection-view-source'\nimport { useCms } from '../cms/cms-store'\nimport { useCmsCollectionViewSource } from '../collection-view/cms-collection-view-source'\nimport { CollectionViewProvider } from '../collection-view/collection-view-context'\nimport { DocumentDiffView } from '../cms/document-diff-view'\nimport { ProposalIssues } from './proposal-issues'\nimport { TranslateSkipped } from './translate-skipped'\n\n/**\n * The AI proposal review (EC-199, extended by EC-332/EC-378): a valid,\n * leash-compliant proposal the editor reviews as a DIFF (the shared EC-317\n * {@link DocumentDiffView} — never a second renderer) before applying it as a\n * draft or discarding it. Create proposals diff `empty-before` vs\n * `proposed-after`; translate/update proposals diff the EXISTING document\n * (old → new). Apply/discard are handled by the panel (the operations write +\n * provenance snapshot happen there); this card is the surface.\n *\n * {@link ProposalCard} is the CMS-wired shell; {@link ProposalCardView} is the\n * presentational card over an injected collection + view source (node-smoked\n * with `renderToStaticMarkup`, house pattern).\n *\n * ## EC-496 — the proposal's own findings\n *\n * The diff answers *what changes*; {@link ProposalIssues} answers *what the engine\n * flagged about it*, immediately above the Apply/Discard row so it is read while the\n * decision is being made. Two calls made here, both deliberate:\n *\n * **An error on the card does NOT block apply.** Grounded before deciding\n * (`file:line`, read 2026-08-01): every producer already filters this list to\n * non-error findings (`lib/ai/apply-content.ts:259`, `lib/ai/update-fields.ts:442`,\n * `lib/ai/tools.ts:764`), so a card-blocking gate would be dead code today. More\n * importantly the real gate already exists one layer up and is strictly better\n * placed: EC-473 made apply RE-VALIDATE against the session as it is NOW\n * (`ai-chat-panel.tsx:371`) and refuse with `ai.error.applyInvalid` when the write\n * would INTRODUCE an error. A build-time snapshot cannot see an edit the editor made\n * since, and gating on pre-existing brokenness is exactly what EC-473 argued makes an\n * assistant unusable on real content. So this surface REPORTS truthfully — errors\n * render as errors and sort first ({@link orderedProposalIssues}) — and the gate\n * stays where it can see the truth.\n *\n * **`attempts` is not rendered** (the EC-496 scope-2 owner call). The repair-loop\n * count is provenance about the MODEL, not about the content: a proposal repaired on\n * the second attempt passed the identical validation gate as a first-shot one, so the\n * number changes nothing an editor can act on — and spending sidebar space plus a new\n * catalog string on it would trade a real signal (the findings) for a trivia line. The\n * field stays on `ChatProposal` (it is deterministic, cheap, and the natural input for\n * a future AI-diagnostics surface); it simply has no place on the editor's card.\n */\n\n/** The card's origin-dependent captions (title + diff column headers). */\nexport function proposalCaptions(\n origin: ProposalOrigin,\n collectionLabel: string,\n): { title: string; unified: string; before: string; after: string } {\n if (origin === 'translate') {\n return {\n title: translate('ai.translate.proposalTitle', { collection: collectionLabel }),\n unified: translate('ai.proposal.diffUnified'),\n before: translate('ai.translate.diffBefore'),\n after: translate('ai.translate.diffAfter'),\n }\n }\n if (origin === 'update') {\n return {\n title: translate('ai.update.proposalTitle', { collection: collectionLabel }),\n unified: translate('ai.proposal.diffUnified'),\n before: translate('ai.update.diffBefore'),\n after: translate('ai.update.diffAfter'),\n }\n }\n return {\n title: translate('ai.proposal.title', { collection: collectionLabel }),\n unified: translate('ai.proposal.diffUnified'),\n before: translate('ai.proposal.diffBefore'),\n after: translate('ai.proposal.diffAfter'),\n }\n}\n\nexport function ProposalCard({\n proposal,\n onApply,\n onDiscard,\n onOpen,\n}: {\n proposal: ProposalReview\n onApply: () => void\n onDiscard: () => void\n onOpen: () => void\n}) {\n const cms = useCms()\n const collection = cms.getCollection(proposal.collection)\n const source = useCmsCollectionViewSource(proposal.collection)\n return (\n <ProposalCardView\n proposal={proposal}\n collection={collection}\n source={source}\n onApply={onApply}\n onDiscard={onDiscard}\n onOpen={onOpen}\n />\n )\n}\n\n/** The presentational proposal card over an injected collection + view source. */\nexport function ProposalCardView({\n proposal,\n collection,\n source,\n onApply,\n onDiscard,\n onOpen,\n}: {\n proposal: ProposalReview\n collection: CollectionDef | undefined\n source: CollectionViewSource | null\n onApply: () => void\n onDiscard: () => void\n onOpen: () => void\n}) {\n const diff = useMemo(() => {\n if (!collection) return null\n const { before, after } = proposalDocuments(proposal.patch, proposal.before)\n return diffDocuments(collection, before, after)\n }, [collection, proposal.patch, proposal.before])\n\n const collectionLabel =\n (collection?.form?.labelSingular && resolveLabel(collection.form.labelSingular)) ??\n (collection?.form?.label && resolveLabel(collection.form.label)) ??\n proposal.collection\n\n const captions = proposalCaptions(proposal.origin, collectionLabel)\n const applied = proposal.status === 'applied'\n const rejected = proposal.status === 'rejected'\n const columnHeaders = { unified: captions.unified, before: captions.before, after: captions.after }\n\n // EC-382 — the expandable review surface: the sidebar card stays stacked; a\n // roomy full-height sheet is offered for a large proposal (never a modal form).\n const [reviewOpen, setReviewOpen] = useState(false)\n const reviewable = diff !== null && source !== null\n\n return (\n <Stack\n gap=\"2\"\n className=\"overflow-hidden rounded-xl border border-border bg-card\"\n >\n <Row gap=\"2\" align=\"center\" className=\"border-b border-border/60 bg-muted/30 px-3 py-2\">\n <Sparkles className=\"size-4 shrink-0 text-primary\" />\n <Text size=\"sm\" weight=\"medium\" className=\"min-w-0 truncate\">\n {captions.title}\n </Text>\n <Spacer />\n {applied ? <Badge variant=\"success\">{translate('ai.proposal.applied')}</Badge> : null}\n {rejected ? <Badge variant=\"outline\">{translate('ai.proposal.discarded')}</Badge> : null}\n {reviewable ? (\n <Button\n size=\"icon-sm\"\n variant=\"ghost\"\n onClick={() => setReviewOpen(true)}\n title={translate('ai.proposal.expandReview')}\n aria-label={translate('ai.proposal.expandReview')}\n >\n <Maximize2 />\n </Button>\n ) : null}\n </Row>\n\n <div className=\"px-3\">\n {reviewable ? (\n <CollectionViewProvider source={source!}>\n <DocumentDiffView\n diff={diff!}\n collection={collection!}\n columnHeaders={columnHeaders}\n layout=\"stacked\"\n />\n </CollectionViewProvider>\n ) : (\n <Text size=\"xs\" tone=\"muted\" className=\"py-2\">\n {translate('ai.proposal.unavailable')}\n </Text>\n )}\n </div>\n\n {/* EC-496 — the engine's surviving findings, last thing before the actions. */}\n <ProposalIssues issues={proposal.issues} className=\"px-3\" />\n {/* EC-593 — what a translation could not translate, listed (never skipped silently). */}\n {proposal.skipped && proposal.skipped.length > 0 ? (\n <div className=\"px-3\">\n <TranslateSkipped skipped={proposal.skipped} collection={collection} />\n </div>\n ) : null}\n\n <Row gap=\"2\" align=\"center\" className=\"border-t border-border/60 px-3 py-2\">\n {proposal.status === 'pending' ? (\n <>\n <Text size=\"xs\" tone=\"muted\" className=\"min-w-0 flex-1\">\n {translate('ai.proposal.reviewHint')}\n </Text>\n <Button size=\"sm\" variant=\"ghost\" onClick={onDiscard}>\n <X /> {translate('ai.proposal.discard')}\n </Button>\n <Button size=\"sm\" onClick={onApply}>\n <Check /> {translate('ai.proposal.apply')}\n </Button>\n </>\n ) : applied ? (\n <>\n <Spacer />\n <Button size=\"sm\" variant=\"outline\" onClick={onOpen}>\n <ArrowUpRight /> {translate('ai.proposal.open')}\n </Button>\n </>\n ) : (\n <Text size=\"xs\" tone=\"muted\">\n {translate('ai.proposal.discardedNote')}\n </Text>\n )}\n </Row>\n\n {reviewable && reviewOpen ? (\n <ProposalReviewSheet\n title={captions.title}\n diff={diff!}\n collection={collection!}\n source={source!}\n columnHeaders={columnHeaders}\n issues={proposal.issues}\n status={proposal.status}\n onApply={onApply}\n onDiscard={onDiscard}\n onClose={() => setReviewOpen(false)}\n />\n ) : null}\n </Stack>\n )\n}\n\n/**\n * The expandable review surface (EC-382): the proposal's diff promoted into a\n * roomy, full-height right-anchored sheet where the wide `grid` layout is\n * comfortable — for a large proposal the 320px sidebar can only cramp. It is a\n * REVIEW surface, not a form, so it stays lightly dismissible (backdrop click /\n * Escape / close button) rather than a trapping modal — the forms-never-modal\n * spirit, applied. Presentation only: Apply/Discard call the same handlers the\n * card does; it changes no proposal data. Since EC-392 it renders through the\n * shared {@link ExpandableSurface} primitive (portal-to-body, backdrop, header\n * close, layer-stacked Escape) at the shipped 720px width, so it escapes the\n * narrow AI panel; the card default keeps it closed, so the SSR smoke path\n * never mounts the portal.\n */\nfunction ProposalReviewSheet({\n title,\n diff,\n collection,\n source,\n columnHeaders,\n issues,\n status,\n onApply,\n onDiscard,\n onClose,\n}: {\n title: string\n diff: DocumentDiff\n collection: CollectionDef\n source: CollectionViewSource\n columnHeaders: { unified: string; before: string; after: string }\n /** EC-496 — the same findings the card shows; the roomy surface must not hide them. */\n issues: readonly CmsValidationIssue[]\n status: ProposalReview['status']\n onApply: () => void\n onDiscard: () => void\n onClose: () => void\n}) {\n return (\n <ExpandableSurface\n title={title}\n closeLabel={translate('ai.proposal.collapseReview')}\n width=\"min(720px, 92vw)\"\n onDismiss={onClose}\n headerLeading={<Sparkles className=\"size-4 shrink-0 text-primary\" />}\n >\n <div className=\"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6\">\n <div className=\"mx-auto w-full max-w-3xl\">\n <CollectionViewProvider source={source}>\n <DocumentDiffView diff={diff} collection={collection} columnHeaders={columnHeaders} />\n </CollectionViewProvider>\n <ProposalIssues issues={issues} className=\"mt-4\" />\n </div>\n </div>\n\n {status === 'pending' ? (\n <Row gap=\"2\" align=\"center\" className=\"shrink-0 border-t border-border px-4 py-3\">\n <Text size=\"xs\" tone=\"muted\" className=\"min-w-0 flex-1\">\n {translate('ai.proposal.reviewHint')}\n </Text>\n <Button\n size=\"sm\"\n variant=\"ghost\"\n onClick={() => {\n onDiscard()\n onClose()\n }}\n >\n <X /> {translate('ai.proposal.discard')}\n </Button>\n <Button\n size=\"sm\"\n onClick={() => {\n onApply()\n onClose()\n }}\n >\n <Check /> {translate('ai.proposal.apply')}\n </Button>\n </Row>\n ) : null}\n </ExpandableSurface>\n )\n}\n"]}
1
+ {"version":3,"file":"proposal-card.js","sourceRoot":"","sources":["../../../src/components/ai/proposal-card.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE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,EAAC,SAAS,EAAC,gBAAgB,YACpD,SAAS,CAAC,wBAAwB,CAAC,GAC/B,EACP,MAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAC,OAAO,EACf,OAAO,EAAE,GAAG,EAAE;4BACZ,SAAS,EAAE,CAAA;4BACX,OAAO,EAAE,CAAA;wBACX,CAAC,aAED,KAAC,CAAC,KAAG,OAAE,SAAS,CAAC,qBAAqB,CAAC,IAChC,EACT,MAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,GAAG,EAAE;4BACZ,OAAO,EAAE,CAAA;4BACT,OAAO,EAAE,CAAA;wBACX,CAAC,aAED,KAAC,KAAK,KAAG,OAAE,SAAS,CAAC,mBAAmB,CAAC,IAClC,IACL,CACP,CAAC,CAAC,CAAC,IAAI,IACU,CACrB,CAAA;AACH,CAAC","sourcesContent":["import { useMemo, useState } from 'react'\nimport { ArrowUpRight, Check, Maximize2, Sparkles, X } from 'lucide-react'\nimport { diffDocuments } from '@elytracms/core/content'\nimport type { DocumentDiff } from '@elytracms/core/content'\nimport { resolveLabel } from '@elytracms/core/cms-core'\nimport type { CmsValidationIssue, CollectionDef } from '@elytracms/core/cms-core'\nimport { Badge, Button, ExpandableSurface, Row, Spacer, Stack, Text } from '@elytracms/studio/ui'\nimport { translate } from '../../lib/i18n'\nimport { proposalDocuments } from '../../lib/ai'\nimport type { ProposalOrigin, ProposalReview } from '../../lib/ai'\nimport type { CollectionViewSource } from '../../lib/collection-view/collection-view-source'\nimport { useCms } from '../cms/cms-store'\nimport { useCmsCollectionViewSource } from '../collection-view/cms-collection-view-source'\nimport { CollectionViewProvider } from '../collection-view/collection-view-context'\nimport { DocumentDiffView } from '../cms/document-diff-view'\nimport { ProposalIssues } from './proposal-issues'\nimport { TranslateSkipped } from './translate-skipped'\n\n/**\n * The AI proposal review (EC-199, extended by EC-332/EC-378): a valid,\n * leash-compliant proposal the editor reviews as a DIFF (the shared EC-317\n * {@link DocumentDiffView} — never a second renderer) before applying it as a\n * draft or discarding it. Create proposals diff `empty-before` vs\n * `proposed-after`; translate/update proposals diff the EXISTING document\n * (old → new). Apply/discard are handled by the panel (the operations write +\n * provenance snapshot happen there); this card is the surface.\n *\n * {@link ProposalCard} is the CMS-wired shell; {@link ProposalCardView} is the\n * presentational card over an injected collection + view source (node-smoked\n * with `renderToStaticMarkup`, house pattern).\n *\n * ## EC-496 — the proposal's own findings\n *\n * The diff answers *what changes*; {@link ProposalIssues} answers *what the engine\n * flagged about it*, immediately above the Apply/Discard row so it is read while the\n * decision is being made. Two calls made here, both deliberate:\n *\n * **An error on the card does NOT block apply.** Grounded before deciding\n * (`file:line`, read 2026-08-01): every producer already filters this list to\n * non-error findings (`lib/ai/apply-content.ts:259`, `lib/ai/update-fields.ts:442`,\n * `lib/ai/tools.ts:764`), so a card-blocking gate would be dead code today. More\n * importantly the real gate already exists one layer up and is strictly better\n * placed: EC-473 made apply RE-VALIDATE against the session as it is NOW\n * (`ai-chat-panel.tsx:371`) and refuse with `ai.error.applyInvalid` when the write\n * would INTRODUCE an error. A build-time snapshot cannot see an edit the editor made\n * since, and gating on pre-existing brokenness is exactly what EC-473 argued makes an\n * assistant unusable on real content. So this surface REPORTS truthfully — errors\n * render as errors and sort first ({@link orderedProposalIssues}) — and the gate\n * stays where it can see the truth.\n *\n * **`attempts` is not rendered** (the EC-496 scope-2 owner call). The repair-loop\n * count is provenance about the MODEL, not about the content: a proposal repaired on\n * the second attempt passed the identical validation gate as a first-shot one, so the\n * number changes nothing an editor can act on — and spending sidebar space plus a new\n * catalog string on it would trade a real signal (the findings) for a trivia line. The\n * field stays on `ChatProposal` (it is deterministic, cheap, and the natural input for\n * a future AI-diagnostics surface); it simply has no place on the editor's card.\n */\n\n/** The card's origin-dependent captions (title + diff column headers). */\nexport function proposalCaptions(\n origin: ProposalOrigin,\n collectionLabel: string,\n): { title: string; unified: string; before: string; after: string } {\n if (origin === 'translate') {\n return {\n title: translate('ai.translate.proposalTitle', { collection: collectionLabel }),\n unified: translate('ai.proposal.diffUnified'),\n before: translate('ai.translate.diffBefore'),\n after: translate('ai.translate.diffAfter'),\n }\n }\n if (origin === 'update') {\n return {\n title: translate('ai.update.proposalTitle', { collection: collectionLabel }),\n unified: translate('ai.proposal.diffUnified'),\n before: translate('ai.update.diffBefore'),\n after: translate('ai.update.diffAfter'),\n }\n }\n return {\n title: translate('ai.proposal.title', { collection: collectionLabel }),\n unified: translate('ai.proposal.diffUnified'),\n before: translate('ai.proposal.diffBefore'),\n after: translate('ai.proposal.diffAfter'),\n }\n}\n\nexport function ProposalCard({\n proposal,\n onApply,\n onDiscard,\n onOpen,\n}: {\n proposal: ProposalReview\n onApply: () => void\n onDiscard: () => void\n onOpen: () => void\n}) {\n const cms = useCms()\n const collection = cms.getCollection(proposal.collection)\n const source = useCmsCollectionViewSource(proposal.collection)\n return (\n <ProposalCardView\n proposal={proposal}\n collection={collection}\n source={source}\n onApply={onApply}\n onDiscard={onDiscard}\n onOpen={onOpen}\n />\n )\n}\n\n/** The presentational proposal card over an injected collection + view source. */\nexport function ProposalCardView({\n proposal,\n collection,\n source,\n onApply,\n onDiscard,\n onOpen,\n}: {\n proposal: ProposalReview\n collection: CollectionDef | undefined\n source: CollectionViewSource | null\n onApply: () => void\n onDiscard: () => void\n onOpen: () => void\n}) {\n const diff = useMemo(() => {\n if (!collection) return null\n const { before, after } = proposalDocuments(proposal.patch, proposal.before)\n return diffDocuments(collection, before, after)\n }, [collection, proposal.patch, proposal.before])\n\n const collectionLabel =\n (collection?.form?.labelSingular && resolveLabel(collection.form.labelSingular)) ??\n (collection?.form?.label && resolveLabel(collection.form.label)) ??\n proposal.collection\n\n const captions = proposalCaptions(proposal.origin, collectionLabel)\n const applied = proposal.status === 'applied'\n const rejected = proposal.status === 'rejected'\n const columnHeaders = { unified: captions.unified, before: captions.before, after: captions.after }\n\n // EC-382 — the expandable review surface: the sidebar card stays stacked; a\n // roomy full-height sheet is offered for a large proposal (never a modal form).\n const [reviewOpen, setReviewOpen] = useState(false)\n const reviewable = diff !== null && source !== null\n\n return (\n <Stack\n gap=\"2\"\n className=\"overflow-hidden rounded-xl border border-border bg-card\"\n >\n <Row gap=\"2\" align=\"center\" className=\"border-b border-border/60 bg-muted/30 px-3 py-2\">\n <Sparkles className=\"size-4 shrink-0 text-primary\" />\n <Text size=\"sm\" weight=\"medium\" className=\"min-w-0 truncate\">\n {captions.title}\n </Text>\n <Spacer />\n {applied ? <Badge variant=\"success\">{translate('ai.proposal.applied')}</Badge> : null}\n {rejected ? <Badge variant=\"outline\">{translate('ai.proposal.discarded')}</Badge> : null}\n {reviewable ? (\n <Button\n size=\"icon-sm\"\n variant=\"ghost\"\n onClick={() => setReviewOpen(true)}\n title={translate('ai.proposal.expandReview')}\n aria-label={translate('ai.proposal.expandReview')}\n >\n <Maximize2 />\n </Button>\n ) : null}\n </Row>\n\n <div className=\"px-3\">\n {reviewable ? (\n <CollectionViewProvider source={source!}>\n <DocumentDiffView\n diff={diff!}\n collection={collection!}\n columnHeaders={columnHeaders}\n layout=\"stacked\"\n />\n </CollectionViewProvider>\n ) : (\n <Text size=\"xs\" tone=\"muted\" className=\"py-2\">\n {translate('ai.proposal.unavailable')}\n </Text>\n )}\n </div>\n\n {/* EC-496 — the engine's surviving findings, last thing before the actions. */}\n <ProposalIssues issues={proposal.issues} className=\"px-3\" />\n {/* EC-593 — what a translation could not translate, listed (never skipped silently). */}\n {proposal.skipped && proposal.skipped.length > 0 ? (\n <div className=\"px-3\">\n <TranslateSkipped skipped={proposal.skipped} collection={collection} />\n </div>\n ) : null}\n\n <Row gap=\"2\" align=\"center\" className=\"border-t border-border/60 px-3 py-2\">\n {proposal.status === 'pending' ? (\n <>\n <Text size=\"xs\" tone=\"muted\" className=\"min-w-0 flex-1\">\n {translate('ai.proposal.reviewHint')}\n </Text>\n <Button size=\"sm\" variant=\"ghost\" onClick={onDiscard}>\n <X /> {translate('ai.proposal.discard')}\n </Button>\n <Button size=\"sm\" onClick={onApply}>\n <Check /> {translate('ai.proposal.apply')}\n </Button>\n </>\n ) : applied ? (\n <>\n <Spacer />\n <Button size=\"sm\" variant=\"outline\" onClick={onOpen}>\n <ArrowUpRight /> {translate('ai.proposal.open')}\n </Button>\n </>\n ) : (\n <Text size=\"xs\" tone=\"muted\">\n {translate('ai.proposal.discardedNote')}\n </Text>\n )}\n </Row>\n\n {reviewable && reviewOpen ? (\n <ProposalReviewSheet\n title={captions.title}\n diff={diff!}\n collection={collection!}\n source={source!}\n columnHeaders={columnHeaders}\n issues={proposal.issues}\n status={proposal.status}\n onApply={onApply}\n onDiscard={onDiscard}\n onClose={() => setReviewOpen(false)}\n />\n ) : null}\n </Stack>\n )\n}\n\n/**\n * The expandable review surface (EC-382): the proposal's diff promoted into a\n * roomy, full-height right-anchored sheet where the wide `grid` layout is\n * comfortable — for a large proposal the 320px sidebar can only cramp. It is a\n * REVIEW surface, not a form, so it stays lightly dismissible (backdrop click /\n * Escape / close button) rather than a trapping modal — the forms-never-modal\n * spirit, applied. Presentation only: Apply/Discard call the same handlers the\n * card does; it changes no proposal data. Since EC-392 it renders through the\n * shared {@link ExpandableSurface} primitive (portal-to-body, backdrop, header\n * close, layer-stacked Escape) at the shipped 720px width, so it escapes the\n * narrow AI panel; the card default keeps it closed, so the SSR smoke path\n * never mounts the portal.\n */\nfunction ProposalReviewSheet({\n title,\n diff,\n collection,\n source,\n columnHeaders,\n issues,\n status,\n onApply,\n onDiscard,\n onClose,\n}: {\n title: string\n diff: DocumentDiff\n collection: CollectionDef\n source: CollectionViewSource\n columnHeaders: { unified: string; before: string; after: string }\n /** EC-496 — the same findings the card shows; the roomy surface must not hide them. */\n issues: readonly CmsValidationIssue[]\n status: ProposalReview['status']\n onApply: () => void\n onDiscard: () => void\n onClose: () => void\n}) {\n return (\n <ExpandableSurface\n title={title}\n closeLabel={translate('ai.proposal.collapseReview')}\n width=\"min(720px, 92vw)\"\n onDismiss={onClose}\n headerLeading={<Sparkles className=\"size-4 shrink-0 text-primary\" />}\n >\n <div className=\"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6\">\n <div className=\"mx-auto w-full max-w-3xl\">\n <CollectionViewProvider source={source}>\n <DocumentDiffView diff={diff} collection={collection} columnHeaders={columnHeaders} />\n </CollectionViewProvider>\n <ProposalIssues issues={issues} className=\"mt-4\" />\n </div>\n </div>\n\n {status === 'pending' ? (\n <Row gap=\"2\" align=\"center\" className=\"shrink-0 border-t border-border px-4 py-3\">\n <Text size=\"xs\" tone=\"muted\" className=\"min-w-0 flex-1\">\n {translate('ai.proposal.reviewHint')}\n </Text>\n <Button\n size=\"sm\"\n variant=\"ghost\"\n onClick={() => {\n onDiscard()\n onClose()\n }}\n >\n <X /> {translate('ai.proposal.discard')}\n </Button>\n <Button\n size=\"sm\"\n onClick={() => {\n onApply()\n onClose()\n }}\n >\n <Check /> {translate('ai.proposal.apply')}\n </Button>\n </Row>\n ) : null}\n </ExpandableSurface>\n )\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { cn } from '@elytracms/studio/lib/utils';
3
- import { cmsIssueLabel, cmsValidationIssueMessage } from '@elytracms/studio/lib/persona/labels';
2
+ import { cn } from '../../lib/utils.js';
3
+ import { cmsIssueLabel, cmsValidationIssueMessage } from '../../lib/persona/labels.js';
4
4
  import { Row, Stack, Text } from '@elytracms/studio/ui';
5
5
  import { issueSeverityIcon, issueSeverityStyle, orderBySeverity } from '../issue-severity.js';
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"proposal-issues.js","sourceRoot":"","sources":["../../../src/components/ai/proposal-issues.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,6BAA6B,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AAC/F,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AACvD,OA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C,GAAG,EAAC,SAAS,EAAC,SAAS,aAChC,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,MAAM,EAAC,UAAU,EAAC,KAAK,EAAE,KAAK,CAAC,IAAI,YAChD,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,GACrC,EACP,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,sBAAsB,YAC7C,yBAAyB,CAAC,KAAK,CAAC,GAC5B,IACD,IACJ,CACP,CAAA;AACH,CAAC","sourcesContent":["import type { CmsValidationIssue } from '@elytracms/core/cms-core'\nimport { cn } from '@elytracms/studio/lib/utils'\nimport { cmsIssueLabel, cmsValidationIssueMessage } from '@elytracms/studio/lib/persona/labels'\nimport { Row, Stack, Text } from '@elytracms/studio/ui'\nimport { issueSeverityIcon, issueSeverityStyle, orderBySeverity } from '../issue-severity'\n\n/**\n * EC-496 — the findings the engine attached to an AI proposal, rendered on the\n * review surface.\n *\n * A proposal carries the non-error issues its content produced\n * (`ChatProposal.issues`): the repair loop and the EC-473 gate block on errors the\n * change INTRODUCES, and everything else — an EC-472 implausible year, an EC-390\n * localized-plain-value note, an unpublished relation target, a nesting-depth\n * warning — deliberately survives into the proposal. Until this ticket nothing\n * read the field, so the one consumer of a warning-severity finding on the AI path\n * was a UI that ignored it: an editor pressed **Apply as draft** without ever being\n * told the engine had flagged the content.\n *\n * The treatment is the studio's ONE severity vocabulary, not a third one: the\n * palette and glyph come from {@link issueSeverityStyle} / {@link issueSeverityIcon}\n * in `components/issue-severity.ts` — the pure cores EC-493 first extracted from the\n * document Issues pane, which EC-507 then moved out of the section rail into a home\n * neither surface owns (importing them from `nav-issues` was how this card ended up\n * depending on a `nav`-prefixed core). The card copy follows the pane too: the plain-language\n * {@link cmsIssueLabel} as the title with the raw `code` in `title=` for engineers\n * (the EC-192 persona boundary), and the localized body via\n * {@link cmsValidationIssueMessage} (EC-487's `messageRef` carriage, degrading to the\n * producer's English for a ref-less issue).\n *\n * `data-proposal-issue-severity` on each card is the machine-readable form of the\n * same distinction — what the smoke test pins, and what an agent inspecting the live\n * DOM reads without decoding Tailwind classes.\n */\n\n/**\n * The proposal's findings in render order: **errors first**, warnings after, stable\n * within each severity.\n *\n * The card's primary action is *Apply as draft*, and the reader scans top-down — so\n * the finding that should give pause must not sit below one that should merely\n * inform. That is the shared rank rule (`error` outranks `warning`), so since EC-507\n * this delegates to {@link orderBySeverity} rather than re-expressing it: the rail's\n * `highestIssueSeverity` is the same rule reduced to one aggregate glyph.\n *\n * Errors are not *expected* here — all three producers filter to non-error findings\n * (`apply-content.ts:259`, `update-fields.ts:442`, `tools.ts:764`) — but\n * `ChatProposal.issues` is typed `CmsValidationIssue[]`, so this surface renders\n * whatever it is handed, truthfully. See the apply-gate note in `proposal-card.tsx`.\n */\nexport function orderedProposalIssues(\n issues: readonly CmsValidationIssue[],\n): CmsValidationIssue[] {\n return orderBySeverity(issues)\n}\n\n/**\n * The proposal's findings, severity-tinted. Renders NOTHING for an empty list — a\n * clean proposal gets no issue affordance at all, never an empty box captioned\n * \"no issues\" (the card is a narrow sidebar surface; silence is the correct\n * negative).\n */\nexport function ProposalIssues({\n issues,\n className,\n}: {\n issues: readonly CmsValidationIssue[]\n className?: string\n}) {\n if (issues.length === 0) return null\n return (\n <Stack gap=\"1\" className={className} data-testid=\"proposal-issues\">\n {orderedProposalIssues(issues).map((issue, index) => (\n <ProposalIssueCard\n key={`${issue.code}:${issue.path.join('/')}:${index}`}\n issue={issue}\n />\n ))}\n </Stack>\n )\n}\n\n/** One finding on the proposal, tinted + glyphed by its severity. */\nfunction ProposalIssueCard({ issue }: { issue: CmsValidationIssue }) {\n const style = issueSeverityStyle(issue.severity)\n const Icon = issueSeverityIcon(issue.severity)\n return (\n <Row\n gap=\"2\"\n align=\"start\"\n className={cn('rounded-md border px-2.5 py-2', style.card, style.text)}\n data-proposal-issue-severity={issue.severity}\n >\n <Icon className=\"mt-0.5 size-3.5 shrink-0\" aria-hidden />\n <Stack gap=\"1\" className=\"min-w-0\">\n <Text size=\"xs\" weight=\"semibold\" title={issue.code}>\n {cmsIssueLabel(issue.code, issue.severity)}\n </Text>\n <Text size=\"xs\" className=\"min-w-0 leading-snug\">\n {cmsValidationIssueMessage(issue)}\n </Text>\n </Stack>\n </Row>\n )\n}\n"]}
1
+ {"version":3,"file":"proposal-issues.js","sourceRoot":"","sources":["../../../src/components/ai/proposal-issues.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AACnF,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAE1F;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAAqC;IAErC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAA;AAChC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,EAC7B,MAAM,EACN,SAAS,GAIV;IACC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACpC,OAAO,CACL,KAAC,KAAK,IAAC,GAAG,EAAC,GAAG,EAAC,SAAS,EAAE,SAAS,iBAAc,iBAAiB,YAC/D,qBAAqB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CACnD,KAAC,iBAAiB,IAEhB,KAAK,EAAE,KAAK,IADP,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,EAAE,CAErD,CACH,CAAC,GACI,CACT,CAAA;AACH,CAAC;AAED,qEAAqE;AACrE,SAAS,iBAAiB,CAAC,EAAE,KAAK,EAAiC;IACjE,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAChD,MAAM,IAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAC9C,OAAO,CACL,MAAC,GAAG,IACF,GAAG,EAAC,GAAG,EACP,KAAK,EAAC,OAAO,EACb,SAAS,EAAE,EAAE,CAAC,+BAA+B,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,kCACxC,KAAK,CAAC,QAAQ,aAE5C,KAAC,IAAI,IAAC,SAAS,EAAC,0BAA0B,wBAAe,EACzD,MAAC,KAAK,IAAC,GAAG,EAAC,GAAG,EAAC,SAAS,EAAC,SAAS,aAChC,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,MAAM,EAAC,UAAU,EAAC,KAAK,EAAE,KAAK,CAAC,IAAI,YAChD,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,GACrC,EACP,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,sBAAsB,YAC7C,yBAAyB,CAAC,KAAK,CAAC,GAC5B,IACD,IACJ,CACP,CAAA;AACH,CAAC","sourcesContent":["import type { CmsValidationIssue } from '@elytracms/core/cms-core'\nimport { cn } from '../../lib/utils'\nimport { cmsIssueLabel, cmsValidationIssueMessage } from '../../lib/persona/labels'\nimport { Row, Stack, Text } from '@elytracms/studio/ui'\nimport { issueSeverityIcon, issueSeverityStyle, orderBySeverity } from '../issue-severity'\n\n/**\n * EC-496 — the findings the engine attached to an AI proposal, rendered on the\n * review surface.\n *\n * A proposal carries the non-error issues its content produced\n * (`ChatProposal.issues`): the repair loop and the EC-473 gate block on errors the\n * change INTRODUCES, and everything else — an EC-472 implausible year, an EC-390\n * localized-plain-value note, an unpublished relation target, a nesting-depth\n * warning — deliberately survives into the proposal. Until this ticket nothing\n * read the field, so the one consumer of a warning-severity finding on the AI path\n * was a UI that ignored it: an editor pressed **Apply as draft** without ever being\n * told the engine had flagged the content.\n *\n * The treatment is the studio's ONE severity vocabulary, not a third one: the\n * palette and glyph come from {@link issueSeverityStyle} / {@link issueSeverityIcon}\n * in `components/issue-severity.ts` — the pure cores EC-493 first extracted from the\n * document Issues pane, which EC-507 then moved out of the section rail into a home\n * neither surface owns (importing them from `nav-issues` was how this card ended up\n * depending on a `nav`-prefixed core). The card copy follows the pane too: the plain-language\n * {@link cmsIssueLabel} as the title with the raw `code` in `title=` for engineers\n * (the EC-192 persona boundary), and the localized body via\n * {@link cmsValidationIssueMessage} (EC-487's `messageRef` carriage, degrading to the\n * producer's English for a ref-less issue).\n *\n * `data-proposal-issue-severity` on each card is the machine-readable form of the\n * same distinction — what the smoke test pins, and what an agent inspecting the live\n * DOM reads without decoding Tailwind classes.\n */\n\n/**\n * The proposal's findings in render order: **errors first**, warnings after, stable\n * within each severity.\n *\n * The card's primary action is *Apply as draft*, and the reader scans top-down — so\n * the finding that should give pause must not sit below one that should merely\n * inform. That is the shared rank rule (`error` outranks `warning`), so since EC-507\n * this delegates to {@link orderBySeverity} rather than re-expressing it: the rail's\n * `highestIssueSeverity` is the same rule reduced to one aggregate glyph.\n *\n * Errors are not *expected* here — all three producers filter to non-error findings\n * (`apply-content.ts:259`, `update-fields.ts:442`, `tools.ts:764`) — but\n * `ChatProposal.issues` is typed `CmsValidationIssue[]`, so this surface renders\n * whatever it is handed, truthfully. See the apply-gate note in `proposal-card.tsx`.\n */\nexport function orderedProposalIssues(\n issues: readonly CmsValidationIssue[],\n): CmsValidationIssue[] {\n return orderBySeverity(issues)\n}\n\n/**\n * The proposal's findings, severity-tinted. Renders NOTHING for an empty list — a\n * clean proposal gets no issue affordance at all, never an empty box captioned\n * \"no issues\" (the card is a narrow sidebar surface; silence is the correct\n * negative).\n */\nexport function ProposalIssues({\n issues,\n className,\n}: {\n issues: readonly CmsValidationIssue[]\n className?: string\n}) {\n if (issues.length === 0) return null\n return (\n <Stack gap=\"1\" className={className} data-testid=\"proposal-issues\">\n {orderedProposalIssues(issues).map((issue, index) => (\n <ProposalIssueCard\n key={`${issue.code}:${issue.path.join('/')}:${index}`}\n issue={issue}\n />\n ))}\n </Stack>\n )\n}\n\n/** One finding on the proposal, tinted + glyphed by its severity. */\nfunction ProposalIssueCard({ issue }: { issue: CmsValidationIssue }) {\n const style = issueSeverityStyle(issue.severity)\n const Icon = issueSeverityIcon(issue.severity)\n return (\n <Row\n gap=\"2\"\n align=\"start\"\n className={cn('rounded-md border px-2.5 py-2', style.card, style.text)}\n data-proposal-issue-severity={issue.severity}\n >\n <Icon className=\"mt-0.5 size-3.5 shrink-0\" aria-hidden />\n <Stack gap=\"1\" className=\"min-w-0\">\n <Text size=\"xs\" weight=\"semibold\" title={issue.code}>\n {cmsIssueLabel(issue.code, issue.severity)}\n </Text>\n <Text size=\"xs\" className=\"min-w-0 leading-snug\">\n {cmsValidationIssueMessage(issue)}\n </Text>\n </Stack>\n </Row>\n )\n}\n"]}
@@ -3,8 +3,8 @@ import { Suspense, lazy, useMemo, useState } from 'react';
3
3
  import { Languages } from 'lucide-react';
4
4
  import { isFieldLocalized } from '@elytracms/core/cms-core';
5
5
  import { Button } from '@elytracms/studio/ui';
6
- import { translate } from '@elytracms/studio/lib/i18n';
7
- import { resolveDeploymentAi } from '@elytracms/studio/lib/workspace';
6
+ import { translate } from '../../lib/i18n/index.js';
7
+ import { resolveDeploymentAi } from '../../lib/workspace/index.js';
8
8
  /**
9
9
  * The "Translate document" header action (EC-332), gate side.
10
10
  *
@@ -1 +1 @@
1
- {"version":3,"file":"translate-document-action.js","sourceRoot":"","sources":["../../../src/components/ai/translate-document-action.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzD,OAAO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IAAI,CAAC,CAAC,CAAA;IAC5E,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC,CAAA;IAEzD,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAA;IAE1B,OAAO,CACL,8BACE,MAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,iBAChB,eAAe,EAC3B,KAAK,EAAE,SAAS,CAAC,sBAAsB,CAAC,aAExC,KAAC,SAAS,KAAG,OAAE,SAAS,CAAC,qBAAqB,CAAC,IACxC,EACR,IAAI,CAAC,CAAC,CAAC,CACN,KAAC,QAAQ,IAAC,QAAQ,EAAE,IAAI,YACtB,KAAC,uBAAuB,OAAK,KAAK,EAAE,IAAI,QAAC,YAAY,EAAE,OAAO,GAAI,GACzD,CACZ,CAAC,CAAC,CAAC,IAAI,IACP,CACJ,CAAA;AACH,CAAC","sourcesContent":["import { Suspense, lazy, useMemo, useState } from 'react'\nimport { Languages } from 'lucide-react'\nimport { isFieldLocalized } from '@elytracms/core/cms-core'\nimport type { CmsDocument, CollectionDef, DocumentRef, LocaleConfig } from '@elytracms/core/cms-core'\nimport { Button } from '@elytracms/studio/ui'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { resolveDeploymentAi } from '@elytracms/studio/lib/workspace'\n\n/**\n * The \"Translate document\" header action (EC-332), gate side.\n *\n * Rendered ALWAYS in the detail-editor header but returns null unless the studio is\n * `ai`-configured (EC-331 presence-enable), the collection is localized with a real\n * localized field, and there is a target locale to fill. Like the AI panel toggle, the\n * gate reads only the config object + pure core helpers — it never statically imports\n * the AI engine (`@elytracms/studio/lib/ai`) or the AI SDK. The heavy dialog (which runs\n * the translation engine + operations write) loads ONLY when the editor opens it, via a\n * dynamic `import()`, so an unconfigured studio pulls none of it onto the critical path.\n */\nconst TranslateDocumentDialog = lazy(() =>\n import('./translate-document-dialog').then((m) => ({ default: m.TranslateDocumentDialog })),\n)\n\nexport interface TranslateDocumentActionProps {\n projectId: string | undefined\n collection: CollectionDef\n docRef: DocumentRef\n /** The live editor draft — the translation source + the target for the fills. */\n document: CmsDocument\n localeConfig: LocaleConfig\n /** Whether the collection view exposes per-locale editing (`source.capabilities.locales`). */\n localesEnabled: boolean\n /**\n * EC-595 A2 — the FORCED FLUSH before the AI reads the draft (the ruling: \"a forced\n * flush before … an AI proposal\"): the editor commits its uncommitted fields and the\n * persister lands them, so the translation's patches are made on the committed draft.\n * The translated buckets reach the open editor through the session (it rebases), so\n * there is no draft to hand back.\n */\n flushDraft: () => Promise<void>\n}\n\nexport function TranslateDocumentAction(props: TranslateDocumentActionProps) {\n const [open, setOpen] = useState(false)\n const { collection, localeConfig, localesEnabled, projectId } = props\n\n const eligible = useMemo(() => {\n const ai = resolveDeploymentAi()\n if (!ai || ai.enabled === false) return false\n if (!localesEnabled || projectId === undefined) return false\n const base = localeConfig.default\n if (!localeConfig.locales.some((l) => l !== base)) return false\n return collection.fields.some((f) => isFieldLocalized(collection, f.name))\n }, [collection, localeConfig, localesEnabled, projectId])\n\n if (!eligible) return null\n\n return (\n <>\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => setOpen(true)}\n data-testid=\"doc-translate\"\n title={translate('ai.translate.tooltip')}\n >\n <Languages /> {translate('ai.translate.action')}\n </Button>\n {open ? (\n <Suspense fallback={null}>\n <TranslateDocumentDialog {...props} open onOpenChange={setOpen} />\n </Suspense>\n ) : null}\n </>\n )\n}\n"]}
1
+ {"version":3,"file":"translate-document-action.js","sourceRoot":"","sources":["../../../src/components/ai/translate-document-action.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM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,cAAc,EAAE,SAAS,CAAC,CAAC,CAAA;IAEzD,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAA;IAE1B,OAAO,CACL,8BACE,MAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,iBAChB,eAAe,EAC3B,KAAK,EAAE,SAAS,CAAC,sBAAsB,CAAC,aAExC,KAAC,SAAS,KAAG,OAAE,SAAS,CAAC,qBAAqB,CAAC,IACxC,EACR,IAAI,CAAC,CAAC,CAAC,CACN,KAAC,QAAQ,IAAC,QAAQ,EAAE,IAAI,YACtB,KAAC,uBAAuB,OAAK,KAAK,EAAE,IAAI,QAAC,YAAY,EAAE,OAAO,GAAI,GACzD,CACZ,CAAC,CAAC,CAAC,IAAI,IACP,CACJ,CAAA;AACH,CAAC","sourcesContent":["import { Suspense, lazy, useMemo, useState } from 'react'\nimport { Languages } from 'lucide-react'\nimport { isFieldLocalized } from '@elytracms/core/cms-core'\nimport type { CmsDocument, CollectionDef, DocumentRef, LocaleConfig } from '@elytracms/core/cms-core'\nimport { Button } from '@elytracms/studio/ui'\nimport { translate } from '../../lib/i18n'\nimport { resolveDeploymentAi } from '../../lib/workspace'\n\n/**\n * The \"Translate document\" header action (EC-332), gate side.\n *\n * Rendered ALWAYS in the detail-editor header but returns null unless the studio is\n * `ai`-configured (EC-331 presence-enable), the collection is localized with a real\n * localized field, and there is a target locale to fill. Like the AI panel toggle, the\n * gate reads only the config object + pure core helpers — it never statically imports\n * the AI engine (`@elytracms/studio/lib/ai`) or the AI SDK. The heavy dialog (which runs\n * the translation engine + operations write) loads ONLY when the editor opens it, via a\n * dynamic `import()`, so an unconfigured studio pulls none of it onto the critical path.\n */\nconst TranslateDocumentDialog = lazy(() =>\n import('./translate-document-dialog').then((m) => ({ default: m.TranslateDocumentDialog })),\n)\n\nexport interface TranslateDocumentActionProps {\n projectId: string | undefined\n collection: CollectionDef\n docRef: DocumentRef\n /** The live editor draft — the translation source + the target for the fills. */\n document: CmsDocument\n localeConfig: LocaleConfig\n /** Whether the collection view exposes per-locale editing (`source.capabilities.locales`). */\n localesEnabled: boolean\n /**\n * EC-595 A2 — the FORCED FLUSH before the AI reads the draft (the ruling: \"a forced\n * flush before … an AI proposal\"): the editor commits its uncommitted fields and the\n * persister lands them, so the translation's patches are made on the committed draft.\n * The translated buckets reach the open editor through the session (it rebases), so\n * there is no draft to hand back.\n */\n flushDraft: () => Promise<void>\n}\n\nexport function TranslateDocumentAction(props: TranslateDocumentActionProps) {\n const [open, setOpen] = useState(false)\n const { collection, localeConfig, localesEnabled, projectId } = props\n\n const eligible = useMemo(() => {\n const ai = resolveDeploymentAi()\n if (!ai || ai.enabled === false) return false\n if (!localesEnabled || projectId === undefined) return false\n const base = localeConfig.default\n if (!localeConfig.locales.some((l) => l !== base)) return false\n return collection.fields.some((f) => isFieldLocalized(collection, f.name))\n }, [collection, localeConfig, localesEnabled, projectId])\n\n if (!eligible) return null\n\n return (\n <>\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => setOpen(true)}\n data-testid=\"doc-translate\"\n title={translate('ai.translate.tooltip')}\n >\n <Languages /> {translate('ai.translate.action')}\n </Button>\n {open ? (\n <Suspense fallback={null}>\n <TranslateDocumentDialog {...props} open onOpenChange={setOpen} />\n </Suspense>\n ) : null}\n </>\n )\n}\n"]}
@@ -3,12 +3,12 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { createCollectionRegistry } from '@elytracms/core/cms-core';
4
4
  import { Check, Languages, Loader2, X } from 'lucide-react';
5
5
  import { Badge, Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Row, Stack, Text, } from '@elytracms/studio/ui';
6
- import { translate } from '@elytracms/studio/lib/i18n';
7
- import { localeChipLabel } from '@elytracms/studio/lib/locale';
8
- import { getStudioOperations } from '@elytracms/studio/lib/operations';
9
- import { resolveDeploymentAi } from '@elytracms/studio/lib/workspace';
10
- import { resolveAiConfig, resolveKnowledge, translateDocument } from '@elytracms/studio/lib/ai';
11
- import { cmsValidationIssueMessage } from '@elytracms/studio/lib/persona/labels';
6
+ import { translate } from '../../lib/i18n/index.js';
7
+ import { localeChipLabel } from '../../lib/locale/index.js';
8
+ import { getStudioOperations } from '../../lib/operations/index.js';
9
+ import { resolveDeploymentAi } from '../../lib/workspace/index.js';
10
+ import { resolveAiConfig, resolveKnowledge, translateDocument } from '../../lib/ai/index.js';
11
+ import { cmsValidationIssueMessage } from '../../lib/persona/labels.js';
12
12
  import { useCms } from '../cms/cms-store.js';
13
13
  import { TranslateSkipped } from './translate-skipped.js';
14
14
  export function TranslateDocumentDialog({ projectId, collection, docRef, document, localeConfig, flushDraft, open, onOpenChange, }) {
@@ -1 +1 @@
1
- {"version":3,"file":"translate-document-dialog.js","sourceRoot":"","sources":["../../../src/components/ai/translate-document-dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,GAAG,EACH,KAAK,EACL,IAAI,GACL,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,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,OAAO,EAAE,KAAK,EAAE,iBAAc,kBAAkB,YACzG,SAAS,CAAC,eAAe,CAAC,GACpB,CACV,CAAC,CAAC,CAAC,CACF,KAAC,MAAM,IAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,KAAK,iBAAc,iBAAiB,YAC5D,SAAS,CAAC,oBAAoB,CAAC,GACzB,CACV,GACY,IACD,GACT,CACV,CAAA;AACH,CAAC","sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { createCollectionRegistry } from '@elytracms/core/cms-core'\nimport { Check, Languages, Loader2, X } from 'lucide-react'\nimport {\n Badge,\n Button,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Row,\n Stack,\n Text,\n} from '@elytracms/studio/ui'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { localeChipLabel } from '@elytracms/studio/lib/locale'\nimport { getStudioOperations } from '@elytracms/studio/lib/operations'\nimport { resolveDeploymentAi } from '@elytracms/studio/lib/workspace'\nimport { resolveAiConfig, resolveKnowledge, translateDocument } from '@elytracms/studio/lib/ai'\nimport type { TranslateProgress, TranslateSkip } from '@elytracms/studio/lib/ai'\nimport { cmsValidationIssueMessage } from '@elytracms/studio/lib/persona/labels'\nimport { useCms } from '../cms/cms-store'\nimport type { TranslateDocumentActionProps } from './translate-document-action'\nimport { TranslateSkipped } from './translate-skipped'\n\n/**\n * The \"Translate document\" confirm + progress dialog (EC-332), heavy side — loaded lazily\n * by the gate so the AI engine stays off the critical path (EC-331 bundle discipline). A\n * modal is allowed here (a picker/confirmation, per the house rule — property forms are\n * not). It resolves the EC-331 provider + knowledge, runs the ONE `translateDocument`\n * engine over the live draft (fill-empty-only on EC-318 connection state), streams\n * progress, then writes the result to the DRAFT via the operations layer with a\n * provenance-tagged snapshot (mirroring the EC-199 apply) and reflects it into the open\n * editor. Cancel aborts cleanly — any already-translated units stay on the draft, visible\n * in Compare (EC-317) and rejectable via Discard (EC-316).\n */\ntype Phase = 'confirm' | 'running' | 'done' | 'error'\n\ninterface RunSummary {\n translated: number\n slugs: number\n locales: number\n cancelled: boolean\n nothing: boolean\n /** EC-593: every text position the run could not translate — listed, never silent. */\n skipped: readonly TranslateSkip[]\n}\n\nexport function TranslateDocumentDialog({\n projectId,\n collection,\n docRef,\n document,\n localeConfig,\n flushDraft,\n open,\n onOpenChange,\n}: TranslateDocumentActionProps & { open: boolean; onOpenChange: (open: boolean) => void }) {\n const [phase, setPhase] = useState<Phase>('confirm')\n const [progress, setProgress] = useState<TranslateProgress | null>(null)\n const [summary, setSummary] = useState<RunSummary | null>(null)\n /**\n * EC-497 — why the refusal was blocked, when the gate refused. Reuses the\n * EC-473 `ai.error.applyInvalid` copy (\"the proposal no longer fits the current\n * document: …\"), which is exactly this situation: no new catalog string, and the\n * editor is told WHICH rules the translation would have broken rather than a bare\n * \"failed\".\n */\n const [refusal, setRefusal] = useState<string | null>(null)\n const abortRef = useRef<AbortController | null>(null)\n const cms = useCms()\n // The session registry the produced draft is judged against. Built here rather\n // than added to the CMS store's public surface for one consumer; the memo means\n // once per open, not once per render.\n const registry = useMemo(() => createCollectionRegistry(cms.collections), [cms.collections])\n\n useEffect(() => () => abortRef.current?.abort(), [])\n\n const base = localeConfig.default\n const targets = localeConfig.locales.filter((l) => l !== base)\n\n const run = useCallback(async () => {\n if (projectId === undefined) {\n setPhase('error')\n return\n }\n const resolved = resolveAiConfig(resolveDeploymentAi())\n const provider = resolved.resolved?.provider\n if (!provider || !resolved.ok) {\n setPhase('error')\n return\n }\n const controller = new AbortController()\n abortRef.current = controller\n setRefusal(null)\n setPhase('running')\n await flushDraft()\n setProgress({ completed: 0, total: 0 })\n try {\n const knowledge = await resolveKnowledge(resolved.resolved?.knowledge ?? [])\n const result = await translateDocument({\n provider,\n collection,\n document,\n localeConfig,\n knowledge,\n signal: controller.signal,\n onProgress: setProgress,\n // EC-497 — this action used to hand `translateDocument`'s output STRAIGHT to\n // `documents.upsert` with nothing in between: no gate, no proposal card, no\n // re-validation, so model-generated content reached the document completely\n // unvalidated while the chat path validated twice. It now validates with the\n // session's canonical bag (`cms.validateOptions`) — the editor's own rules —\n // and refuses below on what the translation INTRODUCED.\n registry,\n validateOptions: cms.validateOptions,\n })\n if (result.introducedErrors.length > 0) {\n setRefusal(\n translate('ai.error.applyInvalid', {\n issues: result.introducedErrors\n .slice(0, 3)\n .map((issue) => cmsValidationIssueMessage(issue))\n .join('; '),\n }),\n )\n setPhase('error')\n return\n }\n if (result.translated > 0 || result.slugsDerived > 0) {\n // EC-595 A2: the translation persists as the patches of the buckets it filled\n // (never the whole document) — through the session's queue, at the revision\n // the editor's view is at; a bucket a colleague changed meanwhile is refused on\n // that field and shown there.\n const outcome = await cms.commitPatches(docRef, result.patches)\n if (outcome?.status === 'failed') {\n setPhase('error')\n return\n }\n const { operations } = await getStudioOperations()\n // Provenance: an AI-tagged version snapshot (best-effort — the draft already landed).\n try {\n await operations.documents.snapshot({\n projectId,\n ref: docRef,\n label: translate('cms.version.aiAuthoredTitle'),\n origin: 'assistant',\n })\n } catch {\n // ignore — provenance is additive\n }\n }\n setSummary({\n translated: result.translated,\n slugs: result.slugsDerived,\n locales: Object.keys(result.perLocale).length,\n cancelled: result.cancelled,\n nothing: result.total === 0 && result.skipped.length === 0,\n skipped: result.skipped,\n })\n setPhase('done')\n } catch {\n setPhase('error')\n } finally {\n abortRef.current = null\n }\n }, [projectId, collection, document, localeConfig, docRef, flushDraft, registry, cms])\n\n const close = () => {\n if (phase === 'running') return // never close mid-run — Cancel aborts instead\n onOpenChange(false)\n }\n\n const doneMessage = (s: RunSummary): string => {\n if (s.nothing) return translate('ai.translate.nothing')\n if (s.cancelled) return translate('ai.translate.cancelled')\n return translate('ai.translate.applied', { count: s.translated, locales: s.locales })\n }\n\n return (\n <Dialog open={open} onOpenChange={(next) => (!next ? close() : undefined)}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>\n <Row gap=\"2\" align=\"center\">\n <Languages className=\"size-4\" /> {translate('ai.translate.dialogTitle')}\n </Row>\n </DialogTitle>\n <DialogDescription>\n {translate('ai.translate.dialogDescription', { base: localeChipLabel(base) })}\n </DialogDescription>\n </DialogHeader>\n\n {phase === 'confirm' ? (\n <Stack gap=\"4\" className=\"py-2\">\n <Stack gap=\"1\">\n <Text size=\"xs\" weight=\"medium\" tone=\"muted\">\n {translate('ai.translate.targetsLabel')}\n </Text>\n <Row gap=\"1\" wrap>\n {targets.map((l) => (\n <Badge key={l} variant=\"outline\">\n {localeChipLabel(l)}\n </Badge>\n ))}\n </Row>\n </Stack>\n <Stack gap=\"1\">\n <Text size=\"xs\" weight=\"medium\" tone=\"muted\">\n {translate('ai.translate.scopeLabel')}\n </Text>\n <Row gap=\"2\" align=\"center\">\n <Badge variant=\"default\">{translate('ai.translate.fillMissing')}</Badge>\n <Button size=\"sm\" variant=\"ghost\" disabled title={translate('ai.translate.retranslateSoon')}>\n {translate('ai.translate.retranslateAll')}\n </Button>\n <Text size=\"xs\" tone=\"muted\">\n {translate('ai.translate.retranslateSoon')}\n </Text>\n </Row>\n </Stack>\n </Stack>\n ) : null}\n\n {phase === 'running' ? (\n <Stack gap=\"3\" align=\"center\" className=\"py-6\">\n <Loader2 className=\"size-6 animate-spin text-primary\" />\n <Text size=\"sm\" tone=\"muted\" data-testid=\"translate-progress\">\n {progress && progress.total > 0\n ? translate('ai.translate.progress', { completed: progress.completed, total: progress.total })\n : translate('ai.translate.preparing')}\n </Text>\n {progress && progress.total > 0 ? (\n <div className=\"h-1.5 w-56 overflow-hidden rounded-full bg-muted\">\n <div\n className=\"h-full rounded-full bg-primary transition-all\"\n style={{ width: `${Math.round((progress.completed / progress.total) * 100)}%` }}\n />\n </div>\n ) : null}\n </Stack>\n ) : null}\n\n {phase === 'done' && summary ? (\n <Stack gap=\"2\" align=\"center\" className=\"py-6\">\n <Check className=\"size-6 text-success\" />\n <Text size=\"sm\" tone=\"muted\" className=\"text-center\" data-testid=\"translate-summary\">\n {doneMessage(summary)}\n </Text>\n <TranslateSkipped skipped={summary.skipped} collection={collection} />\n </Stack>\n ) : null}\n\n {phase === 'error' ? (\n <Stack gap=\"2\" align=\"center\" className=\"py-6\">\n <X className=\"size-6 text-destructive\" />\n <Text size=\"sm\" tone=\"muted\" className=\"text-center\" data-testid=\"translate-error\">\n {refusal ?? translate('ai.translate.failed')}\n </Text>\n </Stack>\n ) : null}\n\n <DialogFooter className=\"mt-2\">\n {phase === 'confirm' ? (\n <>\n <Button variant=\"ghost\" size=\"sm\" onClick={close}>\n {translate('common.cancel')}\n </Button>\n <Button size=\"sm\" onClick={() => void run()} data-testid=\"translate-confirm\">\n <Languages /> {translate('ai.translate.confirm')}\n </Button>\n </>\n ) : phase === 'running' ? (\n <Button variant=\"outline\" size=\"sm\" onClick={() => abortRef.current?.abort()} data-testid=\"translate-cancel\">\n {translate('common.cancel')}\n </Button>\n ) : (\n <Button size=\"sm\" onClick={close} data-testid=\"translate-close\">\n {translate('ai.translate.close')}\n </Button>\n )}\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n"]}
1
+ {"version":3,"file":"translate-document-dialog.js","sourceRoot":"","sources":["../../../src/components/ai/translate-document-dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,GAAG,EACH,KAAK,EACL,IAAI,GACL,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,eAAe,E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AK,KAAK,SAAS,CAAC,CAAC,CAAC,CACxB,KAAC,MAAM,IAAC,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,iBAAc,kBAAkB,YACzG,SAAS,CAAC,eAAe,CAAC,GACpB,CACV,CAAC,CAAC,CAAC,CACF,KAAC,MAAM,IAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,KAAK,iBAAc,iBAAiB,YAC5D,SAAS,CAAC,oBAAoB,CAAC,GACzB,CACV,GACY,IACD,GACT,CACV,CAAA;AACH,CAAC","sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { createCollectionRegistry } from '@elytracms/core/cms-core'\nimport { Check, Languages, Loader2, X } from 'lucide-react'\nimport {\n Badge,\n Button,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Row,\n Stack,\n Text,\n} from '@elytracms/studio/ui'\nimport { translate } from '../../lib/i18n'\nimport { localeChipLabel } from '../../lib/locale'\nimport { getStudioOperations } from '../../lib/operations'\nimport { resolveDeploymentAi } from '../../lib/workspace'\nimport { resolveAiConfig, resolveKnowledge, translateDocument } from '../../lib/ai'\nimport type { TranslateProgress, TranslateSkip } from '../../lib/ai'\nimport { cmsValidationIssueMessage } from '../../lib/persona/labels'\nimport { useCms } from '../cms/cms-store'\nimport type { TranslateDocumentActionProps } from './translate-document-action'\nimport { TranslateSkipped } from './translate-skipped'\n\n/**\n * The \"Translate document\" confirm + progress dialog (EC-332), heavy side — loaded lazily\n * by the gate so the AI engine stays off the critical path (EC-331 bundle discipline). A\n * modal is allowed here (a picker/confirmation, per the house rule — property forms are\n * not). It resolves the EC-331 provider + knowledge, runs the ONE `translateDocument`\n * engine over the live draft (fill-empty-only on EC-318 connection state), streams\n * progress, then writes the result to the DRAFT via the operations layer with a\n * provenance-tagged snapshot (mirroring the EC-199 apply) and reflects it into the open\n * editor. Cancel aborts cleanly — any already-translated units stay on the draft, visible\n * in Compare (EC-317) and rejectable via Discard (EC-316).\n */\ntype Phase = 'confirm' | 'running' | 'done' | 'error'\n\ninterface RunSummary {\n translated: number\n slugs: number\n locales: number\n cancelled: boolean\n nothing: boolean\n /** EC-593: every text position the run could not translate — listed, never silent. */\n skipped: readonly TranslateSkip[]\n}\n\nexport function TranslateDocumentDialog({\n projectId,\n collection,\n docRef,\n document,\n localeConfig,\n flushDraft,\n open,\n onOpenChange,\n}: TranslateDocumentActionProps & { open: boolean; onOpenChange: (open: boolean) => void }) {\n const [phase, setPhase] = useState<Phase>('confirm')\n const [progress, setProgress] = useState<TranslateProgress | null>(null)\n const [summary, setSummary] = useState<RunSummary | null>(null)\n /**\n * EC-497 — why the refusal was blocked, when the gate refused. Reuses the\n * EC-473 `ai.error.applyInvalid` copy (\"the proposal no longer fits the current\n * document: …\"), which is exactly this situation: no new catalog string, and the\n * editor is told WHICH rules the translation would have broken rather than a bare\n * \"failed\".\n */\n const [refusal, setRefusal] = useState<string | null>(null)\n const abortRef = useRef<AbortController | null>(null)\n const cms = useCms()\n // The session registry the produced draft is judged against. Built here rather\n // than added to the CMS store's public surface for one consumer; the memo means\n // once per open, not once per render.\n const registry = useMemo(() => createCollectionRegistry(cms.collections), [cms.collections])\n\n useEffect(() => () => abortRef.current?.abort(), [])\n\n const base = localeConfig.default\n const targets = localeConfig.locales.filter((l) => l !== base)\n\n const run = useCallback(async () => {\n if (projectId === undefined) {\n setPhase('error')\n return\n }\n const resolved = resolveAiConfig(resolveDeploymentAi())\n const provider = resolved.resolved?.provider\n if (!provider || !resolved.ok) {\n setPhase('error')\n return\n }\n const controller = new AbortController()\n abortRef.current = controller\n setRefusal(null)\n setPhase('running')\n await flushDraft()\n setProgress({ completed: 0, total: 0 })\n try {\n const knowledge = await resolveKnowledge(resolved.resolved?.knowledge ?? [])\n const result = await translateDocument({\n provider,\n collection,\n document,\n localeConfig,\n knowledge,\n signal: controller.signal,\n onProgress: setProgress,\n // EC-497 — this action used to hand `translateDocument`'s output STRAIGHT to\n // `documents.upsert` with nothing in between: no gate, no proposal card, no\n // re-validation, so model-generated content reached the document completely\n // unvalidated while the chat path validated twice. It now validates with the\n // session's canonical bag (`cms.validateOptions`) — the editor's own rules —\n // and refuses below on what the translation INTRODUCED.\n registry,\n validateOptions: cms.validateOptions,\n })\n if (result.introducedErrors.length > 0) {\n setRefusal(\n translate('ai.error.applyInvalid', {\n issues: result.introducedErrors\n .slice(0, 3)\n .map((issue) => cmsValidationIssueMessage(issue))\n .join('; '),\n }),\n )\n setPhase('error')\n return\n }\n if (result.translated > 0 || result.slugsDerived > 0) {\n // EC-595 A2: the translation persists as the patches of the buckets it filled\n // (never the whole document) — through the session's queue, at the revision\n // the editor's view is at; a bucket a colleague changed meanwhile is refused on\n // that field and shown there.\n const outcome = await cms.commitPatches(docRef, result.patches)\n if (outcome?.status === 'failed') {\n setPhase('error')\n return\n }\n const { operations } = await getStudioOperations()\n // Provenance: an AI-tagged version snapshot (best-effort — the draft already landed).\n try {\n await operations.documents.snapshot({\n projectId,\n ref: docRef,\n label: translate('cms.version.aiAuthoredTitle'),\n origin: 'assistant',\n })\n } catch {\n // ignore — provenance is additive\n }\n }\n setSummary({\n translated: result.translated,\n slugs: result.slugsDerived,\n locales: Object.keys(result.perLocale).length,\n cancelled: result.cancelled,\n nothing: result.total === 0 && result.skipped.length === 0,\n skipped: result.skipped,\n })\n setPhase('done')\n } catch {\n setPhase('error')\n } finally {\n abortRef.current = null\n }\n }, [projectId, collection, document, localeConfig, docRef, flushDraft, registry, cms])\n\n const close = () => {\n if (phase === 'running') return // never close mid-run — Cancel aborts instead\n onOpenChange(false)\n }\n\n const doneMessage = (s: RunSummary): string => {\n if (s.nothing) return translate('ai.translate.nothing')\n if (s.cancelled) return translate('ai.translate.cancelled')\n return translate('ai.translate.applied', { count: s.translated, locales: s.locales })\n }\n\n return (\n <Dialog open={open} onOpenChange={(next) => (!next ? close() : undefined)}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>\n <Row gap=\"2\" align=\"center\">\n <Languages className=\"size-4\" /> {translate('ai.translate.dialogTitle')}\n </Row>\n </DialogTitle>\n <DialogDescription>\n {translate('ai.translate.dialogDescription', { base: localeChipLabel(base) })}\n </DialogDescription>\n </DialogHeader>\n\n {phase === 'confirm' ? (\n <Stack gap=\"4\" className=\"py-2\">\n <Stack gap=\"1\">\n <Text size=\"xs\" weight=\"medium\" tone=\"muted\">\n {translate('ai.translate.targetsLabel')}\n </Text>\n <Row gap=\"1\" wrap>\n {targets.map((l) => (\n <Badge key={l} variant=\"outline\">\n {localeChipLabel(l)}\n </Badge>\n ))}\n </Row>\n </Stack>\n <Stack gap=\"1\">\n <Text size=\"xs\" weight=\"medium\" tone=\"muted\">\n {translate('ai.translate.scopeLabel')}\n </Text>\n <Row gap=\"2\" align=\"center\">\n <Badge variant=\"default\">{translate('ai.translate.fillMissing')}</Badge>\n <Button size=\"sm\" variant=\"ghost\" disabled title={translate('ai.translate.retranslateSoon')}>\n {translate('ai.translate.retranslateAll')}\n </Button>\n <Text size=\"xs\" tone=\"muted\">\n {translate('ai.translate.retranslateSoon')}\n </Text>\n </Row>\n </Stack>\n </Stack>\n ) : null}\n\n {phase === 'running' ? (\n <Stack gap=\"3\" align=\"center\" className=\"py-6\">\n <Loader2 className=\"size-6 animate-spin text-primary\" />\n <Text size=\"sm\" tone=\"muted\" data-testid=\"translate-progress\">\n {progress && progress.total > 0\n ? translate('ai.translate.progress', { completed: progress.completed, total: progress.total })\n : translate('ai.translate.preparing')}\n </Text>\n {progress && progress.total > 0 ? (\n <div className=\"h-1.5 w-56 overflow-hidden rounded-full bg-muted\">\n <div\n className=\"h-full rounded-full bg-primary transition-all\"\n style={{ width: `${Math.round((progress.completed / progress.total) * 100)}%` }}\n />\n </div>\n ) : null}\n </Stack>\n ) : null}\n\n {phase === 'done' && summary ? (\n <Stack gap=\"2\" align=\"center\" className=\"py-6\">\n <Check className=\"size-6 text-success\" />\n <Text size=\"sm\" tone=\"muted\" className=\"text-center\" data-testid=\"translate-summary\">\n {doneMessage(summary)}\n </Text>\n <TranslateSkipped skipped={summary.skipped} collection={collection} />\n </Stack>\n ) : null}\n\n {phase === 'error' ? (\n <Stack gap=\"2\" align=\"center\" className=\"py-6\">\n <X className=\"size-6 text-destructive\" />\n <Text size=\"sm\" tone=\"muted\" className=\"text-center\" data-testid=\"translate-error\">\n {refusal ?? translate('ai.translate.failed')}\n </Text>\n </Stack>\n ) : null}\n\n <DialogFooter className=\"mt-2\">\n {phase === 'confirm' ? (\n <>\n <Button variant=\"ghost\" size=\"sm\" onClick={close}>\n {translate('common.cancel')}\n </Button>\n <Button size=\"sm\" onClick={() => void run()} data-testid=\"translate-confirm\">\n <Languages /> {translate('ai.translate.confirm')}\n </Button>\n </>\n ) : phase === 'running' ? (\n <Button variant=\"outline\" size=\"sm\" onClick={() => abortRef.current?.abort()} data-testid=\"translate-cancel\">\n {translate('common.cancel')}\n </Button>\n ) : (\n <Button size=\"sm\" onClick={close} data-testid=\"translate-close\">\n {translate('ai.translate.close')}\n </Button>\n )}\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { CollectionDef } from '@elytracms/core/cms-core';
2
- import type { TranslateSkip } from '@elytracms/studio/lib/ai';
2
+ import type { TranslateSkip } from '../../lib/ai/index.js';
3
3
  /** One skip as the editor reads it: where (field label › component › position), which language, why. */
4
4
  export interface TranslateSkipLine {
5
5
  where: string;
@@ -2,8 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { resolveLabel } from '@elytracms/core/cms-core';
3
3
  import { AlertTriangle } from 'lucide-react';
4
4
  import { Row, Stack, Text } from '@elytracms/studio/ui';
5
- import { translate } from '@elytracms/studio/lib/i18n';
6
- import { localeChipLabel } from '@elytracms/studio/lib/locale';
5
+ import { translate } from '../../lib/i18n/index.js';
6
+ import { localeChipLabel } from '../../lib/locale/index.js';
7
7
  /**
8
8
  * EC-593 (ratified 4e) — what a translation run could NOT translate, shown where the
9
9
  * editor reads the outcome: the "Translate document" dialog and the chat's translation
@@ -1 +1 @@
1
- {"version":3,"file":"translate-skipped.js","sourceRoot":"","sources":["../../../src/components/ai/translate-skipped.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAG9D;;;;;GAKG;AAEH,MAAM,UAAU,GAAwC;IACtD,UAAU,EAAE,iCAAiC;IAC7C,cAAc,EAAE,kCAAkC;IAClD,mBAAmB,EAAE,uCAAuC;CAC7D,CAAA;AASD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAiC,EACjC,UAAqC;IAErC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC1B,MAAM,KAAK,GAAG,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,CAAA;QACnE,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAA;QAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS;YAC1B,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;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,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,0CACrC,IAAI,CAAC,KAAK,QAAI,IAAI,CAAC,MAAM,eAAM,IAAI,CAAC,MAAM,KADlC,KAAK,CAET,CACR,CAAC,IACI,CACT,CAAA;AACH,CAAC","sourcesContent":["import { resolveLabel } from '@elytracms/core/cms-core'\nimport type { CollectionDef } from '@elytracms/core/cms-core'\nimport { AlertTriangle } from 'lucide-react'\nimport { Row, Stack, Text } from '@elytracms/studio/ui'\nimport { translate } from '@elytracms/studio/lib/i18n'\nimport { localeChipLabel } from '@elytracms/studio/lib/locale'\nimport type { TranslateSkip, TranslateSkipReason } from '@elytracms/studio/lib/ai'\n\n/**\n * EC-593 (ratified 4e) — what a translation run could NOT translate, shown where the\n * editor reads the outcome: the \"Translate document\" dialog and the chat's translation\n * proposal card. Before, a localized object or composition was skipped with no word,\n * and a garbled rich-text block silently kept its original.\n */\n\nconst REASON_KEY: Record<TranslateSkipReason, string> = {\n unreadable: 'ai.translate.skipped.unreadable',\n 'not-returned': 'ai.translate.skipped.notReturned',\n 'structure-changed': 'ai.translate.skipped.structureChanged',\n}\n\n/** One skip as the editor reads it: where (field label › component › position), which language, why. */\nexport interface TranslateSkipLine {\n where: string\n locale: string\n reason: string\n}\n\n/**\n * The where-label of a skipped position: the field's label, then — inside a component —\n * the component and its prop path, else the position below the field (an item counted\n * from 1). Index-bearing segments the editor does not see (`content`, `props`) are left out.\n */\nexport function translateSkipLines(\n skipped: readonly TranslateSkip[],\n collection: CollectionDef | undefined,\n): TranslateSkipLine[] {\n return skipped.map((skip) => {\n const field = collection?.fields.find((f) => f.name === skip.field)\n const label = resolveLabel(field?.form?.label) ?? skip.field\n const below = skip.component\n ? [skip.component.componentId, ...skip.at.slice(skip.at.lastIndexOf('props') + 1)]\n : skip.at\n const segments = below\n .filter((segment) => segment !== 'content' && segment !== 'props')\n .map((segment) => (typeof segment === 'number' ? `#${segment + 1}` : segment))\n return {\n where: [label, ...segments].join(' › '),\n locale: localeChipLabel(skip.locale),\n reason: translate(REASON_KEY[skip.reason]),\n }\n })\n}\n\n/** The list; renders nothing when everything was translated. */\nexport function TranslateSkipped({\n skipped,\n collection,\n}: {\n skipped: readonly TranslateSkip[]\n collection: CollectionDef | undefined\n}) {\n if (skipped.length === 0) return null\n return (\n <Stack gap=\"1\" data-testid=\"translate-skipped\">\n <Row gap=\"1\" align=\"center\">\n <AlertTriangle className=\"size-3.5 text-warning\" />\n <Text size=\"xs\" weight=\"medium\">\n {translate('ai.translate.skippedTitle', { count: skipped.length })}\n </Text>\n </Row>\n {translateSkipLines(skipped, collection).map((line, index) => (\n <Text key={index} size=\"xs\" tone=\"muted\" data-translate-skip>\n {line.where} ({line.locale}) — {line.reason}\n </Text>\n ))}\n </Stack>\n )\n}\n"]}
1
+ {"version":3,"file":"translate-skipped.js","sourceRoot":"","sources":["../../../src/components/ai/translate-skipped.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAGlD;;;;;GAKG;AAEH,MAAM,UAAU,GAAwC;IACtD,UAAU,EAAE,iCAAiC;IAC7C,cAAc,EAAE,kCAAkC;IAClD,mBAAmB,EAAE,uCAAuC;CAC7D,CAAA;AASD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAiC,EACjC,UAAqC;IAErC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC1B,MAAM,KAAK,GAAG,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI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,aACzB,KAAC,aAAa,IAAC,SAAS,EAAC,uBAAuB,GAAG,EACnD,KAAC,IAAI,IAAC,IAAI,EAAC,IAAI,EAAC,MAAM,EAAC,QAAQ,YAC5B,SAAS,CAAC,2BAA2B,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,GAC7D,IACH,EACL,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAC5D,MAAC,IAAI,IAAa,IAAI,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,0CACrC,IAAI,CAAC,KAAK,QAAI,IAAI,CAAC,MAAM,eAAM,IAAI,CAAC,MAAM,KADlC,KAAK,CAET,CACR,CAAC,IACI,CACT,CAAA;AACH,CAAC","sourcesContent":["import { resolveLabel } from '@elytracms/core/cms-core'\nimport type { CollectionDef } from '@elytracms/core/cms-core'\nimport { AlertTriangle } from 'lucide-react'\nimport { Row, Stack, Text } from '@elytracms/studio/ui'\nimport { translate } from '../../lib/i18n'\nimport { localeChipLabel } from '../../lib/locale'\nimport type { TranslateSkip, TranslateSkipReason } from '../../lib/ai'\n\n/**\n * EC-593 (ratified 4e) — what a translation run could NOT translate, shown where the\n * editor reads the outcome: the \"Translate document\" dialog and the chat's translation\n * proposal card. Before, a localized object or composition was skipped with no word,\n * and a garbled rich-text block silently kept its original.\n */\n\nconst REASON_KEY: Record<TranslateSkipReason, string> = {\n unreadable: 'ai.translate.skipped.unreadable',\n 'not-returned': 'ai.translate.skipped.notReturned',\n 'structure-changed': 'ai.translate.skipped.structureChanged',\n}\n\n/** One skip as the editor reads it: where (field label › component › position), which language, why. */\nexport interface TranslateSkipLine {\n where: string\n locale: string\n reason: string\n}\n\n/**\n * The where-label of a skipped position: the field's label, then — inside a component —\n * the component and its prop path, else the position below the field (an item counted\n * from 1). Index-bearing segments the editor does not see (`content`, `props`) are left out.\n */\nexport function translateSkipLines(\n skipped: readonly TranslateSkip[],\n collection: CollectionDef | undefined,\n): TranslateSkipLine[] {\n return skipped.map((skip) => {\n const field = collection?.fields.find((f) => f.name === skip.field)\n const label = resolveLabel(field?.form?.label) ?? skip.field\n const below = skip.component\n ? [skip.component.componentId, ...skip.at.slice(skip.at.lastIndexOf('props') + 1)]\n : skip.at\n const segments = below\n .filter((segment) => segment !== 'content' && segment !== 'props')\n .map((segment) => (typeof segment === 'number' ? `#${segment + 1}` : segment))\n return {\n where: [label, ...segments].join(' › '),\n locale: localeChipLabel(skip.locale),\n reason: translate(REASON_KEY[skip.reason]),\n }\n })\n}\n\n/** The list; renders nothing when everything was translated. */\nexport function TranslateSkipped({\n skipped,\n collection,\n}: {\n skipped: readonly TranslateSkip[]\n collection: CollectionDef | undefined\n}) {\n if (skipped.length === 0) return null\n return (\n <Stack gap=\"1\" data-testid=\"translate-skipped\">\n <Row gap=\"1\" align=\"center\">\n <AlertTriangle className=\"size-3.5 text-warning\" />\n <Text size=\"xs\" weight=\"medium\">\n {translate('ai.translate.skippedTitle', { count: skipped.length })}\n </Text>\n </Row>\n {translateSkipLines(skipped, collection).map((line, index) => (\n <Text key={index} size=\"xs\" tone=\"muted\" data-translate-skip>\n {line.where} ({line.locale}) — {line.reason}\n </Text>\n ))}\n </Stack>\n )\n}\n"]}