@drawbridge/components 0.1.13 → 0.1.14

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 (236) hide show
  1. package/components/styles.css +364 -2
  2. package/dist/advertisement.js +3 -1
  3. package/dist/advertisement.mjs +3 -1
  4. package/dist/bridge/advertisements.js +2 -0
  5. package/dist/bridge/advertisements.mjs +2 -0
  6. package/dist/bridge/countdown.js +2 -1
  7. package/dist/bridge/countdown.mjs +2 -1
  8. package/dist/bridge/form-subdomain-embed.js +18 -20
  9. package/dist/bridge/form-subdomain-embed.mjs +18 -20
  10. package/dist/bridge/form-subdomain-header.js +24 -1
  11. package/dist/bridge/form-subdomain-header.mjs +24 -1
  12. package/dist/bridge/form-subdomain-missions.js +538 -0
  13. package/dist/bridge/form-subdomain-missions.mjs +502 -0
  14. package/dist/bridge/form-subdomain.js +530 -220
  15. package/dist/bridge/form-subdomain.mjs +533 -222
  16. package/dist/bridge/lib/entry.js +59 -0
  17. package/dist/bridge/lib/entry.mjs +29 -0
  18. package/dist/bridge/lib/location.js +38 -0
  19. package/dist/bridge/lib/location.mjs +13 -0
  20. package/dist/bridge/lib/order.js +71 -0
  21. package/dist/bridge/lib/order.mjs +44 -0
  22. package/dist/bridge/lib/url.js +9 -0
  23. package/dist/bridge/lib/url.mjs +7 -0
  24. package/dist/bridge/share-button.js +5 -3
  25. package/dist/bridge/share-button.mjs +5 -3
  26. package/dist/bridge/subdomain-content.js +7 -6
  27. package/dist/bridge/subdomain-content.mjs +7 -6
  28. package/dist/bridge/template-layout.js +59 -21
  29. package/dist/bridge/template-layout.mjs +59 -21
  30. package/dist/bridge/template-modal.js +42 -76
  31. package/dist/bridge/template-modal.mjs +39 -73
  32. package/dist/bridge/template-preview.js +208 -0
  33. package/dist/bridge/template-preview.mjs +173 -0
  34. package/dist/bridge/template-subdomain-gallery.js +6 -2
  35. package/dist/bridge/template-subdomain-gallery.mjs +6 -2
  36. package/dist/bridge/template-subdomain-link.js +6 -1
  37. package/dist/bridge/template-subdomain-link.mjs +6 -1
  38. package/dist/bridge/template-subdomain.js +20 -15
  39. package/dist/bridge/template-subdomain.mjs +20 -15
  40. package/dist/dashboard/accordion.js +74 -39
  41. package/dist/dashboard/accordion.mjs +74 -39
  42. package/dist/dashboard/avatar.js +109 -3
  43. package/dist/dashboard/avatar.mjs +106 -4
  44. package/dist/dashboard/buttons-subscription.js +384 -0
  45. package/dist/dashboard/buttons-subscription.mjs +349 -0
  46. package/dist/dashboard/card-campaign-switch.js +265 -0
  47. package/dist/dashboard/card-campaign-switch.mjs +231 -0
  48. package/dist/dashboard/card-order.js +28 -11
  49. package/dist/dashboard/card-order.mjs +28 -11
  50. package/dist/dashboard/card-section.js +26 -2
  51. package/dist/dashboard/card-section.mjs +26 -2
  52. package/dist/dashboard/card-tile.js +6 -7
  53. package/dist/dashboard/card-tile.mjs +6 -7
  54. package/dist/dashboard/connection-workflows.js +196 -0
  55. package/dist/dashboard/connection-workflows.mjs +162 -0
  56. package/dist/dashboard/device.js +95 -0
  57. package/dist/dashboard/device.mjs +72 -0
  58. package/dist/dashboard/form-admin-campaign.js +19 -50
  59. package/dist/dashboard/form-admin-campaign.mjs +20 -51
  60. package/dist/dashboard/form-ai.js +9 -6
  61. package/dist/dashboard/form-ai.mjs +9 -6
  62. package/dist/dashboard/form-auth.js +35 -25
  63. package/dist/dashboard/form-auth.mjs +36 -26
  64. package/dist/dashboard/form-file.js +10 -1
  65. package/dist/dashboard/form-file.mjs +10 -1
  66. package/dist/dashboard/form-filters-analytics.js +14 -1
  67. package/dist/dashboard/form-filters-analytics.mjs +15 -2
  68. package/dist/dashboard/form-organization-campaign-advertisement.js +15 -1
  69. package/dist/dashboard/form-organization-campaign-advertisement.mjs +16 -2
  70. package/dist/dashboard/form-organization-campaign-agreement.js +215 -164
  71. package/dist/dashboard/form-organization-campaign-agreement.mjs +215 -164
  72. package/dist/dashboard/form-organization-campaign-field-email.js +0 -34
  73. package/dist/dashboard/form-organization-campaign-field-email.mjs +0 -34
  74. package/dist/dashboard/form-organization-campaign-field-list.js +466 -0
  75. package/dist/dashboard/form-organization-campaign-field-list.mjs +437 -0
  76. package/dist/dashboard/form-organization-campaign-field-phone.js +0 -34
  77. package/dist/dashboard/form-organization-campaign-field-phone.mjs +0 -34
  78. package/dist/dashboard/form-organization-campaign-field-remove.js +66 -0
  79. package/dist/dashboard/form-organization-campaign-field-remove.mjs +33 -0
  80. package/dist/dashboard/form-organization-campaign-integration-age.js +6 -12
  81. package/dist/dashboard/form-organization-campaign-integration-age.mjs +6 -12
  82. package/dist/dashboard/form-organization-campaign-integration-enable.js +52 -24
  83. package/dist/dashboard/form-organization-campaign-integration-enable.mjs +54 -26
  84. package/dist/dashboard/form-organization-campaign-integration-geocode.js +6 -12
  85. package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +6 -12
  86. package/dist/dashboard/form-organization-campaign-integration-gtm.js +6 -12
  87. package/dist/dashboard/form-organization-campaign-integration-gtm.mjs +6 -12
  88. package/dist/dashboard/form-organization-campaign-link.js +7 -1
  89. package/dist/dashboard/form-organization-campaign-link.mjs +7 -1
  90. package/dist/dashboard/form-organization-campaign-mission.js +291 -0
  91. package/dist/dashboard/form-organization-campaign-mission.mjs +258 -0
  92. package/dist/dashboard/form-organization-campaign-page-embed.js +13 -2
  93. package/dist/dashboard/form-organization-campaign-page-embed.mjs +12 -1
  94. package/dist/dashboard/form-organization-campaign-page.js +20 -11
  95. package/dist/dashboard/form-organization-campaign-page.mjs +20 -11
  96. package/dist/dashboard/form-organization-campaign-prize-edit.js +12 -1
  97. package/dist/dashboard/form-organization-campaign-prize-edit.mjs +12 -1
  98. package/dist/dashboard/form-organization-campaign-section.js +223 -0
  99. package/dist/dashboard/form-organization-campaign-section.mjs +194 -0
  100. package/dist/dashboard/form-organization-campaign.js +114 -469
  101. package/dist/dashboard/form-organization-campaign.mjs +113 -467
  102. package/dist/dashboard/form-organization-export.js +4 -7
  103. package/dist/dashboard/form-organization-export.mjs +4 -7
  104. package/dist/dashboard/form-organization-identity.js +46 -51
  105. package/dist/dashboard/form-organization-identity.mjs +46 -51
  106. package/dist/dashboard/form-organization-workflow.js +518 -686
  107. package/dist/dashboard/form-organization-workflow.mjs +517 -682
  108. package/dist/dashboard/form-organization.js +82 -110
  109. package/dist/dashboard/form-organization.mjs +81 -109
  110. package/dist/dashboard/form-otc.js +4 -5
  111. package/dist/dashboard/form-otc.mjs +4 -5
  112. package/dist/dashboard/form-payment-methods.js +20 -9
  113. package/dist/dashboard/form-payment-methods.mjs +20 -9
  114. package/dist/dashboard/form-stripe.js +30 -0
  115. package/dist/dashboard/form-stripe.mjs +26 -0
  116. package/dist/dashboard/input-array.js +4 -2
  117. package/dist/dashboard/input-array.mjs +4 -2
  118. package/dist/dashboard/input-combobox.js +7 -3
  119. package/dist/dashboard/input-combobox.mjs +7 -3
  120. package/dist/dashboard/input-date.js +7 -0
  121. package/dist/dashboard/input-date.mjs +7 -0
  122. package/dist/dashboard/input-fields.js +80 -20
  123. package/dist/dashboard/input-fields.mjs +80 -20
  124. package/dist/dashboard/input-file.js +21 -1
  125. package/dist/dashboard/input-file.mjs +21 -1
  126. package/dist/dashboard/input-font.js +10 -1
  127. package/dist/dashboard/input-font.mjs +10 -1
  128. package/dist/dashboard/lib/item-list.js +57 -0
  129. package/dist/dashboard/lib/item-list.mjs +33 -0
  130. package/dist/dashboard/lib/menu.js +50 -0
  131. package/dist/dashboard/lib/menu.mjs +26 -0
  132. package/dist/dashboard/locked.js +82 -0
  133. package/dist/dashboard/locked.mjs +53 -0
  134. package/dist/dashboard/menu.js +72 -19
  135. package/dist/dashboard/menu.mjs +72 -19
  136. package/dist/dashboard/note-ai.js +69 -0
  137. package/dist/dashboard/note-ai.mjs +36 -0
  138. package/dist/dashboard/preview.js +419 -0
  139. package/dist/dashboard/preview.mjs +384 -0
  140. package/dist/dashboard/steps.js +39 -13
  141. package/dist/dashboard/steps.mjs +37 -12
  142. package/dist/dashboard/table-contacts.js +136 -0
  143. package/dist/dashboard/table-contacts.mjs +103 -0
  144. package/dist/dashboard/template-not-found.js +4 -2
  145. package/dist/dashboard/template-not-found.mjs +4 -2
  146. package/dist/dashboard/template-socket.js +20 -7
  147. package/dist/dashboard/template-socket.mjs +20 -7
  148. package/dist/icons/desktop.js +46 -0
  149. package/dist/icons/desktop.mjs +27 -0
  150. package/dist/icons/phone.js +46 -0
  151. package/dist/icons/phone.mjs +27 -0
  152. package/dist/icons/puzzle-piece.js +46 -0
  153. package/dist/icons/puzzle-piece.mjs +27 -0
  154. package/dist/icons/tablet.js +46 -0
  155. package/dist/icons/tablet.mjs +27 -0
  156. package/dist/icons/users.js +46 -0
  157. package/dist/icons/users.mjs +27 -0
  158. package/dist/input-checkbox.js +1 -0
  159. package/dist/input-checkbox.mjs +1 -0
  160. package/dist/input-code.js +101 -0
  161. package/dist/input-code.mjs +78 -0
  162. package/dist/input-text.js +2 -1
  163. package/dist/input-text.mjs +2 -1
  164. package/dist/shared/input-checkbox-list.js +0 -1
  165. package/dist/shared/input-checkbox-list.mjs +0 -1
  166. package/dist/shared/input-switch.js +6 -1
  167. package/dist/shared/input-switch.mjs +6 -1
  168. package/dist/shared/lib/campaign.js +117 -0
  169. package/dist/shared/lib/campaign.mjs +91 -0
  170. package/dist/shared/lib/helpers.js +14 -2
  171. package/dist/shared/lib/helpers.mjs +13 -2
  172. package/package.json +133 -13
  173. package/types/bridge/form-subdomain-header.d.ts +2 -0
  174. package/types/bridge/form-subdomain-missions.d.ts +36 -0
  175. package/types/bridge/form-subdomain.d.ts +23 -1
  176. package/types/bridge/lib/entry.d.ts +26 -0
  177. package/types/bridge/lib/location.d.ts +13 -0
  178. package/types/bridge/lib/order.d.ts +30 -0
  179. package/types/bridge/lib/url.d.ts +19 -0
  180. package/types/bridge/template-modal.d.ts +1 -1
  181. package/types/bridge/template-preview.d.ts +10 -0
  182. package/types/bridge/template-subdomain-link.d.ts +2 -0
  183. package/types/dashboard/accordion.d.ts +2 -0
  184. package/types/dashboard/avatar.d.ts +18 -2
  185. package/types/dashboard/buttons-subscription.d.ts +22 -0
  186. package/types/dashboard/card-campaign-switch.d.ts +32 -0
  187. package/types/dashboard/card-order.d.ts +11 -0
  188. package/types/dashboard/card-section.d.ts +2 -0
  189. package/types/dashboard/connection-workflows.d.ts +33 -0
  190. package/types/dashboard/device.d.ts +12 -0
  191. package/types/dashboard/form-admin-campaign.d.ts +3 -2
  192. package/types/dashboard/form-ai.d.ts +2 -2
  193. package/types/dashboard/form-organization-campaign-agreement.d.ts +18 -12
  194. package/types/dashboard/form-organization-campaign-field-email.d.ts +1 -2
  195. package/types/dashboard/form-organization-campaign-field-list.d.ts +36 -0
  196. package/types/dashboard/form-organization-campaign-field-phone.d.ts +1 -2
  197. package/types/dashboard/form-organization-campaign-field-remove.d.ts +22 -0
  198. package/types/dashboard/form-organization-campaign-field-select.d.ts +2 -1
  199. package/types/dashboard/form-organization-campaign-field-textarea.d.ts +2 -1
  200. package/types/dashboard/form-organization-campaign-integration-age.d.ts +3 -3
  201. package/types/dashboard/form-organization-campaign-integration-enable.d.ts +3 -3
  202. package/types/dashboard/form-organization-campaign-mission.d.ts +40 -0
  203. package/types/dashboard/form-organization-campaign-section.d.ts +27 -0
  204. package/types/dashboard/form-organization-campaign.d.ts +27 -17
  205. package/types/dashboard/form-organization-identity.d.ts +2 -0
  206. package/types/dashboard/form-organization-workflow.d.ts +43 -47
  207. package/types/dashboard/form-organization.d.ts +7 -2
  208. package/types/dashboard/form-stripe.d.ts +3 -0
  209. package/types/dashboard/input-combobox.d.ts +2 -0
  210. package/types/dashboard/input-date.d.ts +2 -0
  211. package/types/dashboard/input-fields.d.ts +3 -2
  212. package/types/dashboard/input-file.d.ts +4 -0
  213. package/types/dashboard/lib/item-list.d.ts +14 -0
  214. package/types/dashboard/lib/menu.d.ts +17 -0
  215. package/types/dashboard/locked.d.ts +10 -0
  216. package/types/dashboard/menu.d.ts +10 -2
  217. package/types/dashboard/note-ai.d.ts +15 -0
  218. package/types/dashboard/preview.d.ts +33 -0
  219. package/types/dashboard/steps.d.ts +19 -4
  220. package/types/dashboard/table-cell-title.d.ts +2 -2
  221. package/types/dashboard/table-contacts.d.ts +2 -0
  222. package/types/icons/desktop.d.ts +5 -0
  223. package/types/icons/phone.d.ts +5 -0
  224. package/types/icons/puzzle-piece.d.ts +5 -0
  225. package/types/icons/tablet.d.ts +5 -0
  226. package/types/icons/users.d.ts +5 -0
  227. package/types/input-code.d.ts +23 -0
  228. package/types/shared/input-switch.d.ts +2 -0
  229. package/types/shared/lib/campaign.d.ts +35 -0
  230. package/types/shared/lib/helpers.d.ts +3 -0
  231. package/dist/dashboard/card-integration.js +0 -187
  232. package/dist/dashboard/card-integration.mjs +0 -158
  233. package/dist/dashboard/iframe.js +0 -159
  234. package/dist/dashboard/iframe.mjs +0 -130
  235. package/types/dashboard/card-integration.d.ts +0 -24
  236. package/types/dashboard/iframe.d.ts +0 -18
