@aglyn/plugins-ai 1.0.0-beta.228 → 1.0.0-beta.230

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 (274) hide show
  1. package/README.md +3 -3
  2. package/package.json +17 -17
  3. package/src/lib/activity/ai-activity-actions.js +7 -1
  4. package/src/lib/activity/ai-activity-actions.js.map +1 -1
  5. package/src/lib/components/ai-automation-zones.d.ts +38 -0
  6. package/src/lib/components/ai-automation-zones.js +5 -1
  7. package/src/lib/components/ai-automation-zones.js.map +1 -1
  8. package/src/lib/components/ai-brief-dialog.component.d.ts +20 -2
  9. package/src/lib/components/ai-brief-dialog.component.js +87 -8
  10. package/src/lib/components/ai-brief-dialog.component.js.map +1 -1
  11. package/src/lib/components/ai-campaign-create.component.d.ts +54 -0
  12. package/src/lib/components/ai-campaign-create.component.js +270 -0
  13. package/src/lib/components/ai-campaign-create.component.js.map +1 -0
  14. package/src/lib/components/ai-describe-automation.component.d.ts +8 -3
  15. package/src/lib/components/ai-describe-automation.component.js +15 -6
  16. package/src/lib/components/ai-describe-automation.component.js.map +1 -1
  17. package/src/lib/components/ai-describe-button.component.d.ts +20 -8
  18. package/src/lib/components/ai-describe-button.component.js +19 -36
  19. package/src/lib/components/ai-describe-button.component.js.map +1 -1
  20. package/src/lib/components/ai-describe-email.component.d.ts +31 -0
  21. package/src/lib/components/ai-describe-email.component.js +22 -0
  22. package/src/lib/components/ai-describe-email.component.js.map +1 -0
  23. package/src/lib/components/ai-describe-org-automation.component.d.ts +36 -0
  24. package/src/lib/components/ai-describe-org-automation.component.js +238 -0
  25. package/src/lib/components/ai-describe-org-automation.component.js.map +1 -0
  26. package/src/lib/components/ai-experiment-cards.component.d.ts +9 -1
  27. package/src/lib/components/ai-experiment-cards.component.js +104 -18
  28. package/src/lib/components/ai-experiment-cards.component.js.map +1 -1
  29. package/src/lib/components/ai-explain-automation.component.js +1 -5
  30. package/src/lib/components/ai-explain-automation.component.js.map +1 -1
  31. package/src/lib/components/ai-funnel-zones.component.d.ts +61 -0
  32. package/src/lib/components/ai-funnel-zones.component.js +178 -0
  33. package/src/lib/components/ai-funnel-zones.component.js.map +1 -0
  34. package/src/lib/components/ai-insight-card.component.d.ts +42 -0
  35. package/src/lib/components/ai-insight-card.component.js +137 -0
  36. package/src/lib/components/ai-insight-card.component.js.map +1 -0
  37. package/src/lib/components/ai-insight-dialog.component.d.ts +6 -0
  38. package/src/lib/components/ai-insight-dialog.component.js +9 -3
  39. package/src/lib/components/ai-insight-dialog.component.js.map +1 -1
  40. package/src/lib/components/ai-job-plan.component.d.ts +7 -2
  41. package/src/lib/components/ai-job-plan.component.js +35 -5
  42. package/src/lib/components/ai-job-plan.component.js.map +1 -1
  43. package/src/lib/components/ai-job-requests.d.ts +17 -1
  44. package/src/lib/components/ai-job-requests.js +39 -3
  45. package/src/lib/components/ai-job-requests.js.map +1 -1
  46. package/src/lib/components/ai-jobs-list-page.component.js +12 -1
  47. package/src/lib/components/ai-jobs-list-page.component.js.map +1 -1
  48. package/src/lib/components/ai-logic-zones.d.ts +64 -0
  49. package/src/lib/components/ai-logic-zones.js +18 -0
  50. package/src/lib/components/ai-logic-zones.js.map +1 -0
  51. package/src/lib/components/ai-logic.component.d.ts +77 -0
  52. package/src/lib/components/ai-logic.component.js +553 -0
  53. package/src/lib/components/ai-logic.component.js.map +1 -0
  54. package/src/lib/components/ai-marketing-insight.component.d.ts +30 -0
  55. package/src/lib/components/ai-marketing-insight.component.js +80 -0
  56. package/src/lib/components/ai-marketing-insight.component.js.map +1 -0
  57. package/src/lib/components/ai-media-create.component.d.ts +55 -0
  58. package/src/lib/components/ai-media-create.component.js +433 -0
  59. package/src/lib/components/ai-media-create.component.js.map +1 -0
  60. package/src/lib/components/ai-overlay-cards.component.d.ts +83 -0
  61. package/src/lib/components/ai-overlay-cards.component.js +505 -0
  62. package/src/lib/components/ai-overlay-cards.component.js.map +1 -0
  63. package/src/lib/components/ai-product-zones.d.ts +5 -0
  64. package/src/lib/components/ai-product-zones.js +1 -1
  65. package/src/lib/components/ai-product-zones.js.map +1 -1
  66. package/src/lib/components/ai-products-create-button.component.d.ts +42 -0
  67. package/src/lib/components/ai-products-create-button.component.js +67 -0
  68. package/src/lib/components/ai-products-create-button.component.js.map +1 -0
  69. package/src/lib/components/ai-products-hub-card.component.js +100 -81
  70. package/src/lib/components/ai-products-hub-card.component.js.map +1 -1
  71. package/src/lib/components/ai-revise-automation.component.d.ts +16 -0
  72. package/src/lib/components/ai-revise-automation.component.js +207 -0
  73. package/src/lib/components/ai-revise-automation.component.js.map +1 -0
  74. package/src/lib/components/ai-site-build-page.component.d.ts +1 -1
  75. package/src/lib/components/ai-site-build-page.component.js +177 -20
  76. package/src/lib/components/ai-site-build-page.component.js.map +1 -1
  77. package/src/lib/components/ai-site-start-card.component.d.ts +10 -1
  78. package/src/lib/components/ai-site-start-card.component.js +7 -4
  79. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  80. package/src/lib/components/ai-upsell-dialog.component.d.ts +53 -0
  81. package/src/lib/components/ai-upsell-dialog.component.js +177 -0
  82. package/src/lib/components/ai-upsell-dialog.component.js.map +1 -0
  83. package/src/lib/components/assist-build-card.component.d.ts +42 -0
  84. package/src/lib/components/assist-build-card.component.js +183 -0
  85. package/src/lib/components/assist-build-card.component.js.map +1 -0
  86. package/src/lib/components/assist-edit-canvas.d.ts +2 -0
  87. package/src/lib/components/assist-edit-canvas.js +56 -1
  88. package/src/lib/components/assist-edit-canvas.js.map +1 -1
  89. package/src/lib/components/assist-jobs-drawer.component.d.ts +11 -0
  90. package/src/lib/components/assist-jobs-drawer.component.js +85 -4
  91. package/src/lib/components/assist-jobs-drawer.component.js.map +1 -1
  92. package/src/lib/components/assist-panel.component.js +51 -2
  93. package/src/lib/components/assist-panel.component.js.map +1 -1
  94. package/src/lib/components/use-ai-job-run.d.ts +3 -14
  95. package/src/lib/components/use-ai-job-run.js +0 -50
  96. package/src/lib/components/use-ai-job-run.js.map +1 -1
  97. package/src/lib/jobs/ai-build-capabilities.d.ts +58 -0
  98. package/src/lib/jobs/ai-build-capabilities.js +256 -0
  99. package/src/lib/jobs/ai-build-capabilities.js.map +1 -0
  100. package/src/lib/jobs/ai-build-unit-outcome.d.ts +52 -0
  101. package/src/lib/jobs/ai-build-unit-outcome.js +138 -0
  102. package/src/lib/jobs/ai-build-unit-outcome.js.map +1 -0
  103. package/src/lib/jobs/ai-job-build-step.d.ts +144 -0
  104. package/src/lib/jobs/ai-job-build-step.js +657 -0
  105. package/src/lib/jobs/ai-job-build-step.js.map +1 -0
  106. package/src/lib/jobs/ai-job-draft-ids.js +9 -1
  107. package/src/lib/jobs/ai-job-draft-ids.js.map +1 -1
  108. package/src/lib/jobs/ai-job-drafts.d.ts +14 -4
  109. package/src/lib/jobs/ai-job-drafts.js +25 -4
  110. package/src/lib/jobs/ai-job-drafts.js.map +1 -1
  111. package/src/lib/jobs/ai-job-layout-site-pages.d.ts +70 -0
  112. package/src/lib/jobs/ai-job-layout-site-pages.js +216 -0
  113. package/src/lib/jobs/ai-job-layout-site-pages.js.map +1 -0
  114. package/src/lib/jobs/ai-job-layout-step.d.ts +2 -2
  115. package/src/lib/jobs/ai-job-layout-step.js +19 -1
  116. package/src/lib/jobs/ai-job-layout-step.js.map +1 -1
  117. package/src/lib/jobs/ai-job-logic-step.d.ts +107 -0
  118. package/src/lib/jobs/ai-job-logic-step.js +395 -0
  119. package/src/lib/jobs/ai-job-logic-step.js.map +1 -0
  120. package/src/lib/jobs/ai-job-overlay-copy.d.ts +70 -0
  121. package/src/lib/jobs/ai-job-overlay-copy.js +178 -0
  122. package/src/lib/jobs/ai-job-overlay-copy.js.map +1 -0
  123. package/src/lib/jobs/ai-job-page-step.js +6 -6
  124. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  125. package/src/lib/jobs/ai-job-plan-step.d.ts +26 -1
  126. package/src/lib/jobs/ai-job-plan-step.js +79 -11
  127. package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
  128. package/src/lib/jobs/ai-job-site-step.d.ts +15 -1
  129. package/src/lib/jobs/ai-job-site-step.js +207 -58
  130. package/src/lib/jobs/ai-job-site-step.js.map +1 -1
  131. package/src/lib/jobs/ai-job-text-step.d.ts +22 -1
  132. package/src/lib/jobs/ai-job-text-step.js +12 -0
  133. package/src/lib/jobs/ai-job-text-step.js.map +1 -1
  134. package/src/lib/jobs/ai-job-workflow-step.d.ts +54 -4
  135. package/src/lib/jobs/ai-job-workflow-step.js +318 -13
  136. package/src/lib/jobs/ai-job-workflow-step.js.map +1 -1
  137. package/src/lib/jobs/ai-jobs.d.ts +90 -2
  138. package/src/lib/jobs/ai-jobs.js +495 -61
  139. package/src/lib/jobs/ai-jobs.js.map +1 -1
  140. package/src/lib/jobs/ai-logic-records.d.ts +40 -0
  141. package/src/lib/jobs/ai-logic-records.js +55 -0
  142. package/src/lib/jobs/ai-logic-records.js.map +1 -0
  143. package/src/lib/jobs/ai-site-publish.d.ts +7 -0
  144. package/src/lib/jobs/ai-site-publish.js +9 -0
  145. package/src/lib/jobs/ai-site-publish.js.map +1 -1
  146. package/src/lib/jobs/ai-workflow-records.d.ts +4 -0
  147. package/src/lib/jobs/ai-workflow-records.js +40 -1
  148. package/src/lib/jobs/ai-workflow-records.js.map +1 -1
  149. package/src/lib/model/ai-automation-draft.d.ts +18 -0
  150. package/src/lib/model/ai-automation-draft.js +86 -0
  151. package/src/lib/model/ai-automation-draft.js.map +1 -1
  152. package/src/lib/model/ai-build-job.d.ts +201 -0
  153. package/src/lib/model/ai-build-job.js +471 -0
  154. package/src/lib/model/ai-build-job.js.map +1 -0
  155. package/src/lib/model/ai-build-plan.d.ts +61 -0
  156. package/src/lib/model/ai-build-plan.js +154 -9
  157. package/src/lib/model/ai-build-plan.js.map +1 -1
  158. package/src/lib/model/ai-build-progress.d.ts +56 -0
  159. package/src/lib/model/ai-build-progress.js +128 -0
  160. package/src/lib/model/ai-build-progress.js.map +1 -0
  161. package/src/lib/model/ai-insight.d.ts +20 -10
  162. package/src/lib/model/ai-insight.js +72 -9
  163. package/src/lib/model/ai-insight.js.map +1 -1
  164. package/src/lib/model/ai-job-activity.js +3 -1
  165. package/src/lib/model/ai-job-activity.js.map +1 -1
  166. package/src/lib/model/ai-job-failure-copy.d.ts +20 -1
  167. package/src/lib/model/ai-job-failure-copy.js +28 -1
  168. package/src/lib/model/ai-job-failure-copy.js.map +1 -1
  169. package/src/lib/model/ai-job-notice.d.ts +3 -0
  170. package/src/lib/model/ai-job-notice.js +11 -2
  171. package/src/lib/model/ai-job-notice.js.map +1 -1
  172. package/src/lib/model/ai-jobs.types.d.ts +87 -2
  173. package/src/lib/model/ai-jobs.types.js +3 -1
  174. package/src/lib/model/ai-jobs.types.js.map +1 -1
  175. package/src/lib/model/ai-logic-job.d.ts +108 -0
  176. package/src/lib/model/ai-logic-job.js +327 -0
  177. package/src/lib/model/ai-logic-job.js.map +1 -0
  178. package/src/lib/model/ai-media-credits.d.ts +52 -0
  179. package/src/lib/model/ai-media-credits.js +61 -0
  180. package/src/lib/model/ai-media-credits.js.map +1 -0
  181. package/src/lib/model/ai-overlay-copy.d.ts +114 -0
  182. package/src/lib/model/ai-overlay-copy.js +175 -0
  183. package/src/lib/model/ai-overlay-copy.js.map +1 -0
  184. package/src/lib/model/ai-site-build-progress.d.ts +28 -3
  185. package/src/lib/model/ai-site-build-progress.js +231 -17
  186. package/src/lib/model/ai-site-build-progress.js.map +1 -1
  187. package/src/lib/model/ai-site-start-seo.d.ts +16 -0
  188. package/src/lib/model/ai-site-start-seo.js +54 -4
  189. package/src/lib/model/ai-site-start-seo.js.map +1 -1
  190. package/src/lib/model/ai-site-start.d.ts +14 -0
  191. package/src/lib/model/ai-site-start.js +43 -0
  192. package/src/lib/model/ai-site-start.js.map +1 -1
  193. package/src/lib/model/ai-svg.d.ts +69 -0
  194. package/src/lib/model/ai-svg.js +265 -0
  195. package/src/lib/model/ai-svg.js.map +1 -0
  196. package/src/lib/model/ai-usage-by-user.d.ts +3 -2
  197. package/src/lib/model/ai-usage-by-user.js.map +1 -1
  198. package/src/lib/model/ai-workflow-job.d.ts +92 -4
  199. package/src/lib/model/ai-workflow-job.js +124 -7
  200. package/src/lib/model/ai-workflow-job.js.map +1 -1
  201. package/src/lib/model/assist-build.d.ts +58 -0
  202. package/src/lib/model/assist-build.js +52 -0
  203. package/src/lib/model/assist-build.js.map +1 -0
  204. package/src/lib/model/assist-edit.d.ts +48 -3
  205. package/src/lib/model/assist-edit.js +48 -4
  206. package/src/lib/model/assist-edit.js.map +1 -1
  207. package/src/lib/plugin-config.js +2 -0
  208. package/src/lib/plugin-config.js.map +1 -1
  209. package/src/lib/plugin.js +240 -11
  210. package/src/lib/plugin.js.map +1 -1
  211. package/src/lib/providers/catalog.d.ts +81 -4
  212. package/src/lib/providers/catalog.js +80 -9
  213. package/src/lib/providers/catalog.js.map +1 -1
  214. package/src/lib/providers/image-contract.d.ts +116 -0
  215. package/src/lib/providers/image-contract.js +74 -0
  216. package/src/lib/providers/image-contract.js.map +1 -0
  217. package/src/lib/providers/model-choice.js +11 -0
  218. package/src/lib/providers/model-choice.js.map +1 -1
  219. package/src/lib/providers/routing.js +18 -0
  220. package/src/lib/providers/routing.js.map +1 -1
  221. package/src/lib/providers/vertex-image.d.ts +121 -0
  222. package/src/lib/providers/vertex-image.js +312 -0
  223. package/src/lib/providers/vertex-image.js.map +1 -0
  224. package/src/lib/runtime/ai-doctrine-validators.d.ts +19 -0
  225. package/src/lib/runtime/ai-doctrine-validators.js +89 -0
  226. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  227. package/src/lib/runtime/ai-doctrine.d.ts +6 -0
  228. package/src/lib/runtime/ai-doctrine.js +16 -6
  229. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  230. package/src/lib/runtime/ai-eval-live.js +4 -0
  231. package/src/lib/runtime/ai-eval-live.js.map +1 -1
  232. package/src/lib/runtime/ai-eval.d.ts +15 -1
  233. package/src/lib/runtime/ai-eval.js +52 -1
  234. package/src/lib/runtime/ai-eval.js.map +1 -1
  235. package/src/lib/runtime/experiment-variant-copy.d.ts +34 -0
  236. package/src/lib/runtime/experiment-variant-copy.js +102 -0
  237. package/src/lib/runtime/experiment-variant-copy.js.map +1 -0
  238. package/src/lib/server/ai-experiment-versions.d.ts +51 -0
  239. package/src/lib/server/ai-experiment-versions.js +270 -0
  240. package/src/lib/server/ai-experiment-versions.js.map +1 -0
  241. package/src/lib/server/ai-jobs-resume.js +74 -4
  242. package/src/lib/server/ai-jobs-resume.js.map +1 -1
  243. package/src/lib/server/ai-media-image.d.ts +66 -0
  244. package/src/lib/server/ai-media-image.js +521 -0
  245. package/src/lib/server/ai-media-image.js.map +1 -0
  246. package/src/lib/server/ai-media-svg.d.ts +91 -0
  247. package/src/lib/server/ai-media-svg.js +186 -0
  248. package/src/lib/server/ai-media-svg.js.map +1 -0
  249. package/src/lib/server/assist-build.d.ts +54 -0
  250. package/src/lib/server/assist-build.js +121 -0
  251. package/src/lib/server/assist-build.js.map +1 -0
  252. package/src/lib/server/assist-chat.js +108 -12
  253. package/src/lib/server/assist-chat.js.map +1 -1
  254. package/src/lib/server/assist-edit.js +213 -3
  255. package/src/lib/server/assist-edit.js.map +1 -1
  256. package/src/lib/server/assist-view-context.js +242 -4
  257. package/src/lib/server/assist-view-context.js.map +1 -1
  258. package/src/lib/server.js +26 -0
  259. package/src/lib/server.js.map +1 -1
  260. package/src/lib/tools/ai-logic-tool.d.ts +27 -0
  261. package/src/lib/tools/ai-logic-tool.js +207 -0
  262. package/src/lib/tools/ai-logic-tool.js.map +1 -0
  263. package/src/lib/tools/ai-overlay-tool.d.ts +35 -0
  264. package/src/lib/tools/ai-overlay-tool.js +107 -0
  265. package/src/lib/tools/ai-overlay-tool.js.map +1 -0
  266. package/src/lib/tools/ai-workflow-tool.d.ts +11 -0
  267. package/src/lib/tools/ai-workflow-tool.js +31 -0
  268. package/src/lib/tools/ai-workflow-tool.js.map +1 -1
  269. package/src/lib/usage/assist-job-refund.d.ts +31 -3
  270. package/src/lib/usage/assist-job-refund.js +46 -10
  271. package/src/lib/usage/assist-job-refund.js.map +1 -1
  272. package/src/lib/usage/assist-usage.d.ts +5 -0
  273. package/src/lib/usage/assist-usage.js +2 -0
  274. package/src/lib/usage/assist-usage.js.map +1 -1
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type { ConsoleWidgetEntitlementProps } from '@aglyn/aglyn/plugin-manager/feature-plugins';
18
+ import type { ConsoleProductsCreateZoneProps } from './ai-product-zones';
19
+ /**
20
+ * "Create with AI" for products (AGL-3596), beside Add product and in the
21
+ * empty catalog, through the commerce plugin's `productsCreate` zone.
22
+ *
23
+ * Products from a brief are already the products hub card's ("Propose
24
+ * products", AGL-2916): the card starts the `products` job, and the proposal
25
+ * is reviewed in its table and written through the hub's own writes, which
26
+ * only the `productsHub` zone hands a widget. So this button is a door to
27
+ * that brief, not a second flow: the card registers an opener for its site
28
+ * as it mounts, and the button shows only while one is registered — never
29
+ * where the card could not take the brief, or would not show the proposal.
30
+ * Both are drawn from the shell's gates alone (AGL-3601), so nothing asks a
31
+ * server until the brief is sent; on a plan without the AI add-on the button
32
+ * opens the add-on's dialog instead.
33
+ */
34
+ type Opener = () => void;
35
+ /** The products hub card offers its "Propose products" brief for a site; returns the release. */
36
+ export declare function registerAiProductsBriefOpener(hostId: string, open: Opener): () => void;
37
+ /** Opens the newest card's brief for the site; `false` when no card offers one. */
38
+ export declare function openAiProductsBrief(hostId: string): boolean;
39
+ /** Whether a hub card on this site takes the brief right now. */
40
+ export declare function useAiProductsBriefAvailable(hostId: string): boolean;
41
+ export declare function AiCreateProductsButton({ hostId, entitled, upgrade, }: ConsoleProductsCreateZoneProps & ConsoleWidgetEntitlementProps): import("react").JSX.Element;
42
+ export default AiCreateProductsButton;
@@ -0,0 +1,67 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { mdiCreation } from "@aglyn/shared-data-mdi";
4
+ import { MdiIcon } from "@aglyn/shared-ui-jsx";
5
+ import { Button } from "@mui/material";
6
+ import { useCallback, useSyncExternalStore } from "react";
7
+ import { AiUpsellButton } from "./ai-upsell-dialog.component.js";
8
+ /** The open hub cards' brief openers, by site. */ const openers = new Map();
9
+ const subscribers = new Set();
10
+ function notify() {
11
+ for (const subscriber of subscribers)subscriber();
12
+ }
13
+ /** The products hub card offers its "Propose products" brief for a site; returns the release. */ export function registerAiProductsBriefOpener(hostId, open) {
14
+ var _openers_get;
15
+ const set = (_openers_get = openers.get(hostId)) != null ? _openers_get : new Set();
16
+ set.add(open);
17
+ openers.set(hostId, set);
18
+ notify();
19
+ return ()=>{
20
+ set.delete(open);
21
+ if (!set.size) openers.delete(hostId);
22
+ notify();
23
+ };
24
+ }
25
+ /** Opens the newest card's brief for the site; `false` when no card offers one. */ export function openAiProductsBrief(hostId) {
26
+ const set = openers.get(hostId);
27
+ if (!(set == null ? void 0 : set.size)) return false;
28
+ [
29
+ ...set
30
+ ][set.size - 1]();
31
+ return true;
32
+ }
33
+ function subscribe(onChange) {
34
+ subscribers.add(onChange);
35
+ return ()=>{
36
+ subscribers.delete(onChange);
37
+ };
38
+ }
39
+ /** Whether a hub card on this site takes the brief right now. */ export function useAiProductsBriefAvailable(hostId) {
40
+ const read = useCallback(()=>{
41
+ var _openers_get;
42
+ return Boolean((_openers_get = openers.get(hostId)) == null ? void 0 : _openers_get.size);
43
+ }, [
44
+ hostId
45
+ ]);
46
+ return useSyncExternalStore(subscribe, read, ()=>false);
47
+ }
48
+ export function AiCreateProductsButton({ hostId, entitled, upgrade }) {
49
+ const available = useAiProductsBriefAvailable(hostId);
50
+ if (entitled === false) return upgrade ? /*#__PURE__*/ _jsx(AiUpsellButton, {
51
+ kind: "product",
52
+ upgrade: upgrade
53
+ }) : null;
54
+ if (!available) return null;
55
+ return /*#__PURE__*/ _jsx(Button, {
56
+ size: "small",
57
+ variant: "outlined",
58
+ startIcon: /*#__PURE__*/ _jsx(MdiIcon, {
59
+ path: mdiCreation.path
60
+ }),
61
+ onClick: ()=>openAiProductsBrief(hostId),
62
+ children: 'Create with AI'
63
+ });
64
+ }
65
+ export default AiCreateProductsButton;
66
+
67
+ //# sourceMappingURL=ai-products-create-button.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-products-create-button.component.tsx"],"sourcesContent":["'use client'\n\n/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ConsoleWidgetEntitlementProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { mdiCreation } from '@aglyn/shared-data-mdi'\nimport { MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { Button } from '@mui/material'\nimport { useCallback, useSyncExternalStore } from 'react'\nimport type { ConsoleProductsCreateZoneProps } from './ai-product-zones'\nimport { AiUpsellButton } from './ai-upsell-dialog.component'\n\n/**\n * \"Create with AI\" for products (AGL-3596), beside Add product and in the\n * empty catalog, through the commerce plugin's `productsCreate` zone.\n *\n * Products from a brief are already the products hub card's (\"Propose\n * products\", AGL-2916): the card starts the `products` job, and the proposal\n * is reviewed in its table and written through the hub's own writes, which\n * only the `productsHub` zone hands a widget. So this button is a door to\n * that brief, not a second flow: the card registers an opener for its site\n * as it mounts, and the button shows only while one is registered — never\n * where the card could not take the brief, or would not show the proposal.\n * Both are drawn from the shell's gates alone (AGL-3601), so nothing asks a\n * server until the brief is sent; on a plan without the AI add-on the button\n * opens the add-on's dialog instead.\n */\n\ntype Opener = () => void\n\n/** The open hub cards' brief openers, by site. */\nconst openers = new Map<string, Set<Opener>>()\nconst subscribers = new Set<() => void>()\n\nfunction notify() {\n for (const subscriber of subscribers) subscriber()\n}\n\n/** The products hub card offers its \"Propose products\" brief for a site; returns the release. */\nexport function registerAiProductsBriefOpener(hostId: string, open: Opener): () => void {\n const set = openers.get(hostId) ?? new Set<Opener>()\n set.add(open)\n openers.set(hostId, set)\n notify()\n return () => {\n set.delete(open)\n if (!set.size) openers.delete(hostId)\n notify()\n }\n}\n\n/** Opens the newest card's brief for the site; `false` when no card offers one. */\nexport function openAiProductsBrief(hostId: string): boolean {\n const set = openers.get(hostId)\n if (!set?.size) return false\n ;[...set][set.size - 1]()\n return true\n}\n\nfunction subscribe(onChange: () => void) {\n subscribers.add(onChange)\n return () => {\n subscribers.delete(onChange)\n }\n}\n\n/** Whether a hub card on this site takes the brief right now. */\nexport function useAiProductsBriefAvailable(hostId: string): boolean {\n const read = useCallback(() => Boolean(openers.get(hostId)?.size), [hostId])\n return useSyncExternalStore(subscribe, read, () => false)\n}\n\nexport function AiCreateProductsButton({\n hostId,\n entitled,\n upgrade,\n}: ConsoleProductsCreateZoneProps & ConsoleWidgetEntitlementProps) {\n const available = useAiProductsBriefAvailable(hostId)\n if (entitled === false) return upgrade ? <AiUpsellButton kind=\"product\" upgrade={upgrade} /> : null\n if (!available) return null\n return (\n <Button\n size=\"small\"\n variant=\"outlined\"\n startIcon={<MdiIcon path={mdiCreation.path} />}\n onClick={() => openAiProductsBrief(hostId)}\n >\n {'Create with AI'}\n </Button>\n )\n}\n\nexport default AiCreateProductsButton\n"],"names":["mdiCreation","MdiIcon","Button","useCallback","useSyncExternalStore","AiUpsellButton","openers","Map","subscribers","Set","notify","subscriber","registerAiProductsBriefOpener","hostId","open","set","get","add","delete","size","openAiProductsBrief","subscribe","onChange","useAiProductsBriefAvailable","read","Boolean","AiCreateProductsButton","entitled","upgrade","available","kind","variant","startIcon","path","onClick"],"mappings":"AAAA;;AAoBA,SAASA,WAAW,QAAQ,yBAAwB;AACpD,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SAASC,MAAM,QAAQ,gBAAe;AACtC,SAASC,WAAW,EAAEC,oBAAoB,QAAQ,QAAO;AAEzD,SAASC,cAAc,QAAQ,kCAA8B;AAoB7D,gDAAgD,GAChD,MAAMC,UAAU,IAAIC;AACpB,MAAMC,cAAc,IAAIC;AAExB,SAASC;IACP,KAAK,MAAMC,cAAcH,YAAaG;AACxC;AAEA,+FAA+F,GAC/F,OAAO,SAASC,8BAA8BC,MAAc,EAAEC,IAAY;QAC5DR;IAAZ,MAAMS,OAAMT,eAAAA,QAAQU,GAAG,CAACH,mBAAZP,eAAuB,IAAIG;IACvCM,IAAIE,GAAG,CAACH;IACRR,QAAQS,GAAG,CAACF,QAAQE;IACpBL;IACA,OAAO;QACLK,IAAIG,MAAM,CAACJ;QACX,IAAI,CAACC,IAAII,IAAI,EAAEb,QAAQY,MAAM,CAACL;QAC9BH;IACF;AACF;AAEA,iFAAiF,GACjF,OAAO,SAASU,oBAAoBP,MAAc;IAChD,MAAME,MAAMT,QAAQU,GAAG,CAACH;IACxB,IAAI,EAACE,uBAAAA,IAAKI,IAAI,GAAE,OAAO;IACtB;WAAIJ;KAAI,CAACA,IAAII,IAAI,GAAG,EAAE;IACvB,OAAO;AACT;AAEA,SAASE,UAAUC,QAAoB;IACrCd,YAAYS,GAAG,CAACK;IAChB,OAAO;QACLd,YAAYU,MAAM,CAACI;IACrB;AACF;AAEA,+DAA+D,GAC/D,OAAO,SAASC,4BAA4BV,MAAc;IACxD,MAAMW,OAAOrB,YAAY;YAAcG;eAARmB,SAAQnB,eAAAA,QAAQU,GAAG,CAACH,4BAAZP,aAAqBa,IAAI;OAAG;QAACN;KAAO;IAC3E,OAAOT,qBAAqBiB,WAAWG,MAAM,IAAM;AACrD;AAEA,OAAO,SAASE,uBAAuB,EACrCb,MAAM,EACNc,QAAQ,EACRC,OAAO,EACwD;IAC/D,MAAMC,YAAYN,4BAA4BV;IAC9C,IAAIc,aAAa,OAAO,OAAOC,wBAAU,KAACvB;QAAeyB,MAAK;QAAUF,SAASA;SAAc;IAC/F,IAAI,CAACC,WAAW,OAAO;IACvB,qBACE,KAAC3B;QACCiB,MAAK;QACLY,SAAQ;QACRC,yBAAW,KAAC/B;YAAQgC,MAAMjC,YAAYiC,IAAI;;QAC1CC,SAAS,IAAMd,oBAAoBP;kBAElC;;AAGP;AAEA,eAAea,uBAAsB"}
@@ -21,6 +21,7 @@ import { ListTable } from "@aglyn/shared-ui-jsx/components/list-table.component"
21
21
  import { Alert, Box, Button, Chip, Dialog, DialogActions, DialogContent, DialogTitle, Link, Stack, TextField, Typography } from "@mui/material";
