@digiform/wizard 0.3.1 → 0.3.2

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 (43) hide show
  1. package/features/form-runtime/components/FormFooter.d.ts +5 -0
  2. package/features/form-runtime/hooks/useValidationEvents.d.ts +0 -1
  3. package/features/state-management/machines/formMachine.d.ts +3 -0
  4. package/features/state-management/machines/types.d.ts +4 -0
  5. package/features/state-management/machines/useFormMachine.d.ts +18 -0
  6. package/package.json +1 -3
  7. package/styles.css +1 -1
  8. package/wizard/src/features/api-integration/services/ApiCallService.js +65 -74
  9. package/wizard/src/features/dialog-system/components/ActionDialog/ActionDialog.js +39 -43
  10. package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.js +37 -41
  11. package/wizard/src/features/dialog-system/components/EmailVerificationDialog/EmailVerificationDialog.js +44 -45
  12. package/wizard/src/features/form-runtime/FormWizard/FormWizard.js +54 -79
  13. package/wizard/src/features/form-runtime/components/FormFooter.js +53 -184
  14. package/wizard/src/features/form-runtime/components/FormSection/FormSection.js +150 -194
  15. package/wizard/src/features/form-runtime/components/FormStep/FormStep.js +83 -92
  16. package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +24 -30
  17. package/wizard/src/features/form-runtime/config/templateLoader.js +48 -55
  18. package/wizard/src/features/form-runtime/hooks/useComponentTriggers.js +44 -63
  19. package/wizard/src/features/form-runtime/hooks/useFieldEventHandlers.js +26 -40
  20. package/wizard/src/features/form-runtime/hooks/useValidationEvents.js +22 -25
  21. package/wizard/src/features/form-runtime/utils/formDirtyStateSync.js +26 -37
  22. package/wizard/src/features/form-runtime/utils/logger.js +12 -12
  23. package/wizard/src/features/state-management/machines/actions/navigationActions.js +13 -8
  24. package/wizard/src/features/state-management/machines/componentTriggerEngine.js +167 -432
  25. package/wizard/src/features/state-management/machines/formMachine.js +558 -677
  26. package/wizard/src/features/state-management/machines/useFormMachine.js +172 -190
  27. package/wizard/src/features/trigger-action-system/components/ActionManager.js +35 -86
  28. package/wizard/src/features/validation-system/validation/SchemaBuilder.js +28 -82
  29. package/wizard/src/features/validation-system/validation/ValidationCache.js +11 -27
  30. package/wizard/src/features/validation-system/validation/ValidationExecutor.js +26 -58
  31. package/features/form-runtime/utils/formSaver.d.ts +0 -22
  32. package/features/state-management/components/ValidationBuilder/ValidationBuilder.d.ts +0 -9
  33. package/features/state-management/machines/__tests__/setup.d.ts +0 -0
  34. package/features/state-management/machines/__tests__/vitest.config.d.ts +0 -2
  35. package/features/state-management/machines/actions/validationActions.d.ts +0 -68
  36. package/features/state-management/machines/lazyLoading.d.ts +0 -34
  37. package/features/state-management/machines/validation/index.d.ts +0 -5
  38. package/features/state-management/machines/validation/validateField.d.ts +0 -2
  39. package/features/state-management/machines/validation/validateForm.d.ts +0 -2
  40. package/features/state-management/machines/validation/validateSection.d.ts +0 -2
  41. package/features/state-management/machines/validation/validateStep.d.ts +0 -2
  42. package/features/state-management/machines/validation/validationTypes.d.ts +0 -1
  43. package/features/trigger-action-system/components/FieldWarning/FieldWarning.d.ts +0 -20
@@ -1,56 +1,56 @@
1
1
  "use client";
2
- import { createMachine as I, assign as a } from "xstate";
3
- import { executeComponentAction as p } from "./actions/componentActions.js";
4
- import { executePendingNavigation as f } from "./actions/navigationActions.js";
5
- import { executeSaveActions as m } from "./actions/saveActions.js";
6
- import { ComponentTriggerEngine as u } from "./componentTriggerEngine.js";
7
- import { canNavigate as d, isPendingNextNavigation as S, isPendingPreviousNavigation as A, isPendingStepNavigation as T, hasSaveContextActions as E, shouldProceedWithNormalNavigation as O, hasSaveTriggersForNext as N } from "./guards/navigationGuards.js";
8
- import { isSectionEditable as _, canExecuteSaveActions as C } from "./guards/saveGuards.js";
9
- import { hasDirtyComponentsWithTriggers as v } from "./guards/triggerGuards.js";
2
+ import { createMachine as I, assign as i } from "xstate";
3
+ import { executeComponentAction as d } from "./actions/componentActions.js";
4
+ import { executePendingNavigation as S } from "./actions/navigationActions.js";
5
+ import { executeSaveActions as f } from "./actions/saveActions.js";
6
+ import { ComponentTriggerEngine as l } from "./componentTriggerEngine.js";
7
+ import { canNavigate as c, isPendingNextNavigation as m, isPendingPreviousNavigation as A, isPendingStepNavigation as T, hasSaveContextActions as E, shouldProceedWithNormalNavigation as N, hasSaveTriggersForNext as O } from "./guards/navigationGuards.js";
8
+ import { isSectionEditable as v, canExecuteSaveActions as _ } from "./guards/saveGuards.js";
9
+ import { hasDirtyComponentsWithTriggers as C } from "./guards/triggerGuards.js";
10
10
  import { findComponentTriggers as V } from "./helpers/triggerHelpers.js";