@@ -27,14 +27,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
  var form_organization_workflow_exports = {};
29
29
  __export(form_organization_workflow_exports, {
30
- FormOrganizationWorkflow: () => FormOrganizationWorkflow,
31
30
  FormOrganizationWorkflowEdit: () => FormOrganizationWorkflowEdit,
32
- campaignFilterId: () => campaignFilterId,
33
- campaignFilterIds: () => campaignFilterIds,
34
- filterMissing: () => filterMissing,
35
- filterRows: () => filterRows,
36
- filterSeed: () => filterSeed,
31
+ prefillRow: () => prefillRow,
32
+ stepReason: () => stepReason,
37
33
  stepRow: () => stepRow,
34
+ stepVariables: () => stepVariables,
38
35
  workflowSchema: () => workflowSchema
39
36
  });
40
37
  module.exports = __toCommonJS(form_organization_workflow_exports);
@@ -50,7 +47,6 @@ var import_form2 = __toESM(require("../shared/form"));
50
47
  var import_fieldset = __toESM(require("../shared/fieldset"));
51
48
  var import_input_group = __toESM(require("../input-group"));
52
49
  var import_error = __toESM(require("../shared/error"));
53
- var import_input_text = __toESM(require("../input-text"));
54
50
  var import_input_textarea = __toESM(require("../input-textarea"));