22
22
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
23
23
  import { AI_PRODUCTS_BULK_MAX, AI_PRODUCTS_IMPORT_WRITE_COPY, aiProductsBulkBrief, aiProductsBulkCount, aiProductsJobInputs, aiProductsProposalOfKind } from "../model/ai-products.js";
24
+ import { registerAiProductsBriefOpener } from "./ai-products-create-button.component.js";
24
25
  import { AiBulkCopyReview, AiCatalogReview, AiCategoriesReview } from "./ai-products-proposals.component.js";
25
26
  import { useAiProductsJobs } from "./use-ai-products-jobs.js";
26
27
  /**
@@ -37,6 +38,9 @@ import { useAiProductsJobs } from "./use-ai-products-jobs.js";
37
38
  * - **Propose categories and discounts** — from a brief, created as the
38
39
  * catalog and discounts cards create them, every discount switched off.
39
40
  *
41
+ * "Create with AI" beside Add product and in the empty catalog
42
+ * (`productsCreate`, AGL-3596) opens the Propose products brief here.
43
+ *
40
44
  * An import whose `productImport` option asked for it starts a copy job for
41
45
  * the products the import created, as they land. Every write is the hub's
42
46
  * (`ConsoleProductsHubZoneProps`); this card writes nothing itself.
@@ -109,6 +113,17 @@ export function AiProductsHubCard(props) {
109
113
  lastImport,
110
114
  startBulk
111
115
  ]);
116
+ // "Create with AI" beside Add product (AGL-3596) opens this card's
117
+ // Propose products brief. Offered from the moment the card is on the page,
118
+ // so the door draws from the shell's gates alone (AGL-3601) rather than
119
+ // after this card's list of recent proposals is read; the start door
120
+ // decides when the brief is sent, and says why in the dialog if it refuses.
121
+ useEffect(()=>registerAiProductsBriefOpener(hostId, ()=>setBrief({
122
+ kind: 'catalog',
123
+ text: ''
124
+ })), [
125
+ hostId
126
+ ]);
112
127
  const heldNames = useMemo(()=>new Set(products.map((product)=>nameKey(product.name))), [
113
128
  products
114
129
  ]);
@@ -138,7 +153,6 @@ export function AiProductsHubCard(props) {
138
153
  width: 110
139
154
  }
140
155
  ], []);
141
- if (verdict !== 'ready') return null;
142
156
  const latest = (target)=>{
143
157
  var _jobs_find;
144
158
  return (_jobs_find = jobs.find((job)=>targetOf(job, started) === target)) != null ? _jobs_find : null;
@@ -168,6 +182,90 @@ export function AiProductsHubCard(props) {
168
182
  setBusy(false);
169
183
  }
170
184
  };
185
+ const briefDialog = /*#__PURE__*/ _jsxs(Dialog, {
186
+ open: Boolean(brief),
187
+ onClose: busy ? undefined : ()=>setBrief(null),
188
+ fullWidth: true,
189
+ maxWidth: "sm",
190
+ children: [
191
+ /*#__PURE__*/ _jsx(DialogTitle, {
192
+ children: copy == null ? void 0 : copy.title
193
+ }),
194
+ /*#__PURE__*/ _jsx(DialogContent, {
195
+ children: /*#__PURE__*/ _jsxs(Stack, {
196
+ spacing: 2,
197
+ sx: {
198
+ pt: 1
199
+ },
200
+ children: [
201
+ /*#__PURE__*/ _jsx(TextField, {
202
+ label: copy == null ? void 0 : copy.label,
203
+ placeholder: copy == null ? void 0 : copy.placeholder,
204
+ multiline: true,
205
+ minRows: 4,
206
+ value: (_ref = brief == null ? void 0 : brief.text) != null ? _ref : '',
207
+ onChange: (event)=>setBrief((current)=>current ? _extends({}, current, {
208
+ text: event.target.value.slice(0, BRIEF_MAX_CHARS)
209
+ }) : current),
210
+ helperText: `${((_ref1 = brief == null ? void 0 : brief.text.length) != null ? _ref1 : 0).toLocaleString('en-US')} / ${BRIEF_MAX_CHARS.toLocaleString('en-US')}`,
211
+ disabled: busy,
212
+ autoFocus: true
213
+ }),
214
+ /*#__PURE__*/ _jsx(Typography, {
215
+ variant: "body2",
216
+ color: "text.secondary",
217
+ children: copy == null ? void 0 : copy.next
218
+ }),
219
+ (brief == null ? void 0 : brief.kind) === 'catalog' ? /*#__PURE__*/ _jsxs(Stack, {
220
+ direction: "row",
221
+ spacing: 1,
222
+ useFlexGap: true,
223
+ sx: {
224
+ flexWrap: 'wrap'
225
+ },
226
+ children: [
227
+ /*#__PURE__*/ _jsx(Chip, {
228
+ size: "small",
229
+ color: "warning",
230
+ variant: "outlined",
231
+ label: "Prices stay empty"
232
+ }),
233
+ /*#__PURE__*/ _jsx(Chip, {
234
+ size: "small",
235
+ color: "warning",
236
+ variant: "outlined",
237
+ label: "Photos are yours to add"
238
+ })
239
+ ]
240
+ }) : null,
241
+ notice ? /*#__PURE__*/ _jsx(Alert, {
242
+ severity: "warning",
243
+ children: notice
244
+ }) : null
245
+ ]
246
+ })
247
+ }),
248
+ /*#__PURE__*/ _jsxs(DialogActions, {
249
+ children: [
250
+ /*#__PURE__*/ _jsx(Button, {
251
+ onClick: ()=>setBrief(null),
252
+ disabled: busy,
253
+ children: 'Cancel'
254
+ }),
255
+ /*#__PURE__*/ _jsx(Button, {
256
+ variant: "contained",
257
+ disabled: busy || !orgId || !(brief == null ? void 0 : brief.text.trim()),
258
+ onClick: ()=>void submitBrief(),
259
+ children: copy == null ? void 0 : copy.submit
260
+ })
261
+ ]
262
+ })
263
+ ]
264
+ });
265
+ // Until the card's list of recent proposals is read — or where the jobs
266
+ // route will not list them — it draws nothing but a brief the products door
267
+ // opened, whose start door says any refusal in the dialog.
268
+ if (verdict !== 'ready') return briefDialog;
171
269
  const submitPicked = async ()=>{
172
270
  setBusy(true);
173
271
  try {
@@ -332,86 +430,7 @@ export function AiProductsHubCard(props) {
332
430
  })
333
431
  ]
