@arkcit/engine 0.3.0

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 (42) hide show
  1. package/README.md +68 -0
  2. package/dist/UIEngine.d.ts +6 -0
  3. package/dist/UIEngine.js +3235 -0
  4. package/dist/bindings.d.ts +8 -0
  5. package/dist/bindings.js +146 -0
  6. package/dist/components/index.d.ts +17 -0
  7. package/dist/components/index.js +143 -0
  8. package/dist/core/index.d.ts +4 -0
  9. package/dist/core/index.js +9 -0
  10. package/dist/form/engineFormValidation.d.ts +2 -0
  11. package/dist/form/engineFormValidation.js +241 -0
  12. package/dist/form.d.ts +67 -0
  13. package/dist/form.js +241 -0
  14. package/dist/index.d.ts +15 -0
  15. package/dist/index.js +3336 -0
  16. package/dist/layout.d.ts +6 -0
  17. package/dist/layout.js +82 -0
  18. package/dist/preview/index.d.ts +63 -0
  19. package/dist/preview/index.js +1514 -0
  20. package/dist/react-web/index.d.ts +8 -0
  21. package/dist/react-web/index.js +3246 -0
  22. package/dist/registry.d.ts +2 -0
  23. package/dist/registry.js +0 -0
  24. package/dist/render-layer/index.d.ts +1 -0
  25. package/dist/render-layer/index.js +13 -0
  26. package/dist/renderStudioForm-CPQEzvT7.d.ts +75 -0
  27. package/dist/renderers/index.d.ts +8 -0
  28. package/dist/renderers/index.js +1570 -0
  29. package/dist/runtime/index.d.ts +1 -0
  30. package/dist/runtime/index.js +0 -0
  31. package/dist/schema/index.d.ts +1 -0
  32. package/dist/schema/index.js +0 -0
  33. package/dist/studio-bridge/index.d.ts +501 -0
  34. package/dist/studio-bridge/index.js +2840 -0
  35. package/dist/studioProps.d.ts +8 -0
  36. package/dist/studioProps.js +97 -0
  37. package/dist/types-9TZ2lQDP.d.ts +60 -0
  38. package/dist/types-CyAE6ZLH.d.ts +19 -0
  39. package/dist/types.d.ts +16 -0
  40. package/dist/types.js +0 -0
  41. package/dist/wizardEditingHandlers-D50tR-6n.d.ts +163 -0
  42. package/package.json +160 -0