55
51
  var import_input_url = __toESM(require("../shared/input-url"));
56
52
  var import_input_resource = __toESM(require("./input-resource"));
@@ -58,13 +54,16 @@ var import_input_combobox = __toESM(require("./input-combobox"));
58
54
  var import_form_notification = require("./form-notification");
59
55
  var import_input_array = require("./input-array");
60
56
  var import_badge = __toESM(require("../shared/badge"));
57
+ var import_card_section = __toESM(require("./card-section"));
58
+ var import_accordion = __toESM(require("./accordion"));
59
+ var import_preview = __toESM(require("./preview"));
61
60
  var import_card_task = __toESM(require("./card-task"));
62
61
  var import_loader = require("../shared/loader");
63
62
  var import_sms = require("./lib/sms");
64
63
  var import_trash = __toESM(require("../icons/trash"));
65
64
  var import_button = __toESM(require("../shared/button"));
66
- const emailSteps = ["step.email.send", "step.email.digest"];
67
- const teamSteps = ["step.email.notify", "step.email.digest"];
65
+ const emailSteps = ["step.email.send"];
66
+ const teamSteps = ["step.email.notify"];
68
67
  const messageSteps = [...emailSteps, "step.sms.send"];
69
68
  const defaultScore = {
70
69
  rules: [
@@ -83,16 +82,8 @@ const stepPrefills = {
83
82
  subject: "Thanks for entering",
84
83
  text: "Thanks for entering. We have your entry and will be in touch."
85
84
  },
86
- // Nothing to prefill — the step writes its own copy — but the entry has to
87
- // exist: an unlisted step arrives from the deep link with no settings shape
88
- // and the drawer creates the workflow without it.
89
- "step.email.notify": {},
90
- "step.email.digest": {
91
- message: "You had {{count}} new entries.",
92
- score: defaultScore,
93
- subject: "Your entries",
94
- text: "You had {{count}} new entries."
95
- }
85
+ // Nothing to prefill: the step writes its own copy.
86
+ "step.email.notify": {}
96
87
  };
97
88
  const memberParams = {
98
89
  filters: {
@@ -130,188 +121,27 @@ const memberLabel = (member) => {
130
121
  var _a, _b, _c;
131
122
  return [(_a = member == null ? void 0 : member.user) == null ? void 0 : _a.firstName, (_b = member == null ? void 0 : member.user) == null ? void 0 : _b.lastName].filter(Boolean).join(" ") || (member == null ? void 0 : member.email) || ((_c = member == null ? void 0 : member.user) == null ? void 0 : _c.email) || "Member";
132
123
  };
133
- const useWorkflowCatalog = (organization, current) => {
134
- const catalog = (0, import_react_query.useQuery)({
135
- queryKey: ["organization-workflow-catalog", organization],
136
- queryFn: async () => {
137
- const { result } = await (0, import_fetch.request)({
138
- endpoint: "/organization/" + organization + "/workflows/catalog"
139
- });
140
- return result;
141
- },
142
- enabled: Boolean(organization),
143
- staleTime: Infinity
124
+ const stepVariables = (entry, steps = [], index = 0) => [
125
+ ...(entry == null ? void 0 : entry.variables) || [],
126
+ ...steps.slice(0, index).flatMap((step) => {
127
+ var _a;
128
+ return ((_a = ((entry == null ? void 0 : entry.steps) || []).find((option) => option.value === (step == null ? void 0 : step.type))) == null ? void 0 : _a.returns) || [];
129
+ })
130
+ ];
131
+ const prefillRow = ({ entry, step, steps = [] }) => {
132
+ if (!step || steps.some((row) => (row == null ? void 0 : row.type) === step)) return null;
133
+ const option = ((entry == null ? void 0 : entry.steps) || []).find((each) => each.value === step);
134
+ if (!option || option.ownerOnly || option.disabled) return null;
135
+ return stepRow({
136
+ connectionId: option.connectionId,
137
+ settings: stepPrefills[step] || {},
138
+ slug: option.slug,
139
+ type: step
144
140
  });
145
- const catalogList = catalog.data || [];
146
- const triggerGroups = catalogList.filter((item) => item.type !== "schedule" || item.trigger === current).reduce((groups, item) => {
147
- const model = item.type === "schedule" ? "schedule" : item.trigger.split(".")[0];
148
- if (!groups[model]) groups[model] = [];
149
- groups[model].push(item);
150
- return groups;
151
- }, {});
152
- const triggerOptions = [
153
- { key: "Select a trigger", value: "" },
154
- ...Object.entries(triggerGroups).sort(([a], [b]) => a.localeCompare(b)).flatMap(([model, items]) => [
155
- { key: model.charAt(0).toUpperCase() + model.slice(1), header: true },
156
- ...items.sort((a, b) => a.title.localeCompare(b.title)).map((item) => ({
157
- image: item.image,
158
- key: item.title,
159
- value: item.trigger
160
- }))
161
- ])
162
- ];
163
- return { catalog, catalogList, triggerOptions };
164
141
  };
165
- const WorkflowTriggerField = ({ control, formState, catalogList, triggerOptions, getValues, setValue }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
166
- import_form.Controller,
167
- {
168
- ...{
169
- control,
170
- name: "triggerEvent",
171
- render: ({ field: { value, onChange } }) => {
172
- var _a, _b;
173
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
174
- import_input_group.default,
175
- {
176
- ...{
177
- error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.triggerEvent) == null ? void 0 : _b.message,
178
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
179
- import_input_combobox.default,
180
- {
181
- ...{
182
- onChange: (val) => {
183
- onChange(val);
184
- const entry = catalogList.find((item) => item.trigger === val);
185
- if (entry) {
186
- const currentTitle = getValues("title");
187
- const catalogTitles = catalogList.map((item) => item.title);
188
- if (!currentTitle || catalogTitles.includes(currentTitle)) {
189
- setValue("title", entry.title);
190
- }
191
- ;
192
- }
193
- ;
194
- },
195
- options: triggerOptions,
196
- value: value || ""
197
- }
198
- }
199
- ),
200
- label: "Trigger"
201
- }
202
- }
203
- );
204
- }
205
- }
206
- }
207
- );
208
- const WorkflowTitleField = ({ control, formState }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
209
- import_form.Controller,
210
- {
211
- ...{
212
- control,
213
- name: "title",
214
- render: ({ field: { value, onChange } }) => {
215
- var _a, _b;
216
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
217
- import_input_group.default,
218
- {
219
- ...{
220
- error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a.title) == null ? void 0 : _b.message,
221
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
222
- import_input_text.default,
223
- {
224
- ...{
225
- onChange,
226
- placeholder: "Workflow name",
227
- value: value || ""
228
- }
229
- }
230
- ),
231
- label: "Title"
232
- }
233
- }
234
- );
235
- }
236
- }
237
- }
238
- );
239
- const campaignFilterId = (campaign) => (campaign == null ? void 0 : campaign.id) || campaign || null;
240
- const campaignFilterIds = (filters) => (Array.isArray(filters == null ? void 0 : filters.campaigns) ? filters.campaigns : [filters == null ? void 0 : filters.campaign]).map(campaignFilterId).filter(Boolean);
241
- const filterRows = (ids, docs) => ids.map((id) => docs.find((doc) => (doc == null ? void 0 : doc.id) === id) || { id });
242
- const filterSeed = (seeds, id) => (seeds || []).find((doc) => (doc == null ? void 0 : doc.id) === id);
243
- const filterMissing = (error) => {
244
- if ((error == null ? void 0 : error.status) === 404) return { result: null };
245
- throw error;
246
- };
247
- const WorkflowFilterField = ({
248
- collection,
249
- control,
250
- label,
251
- message,
252
- model,
253
- multiple = false,
254
- name,
255
- organization,
256
- resource,
257
- seeds
258
- }) => {
259
- const queryClient = (0, import_react_query.useQueryClient)();
260
- const value = (0, import_form.useWatch)({
261
- control,
262
- name
263
- });
264
- const ids = multiple ? value || [] : [value].filter(Boolean);
265
- const docs = (0, import_react_query.useQueries)({
266
- queries: ids.map((id) => ({
267
- queryKey: ["workflow-filter", model, organization, id],
268
- queryFn: async () => {
269
- const { result } = await (0, import_fetch.request)({
270
- endpoint: "/organization/" + organization + "/" + resource + "/" + id
271
- }).catch(filterMissing);
272
- return result;
273
- },
274
- initialData: () => filterSeed(seeds, id),
275
- staleTime: Infinity
276
- }))
277
- }).map((query) => query.data);
278
- const seed = (doc) => (doc == null ? void 0 : doc.id) && queryClient.setQueryData(["workflow-filter", model, organization, doc.id], doc);
279
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
280
- import_form.Controller,
281
- {
282
- ...{
283
- control,
284
- name,
285
- render: ({ field: { onChange } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
286
- import_input_group.default,
287
- {
288
- ...{
289
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
290
- import_input_resource.default,
291
- {
292
- ...{
293
- endpoint: "/organization/" + organization + "/" + collection,
294
- model,
295
- multiple,
296
- onChange: multiple ? (picked) => {
297
- picked.forEach(seed);
298
- onChange(picked.map((doc) => doc == null ? void 0 : doc.id).filter(Boolean));
299
- } : (doc) => {
300
- seed(doc);
301
- onChange((doc == null ? void 0 : doc.id) || null);
302
- },
303
- value: multiple ? filterRows(ids, docs) : docs[0] || null
304
- }
305
- }
306
- ),
307
- label,
308
- message
309
- }
310
- }
311
- )
312
- }
313
- }
314
- );
142
+ const stepReason = ({ entry, saved = [], type }) => {
143
+ var _a, _b;
144
+ return ((_a = ((entry == null ? void 0 : entry.steps) || []).find((step) => (step == null ? void 0 : step.value) === type && (step == null ? void 0 : step.reason))) == null ? void 0 : _a.reason) || ((_b = saved.find((step) => (step == null ? void 0 : step.type) === type && (step == null ? void 0 : step.reason))) == null ? void 0 : _b.reason) || null;
315
145
  };
