@aglyn/plugins-workflows 1.0.0-beta.143

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 (75) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +52 -0
  3. package/package.json +53 -0
  4. package/src/index.d.ts +18 -0
  5. package/src/index.js +19 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/components/automation-step-fields.component.d.ts +74 -0
  8. package/src/lib/components/automation-step-fields.component.js +1210 -0
  9. package/src/lib/components/automation-step-fields.component.js.map +1 -0
  10. package/src/lib/components/host-actions-card.component.d.ts +15 -0
  11. package/src/lib/components/host-actions-card.component.js +1229 -0
  12. package/src/lib/components/host-actions-card.component.js.map +1 -0
  13. package/src/lib/components/host-activity-card.component.d.ts +84 -0
  14. package/src/lib/components/host-activity-card.component.js +280 -0
  15. package/src/lib/components/host-activity-card.component.js.map +1 -0
  16. package/src/lib/components/host-run-history-card.component.d.ts +40 -0
  17. package/src/lib/components/host-run-history-card.component.js +284 -0
  18. package/src/lib/components/host-run-history-card.component.js.map +1 -0
  19. package/src/lib/components/host-webhooks-card.component.d.ts +15 -0
  20. package/src/lib/components/host-webhooks-card.component.js +421 -0
  21. package/src/lib/components/host-webhooks-card.component.js.map +1 -0
  22. package/src/lib/components/host-workflows-card.component.d.ts +18 -0
  23. package/src/lib/components/host-workflows-card.component.js +952 -0
  24. package/src/lib/components/host-workflows-card.component.js.map +1 -0
  25. package/src/lib/components/run-quota-line.component.d.ts +27 -0
  26. package/src/lib/components/run-quota-line.component.js +72 -0
  27. package/src/lib/components/run-quota-line.component.js.map +1 -0
  28. package/src/lib/components/use-automation-step-pickers.d.ts +27 -0
  29. package/src/lib/components/use-automation-step-pickers.js +205 -0
  30. package/src/lib/components/use-automation-step-pickers.js.map +1 -0
  31. package/src/lib/components/workflow-zones.d.ts +36 -0
  32. package/src/lib/components/workflow-zones.js +19 -0
  33. package/src/lib/components/workflow-zones.js.map +1 -0
  34. package/src/lib/components/workflows-console-page.d.ts +25 -0
  35. package/src/lib/components/workflows-console-page.js +112 -0
  36. package/src/lib/components/workflows-console-page.js.map +1 -0
  37. package/src/lib/components/workflows-console-sections.d.ts +34 -0
  38. package/src/lib/components/workflows-console-sections.js +50 -0
  39. package/src/lib/components/workflows-console-sections.js.map +1 -0
  40. package/src/lib/constants/bundle-common.d.ts +8 -0
  41. package/src/lib/constants/bundle-common.js +9 -0
  42. package/src/lib/constants/bundle-common.js.map +1 -0
  43. package/src/lib/declarations.server.d.ts +41 -0
  44. package/src/lib/declarations.server.js +54 -0
  45. package/src/lib/declarations.server.js.map +1 -0
  46. package/src/lib/engine/crm-action-steps.d.ts +129 -0
  47. package/src/lib/engine/crm-action-steps.js +432 -0
  48. package/src/lib/engine/crm-action-steps.js.map +1 -0
  49. package/src/lib/engine/flow-enrollments.d.ts +264 -0
  50. package/src/lib/engine/flow-enrollments.js +386 -0
  51. package/src/lib/engine/flow-enrollments.js.map +1 -0
  52. package/src/lib/engine/run-event-actions.d.ts +232 -0
  53. package/src/lib/engine/run-event-actions.js +1392 -0
  54. package/src/lib/engine/run-event-actions.js.map +1 -0
  55. package/src/lib/engine/run-event-automations.d.ts +28 -0
  56. package/src/lib/engine/run-event-automations.js +37 -0
  57. package/src/lib/engine/run-event-automations.js.map +1 -0
  58. package/src/lib/engine/run-event-workflows.d.ts +75 -0
  59. package/src/lib/engine/run-event-workflows.js +311 -0
  60. package/src/lib/engine/run-event-workflows.js.map +1 -0
  61. package/src/lib/engine/workflow-steps.d.ts +107 -0
  62. package/src/lib/engine/workflow-steps.js +124 -0
  63. package/src/lib/engine/workflow-steps.js.map +1 -0
  64. package/src/lib/plugin.d.ts +33 -0
  65. package/src/lib/plugin.js +94 -0
  66. package/src/lib/plugin.js.map +1 -0
  67. package/src/lib/server-automation-drafts.d.ts +90 -0
  68. package/src/lib/server-automation-drafts.js +429 -0
  69. package/src/lib/server-automation-drafts.js.map +1 -0
  70. package/src/lib/server-console.d.ts +27 -0
  71. package/src/lib/server-console.js +35 -0
  72. package/src/lib/server-console.js.map +1 -0
  73. package/src/lib/server.d.ts +29 -0
  74. package/src/lib/server.js +298 -0
  75. package/src/lib/server.js.map +1 -0
