@aglyn/plugins-ai 1.0.0-beta.218 → 1.0.0-beta.219
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.
- package/README.md +2 -2
- package/package.json +17 -17
- package/src/index.d.ts +1 -0
- package/src/index.js.map +1 -1
- package/src/lib/activity/ai-activity-actions.js +8 -1
- package/src/lib/activity/ai-activity-actions.js.map +1 -1
- package/src/lib/components/ai-assist-provider.component.js +2 -2
- package/src/lib/components/ai-assist-provider.component.js.map +1 -1
- package/src/lib/components/ai-brief-dialog.component.js +3 -3
- package/src/lib/components/ai-brief-dialog.component.js.map +1 -1
- package/src/lib/components/ai-experiment-cards.component.js +1 -1
- package/src/lib/components/ai-experiment-cards.component.js.map +1 -1
- package/src/lib/components/ai-job-plan.component.d.ts +8 -0
- package/src/lib/components/ai-job-plan.component.js +21 -4
- package/src/lib/components/ai-job-plan.component.js.map +1 -1
- package/src/lib/components/ai-permissions-on-host.component.d.ts +12 -2
- package/src/lib/components/ai-permissions-on-host.component.js +12 -3
- package/src/lib/components/ai-permissions-on-host.component.js.map +1 -1
- package/src/lib/components/ai-product-copy-card.component.d.ts +1 -1
- package/src/lib/components/ai-product-copy-card.component.js.map +1 -1
- package/src/lib/components/ai-product-import-option.component.d.ts +1 -1
- package/src/lib/components/ai-product-import-option.component.js.map +1 -1
- package/src/lib/components/ai-product-zones.d.ts +124 -0
- package/src/lib/components/ai-product-zones.js +32 -0
- package/src/lib/components/ai-product-zones.js.map +1 -0
- package/src/lib/components/ai-products-hub-card.component.d.ts +1 -1
- package/src/lib/components/ai-products-hub-card.component.js.map +1 -1
- package/src/lib/components/ai-products-proposals.component.d.ts +1 -1
- package/src/lib/components/ai-products-proposals.component.js.map +1 -1
- package/src/lib/components/ai-seo-audit-card.component.js +35 -92
- package/src/lib/components/ai-seo-audit-card.component.js.map +1 -1
- package/src/lib/components/ai-seo-fields-card.component.js.map +1 -1
- package/src/lib/components/ai-theme-proposal-card.component.js.map +1 -1
- package/src/lib/components/assist-jobs-drawer.component.js +21 -15
- package/src/lib/components/assist-jobs-drawer.component.js.map +1 -1
- package/src/lib/components/assist-panel.component.js +2 -2
- package/src/lib/components/assist-panel.component.js.map +1 -1
- package/src/lib/components/assist-signals-page.component.js +2 -2
- package/src/lib/components/assist-signals-page.component.js.map +1 -1
- package/src/lib/jobs/ai-email-bindings.d.ts +28 -21
- package/src/lib/jobs/ai-email-bindings.js +75 -42
- package/src/lib/jobs/ai-email-bindings.js.map +1 -1
- package/src/lib/jobs/ai-job-campaign-step.d.ts +0 -2
- package/src/lib/jobs/ai-job-campaign-step.js +5 -10
- package/src/lib/jobs/ai-job-campaign-step.js.map +1 -1
- package/src/lib/jobs/ai-job-component-step.js +9 -3
- package/src/lib/jobs/ai-job-component-step.js.map +1 -1
- package/src/lib/jobs/ai-job-drafts.js +1 -1
- package/src/lib/jobs/ai-job-drafts.js.map +1 -1
- package/src/lib/jobs/ai-job-email-step.d.ts +0 -2
- package/src/lib/jobs/ai-job-email-step.js +1 -3
- package/src/lib/jobs/ai-job-email-step.js.map +1 -1
- package/src/lib/jobs/ai-job-experiment-step.d.ts +1 -1
- package/src/lib/jobs/ai-job-experiment-step.js +1 -1
- package/src/lib/jobs/ai-job-experiment-step.js.map +1 -1
- package/src/lib/jobs/ai-job-generation.d.ts +1 -1
- package/src/lib/jobs/ai-job-generation.js +10 -2
- package/src/lib/jobs/ai-job-generation.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-step.js +1 -1
- package/src/lib/jobs/ai-job-layout-step.js.map +1 -1
- package/src/lib/jobs/ai-job-page-sections.d.ts +4 -2
- package/src/lib/jobs/ai-job-page-sections.js +7 -4
- package/src/lib/jobs/ai-job-page-sections.js.map +1 -1
- package/src/lib/jobs/ai-job-page-step.js +7 -2
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-job-plan-conformance.js +33 -0
- package/src/lib/jobs/ai-job-plan-conformance.js.map +1 -1
- package/src/lib/jobs/ai-job-plan-step.d.ts +3 -0
- package/src/lib/jobs/ai-job-plan-step.js +29 -17
- package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
- package/src/lib/jobs/ai-job-plugin-drafts.d.ts +14 -6
- package/src/lib/jobs/ai-job-plugin-drafts.js +12 -4
- package/src/lib/jobs/ai-job-plugin-drafts.js.map +1 -1
- package/src/lib/jobs/ai-job-products-step.d.ts +7 -0
- package/src/lib/jobs/ai-job-products-step.js +54 -32
- package/src/lib/jobs/ai-job-products-step.js.map +1 -1
- package/src/lib/jobs/ai-job-seo-step.d.ts +3 -24
- package/src/lib/jobs/ai-job-seo-step.js +35 -108
- package/src/lib/jobs/ai-job-seo-step.js.map +1 -1
- package/src/lib/jobs/ai-job-template-step.js +1 -0
- package/src/lib/jobs/ai-job-template-step.js.map +1 -1
- package/src/lib/jobs/ai-job-theme-step.d.ts +1 -1
- package/src/lib/jobs/ai-job-theme-step.js +1 -1
- package/src/lib/jobs/ai-job-theme-step.js.map +1 -1
- package/src/lib/jobs/ai-job-workflow-step.js +17 -9
- package/src/lib/jobs/ai-job-workflow-step.js.map +1 -1
- package/src/lib/jobs/ai-workflow-records.d.ts +19 -11
- package/src/lib/jobs/ai-workflow-records.js +60 -27
- package/src/lib/jobs/ai-workflow-records.js.map +1 -1
- package/src/lib/model/ai-allotments.d.ts +11 -3
- package/src/lib/model/ai-allotments.js +21 -4
- package/src/lib/model/ai-allotments.js.map +1 -1
- package/src/lib/model/ai-automation-outline.d.ts +21 -2
- package/src/lib/model/ai-automation-outline.js.map +1 -1
- package/src/lib/model/ai-build-plan.d.ts +57 -0
- package/src/lib/model/ai-build-plan.js +116 -7
- package/src/lib/model/ai-build-plan.js.map +1 -1
- package/src/lib/model/ai-seo.d.ts +11 -51
- package/src/lib/model/ai-seo.js +0 -17
- package/src/lib/model/ai-seo.js.map +1 -1
- package/src/lib/model/ai-site-inventory.js +1 -1
- package/src/lib/model/ai-site-inventory.js.map +1 -1
- package/src/lib/model/ai-template-subjects.js +2 -2
- package/src/lib/model/ai-template-subjects.js.map +1 -1
- package/src/lib/model/ai-theme-proposal.d.ts +1 -1
- package/src/lib/model/ai-theme-proposal.js +1 -1
- package/src/lib/model/ai-theme-proposal.js.map +1 -1
- package/src/lib/model/ai-workflow-job.d.ts +1 -3
- package/src/lib/model/ai-workflow-job.js +1 -2
- package/src/lib/model/ai-workflow-job.js.map +1 -1
- package/src/lib/plan-entitlements.d.ts +149 -0
- package/src/lib/plan-entitlements.js +168 -0
- package/src/lib/plan-entitlements.js.map +1 -0
- package/src/lib/plugin.js +1 -1
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/runtime/ai-doctrine-validators.d.ts +25 -4
- package/src/lib/runtime/ai-doctrine-validators.js +178 -21
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-doctrine.js +5 -5
- package/src/lib/runtime/ai-doctrine.js.map +1 -1
- package/src/lib/runtime/ai-eval-live.js +29 -14
- package/src/lib/runtime/ai-eval-live.js.map +1 -1
- package/src/lib/runtime/ai-eval.d.ts +8 -1
- package/src/lib/runtime/ai-eval.js +29 -2
- package/src/lib/runtime/ai-eval.js.map +1 -1
- package/src/lib/runtime/ai-node-tree.js +3 -3
- package/src/lib/runtime/ai-node-tree.js.map +1 -1
- package/src/lib/runtime/ai-palette.d.ts +6 -0
- package/src/lib/runtime/ai-palette.generated.js +15 -12
- package/src/lib/runtime/ai-palette.generated.js.map +1 -1
- package/src/lib/runtime/ai-palette.js +7 -1
- package/src/lib/runtime/ai-palette.js.map +1 -1
- package/src/lib/runtime/seo-audit.d.ts +13 -63
- package/src/lib/runtime/seo-audit.js +22 -207
- package/src/lib/runtime/seo-audit.js.map +1 -1
- package/src/lib/runtime/site-inventory.js +1 -1
- package/src/lib/runtime/site-inventory.js.map +1 -1
- package/src/lib/server/ai-assist-prompts.js +3 -3
- package/src/lib/server/ai-assist-prompts.js.map +1 -1
- package/src/lib/server/assist-chat.js +11 -10
- package/src/lib/server/assist-chat.js.map +1 -1
- package/src/lib/server/assist-view-context.js +23 -23
- package/src/lib/server/assist-view-context.js.map +1 -1
- package/src/lib/server.d.ts +1 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/testing/stand-in-automation-index.d.ts +20 -0
- package/src/lib/testing/stand-in-automation-index.js +102 -0
- package/src/lib/testing/stand-in-automation-index.js.map +1 -0
- package/src/lib/testing/stand-in-list-send-time.d.ts +4 -0
- package/src/lib/testing/stand-in-list-send-time.js +77 -0
- package/src/lib/testing/stand-in-list-send-time.js.map +1 -0
- package/src/lib/testing/stand-in-pipeline-index.d.ts +32 -0
- package/src/lib/testing/stand-in-pipeline-index.js +59 -0
- package/src/lib/testing/stand-in-pipeline-index.js.map +1 -0
- package/src/lib/testing/stand-in-product-index.d.ts +20 -0
- package/src/lib/testing/stand-in-product-index.js +105 -0
- package/src/lib/testing/stand-in-product-index.js.map +1 -0
- package/src/lib/tools/ai-component-tool.js +2 -2
- package/src/lib/tools/ai-component-tool.js.map +1 -1
- package/src/lib/tools/ai-duplicate-resource-tool.js +1 -1
- package/src/lib/tools/ai-duplicate-resource-tool.js.map +1 -1
- package/src/lib/tools/ai-seo-tool.d.ts +6 -18
- package/src/lib/tools/ai-seo-tool.js +7 -38
- package/src/lib/tools/ai-seo-tool.js.map +1 -1
- package/src/lib/tools/ai-workflow-tool.d.ts +1 -1
- package/src/lib/tools/ai-workflow-tool.js +1 -1
- package/src/lib/tools/ai-workflow-tool.js.map +1 -1
- package/src/lib/usage/ai-allotment-alerts.js +8 -1
- package/src/lib/usage/ai-allotment-alerts.js.map +1 -1
- package/src/lib/usage/assist-free-taste.js +2 -1
- package/src/lib/usage/assist-free-taste.js.map +1 -1
- package/src/lib/usage-axes.d.ts +39 -0
- package/src/lib/usage-axes.js +70 -0
- package/src/lib/usage-axes.js.map +1 -0
- package/src/lib/runtime/seo-page-facts.d.ts +0 -61
- package/src/lib/runtime/seo-page-facts.js +0 -150
- package/src/lib/runtime/seo-page-facts.js.map +0 -1
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
/**
|
|
18
|
+
* What the commerce plugin's product zones hand this plugin's widgets.
|
|
19
|
+
*
|
|
20
|
+
* `productEditor`, `productsHub` and `productImport` are zones the commerce
|
|
21
|
+
* plugin hosts and declares (`registerPluginZone`), with their props on its
|
|
22
|
+
* own zone tokens. A plugin never imports another plugin, so the widgets
|
|
23
|
+
* registered there read the props through the shapes restated here — the
|
|
24
|
+
* zone's props as the host documents them, by the same names. A widget is
|
|
25
|
+
* handed whatever the host passes, so this restates what the host SENDS; a
|
|
26
|
+
* field dropped from the host's declaration leaves a widget reading
|
|
27
|
+
* `undefined`, which is why every member below is one the host documents in
|
|
28
|
+
* the injection zones reference.
|
|
29
|
+
*
|
|
30
|
+
* Types only: nothing here reaches a bundle.
|
|
31
|
+
*/
|
|
32
|
+
export type ConsoleProductType = 'physical' | 'digital' | 'service';
|
|
33
|
+
export interface ConsoleProductOption {
|
|
34
|
+
name: string;
|
|
35
|
+
values: string[];
|
|
36
|
+
}
|
|
37
|
+
/** A product as the editor holds it: saved, or staged and unsaved. */
|
|
38
|
+
export interface ConsoleProductDraft {
|
|
39
|
+
/** `null` for a product nobody has saved yet. */
|
|
40
|
+
id: string | null;
|
|
41
|
+
name: string;
|
|
42
|
+
type: ConsoleProductType;
|
|
43
|
+
description: string;
|
|
44
|
+
tags: string[];
|
|
45
|
+
categoryIds: string[];
|
|
46
|
+
options: ConsoleProductOption[];
|
|
47
|
+
/** The product's media, in order; the first is the photo the storefront leads with. */
|
|
48
|
+
mediaUrls: string[];
|
|
49
|
+
seoTitle: string;
|
|
50
|
+
seoDescription: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Copy proposed for one product. A field left out is left alone;
|
|
54
|
+
* `optionNames` renames the product's options in order.
|
|
55
|
+
*/
|
|
56
|
+
export interface ConsoleProductCopyValues {
|
|
57
|
+
description?: string;
|
|
58
|
+
tags?: string[];
|
|
59
|
+
categoryIds?: string[];
|
|
60
|
+
optionNames?: string[];
|
|
61
|
+
seoTitle?: string;
|
|
62
|
+
seoDescription?: string;
|
|
63
|
+
}
|
|
64
|
+
/** The `productEditor` zone: the product, and a door that stages copy as unsaved edits. */
|
|
65
|
+
export interface ConsoleProductEditorZoneProps {
|
|
66
|
+
hostId: string;
|
|
67
|
+
orgId: string | undefined;
|
|
68
|
+
product: ConsoleProductDraft;
|
|
69
|
+
categories: ReadonlyArray<{
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
}>;
|
|
73
|
+
proposeValues: (values: ConsoleProductCopyValues, key: string) => void;
|
|
74
|
+
}
|
|
75
|
+
/** A catalog row as the products hub holds it. */
|
|
76
|
+
export interface ConsoleProductSummary {
|
|
77
|
+
id: string;
|
|
78
|
+
name: string;
|
|
79
|
+
status: 'draft' | 'active' | 'archived';
|
|
80
|
+
priceMissing: boolean;
|
|
81
|
+
hasPhoto: boolean;
|
|
82
|
+
}
|
|
83
|
+
/** A new product proposed to the hub, which creates it as a draft with no price. */
|
|
84
|
+
export interface ConsoleProposedProduct {
|
|
85
|
+
name: string;
|
|
86
|
+
type: ConsoleProductType;
|
|
87
|
+
description: string;
|
|
88
|
+
tags: string[];
|
|
89
|
+
options: ConsoleProductOption[];
|
|
90
|
+
seoTitle: string;
|
|
91
|
+
seoDescription: string;
|
|
92
|
+
}
|
|
93
|
+
/** A discount proposed to the hub, which creates it switched off. */
|
|
94
|
+
export interface ConsoleProposedDiscount {
|
|
95
|
+
name: string;
|
|
96
|
+
code: string | null;
|
|
97
|
+
kind: 'percent' | 'fixed' | 'free_shipping';
|
|
98
|
+
valuePct: number | null;
|
|
99
|
+
valueCents: number | null;
|
|
100
|
+
minSubtotalCents: number | null;
|
|
101
|
+
}
|
|
102
|
+
/** The `productsHub` zone: the catalog rows, the latest import, and the hub's writes. */
|
|
103
|
+
export interface ConsoleProductsHubZoneProps {
|
|
104
|
+
hostId: string;
|
|
105
|
+
orgId: string | undefined;
|
|
106
|
+
products: readonly ConsoleProductSummary[];
|
|
107
|
+
lastImport: {
|
|
108
|
+
key: string;
|
|
109
|
+
productIds: readonly string[];
|
|
110
|
+
options: Readonly<Record<string, boolean>>;
|
|
111
|
+
} | null;
|
|
112
|
+
applyProductCopy: (productId: string, values: ConsoleProductCopyValues) => Promise<void>;
|
|
113
|
+
createProductDrafts: (products: readonly ConsoleProposedProduct[]) => Promise<string[]>;
|
|
114
|
+
createCategories: (names: readonly string[]) => Promise<number>;
|
|
115
|
+
createDiscountDrafts: (discounts: readonly ConsoleProposedDiscount[]) => Promise<number>;
|
|
116
|
+
}
|
|
117
|
+
/** The `productImport` zone: the import's size and the options set for it. */
|
|
118
|
+
export interface ConsoleProductImportZoneProps {
|
|
119
|
+
hostId: string;
|
|
120
|
+
orgId: string | undefined;
|
|
121
|
+
count: number;
|
|
122
|
+
options: Readonly<Record<string, boolean>>;
|
|
123
|
+
setOption: (key: string, on: boolean) => void;
|
|
124
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
* What the commerce plugin's product zones hand this plugin's widgets.
|
|
18
|
+
*
|
|
19
|
+
* `productEditor`, `productsHub` and `productImport` are zones the commerce
|
|
20
|
+
* plugin hosts and declares (`registerPluginZone`), with their props on its
|
|
21
|
+
* own zone tokens. A plugin never imports another plugin, so the widgets
|
|
22
|
+
* registered there read the props through the shapes restated here — the
|
|
23
|
+
* zone's props as the host documents them, by the same names. A widget is
|
|
24
|
+
* handed whatever the host passes, so this restates what the host SENDS; a
|
|
25
|
+
* field dropped from the host's declaration leaves a widget reading
|
|
26
|
+
* `undefined`, which is why every member below is one the host documents in
|
|
27
|
+
* the injection zones reference.
|
|
28
|
+
*
|
|
29
|
+
* Types only: nothing here reaches a bundle.
|
|
30
|
+
*/ /** The `productImport` zone: the import's size and the options set for it. */ export { };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=ai-product-zones.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-product-zones.ts"],"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\n/**\n * What the commerce plugin's product zones hand this plugin's widgets.\n *\n * `productEditor`, `productsHub` and `productImport` are zones the commerce\n * plugin hosts and declares (`registerPluginZone`), with their props on its\n * own zone tokens. A plugin never imports another plugin, so the widgets\n * registered there read the props through the shapes restated here — the\n * zone's props as the host documents them, by the same names. A widget is\n * handed whatever the host passes, so this restates what the host SENDS; a\n * field dropped from the host's declaration leaves a widget reading\n * `undefined`, which is why every member below is one the host documents in\n * the injection zones reference.\n *\n * Types only: nothing here reaches a bundle.\n */\n\nexport type ConsoleProductType = 'physical' | 'digital' | 'service'\n\nexport interface ConsoleProductOption {\n name: string\n values: string[]\n}\n\n/** A product as the editor holds it: saved, or staged and unsaved. */\nexport interface ConsoleProductDraft {\n /** `null` for a product nobody has saved yet. */\n id: string | null\n name: string\n type: ConsoleProductType\n description: string\n tags: string[]\n categoryIds: string[]\n options: ConsoleProductOption[]\n /** The product's media, in order; the first is the photo the storefront leads with. */\n mediaUrls: string[]\n seoTitle: string\n seoDescription: string\n}\n\n/**\n * Copy proposed for one product. A field left out is left alone;\n * `optionNames` renames the product's options in order.\n */\nexport interface ConsoleProductCopyValues {\n description?: string\n tags?: string[]\n categoryIds?: string[]\n optionNames?: string[]\n seoTitle?: string\n seoDescription?: string\n}\n\n/** The `productEditor` zone: the product, and a door that stages copy as unsaved edits. */\nexport interface ConsoleProductEditorZoneProps {\n hostId: string\n orgId: string | undefined\n product: ConsoleProductDraft\n categories: ReadonlyArray<{ id: string; name: string }>\n proposeValues: (values: ConsoleProductCopyValues, key: string) => void\n}\n\n/** A catalog row as the products hub holds it. */\nexport interface ConsoleProductSummary {\n id: string\n name: string\n status: 'draft' | 'active' | 'archived'\n priceMissing: boolean\n hasPhoto: boolean\n}\n\n/** A new product proposed to the hub, which creates it as a draft with no price. */\nexport interface ConsoleProposedProduct {\n name: string\n type: ConsoleProductType\n description: string\n tags: string[]\n options: ConsoleProductOption[]\n seoTitle: string\n seoDescription: string\n}\n\n/** A discount proposed to the hub, which creates it switched off. */\nexport interface ConsoleProposedDiscount {\n name: string\n code: string | null\n kind: 'percent' | 'fixed' | 'free_shipping'\n valuePct: number | null\n valueCents: number | null\n minSubtotalCents: number | null\n}\n\n/** The `productsHub` zone: the catalog rows, the latest import, and the hub's writes. */\nexport interface ConsoleProductsHubZoneProps {\n hostId: string\n orgId: string | undefined\n products: readonly ConsoleProductSummary[]\n lastImport: {\n key: string\n productIds: readonly string[]\n options: Readonly<Record<string, boolean>>\n } | null\n applyProductCopy: (productId: string, values: ConsoleProductCopyValues) => Promise<void>\n createProductDrafts: (products: readonly ConsoleProposedProduct[]) => Promise<string[]>\n createCategories: (names: readonly string[]) => Promise<number>\n createDiscountDrafts: (discounts: readonly ConsoleProposedDiscount[]) => Promise<number>\n}\n\n/** The `productImport` zone: the import's size and the options set for it. */\nexport interface ConsoleProductImportZoneProps {\n hostId: string\n orgId: string | undefined\n count: number\n options: Readonly<Record<string, boolean>>\n setOption: (key: string, on: boolean) => void\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;CAcC,GA6FD,4EAA4E,GAC5E,WAMC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConsoleProductsHubZoneProps } from '
|
|
1
|
+
import type { ConsoleProductsHubZoneProps } from './ai-product-zones';
|
|
2
2
|
type BriefKind = 'catalog' | 'categories';
|
|
3
3
|
/** What each brief dialog says. */
|
|
4
4
|
export declare const AI_PRODUCTS_BRIEF_COPY: Readonly<Record<BriefKind, {
|
|
@@ -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 '@aglyn/aglyn/plugin-manager/feature-plugins'\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","useFl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AM4G,WAAU;oCAAMD,SAAS;oCAAGkC,UAAU;oCAACxC,IAAI;wCAAEyC,UAAU;oCAAO;;sDACnE,KAACpJ;4CAAK0H,MAAK;4CAAQU,OAAM;4CAAUhB,SAAQ;4CAAWxF,OAAM;;sDAC5D,KAAC5B;4CAAK0H,MAAK;4CAAQU,OAAM;4CAAUhB,SAAQ;4CAAWxF,OAAM;;;qCAE5D;gCACH0B,uBAAS,KAACzD;oCAAMgI,UAAS;8CAAWvE;qCAAkB;;;;kCAG3D,MAACpD;;0CACC,KAACH;gCAAO6H,SAAS,IAAM7D,SAAS;gCAAO4D,UAAU3D;0CAC9C;;0CAEH,KAACjE;gCAAOqH,SAAQ;gCAAYO,UAAU3D,QAAQ,CAACb,SAAS,EAACW,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 { 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,oBA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;;0CAEH,KAACjE;gCAAOqH,SAAQ;gCAAYO,UAAU3D,QAAQ,CAACb,SAAS,EAACW,yBAAAA,MAAO2C,IAAI,CAACrE,IAAI;gCAAIwF,SAAS,IAAM,KAAKpB;0CAC9FF,wBAAAA,KAAMvE,MAAM;;;;;;;;AAMzB;AACAW,kBAAkB2G,WAAW,GAAG;AAEhC,eAAe3G,kBAAiB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConsoleProductsHubZoneProps } from '
|
|
1
|
+
import type { ConsoleProductsHubZoneProps } from './ai-product-zones';
|
|
2
2
|
import type { AiJobSummary } from '../model/ai-jobs.types';
|
|
3
3
|
import { type AiProposedDiscount } from '../model/ai-products';
|
|
4
4
|
/** A discount's offer, in the words the discounts card uses. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-products-proposals.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 type { ConsoleProductsHubZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { ListTable, type ListTableProps } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { Alert, Button, Chip, CircularProgress, Stack, Typography } from '@mui/material'\nimport { useCallback, useMemo, useState } from 'react'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport {\n aiProductCopyProposals,\n aiProductsBulkCount,\n aiProductsProposalOfKind,\n type AiProductCopyProposal,\n type AiProposedDiscount,\n} from '../model/ai-products'\nimport { aiProductCopyValues } from './ai-product-copy-card.component'\nimport { isAiJobMoving } from './use-ai-products-jobs'\n\n/**\n * The review tables of the products hub's AI card (AGL-2916): what a\n * `products` job proposed, row by row, before anything is written. Every\n * write is one the hub makes when a person asks for it — Apply, Apply to all,\n * Create drafts, Create selected — and the hub passes over what the site\n * already has, so a proposal applied twice creates nothing twice.\n *\n * Each table is one job's whole answer, held in hand and capped by the job\n * (`AI_PRODUCTS_BULK_MAX`, `AI_CATEGORIES_MAX`, `AI_DISCOUNTS_MAX`, a dozen\n * proposed products), so none offers a Filters panel or a search box: a\n * bounded readout is read whole, and a grid that filtered the rows it holds\n * is the pattern every list is leaving (AGL-3321).\n */\n\n/** A column of a review table, in the shared list table's own terms. */\ntype GridColDef = NonNullable<ListTableProps['columns']>[number]\n\nconst clip = (text: string, max: number) => (text.length > max ? `${text.slice(0, max - 1)}…` : text)\n\nconst messageOf = (error: unknown, fallback: string) =>\n error instanceof Error && error.message ? error.message : fallback\n\n/** A discount's offer, in the words the discounts card uses. */\nexport function aiDiscountOffer(discount: AiProposedDiscount): string {\n if (discount.kind === 'percent') return `${discount.valuePct ?? 0}% off`\n if (discount.kind === 'fixed') return `$${((discount.valueCents ?? 0) / 100).toFixed(2)} off`\n return 'Free shipping'\n}\n\nfunction JobState(props: { job: AiJobSummary; doing: string }) {\n const { job } = props\n if (isAiJobMoving(job)) {\n return (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <CircularProgress size={16} aria-label={props.doing} />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {props.doing}\n </Typography>\n </Stack>\n )\n }\n return job.error ? <Alert severity={job.status === 'failed' ? 'error' : 'warning'}>{job.error}</Alert> : null\n}\n\n/* ------------------------------------------------------------------------ *\n * Copy for many products\n * ------------------------------------------------------------------------ */\n\ntype RowState = 'applying' | 'applied' | { error: string }\n\nexport function AiBulkCopyReview(props: {\n job: AiJobSummary\n applyProductCopy: ConsoleProductsHubZoneProps['applyProductCopy']\n}) {\n const { job, applyProductCopy } = props\n const proposals = aiProductCopyProposals(job)\n const asked = aiProductsBulkCount(job) ?? proposals.length\n const [rows, setRows] = useState<Record<string, RowState>>({})\n const [applyingAll, setApplyingAll] = useState(false)\n\n const ready = (proposal: AiProductCopyProposal) =>\n Boolean(proposal.values && proposal.product.id) && rows[proposal.product.id as string] !== 'applied'\n\n const apply = useCallback(\n async (proposal: AiProductCopyProposal) => {\n const id = proposal.product.id\n if (!id || !proposal.values) return\n setRows((current) => ({ ...current, [id]: 'applying' }))\n try {\n await applyProductCopy(id, aiProductCopyValues(proposal))\n setRows((current) => ({ ...current, [id]: 'applied' }))\n } catch (error) {\n setRows((current) => ({ ...current, [id]: { error: messageOf(error, 'The copy could not be saved.') } }))\n }\n },\n [applyProductCopy],\n )\n\n /** Applies each proposal in turn, so one refusal names its product and the rest still land. */\n const applyAll = useCallback(\n async (targets: readonly AiProductCopyProposal[]) => {\n setApplyingAll(true)\n try {\n for (const proposal of targets) await apply(proposal)\n } finally {\n setApplyingAll(false)\n }\n },\n [apply],\n )\n\n const columns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Product', flex: 1, minWidth: 160 },\n { field: 'description', headerName: 'Proposed description', flex: 2, minWidth: 220 },\n { field: 'seoTitle', headerName: 'Search title', flex: 1, minWidth: 160 },\n {\n field: 'actions',\n headerName: '',\n width: 170,\n sortable: false,\n renderCell: ({ row }: { row: { proposal: AiProductCopyProposal } }) => {\n const { proposal } = row\n if (proposal.skipped) return <Chip size=\"small\" variant=\"outlined\" label=\"Skipped\" title={proposal.skipped} />\n const state = proposal.product.id ? rows[proposal.product.id] : undefined\n if (state === 'applied') return <Chip size=\"small\" color=\"success\" variant=\"outlined\" label=\"Applied\" />\n if (typeof state === 'object') return <Chip size=\"small\" color=\"error\" variant=\"outlined\" label=\"Not saved\" title={state.error} />\n return (\n <Button size=\"small\" disabled={state === 'applying' || applyingAll} onClick={() => void apply(proposal)}>\n {'Apply'}\n </Button>\n )\n },\n },\n ],\n [rows, applyingAll, apply],\n )\n\n const tableRows = proposals.map((proposal) => ({\n $id: proposal.product.id ?? proposal.product.name,\n name: proposal.product.name,\n description: proposal.values ? clip(proposal.values.description, 140) : (proposal.skipped ?? ''),\n seoTitle: proposal.values?.seoTitle ?? '',\n proposal,\n }))\n const readyCount = proposals.filter(ready).length\n const errors = Object.values(rows).filter((state): state is { error: string } => typeof state === 'object')\n const gaps = proposals.filter((proposal) => proposal.gaps.length).length\n\n return (\n <Stack spacing={1} aria-label=\"Proposed product copy\">\n <Typography variant=\"subtitle2\">{`Product copy · ${proposals.length} of ${asked}`}</Typography>\n <JobState job={job} doing={`Writing copy: ${proposals.length} of ${asked}`} />\n {tableRows.length ? <ListTable rows={tableRows} columns={columns} hideFooter disableColumnFilter quickFilter={false} /> : null}\n {gaps ? (\n <Alert severity=\"warning\">\n {`${gaps} ${gaps === 1 ? 'description marks' : 'descriptions mark'} facts in [brackets] to fill in before you publish.`}\n </Alert>\n ) : null}\n {errors.length ? <Alert severity=\"error\">{errors[0].error}</Alert> : null}\n <Button\n size=\"small\"\n variant=\"contained\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={!readyCount || applyingAll}\n onClick={() => void applyAll(proposals.filter(ready))}\n >\n {readyCount ? `Apply to all ${readyCount}` : 'Apply to all'}\n </Button>\n </Stack>\n )\n}\n\n/* ------------------------------------------------------------------------ *\n * A store's first products\n * ------------------------------------------------------------------------ */\n\nexport function AiCatalogReview(props: {\n job: AiJobSummary\n heldNames: ReadonlySet<string>\n createProductDrafts: ConsoleProductsHubZoneProps['createProductDrafts']\n}) {\n const { job, heldNames, createProductDrafts } = props\n const proposal = aiProductsProposalOfKind(job, 'catalog')\n const products = useMemo(() => proposal?.products ?? [], [proposal])\n const held = (name: string) => heldNames.has(name.replace(/\\s+/g, ' ').trim().toLowerCase())\n const [selected, setSelected] = useState<string[] | null>(null)\n const [busy, setBusy] = useState(false)\n const [result, setResult] = useState<{ severity: 'success' | 'error'; text: string } | null>(null)\n\n const rows = products.map((product, index) => ({\n $id: `p${index}`,\n name: product.name,\n type: product.type,\n options: product.options.map((option) => `${option.name}: ${option.values.join(', ')}`).join(' · ') || '—',\n photo: product.photo,\n inCatalog: held(product.name),\n product,\n }))\n const chosen = selected ?? rows.filter((row) => !row.inCatalog).map((row) => row.$id)\n\n const columns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Product', flex: 1, minWidth: 180 },\n { field: 'options', headerName: 'Options', flex: 1, minWidth: 160 },\n {\n field: 'price',\n headerName: 'Price',\n width: 130,\n sortable: false,\n // Never proposed: prices are the merchant's to set.\n renderCell: () => <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Set a price\" />,\n },\n {\n field: 'photo',\n headerName: 'Photo',\n flex: 1,\n minWidth: 200,\n sortable: false,\n renderCell: ({ row }: { row: { photo: string; inCatalog: boolean } }) => (\n <Stack spacing={0.25} sx={{ py: 0.5 }}>\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Needs a photo\" sx={{ alignSelf: 'flex-start' }} />\n <Typography variant=\"caption\" color=\"text.secondary\" sx={{ whiteSpace: 'normal' }}>\n {row.photo}\n </Typography>\n </Stack>\n ),\n },\n {\n field: 'inCatalog',\n headerName: '',\n width: 150,\n sortable: false,\n renderCell: ({ row }: { row: { inCatalog: boolean } }) =>\n row.inCatalog ? <Chip size=\"small\" variant=\"outlined\" label=\"In your catalog\" /> : null,\n },\n ],\n [],\n )\n\n const create = useCallback(async () => {\n const picks = rows.filter((row) => chosen.includes(row.$id)).map((row) => row.product)\n if (!picks.length) return\n setBusy(true)\n setResult(null)\n try {\n const created = await createProductDrafts(\n picks.map((product) => ({\n name: product.name,\n type: product.type,\n description: product.description,\n tags: product.tags,\n options: product.options,\n seoTitle: product.seoTitle,\n seoDescription: product.seoDescription,\n })),\n )\n const passed = picks.length - created.length\n setResult({\n severity: 'success',\n text:\n `Created ${created.length} draft ${created.length === 1 ? 'product' : 'products'}. ` +\n 'Each needs a price and a photo before you activate it.' +\n (passed ? ` ${passed} already in your catalog ${passed === 1 ? 'was' : 'were'} left as they are.` : ''),\n })\n setSelected([])\n } catch (error) {\n setResult({ severity: 'error', text: messageOf(error, 'The draft products could not be created.') })\n } finally {\n setBusy(false)\n }\n }, [rows, chosen, createProductDrafts])\n\n return (\n <Stack spacing={1} aria-label=\"Proposed products\">\n <Typography variant=\"subtitle2\">{'Proposed products'}</Typography>\n <JobState job={job} doing=\"Proposing products from your brief\" />\n {rows.length ? (\n <>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Each is created as a draft with its price left empty and no photo. Set both in the product editor, ' +\n 'then activate it.'}\n </Typography>\n <ListTable\n rows={rows}\n columns={columns}\n hideFooter\n disableColumnFilter\n quickFilter={false}\n getRowHeight={() => 'auto'}\n selectable={{ selected: chosen, onChange: setSelected }}\n />\n <Button\n size=\"small\"\n variant=\"contained\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={busy || !chosen.length}\n onClick={() => void create()}\n >\n {`Create ${chosen.length} ${chosen.length === 1 ? 'draft' : 'drafts'}`}\n </Button>\n </>\n ) : null}\n {result ? <Alert severity={result.severity}>{result.text}</Alert> : null}\n </Stack>\n )\n}\n\n/* ------------------------------------------------------------------------ *\n * Categories and discounts\n * ------------------------------------------------------------------------ */\n\nexport function AiCategoriesReview(props: {\n job: AiJobSummary\n createCategories: ConsoleProductsHubZoneProps['createCategories']\n createDiscountDrafts: ConsoleProductsHubZoneProps['createDiscountDrafts']\n}) {\n const { job, createCategories, createDiscountDrafts } = props\n const proposal = aiProductsProposalOfKind(job, 'categories')\n const categoryRows = (proposal?.categories ?? []).map((category, index) => ({\n $id: `c${index}`,\n name: category.name,\n why: category.why,\n }))\n const discountRows = (proposal?.discounts ?? []).map((discount, index) => ({\n $id: `d${index}`,\n name: discount.name,\n code: discount.code ?? 'Applies on its own',\n offer: aiDiscountOffer(discount),\n minimum: discount.minSubtotalCents ? `$${(discount.minSubtotalCents / 100).toFixed(2)}` : 'Any order',\n why: discount.why,\n discount,\n }))\n const [categories, setCategories] = useState<string[] | null>(null)\n const [discounts, setDiscounts] = useState<string[] | null>(null)\n const [busy, setBusy] = useState(false)\n const [result, setResult] = useState<{ severity: 'success' | 'error'; text: string } | null>(null)\n const chosenCategories = categories ?? categoryRows.map((row) => row.$id)\n const chosenDiscounts = discounts ?? discountRows.map((row) => row.$id)\n\n const categoryColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Category', flex: 1, minWidth: 160 },\n { field: 'why', headerName: 'Why', flex: 2, minWidth: 220 },\n ],\n [],\n )\n const discountColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Discount', flex: 1, minWidth: 150 },\n { field: 'code', headerName: 'Code', width: 150 },\n { field: 'offer', headerName: 'Offer', width: 120 },\n { field: 'minimum', headerName: 'Minimum order', width: 130 },\n { field: 'why', headerName: 'Why', flex: 2, minWidth: 200 },\n ],\n [],\n )\n\n const create = useCallback(async () => {\n setBusy(true)\n setResult(null)\n try {\n const madeCategories = await createCategories(\n categoryRows.filter((row) => chosenCategories.includes(row.$id)).map((row) => row.name),\n )\n const madeDiscounts = await createDiscountDrafts(\n discountRows\n .filter((row) => chosenDiscounts.includes(row.$id))\n .map(({ discount }) => ({\n name: discount.name,\n code: discount.code,\n kind: discount.kind,\n valuePct: discount.valuePct,\n valueCents: discount.valueCents,\n minSubtotalCents: discount.minSubtotalCents,\n })),\n )\n setResult({\n severity: 'success',\n text:\n `Created ${madeCategories} ${madeCategories === 1 ? 'category' : 'categories'} and ` +\n `${madeDiscounts} ${madeDiscounts === 1 ? 'discount' : 'discounts'}. ` +\n 'Discounts start switched off: switch each on under Promotions when you are ready. ' +\n 'Anything your store already had was left as it is.',\n })\n setCategories([])\n setDiscounts([])\n } catch (error) {\n setResult({ severity: 'error', text: messageOf(error, 'The categories and discounts could not be created.') })\n } finally {\n setBusy(false)\n }\n }, [categoryRows, discountRows, chosenCategories, chosenDiscounts, createCategories, createDiscountDrafts])\n\n const any = chosenCategories.length + chosenDiscounts.length\n return (\n <Stack spacing={1} aria-label=\"Proposed categories and discounts\">\n <Typography variant=\"subtitle2\">{'Proposed categories and discounts'}</Typography>\n <JobState job={job} doing=\"Proposing categories and discounts from your brief\" />\n {categoryRows.length ? (\n <ListTable\n rows={categoryRows}\n columns={categoryColumns}\n hideFooter\n disableColumnFilter\n quickFilter={false}\n selectable={{ selected: chosenCategories, onChange: setCategories }}\n />\n ) : null}\n {discountRows.length ? (\n <ListTable\n rows={discountRows}\n columns={discountColumns}\n hideFooter\n disableColumnFilter\n quickFilter={false}\n selectable={{ selected: chosenDiscounts, onChange: setDiscounts }}\n />\n ) : null}\n {categoryRows.length || discountRows.length ? (\n <Button\n size=\"small\"\n variant=\"contained\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={busy || !any}\n onClick={() => void create()}\n >\n {'Create selected'}\n </Button>\n ) : null}\n {result ? <Alert severity={result.severity}>{result.text}</Alert> : null}\n </Stack>\n )\n}\n"],"names":["ListTable","Alert","Button","Chip","CircularProgress","Stack","Typography","useCallback","useMemo","useState","aiProductCopyProposals","aiProductsBulkCount","aiProductsProposalOfKind","aiProductCopyValues","isAiJobMoving","clip","text","max","length","slice","messageOf","error","fallback","Error","message","aiDiscountOffer","discount","kind","valuePct","valueCents","toFixed","JobState","props","job","direction","spacing","sx","alignItems","size","aria-label","doing","variant","color","severity","status","AiBulkCopyReview","applyProductCopy","proposals","asked","rows","setRows","applyingAll","setApplyingAll","ready","proposal","Boolean","values","product","id","apply","current","applyAll","targets","columns","field","headerName","flex","minWidth","width","sortable","renderCell","row","skipped","label","title","state","undefined","disabled","onClick","tableRows","map","$id","name","description","seoTitle","readyCount","filter","errors","Object","gaps","hideFooter","disableColumnFilter","quickFilter","alignSelf","AiCatalogReview","heldNames","createProductDrafts","products","held","has","replace","trim","toLowerCase","selected","setSelected","busy","setBusy","result","setResult","index","type","options","option","join","photo","inCatalog","chosen","py","whiteSpace","create","picks","includes","created","tags","seoDescription","passed","getRowHeight","selectable","onChange","AiCategoriesReview","createCategories","createDiscountDrafts","categoryRows","categories","category","why","discountRows","discounts","code","offer","minimum","minSubtotalCents","setCategories","setDiscounts","chosenCategories","chosenDiscounts","categoryColumns","discountColumns","madeCategories","madeDiscounts","any"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAGA,SAASA,SAAS,QAA6B,uDAAsD;AACrG,SAASC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,gBAAgB,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAe;AACxF,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAEtD,SACEC,sBAAsB,EACtBC,mBAAmB,EACnBC,wBAAwB,QAGnB,0BAAsB;AAC7B,SAASC,mBAAmB,QAAQ,sCAAkC;AACtE,SAASC,aAAa,QAAQ,4BAAwB;AAmBtD,MAAMC,OAAO,CAACC,MAAcC,MAAiBD,KAAKE,MAAM,GAAGD,MAAM,GAAGD,KAAKG,KAAK,CAAC,GAAGF,MAAM,GAAG,CAAC,CAAC,GAAGD;AAEhG,MAAMI,YAAY,CAACC,OAAgBC,WACjCD,iBAAiBE,SAASF,MAAMG,OAAO,GAAGH,MAAMG,OAAO,GAAGF;AAE5D,8DAA8D,GAC9D,OAAO,SAASG,gBAAgBC,QAA4B;QACfA,oBACCA;IAD5C,IAAIA,SAASC,IAAI,KAAK,WAAW,OAAO,IAAGD,qBAAAA,SAASE,QAAQ,YAAjBF,qBAAqB,EAAE,KAAK,CAAC;IACxE,IAAIA,SAASC,IAAI,KAAK,SAAS,OAAO,CAAC,CAAC,EAAE,AAAC,CAAA,EAACD,uBAAAA,SAASG,UAAU,YAAnBH,uBAAuB,KAAK,GAAE,EAAGI,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7F,OAAO;AACT;AAEA,SAASC,SAASC,KAA2C;IAC3D,MAAM,EAAEC,GAAG,EAAE,GAAGD;IAChB,IAAIlB,cAAcmB,MAAM;QACtB,qBAC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,KAAClB;gBACCiD,MAAMuF;gBACNzE,SAASoF;gBACTzD,UAAU;gBACVC,mBAAmB;gBACnBC,aAAa;gBACbmC,YAAY;oBAAExB,UAAU0C;oBAAiBjB,UAAUe;gBAAa;iBAEhE;YACHX,aAAalH,MAAM,IAAIsH,aAAatH,MAAM,iBACzC,KAAChB;gBACCoC,MAAK;gBACLG,SAAQ;gBACRL,IAAI;oBAAEyD,WAAW;gBAAa;gBAC9BhB,UAAU4B,QAAQ,CAAC6C;gBACnBxE,SAAS,IAAM,KAAKyC;0BAEnB;iBAED;YACHZ,uBAAS,KAAC1G;gBAAM0C,UAAUgE,OAAOhE,QAAQ;0BAAGgE,OAAO3F,IAAI;iBAAY;;;AAG1E"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-products-proposals.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 type { ConsoleProductsHubZoneProps } from './ai-product-zones'\nimport { ListTable, type ListTableProps } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { Alert, Button, Chip, CircularProgress, Stack, Typography } from '@mui/material'\nimport { useCallback, useMemo, useState } from 'react'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport {\n aiProductCopyProposals,\n aiProductsBulkCount,\n aiProductsProposalOfKind,\n type AiProductCopyProposal,\n type AiProposedDiscount,\n} from '../model/ai-products'\nimport { aiProductCopyValues } from './ai-product-copy-card.component'\nimport { isAiJobMoving } from './use-ai-products-jobs'\n\n/**\n * The review tables of the products hub's AI card (AGL-2916): what a\n * `products` job proposed, row by row, before anything is written. Every\n * write is one the hub makes when a person asks for it — Apply, Apply to all,\n * Create drafts, Create selected — and the hub passes over what the site\n * already has, so a proposal applied twice creates nothing twice.\n *\n * Each table is one job's whole answer, held in hand and capped by the job\n * (`AI_PRODUCTS_BULK_MAX`, `AI_CATEGORIES_MAX`, `AI_DISCOUNTS_MAX`, a dozen\n * proposed products), so none offers a Filters panel or a search box: a\n * bounded readout is read whole, and a grid that filtered the rows it holds\n * is the pattern every list is leaving (AGL-3321).\n */\n\n/** A column of a review table, in the shared list table's own terms. */\ntype GridColDef = NonNullable<ListTableProps['columns']>[number]\n\nconst clip = (text: string, max: number) => (text.length > max ? `${text.slice(0, max - 1)}…` : text)\n\nconst messageOf = (error: unknown, fallback: string) =>\n error instanceof Error && error.message ? error.message : fallback\n\n/** A discount's offer, in the words the discounts card uses. */\nexport function aiDiscountOffer(discount: AiProposedDiscount): string {\n if (discount.kind === 'percent') return `${discount.valuePct ?? 0}% off`\n if (discount.kind === 'fixed') return `$${((discount.valueCents ?? 0) / 100).toFixed(2)} off`\n return 'Free shipping'\n}\n\nfunction JobState(props: { job: AiJobSummary; doing: string }) {\n const { job } = props\n if (isAiJobMoving(job)) {\n return (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <CircularProgress size={16} aria-label={props.doing} />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {props.doing}\n </Typography>\n </Stack>\n )\n }\n return job.error ? <Alert severity={job.status === 'failed' ? 'error' : 'warning'}>{job.error}</Alert> : null\n}\n\n/* ------------------------------------------------------------------------ *\n * Copy for many products\n * ------------------------------------------------------------------------ */\n\ntype RowState = 'applying' | 'applied' | { error: string }\n\nexport function AiBulkCopyReview(props: {\n job: AiJobSummary\n applyProductCopy: ConsoleProductsHubZoneProps['applyProductCopy']\n}) {\n const { job, applyProductCopy } = props\n const proposals = aiProductCopyProposals(job)\n const asked = aiProductsBulkCount(job) ?? proposals.length\n const [rows, setRows] = useState<Record<string, RowState>>({})\n const [applyingAll, setApplyingAll] = useState(false)\n\n const ready = (proposal: AiProductCopyProposal) =>\n Boolean(proposal.values && proposal.product.id) && rows[proposal.product.id as string] !== 'applied'\n\n const apply = useCallback(\n async (proposal: AiProductCopyProposal) => {\n const id = proposal.product.id\n if (!id || !proposal.values) return\n setRows((current) => ({ ...current, [id]: 'applying' }))\n try {\n await applyProductCopy(id, aiProductCopyValues(proposal))\n setRows((current) => ({ ...current, [id]: 'applied' }))\n } catch (error) {\n setRows((current) => ({ ...current, [id]: { error: messageOf(error, 'The copy could not be saved.') } }))\n }\n },\n [applyProductCopy],\n )\n\n /** Applies each proposal in turn, so one refusal names its product and the rest still land. */\n const applyAll = useCallback(\n async (targets: readonly AiProductCopyProposal[]) => {\n setApplyingAll(true)\n try {\n for (const proposal of targets) await apply(proposal)\n } finally {\n setApplyingAll(false)\n }\n },\n [apply],\n )\n\n const columns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Product', flex: 1, minWidth: 160 },\n { field: 'description', headerName: 'Proposed description', flex: 2, minWidth: 220 },\n { field: 'seoTitle', headerName: 'Search title', flex: 1, minWidth: 160 },\n {\n field: 'actions',\n headerName: '',\n width: 170,\n sortable: false,\n renderCell: ({ row }: { row: { proposal: AiProductCopyProposal } }) => {\n const { proposal } = row\n if (proposal.skipped) return <Chip size=\"small\" variant=\"outlined\" label=\"Skipped\" title={proposal.skipped} />\n const state = proposal.product.id ? rows[proposal.product.id] : undefined\n if (state === 'applied') return <Chip size=\"small\" color=\"success\" variant=\"outlined\" label=\"Applied\" />\n if (typeof state === 'object') return <Chip size=\"small\" color=\"error\" variant=\"outlined\" label=\"Not saved\" title={state.error} />\n return (\n <Button size=\"small\" disabled={state === 'applying' || applyingAll} onClick={() => void apply(proposal)}>\n {'Apply'}\n </Button>\n )\n },\n },\n ],\n [rows, applyingAll, apply],\n )\n\n const tableRows = proposals.map((proposal) => ({\n $id: proposal.product.id ?? proposal.product.name,\n name: proposal.product.name,\n description: proposal.values ? clip(proposal.values.description, 140) : (proposal.skipped ?? ''),\n seoTitle: proposal.values?.seoTitle ?? '',\n proposal,\n }))\n const readyCount = proposals.filter(ready).length\n const errors = Object.values(rows).filter((state): state is { error: string } => typeof state === 'object')\n const gaps = proposals.filter((proposal) => proposal.gaps.length).length\n\n return (\n <Stack spacing={1} aria-label=\"Proposed product copy\">\n <Typography variant=\"subtitle2\">{`Product copy · ${proposals.length} of ${asked}`}</Typography>\n <JobState job={job} doing={`Writing copy: ${proposals.length} of ${asked}`} />\n {tableRows.length ? <ListTable rows={tableRows} columns={columns} hideFooter disableColumnFilter quickFilter={false} /> : null}\n {gaps ? (\n <Alert severity=\"warning\">\n {`${gaps} ${gaps === 1 ? 'description marks' : 'descriptions mark'} facts in [brackets] to fill in before you publish.`}\n </Alert>\n ) : null}\n {errors.length ? <Alert severity=\"error\">{errors[0].error}</Alert> : null}\n <Button\n size=\"small\"\n variant=\"contained\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={!readyCount || applyingAll}\n onClick={() => void applyAll(proposals.filter(ready))}\n >\n {readyCount ? `Apply to all ${readyCount}` : 'Apply to all'}\n </Button>\n </Stack>\n )\n}\n\n/* ------------------------------------------------------------------------ *\n * A store's first products\n * ------------------------------------------------------------------------ */\n\nexport function AiCatalogReview(props: {\n job: AiJobSummary\n heldNames: ReadonlySet<string>\n createProductDrafts: ConsoleProductsHubZoneProps['createProductDrafts']\n}) {\n const { job, heldNames, createProductDrafts } = props\n const proposal = aiProductsProposalOfKind(job, 'catalog')\n const products = useMemo(() => proposal?.products ?? [], [proposal])\n const held = (name: string) => heldNames.has(name.replace(/\\s+/g, ' ').trim().toLowerCase())\n const [selected, setSelected] = useState<string[] | null>(null)\n const [busy, setBusy] = useState(false)\n const [result, setResult] = useState<{ severity: 'success' | 'error'; text: string } | null>(null)\n\n const rows = products.map((product, index) => ({\n $id: `p${index}`,\n name: product.name,\n type: product.type,\n options: product.options.map((option) => `${option.name}: ${option.values.join(', ')}`).join(' · ') || '—',\n photo: product.photo,\n inCatalog: held(product.name),\n product,\n }))\n const chosen = selected ?? rows.filter((row) => !row.inCatalog).map((row) => row.$id)\n\n const columns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Product', flex: 1, minWidth: 180 },\n { field: 'options', headerName: 'Options', flex: 1, minWidth: 160 },\n {\n field: 'price',\n headerName: 'Price',\n width: 130,\n sortable: false,\n // Never proposed: prices are the merchant's to set.\n renderCell: () => <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Set a price\" />,\n },\n {\n field: 'photo',\n headerName: 'Photo',\n flex: 1,\n minWidth: 200,\n sortable: false,\n renderCell: ({ row }: { row: { photo: string; inCatalog: boolean } }) => (\n <Stack spacing={0.25} sx={{ py: 0.5 }}>\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Needs a photo\" sx={{ alignSelf: 'flex-start' }} />\n <Typography variant=\"caption\" color=\"text.secondary\" sx={{ whiteSpace: 'normal' }}>\n {row.photo}\n </Typography>\n </Stack>\n ),\n },\n {\n field: 'inCatalog',\n headerName: '',\n width: 150,\n sortable: false,\n renderCell: ({ row }: { row: { inCatalog: boolean } }) =>\n row.inCatalog ? <Chip size=\"small\" variant=\"outlined\" label=\"In your catalog\" /> : null,\n },\n ],\n [],\n )\n\n const create = useCallback(async () => {\n const picks = rows.filter((row) => chosen.includes(row.$id)).map((row) => row.product)\n if (!picks.length) return\n setBusy(true)\n setResult(null)\n try {\n const created = await createProductDrafts(\n picks.map((product) => ({\n name: product.name,\n type: product.type,\n description: product.description,\n tags: product.tags,\n options: product.options,\n seoTitle: product.seoTitle,\n seoDescription: product.seoDescription,\n })),\n )\n const passed = picks.length - created.length\n setResult({\n severity: 'success',\n text:\n `Created ${created.length} draft ${created.length === 1 ? 'product' : 'products'}. ` +\n 'Each needs a price and a photo before you activate it.' +\n (passed ? ` ${passed} already in your catalog ${passed === 1 ? 'was' : 'were'} left as they are.` : ''),\n })\n setSelected([])\n } catch (error) {\n setResult({ severity: 'error', text: messageOf(error, 'The draft products could not be created.') })\n } finally {\n setBusy(false)\n }\n }, [rows, chosen, createProductDrafts])\n\n return (\n <Stack spacing={1} aria-label=\"Proposed products\">\n <Typography variant=\"subtitle2\">{'Proposed products'}</Typography>\n <JobState job={job} doing=\"Proposing products from your brief\" />\n {rows.length ? (\n <>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Each is created as a draft with its price left empty and no photo. Set both in the product editor, ' +\n 'then activate it.'}\n </Typography>\n <ListTable\n rows={rows}\n columns={columns}\n hideFooter\n disableColumnFilter\n quickFilter={false}\n getRowHeight={() => 'auto'}\n selectable={{ selected: chosen, onChange: setSelected }}\n />\n <Button\n size=\"small\"\n variant=\"contained\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={busy || !chosen.length}\n onClick={() => void create()}\n >\n {`Create ${chosen.length} ${chosen.length === 1 ? 'draft' : 'drafts'}`}\n </Button>\n </>\n ) : null}\n {result ? <Alert severity={result.severity}>{result.text}</Alert> : null}\n </Stack>\n )\n}\n\n/* ------------------------------------------------------------------------ *\n * Categories and discounts\n * ------------------------------------------------------------------------ */\n\nexport function AiCategoriesReview(props: {\n job: AiJobSummary\n createCategories: ConsoleProductsHubZoneProps['createCategories']\n createDiscountDrafts: ConsoleProductsHubZoneProps['createDiscountDrafts']\n}) {\n const { job, createCategories, createDiscountDrafts } = props\n const proposal = aiProductsProposalOfKind(job, 'categories')\n const categoryRows = (proposal?.categories ?? []).map((category, index) => ({\n $id: `c${index}`,\n name: category.name,\n why: category.why,\n }))\n const discountRows = (proposal?.discounts ?? []).map((discount, index) => ({\n $id: `d${index}`,\n name: discount.name,\n code: discount.code ?? 'Applies on its own',\n offer: aiDiscountOffer(discount),\n minimum: discount.minSubtotalCents ? `$${(discount.minSubtotalCents / 100).toFixed(2)}` : 'Any order',\n why: discount.why,\n discount,\n }))\n const [categories, setCategories] = useState<string[] | null>(null)\n const [discounts, setDiscounts] = useState<string[] | null>(null)\n const [busy, setBusy] = useState(false)\n const [result, setResult] = useState<{ severity: 'success' | 'error'; text: string } | null>(null)\n const chosenCategories = categories ?? categoryRows.map((row) => row.$id)\n const chosenDiscounts = discounts ?? discountRows.map((row) => row.$id)\n\n const categoryColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Category', flex: 1, minWidth: 160 },\n { field: 'why', headerName: 'Why', flex: 2, minWidth: 220 },\n ],\n [],\n )\n const discountColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Discount', flex: 1, minWidth: 150 },\n { field: 'code', headerName: 'Code', width: 150 },\n { field: 'offer', headerName: 'Offer', width: 120 },\n { field: 'minimum', headerName: 'Minimum order', width: 130 },\n { field: 'why', headerName: 'Why', flex: 2, minWidth: 200 },\n ],\n [],\n )\n\n const create = useCallback(async () => {\n setBusy(true)\n setResult(null)\n try {\n const madeCategories = await createCategories(\n categoryRows.filter((row) => chosenCategories.includes(row.$id)).map((row) => row.name),\n )\n const madeDiscounts = await createDiscountDrafts(\n discountRows\n .filter((row) => chosenDiscounts.includes(row.$id))\n .map(({ discount }) => ({\n name: discount.name,\n code: discount.code,\n kind: discount.kind,\n valuePct: discount.valuePct,\n valueCents: discount.valueCents,\n minSubtotalCents: discount.minSubtotalCents,\n })),\n )\n setResult({\n severity: 'success',\n text:\n `Created ${madeCategories} ${madeCategories === 1 ? 'category' : 'categories'} and ` +\n `${madeDiscounts} ${madeDiscounts === 1 ? 'discount' : 'discounts'}. ` +\n 'Discounts start switched off: switch each on under Promotions when you are ready. ' +\n 'Anything your store already had was left as it is.',\n })\n setCategories([])\n setDiscounts([])\n } catch (error) {\n setResult({ severity: 'error', text: messageOf(error, 'The categories and discounts could not be created.') })\n } finally {\n setBusy(false)\n }\n }, [categoryRows, discountRows, chosenCategories, chosenDiscounts, createCategories, createDiscountDrafts])\n\n const any = chosenCategories.length + chosenDiscounts.length\n return (\n <Stack spacing={1} aria-label=\"Proposed categories and discounts\">\n <Typography variant=\"subtitle2\">{'Proposed categories and discounts'}</Typography>\n <JobState job={job} doing=\"Proposing categories and discounts from your brief\" />\n {categoryRows.length ? (\n <ListTable\n rows={categoryRows}\n columns={categoryColumns}\n hideFooter\n disableColumnFilter\n quickFilter={false}\n selectable={{ selected: chosenCategories, onChange: setCategories }}\n />\n ) : null}\n {discountRows.length ? (\n <ListTable\n rows={discountRows}\n columns={discountColumns}\n hideFooter\n disableColumnFilter\n quickFilter={false}\n selectable={{ selected: chosenDiscounts, onChange: setDiscounts }}\n />\n ) : null}\n {categoryRows.length || discountRows.length ? (\n <Button\n size=\"small\"\n variant=\"contained\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={busy || !any}\n onClick={() => void create()}\n >\n {'Create selected'}\n </Button>\n ) : null}\n {result ? <Alert severity={result.severity}>{result.text}</Alert> : null}\n </Stack>\n )\n}\n"],"names":["ListTable","Alert","Button","Chip","CircularProgress","Stack","Typography","useCallback","useMemo","useState","aiProductCopyProposals","aiProductsBulkCount","aiProductsProposalOfKind","aiProductCopyValues","isAiJobMoving","clip","text","max","length","slice","messageOf","error","fallback","Error","message","aiDiscountOffer","discount","kind","valuePct","valueCents","toFixed","JobState","props","job","direction","spacing","sx","alignItems","size","aria-label","doing","variant","color","severity","status","AiBulkCopyReview","applyProductCopy","proposals","asked","rows","setRows","applyingAll","setApplyingAll","ready","proposal","Boolean","values","product","id","apply","current","applyAll","targets","columns","field","headerName","flex","minWidth","width","sortable","renderCell","row","skipped","label","title","state","undefined","disabled","onClick","tableRows","map","$id","name","description","seoTitle","readyCount","filter","errors","Object","gaps","hideFooter","disableColumnFilter","quickFilter","alignSelf","AiCatalogReview","heldNames","createProductDrafts","products","held","has","replace","trim","toLowerCase","selected","setSelected","busy","setBusy","result","setResult","index","type","options","option","join","photo","inCatalog","chosen","py","whiteSpace","create","picks","includes","created","tags","seoDescription","passed","getRowHeight","selectable","onChange","AiCategoriesReview","createCategories","createDiscountDrafts","categoryRows","categories","category","why","discountRows","discounts","code","offer","minimum","minSubtotalCents","setCategories","setDiscounts","chosenCategories","chosenDiscounts","categoryColumns","discountColumns","madeCategories","madeDiscounts","any"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAGA,SAASA,SAAS,QAA6B,uDAAsD;AACrG,SAASC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,gBAAgB,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAe;AACxF,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAEtD,SACEC,sBAAsB,EACtBC,mBAAmB,EACnBC,wBAAwB,QAGnB,0BAAsB;AAC7B,SAASC,mBAAmB,QAAQ,sCAAkC;AACtE,SAASC,aAAa,QAAQ,4BAAwB;AAmBtD,MAAMC,OAAO,CAACC,MAAcC,MAAiBD,KAAKE,MAAM,GAAGD,MAAM,GAAGD,KAAKG,KAAK,CAAC,GAAGF,MAAM,GAAG,CAAC,CAAC,GAAGD;AAEhG,MAAMI,YAAY,CAACC,OAAgBC,WACjCD,iBAAiBE,SAASF,MAAMG,OAAO,GAAGH,MAAMG,OAAO,GAAGF;AAE5D,8DAA8D,GAC9D,OAAO,SAASG,gBAAgBC,QAA4B;QACfA,oBACCA;IAD5C,IAAIA,SAASC,IAAI,KAAK,WAAW,OAAO,IAAGD,qBAAAA,SAASE,QAAQ,YAAjBF,qBAAqB,EAAE,KAAK,CAAC;IACxE,IAAIA,SAASC,IAAI,KAAK,SAAS,OAAO,CAAC,CAAC,EAAE,AAAC,CAAA,EAACD,uBAAAA,SAASG,UAAU,YAAnBH,uBAAuB,KAAK,GAAE,EAAGI,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7F,OAAO;AACT;AAEA,SAASC,SAASC,KAA2C;IAC3D,MAAM,EAAEC,GAAG,EAAE,GAAGD;IAChB,IAAIlB,cAAcmB,MAAM;QACtB,qBACE,MAAC5B;YAAM6B,WAAU;YAAMC,SAAS;YAAGC,IAAI;gBAAEC,YAAY;YAAS;;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