11
- import { memoryUtils as h } from "./performance.js";
12
- const W = I({
11
+ import { memoryUtils as R } from "./performance.js";
12
+ const x = I({
13
13
  id: "formMachine",
14
14
  types: {},
15
- context: ({ input: e }) => ({
16
- config: e.config || { id: "", title: "", steps: [] },
17
- currentStepId: e.currentStepId || "",
18
- currentStepIndex: e.currentStepIndex || 0,
19
- data: e.data || {},
20
- errors: e.errors || {},
21
- dirtyFields: e.dirtyFields || {},
22
- touchedFields: e.touchedFields || {},
23
- isValid: e.isValid ?? !0,
24
- isSubmitting: e.isSubmitting ?? !1,
25
- fieldStates: e.fieldStates || {},
26
- sectionBackups: e.sectionBackups || {},
27
- activeActions: e.activeActions || {},
28
- actionResults: e.actionResults || {},
29
- activeDialog: e.activeDialog || null,
30
- executingTrigger: e.executingTrigger || null,
31
- pendingNavigation: e.pendingNavigation || null,
32
- canNavigate: e.canNavigate ?? !0,
33
- waitingForActions: e.waitingForActions ?? !1,
15
+ context: ({ input: t }) => ({
16
+ config: t.config || { id: "", title: "", steps: [] },
17
+ currentStepId: t.currentStepId || "",
18
+ currentStepIndex: t.currentStepIndex || 0,
19
+ data: t.data || {},
20
+ errors: t.errors || {},
21
+ dirtyFields: t.dirtyFields || {},
22
+ touchedFields: t.touchedFields || {},
23
+ isValid: t.isValid ?? !0,
24
+ isSubmitting: t.isSubmitting ?? !1,
25
+ fieldStates: t.fieldStates || {},
26
+ sectionBackups: t.sectionBackups || {},
27
+ activeActions: t.activeActions || {},
28
+ actionResults: t.actionResults || {},
29
+ activeDialog: t.activeDialog || null,
30
+ executingTrigger: t.executingTrigger || null,
31
+ pendingNavigation: t.pendingNavigation || null,
32
+ canNavigate: t.canNavigate ?? !0,
33
+ waitingForActions: t.waitingForActions ?? !1,
34
34
  // Initialize field change validation state
35
- fieldChangeState: e.fieldChangeState || {},
36
- fieldValidationState: e.fieldValidationState || {
35
+ fieldChangeState: t.fieldChangeState || {},
36
+ fieldValidationState: t.fieldValidationState || {
37
37
  activeWarnings: [],
38
38
  pendingVerifications: [],
39
39
  verificationResults: {}
40
40
  },
41
41
  // Initialize component trigger-action system state
42
- componentTriggerState: e.componentTriggerState || {},
43
- activeComponentActions: e.activeComponentActions || {},
44
- componentAlerts: e.componentAlerts || {},
42
+ componentTriggerState: t.componentTriggerState || {},
43
+ activeComponentActions: t.activeComponentActions || {},
44
+ componentAlerts: t.componentAlerts || {},
45
45
  // Enhanced original value tracking
46
- componentOriginalValues: e.componentOriginalValues || {},
46
+ componentOriginalValues: t.componentOriginalValues || {},
47
47
  // New simplified state machine context
48
- activeExecutionPlan: e.activeExecutionPlan || null,
49
- executionResults: e.executionResults || {},
48
+ activeExecutionPlan: t.activeExecutionPlan || null,
49
+ executionResults: t.executionResults || {},
50
50
  // Track completed context actions
51
- contextActionCompletions: e.contextActionCompletions || {},
51
+ contextActionCompletions: t.contextActionCompletions || {},
52
52
  // Initialize enhanced save state tracking
53
- saveState: e.saveState || {
53
+ saveState: t.saveState || {
54
54
  saveInProgress: !1,
55
55
  saveInitiator: null,
56
56
  savingSection: null,
@@ -59,82 +59,41 @@ const W = I({
59
59
  completedVerifications: [],
60
60
  validationErrors: {},
61
61
  saveStartTimestamp: null
62
- }
62
+ },
63
+ forcedValidationFields: t.forcedValidationFields || []
63
64
  }),
64
65
  initial: "idle",
65
66
  // Global events that should work in any state
66
67
  on: {
68
+ TRIGGER_STEP_VALIDATION: {
69
+ actions: i({
70
+ forcedValidationFields: ({ event: t }) => t.fieldIds
71
+ })
72
+ },
67
73
  EVALUATE_COMPONENT_TRIGGERS: {
68
74
  actions: [
69
75
  // Create execution plan for fieldChange context and execute if needed
70
- ({ context: e, event: t, self: n }) => {
71
- if (t.type !== "EVALUATE_COMPONENT_TRIGGERS")
76
+ ({ context: t, event: e, self: n }) => {
77
+ if (e.type !== "EVALUATE_COMPONENT_TRIGGERS")
72
78
  return;
73
- const { componentId: i, value: o } = t, r = e.componentOriginalValues[i], s = !!(r?.isPopulated && r.value !== o);
74
- console.log(
75
- `🔥 [formMachine] EVALUATE_COMPONENT_TRIGGERS for ${i}:`,
76
- {
77
- value: o,
78
- originalValue: r?.value,
79
- isPopulated: r?.isPopulated,
80
- isDirty: s,
81
- hasAlerts: !!e.componentAlerts[i]?.length
82
- }
83
- ), console.log(
84
- `🔍 [formMachine] Checking alert dismissal condition for ${i}:`,
85
- {
86
- isDirty: s,
87
- hasAlerts: !!e.componentAlerts[i]?.length,
88
- alertsCount: e.componentAlerts[i]?.length,
89
- allComponentAlerts: Object.keys(e.componentAlerts),
90
- alertsForComponent: e.componentAlerts[i],
91
- conditionMet: !s && e.componentAlerts[i]?.length
92
- }
93
- ), !s && e.componentAlerts[i]?.length && (console.log(
94
- `🧹 [formMachine] Clearing alerts for ${i} - field no longer dirty`
95
- ), console.log(
96
- `🧹 [formMachine] Sending DISMISS_COMPONENT_ALERT for ${i}`,
97
- {
98
- alertsCount: e.componentAlerts[i]?.length,
99
- currentState: "about to send"
100
- }
101
- ), n.send({
79
+ const { componentId: a, value: o } = e, r = t.componentOriginalValues[a];
80
+ !(r?.isPopulated && r.value !== o) && t.componentAlerts[a]?.length && n.send({
102
81
  type: "DISMISS_COMPONENT_ALERT",
103
- componentId: i
104
- }), console.log(
105
- `🧹 [formMachine] DISMISS_COMPONENT_ALERT sent for ${i}`
106
- ));
107
- const g = u.createExecutionPlan(
108
- e.config,
82
+ componentId: a
83
+ });
84
+ const p = l.createExecutionPlan(
85
+ t.config,
109
86
  "fieldChange",
110
- e.currentStepIndex,
111
- e
87
+ t.currentStepIndex,
88
+ t
112
89
  );
113
- console.log(
114
- `🎯 [formMachine] FieldChange execution plan for ${i}:`,
115
- {
116
- totalActions: g.totalActions,
117
- executionsCount: g.executions.length,
118
- executions: g.executions.map((c) => ({
119
- componentId: c.componentId,
120
- triggerId: c.trigger.id,
121
- actionsCount: c.actions.length,
122
- actions: c.actions.map((l) => ({
123
- id: l.id,
124
- type: l.type,
125
- contexts: l.contexts
126
- }))
127
- }))
128
- }
129
- ), g.totalActions > 0 && g.executions.forEach((c) => {
130
- c.actions.forEach((l) => {
131
- console.log(
132
- `⚡ [formMachine] Executing fieldChange action ${l.id} for ${c.componentId}`
133
- ), n.send({
90
+ p.totalActions > 0 && p.executions.forEach((g) => {
91
+ g.actions.forEach((u) => {
92
+ n.send({
134
93
  type: "TRIGGER_COMPONENT_ACTION",
135
- componentId: c.componentId,
136
- triggerId: c.trigger.id,
137
- actionId: l.id,
94
+ componentId: g.componentId,
95
+ triggerId: g.trigger.id,
96
+ actionId: u.id,
138
97
  eventType: "valueChange"
139
98
  });
140
99
  });
@@ -143,55 +102,47 @@ const W = I({
143
102
  ]
144
103
  },
145
104
  SET_COMPONENT_ORIGINAL_VALUE: {
146
- actions: a({
147
- componentOriginalValues: ({ context: e, event: t }) => ({
148
- ...e.componentOriginalValues,
149
- [t.componentId]: {
150
- value: t.value,
105
+ actions: i({
106
+ componentOriginalValues: ({ context: t, event: e }) => ({
107
+ ...t.componentOriginalValues,
108
+ [e.componentId]: {
109
+ value: e.value,
151
110
  timestamp: Date.now(),
152
- source: t.source || "initialized",
153
- isPopulated: t.source !== "initialized"
111
+ source: e.source || "initialized",
112
+ isPopulated: e.source !== "initialized"
154
113
  }
155
114
  }),
156
- componentTriggerState: ({ context: e, event: t }) => {
115
+ componentTriggerState: ({ context: t, event: e }) => {
157
116
  const n = V(
158
- e.config,
159
- t.componentId
160
- ), i = { ...e.componentTriggerState };
117
+ t.config,
118
+ e.componentId
119
+ ), a = { ...t.componentTriggerState };
161
120
  return n.forEach((o) => {
162
- const r = `${t.componentId}-${o.id}`;
163
- i[r] ? i[r].originalValue === void 0 && (i[r] = {
164
- ...i[r],
165
- originalValue: t.value
166
- }) : i[r] = {
167
- componentId: t.componentId,
121
+ const r = `${e.componentId}-${o.id}`;
122
+ a[r] ? a[r].originalValue === void 0 && (a[r] = {
123
+ ...a[r],
124
+ originalValue: e.value
125
+ }) : a[r] = {
126
+ componentId: e.componentId,
168
127
  triggerId: o.id,
169
128
  isActive: !1,
170
- originalValue: t.value,
129
+ originalValue: e.value,
171
130
  lastEvaluated: Date.now()
172
131
  };
173
- }), i;
132
+ }), a;
174
133
  }
175
134
  })
176
135
  },
177
136
  MARK_COMPONENT_AS_POPULATED: {
178
- actions: a({
137
+ actions: i({
179
138
  componentOriginalValues: ({
180
- context: e,
181
- event: t
182
- }) => (console.log(
183
- `🔧 [formMachine] MARK_COMPONENT_AS_POPULATED fixing original value for ${t.componentId}:`,
184
- {
185
- eventValue: t.value,
186
- contextDataValue: e.data[t.componentId],
187
- existingOriginalValue: e.componentOriginalValues[t.componentId]?.value,
188
- isPopulated: e.componentOriginalValues[t.componentId]?.isPopulated
189
- }
190
- ), {
191
- ...e.componentOriginalValues,
192
- [t.componentId]: {
193
- ...e.componentOriginalValues[t.componentId],
194
- value: t.value,
139
+ context: t,
140
+ event: e
141
+ }) => ({
142
+ ...t.componentOriginalValues,
143
+ [e.componentId]: {
144
+ ...t.componentOriginalValues[e.componentId],
145
+ value: e.value,
195
146
  // Use event.value instead of currentValue from context.data
196
147
  timestamp: Date.now(),
197
148
  source: "api_populated",
@@ -202,24 +153,16 @@ const W = I({
202
153
  },
203
154
  UPDATE_COMPONENT_ORIGINAL_VALUE: {
204
155
  actions: [
205
- a({
156
+ i({
206
157
  componentOriginalValues: ({
207
- context: e,
208
- event: t
158
+ context: t,
159
+ event: e
209
160
  }) => {
210
- const n = e.data[t.componentId];
211
- return console.log(
212
- `🔄 [formMachine] UPDATE_COMPONENT_ORIGINAL_VALUE for ${t.componentId}:`,
213
- {
214
- componentId: t.componentId,
215
- currentValue: n,
216
- oldOriginalValue: e.componentOriginalValues[t.componentId]?.value,
217
- willUpdateTo: n
218
- }
219
- ), {
220
- ...e.componentOriginalValues,
221
- [t.componentId]: {
222
- ...e.componentOriginalValues[t.componentId],
161
+ const n = t.data[e.componentId];
162
+ return {
163
+ ...t.componentOriginalValues,
164
+ [e.componentId]: {
165
+ ...t.componentOriginalValues[e.componentId],
223
166
  value: n,
224
167
  // Update original value to current field value
225
168
  timestamp: Date.now(),
@@ -230,13 +173,11 @@ const W = I({
230
173
  }
231
174
  }),
232
175
  // Re-evaluate triggers after updating original value to clear alerts
233
- ({ context: e, event: t, self: n }) => {
234
- console.log(
235
- `🔄 [formMachine] Re-evaluating triggers after UPDATE_COMPONENT_ORIGINAL_VALUE for ${t.componentId}`
236
- ), n.send({
176
+ ({ context: t, event: e, self: n }) => {
177
+ n.send({
237
178
  type: "EVALUATE_COMPONENT_TRIGGERS",
238
- componentId: t.componentId,
239
- value: e.data[t.componentId],
179
+ componentId: e.componentId,
180
+ value: t.data[e.componentId],
240
181
  eventType: "valueChange"
241
182
  });
242
183
  }
@@ -247,49 +188,49 @@ const W = I({
247
188
  idle: {
248
189
  on: {
249
190
  SET_DATA: {
250
- actions: a({
251
- data: ({ context: e, event: t }) => e.data[t.key] === t.value ? e.data : Object.assign({}, e.data, {
252
- [t.key]: t.value
191
+ actions: i({
192
+ data: ({ context: t, event: e }) => t.data[e.key] === e.value ? t.data : Object.assign({}, t.data, {
193
+ [e.key]: e.value
253
194
  }),
254
- dirtyFields: ({ context: e, event: t }) => e.dirtyFields[t.key] ? e.dirtyFields : Object.assign({}, e.dirtyFields, {
255
- [t.key]: !0
195
+ dirtyFields: ({ context: t, event: e }) => t.dirtyFields[e.key] ? t.dirtyFields : Object.assign({}, t.dirtyFields, {
196
+ [e.key]: !0
256
197
  })
257
198
  })
258
199
  },
259
200
  SET_FIELD_STATE: {
260
- actions: a({
261
- fieldStates: ({ context: e, event: t }) => {
262
- const n = e.fieldStates[t.componentId] || {
201
+ actions: i({
202
+ fieldStates: ({ context: t, event: e }) => {
203
+ const n = t.fieldStates[e.componentId] || {
263
204
  value: void 0,
264
205
  error: null,
265
206
  isDirty: !1,
266
207
  isTouched: !1,
267
208
  isValidating: !1
268
209
  };
269
- let i = !1;
270
- for (const r in t.state) {
210
+ let a = !1;
211
+ for (const r in e.state) {
271
212
  const s = r;
272
- if (n[s] !== t.state[s]) {
273
- i = !0;
213
+ if (n[s] !== e.state[s]) {
214
+ a = !0;
274
215
  break;
275
216
  }
276
217
  }
277
- if (!i)
278
- return e.fieldStates;
279
- const o = Object.assign({}, e.fieldStates);
280
- return o[t.componentId] = Object.assign(
218
+ if (!a)
219
+ return t.fieldStates;
220
+ const o = Object.assign({}, t.fieldStates);
221
+ return o[e.componentId] = Object.assign(
281
222
  {},
282
223
  n,
283
- t.state
224
+ e.state
284
225
  ), o;
285
226
  }
286
227
  })
287
228
  },
288
229
  VALIDATE_FIELD: {
289
230
  actions: [
290
- a({
291
- touchedFields: ({ context: e, event: t }) => e.touchedFields[t.componentId] ? e.touchedFields : Object.assign({}, e.touchedFields, {
292
- [t.componentId]: !0
231
+ i({
232
+ touchedFields: ({ context: t, event: e }) => t.touchedFields[e.componentId] ? t.touchedFields : Object.assign({}, t.touchedFields, {
233
+ [e.componentId]: !0
293
234
  })
294
235
  })
295
236
  ]
@@ -304,77 +245,77 @@ const W = I({
304
245
  actions: []
305
246
  },
306
247
  START_SECTION_EDIT: {
307
- actions: a({
308
- sectionBackups: ({ context: e, event: t }) => {
309
- if (e.sectionBackups[t.sectionId])
310
- return e.sectionBackups;
248
+ actions: i({
249
+ sectionBackups: ({ context: t, event: e }) => {
250
+ if (t.sectionBackups[e.sectionId])
251
+ return t.sectionBackups;
311
252
  const n = {};
312
- for (const i of t.componentIds)
313
- n[i] = e.data[i];
314
- return Object.assign({}, e.sectionBackups, {
315
- [t.sectionId]: n
253
+ for (const a of e.componentIds)
254
+ n[a] = t.data[a];
255
+ return Object.assign({}, t.sectionBackups, {
256
+ [e.sectionId]: n
316
257
  });
317
258
  }
318
259
  })
319
260
  },
320
261
  CANCEL_SECTION_EDIT: {
321
- actions: a({
322
- data: ({ context: e, event: t }) => {
323
- const n = e.sectionBackups[t.sectionId];
324
- if (!n) return e.data;
325
- let i = !1;
262
+ actions: i({
263
+ data: ({ context: t, event: e }) => {
264
+ const n = t.sectionBackups[e.sectionId];
265
+ if (!n) return t.data;
266
+ let a = !1;
326
267
  for (const [r, s] of Object.entries(n))
327
- if (e.data[r] !== s) {
328
- i = !0;
268
+ if (t.data[r] !== s) {
269
+ a = !0;
329
270
  break;
330
271
  }
331
- if (!i)
332
- return e.data;
333
- const o = Object.assign({}, e.data);
272
+ if (!a)
273
+ return t.data;
274
+ const o = Object.assign({}, t.data);
334
275
  for (const [r, s] of Object.entries(n))
335
276
  o[r] = s;
336
277
  return o;
337
278
  },
338
279
  // Clear the backup after restoring
339
- sectionBackups: ({ context: e, event: t }) => {
340
- if (!e.sectionBackups[t.sectionId])
341
- return e.sectionBackups;
342
- const n = Object.assign({}, e.sectionBackups);
343
- return delete n[t.sectionId], n;
280
+ sectionBackups: ({ context: t, event: e }) => {
281
+ if (!t.sectionBackups[e.sectionId])
282
+ return t.sectionBackups;
283
+ const n = Object.assign({}, t.sectionBackups);
284
+ return delete n[e.sectionId], n;
344
285
  }
345
286
  })
346
287
  },
347
288
  REQUEST_NAVIGATION: {
348
289
  target: "evaluatingNavigation",
349
290
  actions: [
350
- a({
351
- pendingNavigation: ({ event: e }) => {
352
- if (e.type !== "REQUEST_NAVIGATION") return null;
353
- const t = {
354
- type: e.navigationType
291
+ i({
292
+ pendingNavigation: ({ event: t }) => {
293
+ if (t.type !== "REQUEST_NAVIGATION") return null;
294
+ const e = {
295
+ type: t.navigationType
355
296
  };
356
- return e.stepId !== void 0 && (t.stepId = e.stepId), t;
297
+ return t.stepId !== void 0 && (e.stepId = t.stepId), e;
357
298
  }
358
299
  })
359
300
  ]
360
301
  },
361
302
  NEXT: [
362
303
  {
363
- guard: N,
304
+ guard: O,
364
305
  target: "evaluatingNavigation",
365
306
  actions: [
366
- a({
367
- activeExecutionPlan: ({ context: e }) => u.createExecutionPlan(
368
- e.config,
307
+ i({
308
+ activeExecutionPlan: ({ context: t }) => l.createExecutionPlan(
309
+ t.config,
369
310
  "save",
370
- e.currentStepIndex,
371
- e
311
+ t.currentStepIndex,
312
+ t
372
313
  )
373
314
  }),
374
- a({
315
+ i({
375
316
  pendingNavigation: { type: "next" }
376
317
  }),
377
- a({
318
+ i({
378
319
  pendingNavigation: null,
379
320
  canNavigate: !1
380
321
  })
@@ -382,18 +323,18 @@ const W = I({
382
323
  },
383
324
  {
384
325
  // Direct navigation if no triggers need execution
385
- guard: d,
386
- actions: a({
387
- currentStepIndex: ({ context: e }) => Math.min(
388
- e.currentStepIndex + 1,
389
- e.config.steps.length - 1
326
+ guard: c,
327
+ actions: i({
328
+ currentStepIndex: ({ context: t }) => Math.min(
329
+ t.currentStepIndex + 1,
330
+ t.config.steps.length - 1
390
331
  ),
391
- currentStepId: ({ context: e }) => {
392
- const t = Math.min(
393
- e.currentStepIndex + 1,
394
- e.config.steps.length - 1
332
+ currentStepId: ({ context: t }) => {
333
+ const e = Math.min(
334
+ t.currentStepIndex + 1,
335
+ t.config.steps.length - 1
395
336
  );
396
- return e.config.steps[t]?.id || "";
337
+ return t.config.steps[e]?.id || "";
397
338
  },
398
339
  pendingNavigation: null
399
340
  })
@@ -401,19 +342,19 @@ const W = I({
401
342
  {
402
343
  // Fallback - set pending navigation and transition to evaluation state
403
344
  target: "evaluatingNavigation",
404
- actions: a({
345
+ actions: i({
405
346
  pendingNavigation: { type: "next" }
406
347
  })
407
348
  }
408
349
  ],
409
350
  PREVIOUS: [
410
351
  {
411
- guard: d,
412
- actions: a({
413
- currentStepIndex: ({ context: e }) => Math.max(e.currentStepIndex - 1, 0),
414
- currentStepId: ({ context: e }) => {
415
- const t = Math.max(e.currentStepIndex - 1, 0);
416
- return e.config.steps[t]?.id || "";
352
+ guard: c,
353
+ actions: i({
354
+ currentStepIndex: ({ context: t }) => Math.max(t.currentStepIndex - 1, 0),
355
+ currentStepId: ({ context: t }) => {
356
+ const e = Math.max(t.currentStepIndex - 1, 0);
357
+ return t.config.steps[e]?.id || "";
417
358
  },
418
359
  pendingNavigation: null
419
360
  })
@@ -421,34 +362,34 @@ const W = I({
421
362
  {
422
363
  // Fallback - set pending navigation and transition to evaluation state
423
364
  target: "evaluatingNavigation",
424
- actions: a({
365
+ actions: i({
425
366
  pendingNavigation: { type: "previous" }
426
367
  })
427
368
  }
428
369
  ],
429
370
  GO_TO_STEP: [
430
371
  {
431
- guard: d,
432
- actions: a({
433
- currentStepIndex: ({ context: e, event: t }) => {
434
- if (t.type !== "GO_TO_STEP")
435
- return e.currentStepIndex;
436
- const n = e.config.steps.findIndex(
437
- (i) => i.id === t.stepId
372
+ guard: c,
373
+ actions: i({
374
+ currentStepIndex: ({ context: t, event: e }) => {
375
+ if (e.type !== "GO_TO_STEP")
376
+ return t.currentStepIndex;
377
+ const n = t.config.steps.findIndex(
378
+ (a) => a.id === e.stepId
438
379
  );
439
- return n >= 0 ? n : e.currentStepIndex;
380
+ return n >= 0 ? n : t.currentStepIndex;
440
381
  },
441
- currentStepId: ({ context: e, event: t }) => t.type !== "GO_TO_STEP" ? e.currentStepId : t.stepId,
382
+ currentStepId: ({ context: t, event: e }) => e.type !== "GO_TO_STEP" ? t.currentStepId : e.stepId,
442
383
  pendingNavigation: null
443
384
  })
444
385
  },
445
386
  {
446
387
  // Fallback - set pending navigation and transition to evaluation state
447
388
  target: "evaluatingNavigation",
448
- actions: a({
449
- pendingNavigation: ({ event: e }) => e.type !== "GO_TO_STEP" ? null : {
389
+ actions: i({
390
+ pendingNavigation: ({ event: t }) => t.type !== "GO_TO_STEP" ? null : {
450
391
  type: "step",
451
- stepId: e.stepId
392
+ stepId: t.stepId
452
393
  }
453
394
  })
454
395
  }
@@ -457,9 +398,9 @@ const W = I({
457
398
  target: "submitting"
458
399
  },
459
400
  RESET: {
460
- actions: a({
401
+ actions: i({
461
402
  currentStepIndex: 0,
462
- currentStepId: ({ context: e }) => e.config.steps[0]?.id || "",
403
+ currentStepId: ({ context: t }) => t.config.steps[0]?.id || "",
463
404
  data: {},
464
405
  errors: {},
465
406
  dirtyFields: {},
@@ -488,31 +429,31 @@ const W = I({
488
429
  },
489
430
  EXECUTE_TRIGGER: {
490
431
  target: "executingActions",
491
- actions: a({
492
- executingTrigger: ({ event: e }) => e.trigger,
432
+ actions: i({
433
+ executingTrigger: ({ event: t }) => t.trigger,
493
434
  waitingForActions: !0,
494
435
  canNavigate: !1
495
436
  })
496
437
  },
497
438
  EXECUTE_ACTIONS: {
498
439
  target: "executingActions",
499
- actions: a({
500
- executingTrigger: ({ event: e }) => e.trigger,
440
+ actions: i({
441
+ executingTrigger: ({ event: t }) => t.trigger,
501
442
  waitingForActions: !0,
502
443
  canNavigate: !1
503
444
  })
504
445
  },
505
446
  EXECUTE_CONTEXT_ACTIONS: {
506
447
  target: "executingContextActions",
507
- actions: a({
508
- activeExecutionPlan: ({ event: e }) => e.executionPlan,
448
+ actions: i({
449
+ activeExecutionPlan: ({ event: t }) => t.executionPlan,
509
450
  canNavigate: !1
510
451
  })
511
452
  },
512
453
  SHOW_ACTION_DIALOG: {
513
454
  target: "showingActionDialog",
514
- actions: a({
515
- activeDialog: ({ event: e }) => e.dialogConfig,
455
+ actions: i({
456
+ activeDialog: ({ event: t }) => t.dialogConfig,
516
457
  canNavigate: !0,
517
458
  // Reset navigation permission when showing dialog
518
459
  waitingForActions: !1
@@ -520,74 +461,74 @@ const W = I({
520
461
  })
521
462
  },
522
463
  SHOW_FIELD_WARNING: {
523
- actions: a({
524
- fieldChangeState: ({ context: e, event: t }) => t.type !== "SHOW_FIELD_WARNING" ? e.fieldChangeState : {
525
- ...e.fieldChangeState,
526
- [t.fieldId]: {
527
- ...e.fieldChangeState[t.fieldId],
464
+ actions: i({
465
+ fieldChangeState: ({ context: t, event: e }) => e.type !== "SHOW_FIELD_WARNING" ? t.fieldChangeState : {
466
+ ...t.fieldChangeState,
467
+ [e.fieldId]: {
468
+ ...t.fieldChangeState[e.fieldId],
528
469
  validationWarnings: [
529
- ...e.fieldChangeState[t.fieldId]?.validationWarnings || [],
470
+ ...t.fieldChangeState[e.fieldId]?.validationWarnings || [],
530
471
  {
531
- id: t.warningId,
532
- fieldId: t.fieldId,
533
- message: t.message,
534
- severity: t.warningType || "warning",
535
- type: t.warningType || "warning",
472
+ id: e.warningId,
473
+ fieldId: e.fieldId,
474
+ message: e.message,
475
+ severity: e.warningType || "warning",
476
+ type: e.warningType || "warning",
536
477
  timestamp: Date.now(),
537
478
  dismissible: !0
538
479
  }
539
480
  ]
540
481
  }
541
482
  },
542
- fieldValidationState: ({ context: e, event: t }) => t.type !== "SHOW_FIELD_WARNING" ? e.fieldValidationState : {
543
- ...e.fieldValidationState,
544
- activeWarnings: e.fieldValidationState.activeWarnings.includes(
545
- t.fieldId
546
- ) ? e.fieldValidationState.activeWarnings : [
547
- ...e.fieldValidationState.activeWarnings,
548
- t.fieldId
483
+ fieldValidationState: ({ context: t, event: e }) => e.type !== "SHOW_FIELD_WARNING" ? t.fieldValidationState : {
484
+ ...t.fieldValidationState,
485
+ activeWarnings: t.fieldValidationState.activeWarnings.includes(
486
+ e.fieldId
487
+ ) ? t.fieldValidationState.activeWarnings : [
488
+ ...t.fieldValidationState.activeWarnings,
489
+ e.fieldId
549
490
  ]
550
491
  }
551
492
  })
552
493
  },
553
494
  DISMISS_FIELD_WARNING: {
554
- actions: a({
555
- fieldChangeState: ({ context: e, event: t }) => {
556
- const n = e.fieldChangeState[t.fieldId];
495
+ actions: i({
496
+ fieldChangeState: ({ context: t, event: e }) => {
497
+ const n = t.fieldChangeState[e.fieldId];
557
498
  return n ? {
558
- ...e.fieldChangeState,
559
- [t.fieldId]: {
499
+ ...t.fieldChangeState,
500
+ [e.fieldId]: {
560
501
  ...n,
561
502
  validationWarnings: n.validationWarnings?.filter(
562
- (i) => i.id !== t.warningId
503
+ (a) => a.id !== e.warningId
563
504
  ) || []
564
505
  }
565
- } : e.fieldChangeState;
506
+ } : t.fieldChangeState;
566
507
  },
567
- fieldValidationState: ({ context: e, event: t }) => {
568
- const i = e.fieldChangeState[t.fieldId]?.validationWarnings?.length > 0;
508
+ fieldValidationState: ({ context: t, event: e }) => {
509
+ const a = t.fieldChangeState[e.fieldId]?.validationWarnings?.length > 0;
569
510
  return {
570
- ...e.fieldValidationState,
571
- activeWarnings: i ? e.fieldValidationState.activeWarnings : e.fieldValidationState.activeWarnings.filter(
572
- (o) => o !== t.fieldId
511
+ ...t.fieldValidationState,
512
+ activeWarnings: a ? t.fieldValidationState.activeWarnings : t.fieldValidationState.activeWarnings.filter(
513
+ (o) => o !== e.fieldId
573
514
  )
574
515
  };
575
516
  }
576
517
  })
577
518
  },
578
519
  START_FIELD_VERIFICATION: {
579
- actions: a({
580
- fieldValidationState: ({ context: e, event: t }) => t.type !== "START_FIELD_VERIFICATION" ? e.fieldValidationState : {
581
- ...e.fieldValidationState,
582
- pendingVerifications: e.fieldValidationState.pendingVerifications.includes(
583
- t.fieldId
584
- ) ? e.fieldValidationState.pendingVerifications : [
585
- ...e.fieldValidationState.pendingVerifications,
586
- t.fieldId
520
+ actions: i({
521
+ fieldValidationState: ({ context: t, event: e }) => e.type !== "START_FIELD_VERIFICATION" ? t.fieldValidationState : {
522
+ ...t.fieldValidationState,
523
+ pendingVerifications: t.fieldValidationState.pendingVerifications.includes(
524
+ e.fieldId
525
+ ) ? t.fieldValidationState.pendingVerifications : [
526
+ ...t.fieldValidationState.pendingVerifications,
527
+ e.fieldId
587
528
  ],
588
529
  verificationResults: {
589
- ...e.fieldValidationState.verificationResults,
590
- [t.fieldId]: {
530
+ ...t.fieldValidationState.verificationResults,
531
+ [e.fieldId]: {
591
532
  status: "pending",
592
533
  timestamp: Date.now()
593
534
  }
@@ -596,47 +537,47 @@ const W = I({
596
537
  })
597
538
  },
598
539
  FIELD_VERIFICATION_COMPLETE: {
599
- actions: a({
540
+ actions: i({
600
541
  fieldValidationState: ({
601
- context: e,
602
- event: t
542
+ context: t,
543
+ event: e
603
544
  }) => ({
604
- ...e.fieldValidationState,
605
- pendingVerifications: e.fieldValidationState.pendingVerifications.filter(
606
- (n) => n !== t.fieldId
545
+ ...t.fieldValidationState,
546
+ pendingVerifications: t.fieldValidationState.pendingVerifications.filter(
547
+ (n) => n !== e.fieldId
607
548
  ),
608
549
  verificationResults: {
609
- ...e.fieldValidationState.verificationResults,
610
- [t.fieldId]: {
611
- status: t.success ? "success" : "failed",
550
+ ...t.fieldValidationState.verificationResults,
551
+ [e.fieldId]: {
552
+ status: e.success ? "success" : "failed",
612
553
  timestamp: Date.now(),
613
- result: t.result
554
+ result: e.result
614
555
  }
615
556
  }
616
557
  })
617
558
  })
618
559
  },
619
560
  CLEAR_FIELD_CHANGES: {
620
- actions: a({
621
- fieldChangeState: ({ context: e, event: t }) => {
622
- if (t.fieldId) {
623
- const n = { ...e.fieldChangeState };
624
- return delete n[t.fieldId], n;
561
+ actions: i({
562
+ fieldChangeState: ({ context: t, event: e }) => {
563
+ if (e.fieldId) {
564
+ const n = { ...t.fieldChangeState };
565
+ return delete n[e.fieldId], n;
625
566
  } else
626
567
  return {};
627
568
  },
628
- fieldValidationState: ({ context: e, event: t }) => t.fieldId ? {
629
- ...e.fieldValidationState,
630
- activeWarnings: e.fieldValidationState.activeWarnings.filter(
631
- (n) => n !== t.fieldId
569
+ fieldValidationState: ({ context: t, event: e }) => e.fieldId ? {
570
+ ...t.fieldValidationState,
571
+ activeWarnings: t.fieldValidationState.activeWarnings.filter(
572
+ (n) => n !== e.fieldId
632
573
  ),
633
- pendingVerifications: e.fieldValidationState.pendingVerifications.filter(
634
- (n) => n !== t.fieldId
574
+ pendingVerifications: t.fieldValidationState.pendingVerifications.filter(
575
+ (n) => n !== e.fieldId
635
576
  ),
636
577
  verificationResults: Object.fromEntries(
637
578
  Object.entries(
638
- e.fieldValidationState.verificationResults
639
- ).filter(([n]) => n !== t.fieldId)
579
+ t.fieldValidationState.verificationResults
580
+ ).filter(([n]) => n !== e.fieldId)
640
581
  )
641
582
  } : {
642
583
  activeWarnings: [],
@@ -646,73 +587,63 @@ const W = I({
646
587
  })
647
588
  },
648
589
  SET_COMPONENT_ORIGINAL_VALUE: {
649
- actions: a({
650
- componentOriginalValues: ({ context: e, event: t }) => {
651
- const n = e.componentOriginalValues[t.componentId], i = {
652
- value: t.value,
590
+ actions: i({
591
+ componentOriginalValues: ({ context: t, event: e }) => {
592
+ const n = t.componentOriginalValues[e.componentId], a = {
593
+ value: e.value,
653
594
  timestamp: Date.now(),
654
- source: t.source || "initialized",
655
- isPopulated: t.source !== "initialized"
595
+ source: e.source || "initialized",
596
+ isPopulated: e.source !== "initialized"
656
597
  };
657
- return n && h.shallowEqual(n, i) ? e.componentOriginalValues : Object.assign({}, e.componentOriginalValues, {
658
- [t.componentId]: i
598
+ return n && R.shallowEqual(n, a) ? t.componentOriginalValues : Object.assign({}, t.componentOriginalValues, {
599
+ [e.componentId]: a
659
600
  });
660
601
  }
661
602
  })
662
603
  },
663
604
  TRIGGER_COMPONENT_ACTION: {
664
- actions: [p]
605
+ actions: [d]
665
606
  },
666
607
  SHOW_COMPONENT_ALERT: {
667
- actions: a({
668
- componentAlerts: ({ context: e, event: t }) => {
669
- const i = (e.componentAlerts[t.componentId] || []).filter(
670
- (o) => o.id !== t.alert.id
608
+ actions: i({
609
+ componentAlerts: ({ context: t, event: e }) => {
610
+ const a = (t.componentAlerts[e.componentId] || []).filter(
611
+ (o) => o.id !== e.alert.id
671
612
  );
672
613
  return {
673
- ...e.componentAlerts,
674
- [t.componentId]: [...i, t.alert]
614
+ ...t.componentAlerts,
615
+ [e.componentId]: [...a, e.alert]
675
616
  };
676
617
  }
677
618
  })
678
619
  },
679
620
  DISMISS_COMPONENT_ALERT: {
680
- actions: a({
681
- componentAlerts: ({ context: e, event: t }) => {
682
- const n = e.componentAlerts[t.componentId] || [], i = t.alertId ? n.filter((o) => o.id !== t.alertId) : [];
683
- return console.log(
684
- `🧹 [formMachine] DISMISS_COMPONENT_ALERT for ${t.componentId}:`,
685
- {
686
- alertId: t.alertId,
687
- beforeCount: n.length,
688
- afterCount: i.length,
689
- clearedAll: !t.alertId && n.length > 0
690
- }
691
- ), {
692
- ...e.componentAlerts,
693
- [t.componentId]: i
621
+ actions: i({
622
+ componentAlerts: ({ context: t, event: e }) => {
623
+ const n = t.componentAlerts[e.componentId] || [], a = e.alertId ? n.filter((o) => o.id !== e.alertId) : [];
624
+ return {
625
+ ...t.componentAlerts,
626
+ [e.componentId]: a
694
627
  };
695
628
  }
696
629
  })
697
630
  },
698
631
  CLEAR_COMPONENT_ALERT: {
699
- actions: a({
700
- componentAlerts: ({ context: e, event: t }) => (console.log(
701
- `🧹 [formMachine] CLEAR_COMPONENT_ALERT for ${t.componentId}`
702
- ), {
703
- ...e.componentAlerts,
704
- [t.componentId]: []
632
+ actions: i({
633
+ componentAlerts: ({ context: t, event: e }) => ({
634
+ ...t.componentAlerts,
635
+ [e.componentId]: []
705
636
  })
706
637
  })
707
638
  },
708
639
  START_SAVE: {
709
640
  target: "preparingSave",
710
- actions: a({
711
- saveState: ({ context: e, event: t }) => t.type !== "START_SAVE" ? e.saveState : {
712
- ...e.saveState,
641
+ actions: i({
642
+ saveState: ({ context: t, event: e }) => e.type !== "START_SAVE" ? t.saveState : {
643
+ ...t.saveState,
713
644
  saveInProgress: !0,
714
- saveInitiator: t.initiator,
715
- savingSection: t.sectionId,
645
+ saveInitiator: e.initiator,
646
+ savingSection: e.sectionId,
716
647
  saveStartTimestamp: Date.now(),
717
648
  pendingVerifications: [],
718
649
  completedVerifications: [],
@@ -721,12 +652,12 @@ const W = I({
721
652
  })
722
653
  },
723
654
  SAVE_DIALOG_SHOWN: {
724
- actions: a({
725
- saveState: ({ context: e, event: t }) => t.type !== "SAVE_DIALOG_SHOWN" ? e.saveState : {
726
- ...e.saveState,
655
+ actions: i({
656
+ saveState: ({ context: t, event: e }) => e.type !== "SAVE_DIALOG_SHOWN" ? t.saveState : {
657
+ ...t.saveState,
727
658
  pendingVerifications: [
728
- ...e.saveState.pendingVerifications,
729
- t.dialogId
659
+ ...t.saveState.pendingVerifications,
660
+ e.dialogId
730
661
  ]
731
662
  }
732
663
  })
@@ -737,19 +668,19 @@ const W = I({
737
668
  executingContextActions: {
738
669
  entry: [
739
670
  // Execute all actions in the execution plan
740
- ({ context: e, self: t }) => {
741
- const n = e.activeExecutionPlan;
742
- n && (n.executions.forEach((i) => {
743
- i.actions.forEach((o) => {
744
- t.send({
671
+ ({ context: t, self: e }) => {
672
+ const n = t.activeExecutionPlan;
673
+ n && (n.executions.forEach((a) => {
674
+ a.actions.forEach((o) => {
675
+ e.send({
745
676
  type: "TRIGGER_COMPONENT_ACTION",
746
- componentId: i.componentId,
747
- triggerId: i.trigger.id,
677
+ componentId: a.componentId,
678
+ triggerId: a.trigger.id,
748
679
  actionId: o.id,
749
680
  eventType: "navigationAttempt"
750
681
  });
751
682
  });
752
- }), n.totalActions === 0 && t.send({
683
+ }), n.totalActions === 0 && e.send({
753
684
  type: "CONTEXT_ACTIONS_COMPLETE",
754
685
  results: {}
755
686
  }));
@@ -758,48 +689,48 @@ const W = I({
758
689
  on: {
759
690
  REQUEST_NAVIGATION: {
760
691
  actions: [
761
- a({
762
- pendingNavigation: ({ event: e }) => {
763
- if (e.type !== "REQUEST_NAVIGATION") return null;
764
- const t = {
765
- type: e.navigationType
692
+ i({
693
+ pendingNavigation: ({ event: t }) => {
694
+ if (t.type !== "REQUEST_NAVIGATION") return null;
695
+ const e = {
696
+ type: t.navigationType
766
697
  };
767
- return e.stepId !== void 0 && (t.stepId = e.stepId), t;
698
+ return t.stepId !== void 0 && (e.stepId = t.stepId), e;
768
699
  }
769
700
  })
770
701
  ]
771
702
  },
772
703
  TRIGGER_COMPONENT_ACTION: {
773
- actions: [p]
704
+ actions: [d]
774
705
  },
775
706
  CONTEXT_ACTIONS_COMPLETE: {
776
707
  target: "idle",
777
708
  actions: [
778
- a({
709
+ i({
779
710
  activeExecutionPlan: null,
780
- executionResults: ({ context: e, event: t }) => ({
781
- ...e.executionResults,
782
- ...t.results
711
+ executionResults: ({ context: t, event: e }) => ({
712
+ ...t.executionResults,
713
+ ...e.results
783
714
  })
784
715
  }),
785
- f
716
+ S
786
717
  ]
787
718
  },
788
719
  SHOW_ACTION_DIALOG: {
789
720
  target: "showingActionDialog",
790
- actions: a({
791
- activeDialog: ({ event: e }) => e.dialogConfig
721
+ actions: i({
722
+ activeDialog: ({ event: t }) => t.dialogConfig
792
723
  })
793
724
  },
794
725
  SHOW_COMPONENT_ALERT: {
795
- actions: a({
796
- componentAlerts: ({ context: e, event: t }) => {
797
- const i = (e.componentAlerts[t.componentId] || []).filter(
798
- (o) => o.id !== t.alert.id
726
+ actions: i({
727
+ componentAlerts: ({ context: t, event: e }) => {
728
+ const a = (t.componentAlerts[e.componentId] || []).filter(
729
+ (o) => o.id !== e.alert.id
799
730
  );
800
731
  return {
801
- ...e.componentAlerts,
802
- [t.componentId]: [...i, t.alert]
732
+ ...t.componentAlerts,
733
+ [e.componentId]: [...a, e.alert]
803
734
  };
804
735
  }
805
736
  })
@@ -807,31 +738,31 @@ const W = I({
807
738
  }
808
739
  },
809
740
  submitting: {
810
- entry: a({ isSubmitting: !0 }),
741
+ entry: i({ isSubmitting: !0 }),
811
742
  on: {
812
743
  SUBMIT_SUCCESS: {
813
744
  target: "idle",
814
- actions: a({ isSubmitting: !1 })
745
+ actions: i({ isSubmitting: !1 })
815
746
  },
816
747
  SUBMIT_ERROR: {
817
748
  target: "idle",
818
- actions: a({
749
+ actions: i({
819
750
  isSubmitting: !1,
820
- errors: ({ context: e, event: t }) => ({
821
- ...e.errors,
822
- _form: [t.error.message]
751
+ errors: ({ context: t, event: e }) => ({
752
+ ...t.errors,
753
+ _form: [e.error.message]
823
754
  })
824
755
  })
825
756
  },
826
757
  SET_COMPONENT_ORIGINAL_VALUE: {
827
- actions: a({
828
- componentOriginalValues: ({ context: e, event: t }) => ({
829
- ...e.componentOriginalValues,
830
- [t.componentId]: {
831
- value: t.value,
758
+ actions: i({
759
+ componentOriginalValues: ({ context: t, event: e }) => ({
760
+ ...t.componentOriginalValues,
761
+ [e.componentId]: {
762
+ value: e.value,
832
763
  timestamp: Date.now(),
833
- source: t.source || "initialized",
834
- isPopulated: t.source !== "initialized"
764
+ source: e.source || "initialized",
765
+ isPopulated: e.source !== "initialized"
835
766
  }
836
767
  })
837
768
  })
@@ -842,16 +773,16 @@ const W = I({
842
773
  executingActions: {
843
774
  on: {
844
775
  COMPONENT_ACTION_START: {
845
- actions: a({
846
- activeComponentActions: ({ context: e, event: t }) => {
847
- const n = e.activeComponentActions[t.componentId] || [];
776
+ actions: i({
777
+ activeComponentActions: ({ context: t, event: e }) => {
778
+ const n = t.activeComponentActions[e.componentId] || [];
848
779
  return {
849
- ...e.activeComponentActions,
850
- [t.componentId]: [
780
+ ...t.activeComponentActions,
781
+ [e.componentId]: [
851
782
  ...n,
852
783
  {
853
- actionId: t.actionId,
854
- componentId: t.componentId,
784
+ actionId: e.actionId,
785
+ componentId: e.componentId,
855
786
  status: "executing",
856
787
  startTime: Date.now()
857
788
  }
@@ -861,54 +792,54 @@ const W = I({
861
792
  })
862
793
  },
863
794
  COMPONENT_ACTION_COMPLETE: {
864
- actions: a({
865
- activeComponentActions: ({ context: e, event: t }) => {
866
- const n = e.activeComponentActions[t.componentId] || [];
795
+ actions: i({
796
+ activeComponentActions: ({ context: t, event: e }) => {
797
+ const n = t.activeComponentActions[e.componentId] || [];
867
798
  return {
868
- ...e.activeComponentActions,
869
- [t.componentId]: n.map(
870
- (i) => i.actionId === t.actionId ? { ...i, status: "completed" } : i
799
+ ...t.activeComponentActions,
800
+ [e.componentId]: n.map(
801
+ (a) => a.actionId === e.actionId ? { ...a, status: "completed" } : a
871
802
  )
872
803
  };
873
804
  }
874
805
  })
875
806
  },
876
807
  COMPONENT_ACTION_FAILED: {
877
- actions: a({
878
- activeComponentActions: ({ context: e, event: t }) => {
879
- const n = e.activeComponentActions[t.componentId] || [];
808
+ actions: i({
809
+ activeComponentActions: ({ context: t, event: e }) => {
810
+ const n = t.activeComponentActions[e.componentId] || [];
880
811
  return {
881
- ...e.activeComponentActions,
882
- [t.componentId]: n.map(
883
- (i) => i.actionId === t.actionId ? {
884
- ...i,
812
+ ...t.activeComponentActions,
813
+ [e.componentId]: n.map(
814
+ (a) => a.actionId === e.actionId ? {
815
+ ...a,
885
816
  status: "failed",
886
- error: t.error
887
- } : i
817
+ error: e.error
818
+ } : a
888
819
  )
889
820
  };
890
821
  }
891
822
  })
892
823
  },
893
824
  SHOW_COMPONENT_ALERT: {
894
- actions: a({
895
- componentAlerts: ({ context: e, event: t }) => {
896
- const i = (e.componentAlerts[t.componentId] || []).filter(
897
- (o) => o.id !== t.alert.id
825
+ actions: i({
826
+ componentAlerts: ({ context: t, event: e }) => {
827
+ const a = (t.componentAlerts[e.componentId] || []).filter(
828
+ (o) => o.id !== e.alert.id
898
829
  );
899
830
  return {
900
- ...e.componentAlerts,
901
- [t.componentId]: [...i, t.alert]
831
+ ...t.componentAlerts,
832
+ [e.componentId]: [...a, e.alert]
902
833
  };
903
834
  }
904
835
  })
905
836
  },
906
837
  ACTION_START: {
907
- actions: a({
908
- activeActions: ({ context: e, event: t }) => ({
909
- ...e.activeActions,
910
- [t.actionId]: {
911
- actionId: t.actionId,
838
+ actions: i({
839
+ activeActions: ({ context: t, event: e }) => ({
840
+ ...t.activeActions,
841
+ [e.actionId]: {
842
+ actionId: e.actionId,
912
843
  status: "executing",
913
844
  startTime: Date.now()
914
845
  }
@@ -916,26 +847,26 @@ const W = I({
916
847
  })
917
848
  },
918
849
  ACTION_SUCCESS: {
919
- actions: a({
920
- activeActions: ({ context: e, event: t }) => ({
921
- ...e.activeActions,
922
- [t.actionId]: {
923
- ...e.activeActions[t.actionId],
850
+ actions: i({
851
+ activeActions: ({ context: t, event: e }) => ({
852
+ ...t.activeActions,
853
+ [e.actionId]: {
854
+ ...t.activeActions[e.actionId],
924
855
  status: "success",
925
- result: t.result,
856
+ result: e.result,
926
857
  completedTime: Date.now()
927
858
  }
928
859
  })
929
860
  })
930
861
  },
931
862
  ACTION_ERROR: {
932
- actions: a({
933
- activeActions: ({ context: e, event: t }) => ({
934
- ...e.activeActions,
935
- [t.actionId]: {
936
- ...e.activeActions[t.actionId],
863
+ actions: i({
864
+ activeActions: ({ context: t, event: e }) => ({
865
+ ...t.activeActions,
866
+ [e.actionId]: {
867
+ ...t.activeActions[e.actionId],
937
868
  status: "error",
938
- error: t.error,
869
+ error: e.error,
939
870
  completedTime: Date.now()
940
871
  }
941
872
  })
@@ -943,23 +874,23 @@ const W = I({
943
874
  },
944
875
  ACTIONS_COMPLETED: {
945
876
  target: "executingPendingNavigation",
946
- actions: a({
877
+ actions: i({
947
878
  // Clear all action execution state
948
879
  activeActions: {},
949
880
  executingTrigger: null,
950
881
  waitingForActions: !1,
951
882
  canNavigate: !0,
952
883
  // Store final results
953
- actionResults: ({ context: e, event: t }) => ({
954
- ...e.actionResults,
955
- ...t.results
884
+ actionResults: ({ context: t, event: e }) => ({
885
+ ...t.actionResults,
886
+ ...e.results
956
887
  })
957
888
  })
958
889
  },
959
890
  SHOW_ACTION_DIALOG: {
960
891
  target: "showingActionDialog",
961
- actions: a({
962
- activeDialog: ({ event: e }) => e.dialogConfig,
892
+ actions: i({
893
+ activeDialog: ({ event: t }) => t.dialogConfig,
963
894
  canNavigate: !1,
964
895
  // Block navigation until dialog is resolved
965
896
  waitingForActions: !1
@@ -967,24 +898,24 @@ const W = I({
967
898
  })
968
899
  },
969
900
  TRIGGER_COMPONENT_ACTION: {
970
- actions: [p]
901
+ actions: [d]
971
902
  },
972
903
  DISMISS_COMPONENT_ALERT: {
973
- actions: a({
974
- componentAlerts: ({ context: e, event: t }) => {
975
- const n = e.componentAlerts[t.componentId] || [], i = t.alertId ? n.filter((o) => o.id !== t.alertId) : [];
904
+ actions: i({
905
+ componentAlerts: ({ context: t, event: e }) => {
906
+ const n = t.componentAlerts[e.componentId] || [], a = e.alertId ? n.filter((o) => o.id !== e.alertId) : [];
976
907
  return {
977
- ...e.componentAlerts,
978
- [t.componentId]: i
908
+ ...t.componentAlerts,
909
+ [e.componentId]: a
979
910
  };
980
911
  }
981
912
  })
982
913
  },
983
914
  CLEAR_COMPONENT_ALERT: {
984
- actions: a({
985
- componentAlerts: ({ context: e, event: t }) => ({
986
- ...e.componentAlerts,
987
- [t.componentId]: []
915
+ actions: i({
916
+ componentAlerts: ({ context: t, event: e }) => ({
917
+ ...t.componentAlerts,
918
+ [e.componentId]: []
988
919
  })
989
920
  })
990
921
  }
@@ -999,63 +930,39 @@ const W = I({
999
930
  guard: E,
1000
931
  target: "executingContextActions",
1001
932
  actions: [
1002
- a({
1003
- activeExecutionPlan: ({ context: e }) => {
1004
- console.log(
1005
- "🎯 [formMachine] Creating execution plan for save context in evaluatingNavigation"
1006
- );
1007
- const t = u.createExecutionPlan(
1008
- e.config,
1009
- "save",
1010
- e.currentStepIndex,
1011
- e
1012
- );
1013
- return console.log("🎯 [formMachine] Save context execution plan:", {
1014
- totalActions: t.totalActions,
1015
- executionsCount: t.executions.length,
1016
- executions: t.executions.map((n) => ({
1017
- componentId: n.componentId,
1018
- triggerId: n.trigger.id,
1019
- triggerType: n.trigger.type,
1020
- actionsCount: n.actions.length,
1021
- actions: n.actions.map((i) => ({
1022
- id: i.id,
1023
- type: i.type,
1024
- contexts: i.contexts
1025
- }))
1026
- }))
1027
- }), t;
1028
- }
933
+ i({
934
+ activeExecutionPlan: ({ context: t }) => l.createExecutionPlan(
935
+ t.config,
936
+ "save",
937
+ t.currentStepIndex,
938
+ t
939
+ )
1029
940
  })
1030
941
  ]
1031
942
  },
1032
943
  {
1033
944
  // PRIORITY 2: Check for other dirty components with triggers for step navigation
1034
- guard: v,
945
+ guard: C,
1035
946
  target: "executingTriggerActions",
1036
947
  actions: [
1037
- a({
948
+ i({
1038
949
  executingTrigger: "onStepFinish",
1039
950
  waitingForActions: !0,
1040
951
  canNavigate: !1
1041
952
  }),
1042
953
  // Execute the component trigger actions
1043
- ({ context: e, self: t }) => {
1044
- console.log(
1045
- "🎯 [formMachine] Executing dirty component trigger actions for step navigation"
1046
- ), u.findDirtyComponentsForNavigation(
1047
- e.config,
1048
- e.currentStepIndex,
1049
- e,
954
+ ({ context: t, self: e }) => {
955
+ l.findDirtyComponentsForNavigation(
956
+ t.config,
957
+ t.currentStepIndex,
958
+ t,
1050
959
  "step"
1051
960
  ).forEach(
1052
- ({ componentId: i, trigger: o, actions: r }) => {
961
+ ({ componentId: a, trigger: o, actions: r }) => {
1053
962
  r.forEach((s) => {
1054
- console.log(
1055
- `⚡ [formMachine] Executing step navigation action ${s.id} for ${i}`
1056
- ), t.send({
963
+ e.send({
1057
964
  type: "TRIGGER_COMPONENT_ACTION",
1058
- componentId: i,
965
+ componentId: a,
1059
966
  triggerId: o.id,
1060
967
  actionId: s.id,
1061
968
  eventType: "navigationAttempt"
@@ -1068,40 +975,22 @@ const W = I({
1068
975
  },
1069
976
  {
1070
977
  // PRIORITY 3: Execute step-level onStepFinish actions if this is a next navigation
1071
- guard: ({ context: e }) => {
1072
- if (e.pendingNavigation?.type !== "next") return !1;
1073
- const t = e.config.steps[e.currentStepIndex];
1074
- if (!t || !("actions" in t)) return !1;
1075
- const n = t.actions || [], i = n.some(
978
+ guard: ({ context: t }) => {
979
+ if (t.pendingNavigation?.type !== "next") return !1;
980
+ const e = t.config.steps[t.currentStepIndex];
981
+ return !e || !("actions" in e) ? !1 : (e.actions || []).some(
1076
982
  (o) => o.trigger === "onStepFinish"
1077
983
  );
1078
- return console.log(
1079
- "🎯 [formMachine] Checking for step-level onStepFinish actions:",
1080
- {
1081
- stepIndex: e.currentStepIndex,
1082
- stepId: t.id,
1083
- hasFinishActions: i,
1084
- stepActionsCount: n.length
1085
- }
1086
- ), i;
1087
984
  },
1088
985
  target: "executingActions",
1089
986
  actions: [
1090
- a({
987
+ i({
1091
988
  executingTrigger: "onStepFinish",
1092
989
  waitingForActions: !0,
1093
990
  canNavigate: !1
1094
991
  }),
1095
- ({ context: e, self: t }) => {
1096
- const n = e.config.steps[e.currentStepIndex], i = n.actions || [];
1097
- console.log(
1098
- "🎯 [formMachine] Executing step-level onStepFinish actions:",
1099
- {
1100
- stepIndex: e.currentStepIndex,
1101
- stepId: n.id,
1102
- actionsCount: i.length
1103
- }
1104
- ), t.send({
992
+ ({ self: t }) => {
993
+ t.send({
1105
994
  type: "EXECUTE_ACTIONS",
1106
995
  trigger: "onStepFinish"
1107
996
  });
@@ -1110,7 +999,7 @@ const W = I({
1110
999
  },
1111
1000
  {
1112
1001
  // PRIORITY 4: Proceed with normal navigation evaluation
1113
- guard: O,
1002
+ guard: N,
1114
1003
  target: "executingPendingNavigation"
1115
1004
  }
1116
1005
  ]
@@ -1120,26 +1009,26 @@ const W = I({
1120
1009
  on: {
1121
1010
  TRIGGER_COMPONENT_ACTION: {
1122
1011
  actions: [
1123
- a({
1124
- componentTriggerState: ({ context: e, event: t }) => ({
1125
- ...e.componentTriggerState,
1126
- [`${t.componentId}-${t.triggerId}`]: {
1127
- ...e.componentTriggerState[`${t.componentId}-${t.triggerId}`],
1012
+ i({
1013
+ componentTriggerState: ({ context: t, event: e }) => ({
1014
+ ...t.componentTriggerState,
1015
+ [`${e.componentId}-${e.triggerId}`]: {
1016
+ ...t.componentTriggerState[`${e.componentId}-${e.triggerId}`],
1128
1017
  isActive: !0,
1129
1018
  lastTriggered: Date.now()
1130
1019
  }
1131
1020
  })
1132
1021
  }),
1133
- a({
1134
- activeComponentActions: ({ context: e, event: t }) => {
1135
- const n = e.activeComponentActions[t.componentId] || [];
1022
+ i({
1023
+ activeComponentActions: ({ context: t, event: e }) => {
1024
+ const n = t.activeComponentActions[e.componentId] || [];
1136
1025
  return {
1137
- ...e.activeComponentActions,
1138
- [t.componentId]: [
1026
+ ...t.activeComponentActions,
1027
+ [e.componentId]: [
1139
1028
  ...n,
1140
1029
  {
1141
- actionId: t.actionId,
1142
- componentId: t.componentId,
1030
+ actionId: e.actionId,
1031
+ componentId: e.componentId,
1143
1032
  status: "executing",
1144
1033
  startTime: Date.now()
1145
1034
  }
@@ -1147,40 +1036,40 @@ const W = I({
1147
1036
  };
1148
1037
  }
1149
1038
  }),
1150
- p
1039
+ d
1151
1040
  ]
1152
1041
  },
1153
1042
  TRIGGER_ACTIONS_COMPLETE: {
1154
1043
  target: "executingPendingNavigation",
1155
- actions: a({
1044
+ actions: i({
1156
1045
  executingTrigger: null,
1157
1046
  waitingForActions: !1,
1158
1047
  canNavigate: !0
1159
1048
  })
1160
1049
  },
1161
1050
  DISMISS_COMPONENT_ALERT: {
1162
- actions: a({
1163
- componentAlerts: ({ context: e, event: t }) => {
1164
- const n = e.componentAlerts[t.componentId] || [], i = t.alertId ? n.filter((o) => o.id !== t.alertId) : [];
1051
+ actions: i({
1052
+ componentAlerts: ({ context: t, event: e }) => {
1053
+ const n = t.componentAlerts[e.componentId] || [], a = e.alertId ? n.filter((o) => o.id !== e.alertId) : [];
1165
1054
  return {
1166
- ...e.componentAlerts,
1167
- [t.componentId]: i
1055
+ ...t.componentAlerts,
1056
+ [e.componentId]: a
1168
1057
  };
1169
1058
  }
1170
1059
  })
1171
1060
  },
1172
1061
  CLEAR_COMPONENT_ALERT: {
1173
- actions: a({
1174
- componentAlerts: ({ context: e, event: t }) => ({
1175
- ...e.componentAlerts,
1176
- [t.componentId]: []
1062
+ actions: i({
1063
+ componentAlerts: ({ context: t, event: e }) => ({
1064
+ ...t.componentAlerts,
1065
+ [e.componentId]: []
1177
1066
  })
1178
1067
  })
1179
1068
  },
1180
1069
  SHOW_ACTION_DIALOG: {
1181
1070
  target: "showingActionDialog",
1182
- actions: a({
1183
- activeDialog: ({ event: e }) => e.dialogConfig,
1071
+ actions: i({
1072
+ activeDialog: ({ event: t }) => t.dialogConfig,
1184
1073
  canNavigate: !1,
1185
1074
  waitingForActions: !1
1186
1075
  })
@@ -1191,19 +1080,19 @@ const W = I({
1191
1080
  executingPendingNavigation: {
1192
1081
  always: [
1193
1082
  {
1194
- guard: S,
1083
+ guard: m,
1195
1084
  target: "idle",
1196
- actions: a({
1197
- currentStepIndex: ({ context: e }) => Math.min(
1198
- e.currentStepIndex + 1,
1199
- e.config.steps.length - 1
1085
+ actions: i({
1086
+ currentStepIndex: ({ context: t }) => Math.min(
1087
+ t.currentStepIndex + 1,
1088
+ t.config.steps.length - 1
1200
1089
  ),
1201
- currentStepId: ({ context: e }) => {
1202
- const t = Math.min(
1203
- e.currentStepIndex + 1,
1204
- e.config.steps.length - 1
1090
+ currentStepId: ({ context: t }) => {
1091
+ const e = Math.min(
1092
+ t.currentStepIndex + 1,
1093
+ t.config.steps.length - 1
1205
1094
  );
1206
- return e.config.steps[t]?.id || "";
1095
+ return t.config.steps[e]?.id || "";
1207
1096
  },
1208
1097
  pendingNavigation: null
1209
1098
  })
@@ -1211,11 +1100,11 @@ const W = I({
1211
1100
  {
1212
1101
  guard: A,
1213
1102
  target: "idle",
1214
- actions: a({
1215
- currentStepIndex: ({ context: e }) => Math.max(e.currentStepIndex - 1, 0),
1216
- currentStepId: ({ context: e }) => {
1217
- const t = Math.max(e.currentStepIndex - 1, 0);
1218
- return e.config.steps[t]?.id || "";
1103
+ actions: i({
1104
+ currentStepIndex: ({ context: t }) => Math.max(t.currentStepIndex - 1, 0),
1105
+ currentStepId: ({ context: t }) => {
1106
+ const e = Math.max(t.currentStepIndex - 1, 0);
1107
+ return t.config.steps[e]?.id || "";
1219
1108
  },
1220
1109
  pendingNavigation: null
1221
1110
  })
@@ -1223,21 +1112,21 @@ const W = I({
1223
1112
  {
1224
1113
  guard: T,
1225
1114
  target: "idle",
1226
- actions: a({
1227
- currentStepIndex: ({ context: e }) => {
1228
- const t = e.config.steps.findIndex(
1229
- (n) => n.id === e.pendingNavigation?.stepId
1115
+ actions: i({
1116
+ currentStepIndex: ({ context: t }) => {
1117
+ const e = t.config.steps.findIndex(
1118
+ (n) => n.id === t.pendingNavigation?.stepId
1230
1119
  );
1231
- return t >= 0 ? t : e.currentStepIndex;
1120
+ return e >= 0 ? e : t.currentStepIndex;
1232
1121
  },
1233
- currentStepId: ({ context: e }) => e.pendingNavigation?.stepId || e.currentStepId,
1122
+ currentStepId: ({ context: t }) => t.pendingNavigation?.stepId || t.currentStepId,
1234
1123
  pendingNavigation: null,
1235
1124
  canNavigate: !0
1236
1125
  })
1237
1126
  },
1238
1127
  {
1239
1128
  target: "idle",
1240
- actions: a({
1129
+ actions: i({
1241
1130
  pendingNavigation: null,
1242
1131
  canNavigate: !0
1243
1132
  })
@@ -1248,7 +1137,7 @@ const W = I({
1248
1137
  on: {
1249
1138
  HIDE_ACTION_DIALOG: {
1250
1139
  target: "idle",
1251
- actions: a({
1140
+ actions: i({
1252
1141
  activeDialog: null,
1253
1142
  canNavigate: !0,
1254
1143
  // Allow navigation when dialog is hidden (cancelled)
@@ -1260,44 +1149,36 @@ const W = I({
1260
1149
  DIALOG_VERIFIED: {
1261
1150
  target: "executingPendingNavigation",
1262
1151
  actions: [
1263
- a({
1152
+ i({
1264
1153
  activeDialog: null,
1265
1154
  canNavigate: !0
1266
1155
  // Allow navigation after successful verification
1267
1156
  }),
1268
1157
  // Handle updateOriginalValue action from verified dialog
1269
- ({ context: e, self: t }) => {
1270
- const n = e.activeDialog;
1158
+ ({ context: t, self: e }) => {
1159
+ const n = t.activeDialog;
1271
1160
  if (!n) return;
1272
- const i = n;
1273
- if (i.templateConfig?.onVerifiedAction?.type === "updateOriginalValue") {
1274
- const o = i.componentId;
1275
- o && e.data[o] !== void 0 && (console.log(
1276
- `🔄 [formMachine] DIALOG_VERIFIED: Updating original value for ${o}`,
1277
- {
1278
- newValue: e.data[o],
1279
- oldOriginalValue: e.componentOriginalValues[o]?.value
1280
- }
1281
- ), t.send({
1161
+ const a = n;
1162
+ if (a.templateConfig?.onVerifiedAction?.type === "updateOriginalValue") {
1163
+ const o = a.componentId;
1164
+ o && t.data[o] !== void 0 && (e.send({
1282
1165
  type: "SET_COMPONENT_ORIGINAL_VALUE",
1283
1166
  componentId: o,
1284
- value: e.data[o],
1167
+ value: t.data[o],
1285
1168
  source: "user_verified"
1286
- }), t.send({
1169
+ }), e.send({
1287
1170
  type: "MARK_COMPONENT_AS_POPULATED",
1288
1171
  componentId: o,
1289
- value: e.data[o]
1290
- }), t.send({
1172
+ value: t.data[o]
1173
+ }), e.send({
1291
1174
  type: "DISMISS_COMPONENT_ALERT",
1292
1175
  componentId: o
1293
- }), t.send({
1176
+ }), e.send({
1294
1177
  type: "EVALUATE_COMPONENT_TRIGGERS",
1295
1178
  componentId: o,
1296
- value: e.data[o],
1179
+ value: t.data[o],
1297
1180
  eventType: "valueChange"
1298
- }), console.log(
1299
- `🔄 [formMachine] Sending RESET_FIELD_TANSTACK_STATE event for ${o}`
1300
- ));
1181
+ }));
1301
1182
  }
1302
1183
  }
1303
1184
  ]
@@ -1305,7 +1186,7 @@ const W = I({
1305
1186
  // Handle dialog cancellation
1306
1187
  DIALOG_CANCELLED: {
1307
1188
  target: "idle",
1308
- actions: a({
1189
+ actions: i({
1309
1190
  activeDialog: null,
1310
1191
  canNavigate: !0,
1311
1192
  // Reset navigation permission
@@ -1319,26 +1200,26 @@ const W = I({
1319
1200
  },
1320
1201
  NEXT: [
1321
1202
  {
1322
- guard: d,
1203
+ guard: c,
1323
1204
  target: "idle",
1324
- actions: a({
1325
- currentStepIndex: ({ context: e }) => Math.min(
1326
- e.currentStepIndex + 1,
1327
- e.config.steps.length - 1
1205
+ actions: i({
1206
+ currentStepIndex: ({ context: t }) => Math.min(
1207
+ t.currentStepIndex + 1,
1208
+ t.config.steps.length - 1
1328
1209
  ),
1329
- currentStepId: ({ context: e }) => {
1330
- const t = Math.min(
1331
- e.currentStepIndex + 1,
1332
- e.config.steps.length - 1
1210
+ currentStepId: ({ context: t }) => {
1211
+ const e = Math.min(
1212
+ t.currentStepIndex + 1,
1213
+ t.config.steps.length - 1
1333
1214
  );
1334
- return e.config.steps[t]?.id || "";
1215
+ return t.config.steps[e]?.id || "";
1335
1216
  },
1336
1217
  pendingNavigation: null
1337
1218
  })
1338
1219
  },
1339
1220
  {
1340
1221
  target: "idle",
1341
- actions: a({
1222
+ actions: i({
1342
1223
  activeDialog: null,
1343
1224
  pendingNavigation: { type: "next" }
1344
1225
  })
@@ -1346,20 +1227,20 @@ const W = I({
1346
1227
  ],
1347
1228
  PREVIOUS: [
1348
1229
  {
1349
- guard: d,
1230
+ guard: c,
1350
1231
  target: "idle",
1351
- actions: a({
1352
- currentStepIndex: ({ context: e }) => Math.max(e.currentStepIndex - 1, 0),
1353
- currentStepId: ({ context: e }) => {
1354
- const t = Math.max(e.currentStepIndex - 1, 0);
1355
- return e.config.steps[t]?.id || "";
1232
+ actions: i({
1233
+ currentStepIndex: ({ context: t }) => Math.max(t.currentStepIndex - 1, 0),
1234
+ currentStepId: ({ context: t }) => {
1235
+ const e = Math.max(t.currentStepIndex - 1, 0);
1236
+ return t.config.steps[e]?.id || "";
1356
1237
  },
1357
1238
  pendingNavigation: null
1358
1239
  })
1359
1240
  },
1360
1241
  {
1361
1242
  target: "idle",
1362
- actions: a({
1243
+ actions: i({
1363
1244
  activeDialog: null,
1364
1245
  pendingNavigation: { type: "previous" }
1365
1246
  })
@@ -1367,28 +1248,28 @@ const W = I({
1367
1248
  ],
1368
1249
  GO_TO_STEP: [
1369
1250
  {
1370
- guard: d,
1251
+ guard: c,
1371
1252
  target: "idle",
1372
- actions: a({
1373
- currentStepIndex: ({ context: e, event: t }) => {
1374
- if (t.type !== "GO_TO_STEP")
1375
- return e.currentStepIndex;
1376
- const n = e.config.steps.findIndex(
1377
- (i) => i.id === t.stepId
1253
+ actions: i({
1254
+ currentStepIndex: ({ context: t, event: e }) => {
1255
+ if (e.type !== "GO_TO_STEP")
1256
+ return t.currentStepIndex;
1257
+ const n = t.config.steps.findIndex(
1258
+ (a) => a.id === e.stepId
1378
1259
  );
1379
- return n >= 0 ? n : e.currentStepIndex;
1260
+ return n >= 0 ? n : t.currentStepIndex;
1380
1261
  },
1381
- currentStepId: ({ context: e, event: t }) => t.type !== "GO_TO_STEP" ? e.currentStepId : t.stepId,
1262
+ currentStepId: ({ context: t, event: e }) => e.type !== "GO_TO_STEP" ? t.currentStepId : e.stepId,
1382
1263
  pendingNavigation: null
1383
1264
  })
1384
1265
  },
1385
1266
  {
1386
1267
  target: "idle",
1387
- actions: a({
1268
+ actions: i({
1388
1269
  activeDialog: null,
1389
- pendingNavigation: ({ event: e }) => ({
1270
+ pendingNavigation: ({ event: t }) => ({
1390
1271
  type: "step",
1391
- stepId: e.stepId
1272
+ stepId: t.stepId
1392
1273
  })
1393
1274
  })
1394
1275
  }
@@ -1401,19 +1282,19 @@ const W = I({
1401
1282
  always: [
1402
1283
  {
1403
1284
  // Validate save fields and create execution plan
1404
- guard: C,
1285
+ guard: _,
1405
1286
  target: "executingSaveActions",
1406
- actions: a({
1407
- saveState: ({ context: e }) => {
1408
- const t = u.createExecutionPlan(
1409
- e.config,
1287
+ actions: i({
1288
+ saveState: ({ context: t }) => {
1289
+ const e = l.createExecutionPlan(
1290
+ t.config,
1410
1291
  "save",
1411
- e.currentStepIndex,
1412
- e
1292
+ t.currentStepIndex,
1293
+ t
1413
1294
  );
1414
1295
  return {
1415
- ...e.saveState,
1416
- executionPlan: t
1296
+ ...t.saveState,
1297
+ executionPlan: e
1417
1298
  };
1418
1299
  }
1419
1300
  })
@@ -1422,9 +1303,9 @@ const W = I({
1422
1303
  // Validation failed or no actions to execute
1423
1304
  target: "idle",
1424
1305
  actions: [
1425
- a({
1426
- saveState: ({ context: e }) => ({
1427
- ...e.saveState,
1306
+ i({
1307
+ saveState: ({ context: t }) => ({
1308
+ ...t.saveState,
1428
1309
  saveInProgress: !1,
1429
1310
  saveInitiator: null,
1430
1311
  savingSection: null,
@@ -1439,15 +1320,15 @@ const W = I({
1439
1320
  ]
1440
1321
  },
1441
1322
  executingSaveActions: {
1442
- entry: [m],
1323
+ entry: [f],
1443
1324
  on: {
1444
1325
  TRIGGER_COMPONENT_ACTION: {
1445
- actions: [p]
1326
+ actions: [d]
1446
1327
  },
1447
1328
  SHOW_ACTION_DIALOG: {
1448
1329
  target: "awaitingVerification",
1449
- actions: a({
1450
- activeDialog: ({ event: e }) => e.dialogConfig
1330
+ actions: i({
1331
+ activeDialog: ({ event: t }) => t.dialogConfig
1451
1332
  })
1452
1333
  },
1453
1334
  SAVE_ACTIONS_COMPLETE: {
@@ -1460,20 +1341,20 @@ const W = I({
1460
1341
  DIALOG_VERIFIED: {
1461
1342
  target: "completingSave",
1462
1343
  actions: [
1463
- a({
1344
+ i({
1464
1345
  activeDialog: null,
1465
- saveState: ({ context: e }) => ({
1466
- ...e.saveState,
1346
+ saveState: ({ context: t }) => ({
1347
+ ...t.saveState,
1467
1348
  completedVerifications: [
1468
- ...e.saveState.completedVerifications,
1469
- `${e.activeDialog?.templateMetadata?.componentId || "unknown"}`
1349
+ ...t.saveState.completedVerifications,
1350
+ `${t.activeDialog?.templateMetadata?.componentId || "unknown"}`
1470
1351
  ]
1471
1352
  })
1472
1353
  }),
1473
- ({ context: e, self: t }) => {
1474
- e.saveState.pendingVerifications.length <= e.saveState.completedVerifications.length + 1 && t.send({
1354
+ ({ context: t, self: e }) => {
1355
+ t.saveState.pendingVerifications.length <= t.saveState.completedVerifications.length + 1 && e.send({
1475
1356
  type: "SAVE_ACTIONS_COMPLETE",
1476
- sectionId: e.saveState.savingSection || "",
1357
+ sectionId: t.saveState.savingSection || "",
1477
1358
  results: {}
1478
1359
  });
1479
1360
  }
@@ -1482,10 +1363,10 @@ const W = I({
1482
1363
  DIALOG_CANCELLED: {
1483
1364
  target: "idle",
1484
1365
  actions: [
1485
- a({
1366
+ i({
1486
1367
  activeDialog: null,
1487
- saveState: ({ context: e }) => ({
1488
- ...e.saveState,
1368
+ saveState: ({ context: t }) => ({
1369
+ ...t.saveState,
1489
1370
  saveInProgress: !1,
1490
1371
  saveInitiator: null,
1491
1372
  savingSection: null,
@@ -1504,12 +1385,12 @@ const W = I({
1504
1385
  always: [
1505
1386
  {
1506
1387
  // Handle section mode transitions after successful save
1507
- guard: _,
1388
+ guard: v,
1508
1389
  target: "idle",
1509
1390
  actions: [
1510
- a({
1511
- saveState: ({ context: e }) => ({
1512
- ...e.saveState,
1391
+ i({
1392
+ saveState: ({ context: t }) => ({
1393
+ ...t.saveState,
1513
1394
  saveInProgress: !1,
1514
1395
  saveInitiator: null,
1515
1396
  savingSection: null,
@@ -1525,9 +1406,9 @@ const W = I({
1525
1406
  // Default completion
1526
1407
  target: "idle",
1527
1408
  actions: [
1528
- a({
1529
- saveState: ({ context: e }) => ({
1530
- ...e.saveState,
1409
+ i({
1410
+ saveState: ({ context: t }) => ({
1411
+ ...t.saveState,
1531
1412
  saveInProgress: !1,
1532
1413
  saveInitiator: null,
1533
1414
  savingSection: null,
@@ -1537,19 +1418,19 @@ const W = I({
1537
1418
  executionPlan: null
1538
1419
  })
1539
1420
  }),
1540
- ({ context: e, self: t }) => {
1541
- if (e.saveState.saveInitiator === "navigation" && e.pendingNavigation)
1542
- switch (e.pendingNavigation.type) {
1421
+ ({ context: t, self: e }) => {
1422
+ if (t.saveState.saveInitiator === "navigation" && t.pendingNavigation)
1423
+ switch (t.pendingNavigation.type) {
1543
1424
  case "next":
1544
- t.send({ type: "NEXT" });
1425
+ e.send({ type: "NEXT" });
1545
1426
  break;
1546
1427
  case "previous":
1547
- t.send({ type: "PREVIOUS" });
1428
+ e.send({ type: "PREVIOUS" });
1548
1429
  break;
1549
1430
  case "step":
1550
- t.send({
1431
+ e.send({
1551
1432
  type: "GO_TO_STEP",
1552
- stepId: e.pendingNavigation.stepId
1433
+ stepId: t.pendingNavigation.stepId
1553
1434
  });
1554
1435
  break;
1555
1436
  }
@@ -1561,5 +1442,5 @@ const W = I({
1561
1442
  }
1562
1443
  });
1563
1444
  export {
1564
- W as formMachine
1445
+ x as formMachine
1565
1446
  };