@@ -0,0 +1,1210 @@
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
+ */ 'use client';
17
+ import { _ as _extends } from "@swc/helpers/_/_extends";
18
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
19
+ /**
20
+ * ONE STEP EDITOR FOR BOTH AUTOMATION BUILDERS (AGL-3105).
21
+ *
22
+ * A step's fields belong to the step, not to the card the step is edited on.
23
+ * The Actions builder and the Workflows builder both hold an ordered list of
24
+ * steps, and a workflow step may be any server-side Actions step, so the
25
+ * fields it takes — which dataset, which campaign, how long to wait, what to
26
+ * say — are asked here and in one place. A second copy would be two editors
27
+ * of one vocabulary, drifting a field at a time.
28
+ *
29
+ * What the card keeps is the list: what "Add step" builds, how many are
30
+ * allowed, and what a kind the Actions vocabulary does not hold looks like —
31
+ * a workflow's function call, handed in as `fields`.
32
+ */ import { CONTACT_LIFECYCLE_STAGE_LABELS, CONTACT_LIFECYCLE_STAGES, CONTACT_TAG_MAX_LENGTH, CRM_ACTIVITY_KIND_LABELS, CRM_ACTIVITY_KINDS, CRM_TASK_KIND_LABELS, CRM_TASK_KINDS, CRM_TASK_MAX_DUE_DAYS, HOST_EVENT_TYPES, hostEventLabel, isInteractionAttributeAllowed } from "@aglyn/aglyn";
33
+ import { automationPlaceholderIn } from "@aglyn/aglyn/app-utils/automation-placeholders";
34
+ import { IconButton, MenuItem, Stack, TextField, Typography } from "@mui/material";
35
+ /**
36
+ * The durations a wait may be set to, from the picker.
37
+ *
38
+ * A select rather than a number field, because minutes are the wrong unit for
39
+ * the thing being chosen: a welcome series is authored in days and nobody
40
+ * wants to compute that three days is 4,320. Every value is inside the
41
+ * validated band, so the picker cannot produce a step the validator refuses —
42
+ * which is the property a free-text duration field would not have.
43
+ */ const FLOW_WAIT_PRESETS = [
44
+ {
45
+ minutes: 5,
46
+ label: '5 minutes'
47
+ },
48
+ {
49
+ minutes: 30,
50
+ label: '30 minutes'
51
+ },
52
+ {
53
+ minutes: 60,
54
+ label: '1 hour'
55
+ },
56
+ {
57
+ minutes: 60 * 4,
58
+ label: '4 hours'
59
+ },
60
+ {
61
+ minutes: 60 * 24,
62
+ label: '1 day'
63
+ },
64
+ {
65
+ minutes: 60 * 24 * 2,
66
+ label: '2 days'
67
+ },
68
+ {
69
+ minutes: 60 * 24 * 3,
70
+ label: '3 days'
71
+ },
72
+ {
73
+ minutes: 60 * 24 * 7,
74
+ label: '1 week'
75
+ },
76
+ {
77
+ minutes: 60 * 24 * 14,
78
+ label: '2 weeks'
79
+ },
80
+ {
81
+ minutes: 60 * 24 * 30,
82
+ label: '30 days'
83
+ },
84
+ {
85
+ minutes: 60 * 24 * 60,
86
+ label: '60 days'
87
+ },
88
+ {
89
+ minutes: 60 * 24 * 90,
90
+ label: '90 days'
91
+ }
92
+ ];
93
+ /**
94
+ * The two stored fields a typed teammate reference becomes.
95
+ *
96
+ * `ownerEmail`/`assigneeEmail` hold an address and nothing else — the
97
+ * validator refuses one without an `@`, and the executor matches it on the
98
+ * roster's `email`. A value with no `@` is a member id, stored in the uid
99
+ * field the executor verifies against the roster document. Clearing the
100
+ * text clears both, so a step never carries a stale address beside a uid.
101
+ */ function memberRefFields(role, value) {
102
+ const text = value.trim();
103
+ const emailKey = `${role}Email`;
104
+ const uidKey = `${role}Uid`;
105
+ if (!text) return {
106
+ [emailKey]: undefined,
107
+ [uidKey]: undefined
108
+ };
109
+ return text.includes('@') ? {
110
+ [emailKey]: value,
111
+ [uidKey]: undefined
112
+ } : {
113
+ [emailKey]: undefined,
114
+ [uidKey]: text
115
+ };
116
+ }
117
+ /**
118
+ * What a field holding a placeholder shows: an error state and what to do
119
+ * about it. A placeholder is a value a person still has to supply, written in
120
+ * square brackets where it belongs — an automation drafted for review carries
121
+ * one wherever it could not name a real record or did not know a fact.
122
+ */ export function placeholderState(value, help) {
123
+ return automationPlaceholderIn(value) ? {
124
+ error: true,
125
+ helperText: help
126
+ } : {};
127
+ }
128
+ /**
129
+ * A picker whose stored reference is a placeholder name and no id: the record
130
+ * the draft asked for, which the site did not have when it was written.
131
+ */ function placeholderReference(name, id, noun) {
132
+ const words = String(id != null ? id : '').trim() ? null : automationPlaceholderIn(name);
133
+ return words ? {
134
+ error: true,
135
+ helperText: `Pick the ${noun} — the draft asked for “${words}”`
136
+ } : {};
137
+ }
138
+ export function defaultStep(type) {
139
+ switch(type){
140
+ case 'runWorkflow':
141
+ return {
142
+ type,
143
+ workflowName: ''
144
+ };
145
+ case 'siteAlert':
146
+ return {
147
+ type,
148
+ message: '',
149
+ severity: 'info'
150
+ };
151
+ case 'customEvent':
152
+ return {
153
+ type,
154
+ eventName: ''
155
+ };
156
+ case 'webhookPost':
157
+ return {
158
+ type,
159
+ webhookName: ''
160
+ };
161
+ case 'showOverlay':
162
+ return {
163
+ type,
164
+ overlayId: ''
165
+ };
166
+ case 'stickyNav':
167
+ return {
168
+ type,
169
+ selector: ''
170
+ };
171
+ case 'addClass':
172
+ case 'removeClass':
173
+ case 'toggleClass':
174
+ return {
175
+ type,
176
+ selector: '',
177
+ className: ''
178
+ };
179
+ // Element show/hide + drawer commands (AGL-562).
180
+ case 'showElement':
181
+ case 'hideElement':
182
+ case 'toggleElement':
183
+ return {
184
+ type,
185
+ selector: ''
186
+ };
187
+ // Every step the menu offers needs a case here: the `default` below is a
188
+ // dataset write, so a step without one turns into that (AGL-2876).
189
+ case 'setAttribute':
190
+ return {
191
+ type,
192
+ selector: '',
193
+ name: '',
194
+ value: ''
195
+ };
196
+ case 'removeAttribute':
197
+ return {
198
+ type,
199
+ selector: '',
200
+ name: ''
201
+ };
202
+ // One-target steps (AGL-2867); absent options are the defaults.
203
+ case 'scrollTo':
204
+ case 'playVideo':
205
+ return {
206
+ type,
207
+ selector: ''
208
+ };
209
+ case 'openDrawer':
210
+ case 'closeDrawer':
211
+ case 'toggleDrawer':
212
+ return {
213
+ type
214
+ };
215
+ // Menu commands (AGL-568) mirror the drawer's optional target.
216
+ case 'openMenu':
217
+ case 'closeMenu':
218
+ case 'toggleMenu':
219
+ return {
220
+ type
221
+ };
222
+ case 'showHtml':
223
+ return {
224
+ type,
225
+ html: ''
226
+ };
227
+ case 'runJs':
228
+ return {
229
+ type,
230
+ code: ''
231
+ };
232
+ case 'redirect':
233
+ return {
234
+ type,
235
+ url: ''
236
+ };
237
+ case 'trackGaEvent':
238
+ return {
239
+ type,
240
+ eventName: ''
241
+ };
242
+ case 'sendEmail':
243
+ return {
244
+ type,
245
+ subject: '',
246
+ body: ''
247
+ };
248
+ case 'notifyAdmins':
249
+ return {
250
+ type,
251
+ title: ''
252
+ };
253
+ case 'enrollList':
254
+ return {
255
+ type,
256
+ listId: ''
257
+ };
258
+ case 'updateDataset':
259
+ return {
260
+ type,
261
+ datasetId: ''
262
+ };
263
+ case 'assignCampaign':
264
+ return {
265
+ type,
266
+ campaignId: ''
267
+ };
268
+ // The CRM steps (AGL-2605). A stage and a kind start on a real entry of
269
+ // their vocabulary rather than blank, so the select never shows a value
270
+ // the validator would refuse; the free-text fields start empty because
271
+ // there is nothing sensible to guess for them.
272
+ case 'setContactStage':
273
+ return {
274
+ type,
275
+ lifecycleStage: 'lead'
276
+ };
277
+ case 'addContactTag':
278
+ return {
279
+ type,
280
+ tag: ''
281
+ };
282
+ case 'assignContactOwner':
283
+ return {
284
+ type,
285
+ ownerEmail: ''
286
+ };
287
+ case 'createCrmTask':
288
+ return {
289
+ type,
290
+ title: '',
291
+ kind: 'call',
292
+ dueInDays: 1
293
+ };
294
+ case 'logCrmActivity':
295
+ return {
296
+ type,
297
+ kind: 'note',
298
+ body: ''
299
+ };
300
+ // A day, because a new wait is almost always part of a series measured in
301
+ // days and a default of one minute reads as a placeholder rather than a
302
+ // choice. Both are inside the validated band, so neither can be saved
303
+ // wrong; this is only which one the author starts from.
304
+ case 'wait':
305
+ return {
306
+ type,
307
+ delayMinutes: 60 * 24
308
+ };
309
+ case 'waitForEvent':
310
+ return {
311
+ type,
312
+ eventName: '',
313
+ timeoutMinutes: 60 * 24 * 3
314
+ };
315
+ case 'exitFlow':
316
+ return {
317
+ type
318
+ };
319
+ default:
320
+ return {
321
+ type: 'datasetAppend',
322
+ datasetName: ''
323
+ };
324
+ }
325
+ }
326
+ /**
327
+ * One step's row: its number, what it does, the fields that kind takes, and
328
+ * the condition that gates it.
329
+ */ export function AutomationStepFields({ step, index, kind, kinds, stepForKind, pickers, onSteps, fields }) {
330
+ var _ref, _step_workflowId, _step_severity, _ref1, _step_webhookId, _ref2, _step_datasetId, _step_overlayId, _step_selector, _step_selector1, _step_className, _step_selector2, _step_selector3, _step_offsetPx, _step_selector4, _step_name, _step_value, _step_drawerNodeId, _step_menuNodeId, _step_html, _step_code, _step_url, _step_eventName, _step_subject, _step_body, _step_title, _step_listId, _step_campaignId, _step_lifecycleStage, _step_tag, _step_title1, _step_kind, _step_dueInDays, _step_kind1, _step_body1, _step_eventName1, _step_timeoutMinutes, _step_delayMinutes, _ref3, _step_when_conditions__field, _step_when_conditions__value;
331
+ var _workflowOptions_find, _webhookOptions_find, _datasetOptions_find, _step_when_conditions_, _step_when_conditions, _step_when, _step_when_conditions_1, _step_when_conditions1, _step_when1, _step_when_conditions_2, _step_when_conditions2, _step_when2, _step_when_conditions_3, _step_when_conditions3, _step_when3;
332
+ const { workflowOptions, datasetOptions, overlayOptions, listOptions, campaignOptions, webhookOptions } = pickers;
333
+ /*
334
+ * The list, edited as a draft holding it — the shape both cards' own
335
+ * `patch` takes, so a field below reads the same here as it did beside the
336
+ * card it came from, and an edit that spreads `previous` still spreads only
337
+ * what it may change.
338
+ */ const patch = (update)=>onSteps((previous)=>update({
339
+ steps: previous
340
+ }).steps);
341
+ return /*#__PURE__*/ _jsxs(Stack, {
342
+ spacing: 0.5,
343
+ children: [
344
+ /*#__PURE__*/ _jsxs(Stack, {
345
+ direction: "row",
346
+ spacing: 1,
347
+ sx: {
348
+ alignItems: 'center'
349
+ },
350
+ children: [
351
+ /*#__PURE__*/ _jsx(Typography, {
352
+ variant: "caption",
353
+ color: "text.secondary",
354
+ children: `${index + 1}`
355
+ }),
356
+ /*#__PURE__*/ _jsx(TextField, {
357
+ select: true,
358
+ label: "Do",
359
+ value: kind,
360
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
361
+ steps: previous.steps.map((s, index2)=>index2 === index ? stepForKind(event.target.value) : s)
362
+ })),
363
+ size: "small",
364
+ sx: {
365
+ minWidth: 170
366
+ },
367
+ children: kinds.map((option)=>/*#__PURE__*/ _jsx(MenuItem, {
368
+ value: option.value,
369
+ children: option.label
370
+ }, option.value))
371
+ }),
372
+ fields != null ? fields : step.type === 'runWorkflow' ? /*#__PURE__*/ _jsx(TextField, _extends({
373
+ select: true,
374
+ label: "Workflow"
375
+ }, placeholderReference(step.workflowName, step.workflowId, 'workflow'), {
376
+ value: (_ref = (_step_workflowId = step.workflowId) != null ? _step_workflowId : (_workflowOptions_find = workflowOptions.find((option)=>option.name === step.workflowName)) == null ? void 0 : _workflowOptions_find.id) != null ? _ref : '',
377
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
378
+ steps: previous.steps.map((s, index2)=>{
379
+ var _ref;
380
+ var _workflowOptions_find;
381
+ return index2 === index ? _extends({}, s, {
382
+ workflowId: event.target.value,
383
+ workflowName: (_ref = (_workflowOptions_find = workflowOptions.find((option)=>option.id === event.target.value)) == null ? void 0 : _workflowOptions_find.name) != null ? _ref : s.workflowName
384
+ }) : s;
385
+ })
386
+ })),
387
+ size: "small",
388
+ sx: {
389
+ flex: 1
390
+ },
391
+ children: workflowOptions.map((option)=>/*#__PURE__*/ _jsx(MenuItem, {
392
+ value: option.id,
393
+ children: option.name
394
+ }, option.id))
395
+ })) : step.type === 'siteAlert' ? /*#__PURE__*/ _jsxs(_Fragment, {
396
+ children: [
397
+ /*#__PURE__*/ _jsx(TextField, _extends({
398
+ label: "Message"
399
+ }, placeholderState(step.message, 'Fill in the placeholder'), {
400
+ value: step.message,
401
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
402
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
403
+ message: event.target.value
404
+ }) : s)
405
+ })),
406
+ size: "small",
407
+ sx: {
408
+ flex: 1
409
+ }
410
+ })),
411
+ /*#__PURE__*/ _jsx(TextField, {
412
+ select: true,
413
+ label: "Style",
414
+ value: (_step_severity = step.severity) != null ? _step_severity : 'info',
415
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
416
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
417
+ severity: event.target.value
418
+ }) : s)
419
+ })),
420
+ size: "small",
421
+ sx: {
422
+ width: 110
423
+ },
424
+ children: [
425
+ 'info',
426
+ 'success',
427
+ 'warning',
428
+ 'error'
429
+ ].map((value)=>/*#__PURE__*/ _jsx(MenuItem, {
430
+ value: value,
431
+ children: value
432
+ }, value))
433
+ })
434
+ ]
435
+ }) : step.type === 'customEvent' ? /*#__PURE__*/ _jsx(TextField, {
436
+ label: "Event name",
437
+ value: step.eventName,
438
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
439
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
440
+ eventName: event.target.value
441
+ }) : s)
442
+ })),
443
+ size: "small",
444
+ sx: {
445
+ flex: 1
446
+ }
447
+ }) : step.type === 'webhookPost' ? /*#__PURE__*/ _jsx(TextField, _extends({
448
+ select: true,
449
+ label: "Webhook"
450
+ }, placeholderReference(step.webhookName, step.webhookId, 'webhook'), {
451
+ value: (_ref1 = (_step_webhookId = step.webhookId) != null ? _step_webhookId : (_webhookOptions_find = webhookOptions.find((option)=>option.name === step.webhookName)) == null ? void 0 : _webhookOptions_find.id) != null ? _ref1 : '',
452
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
453
+ steps: previous.steps.map((s, index2)=>{
454
+ var _ref;
455
+ var _webhookOptions_find;
456
+ return index2 === index ? _extends({}, s, {
457
+ webhookId: event.target.value,
458
+ webhookName: (_ref = (_webhookOptions_find = webhookOptions.find((option)=>option.id === event.target.value)) == null ? void 0 : _webhookOptions_find.name) != null ? _ref : s.webhookName
459
+ }) : s;
460
+ })
461
+ })),
462
+ size: "small",
463
+ sx: {
464
+ flex: 1
465
+ },
466
+ children: webhookOptions.map((option)=>/*#__PURE__*/ _jsx(MenuItem, {
467
+ value: option.id,
468
+ children: option.name
469
+ }, option.id))
470
+ })) : step.type === 'datasetAppend' || step.type === 'updateDataset' ? /*#__PURE__*/ _jsx(TextField, _extends({
471
+ select: true,
472
+ label: "Dataset"
473
+ }, placeholderReference(step.datasetName, step.datasetId, 'dataset'), {
474
+ value: (_ref2 = (_step_datasetId = step.datasetId) != null ? _step_datasetId : (_datasetOptions_find = datasetOptions.find((option)=>option.name === step.datasetName)) == null ? void 0 : _datasetOptions_find.id) != null ? _ref2 : '',
475
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
476
+ steps: previous.steps.map((s, index2)=>{
477
+ var _ref;
478
+ var _datasetOptions_find;
479
+ return index2 === index ? _extends({}, s, {
480
+ datasetId: event.target.value,
481
+ datasetName: (_ref = (_datasetOptions_find = datasetOptions.find((option)=>option.id === event.target.value)) == null ? void 0 : _datasetOptions_find.name) != null ? _ref : s.datasetName
482
+ }) : s;
483
+ })
484
+ })),
485
+ size: "small",
486
+ sx: {
487
+ flex: 1
488
+ },
489
+ children: datasetOptions.map((option)=>/*#__PURE__*/ _jsx(MenuItem, {
490
+ value: option.id,
491
+ children: option.name
492
+ }, option.id))
493
+ })) : step.type === 'showOverlay' ? /*#__PURE__*/ _jsx(TextField, {
494
+ select: true,
495
+ label: "Overlay",
496
+ value: (_step_overlayId = step.overlayId) != null ? _step_overlayId : '',
497
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
498
+ steps: previous.steps.map((s, index2)=>{
499
+ var _ref;
500
+ var _overlayOptions_find;
501
+ return index2 === index ? _extends({}, s, {
502
+ overlayId: event.target.value,
503
+ overlayName: (_ref = (_overlayOptions_find = overlayOptions.find((option)=>option.id === event.target.value)) == null ? void 0 : _overlayOptions_find.name) != null ? _ref : ''
504
+ }) : s;
505
+ })
506
+ })),
507
+ size: "small",
508
+ sx: {
509
+ flex: 1
510
+ },
511
+ children: overlayOptions.map((option)=>/*#__PURE__*/ _jsx(MenuItem, {
512
+ value: option.id,
513
+ children: option.name
514
+ }, option.id))
515
+ }) : step.type === 'stickyNav' ? /*#__PURE__*/ _jsx(TextField, {
516
+ label: "Selector (default: header/nav)",
517
+ value: (_step_selector = step.selector) != null ? _step_selector : '',
518
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
519
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
520
+ selector: event.target.value
521
+ }) : s)
522
+ })),
523
+ size: "small",
524
+ sx: {
525
+ flex: 1
526
+ }
527
+ }) : step.type === 'addClass' || step.type === 'removeClass' || step.type === 'toggleClass' ? /*#__PURE__*/ _jsxs(_Fragment, {
528
+ children: [
529
+ /*#__PURE__*/ _jsx(TextField, {
530
+ label: "CSS selector",
531
+ value: (_step_selector1 = step.selector) != null ? _step_selector1 : '',
532
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
533
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
534
+ selector: event.target.value
535
+ }) : s)
536
+ })),
537
+ size: "small",
538
+ sx: {
539
+ flex: 1
540
+ }
541
+ }),
542
+ /*#__PURE__*/ _jsx(TextField, {
543
+ label: "Class name",
544
+ value: (_step_className = step.className) != null ? _step_className : '',
545
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
546
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
547
+ className: event.target.value
548
+ }) : s)
549
+ })),
550
+ size: "small",
551
+ sx: {
552
+ width: 150
553
+ }
554
+ })
555
+ ]
556
+ }) : step.type === 'showElement' || step.type === 'hideElement' || step.type === 'toggleElement' || step.type === 'playVideo' ? // Element choreography (AGL-562) and Play a video
557
+ // (AGL-2867). The besigner's builder offers an element
558
+ // picker; here the CSS selector is the escape hatch (node
559
+ // targets use [data-aglyn="leaf:…"]).
560
+ /*#__PURE__*/ _jsx(TextField, {
561
+ label: "CSS selector",
562
+ placeholder: '[data-aglyn="leaf:…"] or .my-class',
563
+ value: (_step_selector2 = step.selector) != null ? _step_selector2 : '',
564
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
565
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
566
+ selector: event.target.value
567
+ }) : s)
568
+ })),
569
+ size: "small",
570
+ sx: {
571
+ flex: 1
572
+ }
573
+ }) : step.type === 'scrollTo' ? // Scroll to element (AGL-2867): the target, how the page
574
+ // moves, and the room left above it for a sticky header.
575
+ /*#__PURE__*/ _jsxs(_Fragment, {
576
+ children: [
577
+ /*#__PURE__*/ _jsx(TextField, {
578
+ label: "CSS selector",
579
+ placeholder: '[data-aglyn="leaf:…"] or .my-class',
580
+ value: (_step_selector3 = step.selector) != null ? _step_selector3 : '',
581
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
582
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
583
+ selector: event.target.value
584
+ }) : s)
585
+ })),
586
+ size: "small",
587
+ sx: {
588
+ flex: 1
589
+ }
590
+ }),
591
+ /*#__PURE__*/ _jsxs(TextField, {
592
+ select: true,
593
+ label: "Scroll",
594
+ value: step.behavior === 'instant' ? 'instant' : 'smooth',
595
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
596
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
597
+ behavior: event.target.value === 'instant' ? 'instant' : undefined
598
+ }) : s)
599
+ })),
600
+ size: "small",
601
+ sx: {
602
+ width: 130
603
+ },
604
+ children: [
605
+ /*#__PURE__*/ _jsx(MenuItem, {
606
+ value: "smooth",
607
+ children: 'Smoothly'
608
+ }),
609
+ /*#__PURE__*/ _jsx(MenuItem, {
610
+ value: "instant",
611
+ children: 'Instantly'
612
+ })
613
+ ]
614
+ }),
615
+ /*#__PURE__*/ _jsx(TextField, {
616
+ label: "Offset (px)",
617
+ type: "number",
618
+ value: (_step_offsetPx = step.offsetPx) != null ? _step_offsetPx : '',
619
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
620
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
621
+ offsetPx: event.target.value === '' ? undefined : Number(event.target.value)
622
+ }) : s)
623
+ })),
624
+ size: "small",
625
+ sx: {
626
+ width: 110
627
+ }
628
+ })
629
+ ]
630
+ }) : step.type === 'setAttribute' || step.type === 'removeAttribute' ? // The attribute steps (AGL-2546). The page applies only
631
+ // `aria-*` and `data-*` names, so the field says so while
632
+ // it holds any other, as the interaction builder's does.
633
+ /*#__PURE__*/ _jsxs(_Fragment, {
634
+ children: [
635
+ /*#__PURE__*/ _jsx(TextField, {
636
+ label: "CSS selector",
637
+ placeholder: '[data-aglyn="leaf:…"] or .my-class',
638
+ value: (_step_selector4 = step.selector) != null ? _step_selector4 : '',
639
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
640
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
641
+ selector: event.target.value
642
+ }) : s)
643
+ })),
644
+ size: "small",
645
+ sx: {
646
+ flex: 1
647
+ }
648
+ }),
649
+ /*#__PURE__*/ _jsx(TextField, {
650
+ label: "Attribute",
651
+ placeholder: "aria-expanded",
652
+ value: (_step_name = step.name) != null ? _step_name : '',
653
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
654
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
655
+ name: event.target.value
656
+ }) : s)
657
+ })),
658
+ error: Boolean(step.name) && !isInteractionAttributeAllowed(step.name),
659
+ helperText: Boolean(step.name) && !isInteractionAttributeAllowed(step.name) ? 'Must start with aria- or data-' : undefined,
660
+ size: "small",
661
+ sx: {
662
+ width: 150
663
+ }
664
+ }),
665
+ step.type === 'setAttribute' ? /*#__PURE__*/ _jsx(TextField, {
666
+ label: "Value",
667
+ placeholder: "true",
668
+ value: (_step_value = step.value) != null ? _step_value : '',
669
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
670
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
671
+ value: event.target.value
672
+ }) : s)
673
+ })),
674
+ size: "small",
675
+ sx: {
676
+ width: 110
677
+ }
678
+ }) : null
679
+ ]
680
+ }) : step.type === 'openDrawer' || step.type === 'closeDrawer' || step.type === 'toggleDrawer' ? /*#__PURE__*/ _jsx(TextField, {
681
+ label: "Drawer node id (optional)",
682
+ placeholder: "Empty = the page's first drawer",
683
+ value: (_step_drawerNodeId = step.drawerNodeId) != null ? _step_drawerNodeId : '',
684
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
685
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
686
+ drawerNodeId: event.target.value || undefined
687
+ }) : s)
688
+ })),
689
+ size: "small",
690
+ sx: {
691
+ flex: 1
692
+ }
693
+ }) : step.type === 'openMenu' || step.type === 'closeMenu' || step.type === 'toggleMenu' ? // Menu commands (AGL-568). The besigner's builder offers
694
+ // a menu picker; here the raw node id is the escape
695
+ // hatch, like the drawer field above.
696
+ /*#__PURE__*/ _jsx(TextField, {
697
+ label: "Menu node id (optional)",
698
+ placeholder: "Empty = the page's first menu",
699
+ value: (_step_menuNodeId = step.menuNodeId) != null ? _step_menuNodeId : '',
700
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
701
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
702
+ menuNodeId: event.target.value || undefined
703
+ }) : s)
704
+ })),
705
+ size: "small",
706
+ sx: {
707
+ flex: 1
708
+ }
709
+ }) : step.type === 'showHtml' || step.type === 'runJs' ? /*#__PURE__*/ _jsx(TextField, {
710
+ label: step.type === 'showHtml' ? 'HTML' : 'JavaScript',
711
+ value: step.type === 'showHtml' ? (_step_html = step.html) != null ? _step_html : '' : (_step_code = step.code) != null ? _step_code : '',
712
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
713
+ steps: previous.steps.map((s, index2)=>index2 === index ? step.type === 'showHtml' ? _extends({}, s, {
714
+ html: event.target.value
715
+ }) : _extends({}, s, {
716
+ code: event.target.value
717
+ }) : s)
718
+ })),
719
+ size: "small",
720
+ multiline: true,
721
+ maxRows: 4,
722
+ sx: {
723
+ flex: 1
724
+ }
725
+ }) : step.type === 'redirect' ? /*#__PURE__*/ _jsx(TextField, {
726
+ label: "Destination URL",
727
+ value: (_step_url = step.url) != null ? _step_url : '',
728
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
729
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
730
+ url: event.target.value
731
+ }) : s)
732
+ })),
733
+ size: "small",
734
+ sx: {
735
+ flex: 1
736
+ }
737
+ }) : step.type === 'trackGaEvent' ? /*#__PURE__*/ _jsx(TextField, {
738
+ label: "Analytics event name",
739
+ value: (_step_eventName = step.eventName) != null ? _step_eventName : '',
740
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
741
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
742
+ eventName: event.target.value
743
+ }) : s)
744
+ })),
745
+ size: "small",
746
+ sx: {
747
+ flex: 1
748
+ }
749
+ }) : step.type === 'sendEmail' ? /*#__PURE__*/ _jsxs(_Fragment, {
750
+ children: [
751
+ /*#__PURE__*/ _jsx(TextField, _extends({
752
+ label: "Subject"
753
+ }, placeholderState(step.subject, 'Fill in the placeholder'), {
754
+ value: (_step_subject = step.subject) != null ? _step_subject : '',
755
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
756
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
757
+ subject: event.target.value
758
+ }) : s)
759
+ })),
760
+ size: "small",
761
+ sx: {
762
+ width: 180
763
+ }
764
+ })),
765
+ /*#__PURE__*/ _jsx(TextField, _extends({
766
+ label: "Body"
767
+ }, placeholderState(step.body, 'Fill in the placeholders'), {
768
+ value: (_step_body = step.body) != null ? _step_body : '',
769
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
770
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
771
+ body: event.target.value
772
+ }) : s)
773
+ })),
774
+ size: "small",
775
+ multiline: true,
776
+ maxRows: 3,
777
+ sx: {
778
+ flex: 1
779
+ }
780
+ }))
781
+ ]
782
+ }) : step.type === 'notifyAdmins' ? /*#__PURE__*/ _jsx(TextField, _extends({
783
+ label: "Notification title"
784
+ }, placeholderState(step.title, 'Fill in the placeholder'), {
785
+ value: (_step_title = step.title) != null ? _step_title : '',
786
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
787
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
788
+ title: event.target.value
789
+ }) : s)
790
+ })),
791
+ size: "small",
792
+ sx: {
793
+ flex: 1
794
+ }
795
+ })) : step.type === 'enrollList' ? /*#__PURE__*/ _jsxs(TextField, _extends({
796
+ select: true,
797
+ label: "List"
798
+ }, placeholderReference(step.listName, step.listId, 'list'), {
799
+ value: (_step_listId = step.listId) != null ? _step_listId : '',
800
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
801
+ steps: previous.steps.map((s, index2)=>{
802
+ var _ref;
803
+ var _listOptions_find;
804
+ return index2 === index ? _extends({}, s, {
805
+ listId: event.target.value,
806
+ listName: (_ref = (_listOptions_find = listOptions.find((option)=>option.id === event.target.value)) == null ? void 0 : _listOptions_find.name) != null ? _ref : ''
807
+ }) : s;
808
+ })
809
+ })),
810
+ size: "small",
811
+ sx: {
812
+ flex: 1
813
+ },
814
+ children: [
815
+ listOptions.length === 0 ? /*#__PURE__*/ _jsx(MenuItem, {
816
+ value: "",
817
+ disabled: true,
818
+ children: 'No lists yet — create one under Campaigns'
819
+ }) : null,
820
+ listOptions.map((option)=>/*#__PURE__*/ _jsx(MenuItem, {
821
+ value: option.id,
822
+ children: option.name
823
+ }, option.id))
824
+ ]
825
+ })) : step.type === 'assignCampaign' ? /*#__PURE__*/ _jsxs(TextField, _extends({
826
+ select: true,
827
+ label: "Campaign"
828
+ }, placeholderReference(step.campaignName, step.campaignId, 'campaign'), {
829
+ value: (_step_campaignId = step.campaignId) != null ? _step_campaignId : '',
830
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
831
+ steps: previous.steps.map((s, index2)=>{
832
+ var _ref;
833
+ var _campaignOptions_find;
834
+ return index2 === index ? _extends({}, s, {
835
+ campaignId: event.target.value,
836
+ campaignName: (_ref = (_campaignOptions_find = campaignOptions.find((option)=>option.id === event.target.value)) == null ? void 0 : _campaignOptions_find.name) != null ? _ref : ''
837
+ }) : s;
838
+ })
839
+ })),
840
+ size: "small",
841
+ sx: {
842
+ flex: 1
843
+ },
844
+ children: [
845
+ campaignOptions.length === 0 ? /*#__PURE__*/ _jsx(MenuItem, {
846
+ value: "",
847
+ disabled: true,
848
+ children: 'No campaigns yet'
849
+ }) : null,
850
+ campaignOptions.map((option)=>/*#__PURE__*/ _jsx(MenuItem, {
851
+ value: option.id,
852
+ children: option.name
853
+ }, option.id))
854
+ ]
855
+ })) : step.type === 'setContactStage' ? // The CRM steps (AGL-2605). Each acts on the contact the
856
+ // event names — by id when the door knew it, by the email
857
+ // in the payload otherwise — so none of them asks who.
858
+ /*#__PURE__*/ _jsx(TextField, {
859
+ select: true,
860
+ label: "Stage",
861
+ value: (_step_lifecycleStage = step.lifecycleStage) != null ? _step_lifecycleStage : '',
862
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
863
+ steps: previous.steps.map((s, index2)=>index2 === index && s.type === 'setContactStage' ? _extends({}, s, {
864
+ lifecycleStage: event.target.value
865
+ }) : s)
866
+ })),
867
+ size: "small",
868
+ sx: {
869
+ minWidth: 200
870
+ },
871
+ children: CONTACT_LIFECYCLE_STAGES.map((stage)=>/*#__PURE__*/ _jsx(MenuItem, {
872
+ value: stage,
873
+ children: CONTACT_LIFECYCLE_STAGE_LABELS[stage]
874
+ }, stage))
875
+ }) : step.type === 'addContactTag' ? /*#__PURE__*/ _jsx(TextField, _extends({
876
+ label: "Tag"
877
+ }, placeholderState(step.tag, 'Fill in the placeholder'), {
878
+ value: (_step_tag = step.tag) != null ? _step_tag : '',
879
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
880
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
881
+ tag: event.target.value.slice(0, CONTACT_TAG_MAX_LENGTH)
882
+ }) : s)
883
+ })),
884
+ size: "small",
885
+ sx: {
886
+ flex: 1
887
+ }
888
+ })) : step.type === 'assignContactOwner' ? // Two modes (AGL-2618): a member the author names, or the
889
+ // next member of the round-robin pool the CRM's Settings
890
+ // keep. Switching to the rotation drops the named member,
891
+ // because the validator refuses a step that says both.
892
+ /*#__PURE__*/ _jsxs(_Fragment, {
893
+ children: [
894
+ /*#__PURE__*/ _jsxs(TextField, {
895
+ select: true,
896
+ label: "Assign to",
897
+ value: step.roundRobin === true ? 'roundRobin' : 'member',
898
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
899
+ steps: previous.steps.map((s, index2)=>index2 === index && s.type === 'assignContactOwner' ? event.target.value === 'roundRobin' ? {
900
+ type: s.type,
901
+ roundRobin: true
902
+ } : {
903
+ type: s.type,
904
+ ownerEmail: ''
905
+ } : s)
906
+ })),
907
+ size: "small",
908
+ sx: {
909
+ minWidth: 200
910
+ },
911
+ children: [
912
+ /*#__PURE__*/ _jsx(MenuItem, {
913
+ value: "member",
914
+ children: 'A team member'
915
+ }),
916
+ /*#__PURE__*/ _jsx(MenuItem, {
917
+ value: "roundRobin",
918
+ children: 'Round robin — the next member of the CRM’s pool'
919
+ })
920
+ ]
921
+ }),
922
+ step.roundRobin === true ? /*#__PURE__*/ _jsx(Typography, {
923
+ variant: "caption",
924
+ color: "text.secondary",
925
+ children: 'The pool is set under CRM → Settings; an empty pool is a failed step.'
926
+ }) : /*#__PURE__*/ _jsxs(_Fragment, {
927
+ children: [
928
+ /*#__PURE__*/ _jsx(TextField, {
929
+ label: "Owner (email address or member id)",
930
+ value: step.ownerEmail || step.ownerUid || '',
931
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
932
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, memberRefFields('owner', event.target.value)) : s)
933
+ })),
934
+ size: "small",
935
+ sx: {
936
+ flex: 1
937
+ }
938
+ }),
939
+ /*#__PURE__*/ _jsx(Typography, {
940
+ variant: "caption",
941
+ color: "text.secondary",
942
+ children: 'Somebody on your team, matched against the roster when the automation runs.'
943
+ })
944
+ ]
945
+ })
946
+ ]
947
+ }) : step.type === 'createCrmTask' ? /*#__PURE__*/ _jsxs(_Fragment, {
948
+ children: [
949
+ /*#__PURE__*/ _jsx(TextField, _extends({
950
+ label: "Title"
951
+ }, placeholderState(step.title, 'Fill in the placeholder'), {
952
+ value: (_step_title1 = step.title) != null ? _step_title1 : '',
953
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
954
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
955
+ title: event.target.value
956
+ }) : s)
957
+ })),
958
+ size: "small",
959
+ sx: {
960
+ flex: 1
961
+ }
962
+ })),
963
+ /*#__PURE__*/ _jsx(TextField, {
964
+ select: true,
965
+ label: "Kind",
966
+ value: (_step_kind = step.kind) != null ? _step_kind : '',
967
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
968
+ steps: previous.steps.map((s, index2)=>index2 === index && s.type === 'createCrmTask' ? _extends({}, s, {
969
+ kind: event.target.value
970
+ }) : s)
971
+ })),
972
+ size: "small",
973
+ sx: {
974
+ minWidth: 120
975
+ },
976
+ children: CRM_TASK_KINDS.map((kind)=>/*#__PURE__*/ _jsx(MenuItem, {
977
+ value: kind,
978
+ children: CRM_TASK_KIND_LABELS[kind]
979
+ }, kind))
980
+ }),
981
+ /*#__PURE__*/ _jsx(TextField, {
982
+ type: "number",
983
+ label: "Due in (days)",
984
+ value: (_step_dueInDays = step.dueInDays) != null ? _step_dueInDays : '',
985
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
986
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
987
+ dueInDays: Math.min(CRM_TASK_MAX_DUE_DAYS, Math.max(0, Number(event.target.value)))
988
+ }) : s)
989
+ })),
990
+ size: "small",
991
+ sx: {
992
+ width: 130
993
+ }
994
+ }),
995
+ /*#__PURE__*/ _jsx(TextField, {
996
+ label: "Assignee (email address or member id, optional)",
997
+ value: step.assigneeEmail || step.assigneeUid || '',
998
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
999
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, memberRefFields('assignee', event.target.value)) : s)
1000
+ })),
1001
+ size: "small",
1002
+ sx: {
1003
+ flex: 1
1004
+ },
1005
+ helperText: "Blank gives it to the contact’s owner."
1006
+ })
1007
+ ]
1008
+ }) : step.type === 'logCrmActivity' ? /*#__PURE__*/ _jsxs(_Fragment, {
1009
+ children: [
1010
+ /*#__PURE__*/ _jsx(TextField, {
1011
+ select: true,
1012
+ label: "Kind",
1013
+ value: (_step_kind1 = step.kind) != null ? _step_kind1 : '',
1014
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
1015
+ steps: previous.steps.map((s, index2)=>index2 === index && s.type === 'logCrmActivity' ? _extends({}, s, {
1016
+ kind: event.target.value
1017
+ }) : s)
1018
+ })),
1019
+ size: "small",
1020
+ sx: {
1021
+ minWidth: 120
1022
+ },
1023
+ children: CRM_ACTIVITY_KINDS.map((kind)=>/*#__PURE__*/ _jsx(MenuItem, {
1024
+ value: kind,
1025
+ children: CRM_ACTIVITY_KIND_LABELS[kind]
1026
+ }, kind))
1027
+ }),
1028
+ /*#__PURE__*/ _jsx(TextField, _extends({
1029
+ label: "What happened"
1030
+ }, placeholderState(step.body, 'Fill in the placeholders'), {
1031
+ value: (_step_body1 = step.body) != null ? _step_body1 : '',
1032
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
1033
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
1034
+ body: event.target.value
1035
+ }) : s)
1036
+ })),
1037
+ size: "small",
1038
+ multiline: true,
1039
+ maxRows: 3,
1040
+ sx: {
1041
+ flex: 1
1042
+ }
1043
+ }))
1044
+ ]
1045
+ }) : step.type === 'wait' || step.type === 'waitForEvent' ? /*#__PURE__*/ _jsxs(_Fragment, {
1046
+ children: [
1047
+ step.type === 'waitForEvent' ? /*#__PURE__*/ _jsx(TextField, {
1048
+ select: true,
1049
+ label: "Until",
1050
+ value: (_step_eventName1 = step.eventName) != null ? _step_eventName1 : '',
1051
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
1052
+ steps: previous.steps.map((s, index2)=>index2 === index ? _extends({}, s, {
1053
+ eventName: event.target.value
1054
+ }) : s)
1055
+ })),
1056
+ size: "small",
1057
+ sx: {
1058
+ minWidth: 170
1059
+ },
1060
+ children: HOST_EVENT_TYPES.map((option)=>/*#__PURE__*/ _jsx(MenuItem, {
1061
+ value: option,
1062
+ children: hostEventLabel(option)
1063
+ }, option))
1064
+ }) : null,
1065
+ /*#__PURE__*/ _jsx(TextField, {
1066
+ select: true,
1067
+ label: step.type === 'waitForEvent' ? 'Give up after' : 'Wait for',
1068
+ value: String(step.type === 'waitForEvent' ? (_step_timeoutMinutes = step.timeoutMinutes) != null ? _step_timeoutMinutes : '' : (_step_delayMinutes = step.delayMinutes) != null ? _step_delayMinutes : ''),
1069
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
1070
+ steps: previous.steps.map((s, index2)=>index2 === index ? s.type === 'waitForEvent' ? _extends({}, s, {
1071
+ timeoutMinutes: Number(event.target.value)
1072
+ }) : _extends({}, s, {
1073
+ delayMinutes: Number(event.target.value)
1074
+ }) : s)
1075
+ })),
1076
+ size: "small",
1077
+ sx: {
1078
+ minWidth: 150
1079
+ },
1080
+ children: FLOW_WAIT_PRESETS.map((option)=>/*#__PURE__*/ _jsx(MenuItem, {
1081
+ value: option.minutes,
1082
+ children: option.label
1083
+ }, option.minutes))
1084
+ }),
1085
+ /*#__PURE__*/ _jsx(Typography, {
1086
+ variant: "caption",
1087
+ color: "text.secondary",
1088
+ children: step.type === 'waitForEvent' ? 'Continues as soon as this happens, or when the time is up.' : 'The rest of this automation runs later, on its own.'
1089
+ })
1090
+ ]
1091
+ }) : step.type === 'exitFlow' ? /*#__PURE__*/ _jsx(Typography, {
1092
+ variant: "caption",
1093
+ color: "text.secondary",
1094
+ children: 'Nothing after this step runs. Add a condition to make it a branch.'
1095
+ }) : null,
1096
+ /*#__PURE__*/ _jsx(IconButton, {
1097
+ size: "small",
1098
+ "aria-label": "remove step",
1099
+ onClick: ()=>patch((previous)=>_extends({}, previous, {
1100
+ steps: previous.steps.filter((_, index2)=>index2 !== index)
1101
+ })),
1102
+ children: '×'
1103
+ })
1104
+ ]
1105
+ }),
1106
+ fields ? null : /*#__PURE__*/ _jsxs(Stack, {
1107
+ direction: "row",
1108
+ spacing: 1,
1109
+ sx: {
1110
+ alignItems: 'center',
1111
+ pl: 3
1112
+ },
1113
+ children: [
1114
+ /*#__PURE__*/ _jsxs(TextField, {
1115
+ select: true,
1116
+ label: "Only if",
1117
+ value: (_ref3 = (_step_when = step.when) == null ? void 0 : (_step_when_conditions = _step_when.conditions) == null ? void 0 : (_step_when_conditions_ = _step_when_conditions[0]) == null ? void 0 : _step_when_conditions_.op) != null ? _ref3 : '',
1118
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
1119
+ steps: previous.steps.map((s, index2)=>{
1120
+ var _ref, _ref1;
1121
+ var _s_when_conditions_, _s_when_conditions, _s_when, _s_when_conditions_1, _s_when_conditions1, _s_when1;
1122
+ return index2 === index ? _extends({}, s, {
1123
+ when: event.target.value ? {
1124
+ conditions: [
1125
+ {
1126
+ op: event.target.value,
1127
+ field: (_ref = (_s_when = s.when) == null ? void 0 : (_s_when_conditions = _s_when.conditions) == null ? void 0 : (_s_when_conditions_ = _s_when_conditions[0]) == null ? void 0 : _s_when_conditions_.field) != null ? _ref : '',
1128
+ value: (_ref1 = (_s_when1 = s.when) == null ? void 0 : (_s_when_conditions1 = _s_when1.conditions) == null ? void 0 : (_s_when_conditions_1 = _s_when_conditions1[0]) == null ? void 0 : _s_when_conditions_1.value) != null ? _ref1 : ''
1129
+ }
1130
+ ]
1131
+ } : null
1132
+ }) : s;
1133
+ })
1134
+ })),
1135
+ size: "small",
1136
+ sx: {
1137
+ minWidth: 170
1138
+ },
1139
+ children: [
1140
+ /*#__PURE__*/ _jsx(MenuItem, {
1141
+ value: "",
1142
+ children: 'Always run'
1143
+ }),
1144
+ /*#__PURE__*/ _jsx(MenuItem, {
1145
+ value: "notEmpty",
1146
+ children: 'Field is not empty'
1147
+ }),
1148
+ /*#__PURE__*/ _jsx(MenuItem, {
1149
+ value: "equals",
1150
+ children: 'Field equals'
1151
+ }),
1152
+ /*#__PURE__*/ _jsx(MenuItem, {
1153
+ value: "contains",
1154
+ children: 'Field contains'
1155
+ })
1156
+ ]
1157
+ }),
1158
+ ((_step_when1 = step.when) == null ? void 0 : (_step_when_conditions1 = _step_when1.conditions) == null ? void 0 : (_step_when_conditions_1 = _step_when_conditions1[0]) == null ? void 0 : _step_when_conditions_1.op) ? /*#__PURE__*/ _jsx(TextField, {
1159
+ label: "Field",
1160
+ placeholder: "orderId",
1161
+ value: (_step_when_conditions__field = step.when.conditions[0].field) != null ? _step_when_conditions__field : '',
1162
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
1163
+ steps: previous.steps.map((s, index2)=>{
1164
+ var _s_when_conditions, _s_when;
1165
+ return index2 === index && ((_s_when = s.when) == null ? void 0 : (_s_when_conditions = _s_when.conditions) == null ? void 0 : _s_when_conditions[0]) ? _extends({}, s, {
1166
+ when: {
1167
+ conditions: [
1168
+ _extends({}, s.when.conditions[0], {
1169
+ field: event.target.value
1170
+ })
1171
+ ]
1172
+ }
1173
+ }) : s;
1174
+ })
1175
+ })),
1176
+ size: "small",
1177
+ sx: {
1178
+ flex: 1
1179
+ }
1180
+ }) : null,
1181
+ ((_step_when2 = step.when) == null ? void 0 : (_step_when_conditions2 = _step_when2.conditions) == null ? void 0 : (_step_when_conditions_2 = _step_when_conditions2[0]) == null ? void 0 : _step_when_conditions_2.op) === 'equals' || ((_step_when3 = step.when) == null ? void 0 : (_step_when_conditions3 = _step_when3.conditions) == null ? void 0 : (_step_when_conditions_3 = _step_when_conditions3[0]) == null ? void 0 : _step_when_conditions_3.op) === 'contains' ? /*#__PURE__*/ _jsx(TextField, _extends({
1182
+ label: "Value"
1183
+ }, placeholderState(step.when.conditions[0].value, 'Replace the placeholder with the value to match'), {
1184
+ value: (_step_when_conditions__value = step.when.conditions[0].value) != null ? _step_when_conditions__value : '',
1185
+ onChange: (event)=>patch((previous)=>_extends({}, previous, {
1186
+ steps: previous.steps.map((s, index2)=>{
1187
+ var _s_when_conditions, _s_when;
1188
+ return index2 === index && ((_s_when = s.when) == null ? void 0 : (_s_when_conditions = _s_when.conditions) == null ? void 0 : _s_when_conditions[0]) ? _extends({}, s, {
1189
+ when: {
1190
+ conditions: [
1191
+ _extends({}, s.when.conditions[0], {
1192
+ value: event.target.value
1193
+ })
1194
+ ]
1195
+ }
1196
+ }) : s;
1197
+ })
1198
+ })),
1199
+ size: "small",
1200
+ sx: {
1201
+ flex: 1
1202
+ }
1203
+ })) : null
1204
+ ]
1205
+ })
1206
+ ]
1207
+ });
1208
+ }
1209
+
1210
+ //# sourceMappingURL=automation-step-fields.component.js.map