334
432
  }),
335
- /*#__PURE__*/ _jsxs(Dialog, {
336
- open: Boolean(brief),
337
- onClose: busy ? undefined : ()=>setBrief(null),
338
- fullWidth: true,
339
- maxWidth: "sm",
340
- children: [
341
- /*#__PURE__*/ _jsx(DialogTitle, {
342
- children: copy == null ? void 0 : copy.title
343
- }),
344
- /*#__PURE__*/ _jsx(DialogContent, {
345
- children: /*#__PURE__*/ _jsxs(Stack, {
346
- spacing: 2,
347
- sx: {
348
- pt: 1
349
- },
350
- children: [
351
- /*#__PURE__*/ _jsx(TextField, {
352
- label: copy == null ? void 0 : copy.label,
353
- placeholder: copy == null ? void 0 : copy.placeholder,
354
- multiline: true,
355
- minRows: 4,
356
- value: (_ref = brief == null ? void 0 : brief.text) != null ? _ref : '',
357
- onChange: (event)=>setBrief((current)=>current ? _extends({}, current, {
358
- text: event.target.value.slice(0, BRIEF_MAX_CHARS)
359
- }) : current),
360
- helperText: `${((_ref1 = brief == null ? void 0 : brief.text.length) != null ? _ref1 : 0).toLocaleString('en-US')} / ${BRIEF_MAX_CHARS.toLocaleString('en-US')}`,
361
- disabled: busy,
362
- autoFocus: true
363
- }),
364
- /*#__PURE__*/ _jsx(Typography, {
365
- variant: "body2",
366
- color: "text.secondary",
367
- children: copy == null ? void 0 : copy.next
368
- }),
369
- (brief == null ? void 0 : brief.kind) === 'catalog' ? /*#__PURE__*/ _jsxs(Stack, {
370
- direction: "row",
371
- spacing: 1,
372
- useFlexGap: true,
373
- sx: {
374
- flexWrap: 'wrap'
375
- },
376
- children: [
377
- /*#__PURE__*/ _jsx(Chip, {
378
- size: "small",
379
- color: "warning",
380
- variant: "outlined",
381
- label: "Prices stay empty"
382
- }),
383
- /*#__PURE__*/ _jsx(Chip, {
384
- size: "small",
385
- color: "warning",
386
- variant: "outlined",
387
- label: "Photos are yours to add"
388
- })
389
- ]
390
- }) : null,
391
- notice ? /*#__PURE__*/ _jsx(Alert, {
392
- severity: "warning",
393
- children: notice
394
- }) : null
395
- ]
396
- })
397
- }),
398
- /*#__PURE__*/ _jsxs(DialogActions, {
399
- children: [
400
- /*#__PURE__*/ _jsx(Button, {
401
- onClick: ()=>setBrief(null),
402
- disabled: busy,
403
- children: 'Cancel'
404
- }),
405
- /*#__PURE__*/ _jsx(Button, {
406
- variant: "contained",
407
- disabled: busy || !orgId || !(brief == null ? void 0 : brief.text.trim()),
408
- onClick: ()=>void submitBrief(),
409
- children: copy == null ? void 0 : copy.submit
410
- })
411
- ]
412
- })
413
- ]
414
- })
433
+ briefDialog
415
434
  ]