316
146
  const stepRow = (step = {}, members = []) => {
317
147
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
@@ -346,119 +176,7 @@ const stepRow = (step = {}, members = []) => {
346
176
  url: ((_i = step.settings) == null ? void 0 : _i.url) || ""
347
177
  };
348
178
  };
349
- const FormOrganizationWorkflow = ({
350
- disabled,
351
- onClose,
352
- onError,
353
- onSuccess,
354
- values
355
- }) => {
356
- const { catalog, catalogList, triggerOptions } = useWorkflowCatalog(values == null ? void 0 : values.organization, values == null ? void 0 : values.triggerEvent);
357
- const { control, formState, getValues, handleSubmit, setValue } = (0, import_form.useForm)({
358
- defaultValues: {
359
- title: "",
360
- triggerEvent: (values == null ? void 0 : values.triggerEvent) || ""
361
- },
362
- resolver: (0, import_yup.resolver)(
363
- import_yup.default.object({
364
- title: import_yup.default.string().required().max(100).label("Title"),
365
- triggerEvent: import_yup.default.string().label("Trigger").required("A trigger is required")
366
- })
367
- )
368
- });
369
- const watchedTrigger = (0, import_form.useWatch)({
370
- control,
371
- name: "triggerEvent"
372
- });
373
- const onSubmit = async ({ title, triggerEvent }) => {
374
- const prefill = stepPrefills[values == null ? void 0 : values.step];
375
- const prefilledSteps = prefill ? [{
376
- settings: { ...prefill },
377
- type: values.step
378
- }] : [];
379
- try {
380
- const response = await (0, import_fetch.request)({
381
- body: {
382
- steps: prefilledSteps,
383
- title,
384
- trigger: {
385
- event: triggerEvent,
386
- filters: {
387
- // Both blank, meaning every campaign and every segment. The
388
- // create drawer asks for a trigger and a title only; narrowing
389
- // is done on the workflow page afterwards.
390
- campaigns: [],
391
- segment: null
392
- }
393
- }
394
- },
395
- endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/workflow",
396
- method: "POST"
397
- });
398
- onSuccess(response);
399
- onClose == null ? void 0 : onClose();
400
- } catch (error) {
401
- onError(error);
402
- }
403
- };
404
- if (catalog.isLoading) {
405
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_loader.LoaderDynamic, {});
406
- }
407
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
408
- import_form2.default,
409
- {
410
- ...{
411
- className: "relative w-full",
412
- onSubmit: handleSubmit(onSubmit)
413
- },
414
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
415
- import_fieldset.default,
416
- {
417
- ...{
418
- disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
419
- },
420
- children: [
421
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
422
- WorkflowTriggerField,
423
- {
424
- ...{
425
- control,
426
- formState,
427
- catalogList,
428
- triggerOptions,
429
- getValues,
430
- setValue
431
- }
432
- }
433
- ),
434
- watchedTrigger && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
435
- WorkflowTitleField,
436
- {
437
- ...{
438
- control,
439
- formState
440
- }
441
- }
442
- ),
443
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
444
- import_button.default,
445
- {
446
- ...{
447
- loading: formState == null ? void 0 : formState.isSubmitting,
448
- type: "submit"
449
- },
450
- children: "Create workflow"
451
- }
452
- )
453
- ]
454
- }
455
- )
456
- }
457
- );
458
- };
459
179
  const workflowSchema = import_yup.default.object({
460
- title: import_yup.default.string().required().max(100).label("Title"),
461
- triggerEvent: import_yup.default.string().label("Trigger").required("A trigger is required"),
462
180
  steps: import_yup.default.array().of(
463
181
  import_yup.default.object({
464
182
  type: import_yup.default.string().label("Step").required("A step is required"),
@@ -474,7 +192,13 @@ const workflowSchema = import_yup.default.object({
474
192
  }
475
193
  return schema;
476
194
  }),
477
- message: import_yup.default.string().when("type", ([type], schema) => {
195
+ // @story workflows/edit
196
+ // The editor writes an empty message as "<p></p>", which a plain
197
+ // required() accepts: a message needs words, not only markup.
198
+ message: import_yup.default.string().test("words", "Message is required", function(value) {
199
+ var _a;
200
+ return !messageSteps.includes((_a = this.parent) == null ? void 0 : _a.type) || Boolean(String(value || "").replace(/<[^>]*>/g, "").trim());
201
+ }).when("type", ([type], schema) => {
478
202
  if (type === "step.sms.send") {
479
203
  return schema.required("Message is required").max(1500).label("Message");
480
204
  }
@@ -498,21 +222,157 @@ const workflowSchema = import_yup.default.object({
498
222
  })
499
223
  )
500
224
  });
225
+ const samples = [
226
+ {
227
+ key: "New lead",
228
+ value: "lead"
229
+ },
230
+ {
231
+ key: "Verified their email",
232
+ value: "verified"
233
+ }
234
+ ];
235
+ const useEmailPreview = ({ campaign, event, message, organization, sample, subject, text }) => {
236
+ const asked = JSON.stringify({ message, sample, subject, text });
237
+ const [settled, setSettled] = (0, import_react.useState)(asked);
238
+ (0, import_react.useEffect)(() => {
239
+ const timer = setTimeout(() => setSettled(asked), 400);
240
+ return () => clearTimeout(timer);
241
+ }, [asked]);
242
+ const preview = (0, import_react_query.useQuery)({
243
+ enabled: Boolean(organization && campaign && event),
244
+ placeholderData: import_react_query.keepPreviousData,
245
+ queryFn: async () => {
246
+ const { result } = await (0, import_fetch.request)({
247
+ body: JSON.parse(settled),
248
+ endpoint: "/organization/" + organization + "/campaign/" + campaign + "/workflow/" + event + "/preview",
249
+ method: "POST"
250
+ });
251
+ return result;
252
+ },
253
+ queryKey: ["workflow-email-preview", organization, campaign, event, settled]
254
+ });
255
+ return preview.data;
256
+ };
257
+ const EmailStepCard = ({
258
+ card,
259
+ children,
260
+ control,
261
+ email: {
262
+ campaign,
263
+ event,
264
+ name,
265
+ organization
266
+ }
267
+ }) => {
268
+ const [sample, setSample] = (0, import_react.useState)(samples[0].value);
269
+ const [subject, message, text] = (0, import_form.useWatch)({
270
+ control,
271
+ name: [name + ".subject", name + ".message", name + ".text"]
272
+ });
273
+ const preview = useEmailPreview({ campaign, event, message, organization, sample, subject, text });
274
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
275
+ import_card_section.default,
276
+ {
277
+ ...{
278
+ ...card,
279
+ columns: 2
280
+ },
281
+ children: [
282
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
283
+ "div",
284
+ {
285
+ ...{
286
+ className: "space-y-6"
287
+ },
288
+ children: [
289
+ children,
290
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
291
+ import_accordion.default,
292
+ {
293
+ ...{
294
+ className: "pt-6 border-t border-gray",
295
+ classNamePanel: "mt-6",
296
+ title: "Plain-text version"
297
+ },
298
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
299
+ "pre",
300
+ {
301
+ ...{
302
+ className: "p-4 rounded border border-gray bg-white text-sm whitespace-pre-wrap wrap-anywhere"
303
+ },
304
+ children: preview == null ? void 0 : preview.text
305
+ }
306
+ )
307
+ }
308
+ )
309
+ ]
310
+ }
311
+ ),
312
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
313
+ import_preview.default,
314
+ {
315
+ ...{
316
+ states: {
317
+ onChange: setSample,
318
+ options: samples,
319
+ value: sample
320
+ }
321
+ },
322
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
323
+ "iframe",
324
+ {
325
+ ...{
326
+ // The rendered email, as a mail app shows it.
327
+ className: "block w-full h-full border-0 bg-white",
328
+ srcDoc: (preview == null ? void 0 : preview.html) || "",
329
+ title: "Send email"
330
+ }
331
+ }
332
+ )
333
+ }
334
+ )
335
+ ]
336
+ }
337
+ );
338
+ };
339
+ const StepCard = ({
340
+ children,
341
+ control,
342
+ email,
343
+ ...card
344
+ }) => email ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
345
+ EmailStepCard,
346
+ {
347
+ ...{
348
+ card,
349
+ control,
350
+ email
351
+ },
352
+ children
353
+ }
354
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
355
+ import_card_section.default,
356
+ {
357
+ ...card,
358
+ children
359
+ }
360
+ );
501
361
  const FormOrganizationWorkflowEdit = ({
362
+ catalog,
502
363
  disabled,
503
- onClose,
504
364
  onError,
505
365
  onSuccess,
506
366
  values
507
367
  }) => {
508
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
509
- const { catalog, catalogList, triggerOptions } = useWorkflowCatalog(values == null ? void 0 : values.organization, (_a = values == null ? void 0 : values.trigger) == null ? void 0 : _a.event);
368
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
369
+ const event = (_a = values == null ? void 0 : values.trigger) == null ? void 0 : _a.event;
510
370
  const { items: memberItems, loading: membersLoading } = useOrganizationMembers(values == null ? void 0 : values.organization);
511
371
  const queryClient = (0, import_react_query.useQueryClient)();
512
372
  const organizationData = queryClient.getQueryData(["organization", values == null ? void 0 : values.organization]);
513
373
  const ownerEmail = organizationData.owner.email;
514
374
  const smsActive = (0, import_sms.smsNumberActive)(organizationData);
515
- const commerceConnectionId = ((_b = catalogList.flatMap((item) => item.steps || []).find(
375
+ const commerceConnectionId = ((_b = ((catalog == null ? void 0 : catalog.steps) || []).find(
516
376
  (s) => s.value === "step.commerce.customer.insert" || s.value === "step.commerce.code.issue"
517
377
  )) == null ? void 0 : _b.connectionId) || null;
518
378
  const commerceConnection = (0, import_react_query.useQuery)({
@@ -538,38 +398,29 @@ const FormOrganizationWorkflowEdit = ({
538
398
  );
539
399
  const { control, formState, getValues, handleSubmit, setValue } = (0, import_form.useForm)({
540
400
  values: {
541
- steps: defaultSteps,
542
- filterCampaigns: campaignFilterIds((_g = values == null ? void 0 : values.trigger) == null ? void 0 : _g.filters),
543
- // Stored and returned as a plain id — extend.workflow() $lookup-hydrates
544
- // only the campaign — but read through the same reducer, so the field
545
- // stays right if the segment is ever hydrated too.
546
- filterSegment: campaignFilterId((_i = (_h = values == null ? void 0 : values.trigger) == null ? void 0 : _h.filters) == null ? void 0 : _i.segment),
547
- title: (values == null ? void 0 : values.title) || "",
548
- triggerEvent: ((_j = values == null ? void 0 : values.trigger) == null ? void 0 : _j.event) || ""
401
+ steps: defaultSteps
549
402
  },
550
403
  resolver: (0, import_yup.resolver)(workflowSchema)
551
404
  });
552
- const watchedTrigger = (0, import_form.useWatch)({
553
- control,
554
- name: "triggerEvent"
555
- });
556
405
  const watchedSteps = (0, import_form.useWatch)({
557
406
  control,
558
407
  name: "steps"
559
408
  });
560
- const issueIndex = ((_k = values == null ? void 0 : values.issue) == null ? void 0 : _k.step) ? (watchedSteps || []).findIndex((step) => (step == null ? void 0 : step.type) === values.issue.step) : -1;
561
- const selectedTriggerEntry = catalogList.find((item) => item.trigger === watchedTrigger) || null;
562
- const getAvailableVariables = (index) => {
563
- return watchedSteps.slice(0, index).flatMap((watchedStep) => {
564
- const stepDef = ((selectedTriggerEntry == null ? void 0 : selectedTriggerEntry.steps) || []).find((s) => s.value === watchedStep.type);
565
- return (stepDef == null ? void 0 : stepDef.returns) || [];
566
- });
567
- };
409
+ const issueIndex = ((_g = values == null ? void 0 : values.issue) == null ? void 0 : _g.step) ? (watchedSteps || []).findIndex((step) => (step == null ? void 0 : step.type) === values.issue.step) : -1;
410
+ const getAvailableVariables = (index) => stepVariables(catalog, watchedSteps, index);
411
+ const loading = membersLoading || commerceConnection.isLoading;
412
+ const prefilled = (0, import_react.useRef)(false);
413
+ (0, import_react.useEffect)(() => {
414
+ if (loading || disabled || prefilled.current) return;
415
+ prefilled.current = true;
416
+ const row = prefillRow({ entry: catalog, step: values == null ? void 0 : values.step, steps: getValues("steps") });
417
+ if (row) setValue("steps", [...getValues("steps"), row], { shouldDirty: true });
418
+ }, [catalog, disabled, getValues, loading, setValue, values == null ? void 0 : values.step]);
568
419
  const getStepOptions = (index) => {
569
420
  const usedTypes = watchedSteps.map((s, i) => i !== index ? s.type : null).filter(Boolean);
570
421
  return [
571
422
  { key: "Select a step", value: "" },
572
- ...((selectedTriggerEntry == null ? void 0 : selectedTriggerEntry.steps) || []).filter((step) => !usedTypes.includes(step.value)).filter((step) => {
423
+ ...((catalog == null ? void 0 : catalog.steps) || []).filter((step) => !usedTypes.includes(step.value)).filter((step) => {
573
424
  var _a2;
574
425
  return !step.ownerOnly || step.value === ((_a2 = watchedSteps[index]) == null ? void 0 : _a2.type);
575
426
  }).sort((a, b) => String(a.key).localeCompare(String(b.key))).map((step) => ({
@@ -586,7 +437,7 @@ const FormOrganizationWorkflowEdit = ({
586
437
  // connectionless and sendgrid is gone — but the rule is about any
587
438
  // two entries sharing a type, so it stays.
588
439
  value: step.connectionId ? step.value + "::" + step.connectionId : step.slug ? step.value + "::" + step.slug : step.value,
589
- ...step.disabled ? {
440
+ ...step.disabled && !step.reason ? {
590
441
  badge: {
591
442
  text: "Enable connection"
592
443
  },
@@ -594,8 +445,7 @@ const FormOrganizationWorkflowEdit = ({
594
445
  element: import_link.default,
595
446
  key: step == null ? void 0 : step.key,
596
447
  props: {
597
- href: "/organizations/" + (values == null ? void 0 : values.organization) + "/connections/" + step.slug,
598
- onClick: onClose
448
+ href: "/organizations/" + (values == null ? void 0 : values.organization) + "/connections/" + step.slug
599
449
  }
600
450
  } : {},
601
451
  // The same link-shaped option, greyed: it cannot be picked, and
@@ -610,14 +460,29 @@ const FormOrganizationWorkflowEdit = ({
610
460
  key: step == null ? void 0 : step.key,
611
461
  props: {
612
462
  "aria-disabled": true,
613
- href: "/organizations/" + (values == null ? void 0 : values.organization) + "/settings",
614
- onClick: onClose
463
+ href: "/organizations/" + (values == null ? void 0 : values.organization) + "/settings"
464
+ }
465
+ } : {},
466
+ // @story workflows/edit
467
+ // A step the form cannot feed: greyed with its reason, and a
468
+ // click opens the campaign's Form page, where the field is added.
469
+ ...step.reason ? {
470
+ badge: {
471
+ text: step.reason
472
+ },
473
+ className: "opacity-50",
474
+ disabled: false,
475
+ element: import_link.default,
476
+ key: step == null ? void 0 : step.key,
477
+ props: {
478
+ "aria-disabled": true,
479
+ href: "/organizations/" + (values == null ? void 0 : values.organization) + "/campaigns/" + (values == null ? void 0 : values.campaign) + "/form"
615
480
  }
616
481
  } : {}
617
482
  }))
618
483
  ];
619
484
  };
620
- const lockedStep = (index) => ((selectedTriggerEntry == null ? void 0 : selectedTriggerEntry.steps) || []).some((s) => {
485
+ const lockedStep = (index) => ((catalog == null ? void 0 : catalog.steps) || []).some((s) => {
621
486
  var _a2;
622
487
  return s.ownerOnly && s.value === ((_a2 = watchedSteps[index]) == null ? void 0 : _a2.type);
623
488
  });
@@ -631,7 +496,7 @@ const FormOrganizationWorkflowEdit = ({
631
496
  return match ? match.value : "";
632
497
  };
633
498
  const getStepConnection = (field) => {
634
- const steps = (selectedTriggerEntry == null ? void 0 : selectedTriggerEntry.steps) || [];
499
+ const steps = (catalog == null ? void 0 : catalog.steps) || [];
635
500
  const def = field.connectionId && steps.find((s) => s.connectionId === field.connectionId) || field.slug && steps.find((s) => s.slug === field.slug && s.value === field.type) || steps.find((s) => s.value === field.type);
636
501
  if (!def) return null;
637
502
  const connected = Boolean(def.connectionId);
@@ -644,6 +509,19 @@ const FormOrganizationWorkflowEdit = ({
644
509
  };
645
510
  };
646
511
  const renderStepBadge = (field) => {
512
+ const reason = stepReason({ entry: catalog, saved: values == null ? void 0 : values.steps, type: field == null ? void 0 : field.type });
513
+ if (reason) {
514
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
515
+ import_badge.default,
516
+ {
517
+ ...{
518
+ size: "small",
519
+ type: "error"
520
+ },
521
+ children: reason
522
+ }
523
+ );
524
+ }
647
525
  const conn = getStepConnection(field);
648
526
  if (!conn) return null;
649
527
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -658,11 +536,7 @@ const FormOrganizationWorkflowEdit = ({
658
536
  );
659
537
  };
660
538
  const onSubmit = async ({
661
- steps,
662
- filterCampaigns,
663
- filterSegment,
664
- title,
665
- triggerEvent
539
+ steps
666
540
  }) => {
667
541
  try {
668
542
  const body = {
@@ -678,7 +552,7 @@ const FormOrganizationWorkflowEdit = ({
678
552
  }
679
553
  if (teamSteps.includes(type)) settings.members = (members || []).map((member) => member == null ? void 0 : member.id).filter(Boolean);
680
554
  if (type === "step.commerce.code.issue") settings.discount = discount;
681
- const catalogSteps = (selectedTriggerEntry == null ? void 0 : selectedTriggerEntry.steps) || [];
555
+ const catalogSteps = (catalog == null ? void 0 : catalog.steps) || [];
682
556
  const catalogStep = connectionId && catalogSteps.find((s) => s.connectionId === connectionId) || slug && catalogSteps.find((s) => s.slug === slug && s.value === type) || catalogSteps.find((s) => s.value === type);
683
557
  const resolvedConnectionId = (catalogStep == null ? void 0 : catalogStep.connectionId) || connectionId || null;
684
558
  const resolvedSlug = (catalogStep == null ? void 0 : catalogStep.slug) || slug || null;
@@ -688,19 +562,11 @@ const FormOrganizationWorkflowEdit = ({
688
562
  settings,
689
563
  type
690
564
  };
691
- }),
692
- title,
693
- trigger: {
694
- event: triggerEvent,
695
- filters: {
696
- campaigns: filterCampaigns || [],
697
- segment: filterSegment || null
698
- }
699
- }
565
+ })
700
566
  };
701
567
  const response = await (0, import_fetch.request)({
702
568
  body,
703
- endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/workflow/" + values.id,
569
+ endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + (values == null ? void 0 : values.campaign) + "/workflow/" + event,
704
570
  method: "PUT"
705
571
  });
706
572
  onSuccess(response);
@@ -708,7 +574,7 @@ const FormOrganizationWorkflowEdit = ({
708
574
  onError(error);
709
575
  }
710
576
  };
711
- if (catalog.isLoading || membersLoading || commerceConnection.isLoading) {
577
+ if (loading) {
712
578
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_loader.LoaderDynamic, {});
713
579
  }
714
580
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -735,65 +601,32 @@ const FormOrganizationWorkflowEdit = ({
735
601
  }
736
602
  }
737
603
  ),
738
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
739
- WorkflowTriggerField,
740
- {
741
- ...{
742
- control,
743
- formState,
744
- catalogList,
745
- triggerOptions,
746
- getValues,
747
- setValue
748
- }
749
- }
750
- ),
751
- watchedTrigger && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
752
- WorkflowTitleField,
604
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
605
+ import_card_section.default,
753
606
  {
754
607
  ...{
755
- control,
756
- formState
757
- }
758
- }
759
- ),
760
- watchedTrigger === "lead.insert" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
761
- WorkflowFilterField,
762
- {
763
- ...{
764
- collection: "campaigns",
765
- control,
766
- label: "Campaigns",
767
- message: "Only runs for leads from the campaigns you add. With none added, it runs for every campaign.",
768
- model: "campaign",
769
- multiple: true,
770
- name: "filterCampaigns",
771
- organization: values == null ? void 0 : values.organization,
772
- resource: "campaign",
773
- seeds: (_m = (_l = values == null ? void 0 : values.trigger) == null ? void 0 : _l.filters) == null ? void 0 : _m.campaigns
774
- }
775
- }
776
- ),
777
- watchedTrigger === "segment.contact.add" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
778
- WorkflowFilterField,
779
- {
780
- ...{
781
- collection: "segments",
782
- control,
783
- label: "Segment",
784
- message: "Only trigger when a contact joins a specific segment. Leaving blank will trigger for all segments.",
785
- model: "segment",
786
- name: "filterSegment",
787
- organization: values == null ? void 0 : values.organization,
788
- resource: "segment"
789
- }
608
+ "data-trigger": true,
609
+ title: "Trigger"
610
+ },
611
+ children: [
612
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: values == null ? void 0 : values.title }),
613
+ (values == null ? void 0 : values.description) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
614
+ "p",
615
+ {
616
+ ...{
617
+ className: "text-sm text-gray-dark"
618
+ },
619
+ children: values.description
620
+ }
621
+ )
622
+ ]
790
623
  }
791
624
  ),
792
625
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
793
626
  import_input_group.default,
794
627
  {
795
628
  ...{
796
- error: (_o = (_n = formState == null ? void 0 : formState.errors) == null ? void 0 : _n.steps) == null ? void 0 : _o.message,
629
+ error: (_i = (_h = formState == null ? void 0 : formState.errors) == null ? void 0 : _h.steps) == null ? void 0 : _i.message,
797
630
  input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
798
631
  import_input_array.InputArraySortable,
799
632
  {
@@ -805,7 +638,6 @@ const FormOrganizationWorkflowEdit = ({
805
638
  import_input_array.InputArrayButton,
806
639
  {
807
640
  ...{
808
- disabled: !watchedTrigger,
809
641
  onClick: () => append(stepRow()),
810
642
  text: "Add step"
811
643
  }
@@ -814,318 +646,321 @@ const FormOrganizationWorkflowEdit = ({
814
646
  },
815
647
  children: ({ field, handle, index, remove }) => {
816
648
  const step = (watchedSteps == null ? void 0 : watchedSteps[index]) || field;
817
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
818
- "div",
819
- {
820
- ...{
821
- className: "w-full bg-white border border-gray rounded p-4 space-y-3"
822
- },
823
- children: [
824
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
649
+ return (
650
+ // @story workflows/edit
651
+ // EACH STEP IS ITS OWN CARD in the flow under the Trigger card,
652
+ // edited in place: the drag handle left of Step N, as every
653
+ // sortable list has it, then its connection badge and Remove
654
+ // in the card's head, its fields in the body.
655
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
656
+ StepCard,
657
+ {
658
+ ...{
659
+ control,
660
+ // @story workflows/send-email
661
+ // A Send email step shows its email beside its form.
662
+ email: emailSteps.includes(step.type) && {
663
+ campaign: values == null ? void 0 : values.campaign,
664
+ event,
665
+ name: `steps.${index}`,
666
+ organization: values == null ? void 0 : values.organization
667
+ },
668
+ cta: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
669
+ "span",
670
+ {
671
+ ...{
672
+ className: "flex items-center gap-2"
673
+ },
674
+ children: [
675
+ renderStepBadge(step),
676
+ !lockedStep(index) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
677
+ import_input_array.InputArrayControl,
678
+ {
679
+ ...{
680
+ onClick: () => remove(index),
681
+ icon: import_trash.default
682
+ }
683
+ },
684
+ "remove"
685
+ )
686
+ ]
687
+ }
688
+ ),
689
+ "data-step": index + 1,
690
+ title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
691
+ "span",
692
+ {
693
+ ...{
694
+ className: "flex items-center gap-2"
695
+ },
696
+ children: [
697
+ handle,
698
+ "Step " + (index + 1)
699
+ ]
700
+ }
701
+ )
702
+ },
703
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
825
704
  "div",
826
705
  {
827
706
  ...{
828
- className: "flex items-center justify-between"
707
+ className: "space-y-3"
829
708
  },
830
709
  children: [
831
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
832
- "div",
710
+ issueIndex === index && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
711
+ import_error.default,
833
712
  {
834
713
  ...{
835
- className: "flex items-center space-x-2"
836
- },
837
- children: [
838
- handle,
839
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
840
- "span",
841
- {
842
- ...{
843
- className: "text-sm font-medium"
844
- },
845
- children: [
846
- "Step ",
847
- index + 1
848
- ]
849
- }
850
- )
851
- ]
714
+ error: values.issue.message
715
+ }
852
716
  }
853
717
  ),
854
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
855
- "div",
718
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
719
+ import_form.Controller,
856
720
  {
857
721
  ...{
858
- className: "flex items-center space-x-2"
859
- },
860
- children: [
861
- renderStepBadge(step),
862
- !lockedStep(index) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
863
- import_input_array.InputArrayControl,
864
- {
865
- ...{
866
- onClick: () => remove(index),
867
- icon: import_trash.default
868
- }
869
- },
870
- "remove"
871
- )
872
- ]
873
- }
874
- )
875
- ]
876
- }
877
- ),
878
- issueIndex === index && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
879
- import_error.default,
880
- {
881
- ...{
882
- error: values.issue.message
883
- }
884
- }
885
- ),
886
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
887
- import_form.Controller,
888
- {
889
- ...{
890
- control,
891
- name: `steps.${index}.type`,
892
- render: ({ field: { onChange } }) => {
893
- var _a2, _b2, _c2, _d2;
894
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
895
- import_input_group.default,
896
- {
897
- ...{
898
- error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.type) == null ? void 0 : _d2.message,
899
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
900
- import_input_combobox.default,
722
+ control,
723
+ name: `steps.${index}.type`,
724
+ render: ({ field: { onChange } }) => {
725
+ var _a2, _b2, _c2, _d2;
726
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
727
+ import_input_group.default,
901
728
  {
902
729
  ...{
903
- onChange: (val) => {
904
- const [type] = val.split("::");
905
- const option = getStepOptions(index).find((o) => o.value === val);
906
- onChange(type);
907
- setValue(`steps.${index}.connectionId`, (option == null ? void 0 : option.connectionId) || "");
908
- setValue(`steps.${index}.slug`, (option == null ? void 0 : option.slug) || "");
909
- },
910
- disabled: lockedStep(index),
911
- options: getStepOptions(index),
912
- // Resolved from the WHOLE ROW, not from this path: the
913
- // option value carries a connection the type alone cannot
914
- // name.
915
- value: getStepValue(step, index)
730
+ error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.type) == null ? void 0 : _d2.message,
731
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
732
+ import_input_combobox.default,
733
+ {
734
+ ...{
735
+ onChange: (val) => {
736
+ const [type] = val.split("::");
737
+ const option = getStepOptions(index).find((o) => o.value === val);
738
+ onChange(type);
739
+ setValue(`steps.${index}.connectionId`, (option == null ? void 0 : option.connectionId) || "");
740
+ setValue(`steps.${index}.slug`, (option == null ? void 0 : option.slug) || "");
741
+ },
742
+ disabled: lockedStep(index),
743
+ options: getStepOptions(index),
744
+ // Resolved from the WHOLE ROW, not from this path: the
745
+ // option value carries a connection the type alone cannot
746
+ // name.
747
+ value: getStepValue(step, index)
748
+ }
749
+ }
750
+ ),
751
+ label: "Step"
916
752
  }
917
753
  }
918
- ),
919
- label: "Step"
754
+ );
920
755
  }
921
756
  }
922
- );
923
- }
924
- }
925
- }
926
- ),
927
- step.type === "step.webhook.send" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
928
- import_form.Controller,
929
- {
930
- ...{
931
- control,
932
- name: `steps.${index}.url`,
933
- render: ({ field: { value, onChange } }) => {
934
- var _a2, _b2, _c2, _d2;
935
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
936
- import_input_group.default,
937
- {
938
- ...{
939
- error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.url) == null ? void 0 : _d2.message,
940
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
941
- import_input_url.default,
757
+ }
758
+ ),
759
+ step.type === "step.webhook.send" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
760
+ import_form.Controller,
761
+ {
762
+ ...{
763
+ control,
764
+ name: `steps.${index}.url`,
765
+ render: ({ field: { value, onChange } }) => {
766
+ var _a2, _b2, _c2, _d2;
767
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
768
+ import_input_group.default,
942
769
  {
943
770
  ...{
944
- onChange,
945
- value: value || ""
771
+ error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.url) == null ? void 0 : _d2.message,
772
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
773
+ import_input_url.default,
774
+ {
775
+ ...{
776
+ onChange,
777
+ value: value || ""
778
+ }
779
+ }
780
+ ),
781
+ label: "Webhook URL"
946
782
  }
947
783
  }
948
- ),
949
- label: "Webhook URL"
784
+ );
950
785
  }
951
786
  }
952
- );
953
- }
954
- }
955
- }
956
- ),
957
- teamSteps.includes(step.type) && lockedStep(index) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-gray-500", children: "Recipients are chosen by the organization owner." }),
958
- teamSteps.includes(step.type) && !lockedStep(index) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
959
- import_form.Controller,
960
- {
961
- ...{
962
- control,
963
- name: `steps.${index}.members`,
964
- render: ({ field: { value, onChange } }) => {
965
- var _a2, _b2, _c2, _d2;
966
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
967
- import_input_group.default,
968
- {
969
- ...{
970
- error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.members) == null ? void 0 : _d2.message,
971
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
972
- import_input_resource.default,
787
+ }
788
+ ),
789
+ teamSteps.includes(step.type) && lockedStep(index) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-gray-500", children: "Recipients are chosen by the organization owner." }),
790
+ teamSteps.includes(step.type) && !lockedStep(index) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
791
+ import_form.Controller,
792
+ {
793
+ ...{
794
+ control,
795
+ name: `steps.${index}.members`,
796
+ render: ({ field: { value, onChange } }) => {
797
+ var _a2, _b2, _c2, _d2;
798
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
799
+ import_input_group.default,
973
800
  {
974
801
  ...{
975
- empty: "No members to add",
976
- endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/members",
977
- // The owner is a chip like the others, only it cannot be
978
- // removed: they are always a recipient and it is resolved
979
- // in sync. Shaped like a member so `render` labels it the
980
- // same way.
981
- fixed: [{ email: ownerEmail }],
982
- model: "member",
983
- multiple: true,
984
- onChange,
985
- params: memberParams,
986
- render: memberLabel,
987
- // The row shows the name ( memberLabel ), so the search has
988
- // to hit the name too. The members endpoint joins `user`
989
- // before its search stage, so the nested keys resolve.
990
- // Email stays for invitees who have not registered yet.
991
- // ponytail: a full "First Last" query matches neither key;
992
- // a $concat'd name on the API side if that comes up.
993
- searchKeys: ["email", "user.firstName", "user.lastName"],
994
- value: value || []
802
+ error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.members) == null ? void 0 : _d2.message,
803
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
804
+ import_input_resource.default,
805
+ {
806
+ ...{
807
+ empty: "No members to add",
808
+ endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/members",
809
+ // The owner is a chip like the others, only it cannot be
810
+ // removed: they are always a recipient and it is resolved
811
+ // in sync. Shaped like a member so `render` labels it the
812
+ // same way.
813
+ fixed: [{ email: ownerEmail }],
814
+ model: "member",
815
+ multiple: true,
816
+ onChange,
817
+ params: memberParams,
818
+ render: memberLabel,
819
+ // The row shows the name ( memberLabel ), so the search has
820
+ // to hit the name too. The members endpoint joins `user`
821
+ // before its search stage, so the nested keys resolve.
822
+ // Email stays for invitees who have not registered yet.
823
+ // ponytail: a full "First Last" query matches neither key;
824
+ // a $concat'd name on the API side if that comes up.
825
+ searchKeys: ["email", "user.firstName", "user.lastName"],
826
+ value: value || []
827
+ }
828
+ }
829
+ ),
830
+ label: "Recipients"
995
831
  }
996
832
  }
997
- ),
998
- label: "Recipients"
833
+ );
999
834
  }