@@ -0,0 +1,1514 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+
21
+ // src/preview/react/index.ts
22
+ import {
23
+ configurePreviewLinkBehavior,
24
+ materializeBoundTable,
25
+ resolveBoundTableData
26
+ } from "@arkcit/engine-react";
27
+
28
+ // src/layout/nodeLayout.ts
29
+ var toPositiveNumber = (value) => {
30
+ const numeric = Number(value);
31
+ if (!Number.isFinite(numeric) || numeric <= 0) return void 0;
32
+ return numeric;
33
+ };
34
+ var toColSpan = (value) => {
35
+ const numeric = Number(value);
36
+ if (!Number.isInteger(numeric) || numeric < 1 || numeric > 12) return void 0;
37
+ return numeric;
38
+ };
39
+ var toCardSection = (value) => {
40
+ if (value === "header" || value === "body" || value === "footer") return value;
41
+ return void 0;
42
+ };
43
+ var readNodeLayout = (props) => {
44
+ var _a, _b, _c, _d, _e, _f, _g;
45
+ if (!props) return {};
46
+ const rawLayout = props.layout && typeof props.layout === "object" && !Array.isArray(props.layout) ? props.layout : {};
47
+ return {
48
+ widthPct: toPositiveNumber((_a = rawLayout.widthPct) != null ? _a : props.__studioWidthPct),
49
+ heightPct: toPositiveNumber((_b = rawLayout.heightPct) != null ? _b : props.__studioHeightPct),
50
+ heightPx: toPositiveNumber((_c = rawLayout.heightPx) != null ? _c : props.__studioHeightPx),
51
+ colSpan: toColSpan((_d = rawLayout.colSpan) != null ? _d : props.__studioColSpan),
52
+ wrapperClassName: String(
53
+ (_f = (_e = rawLayout.wrapperClassName) != null ? _e : props.__studioWrapperClassName) != null ? _f : ""
54
+ ).trim(),
55
+ cardSection: toCardSection((_g = rawLayout.cardSection) != null ? _g : props.__studioCardSection)
56
+ };
57
+ };
58
+
59
+ // src/runtime/bindings.ts
60
+ var DANGEROUS_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
61
+ var MISSING_TRANSLATION_FALLBACK = "Lorem ipsum dolor sit amet. (fallback)";
62
+ var MISSING_REF_FALLBACK = "Lorem ipsum dolor sit amet. (fallback)";
63
+ var isPlainObject = (value) => {
64
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
65
+ const prototype = Object.getPrototypeOf(value);
66
+ return prototype === Object.prototype || prototype === null;
67
+ };
68
+ var isReactElementLike = (value) => isPlainObject(value) && typeof value.$$typeof === "symbol" && "props" in value;
69
+ var isTranslationValue = (value) => isPlainObject(value) && typeof value.$t === "string";
70
+ var isRefValue = (value) => isPlainObject(value) && typeof value.$ref === "string";
71
+ var isExprValue = (value) => isPlainObject(value) && typeof value.$expr === "string";
72
+ var parseStructuredString = (value) => {
73
+ if (typeof value !== "string") return value;
74
+ const trimmed = value.trim();
75
+ if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) return value;
76
+ try {
77
+ const parsed = JSON.parse(trimmed);
78
+ if (!isPlainObject(parsed)) return value;
79
+ if ((typeof parsed.$ref === "string" || typeof parsed.$t === "string") && Object.keys(parsed).length >= 1) {
80
+ return parsed;
81
+ }
82
+ return value;
83
+ } catch (e) {
84
+ return value;
85
+ }
86
+ };
87
+ var resolveUIValue = (value, runtime) => {
88
+ const normalizedValue = parseStructuredString(value);
89
+ if (isTranslationValue(normalizedValue)) {
90
+ const fallback = typeof normalizedValue.defaultValue === "string" && normalizedValue.defaultValue.trim() ? normalizedValue.defaultValue : normalizedValue.$t;
91
+ if (!runtime.t) return fallback || MISSING_TRANSLATION_FALLBACK;
92
+ const translated = runtime.t(normalizedValue.$t, normalizedValue.values);
93
+ if (typeof translated !== "string") return fallback || MISSING_TRANSLATION_FALLBACK;
94
+ if (!translated.trim()) return fallback || MISSING_TRANSLATION_FALLBACK;
95
+ if (translated === normalizedValue.$t) return fallback || MISSING_TRANSLATION_FALLBACK;
96
+ return translated;
97
+ }
98
+ if (isRefValue(normalizedValue)) {
99
+ const resolved = runtime.get(normalizedValue.$ref);
100
+ if (resolved == null) return MISSING_REF_FALLBACK;
101
+ if (typeof resolved === "string" && !resolved.trim()) return MISSING_REF_FALLBACK;
102
+ return resolved;
103
+ }
104
+ if (isExprValue(normalizedValue)) {
105
+ return void 0;
106
+ }
107
+ if (Array.isArray(normalizedValue)) {
108
+ return normalizedValue.map((item) => resolveUIValue(item, runtime));
109
+ }
110
+ if (isReactElementLike(normalizedValue)) {
111
+ return normalizedValue;
112
+ }
113
+ if (isPlainObject(normalizedValue)) {
114
+ const next = {};
115
+ Object.entries(normalizedValue).forEach(([key, childValue]) => {
116
+ if (DANGEROUS_KEYS.has(key)) return;
117
+ next[key] = resolveUIValue(childValue, runtime);
118
+ });
119
+ return next;
120
+ }
121
+ return normalizedValue;
122
+ };
123
+
124
+ // src/studio-bridge/preview-form/previewFormRenderer.tsx
125
+ import React from "react";
126
+
127
+ // src/form/engineFormValidation.ts
128
+ var EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
129
+ var isEmptyValue = (value) => {
130
+ if (value == null) return true;
131
+ if (typeof value === "string") return value.trim().length === 0;
132
+ if (Array.isArray(value)) return value.length === 0;
133
+ return false;
134
+ };
135
+ var toNumber = (value) => {
136
+ if (typeof value === "number" && Number.isFinite(value)) return value;
137
+ if (typeof value === "string") {
138
+ const parsed = Number(value);
139
+ return Number.isFinite(parsed) ? parsed : null;
140
+ }
141
+ return null;
142
+ };
143
+ var defaultDeclarativeValidatorRegistry = {
144
+ required: (value) => isEmptyValue(value) ? { code: "required" } : null,
145
+ minLength: (value, params) => {
146
+ var _a;
147
+ if (isEmptyValue(value)) return null;
148
+ const min = toNumber((_a = params == null ? void 0 : params.min) != null ? _a : params == null ? void 0 : params.value);
149
+ if (min == null) return null;
150
+ return String(value).length < min ? { code: "minLength", params: { min } } : null;
151
+ },
152
+ maxLength: (value, params) => {
153
+ var _a;
154
+ if (isEmptyValue(value)) return null;
155
+ const max = toNumber((_a = params == null ? void 0 : params.max) != null ? _a : params == null ? void 0 : params.value);
156
+ if (max == null) return null;
157
+ return String(value).length > max ? { code: "maxLength", params: { max } } : null;
158
+ },
159
+ email: (value) => {
160
+ if (isEmptyValue(value)) return null;
161
+ return EMAIL_REGEX.test(String(value)) ? null : { code: "email" };
162
+ },
163
+ pattern: (value, params) => {
164
+ var _a, _b;
165
+ if (isEmptyValue(value)) return null;
166
+ const rawPattern = String((_b = (_a = params == null ? void 0 : params.pattern) != null ? _a : params == null ? void 0 : params.value) != null ? _b : "").trim();
167
+ if (!rawPattern) return null;
168
+ try {
169
+ const regex = new RegExp(rawPattern);
170
+ return regex.test(String(value)) ? null : { code: "pattern", params: { pattern: rawPattern } };
171
+ } catch (e) {
172
+ return { code: "pattern" };
173
+ }
174
+ }
175
+ };
176
+ var buildLegacyValidators = (field) => {
177
+ var _a, _b, _c;
178
+ const validators = [];
179
+ if (field.required) {
180
+ validators.push({
181
+ id: `${String((_a = field.name) != null ? _a : "field")}:required`,
182
+ type: "required",
183
+ stopOnFailure: true
184
+ });
185
+ }
186
+ if (String((_b = field.pattern) != null ? _b : "").trim()) {
187
+ validators.push({
188
+ id: `${String((_c = field.name) != null ? _c : "field")}:pattern`,
189
+ type: "pattern",
190
+ params: { pattern: String(field.pattern) }
191
+ });
192
+ }
193
+ return validators;
194
+ };
195
+ var normalizeValidators = (field, options) => {
196
+ const explicit = Array.isArray(field.validators) ? field.validators : [];
197
+ if (explicit.length > 0) return explicit;
198
+ if (!(options == null ? void 0 : options.useLegacyFieldConstraints)) return [];
199
+ return buildLegacyValidators(field);
200
+ };
201
+ var toIssueArray = (issue) => {
202
+ if (!issue) return [];
203
+ return Array.isArray(issue) ? issue : [issue];
204
+ };
205
+ var validateFieldWithConfig = (field, value, values, config, registry) => {
206
+ if (config.enabled === false) return [];
207
+ const validate = registry[config.type];
208
+ if (!validate) return [];
209
+ const baseIssues = toIssueArray(
210
+ validate(value, config.params, {
211
+ field,
212
+ values
213
+ })
214
+ );
215
+ return baseIssues.map((baseIssue) => {
216
+ var _a, _b, _c, _d, _e;
217
+ return {
218
+ field: String((_a = field.name) != null ? _a : ""),
219
+ validatorId: config.id || baseIssue.validatorId,
220
+ code: baseIssue.code,
221
+ messageKey: (_b = baseIssue.messageKey) != null ? _b : config.messageKey,
222
+ message: (_c = baseIssue.message) != null ? _c : config.message,
223
+ params: __spreadValues(__spreadValues({}, (_d = config.params) != null ? _d : {}), (_e = baseIssue.params) != null ? _e : {})
224
+ };
225
+ });
226
+ };
227
+ var resolveIssueMessage = (issue, t) => {
228
+ const defaultMessageByCode = () => {
229
+ var _a, _b, _c, _d, _e, _f;
230
+ switch (issue.code) {
231
+ case "required":
232
+ return "This field is required";
233
+ case "email":
234
+ return "Invalid email address";
235
+ case "pattern":
236
+ return "Invalid format";
237
+ case "minLength": {
238
+ const min = (_c = (_a = issue.params) == null ? void 0 : _a.min) != null ? _c : (_b = issue.params) == null ? void 0 : _b.value;
239
+ return min != null ? `Minimum ${String(min)} characters` : "Value is too short";
240
+ }
241
+ case "maxLength": {
242
+ const max = (_f = (_d = issue.params) == null ? void 0 : _d.max) != null ? _f : (_e = issue.params) == null ? void 0 : _e.value;
243
+ return max != null ? `Maximum ${String(max)} characters` : "Value is too long";
244
+ }
245
+ default:
246
+ return void 0;
247
+ }
248
+ };
249
+ if (issue.messageKey && t) {
250
+ const translated = t(issue.messageKey, issue.params);
251
+ if (typeof translated === "string" && translated.trim().length > 0) {
252
+ return translated;
253
+ }
254
+ }
255
+ if (issue.message && issue.message.trim().length > 0) return issue.message;
256
+ if (issue.messageKey && issue.messageKey.trim().length > 0) return issue.messageKey;
257
+ return defaultMessageByCode();
258
+ };
259
+ var validateFormValues = (fields, values, options) => {
260
+ var _a;
261
+ const mergedRegistry = __spreadValues(__spreadValues({}, defaultDeclarativeValidatorRegistry), (_a = options == null ? void 0 : options.registry) != null ? _a : {});
262
+ const issues = [];
263
+ fields.forEach((field) => {
264
+ var _a2;
265
+ const fieldName = String((_a2 = field.name) != null ? _a2 : "").trim();
266
+ if (!fieldName) return;
267
+ const fieldValue = values[fieldName];
268
+ const validators = normalizeValidators(field, options);
269
+ if (validators.length === 0) return;
270
+ for (const validatorConfig of validators) {
271
+ const fieldIssues = validateFieldWithConfig(
272
+ field,
273
+ fieldValue,
274
+ values,
275
+ validatorConfig,
276
+ mergedRegistry
277
+ );
278
+ if (fieldIssues.length > 0) {
279
+ issues.push(...fieldIssues);
280
+ if (validatorConfig.stopOnFailure) break;
281
+ }
282
+ }
283
+ });
284
+ const errors = {};
285
+ issues.forEach((issue) => {
286
+ if (errors[issue.field]) return;
287
+ errors[issue.field] = resolveIssueMessage(issue, options == null ? void 0 : options.t);
288
+ });
289
+ return { issues, errors };
290
+ };
291
+
292
+ // src/utils/formStudio.ts
293
+ var getLayoutRecord = (props) => {
294
+ if (!props) return {};
295
+ const layout = props.layout;
296
+ if (!layout || typeof layout !== "object" || Array.isArray(layout)) {
297
+ return {};
298
+ }
299
+ return layout;
300
+ };
301
+ var normalizeStudioFormChild = (child) => {
302
+ var _a, _b, _c, _d, _e;
303
+ const childProps = (_a = child.props) != null ? _a : {};
304
+ const childLayout = getLayoutRecord(childProps);
305
+ if (child.type === "__studio_form_field") {
306
+ return __spreadProps(__spreadValues({}, child), {
307
+ type: "FormField",
308
+ props: __spreadProps(__spreadValues({}, childProps), {
309
+ layout: __spreadProps(__spreadValues({}, childLayout), {
310
+ formRole: "field"
311
+ })
312
+ })
313
+ });
314
+ }
315
+ if (child.type === "__studio_form_title") {
316
+ return __spreadProps(__spreadValues({}, child), {
317
+ type: "Text",
318
+ props: __spreadProps(__spreadValues({}, childProps), {
319
+ layout: __spreadProps(__spreadValues({}, childLayout), {
320
+ formRole: "title"
321
+ })
322
+ })
323
+ });
324
+ }
325
+ if (child.type === "__studio_form_submit") {
326
+ return __spreadProps(__spreadValues({}, child), {
327
+ type: "Button",
328
+ props: __spreadProps(__spreadValues({}, childProps), {
329
+ intent: String((_b = childProps.intent) != null ? _b : "primary"),
330
+ variant: String((_c = childProps.variant) != null ? _c : "solid"),
331
+ layout: __spreadProps(__spreadValues({}, childLayout), {
332
+ formRole: "submit"
333
+ })
334
+ })
335
+ });
336
+ }
337
+ if (child.type === "__studio_form_reset") {
338
+ return __spreadProps(__spreadValues({}, child), {
339
+ type: "Button",
340
+ props: __spreadProps(__spreadValues({}, childProps), {
341
+ intent: String((_d = childProps.intent) != null ? _d : "neutral"),
342
+ variant: String((_e = childProps.variant) != null ? _e : "outline"),
343
+ layout: __spreadProps(__spreadValues({}, childLayout), {
344
+ formRole: "reset"
345
+ })
346
+ })
347
+ });
348
+ }
349
+ return child;
350
+ };
351
+ var getStudioFormChildRole = (child) => {
352
+ var _a, _b;
353
+ if (child.type === "__studio_form_field") return "field";
354
+ if (child.type === "__studio_form_title") return "title";
355
+ if (child.type === "__studio_form_submit") return "submit";
356
+ if (child.type === "__studio_form_reset") return "reset";
357
+ const layout = getLayoutRecord(
358
+ (_a = child.props) != null ? _a : {}
359
+ );
360
+ return String((_b = layout.formRole) != null ? _b : "").trim();
361
+ };
362
+ var buildFormFieldConfig = (rawProps, nestedField = {}) => {
363
+ var _a, _b, _c, _d;
364
+ const fieldName = String((_b = (_a = rawProps.name) != null ? _a : nestedField.name) != null ? _b : "").trim();
365
+ return __spreadProps(__spreadValues(__spreadValues({}, nestedField), rawProps), {
366
+ name: fieldName,
367
+ label: String((_d = (_c = rawProps.label) != null ? _c : nestedField.label) != null ? _d : fieldName)
368
+ });
369
+ };
370
+ var buildWizardFieldConfig = (rawProps, nestedField) => {
371
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
372
+ const name = String((_b = (_a = rawProps.name) != null ? _a : nestedField.name) != null ? _b : "").trim();
373
+ return {
374
+ name,
375
+ label: String((_d = (_c = rawProps.label) != null ? _c : nestedField.label) != null ? _d : name || "Field"),
376
+ type: (_e = rawProps.type) != null ? _e : nestedField.type,
377
+ required: Boolean((_g = (_f = rawProps.required) != null ? _f : nestedField.required) != null ? _g : false),
378
+ pattern: rawProps.pattern != null ? String(rawProps.pattern) : nestedField.pattern != null ? String(nestedField.pattern) : void 0,
379
+ placeholder: (_h = rawProps.placeholder) != null ? _h : nestedField.placeholder,
380
+ validators: Array.isArray(rawProps.validators) && rawProps.validators.length > 0 ? rawProps.validators : Array.isArray(nestedField.validators) && nestedField.validators.length > 0 ? nestedField.validators : void 0,
381
+ options: (_i = rawProps.options) != null ? _i : nestedField.options,
382
+ helperText: (_j = rawProps.helperText) != null ? _j : nestedField.helperText,
383
+ defaultValue: (_k = rawProps.defaultValue) != null ? _k : nestedField.defaultValue,
384
+ rows: (_l = rawProps.rows) != null ? _l : nestedField.rows,
385
+ accept: (_m = rawProps.accept) != null ? _m : nestedField.accept
386
+ };
387
+ };
388
+
389
+ // src/studio-bridge/preview-form/previewFormState.ts
390
+ var resolveStudioFormNextValues = ({
391
+ formValues,
392
+ fieldName,
393
+ nextValue
394
+ }) => __spreadProps(__spreadValues({}, formValues), {
395
+ [fieldName]: nextValue
396
+ });
397
+ var resolveStudioFormResetValues = (normalizedFormFields) => normalizedFormFields.reduce((accumulator, field) => {
398
+ var _a, _b;
399
+ const fieldName = String((_a = field.name) != null ? _a : "").trim();
400
+ if (!fieldName) return accumulator;
401
+ accumulator[fieldName] = (_b = field.defaultValue) != null ? _b : "";
402
+ return accumulator;
403
+ }, {});
404
+ var patchStudioFormFieldNode = ({
405
+ child,
406
+ formValues,
407
+ formErrors,
408
+ formDict,
409
+ formLoaderType,
410
+ fieldOnChange
411
+ }) => {
412
+ var _a, _b, _c;
413
+ const rawChildProps = (_a = child.props) != null ? _a : {};
414
+ const childLayout = readNodeLayout(rawChildProps);
415
+ const rawLayout = rawChildProps.layout && typeof rawChildProps.layout === "object" && !Array.isArray(rawChildProps.layout) ? __spreadValues({}, rawChildProps.layout) : {};
416
+ const existingWrapperClassName = String((_b = rawLayout.wrapperClassName) != null ? _b : "").trim();
417
+ rawLayout.wrapperClassName = [existingWrapperClassName, "w-full", "max-w-full"].filter(Boolean).join(" ");
418
+ delete rawLayout.widthPct;
419
+ delete rawLayout.heightPct;
420
+ delete rawLayout.heightPx;
421
+ const fieldBasis = childLayout.widthPct !== null ? `${childLayout.widthPct}%` : "100%";
422
+ const nestedField = rawChildProps.field && typeof rawChildProps.field === "object" && !Array.isArray(rawChildProps.field) ? rawChildProps.field : {};
423
+ const fieldConfig = buildFormFieldConfig(rawChildProps, nestedField);
424
+ const fieldName = String((_c = fieldConfig.name) != null ? _c : "").trim();
425
+ const value = fieldName && fieldName in formValues ? formValues[fieldName] : rawChildProps.defaultValue;
426
+ const patchedFieldNode = __spreadProps(__spreadValues({}, child), {
427
+ props: __spreadValues(__spreadProps(__spreadValues({}, rawChildProps), {
428
+ layout: rawLayout,
429
+ field: fieldConfig,
430
+ value,
431
+ error: fieldName ? formErrors[fieldName] : void 0,
432
+ onChange: fieldOnChange,
433
+ dict: formDict
434
+ }), formLoaderType !== void 0 ? { loaderType: formLoaderType } : {})
435
+ });
436
+ return {
437
+ patchedFieldNode,
438
+ fieldBasis
439
+ };
440
+ };
441
+
442
+ // src/studio-bridge/preview-form/previewFormStructure.ts
443
+ var DEFAULT_FORM_DICT = {
444
+ submit: "Submit",
445
+ reset: "Reset",
446
+ loading: "Loading...",
447
+ success: "Saved",
448
+ search: "Search...",
449
+ noResultToShow: "No result"
450
+ };
451
+ var resolveStudioFormStructure = ({
452
+ componentProps,
453
+ visibleChildren
454
+ }) => {
455
+ const normalizedChildren = visibleChildren.map((child) => normalizeStudioFormChild(child));
456
+ const titleNode = normalizedChildren.find((child) => getStudioFormChildRole(child) === "title");
457
+ const fieldNodes = normalizedChildren.filter((child) => getStudioFormChildRole(child) === "field");
458
+ const submitNode = normalizedChildren.find((child) => getStudioFormChildRole(child) === "submit");
459
+ const resetNode = normalizedChildren.find((child) => getStudioFormChildRole(child) === "reset");
460
+ const externalChildren = normalizedChildren.filter((child) => {
461
+ const role = getStudioFormChildRole(child);
462
+ return role !== "title" && role !== "field" && role !== "submit" && role !== "reset";
463
+ });
464
+ const formValues = componentProps.values && typeof componentProps.values === "object" && !Array.isArray(componentProps.values) ? componentProps.values : {};
465
+ const formErrors = componentProps.errors && typeof componentProps.errors === "object" && !Array.isArray(componentProps.errors) ? componentProps.errors : {};
466
+ const formDict = componentProps.dict && typeof componentProps.dict === "object" && !Array.isArray(componentProps.dict) ? componentProps.dict : DEFAULT_FORM_DICT;
467
+ const normalizedFormFields = fieldNodes.map((child) => {
468
+ var _a;
469
+ const rawChildProps = (_a = child.props) != null ? _a : {};
470
+ const nestedField = rawChildProps.field && typeof rawChildProps.field === "object" && !Array.isArray(rawChildProps.field) ? rawChildProps.field : {};
471
+ return buildFormFieldConfig(rawChildProps, nestedField);
472
+ }).filter((field) => {
473
+ var _a;
474
+ return String((_a = field.name) != null ? _a : "").trim().length > 0;
475
+ });
476
+ return {
477
+ normalizedChildren,
478
+ titleNode,
479
+ fieldNodes,
480
+ submitNode,
481
+ resetNode,
482
+ externalChildren,
483
+ normalizedFormFields,
484
+ formValues,
485
+ formErrors,
486
+ formDict,
487
+ formLoaderType: componentProps.loaderType
488
+ };
489
+ };
490
+
491
+ // src/studio-bridge/preview-form/previewFormRenderer.tsx
492
+ import { jsx, jsxs } from "react/jsx-runtime";
493
+ var materializePreviewForm = ({
494
+ node,
495
+ componentProps,
496
+ visibleChildren,
497
+ runtime,
498
+ onInlineTextEdit,
499
+ captureFieldFocus,
500
+ renderSafeNode
501
+ }) => {
502
+ var _a, _b, _c, _d, _e, _f, _g;
503
+ const {
504
+ titleNode,
505
+ fieldNodes,
506
+ submitNode,
507
+ resetNode,
508
+ externalChildren,
509
+ normalizedFormFields,
510
+ formValues,
511
+ formErrors,
512
+ formDict,
513
+ formLoaderType
514
+ } = resolveStudioFormStructure({
515
+ componentProps,
516
+ visibleChildren
517
+ });
518
+ if (!(fieldNodes.length > 0 || titleNode || submitNode || resetNode)) {
519
+ return null;
520
+ }
521
+ const validateAndSetErrors = (nextValues) => {
522
+ const validation = validateFormValues(normalizedFormFields, nextValues, {
523
+ t: runtime.t,
524
+ useLegacyFieldConstraints: true
525
+ });
526
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "errors", validation.errors);
527
+ return validation;
528
+ };
529
+ const fieldOnChange = (event) => {
530
+ var _a2;
531
+ captureFieldFocus(event.target);
532
+ const fieldName = String((_a2 = event.target.name) != null ? _a2 : "").trim();
533
+ if (!fieldName) return;
534
+ const target = event.target;
535
+ const nextValue = target.type === "checkbox" ? Boolean(target.checked) : event.target.value;
536
+ const nextValues = resolveStudioFormNextValues({
537
+ formValues,
538
+ fieldName,
539
+ nextValue
540
+ });
541
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "values", nextValues);
542
+ validateAndSetErrors(nextValues);
543
+ };
544
+ const openInlineEditorForFormDictProp = (propName, fallbackValue) => {
545
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, propName, fallbackValue);
546
+ };
547
+ const openInlineEditorForFormNodeProp = (targetNodeId, fallbackValue) => {
548
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(targetNodeId, "children", fallbackValue);
549
+ };
550
+ return /* @__PURE__ */ jsxs("div", { className: "mx-auto mt-10 w-full min-w-0 rounded-2xl border border-border bg-background p-6 shadow-sm", children: [
551
+ titleNode ? /* @__PURE__ */ jsx("div", { className: "mb-6 text-center", children: renderSafeNode(__spreadProps(__spreadValues({}, titleNode), {
552
+ type: "H3",
553
+ props: __spreadProps(__spreadValues({}, (_a = titleNode.props) != null ? _a : {}), {
554
+ className: "text-center text-2xl font-semibold text-foreground",
555
+ layout: __spreadProps(__spreadValues({}, getLayoutRecord(
556
+ (_b = titleNode.props) != null ? _b : {}
557
+ )), {
558
+ formRole: "title"
559
+ })
560
+ })
561
+ })) }) : /* @__PURE__ */ jsx("h3", { className: "mb-6 text-center text-2xl font-semibold text-foreground", children: String((_c = componentProps.title) != null ? _c : "Form") }),
562
+ /* @__PURE__ */ jsxs(
563
+ "form",
564
+ {
565
+ className: "flex flex-wrap items-start gap-x-3 gap-y-3",
566
+ role: "form",
567
+ onSubmit: (event) => {
568
+ event.preventDefault();
569
+ const validation = validateAndSetErrors(formValues);
570
+ if (Object.keys(validation.errors).length > 0) return;
571
+ },
572
+ children: [
573
+ fieldNodes.map((child) => {
574
+ const { patchedFieldNode, fieldBasis } = patchStudioFormFieldNode({
575
+ child,
576
+ formValues,
577
+ formErrors,
578
+ formDict,
579
+ formLoaderType,
580
+ fieldOnChange
581
+ });
582
+ return /* @__PURE__ */ jsx("div", { className: "contents", children: /* @__PURE__ */ jsx("div", { style: { flex: `0 0 ${fieldBasis}`, maxWidth: fieldBasis }, children: /* @__PURE__ */ jsx("div", { className: "min-w-0", children: renderSafeNode(patchedFieldNode) }) }) }, child.id);
583
+ }),
584
+ submitNode || resetNode ? /* @__PURE__ */ jsxs("div", { className: "basis-full flex flex-wrap justify-end gap-3 py-4", children: [
585
+ submitNode ? renderSafeNode(__spreadProps(__spreadValues({}, submitNode), {
586
+ props: __spreadProps(__spreadValues({}, (_d = submitNode.props) != null ? _d : {}), {
587
+ type: "submit",
588
+ onDoubleClick: (event) => {
589
+ var _a2, _b2, _c2;
590
+ event.preventDefault();
591
+ event.stopPropagation();
592
+ openInlineEditorForFormNodeProp(
593
+ submitNode.id,
594
+ String(
595
+ (_c2 = (_b2 = (_a2 = submitNode.props) == null ? void 0 : _a2.children) != null ? _b2 : formDict.submit) != null ? _c2 : "Submit"
596
+ )
597
+ );
598
+ }
599
+ })
600
+ })) : null,
601
+ resetNode ? renderSafeNode(__spreadProps(__spreadValues({}, resetNode), {
602
+ props: __spreadProps(__spreadValues({}, (_e = resetNode.props) != null ? _e : {}), {
603
+ type: "button",
604
+ onClick: () => {
605
+ const resetValues = resolveStudioFormResetValues(normalizedFormFields);
606
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "values", resetValues);
607
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "errors", {});
608
+ },
609
+ onDoubleClick: (event) => {
610
+ var _a2, _b2, _c2;
611
+ event.preventDefault();
612
+ event.stopPropagation();
613
+ openInlineEditorForFormNodeProp(
614
+ resetNode.id,
615
+ String(
616
+ (_c2 = (_b2 = (_a2 = resetNode.props) == null ? void 0 : _a2.children) != null ? _b2 : formDict.reset) != null ? _c2 : "Reset"
617
+ )
618
+ );
619
+ }
620
+ })
621
+ })) : null
622
+ ] }) : componentProps.onSubmit || componentProps.onReset ? /* @__PURE__ */ jsxs("div", { className: "basis-full flex flex-wrap justify-end gap-3 py-4", children: [
623
+ componentProps.onSubmit ? /* @__PURE__ */ jsx(
624
+ "button",
625
+ {
626
+ type: "submit",
627
+ className: "inline-flex items-center justify-center rounded-md border border-primary bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",
628
+ onDoubleClick: (event) => {
629
+ var _a2;
630
+ event.preventDefault();
631
+ event.stopPropagation();
632
+ openInlineEditorForFormDictProp("dict.submit", String((_a2 = formDict.submit) != null ? _a2 : "Submit"));
633
+ },
634
+ children: String((_f = formDict.submit) != null ? _f : "Submit")
635
+ }
636
+ ) : null,
637
+ componentProps.onReset ? /* @__PURE__ */ jsx(
638
+ "button",
639
+ {
640
+ type: "button",
641
+ className: "inline-flex items-center justify-center rounded-md border border-border bg-background px-4 py-2 text-sm font-medium text-foreground",
642
+ onClick: () => {
643
+ const resetValues = resolveStudioFormResetValues(normalizedFormFields);
644
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "values", resetValues);
645
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(node.id, "errors", {});
646
+ },
647
+ onDoubleClick: (event) => {
648
+ var _a2;
649
+ event.preventDefault();
650
+ event.stopPropagation();
651
+ openInlineEditorForFormDictProp("dict.reset", String((_a2 = formDict.reset) != null ? _a2 : "Reset"));
652
+ },
653
+ children: String((_g = formDict.reset) != null ? _g : "Reset")
654
+ }
655
+ ) : null
656
+ ] }) : null,
657
+ externalChildren.map((child) => /* @__PURE__ */ jsx(React.Fragment, { children: renderSafeNode(child) }, child.id))
658
+ ]
659
+ }
660
+ )
661
+ ] });
662
+ };
663
+
664
+ // src/utils/navigationStudio.tsx
665
+ import {
666
+ buildAccordionItems,
667
+ buildExpandablePanelChildren
668
+ } from "@arkcit/engine-react";
669
+
670
+ // src/studio-bridge/preview-navigation/previewTabs.ts
671
+ var normalizeStudioTabsProps = (props) => {
672
+ var _a;
673
+ const rawTabs = Array.isArray(props.tabs) ? props.tabs : [];
674
+ const tabs = rawTabs.length ? rawTabs.map((tab, index) => {
675
+ var _a2, _b, _c;
676
+ const rawTab = tab && typeof tab === "object" && !Array.isArray(tab) ? tab : {};
677
+ const id = String((_a2 = rawTab.id) != null ? _a2 : `tab-${index + 1}`);
678
+ const title = (_c = (_b = rawTab.title) != null ? _b : rawTab.label) != null ? _c : `Tab ${index + 1}`;
679
+ return __spreadProps(__spreadValues({}, rawTab), {
680
+ id,
681
+ title,
682
+ label: title
683
+ });
684
+ }) : [
685
+ {
686
+ id: "overview",
687
+ title: "Overview",
688
+ label: "Overview",
689
+ content: "Overview content"
690
+ }
691
+ ];
692
+ const rawDict = props.dict && typeof props.dict === "object" && !Array.isArray(props.dict) ? props.dict : {};
693
+ const rawUrlSync = props.urlSync && typeof props.urlSync === "object" && !Array.isArray(props.urlSync) ? props.urlSync : null;
694
+ const rawNavigation = (rawUrlSync == null ? void 0 : rawUrlSync.navigation) && typeof rawUrlSync.navigation === "object" && !Array.isArray(rawUrlSync.navigation) ? rawUrlSync.navigation : null;
695
+ const normalizedUrlSync = rawNavigation && typeof rawNavigation.getSearch === "function" && typeof rawNavigation.replaceSearch === "function" ? __spreadProps(__spreadValues({}, rawUrlSync), {
696
+ navigation: rawNavigation
697
+ }) : void 0;
698
+ return __spreadProps(__spreadValues({}, props), {
699
+ tabs,
700
+ dict: __spreadProps(__spreadValues({}, rawDict), {
701
+ noContentYet: typeof rawDict.noContentYet === "string" && rawDict.noContentYet.trim().length > 0 ? rawDict.noContentYet : "No content yet"
702
+ }),
703
+ defaultActive: typeof props.defaultActive === "string" && props.defaultActive.trim().length > 0 ? props.defaultActive : String((_a = tabs[0].id) != null ? _a : "overview"),
704
+ keepMounted: typeof props.keepMounted === "boolean" ? props.keepMounted : true,
705
+ urlSync: normalizedUrlSync
706
+ });
707
+ };
708
+ var resolveStudioTabsContent = ({
709
+ tabItems,
710
+ rawChildren,
711
+ runtime,
712
+ renderChild,
713
+ normalizeRenderableChild
714
+ }) => {
715
+ const childrenByTabId = /* @__PURE__ */ new Map();
716
+ const unassignedChildren = [];
717
+ rawChildren.forEach((child) => {
718
+ var _a, _b, _c;
719
+ const childProps = (_a = child.props) != null ? _a : {};
720
+ const rawLayout = childProps.layout && typeof childProps.layout === "object" && !Array.isArray(childProps.layout) ? childProps.layout : {};
721
+ const tabIdFromLayout = (_b = rawLayout.tabId) != null ? _b : childProps.__studioTabId;
722
+ const resolvedTabId = resolveUIValue(tabIdFromLayout, runtime);
723
+ const normalizedTabId = String(resolvedTabId != null ? resolvedTabId : "").trim();
724
+ if (!normalizedTabId) {
725
+ unassignedChildren.push(child);
726
+ return;
727
+ }
728
+ const existing = (_c = childrenByTabId.get(normalizedTabId)) != null ? _c : [];
729
+ existing.push(child);
730
+ childrenByTabId.set(normalizedTabId, existing);
731
+ });
732
+ return tabItems.map((item, index) => {
733
+ var _a, _b, _c, _d;
734
+ const rawId = (_a = item.id) != null ? _a : `tab-${index + 1}`;
735
+ const resolvedId = resolveUIValue(rawId, runtime);
736
+ const normalizedId = String(
737
+ resolvedId == null || String(resolvedId).trim().length === 0 ? rawId : resolvedId
738
+ );
739
+ const rawTitle = (_b = item.title) != null ? _b : item.label;
740
+ const resolvedTitle = resolveUIValue(rawTitle, runtime);
741
+ const normalizedTitle = (_c = resolvedTitle != null ? resolvedTitle : rawTitle) != null ? _c : `Tab ${index + 1}`;
742
+ const mappedChildren = (_d = childrenByTabId.get(normalizedId)) != null ? _d : [];
743
+ const fallbackChildren = index === 0 ? unassignedChildren : [];
744
+ const contentNodes = [...mappedChildren, ...fallbackChildren];
745
+ const contentFromChildren = contentNodes.length > 0 ? contentNodes.length === 1 ? renderChild(contentNodes[0]) : contentNodes.map((child) => renderChild(child)) : null;
746
+ return __spreadProps(__spreadValues({}, item), {
747
+ id: normalizedId,
748
+ title: normalizedTitle,
749
+ label: normalizedTitle,
750
+ content: contentFromChildren != null ? contentFromChildren : normalizeRenderableChild(item.content)
751
+ });
752
+ });
753
+ };
754
+ var resolveStudioTabsProps = ({
755
+ componentProps,
756
+ tabItems,
757
+ rawChildren,
758
+ runtime,
759
+ renderChild,
760
+ normalizeRenderableChild
761
+ }) => {
762
+ const normalizedProps = normalizeStudioTabsProps(componentProps);
763
+ const resolvedTabs = resolveStudioTabsContent({
764
+ tabItems: Array.isArray(normalizedProps.tabs) ? normalizedProps.tabs : tabItems,
765
+ rawChildren,
766
+ runtime,
767
+ renderChild,
768
+ normalizeRenderableChild
769
+ });
770
+ return {
771
+ normalizedProps,
772
+ resolvedTabs
773
+ };
774
+ };
775
+
776
+ // src/studio-bridge/preview-navigation/previewNavigationState.ts
777
+ var findContainingNodeId = (targetNodeId, candidates, idResolver) => {
778
+ const containsNode = (candidate) => {
779
+ var _a;
780
+ if (candidate.id === targetNodeId) return true;
781
+ return ((_a = candidate.children) != null ? _a : []).some((nested) => containsNode(nested));
782
+ };
783
+ for (const candidate of candidates) {
784
+ if (containsNode(candidate)) {
785
+ return idResolver(candidate);
786
+ }
787
+ }
788
+ return null;
789
+ };
790
+ var resolveAccordionOpenIds = ({
791
+ itemIds,
792
+ persistedOpenIds,
793
+ selectedItemId,
794
+ allowMultiple
795
+ }) => {
796
+ let effectiveOpenIds = persistedOpenIds.filter((id) => itemIds.includes(id));
797
+ if (selectedItemId) {
798
+ effectiveOpenIds = allowMultiple ? Array.from(/* @__PURE__ */ new Set([...effectiveOpenIds, selectedItemId])) : [selectedItemId];
799
+ } else if (effectiveOpenIds.length === 0 && itemIds[0]) {
800
+ effectiveOpenIds = [itemIds[0]];
801
+ }
802
+ return effectiveOpenIds;
803
+ };
804
+ var resolveStudioAccordionState = ({
805
+ nodeId,
806
+ accordionChildren,
807
+ itemIds,
808
+ selectedNodeId,
809
+ accordionOpenIdsByNodeId,
810
+ allowMultiple
811
+ }) => {
812
+ var _a;
813
+ const validItemIds = new Set(itemIds);
814
+ const persistedOpenIds = ((_a = accordionOpenIdsByNodeId[nodeId]) != null ? _a : []).filter(
815
+ (id) => validItemIds.has(id)
816
+ );
817
+ const selectedItemId = selectedNodeId != null ? findContainingNodeId(
818
+ selectedNodeId,
819
+ accordionChildren,
820
+ (candidate) => {
821
+ var _a2, _b;
822
+ return String((_b = ((_a2 = candidate.props) != null ? _a2 : {}).id) != null ? _b : candidate.id);
823
+ }
824
+ ) : null;
825
+ const effectiveOpenIds = resolveAccordionOpenIds({
826
+ itemIds,
827
+ persistedOpenIds,
828
+ selectedItemId,
829
+ allowMultiple
830
+ });
831
+ return {
832
+ validItemIds,
833
+ effectiveOpenIds
834
+ };
835
+ };
836
+ var resolveStudioExpandablePanelState = ({
837
+ nodeId,
838
+ expandablePanelOpenByNodeId
839
+ }) => {
840
+ var _a;
841
+ return {
842
+ controlledOpen: (_a = expandablePanelOpenByNodeId[nodeId]) != null ? _a : true,
843
+ defaultOpen: true,
844
+ disableAnimation: true
845
+ };
846
+ };
847
+
848
+ // src/studio-bridge/preview-navigation/previewNavigationConfigurators.tsx
849
+ var configurePreviewAccordion = ({
850
+ node,
851
+ componentProps,
852
+ accordionChildren,
853
+ selectedNodeId,
854
+ accordionOpenIdsByNodeId,
855
+ setAccordionOpenIdsByNodeId,
856
+ renderSafeNode
857
+ }) => {
858
+ const items = buildAccordionItems(accordionChildren, renderSafeNode);
859
+ componentProps.items = items;
860
+ const { validItemIds, effectiveOpenIds } = resolveStudioAccordionState({
861
+ nodeId: node.id,
862
+ accordionChildren,
863
+ itemIds: items.map((item) => item.id),
864
+ selectedNodeId,
865
+ accordionOpenIdsByNodeId,
866
+ allowMultiple: Boolean(componentProps.allowMultiple)
867
+ });
868
+ componentProps.openIds = effectiveOpenIds;
869
+ componentProps.defaultOpenIds = effectiveOpenIds;
870
+ componentProps.onOpenIdsChange = (nextOpenIds) => {
871
+ setAccordionOpenIdsByNodeId((previous) => __spreadProps(__spreadValues({}, previous), {
872
+ [node.id]: nextOpenIds.filter((id) => validItemIds.has(id))
873
+ }));
874
+ };
875
+ };
876
+ var configurePreviewExpandablePanel = ({
877
+ node,
878
+ componentProps,
879
+ panelChildren,
880
+ expandablePanelOpenByNodeId,
881
+ setExpandablePanelOpenByNodeId,
882
+ renderSafeNode
883
+ }) => {
884
+ const { controlledOpen, defaultOpen, disableAnimation } = resolveStudioExpandablePanelState({
885
+ nodeId: node.id,
886
+ expandablePanelOpenByNodeId
887
+ });
888
+ componentProps.open = controlledOpen;
889
+ componentProps.defaultOpen = defaultOpen;
890
+ componentProps.disableAnimation = disableAnimation;
891
+ componentProps.onOpenChange = (nextOpen) => {
892
+ setExpandablePanelOpenByNodeId((previous) => __spreadProps(__spreadValues({}, previous), {
893
+ [node.id]: Boolean(nextOpen)
894
+ }));
895
+ };
896
+ const panelContent = buildExpandablePanelChildren(panelChildren, renderSafeNode);
897
+ if (panelContent) {
898
+ componentProps.children = panelContent;
899
+ }
900
+ };
901
+ var configurePreviewTabs = ({
902
+ componentProps,
903
+ tabItems,
904
+ rawChildren,
905
+ runtime,
906
+ renderSafeNode,
907
+ normalizeRenderableChild
908
+ }) => {
909
+ const { normalizedProps, resolvedTabs } = resolveStudioTabsProps({
910
+ componentProps,
911
+ tabItems,
912
+ rawChildren,
913
+ runtime,
914
+ renderChild: renderSafeNode,
915
+ normalizeRenderableChild
916
+ });
917
+ Object.assign(componentProps, normalizedProps);
918
+ componentProps.tabs = resolvedTabs;
919
+ delete componentProps.children;
920
+ };
921
+
922
+ // src/studio-bridge/preview-wizard/previewWizardMaterialization.ts
923
+ import React2 from "react";
924
+
925
+ // src/studio-bridge/preview-wizard/previewWizardFormState.ts
926
+ var resolveStudioWizardNextValues = ({
927
+ rawWizardValues,
928
+ fieldName,
929
+ nextValue
930
+ }) => __spreadProps(__spreadValues({}, rawWizardValues), {
931
+ [fieldName]: nextValue
932
+ });
933
+ var resolveStudioWizardActiveStepFields = ({
934
+ stepId,
935
+ stepIdToNode
936
+ }) => {
937
+ var _a;
938
+ const activeStepNode = stepIdToNode[stepId];
939
+ return ((_a = activeStepNode == null ? void 0 : activeStepNode.children) != null ? _a : []).filter((child) => child.type === "FormField").map((child) => {
940
+ var _a2;
941
+ const childProps = (_a2 = child.props) != null ? _a2 : {};
942
+ const childFieldObj = childProps.field && typeof childProps.field === "object" && !Array.isArray(childProps.field) ? childProps.field : {};
943
+ return buildWizardFieldConfig(childProps, childFieldObj);
944
+ }).filter((field) => {
945
+ var _a2;
946
+ return String((_a2 = field.name) != null ? _a2 : "").trim().length > 0;
947
+ });
948
+ };
949
+ var resolveStudioWizardNextErrors = ({
950
+ currentWizardErrors,
951
+ activeStepFields,
952
+ nextValues,
953
+ runtime
954
+ }) => {
955
+ const validation = validateFormValues(activeStepFields, nextValues, {
956
+ t: runtime.t,
957
+ useLegacyFieldConstraints: true
958
+ });
959
+ const activeStepFieldNames = new Set(
960
+ activeStepFields.map((field) => {
961
+ var _a;
962
+ return String((_a = field.name) != null ? _a : "").trim();
963
+ }).filter(Boolean)
964
+ );
965
+ const nextErrors = Object.entries(currentWizardErrors).reduce(
966
+ (accumulator, [key, value]) => {
967
+ if (activeStepFieldNames.has(key)) return accumulator;
968
+ accumulator[key] = value;
969
+ return accumulator;
970
+ },
971
+ {}
972
+ );
973
+ Object.entries(validation.errors).forEach(([key, value]) => {
974
+ if (!value) return;
975
+ nextErrors[key] = value;
976
+ });
977
+ return nextErrors;
978
+ };
979
+ var patchStudioWizardFieldNode = ({
980
+ nested,
981
+ rawWizardValues,
982
+ currentWizardErrors,
983
+ fieldOnChange
984
+ }) => {
985
+ var _a, _b, _c, _d, _e;
986
+ const nestedProps = (_a = nested.props) != null ? _a : {};
987
+ const fieldObj = nestedProps.field && typeof nestedProps.field === "object" && !Array.isArray(nestedProps.field) ? nestedProps.field : {};
988
+ const fieldName = String((_c = (_b = nestedProps.name) != null ? _b : fieldObj.name) != null ? _c : "").trim();
989
+ const fieldConfig = __spreadProps(__spreadValues(__spreadValues({}, fieldObj), nestedProps), {
990
+ name: fieldName,
991
+ label: String((_e = (_d = nestedProps.label) != null ? _d : fieldObj.label) != null ? _e : fieldName || "Field")
992
+ });
993
+ const patchedNode = __spreadProps(__spreadValues({}, nested), {
994
+ props: __spreadProps(__spreadValues({}, nestedProps), {
995
+ layout: (() => {
996
+ var _a2;
997
+ const rawLayout = nestedProps.layout && typeof nestedProps.layout === "object" && !Array.isArray(nestedProps.layout) ? __spreadValues({}, nestedProps.layout) : {};
998
+ const existingWrapperClassName = String((_a2 = rawLayout.wrapperClassName) != null ? _a2 : "").trim();
999
+ rawLayout.wrapperClassName = [existingWrapperClassName, "w-full", "max-w-full"].filter(Boolean).join(" ");
1000
+ delete rawLayout.widthPct;
1001
+ delete rawLayout.heightPct;
1002
+ delete rawLayout.heightPx;
1003
+ return rawLayout;
1004
+ })(),
1005
+ field: fieldConfig,
1006
+ value: fieldName ? rawWizardValues[fieldName] : void 0,
1007
+ error: fieldName ? currentWizardErrors[fieldName] : void 0,
1008
+ onChange: fieldOnChange
1009
+ })
1010
+ });
1011
+ const nestedLayout = readNodeLayout(nestedProps);
1012
+ const fieldBasis = nestedLayout.widthPct !== null ? `${nestedLayout.widthPct}%` : "100%";
1013
+ return {
1014
+ patchedNode,
1015
+ fieldBasis
1016
+ };
1017
+ };
1018
+
1019
+ // src/studio-bridge/preview-wizard/previewWizardMaterialization.ts
1020
+ var renderStudioWizardStepContent = ({
1021
+ step,
1022
+ nodeId,
1023
+ existingFormConfig,
1024
+ rawWizardValues,
1025
+ stepIdToNode,
1026
+ runtime,
1027
+ renderSafeNode,
1028
+ captureFieldFocus,
1029
+ onInlineTextEdit
1030
+ }) => {
1031
+ if (step.contentType === "content") {
1032
+ if (step.contentNode) {
1033
+ return renderSafeNode(step.contentNode);
1034
+ }
1035
+ return step.contentValue;
1036
+ }
1037
+ if (step.stepRenderableContent.length === 0) {
1038
+ return step.contentValue;
1039
+ }
1040
+ return React2.createElement(
1041
+ "div",
1042
+ { className: "flex flex-wrap items-start gap-x-3 gap-y-3" },
1043
+ step.stepRenderableContent.map((nested) => {
1044
+ if (nested.type !== "FormField") {
1045
+ return React2.createElement(
1046
+ "div",
1047
+ { key: nested.id, className: "basis-full" },
1048
+ renderSafeNode(nested)
1049
+ );
1050
+ }
1051
+ const currentWizardErrors = existingFormConfig.errors && typeof existingFormConfig.errors === "object" && !Array.isArray(existingFormConfig.errors) ? existingFormConfig.errors : {};
1052
+ const { patchedNode, fieldBasis } = patchStudioWizardFieldNode({
1053
+ nested,
1054
+ rawWizardValues,
1055
+ currentWizardErrors,
1056
+ fieldOnChange: (event) => {
1057
+ var _a;
1058
+ captureFieldFocus(event.target);
1059
+ const nextFieldName = String((_a = event.target.name) != null ? _a : "").trim();
1060
+ if (!nextFieldName) return;
1061
+ const target = event.target;
1062
+ const nextValue = target.type === "checkbox" ? Boolean(target.checked) : event.target.value;
1063
+ const nextValues = resolveStudioWizardNextValues({
1064
+ rawWizardValues,
1065
+ fieldName: nextFieldName,
1066
+ nextValue
1067
+ });
1068
+ const activeStepFields = resolveStudioWizardActiveStepFields({
1069
+ stepId: step.id,
1070
+ stepIdToNode
1071
+ });
1072
+ const nextErrors = resolveStudioWizardNextErrors({
1073
+ currentWizardErrors,
1074
+ activeStepFields,
1075
+ nextValues,
1076
+ runtime
1077
+ });
1078
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(nodeId, "form.values", nextValues);
1079
+ onInlineTextEdit == null ? void 0 : onInlineTextEdit(nodeId, "form.errors", nextErrors);
1080
+ }
1081
+ });
1082
+ return React2.createElement(
1083
+ "div",
1084
+ {
1085
+ key: nested.id,
1086
+ className: "min-w-0",
1087
+ style: { flex: `0 0 ${fieldBasis}`, maxWidth: fieldBasis }
1088
+ },
1089
+ renderSafeNode(patchedNode)
1090
+ );
1091
+ })
1092
+ );
1093
+ };
1094
+ var materializeStudioWizardSteps = ({
1095
+ nodeId,
1096
+ currentSteps,
1097
+ existingFormConfig,
1098
+ rawWizardValues,
1099
+ stepIdToNode,
1100
+ runtime,
1101
+ renderSafeNode,
1102
+ captureFieldFocus,
1103
+ onInlineTextEdit
1104
+ }) => currentSteps.map((step) => ({
1105
+ id: step.id,
1106
+ title: step.title,
1107
+ description: step.description,
1108
+ titleNode: step.titleNode ? renderSafeNode(step.titleNode) : void 0,
1109
+ descriptionNode: step.descriptionNode ? renderSafeNode(step.descriptionNode) : void 0,
1110
+ isValid: step.isValid,
1111
+ content: renderStudioWizardStepContent({
1112
+ step,
1113
+ nodeId,
1114
+ currentSteps,
1115
+ existingFormConfig,
1116
+ rawWizardValues,
1117
+ stepIdToNode,
1118
+ runtime,
1119
+ renderSafeNode,
1120
+ captureFieldFocus,
1121
+ onInlineTextEdit
1122
+ })
1123
+ }));
1124
+
1125
+ // src/studio-bridge/preview-wizard/wizardEditingHandlers.ts
1126
+ var findWizardStepRoleNode = (stepNode, role) => {
1127
+ var _a;
1128
+ const nestedChildren = Array.isArray(stepNode.children) ? stepNode.children : [];
1129
+ return (_a = nestedChildren.find((child) => {
1130
+ var _a2, _b;
1131
+ const childProps = (_a2 = child.props) != null ? _a2 : {};
1132
+ return String((_b = getLayoutRecord(childProps).wizardStepRole) != null ? _b : "").trim() === role;
1133
+ })) != null ? _a : null;
1134
+ };
1135
+ var createStudioWizardOnStepChange = ({
1136
+ nodeId,
1137
+ stepIdToNode,
1138
+ setWizardActiveStepByNodeId,
1139
+ existingOnStepChange,
1140
+ onNodeClick
1141
+ }) => {
1142
+ return (stepId) => {
1143
+ setWizardActiveStepByNodeId((previous) => {
1144
+ if (previous[nodeId] === stepId) return previous;
1145
+ return __spreadProps(__spreadValues({}, previous), {
1146
+ [nodeId]: stepId
1147
+ });
1148
+ });
1149
+ if (typeof existingOnStepChange === "function") {
1150
+ existingOnStepChange(stepId);
1151
+ }
1152
+ const stepNode = stepIdToNode[stepId];
1153
+ if (stepNode && onNodeClick) {
1154
+ onNodeClick(stepNode.id);
1155
+ }
1156
+ };
1157
+ };
1158
+ var attachStudioWizardEditingHandlers = ({
1159
+ studioConfig,
1160
+ node,
1161
+ stepIdToNode,
1162
+ openInlineEditorForNodeProp
1163
+ }) => {
1164
+ studioConfig.onStepTitleDoubleClick = (stepId) => {
1165
+ var _a, _b, _c, _d, _e;
1166
+ const stepNode = stepIdToNode[stepId];
1167
+ if (!stepNode) return;
1168
+ const stepProps = (_a = stepNode.props) != null ? _a : {};
1169
+ const titleNode = findWizardStepRoleNode(stepNode, "title");
1170
+ if (titleNode) {
1171
+ const titleNodeProps = (_b = titleNode.props) != null ? _b : {};
1172
+ openInlineEditorForNodeProp(
1173
+ titleNode.id,
1174
+ "children",
1175
+ (_d = (_c = titleNodeProps.children) != null ? _c : stepProps.title) != null ? _d : stepId
1176
+ );
1177
+ return;
1178
+ }
1179
+ openInlineEditorForNodeProp(stepNode.id, "title", (_e = stepProps.title) != null ? _e : stepId);
1180
+ };
1181
+ studioConfig.onStepDescriptionDoubleClick = (stepId) => {
1182
+ var _a, _b, _c, _d, _e;
1183
+ const stepNode = stepIdToNode[stepId];
1184
+ if (!stepNode) return;
1185
+ const stepProps = (_a = stepNode.props) != null ? _a : {};
1186
+ const descriptionNode = findWizardStepRoleNode(stepNode, "description");
1187
+ if (descriptionNode) {
1188
+ const descriptionNodeProps = (_b = descriptionNode.props) != null ? _b : {};
1189
+ openInlineEditorForNodeProp(
1190
+ descriptionNode.id,
1191
+ "children",
1192
+ (_d = (_c = descriptionNodeProps.children) != null ? _c : stepProps.description) != null ? _d : ""
1193
+ );
1194
+ return;
1195
+ }
1196
+ openInlineEditorForNodeProp(stepNode.id, "description", (_e = stepProps.description) != null ? _e : "");
1197
+ };
1198
+ studioConfig.onBackLabelDoubleClick = () => {
1199
+ var _a, _b, _c;
1200
+ return openInlineEditorForNodeProp(
1201
+ node.id,
1202
+ "labels.back",
1203
+ (_c = (_b = (_a = node.props) == null ? void 0 : _a.labels) == null ? void 0 : _b.back) != null ? _c : "Back"
1204
+ );
1205
+ };
1206
+ studioConfig.onNextLabelDoubleClick = () => {
1207
+ var _a, _b, _c;
1208
+ return openInlineEditorForNodeProp(
1209
+ node.id,
1210
+ "labels.next",
1211
+ (_c = (_b = (_a = node.props) == null ? void 0 : _a.labels) == null ? void 0 : _b.next) != null ? _c : "Next"
1212
+ );
1213
+ };
1214
+ studioConfig.onFinishLabelDoubleClick = () => {
1215
+ var _a, _b, _c;
1216
+ return openInlineEditorForNodeProp(
1217
+ node.id,
1218
+ "labels.finish",
1219
+ (_c = (_b = (_a = node.props) == null ? void 0 : _a.labels) == null ? void 0 : _b.finish) != null ? _c : "Finish"
1220
+ );
1221
+ };
1222
+ return studioConfig;
1223
+ };
1224
+
1225
+ // src/utils/wizardStudio.ts
1226
+ var getWizardStepRole = (node) => {
1227
+ var _a, _b;
1228
+ const props = (_a = node.props) != null ? _a : {};
1229
+ const layout = getLayoutRecord(props);
1230
+ return String((_b = layout.wizardStepRole) != null ? _b : "").trim();
1231
+ };
1232
+ var getWizardRenderableChildren = (nodes) => nodes.filter((nested) => {
1233
+ const stepRole = getWizardStepRole(nested);
1234
+ return stepRole !== "title" && stepRole !== "description";
1235
+ });
1236
+ var findSelectedWizardStepId = (stepChildren, selectedNodeId) => {
1237
+ var _a, _b, _c;
1238
+ if (!selectedNodeId) return null;
1239
+ const selectedStep = stepChildren.find((stepChild) => {
1240
+ var _a2;
1241
+ if (stepChild.id === selectedNodeId) return true;
1242
+ return ((_a2 = stepChild.children) != null ? _a2 : []).some((nested) => {
1243
+ const stepRole = getWizardStepRole(nested);
1244
+ return nested.id === selectedNodeId && (stepRole === "title" || stepRole === "description");
1245
+ });
1246
+ });
1247
+ if (!selectedStep) return null;
1248
+ const stepProps = (_a = selectedStep.props) != null ? _a : {};
1249
+ return String((_c = (_b = stepProps.id) != null ? _b : selectedStep.id) != null ? _c : "").trim() || null;
1250
+ };
1251
+ var buildFieldsByStep = (stepIdToNode, currentSteps) => currentSteps.reduce((accumulator, step) => {
1252
+ var _a, _b;
1253
+ const stepId = String((_a = step.id) != null ? _a : "").trim();
1254
+ if (!stepId) return accumulator;
1255
+ const stepNode = stepIdToNode[stepId];
1256
+ const stepRenderableChildren = getWizardRenderableChildren((_b = stepNode == null ? void 0 : stepNode.children) != null ? _b : []);
1257
+ const fields = stepRenderableChildren.filter((nested) => nested.type === "FormField").map((nested) => {
1258
+ var _a2;
1259
+ const nestedProps = (_a2 = nested.props) != null ? _a2 : {};
1260
+ const nestedField = nestedProps.field && typeof nestedProps.field === "object" && !Array.isArray(nestedProps.field) ? nestedProps.field : {};
1261
+ return buildWizardFieldConfig(nestedProps, nestedField);
1262
+ }).filter((field) => {
1263
+ var _a2;
1264
+ return String((_a2 = field.name) != null ? _a2 : "").trim().length > 0;
1265
+ });
1266
+ accumulator[stepId] = fields;
1267
+ return accumulator;
1268
+ }, {});
1269
+ var resolveActiveWizardStepId = ({
1270
+ selectedStepId,
1271
+ stepIds,
1272
+ activeStepFromProps,
1273
+ activeStepFromMemory
1274
+ }) => {
1275
+ var _a;
1276
+ if (selectedStepId && stepIds.includes(selectedStepId)) return selectedStepId;
1277
+ if (activeStepFromProps && stepIds.includes(activeStepFromProps)) {
1278
+ return activeStepFromProps;
1279
+ }
1280
+ if (activeStepFromMemory && stepIds.includes(activeStepFromMemory)) {
1281
+ return activeStepFromMemory;
1282
+ }
1283
+ return (_a = stepIds[0]) != null ? _a : "";
1284
+ };
1285
+ var validateWizardStepFields = ({
1286
+ stepRenderableContent,
1287
+ values,
1288
+ runtime
1289
+ }) => {
1290
+ const normalizedFields = stepRenderableContent.filter((nested) => nested.type === "FormField").map((nested) => {
1291
+ var _a;
1292
+ const nestedProps = (_a = nested.props) != null ? _a : {};
1293
+ const fieldObject = nestedProps.field && typeof nestedProps.field === "object" && !Array.isArray(nestedProps.field) ? nestedProps.field : {};
1294
+ return buildWizardFieldConfig(nestedProps, fieldObject);
1295
+ });
1296
+ const filteredFields = normalizedFields.filter((field) => field.name.length > 0);
1297
+ const validation = validateFormValues(filteredFields, values, {
1298
+ t: runtime.t,
1299
+ useLegacyFieldConstraints: true
1300
+ });
1301
+ return validation.issues.length === 0;
1302
+ };
1303
+
1304
+ // src/studio-bridge/preview-wizard/previewWizardStructure.ts
1305
+ var resolveStudioWizardStructure = ({
1306
+ node,
1307
+ componentProps,
1308
+ selectedNodeId,
1309
+ wizardActiveStepByNodeId,
1310
+ runtime,
1311
+ internalStudioNodeTypes
1312
+ }) => {
1313
+ var _a, _b, _c, _d, _e, _f;
1314
+ const existingFormConfig = componentProps.form && typeof componentProps.form === "object" && !Array.isArray(componentProps.form) ? __spreadValues({}, componentProps.form) : {};
1315
+ const existingStudioConfig = componentProps.studio && typeof componentProps.studio === "object" && !Array.isArray(componentProps.studio) ? __spreadValues({}, componentProps.studio) : {};
1316
+ const stepChildren = ((_a = node.children) != null ? _a : []).filter((child) => {
1317
+ var _a2;
1318
+ const childProps = (_a2 = child.props) != null ? _a2 : {};
1319
+ const layout = getLayoutRecord(childProps);
1320
+ const isWizardStepFlag = layout.wizardStep === true;
1321
+ const isSupportedStepType = child.type === "Container" || child.type === "StepForm";
1322
+ return isSupportedStepType && isWizardStepFlag;
1323
+ });
1324
+ const stepIdToNode = stepChildren.reduce(
1325
+ (accumulator, stepChild) => {
1326
+ var _a2, _b2, _c2;
1327
+ const stepProps = (_a2 = stepChild.props) != null ? _a2 : {};
1328
+ const stepId = String((_b2 = stepProps.id) != null ? _b2 : "").trim();
1329
+ const fallbackId = String((_c2 = stepChild.id) != null ? _c2 : "").trim();
1330
+ if (stepId) accumulator[stepId] = stepChild;
1331
+ if (fallbackId) accumulator[fallbackId] = stepChild;
1332
+ return accumulator;
1333
+ },
1334
+ {}
1335
+ );
1336
+ const selectedStepId = findSelectedWizardStepId(stepChildren, selectedNodeId);
1337
+ const rawWizardValues = existingFormConfig.values && typeof existingFormConfig.values === "object" && !Array.isArray(existingFormConfig.values) ? existingFormConfig.values : {};
1338
+ const currentSteps = stepChildren.map((stepChild) => {
1339
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k;
1340
+ const stepProps = (_a2 = stepChild.props) != null ? _a2 : {};
1341
+ const stepId = String((_b2 = stepProps.id) != null ? _b2 : "").trim() || stepChild.id;
1342
+ const stepContent = ((_c2 = stepChild.children) != null ? _c2 : []).filter(
1343
+ (nested) => !internalStudioNodeTypes.has(nested.type)
1344
+ );
1345
+ const stepTitleNode = stepContent.find(
1346
+ (nested) => {
1347
+ var _a3, _b3;
1348
+ return String(
1349
+ (_b3 = getLayoutRecord((_a3 = nested.props) != null ? _a3 : {}).wizardStepRole) != null ? _b3 : ""
1350
+ ).trim() === "title";
1351
+ }
1352
+ );
1353
+ const stepDescriptionNode = stepContent.find(
1354
+ (nested) => {
1355
+ var _a3, _b3;
1356
+ return String(
1357
+ (_b3 = getLayoutRecord((_a3 = nested.props) != null ? _a3 : {}).wizardStepRole) != null ? _b3 : ""
1358
+ ).trim() === "description";
1359
+ }
1360
+ );
1361
+ const stepTitleNodeValue = (_d2 = stepTitleNode == null ? void 0 : stepTitleNode.props) == null ? void 0 : _d2.children;
1362
+ const stepDescriptionNodeValue = (_e2 = stepDescriptionNode == null ? void 0 : stepDescriptionNode.props) == null ? void 0 : _e2.children;
1363
+ const title = resolveUIValue((_f2 = stepTitleNodeValue != null ? stepTitleNodeValue : stepProps.title) != null ? _f2 : stepId, runtime);
1364
+ const description = resolveUIValue((_g = stepDescriptionNodeValue != null ? stepDescriptionNodeValue : stepProps.description) != null ? _g : "", runtime);
1365
+ const rawContentType = String((_h = stepProps.contentType) != null ? _h : "content");
1366
+ const stepRenderableContent = getWizardRenderableChildren(stepContent);
1367
+ const hasFieldChildren = stepRenderableContent.some((nested) => {
1368
+ var _a3, _b3;
1369
+ if (nested.type !== "FormField") return false;
1370
+ const nestedProps = (_a3 = nested.props) != null ? _a3 : {};
1371
+ return String((_b3 = getLayoutRecord(nestedProps).formRole) != null ? _b3 : "field").trim() === "field";
1372
+ });
1373
+ const contentType = hasFieldChildren ? "form" : rawContentType;
1374
+ const isValid = !hasFieldChildren ? stepProps.isValid !== false : validateWizardStepFields({
1375
+ stepRenderableContent,
1376
+ values: rawWizardValues,
1377
+ runtime
1378
+ });
1379
+ const explicitContentNode = stepRenderableContent.find(
1380
+ (nested) => {
1381
+ var _a3;
1382
+ return getLayoutRecord((_a3 = nested.props) != null ? _a3 : {}).wizardContent === true;
1383
+ }
1384
+ );
1385
+ const contentNode = explicitContentNode != null ? explicitContentNode : contentType === "content" ? stepRenderableContent[0] : void 0;
1386
+ return {
1387
+ id: stepId,
1388
+ title,
1389
+ description,
1390
+ titleNode: stepTitleNode,
1391
+ descriptionNode: stepDescriptionNode,
1392
+ contentNode,
1393
+ isValid,
1394
+ contentType,
1395
+ stepRenderableContent,
1396
+ contentValue: contentType === "content" ? resolveUIValue(
1397
+ (_k = (_j = (_i = contentNode == null ? void 0 : contentNode.props) == null ? void 0 : _i.children) != null ? _j : stepProps.content) != null ? _k : title,
1398
+ runtime
1399
+ ) : null
1400
+ };
1401
+ });
1402
+ const normalizedFieldsByStep = buildFieldsByStep(
1403
+ stepIdToNode,
1404
+ currentSteps
1405
+ );
1406
+ const stepIds = currentSteps.map((step) => step.id).filter(Boolean);
1407
+ const activeStepFromMemory = String((_b = wizardActiveStepByNodeId[node.id]) != null ? _b : "").trim();
1408
+ const activeStepFromProps = String(
1409
+ (_f = (_e = (_c = node.props) == null ? void 0 : _c.activeStepId) != null ? _e : (_d = node.props) == null ? void 0 : _d.initialStepId) != null ? _f : ""
1410
+ ).trim();
1411
+ const resolvedActiveStepId = resolveActiveWizardStepId({
1412
+ selectedStepId,
1413
+ stepIds,
1414
+ activeStepFromProps,
1415
+ activeStepFromMemory
1416
+ });
1417
+ return {
1418
+ stepChildren,
1419
+ stepIdToNode,
1420
+ selectedStepId,
1421
+ currentSteps,
1422
+ normalizedFieldsByStep,
1423
+ resolvedActiveStepId,
1424
+ existingFormConfig,
1425
+ existingStudioConfig
1426
+ };
1427
+ };
1428
+
1429
+ // src/studio-bridge/preview-wizard/previewWizardConfigurator.ts
1430
+ var configurePreviewFormWizard = ({
1431
+ node,
1432
+ componentProps,
1433
+ isStudioRendererContext,
1434
+ selectedNodeId,
1435
+ wizardActiveStepByNodeId,
1436
+ runtime,
1437
+ setWizardActiveStepByNodeId,
1438
+ onNodeClick,
1439
+ onInlineTextEdit,
1440
+ renderSafeNode,
1441
+ captureFieldFocus,
1442
+ openInlineEditorForNodeProp,
1443
+ internalStudioNodeTypes
1444
+ }) => {
1445
+ var _a;
1446
+ if (isStudioRendererContext) {
1447
+ const existingClassName = String((_a = componentProps.className) != null ? _a : "").trim();
1448
+ componentProps.className = [
1449
+ existingClassName,
1450
+ "w-full",
1451
+ "[&_[data-step-form-wrapper]>section]:max-w-full",
1452
+ "[&_[data-step-form-wrapper]>section]:mx-0"
1453
+ ].filter(Boolean).join(" ");
1454
+ }
1455
+ const {
1456
+ existingFormConfig,
1457
+ existingStudioConfig,
1458
+ currentSteps,
1459
+ normalizedFieldsByStep,
1460
+ resolvedActiveStepId,
1461
+ stepIdToNode
1462
+ } = resolveStudioWizardStructure({
1463
+ node,
1464
+ componentProps,
1465
+ selectedNodeId,
1466
+ wizardActiveStepByNodeId,
1467
+ runtime,
1468
+ internalStudioNodeTypes
1469
+ });
1470
+ const rawWizardValues = existingFormConfig.values && typeof existingFormConfig.values === "object" && !Array.isArray(existingFormConfig.values) ? existingFormConfig.values : {};
1471
+ const materializedSteps = materializeStudioWizardSteps({
1472
+ nodeId: node.id,
1473
+ currentSteps,
1474
+ existingFormConfig,
1475
+ rawWizardValues,
1476
+ stepIdToNode,
1477
+ runtime,
1478
+ renderSafeNode,
1479
+ captureFieldFocus,
1480
+ onInlineTextEdit
1481
+ });
1482
+ if (materializedSteps.length > 0) {
1483
+ componentProps.steps = materializedSteps;
1484
+ }
1485
+ existingFormConfig.fieldsByStep = normalizedFieldsByStep;
1486
+ if (resolvedActiveStepId) {
1487
+ componentProps.activeStepId = resolvedActiveStepId;
1488
+ }
1489
+ componentProps.onStepChange = createStudioWizardOnStepChange({
1490
+ nodeId: node.id,
1491
+ stepIdToNode,
1492
+ setWizardActiveStepByNodeId,
1493
+ existingOnStepChange: componentProps.onStepChange,
1494
+ onNodeClick
1495
+ });
1496
+ attachStudioWizardEditingHandlers({
1497
+ studioConfig: existingStudioConfig,
1498
+ node,
1499
+ stepIdToNode,
1500
+ openInlineEditorForNodeProp
1501
+ });
1502
+ componentProps.form = isStudioRendererContext ? void 0 : existingFormConfig;
1503
+ componentProps.studio = existingStudioConfig;
1504
+ };
1505
+ export {
1506
+ configurePreviewAccordion,
1507
+ configurePreviewExpandablePanel,
1508
+ configurePreviewFormWizard,
1509
+ configurePreviewLinkBehavior,
1510
+ configurePreviewTabs,
1511
+ materializeBoundTable,
1512
+ materializePreviewForm,
1513
+ resolveBoundTableData
1514
+ };