416
435
  });
417
436
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-products-hub-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport type { ConsoleProductsHubZoneProps } from './ai-product-zones'\nimport { ListTable, type ListTableProps } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport {\n Alert,\n Box,\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Link,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport {\n AI_PRODUCTS_BULK_MAX,\n AI_PRODUCTS_IMPORT_WRITE_COPY,\n aiProductsBulkBrief,\n aiProductsBulkCount,\n aiProductsJobInputs,\n aiProductsProposalOfKind,\n} from '../model/ai-products'\nimport { AiBulkCopyReview, AiCatalogReview, AiCategoriesReview } from './ai-products-proposals.component'\nimport { useAiProductsJobs } from './use-ai-products-jobs'\n\n/**\n * Commerce by AI on the products hub (AGL-2916), through the `productsHub`\n * zone. Three things a person asks for, each a `products` job, and each\n * proposal reviewed in a table before anything is written:\n *\n * - **Write copy for products** — up to 50 saved products, picked from the\n * hub's rows; a job works through them a product at a time, and each row is\n * applied on its own or all at once.\n * - **Propose products** — a store's first products from a brief, created as\n * drafts with their prices empty and no photo, both marked for the person to\n * set.\n * - **Propose categories and discounts** — from a brief, created as the\n * catalog and discounts cards create them, every discount switched off.\n *\n * An import whose `productImport` option asked for it starts a copy job for\n * the products the import created, as they land. Every write is the hub's\n * (`ConsoleProductsHubZoneProps`); this card writes nothing itself.\n */\n\nconst BRIEF_MAX_CHARS = 4_000\n\n/** A column of the product picker, in the shared list table's own terms. */\ntype GridColDef = NonNullable<ListTableProps['columns']>[number]\n\ntype BriefKind = 'catalog' | 'categories'\n\n/** What each brief dialog says. */\nexport const AI_PRODUCTS_BRIEF_COPY: Readonly<\n Record<BriefKind, { title: string; label: string; placeholder: string; next: string; submit: string }>\n> = {\n catalog: {\n title: 'Propose products',\n label: 'What does the store sell?',\n placeholder: 'A candle studio in Asheville: hand-poured soy candles in 8 oz and 16 oz jars, and wax melts',\n next:\n 'You review up to twelve proposed products before any is created. Each is created as a draft with its ' +\n 'price left empty and no photo, and nothing is on your storefront until you price it and activate it.',\n submit: 'Propose products',\n },\n categories: {\n title: 'Propose categories and discounts',\n label: 'What should shoppers be able to browse, and what offers suit the store?',\n placeholder: 'A trail running shop: shoes, apparel and hydration packs, with a welcome offer for new runners',\n next:\n 'You review the proposed categories and discounts before any is created. Discounts are created switched ' +\n 'off, and a shopper sees none until you switch it on.',\n submit: 'Propose',\n },\n}\n\nconst nameKey = (name: string) => name.replace(/\\s+/g, ' ').trim().toLowerCase()\n\n/** Which card a `products` job belongs to: from what it proposed, or from what this card started. */\nfunction targetOf(job: AiJobSummary, started: Readonly<Record<string, string>>): string | null {\n if (started[job.id]) return started[job.id]\n if (aiProductsBulkCount(job) !== null) return 'bulk'\n if (aiProductsProposalOfKind(job, 'catalog')) return 'catalog'\n if (aiProductsProposalOfKind(job, 'categories')) return 'categories'\n return null\n}\n\nexport function AiProductsHubCard(props: ConsoleProductsHubZoneProps) {\n const { hostId, products, lastImport, applyProductCopy, createProductDrafts, createCategories, createDiscountDrafts } =\n props\n const { orgId, verdict, jobs, notice, start } = useAiProductsJobs({\n hostId,\n orgId: props.orgId,\n // A bulk job is known by its brief while it runs; a catalog or categories\n // job started elsewhere is shown once it has proposed.\n follows: (job) => aiProductsBulkCount(job) !== null,\n })\n const [started, setStarted] = useState<Record<string, string>>({})\n const [picking, setPicking] = useState(false)\n const [picked, setPicked] = useState<string[]>([])\n const [brief, setBrief] = useState<{ kind: BriefKind; text: string } | null>(null)\n const [busy, setBusy] = useState(false)\n const handledImports = useRef(new Set<string>())\n\n const startBulk = useCallback(\n async (productIds: readonly string[]) => {\n const ids = productIds.slice(0, AI_PRODUCTS_BULK_MAX)\n if (!ids.length) return false\n const job = await start(aiProductsBulkBrief(ids.length), aiProductsJobInputs({ target: 'bulk', productIds: [...ids] }))\n if (job) setStarted((current) => ({ ...current, [job.id]: 'bulk' }))\n return Boolean(job)\n },\n [start],\n )\n\n // An import that asked for its copy starts the job once, as the import lands.\n useEffect(() => {\n if (verdict !== 'ready' || !lastImport || handledImports.current.has(lastImport.key)) return\n handledImports.current.add(lastImport.key)\n if (lastImport.options[AI_PRODUCTS_IMPORT_WRITE_COPY] && lastImport.productIds.length) {\n void startBulk(lastImport.productIds)\n }\n }, [verdict, lastImport, startBulk])\n\n const heldNames = useMemo(() => new Set(products.map((product) => nameKey(product.name))), [products])\n const pickerRows = useMemo(\n () =>\n products.map((product) => ({\n $id: product.id,\n name: product.name,\n status: product.status,\n photo: product.hasPhoto ? 'Yes' : 'No photo',\n })),\n [products],\n )\n const pickerColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Product', flex: 1, minWidth: 180 },\n { field: 'status', headerName: 'Status', width: 110 },\n { field: 'photo', headerName: 'Photo', width: 110 },\n ],\n [],\n )\n\n if (verdict !== 'ready') return null\n\n const latest = (target: string) => jobs.find((job) => targetOf(job, started) === target) ?? null\n const bulkJob = latest('bulk')\n const catalogJob = latest('catalog')\n const categoriesJob = latest('categories')\n const tooMany = picked.length > AI_PRODUCTS_BULK_MAX\n const help = pluginDocsHelp('aiProducts', {\n excerpt:\n 'Write product copy, propose a first catalog, or propose categories and discounts from a brief. You review every proposal before anything is saved.',\n })\n const copy = brief ? AI_PRODUCTS_BRIEF_COPY[brief.kind] : null\n\n const submitBrief = async () => {\n if (!brief?.text.trim()) return\n setBusy(true)\n try {\n const job = await start(brief.text.trim(), aiProductsJobInputs({ target: brief.kind }))\n if (job) {\n setStarted((current) => ({ ...current, [job.id]: brief.kind }))\n setBrief(null)\n }\n } finally {\n setBusy(false)\n }\n }\n\n const submitPicked = async () => {\n setBusy(true)\n try {\n if (await startBulk(picked)) {\n setPicking(false)\n setPicked([])\n }\n } finally {\n setBusy(false)\n }\n }\n\n return (\n <Box sx={{ border: 1, borderColor: 'divider', borderRadius: 1, p: 1.5 }} aria-label=\"Products assistant\">\n <Stack spacing={1.5}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'baseline' }}>\n <Typography variant=\"subtitle2\" sx={{ flexGrow: 1 }}>\n {'Build your catalog with AI'}\n </Typography>\n <Link href={help.href} target=\"_blank\" rel=\"noopener\" variant=\"caption\" title={help.excerpt}>\n {'How it works'}\n </Link>\n </Stack>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>\n <Button size=\"small\" variant=\"outlined\" disabled={!orgId || !products.length} onClick={() => setPicking(true)}>\n {'Write copy for products'}\n </Button>\n <Button size=\"small\" variant=\"outlined\" disabled={!orgId} onClick={() => setBrief({ kind: 'catalog', text: '' })}>\n {'Propose products'}\n </Button>\n <Button\n size=\"small\"\n variant=\"outlined\"\n disabled={!orgId}\n onClick={() => setBrief({ kind: 'categories', text: '' })}\n >\n {'Propose categories and discounts'}\n </Button>\n </Stack>\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n {bulkJob ? (\n <AiBulkCopyReview key={bulkJob.id} job={bulkJob} applyProductCopy={applyProductCopy} />\n ) : null}\n {catalogJob ? (\n <AiCatalogReview\n key={catalogJob.id}\n job={catalogJob}\n heldNames={heldNames}\n createProductDrafts={createProductDrafts}\n />\n ) : null}\n {categoriesJob ? (\n <AiCategoriesReview\n key={categoriesJob.id}\n job={categoriesJob}\n createCategories={createCategories}\n createDiscountDrafts={createDiscountDrafts}\n />\n ) : null}\n </Stack>\n\n <Dialog open={picking} onClose={busy ? undefined : () => setPicking(false)} fullWidth maxWidth=\"md\">\n <DialogTitle>{'Write copy for products'}</DialogTitle>\n <DialogContent>\n <Stack spacing={1.5} sx={{ pt: 1 }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Pick up to ${AI_PRODUCTS_BULK_MAX} products. Each gets a proposed description, search listing and ` +\n 'tags from its name, text, options and first photo, and you review every one before it is saved. ' +\n 'Prices are never written.'}\n </Typography>\n <ListTable\n rows={pickerRows}\n columns={pickerColumns}\n // A picker over the rows the hub hands its zone, not a list to\n // search: a filter here would narrow only those rows (AGL-3321).\n disableColumnFilter\n quickFilter={false}\n selectable={{ selected: picked, onChange: setPicked }}\n />\n {tooMany ? (\n <Alert severity=\"info\">{`Pick at most ${AI_PRODUCTS_BULK_MAX} products at a time.`}</Alert>\n ) : null}\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setPicking(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !picked.length || tooMany} onClick={() => void submitPicked()}>\n {picked.length ? `Write copy for ${picked.length}` : 'Write copy'}\n </Button>\n </DialogActions>\n </Dialog>\n\n <Dialog open={Boolean(brief)} onClose={busy ? undefined : () => setBrief(null)} fullWidth maxWidth=\"sm\">\n <DialogTitle>{copy?.title}</DialogTitle>\n <DialogContent>\n <Stack spacing={2} sx={{ pt: 1 }}>\n <TextField\n label={copy?.label}\n placeholder={copy?.placeholder}\n multiline\n minRows={4}\n value={brief?.text ?? ''}\n onChange={(event) =>\n setBrief((current) => (current ? { ...current, text: event.target.value.slice(0, BRIEF_MAX_CHARS) } : current))\n }\n helperText={`${(brief?.text.length ?? 0).toLocaleString('en-US')} / ${BRIEF_MAX_CHARS.toLocaleString('en-US')}`}\n disabled={busy}\n autoFocus\n />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {copy?.next}\n </Typography>\n {brief?.kind === 'catalog' ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Prices stay empty\" />\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Photos are yours to add\" />\n </Stack>\n ) : null}\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setBrief(null)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !orgId || !brief?.text.trim()} onClick={() => void submitBrief()}>\n {copy?.submit}\n </Button>\n </DialogActions>\n </Dialog>\n </Box>\n )\n}\nAiProductsHubCard.displayName = 'AiProductsHubCard'\n\nexport default AiProductsHubCard\n"],"names":["pluginDocsHelp","ListTable","Alert","Box","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","Link","Stack","TextField","Typography","useCallback","useEffect","useMemo","useRef","useState","AI_PRODUCTS_BULK_MAX","AI_PRODUCTS_IMPORT_WRITE_COPY","aiProductsBulkBrief","aiProductsBulkCount","aiProductsJobInputs","aiProductsProposalOfKind","AiBulkCopyReview","AiCatalogReview","AiCategoriesReview","useAiProductsJobs","BRIEF_MAX_CHARS","AI_PRODUCTS_BRIEF_COPY","catalog","title","label","placeholder","next","submit","categories","nameKey","name","replace","trim","toLowerCase","targetOf","job","started","id","AiProductsHubCard","props","hostId","products","lastImport","applyProductCopy","createProductDrafts","createCategories","createDiscountDrafts","orgId","verdict","jobs","notice","start","follows","setStarted","picking","setPicking","picked","setPicked","brief","setBrief","busy","setBusy","handledImports","Set","startBulk","productIds","ids","slice","length","target","current","Boolean","has","key","add","options","heldNames","map","product","pickerRows","$id","status","photo","hasPhoto","pickerColumns","field","headerName","flex","minWidth","width","latest","find","bulkJob","catalogJob","categoriesJob","tooMany","help","excerpt","copy","kind","submitBrief","text","submitPicked","sx","border","borderColor","borderRadius","p","aria-label","spacing","direction","alignItems","variant","flexGrow","href","rel","xs","sm","size","disabled","onClick","severity","open","onClose","undefined","fullWidth","maxWidth","pt","color","rows","columns","disableColumnFilter","quickFilter","selectable","selected","onChange","multiline","minRows","value","event","helperText","toLocaleString","autoFocus","useFlexGap","flexWrap","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,mCAAkC;AAEjE,SAASC,SAAS,QAA6B,uDAAsD;AACrG,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAEzE,SACEC,oBAAoB,EACpBC,6BAA6B,EAC7BC,mBAAmB,EACnBC,mBAAmB,EACnBC,mBAAmB,EACnBC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,yBAAAA,MAAO2C,IAAI,CAACrE,IAAI;gCAAIwF,SAAS,IAAM,KAAKpB;0CAC9FF,wBAAAA,KAAMvE,MAAM;;;;;;;;AAMzB;AACAW,kBAAkB2G,WAAW,GAAG;AAEhC,eAAe3G,kBAAiB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-products-hub-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport type { ConsoleProductsHubZoneProps } from './ai-product-zones'\nimport { ListTable, type ListTableProps } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport {\n Alert,\n Box,\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Link,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport {\n AI_PRODUCTS_BULK_MAX,\n AI_PRODUCTS_IMPORT_WRITE_COPY,\n aiProductsBulkBrief,\n aiProductsBulkCount,\n aiProductsJobInputs,\n aiProductsProposalOfKind,\n} from '../model/ai-products'\nimport { registerAiProductsBriefOpener } from './ai-products-create-button.component'\nimport { AiBulkCopyReview, AiCatalogReview, AiCategoriesReview } from './ai-products-proposals.component'\nimport { useAiProductsJobs } from './use-ai-products-jobs'\n\n/**\n * Commerce by AI on the products hub (AGL-2916), through the `productsHub`\n * zone. Three things a person asks for, each a `products` job, and each\n * proposal reviewed in a table before anything is written:\n *\n * - **Write copy for products** — up to 50 saved products, picked from the\n * hub's rows; a job works through them a product at a time, and each row is\n * applied on its own or all at once.\n * - **Propose products** — a store's first products from a brief, created as\n * drafts with their prices empty and no photo, both marked for the person to\n * set.\n * - **Propose categories and discounts** — from a brief, created as the\n * catalog and discounts cards create them, every discount switched off.\n *\n * \"Create with AI\" beside Add product and in the empty catalog\n * (`productsCreate`, AGL-3596) opens the Propose products brief here.\n *\n * An import whose `productImport` option asked for it starts a copy job for\n * the products the import created, as they land. Every write is the hub's\n * (`ConsoleProductsHubZoneProps`); this card writes nothing itself.\n */\n\nconst BRIEF_MAX_CHARS = 4_000\n\n/** A column of the product picker, in the shared list table's own terms. */\ntype GridColDef = NonNullable<ListTableProps['columns']>[number]\n\ntype BriefKind = 'catalog' | 'categories'\n\n/** What each brief dialog says. */\nexport const AI_PRODUCTS_BRIEF_COPY: Readonly<\n Record<BriefKind, { title: string; label: string; placeholder: string; next: string; submit: string }>\n> = {\n catalog: {\n title: 'Propose products',\n label: 'What does the store sell?',\n placeholder: 'A candle studio in Asheville: hand-poured soy candles in 8 oz and 16 oz jars, and wax melts',\n next:\n 'You review up to twelve proposed products before any is created. Each is created as a draft with its ' +\n 'price left empty and no photo, and nothing is on your storefront until you price it and activate it.',\n submit: 'Propose products',\n },\n categories: {\n title: 'Propose categories and discounts',\n label: 'What should shoppers be able to browse, and what offers suit the store?',\n placeholder: 'A trail running shop: shoes, apparel and hydration packs, with a welcome offer for new runners',\n next:\n 'You review the proposed categories and discounts before any is created. Discounts are created switched ' +\n 'off, and a shopper sees none until you switch it on.',\n submit: 'Propose',\n },\n}\n\nconst nameKey = (name: string) => name.replace(/\\s+/g, ' ').trim().toLowerCase()\n\n/** Which card a `products` job belongs to: from what it proposed, or from what this card started. */\nfunction targetOf(job: AiJobSummary, started: Readonly<Record<string, string>>): string | null {\n if (started[job.id]) return started[job.id]\n if (aiProductsBulkCount(job) !== null) return 'bulk'\n if (aiProductsProposalOfKind(job, 'catalog')) return 'catalog'\n if (aiProductsProposalOfKind(job, 'categories')) return 'categories'\n return null\n}\n\nexport function AiProductsHubCard(props: ConsoleProductsHubZoneProps) {\n const { hostId, products, lastImport, applyProductCopy, createProductDrafts, createCategories, createDiscountDrafts } =\n props\n const { orgId, verdict, jobs, notice, start } = useAiProductsJobs({\n hostId,\n orgId: props.orgId,\n // A bulk job is known by its brief while it runs; a catalog or categories\n // job started elsewhere is shown once it has proposed.\n follows: (job) => aiProductsBulkCount(job) !== null,\n })\n const [started, setStarted] = useState<Record<string, string>>({})\n const [picking, setPicking] = useState(false)\n const [picked, setPicked] = useState<string[]>([])\n const [brief, setBrief] = useState<{ kind: BriefKind; text: string } | null>(null)\n const [busy, setBusy] = useState(false)\n const handledImports = useRef(new Set<string>())\n\n const startBulk = useCallback(\n async (productIds: readonly string[]) => {\n const ids = productIds.slice(0, AI_PRODUCTS_BULK_MAX)\n if (!ids.length) return false\n const job = await start(aiProductsBulkBrief(ids.length), aiProductsJobInputs({ target: 'bulk', productIds: [...ids] }))\n if (job) setStarted((current) => ({ ...current, [job.id]: 'bulk' }))\n return Boolean(job)\n },\n [start],\n )\n\n // An import that asked for its copy starts the job once, as the import lands.\n useEffect(() => {\n if (verdict !== 'ready' || !lastImport || handledImports.current.has(lastImport.key)) return\n handledImports.current.add(lastImport.key)\n if (lastImport.options[AI_PRODUCTS_IMPORT_WRITE_COPY] && lastImport.productIds.length) {\n void startBulk(lastImport.productIds)\n }\n }, [verdict, lastImport, startBulk])\n\n // \"Create with AI\" beside Add product (AGL-3596) opens this card's\n // Propose products brief. Offered from the moment the card is on the page,\n // so the door draws from the shell's gates alone (AGL-3601) rather than\n // after this card's list of recent proposals is read; the start door\n // decides when the brief is sent, and says why in the dialog if it refuses.\n useEffect(\n () => registerAiProductsBriefOpener(hostId, () => setBrief({ kind: 'catalog', text: '' })),\n [hostId],\n )\n\n const heldNames = useMemo(() => new Set(products.map((product) => nameKey(product.name))), [products])\n const pickerRows = useMemo(\n () =>\n products.map((product) => ({\n $id: product.id,\n name: product.name,\n status: product.status,\n photo: product.hasPhoto ? 'Yes' : 'No photo',\n })),\n [products],\n )\n const pickerColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Product', flex: 1, minWidth: 180 },\n { field: 'status', headerName: 'Status', width: 110 },\n { field: 'photo', headerName: 'Photo', width: 110 },\n ],\n [],\n )\n\n const latest = (target: string) => jobs.find((job) => targetOf(job, started) === target) ?? null\n const bulkJob = latest('bulk')\n const catalogJob = latest('catalog')\n const categoriesJob = latest('categories')\n const tooMany = picked.length > AI_PRODUCTS_BULK_MAX\n const help = pluginDocsHelp('aiProducts', {\n excerpt:\n 'Write product copy, propose a first catalog, or propose categories and discounts from a brief. You review every proposal before anything is saved.',\n })\n const copy = brief ? AI_PRODUCTS_BRIEF_COPY[brief.kind] : null\n\n const submitBrief = async () => {\n if (!brief?.text.trim()) return\n setBusy(true)\n try {\n const job = await start(brief.text.trim(), aiProductsJobInputs({ target: brief.kind }))\n if (job) {\n setStarted((current) => ({ ...current, [job.id]: brief.kind }))\n setBrief(null)\n }\n } finally {\n setBusy(false)\n }\n }\n\n const briefDialog = (\n <Dialog open={Boolean(brief)} onClose={busy ? undefined : () => setBrief(null)} fullWidth maxWidth=\"sm\">\n <DialogTitle>{copy?.title}</DialogTitle>\n <DialogContent>\n <Stack spacing={2} sx={{ pt: 1 }}>\n <TextField\n label={copy?.label}\n placeholder={copy?.placeholder}\n multiline\n minRows={4}\n value={brief?.text ?? ''}\n onChange={(event) =>\n setBrief((current) => (current ? { ...current, text: event.target.value.slice(0, BRIEF_MAX_CHARS) } : current))\n }\n helperText={`${(brief?.text.length ?? 0).toLocaleString('en-US')} / ${BRIEF_MAX_CHARS.toLocaleString('en-US')}`}\n disabled={busy}\n autoFocus\n />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {copy?.next}\n </Typography>\n {brief?.kind === 'catalog' ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Prices stay empty\" />\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Photos are yours to add\" />\n </Stack>\n ) : null}\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setBrief(null)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !orgId || !brief?.text.trim()} onClick={() => void submitBrief()}>\n {copy?.submit}\n </Button>\n </DialogActions>\n </Dialog>\n )\n\n // Until the card's list of recent proposals is read — or where the jobs\n // route will not list them — it draws nothing but a brief the products door\n // opened, whose start door says any refusal in the dialog.\n if (verdict !== 'ready') return briefDialog\n\n const submitPicked = async () => {\n setBusy(true)\n try {\n if (await startBulk(picked)) {\n setPicking(false)\n setPicked([])\n }\n } finally {\n setBusy(false)\n }\n }\n\n return (\n <Box sx={{ border: 1, borderColor: 'divider', borderRadius: 1, p: 1.5 }} aria-label=\"Products assistant\">\n <Stack spacing={1.5}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'baseline' }}>\n <Typography variant=\"subtitle2\" sx={{ flexGrow: 1 }}>\n {'Build your catalog with AI'}\n </Typography>\n <Link href={help.href} target=\"_blank\" rel=\"noopener\" variant=\"caption\" title={help.excerpt}>\n {'How it works'}\n </Link>\n </Stack>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>\n <Button size=\"small\" variant=\"outlined\" disabled={!orgId || !products.length} onClick={() => setPicking(true)}>\n {'Write copy for products'}\n </Button>\n <Button size=\"small\" variant=\"outlined\" disabled={!orgId} onClick={() => setBrief({ kind: 'catalog', text: '' })}>\n {'Propose products'}\n </Button>\n <Button\n size=\"small\"\n variant=\"outlined\"\n disabled={!orgId}\n onClick={() => setBrief({ kind: 'categories', text: '' })}\n >\n {'Propose categories and discounts'}\n </Button>\n </Stack>\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n {bulkJob ? (\n <AiBulkCopyReview key={bulkJob.id} job={bulkJob} applyProductCopy={applyProductCopy} />\n ) : null}\n {catalogJob ? (\n <AiCatalogReview\n key={catalogJob.id}\n job={catalogJob}\n heldNames={heldNames}\n createProductDrafts={createProductDrafts}\n />\n ) : null}\n {categoriesJob ? (\n <AiCategoriesReview\n key={categoriesJob.id}\n job={categoriesJob}\n createCategories={createCategories}\n createDiscountDrafts={createDiscountDrafts}\n />\n ) : null}\n </Stack>\n\n <Dialog open={picking} onClose={busy ? undefined : () => setPicking(false)} fullWidth maxWidth=\"md\">\n <DialogTitle>{'Write copy for products'}</DialogTitle>\n <DialogContent>\n <Stack spacing={1.5} sx={{ pt: 1 }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Pick up to ${AI_PRODUCTS_BULK_MAX} products. Each gets a proposed description, search listing and ` +\n 'tags from its name, text, options and first photo, and you review every one before it is saved. ' +\n 'Prices are never written.'}\n </Typography>\n <ListTable\n rows={pickerRows}\n columns={pickerColumns}\n // A picker over the rows the hub hands its zone, not a list to\n // search: a filter here would narrow only those rows (AGL-3321).\n disableColumnFilter\n quickFilter={false}\n selectable={{ selected: picked, onChange: setPicked }}\n />\n {tooMany ? (\n <Alert severity=\"info\">{`Pick at most ${AI_PRODUCTS_BULK_MAX} products at a time.`}</Alert>\n ) : null}\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setPicking(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !picked.length || tooMany} onClick={() => void submitPicked()}>\n {picked.length ? `Write copy for ${picked.length}` : 'Write copy'}\n </Button>\n </DialogActions>\n </Dialog>\n\n {briefDialog}\n </Box>\n )\n}\nAiProductsHubCard.displayName = 'AiProductsHubCard'\n\nexport default AiProductsHubCard\n"],"names":["pluginDocsHelp","ListTable","Alert","Box","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","Link","Stack","TextField","Typography","useCallback","useEffect","useMemo","useRef","useState","AI_PRODUCTS_BULK_MAX","AI_PRODUCTS_IMPORT_WRITE_COPY","aiProductsBulkBrief","aiProductsBulkCount","aiProductsJobInputs","aiProductsProposalOfKind","registerAiProductsBriefOpener","AiBulkCopyReview","AiCatalogReview","AiCategoriesReview","useAiProductsJobs","BRIEF_MAX_CHARS","AI_PRODUCTS_BRIEF_COPY","catalog","title","label","placeholder","next","submit","categories","nameKey","name","replace","trim","toLowerCase","targetOf","job","started","id","AiProductsHubCard","props","hostId","products","lastImport","applyProductCopy","createProductDrafts","createCategories","createDiscountDrafts","orgId","verdict","jobs","notice","start","follows","setStarted","picking","setPicking","picked","setPicked","brief","setBrief","busy","setBusy","handledImports","Set","startBulk","productIds","ids","slice","length","target","current","Boolean","has","key","add","options","kind","text","heldNames","map","product","pickerRows","$id","status","photo","hasPhoto","pickerColumns","field","headerName","flex","minWidth","width","latest","find","bulkJob","catalogJob","categoriesJob","tooMany","help","excerpt","copy","submitBrief","briefDialog","open","onClose","undefined","fullWidth","maxWidth","spacing","sx","pt","multiline","minRows","value","onChange","event","helperText","toLocaleString","disabled","autoFocus","variant","color","direction","useFlexGap","flexWrap","size","severity","onClick","submitPicked","border","borderColor","borderRadius","p","aria-label","alignItems","flexGrow","href","rel","xs","sm","rows","columns","disableColumnFilter","quickFilter","selectable","selected","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,mCAAkC;AAEjE,SAASC,SAAS,QAA6B,uDAAsD;AACrG,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAEzE,SACEC,o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F;wCAAQ0D,UAAUzD;oCAAU;;gCAErDwC,wBACC,KAACzG;oCAAMsI,UAAS;8CAAQ,CAAC,aAAa,EAAErH,qBAAqB,oBAAoB,CAAC;qCAChF;gCACHyC,uBAAS,KAAC1D;oCAAMsI,UAAS;8CAAW5E;qCAAkB;;;;kCAG3D,MAACrD;;0CACC,KAACH;gCAAOqI,SAAS,IAAMxE,WAAW;gCAAQ+D,UAAU1D;0CACjD;;0CAEH,KAAClE;gCAAO8H,SAAQ;gCAAYF,UAAU1D,QAAQ,CAACJ,OAAOY,MAAM,IAAI6B;gCAAS8B,SAAS,IAAM,KAAKC;0CAC1FxE,OAAOY,MAAM,GAAG,CAAC,eAAe,EAAEZ,OAAOY,MAAM,EAAE,GAAG;;;;;;YAK1DkC;;;AAGP;AACAhE,kBAAkB4G,WAAW,GAAG;AAEhC,eAAe5G,kBAAiB"}
@@ -0,0 +1,16 @@
1
+ import type { ConsoleAutomationEditorZoneProps } from './ai-automation-zones';
2
+ export declare const AI_AUTOMATION_REVISE_COPY: {
3
+ readonly intro: "Describe a change, or let AI fix what would stop it working. You get a changed copy, switched off, to review — this one is left as it is.";
4
+ readonly label: "What should change?";
5
+ readonly placeholder: "Also tag them “newsletter”, and wait a day before the email";
6
+ readonly change: "Change with AI";
7
+ readonly fix: "Fix with AI";
8
+ readonly running: "Drafting the changed copy. This can take a few minutes.";
9
+ readonly drafted: "Changed copy drafted";
10
+ readonly review: "Review the copy";
11
+ readonly notListed: "The copy is saved. It appears in the list in a moment.";
12
+ readonly failed: "The automation could not be changed. Try again.";
13
+ readonly fixBrief: (name: string) => string;
14
+ };
15
+ export declare function AiReviseAutomation({ hostId, orgId, target, openAction }: ConsoleAutomationEditorZoneProps): import("react").JSX.Element;
16
+ export default AiReviseAutomation;