1000
835
  }
1001
- );
1002
- }
1003
- }
1004
- }
1005
- ),
1006
- emailSteps.includes(step.type) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1007
- import_form_notification.FormNotification,
1008
- {
1009
- ...{
1010
- control,
1011
- // As the Fieldset above: the Message editor is a
1012
- // contenteditable, which a disabled fieldset never reaches.
1013
- disabled: disabled || (formState == null ? void 0 : formState.isSubmitting),
1014
- formState,
1015
- onChecking,
1016
- setValue,
1017
- values: {
1018
- id: field.id,
1019
- name: `steps.${index}`,
1020
- organization: values == null ? void 0 : values.organization,
1021
- variables: getAvailableVariables(index)
1022
- }
1023
- }
1024
- }
1025
- ),
1026
- step.type === "step.sms.send" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1027
- import_form.Controller,
1028
- {
1029
- ...{
1030
- control,
1031
- name: `steps.${index}.message`,
1032
- render: ({ field: { value, onChange } }) => {
1033
- var _a2, _b2, _c2, _d2;
1034
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1035
- import_input_group.default,
1036
- {
1037
- ...{
1038
- error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.message) == null ? void 0 : _d2.message,
1039
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1040
- import_input_textarea.default,
836
+ }
837
+ ),
838
+ emailSteps.includes(step.type) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
839
+ import_form_notification.FormNotification,
840
+ {
841
+ ...{
842
+ control,
843
+ // As the Fieldset above: the Message editor is a
844
+ // contenteditable, which a disabled fieldset never reaches.
845
+ disabled: disabled || (formState == null ? void 0 : formState.isSubmitting),
846
+ formState,
847
+ onChecking,
848
+ setValue,
849
+ values: {
850
+ id: field.id,
851
+ name: `steps.${index}`,
852
+ organization: values == null ? void 0 : values.organization,
853
+ variables: getAvailableVariables(index)
854
+ }
855
+ }
856
+ }
857
+ ),
858
+ step.type === "step.sms.send" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
859
+ import_form.Controller,
860
+ {
861
+ ...{
862
+ control,
863
+ name: `steps.${index}.message`,
864
+ render: ({ field: { value, onChange } }) => {
865
+ var _a2, _b2, _c2, _d2;
866
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
867
+ import_input_group.default,
1041
868
  {
1042
869
  ...{
1043
- onChange,
1044
- rows: 3,
1045
- value: value || ""
870
+ error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.message) == null ? void 0 : _d2.message,
871
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
872
+ import_input_textarea.default,
873
+ {
874
+ ...{
875
+ onChange,
876
+ rows: 3,
877
+ value: value || ""
878
+ }
879
+ }
880
+ ),
881
+ label: "Message"
1046
882
  }
1047
883
  }
1048
- ),
1049
- label: "Message"
884
+ );
1050
885
  }
1051
886
  }
1052
- );
1053
- }
1054
- }
1055
- }
1056
- ),
1057
- step.type === "step.commerce.code.issue" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1058
- import_form.Controller,
1059
- {
1060
- ...{
1061
- control,
1062
- name: `steps.${index}.discount`,
1063
- render: ({ field: { value, onChange } }) => {
1064
- var _a2, _b2, _c2, _d2;
1065
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1066
- import_input_group.default,
1067
- {
1068
- ...{
1069
- error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.discount) == null ? void 0 : _d2.message,
1070
- input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1071
- import_input_resource.default,
887
+ }
888
+ ),
889
+ step.type === "step.commerce.code.issue" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
890
+ import_form.Controller,
891
+ {
892
+ ...{
893
+ control,
894
+ name: `steps.${index}.discount`,
895
+ render: ({ field: { value, onChange } }) => {
896
+ var _a2, _b2, _c2, _d2;
897
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
898
+ import_input_group.default,
1072
899
  {
1073
900
  ...{
1074
- endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/connection/" + commerceConnectionId + "/hook/browse.promotions",
1075
- model: "discount",
1076
- onChange,
1077
- // A DISCOUNT THE STORE CANNOT BACK IS SHOWN AND EXPLAINED, never
1078
- // filtered out. The merchant can see it in Shopify admin, so a row
1079
- // missing here with no reason reads as our bug rather than their
1080
- // setting — and the reason names the fix.
1081
- render: (item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
1082
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: (item == null ? void 0 : item.blocked) ? "text-gray-dark" : void 0, children: item == null ? void 0 : item.title }),
1083
- ((item == null ? void 0 : item.blocked) || (item == null ? void 0 : item.warning)) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "block text-sm text-gray-dark", children: item.blocked || item.warning })
1084
- ] }),
1085
- renderButton: ({ button, item }) => (
1086
- // The list's small inline Add, unless the list says otherwise.
1087
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1088
- import_button.default,
1089
- {
1090
- ...{
1091
- inline: true,
1092
- size: "small",
1093
- ...button.props,
1094
- disabled: Boolean(item == null ? void 0 : item.blocked),
1095
- title: (item == null ? void 0 : item.blocked) || void 0
1096
- },
1097
- children: button.text
901
+ error: (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.discount) == null ? void 0 : _d2.message,
902
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
903
+ import_input_resource.default,
904
+ {
905
+ ...{
906
+ endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/connection/" + commerceConnectionId + "/hook/browse.promotions",
907
+ model: "discount",
908
+ onChange,
909
+ // A DISCOUNT THE STORE CANNOT BACK IS SHOWN AND EXPLAINED, never
910
+ // filtered out. The merchant can see it in Shopify admin, so a row
911
+ // missing here with no reason reads as our bug rather than their
912
+ // setting — and the reason names the fix.
913
+ render: (item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
914
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: (item == null ? void 0 : item.blocked) ? "text-gray-dark" : void 0, children: item == null ? void 0 : item.title }),
915
+ ((item == null ? void 0 : item.blocked) || (item == null ? void 0 : item.warning)) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "block text-sm text-gray-dark", children: item.blocked || item.warning })
916
+ ] }),
917
+ renderButton: ({ button, item }) => (
918
+ // The list's small inline Add, unless the list says otherwise.
919
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
920
+ import_button.default,
921
+ {
922
+ ...{
923
+ inline: true,
924
+ size: "small",
925
+ ...button.props,
926
+ disabled: Boolean(item == null ? void 0 : item.blocked),
927
+ title: (item == null ? void 0 : item.blocked) || void 0
928
+ },
929
+ children: button.text
930
+ }
931
+ )
932
+ ),
933
+ value: value || null
1098
934
  }
1099
- )
935
+ }
1100
936
  ),
1101
- value: value || null
937
+ label: "Discount",
938
+ // "Issue" means MINT, not send — this step creates the code and saves
939
+ // it to the lead, and nothing reaches them until a later email step
940
+ // names the variable. Said here because the step picker says nothing:
941
+ // QA read "Issue a discount code", built the one-step workflow that
942
+ // describes, and reported the codes as never arriving.
943
+ message: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
944
+ "Creates the code and saves it to the lead. To send it, add an email step after this one with ",
945
+ "{{shopifyDiscountCode}}",
946
+ " in the message.",
947
+ commerceDomain ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
948
+ " ",
949
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: "https://" + commerceDomain + "/admin/discounts", rel: "noopener noreferrer", target: "_blank", children: "Manage discounts" })
950
+ ] }) : null
951
+ ] })
1102
952
  }
1103
953
  }
1104
- ),
1105
- label: "Discount",
1106
- // "Issue" means MINT, not send — this step creates the code and saves
1107
- // it to the lead, and nothing reaches them until a later email step
1108
- // names the variable. Said here because the step picker says nothing:
1109
- // QA read "Issue a discount code", built the one-step workflow that
1110
- // describes, and reported the codes as never arriving.
1111
- message: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
1112
- "Creates the code and saves it to the lead. To send it, add an email step after this one with ",
1113
- "{{shopifyDiscountCode}}",
1114
- " in the message.",
1115
- commerceDomain ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
1116
- " ",
1117
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: "https://" + commerceDomain + "/admin/discounts", rel: "noopener noreferrer", target: "_blank", children: "Manage discounts" })
1118
- ] }) : null
1119
- ] })
954
+ );
1120
955
  }
1121
956
  }
1122
- );
1123
- }
1124
- }
957
+ }
958
+ )
959
+ ]
1125
960
  }
1126
961
  )
1127
- ]
1128
- }
962
+ }
963
+ )
1129
964
  );
1130
965
  }
1131
966
  }
@@ -1153,13 +988,10 @@ const FormOrganizationWorkflowEdit = ({
1153
988
  };
1154
989
  // Annotate the CommonJS export names for ESM import in node:
1155
990
  0 && (module.exports = {
1156
- FormOrganizationWorkflow,
1157
991
  FormOrganizationWorkflowEdit,
1158
- campaignFilterId,
1159
- campaignFilterIds,
1160
- filterMissing,
1161
- filterRows,
1162
- filterSeed,
992
+ prefillRow,
993
+ stepReason,
1163
994
  stepRow,
995
+ stepVariables,
1164
996
  workflowSchema
1165
997
  });