@golemui/gui-shared 0.13.1 → 0.13.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.
@@ -0,0 +1,1589 @@
1
+ import "@golemui/core";
2
+ const U = {
3
+ INPUTS: "INPUTS",
4
+ ACTIONS: "ACTIONS",
5
+ LAYOUTS: "LAYOUTS",
6
+ DISPLAYS: "DISPLAYS"
7
+ };
8
+ function R(e) {
9
+ return function(t, s = () => !0) {
10
+ return {
11
+ kind: "leaf",
12
+ selectorType: e,
13
+ matcher: s,
14
+ config: t
15
+ };
16
+ };
17
+ }
18
+ function g(e, t) {
19
+ return typeof e == "function" ? e : { type: t, ...e ?? {} };
20
+ }
21
+ class V {
22
+ /**
23
+ * Deep merges two objects, with right taking precedence over left when properties conflict.
24
+ * Arrays are replaced, not merged.
25
+ * @param left - The base object
26
+ * @param right - The object whose properties take precedence
27
+ * @returns A new merged object
28
+ */
29
+ deepMerge(t, s) {
30
+ if (s == null)
31
+ return t;
32
+ if (t == null || typeof t != "object" || typeof s != "object" || Array.isArray(t) || Array.isArray(s))
33
+ return s;
34
+ const l = { ...t };
35
+ for (const a in s)
36
+ Object.prototype.hasOwnProperty.call(s, a) && (typeof s[a] == "object" && !Array.isArray(s[a]) && s[a] !== null && typeof t[a] == "object" && !Array.isArray(t[a]) && t[a] !== null ? l[a] = this.deepMerge(t[a], s[a]) : l[a] = s[a]);
37
+ return l;
38
+ }
39
+ }
40
+ const x = new V();
41
+ function G(e, t) {
42
+ return {
43
+ items: [e],
44
+ type: "ITEMS",
45
+ itemType: U.ACTIONS,
46
+ tags: t ?? []
47
+ };
48
+ }
49
+ const X = (e) => {
50
+ const t = {
51
+ uid: "#submit",
52
+ label: "Submit"
53
+ }, s = e != null ? x.deepMerge(t, e) : t;
54
+ return G(s);
55
+ }, H = (e, t) => ({
56
+ type: "ITEMS",
57
+ itemType: U.DISPLAYS,
58
+ items: [{ render: e }],
59
+ tags: t ?? []
60
+ }), v = /* @__PURE__ */ new Map();
61
+ function F(e, t) {
62
+ if (v.has(e))
63
+ throw new Error(`Item type "${e}" is already registered.`);
64
+ v.set(e, t);
65
+ }
66
+ function f(e) {
67
+ const t = v.get(e);
68
+ if (!t)
69
+ throw new Error(
70
+ `No handler registered for item type "${e}". Did you forget to import the registration module?`
71
+ );
72
+ return t;
73
+ }
74
+ function j(e) {
75
+ return v.has(e);
76
+ }
77
+ function c(e) {
78
+ const t = (r) => {
79
+ if (!e.sensibleDefaults)
80
+ return {};
81
+ let o = { ...e.sensibleDefaults.base };
82
+ for (const u of r) {
83
+ const p = u.config;
84
+ for (const y of e.sensibleDefaults.fields) {
85
+ const d = y;
86
+ p[d] != null && (o = { ...o, [d]: p[d] });
87
+ }
88
+ }
89
+ return o;
90
+ }, s = (r, o) => e.sensibleDefaults ? e.sensibleDefaults.apply(r, o) : r, l = (r) => {
91
+ switch (e.entryShape) {
92
+ case "bare":
93
+ return { baseDef: r };
94
+ case "keyed": {
95
+ const o = r;
96
+ return { baseDef: o.def, path: o.key };
97
+ }
98
+ case "compound": {
99
+ const o = r;
100
+ return { baseDef: o.def, children: o.children };
101
+ }
102
+ }
103
+ }, a = {
104
+ rollUpSensibleDefaults: t,
105
+ applySensibleDefaults: s,
106
+ mapToWidget: e.mapToWidget,
107
+ parseEntry: l,
108
+ ...e.afterMerge ? { afterMerge: e.afterMerge } : {},
109
+ ...e.buildCustomWidget ? { buildCustomWidget: e.buildCustomWidget } : {},
110
+ ...e.getChildren ? { getChildren: e.getChildren } : {}
111
+ };
112
+ F(e.itemType, a);
113
+ const n = R(e.itemType);
114
+ return { gsl: n, gslByUid: (r, o) => n(o, ((u) => u.uid === r)) };
115
+ }
116
+ function b(e) {
117
+ const {
118
+ uid: t,
119
+ path: s,
120
+ label: l,
121
+ disabled: a,
122
+ readonly: n,
123
+ defaultValue: i,
124
+ tags: r,
125
+ type: o,
126
+ size: u,
127
+ onLoad: p,
128
+ onChange: y,
129
+ onFilter: d,
130
+ on: S,
131
+ states: _,
132
+ include: C,
133
+ exclude: I,
134
+ validator: P,
135
+ ...k
136
+ } = e;
137
+ return k;
138
+ }
139
+ function Z(e) {
140
+ return e ? e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (t) => t.toUpperCase()) : "";
141
+ }
142
+ function m(e, t) {
143
+ return e.label != null || t.suppressAutomaticLabels || !e.path ? e : { ...e, label: Z(e.path) };
144
+ }
145
+ function A(e, t) {
146
+ return e.placeholder != null || t.suppressAutomaticPlaceholders || !e.path ? e : { ...e, placeholder: e.path };
147
+ }
148
+ function q(e) {
149
+ switch (e.type) {
150
+ case "text":
151
+ return Q(e);
152
+ case "number":
153
+ return ee(e);
154
+ case "boolean":
155
+ return J(e);
156
+ default:
157
+ throw new Error(`Unsupported field type "${e.type}"`);
158
+ }
159
+ }
160
+ function J(e) {
161
+ const t = b(e);
162
+ return {
163
+ uid: e.uid ?? "",
164
+ kind: "input",
165
+ type: "toggle",
166
+ path: e.path ?? "",
167
+ ...e.label != null ? { label: e.label } : {},
168
+ ...e.disabled != null ? { disabled: e.disabled } : {},
169
+ ...e.readonly != null ? { readonly: e.readonly } : {},
170
+ ...e.validator != null ? { validator: g(e.validator, "boolean") } : {},
171
+ props: t
172
+ };
173
+ }
174
+ function Q(e) {
175
+ const t = b(e);
176
+ return {
177
+ uid: e.uid ?? "",
178
+ kind: "input",
179
+ type: "textinput",
180
+ path: e.path ?? "",
181
+ ...e.label != null ? { label: e.label } : {},
182
+ ...e.disabled != null ? { disabled: e.disabled } : {},
183
+ ...e.readonly != null ? { readonly: e.readonly } : {},
184
+ props: {
185
+ placeholder: t.placeholder ?? "",
186
+ ...t
187
+ },
188
+ validator: g(e.validator, "string")
189
+ };
190
+ }
191
+ function ee(e) {
192
+ const t = b(e);
193
+ return {
194
+ uid: e.uid ?? "",
195
+ kind: "input",
196
+ type: "number",
197
+ path: e.path ?? "",
198
+ ...e.label != null ? { label: e.label } : {},
199
+ ...e.disabled != null ? { disabled: e.disabled } : {},
200
+ ...e.readonly != null ? { readonly: e.readonly } : {},
201
+ props: {
202
+ placeholder: t.placeholder ?? "",
203
+ ...t
204
+ },
205
+ validator: g(e.validator, "number")
206
+ };
207
+ }
208
+ const { gsl: Ke, gslByUid: Ve } = c({
209
+ itemType: "INPUTS",
210
+ entryShape: "keyed",
211
+ sensibleDefaults: {
212
+ base: {
213
+ suppressAutomaticLabels: !1,
214
+ suppressAutomaticPlaceholders: !1
215
+ },
216
+ fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
217
+ apply: (e, t) => {
218
+ let s = m(e, t);
219
+ return s = A(s, t), s;
220
+ }
221
+ },
222
+ mapToWidget: q
223
+ }), { gsl: Ge, gslByUid: Xe } = c({
224
+ itemType: "SELECT",
225
+ entryShape: "keyed",
226
+ sensibleDefaults: {
227
+ base: { suppressAutomaticLabels: !1, suppressAutomaticPlaceholders: !1 },
228
+ fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
229
+ apply: (e, t) => A(m(e, t), t)
230
+ },
231
+ mapToWidget: (e) => ({
232
+ uid: e.uid ?? "",
233
+ kind: "input",
234
+ type: "select",
235
+ path: e.path ?? "",
236
+ ...e.label != null ? { label: e.label } : {},
237
+ ...e.disabled != null ? { disabled: e.disabled } : {},
238
+ ...e.readonly != null ? { readonly: e.readonly } : {},
239
+ ...e.validator != null ? { validator: e.validator } : {},
240
+ props: b(e)
241
+ })
242
+ }), { gsl: He, gslByUid: Ze } = c({
243
+ itemType: "DROPDOWN",
244
+ entryShape: "keyed",
245
+ sensibleDefaults: {
246
+ base: {
247
+ suppressAutomaticLabels: !1,
248
+ suppressAutomaticPlaceholders: !1
249
+ },
250
+ fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
251
+ apply: (e, t) => A(m(e, t), t)
252
+ },
253
+ mapToWidget: (e) => ({
254
+ uid: e.uid ?? "",
255
+ kind: "input",
256
+ type: "dropdown",
257
+ path: e.path ?? "",
258
+ ...e.label != null ? { label: e.label } : {},
259
+ ...e.disabled != null ? { disabled: e.disabled } : {},
260
+ ...e.readonly != null ? { readonly: e.readonly } : {},
261
+ ...e.validator != null ? { validator: e.validator } : {},
262
+ props: b(e)
263
+ })
264
+ }), { gsl: qe, gslByUid: Je } = c({
265
+ itemType: "RADIOGROUP",
266
+ entryShape: "keyed",
267
+ sensibleDefaults: {
268
+ base: { suppressAutomaticLabels: !1 },
269
+ fields: ["suppressAutomaticLabels"],
270
+ apply: (e, t) => m(e, t)
271
+ },
272
+ mapToWidget: (e) => ({
273
+ uid: e.uid ?? "",
274
+ kind: "input",
275
+ type: "radiogroup",
276
+ path: e.path ?? "",
277
+ ...e.label != null ? { label: e.label } : {},
278
+ ...e.disabled != null ? { disabled: e.disabled } : {},
279
+ ...e.readonly != null ? { readonly: e.readonly } : {},
280
+ ...e.validator != null ? { validator: e.validator } : {},
281
+ props: b(e)
282
+ })
283
+ }), { gsl: Qe, gslByUid: et } = c({
284
+ itemType: "CHECKBOX",
285
+ entryShape: "keyed",
286
+ sensibleDefaults: {
287
+ base: { suppressAutomaticLabels: !1 },
288
+ fields: ["suppressAutomaticLabels"],
289
+ apply: (e, t) => m(e, t)
290
+ },
291
+ mapToWidget: (e) => ({
292
+ uid: e.uid ?? "",
293
+ kind: "input",
294
+ type: "checkbox",
295
+ path: e.path ?? "",
296
+ ...e.label != null ? { label: e.label } : {},
297
+ ...e.disabled != null ? { disabled: e.disabled } : {},
298
+ ...e.readonly != null ? { readonly: e.readonly } : {},
299
+ ...e.validator != null ? { validator: g(e.validator, "boolean") } : {},
300
+ props: b(e)
301
+ })
302
+ }), { gsl: tt, gslByUid: st } = c({
303
+ itemType: "TEXTAREA",
304
+ entryShape: "keyed",
305
+ sensibleDefaults: {
306
+ base: { suppressAutomaticLabels: !1, suppressAutomaticPlaceholders: !1 },
307
+ fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
308
+ apply: (e, t) => A(m(e, t), t)
309
+ },
310
+ mapToWidget: (e) => ({
311
+ uid: e.uid ?? "",
312
+ kind: "input",
313
+ type: "textarea",
314
+ path: e.path ?? "",
315
+ ...e.label != null ? { label: e.label } : {},
316
+ ...e.disabled != null ? { disabled: e.disabled } : {},
317
+ ...e.readonly != null ? { readonly: e.readonly } : {},
318
+ ...e.validator != null ? { validator: g(e.validator, "string") } : {},
319
+ props: b(e)
320
+ })
321
+ }), { gsl: lt, gslByUid: at } = c({
322
+ itemType: "PASSWORD",
323
+ entryShape: "keyed",
324
+ sensibleDefaults: {
325
+ base: { suppressAutomaticLabels: !1, suppressAutomaticPlaceholders: !1 },
326
+ fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
327
+ apply: (e, t) => A(m(e, t), t)
328
+ },
329
+ mapToWidget: (e) => ({
330
+ uid: e.uid ?? "",
331
+ kind: "input",
332
+ type: "password",
333
+ path: e.path ?? "",
334
+ ...e.label != null ? { label: e.label } : {},
335
+ ...e.disabled != null ? { disabled: e.disabled } : {},
336
+ ...e.readonly != null ? { readonly: e.readonly } : {},
337
+ ...e.validator != null ? { validator: g(e.validator, "string") } : {},
338
+ props: b(e)
339
+ })
340
+ }), { gsl: nt, gslByUid: it } = c({
341
+ itemType: "CURRENCY",
342
+ entryShape: "keyed",
343
+ sensibleDefaults: {
344
+ base: { suppressAutomaticLabels: !1, suppressAutomaticPlaceholders: !1 },
345
+ fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
346
+ apply: (e, t) => A(m(e, t), t)
347
+ },
348
+ mapToWidget: (e) => ({
349
+ uid: e.uid ?? "",
350
+ kind: "input",
351
+ type: "currency",
352
+ path: e.path ?? "",
353
+ ...e.label != null ? { label: e.label } : {},
354
+ ...e.disabled != null ? { disabled: e.disabled } : {},
355
+ ...e.readonly != null ? { readonly: e.readonly } : {},
356
+ ...e.validator != null ? { validator: g(e.validator, "number") } : {},
357
+ props: b(e)
358
+ })
359
+ }), { gsl: rt, gslByUid: ot } = c({
360
+ itemType: "MARKDOWN",
361
+ entryShape: "keyed",
362
+ sensibleDefaults: {
363
+ base: { suppressAutomaticLabels: !1, suppressAutomaticPlaceholders: !1 },
364
+ fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
365
+ apply: (e, t) => A(m(e, t), t)
366
+ },
367
+ mapToWidget: (e) => ({
368
+ uid: e.uid ?? "",
369
+ kind: "input",
370
+ type: "markdown",
371
+ path: e.path ?? "",
372
+ ...e.label != null ? { label: e.label } : {},
373
+ ...e.disabled != null ? { disabled: e.disabled } : {},
374
+ ...e.readonly != null ? { readonly: e.readonly } : {},
375
+ ...e.validator != null ? { validator: g(e.validator, "string") } : {},
376
+ props: b(e)
377
+ })
378
+ }), { gsl: ut, gslByUid: pt } = c({
379
+ itemType: "LIST",
380
+ entryShape: "keyed",
381
+ sensibleDefaults: {
382
+ base: { suppressAutomaticLabels: !1 },
383
+ fields: ["suppressAutomaticLabels"],
384
+ apply: (e, t) => m(e, t)
385
+ },
386
+ mapToWidget: (e) => ({
387
+ uid: e.uid ?? "",
388
+ kind: "input",
389
+ type: "list",
390
+ path: e.path ?? "",
391
+ ...e.label != null ? { label: e.label } : {},
392
+ ...e.disabled != null ? { disabled: e.disabled } : {},
393
+ ...e.readonly != null ? { readonly: e.readonly } : {},
394
+ ...e.validator != null ? { validator: e.validator } : {},
395
+ props: b(e)
396
+ })
397
+ }), { gsl: ct, gslByUid: dt } = c({
398
+ itemType: "CALENDAR",
399
+ entryShape: "bare",
400
+ sensibleDefaults: {
401
+ base: { suppressAutomaticLabels: !1 },
402
+ fields: ["suppressAutomaticLabels"],
403
+ apply: (e, t) => m(e, t)
404
+ },
405
+ mapToWidget: (e) => ({
406
+ uid: e.uid ?? "",
407
+ kind: "input",
408
+ type: "calendar",
409
+ path: e.path ?? "",
410
+ ...e.label != null ? { label: e.label } : {},
411
+ ...e.disabled != null ? { disabled: e.disabled } : {},
412
+ ...e.readonly != null ? { readonly: e.readonly } : {},
413
+ ...e.validator != null ? { validator: g(e.validator, "string") } : {},
414
+ props: b(e)
415
+ })
416
+ }), { gsl: yt, gslByUid: bt } = c({
417
+ itemType: "DATE_INPUT",
418
+ entryShape: "keyed",
419
+ sensibleDefaults: {
420
+ base: { suppressAutomaticLabels: !1 },
421
+ fields: ["suppressAutomaticLabels"],
422
+ apply: (e, t) => m(e, t)
423
+ },
424
+ mapToWidget: (e) => ({
425
+ uid: e.uid ?? "",
426
+ kind: "input",
427
+ type: "dateInput",
428
+ path: e.path ?? "",
429
+ ...e.label != null ? { label: e.label } : {},
430
+ ...e.disabled != null ? { disabled: e.disabled } : {},
431
+ ...e.readonly != null ? { readonly: e.readonly } : {},
432
+ ...e.validator != null ? { validator: g(e.validator, "string") } : {},
433
+ props: b(e)
434
+ })
435
+ }), { gsl: mt, gslByUid: ht } = c({
436
+ itemType: "DATE_PICKER",
437
+ entryShape: "keyed",
438
+ sensibleDefaults: {
439
+ base: {
440
+ suppressAutomaticLabels: !1,
441
+ suppressAutomaticPlaceholders: !1
442
+ },
443
+ fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
444
+ apply: (e, t) => A(m(e, t), t)
445
+ },
446
+ mapToWidget: (e) => ({
447
+ uid: e.uid ?? "",
448
+ kind: "input",
449
+ type: "datePicker",
450
+ path: e.path ?? "",
451
+ ...e.label != null ? { label: e.label } : {},
452
+ ...e.disabled != null ? { disabled: e.disabled } : {},
453
+ ...e.readonly != null ? { readonly: e.readonly } : {},
454
+ ...e.validator != null ? { validator: g(e.validator, "string") } : {},
455
+ props: b(e)
456
+ })
457
+ }), { gsl: gt, gslByUid: St } = c({
458
+ itemType: "RANGE_CALENDAR",
459
+ entryShape: "keyed",
460
+ sensibleDefaults: {
461
+ base: { suppressAutomaticLabels: !1 },
462
+ fields: ["suppressAutomaticLabels"],
463
+ apply: (e, t) => m(e, t)
464
+ },
465
+ mapToWidget: (e) => ({
466
+ uid: e.uid ?? "",
467
+ kind: "input",
468
+ type: "rangeCalendar",
469
+ path: e.path ?? "",
470
+ ...e.label != null ? { label: e.label } : {},
471
+ ...e.disabled != null ? { disabled: e.disabled } : {},
472
+ ...e.readonly != null ? { readonly: e.readonly } : {},
473
+ ...e.validator != null ? { validator: g(e.validator, "array") } : {},
474
+ props: b(e)
475
+ })
476
+ }), { gsl: Tt, gslByUid: At } = c({
477
+ itemType: "RANGE_DATE_INPUT",
478
+ entryShape: "keyed",
479
+ sensibleDefaults: {
480
+ base: { suppressAutomaticLabels: !1 },
481
+ fields: ["suppressAutomaticLabels"],
482
+ apply: (e, t) => m(e, t)
483
+ },
484
+ mapToWidget: (e) => ({
485
+ uid: e.uid ?? "",
486
+ kind: "input",
487
+ type: "rangeDateInput",
488
+ path: e.path ?? "",
489
+ ...e.label != null ? { label: e.label } : {},
490
+ ...e.disabled != null ? { disabled: e.disabled } : {},
491
+ ...e.readonly != null ? { readonly: e.readonly } : {},
492
+ ...e.validator != null ? { validator: g(e.validator, "array") } : {},
493
+ props: b(e)
494
+ })
495
+ }), { gsl: kt, gslByUid: ft } = c({
496
+ itemType: "RANGE_DATE_PICKER",
497
+ entryShape: "keyed",
498
+ sensibleDefaults: {
499
+ base: {
500
+ suppressAutomaticLabels: !1,
501
+ suppressAutomaticPlaceholders: !1
502
+ },
503
+ fields: ["suppressAutomaticLabels", "suppressAutomaticPlaceholders"],
504
+ apply: (e, t) => A(m(e, t), t)
505
+ },
506
+ mapToWidget: (e) => ({
507
+ uid: e.uid ?? "",
508
+ kind: "input",
509
+ type: "rangeDatePicker",
510
+ path: e.path ?? "",
511
+ ...e.label != null ? { label: e.label } : {},
512
+ ...e.disabled != null ? { disabled: e.disabled } : {},
513
+ ...e.readonly != null ? { readonly: e.readonly } : {},
514
+ ...e.validator != null ? { validator: g(e.validator, "array") } : {},
515
+ props: b(e)
516
+ })
517
+ });
518
+ function te(e) {
519
+ const t = {};
520
+ return e.addLabel != null && (t.addLabel = e.addLabel), e.removeLabel != null && (t.removeLabel = e.removeLabel), e.limit != null && (t.limit = e.limit), e.title != null && (t.title = e.title), e.addButtonIcon != null && (t.addButtonIcon = e.addButtonIcon), e.removeButtonIcon != null && (t.removeButtonIcon = e.removeButtonIcon), t;
521
+ }
522
+ function se(e) {
523
+ return {
524
+ uid: e.uid ?? "",
525
+ kind: "input",
526
+ type: "repeater",
527
+ path: e.path ?? "",
528
+ ...e.label != null ? { label: e.label } : {},
529
+ ...e.disabled != null ? { disabled: e.disabled } : {},
530
+ ...e.readonly != null ? { readonly: e.readonly } : {},
531
+ ...e.validator != null ? { validator: g(e.validator, "array") } : {},
532
+ props: {
533
+ ...te(e),
534
+ template: { kind: "layout", type: "flex", children: [], props: { direction: "column" } }
535
+ }
536
+ };
537
+ }
538
+ function D(e, t) {
539
+ for (const s of e) {
540
+ if (typeof s == "function") continue;
541
+ const l = s;
542
+ typeof l.path == "string" && l.path && (l.path = t + l.path), "children" in l && Array.isArray(l.children) && D(l.children, t);
543
+ const a = l.props;
544
+ a?.template?.children && Array.isArray(a.template.children) && D(a.template.children, t);
545
+ }
546
+ }
547
+ function le(e, t) {
548
+ const s = t.walkChildren(t.children ?? []), l = e.kind === "static" ? e.def.path ?? "" : e.fn({})?.path ?? "";
549
+ l && D(s, l + ".items.");
550
+ const a = {
551
+ kind: "layout",
552
+ type: "flex",
553
+ uid: "",
554
+ children: s,
555
+ props: { direction: "column" }
556
+ };
557
+ if (e.kind === "static") {
558
+ const i = t.mapStaticDef(e.def, "REPEATER");
559
+ return {
560
+ ...i,
561
+ props: { ...i.props, template: a }
562
+ };
563
+ }
564
+ const n = e.fn;
565
+ return ((i) => {
566
+ const r = n(i), o = t.mapStaticDef(r, "REPEATER");
567
+ return {
568
+ ...o,
569
+ props: { ...o.props, template: a }
570
+ };
571
+ });
572
+ }
573
+ function ae(e) {
574
+ return {
575
+ baseDef: e.def,
576
+ path: e.key,
577
+ children: e.children
578
+ };
579
+ }
580
+ function ne(e) {
581
+ return e.children;
582
+ }
583
+ const ie = {
584
+ parseEntry: ae,
585
+ rollUpSensibleDefaults: () => ({}),
586
+ applySensibleDefaults: (e) => e,
587
+ mapToWidget: se,
588
+ buildCustomWidget: le,
589
+ getChildren: ne
590
+ };
591
+ F("REPEATER", ie);
592
+ const re = R("REPEATER"), _t = (e, t) => re(t, ((s) => s.uid === e)), $ = {
593
+ onLoad: "load",
594
+ onChange: "change",
595
+ onFilter: "filter",
596
+ onBlur: "blur"
597
+ }, oe = Object.keys($);
598
+ class ue {
599
+ // ── Action-specific: onClick + submit ─────────────────────────
600
+ extractOnClickFromMergeResult(t, s, l, a) {
601
+ if (t.kind === "dynamic") {
602
+ const r = t.fn;
603
+ return { kind: "dynamic", fn: (u) => {
604
+ const p = r(u);
605
+ return this.wireOnClick(p, s, l, a);
606
+ } };
607
+ }
608
+ const n = t.def;
609
+ return { kind: "static", def: this.wireOnClick(n, s, l, a) };
610
+ }
611
+ countSubmitButtons(t) {
612
+ let s = 0;
613
+ for (const l of t) {
614
+ if (l.type !== "ITEMS") continue;
615
+ const a = f(l.itemType);
616
+ for (const n of l.items) {
617
+ const i = a.getChildren?.(n);
618
+ if (i && (s += this.countSubmitButtons(i)), l.itemType === U.ACTIONS) {
619
+ if (typeof n == "function") continue;
620
+ const r = n;
621
+ (r.uid === "#submit" || r.onClick === "submit") && s++;
622
+ }
623
+ }
624
+ }
625
+ return s;
626
+ }
627
+ wireOnClick(t, s, l, a) {
628
+ const n = t.uid === "#submit" || t.onClick === "submit", i = n ? "#submit" : a.next(), r = n ? "submit" : i, o = t.onClick, p = (typeof o == "function" ? o : void 0) ?? (n ? l.onSubmit : void 0);
629
+ if (p) {
630
+ s.set(r, (S) => p(S.data));
631
+ const { onClick: y, ...d } = t;
632
+ return { ...d, uid: i, on: { click: r } };
633
+ }
634
+ if (n) {
635
+ const { onClick: y, ...d } = t;
636
+ return { ...d, uid: i, on: { click: "submit" } };
637
+ }
638
+ if (typeof o == "string") {
639
+ const { onClick: y, ...d } = t;
640
+ return { ...d, uid: i, on: { click: o } };
641
+ }
642
+ return { ...t, uid: i };
643
+ }
644
+ // ── Universal: onLoad, onChange, onFilter ──────────────────────
645
+ wireInputLayoutEvents(t, s, l) {
646
+ if (t.kind === "dynamic") {
647
+ const n = t.fn;
648
+ return { kind: "dynamic", fn: (r) => {
649
+ const o = n(r);
650
+ return this.wireEventProperties(o, s, l);
651
+ } };
652
+ }
653
+ return { kind: "static", def: this.wireEventProperties(t.def, s, l) };
654
+ }
655
+ wireEventProperties(t, s, l) {
656
+ const a = { ...t.on || {} };
657
+ let n = !1;
658
+ const i = { ...t };
659
+ for (const r of oe) {
660
+ const o = t[r];
661
+ if (o == null) continue;
662
+ const u = $[r];
663
+ if (typeof o == "function") {
664
+ const p = l.next();
665
+ s.set(p, o), a[u] = p, n = !0;
666
+ } else typeof o == "string" && (a[u] = o, n = !0);
667
+ delete i[r];
668
+ }
669
+ return n && (i.on = a), i;
670
+ }
671
+ }
672
+ const O = new ue();
673
+ function pe(e) {
674
+ const {
675
+ uid: t,
676
+ label: s,
677
+ disabled: l,
678
+ on: a,
679
+ onClick: n,
680
+ data: i,
681
+ type: r,
682
+ tags: o,
683
+ size: u,
684
+ include: p,
685
+ exclude: y,
686
+ states: d,
687
+ ...S
688
+ } = e;
689
+ return {
690
+ uid: t ?? "",
691
+ kind: "action",
692
+ type: "button",
693
+ disabled: l,
694
+ label: s,
695
+ ...a != null ? { on: a } : {},
696
+ props: S
697
+ };
698
+ }
699
+ const { gsl: Ct, gslByUid: vt } = c({
700
+ itemType: "ACTIONS",
701
+ entryShape: "bare",
702
+ mapToWidget: pe,
703
+ afterMerge: (e, t) => O.extractOnClickFromMergeResult(
704
+ e,
705
+ t.eventRegistry,
706
+ t.formConfig,
707
+ t.eventIdGenerator
708
+ )
709
+ });
710
+ function ce(e) {
711
+ const {
712
+ uid: t,
713
+ widgetName: s,
714
+ tags: l,
715
+ size: a,
716
+ onChange: n,
717
+ include: i,
718
+ exclude: r,
719
+ ...o
720
+ } = e, { on: u, ...p } = o;
721
+ return {
722
+ uid: t ?? "",
723
+ kind: "layout",
724
+ type: s ?? "flex",
725
+ props: {
726
+ direction: p.direction ?? "column",
727
+ ...p
728
+ },
729
+ children: []
730
+ };
731
+ }
732
+ function de(e, t) {
733
+ const s = t.walkChildren(t.children ?? []);
734
+ if (e.kind === "static")
735
+ return { ...t.mapStaticDef(e.def, "LAYOUTS"), children: s };
736
+ const l = e.fn;
737
+ return ((a) => {
738
+ const n = l(a);
739
+ return { ...t.mapStaticDef(n, "LAYOUTS"), children: s };
740
+ });
741
+ }
742
+ function ye(e) {
743
+ return e.children;
744
+ }
745
+ const { gsl: Ut, gslByUid: Ot } = c({
746
+ itemType: "LAYOUTS",
747
+ entryShape: "compound",
748
+ mapToWidget: ce,
749
+ buildCustomWidget: de,
750
+ getChildren: ye
751
+ });
752
+ function be(e) {
753
+ return {
754
+ uid: "",
755
+ kind: "display",
756
+ type: "renderer",
757
+ props: { render: e.render }
758
+ };
759
+ }
760
+ function me(e, t) {
761
+ if (e.kind === "static") {
762
+ const l = e.def;
763
+ return ((a) => ({
764
+ uid: "",
765
+ kind: "display",
766
+ type: "renderer",
767
+ ...l.include != null ? { include: l.include } : {},
768
+ ...l.exclude != null ? { exclude: l.exclude } : {},
769
+ props: { render: l.render(a ?? {}) }
770
+ }));
771
+ }
772
+ const s = e.fn;
773
+ return ((l) => {
774
+ const a = s(l);
775
+ return {
776
+ uid: "",
777
+ kind: "display",
778
+ type: "renderer",
779
+ ...a.include != null ? { include: a.include } : {},
780
+ ...a.exclude != null ? { exclude: a.exclude } : {},
781
+ props: { render: a.render(l ?? {}) }
782
+ };
783
+ });
784
+ }
785
+ const { gsl: Lt, gslByUid: Et } = c({
786
+ itemType: "DISPLAYS",
787
+ entryShape: "bare",
788
+ mapToWidget: be,
789
+ buildCustomWidget: me
790
+ }), { gsl: Dt, gslByUid: It } = c({
791
+ itemType: "ALERTS",
792
+ entryShape: "bare",
793
+ mapToWidget: (e) => ({
794
+ uid: e.uid ?? "",
795
+ kind: "display",
796
+ type: "alert",
797
+ props: {
798
+ text: e.text,
799
+ ...e.level != null ? { level: e.level } : {}
800
+ }
801
+ })
802
+ });
803
+ function he(e) {
804
+ return {
805
+ uid: e.uid ?? "",
806
+ kind: "layout",
807
+ type: "tabs",
808
+ props: {
809
+ tabs: e.tabs,
810
+ renderMode: e.renderMode ?? "all",
811
+ ...e.defaultOpen != null ? { defaultOpen: e.defaultOpen } : {}
812
+ },
813
+ children: []
814
+ };
815
+ }
816
+ function ge(e, t) {
817
+ const s = t.walkChildren(t.children ?? []);
818
+ if (e.kind === "static")
819
+ return { ...t.mapStaticDef(e.def, "TABS"), children: s };
820
+ const l = e.fn;
821
+ return ((a) => {
822
+ const n = l(a);
823
+ return { ...t.mapStaticDef(n, "TABS"), children: s };
824
+ });
825
+ }
826
+ function Se(e) {
827
+ return e.children;
828
+ }
829
+ const { gsl: Pt, gslByUid: Wt } = c({
830
+ itemType: "TABS",
831
+ entryShape: "compound",
832
+ mapToWidget: he,
833
+ buildCustomWidget: ge,
834
+ getChildren: Se
835
+ });
836
+ function Te(e) {
837
+ return {
838
+ uid: e.uid ?? "",
839
+ kind: "layout",
840
+ type: "accordion",
841
+ props: {
842
+ sections: e.sections,
843
+ renderMode: e.renderMode ?? "all",
844
+ ...e.singleOpen != null ? { singleOpen: e.singleOpen } : {},
845
+ ...e.defaultOpen != null ? { defaultOpen: e.defaultOpen } : {}
846
+ },
847
+ children: []
848
+ };
849
+ }
850
+ function Ae(e, t) {
851
+ const s = t.walkChildren(t.children ?? []);
852
+ if (e.kind === "static")
853
+ return { ...t.mapStaticDef(e.def, "ACCORDION"), children: s };
854
+ const l = e.fn;
855
+ return ((a) => {
856
+ const n = l(a);
857
+ return { ...t.mapStaticDef(n, "ACCORDION"), children: s };
858
+ });
859
+ }
860
+ function ke(e) {
861
+ return e.children;
862
+ }
863
+ const { gsl: wt, gslByUid: Bt } = c({
864
+ itemType: "ACCORDION",
865
+ entryShape: "compound",
866
+ mapToWidget: Te,
867
+ buildCustomWidget: Ae,
868
+ getChildren: ke
869
+ }), { gsl: Mt, gslByUid: Nt } = c({
870
+ itemType: "CUSTOM_INPUT",
871
+ entryShape: "keyed",
872
+ sensibleDefaults: {
873
+ base: {
874
+ suppressAutomaticLabels: !1
875
+ },
876
+ fields: ["suppressAutomaticLabels"],
877
+ apply: (e, t) => m(e, t)
878
+ },
879
+ mapToWidget: (e) => ({
880
+ uid: e.uid ?? "",
881
+ kind: "input",
882
+ type: e.customType,
883
+ path: e.path ?? "",
884
+ ...e.label != null ? { label: e.label } : {},
885
+ ...e.disabled != null ? { disabled: e.disabled } : {},
886
+ ...e.readonly != null ? { readonly: e.readonly } : {},
887
+ ...e.defaultValue != null ? { defaultValue: e.defaultValue } : {},
888
+ ...e.validator != null ? { validator: e.validator } : {},
889
+ props: e.props ?? {}
890
+ })
891
+ }), { gsl: Rt, gslByUid: xt } = c({
892
+ itemType: "CUSTOM_ACTION",
893
+ entryShape: "bare",
894
+ mapToWidget: (e) => {
895
+ const {
896
+ uid: t,
897
+ label: s,
898
+ disabled: l,
899
+ on: a,
900
+ onClick: n,
901
+ data: i,
902
+ customType: r,
903
+ tags: o,
904
+ size: u,
905
+ include: p,
906
+ exclude: y,
907
+ states: d,
908
+ props: S,
909
+ ..._
910
+ } = e;
911
+ return {
912
+ uid: t ?? "",
913
+ kind: "action",
914
+ type: e.customType,
915
+ label: s,
916
+ disabled: l,
917
+ ...a != null ? { on: a } : {},
918
+ props: { ...S, ..._ }
919
+ };
920
+ },
921
+ afterMerge: (e, t) => O.extractOnClickFromMergeResult(
922
+ e,
923
+ t.eventRegistry,
924
+ t.formConfig,
925
+ t.eventIdGenerator
926
+ )
927
+ }), { gsl: Ft, gslByUid: jt } = c({
928
+ itemType: "CUSTOM_DISPLAY",
929
+ entryShape: "bare",
930
+ mapToWidget: (e) => ({
931
+ uid: e.uid ?? "",
932
+ kind: "display",
933
+ type: e.customType,
934
+ props: e.props ?? {}
935
+ })
936
+ });
937
+ function fe(e) {
938
+ return {
939
+ uid: e.uid ?? "",
940
+ kind: "layout",
941
+ type: e.customType,
942
+ props: e.props ?? {},
943
+ children: []
944
+ };
945
+ }
946
+ function _e(e, t) {
947
+ const s = t.walkChildren(t.children ?? []);
948
+ if (e.kind === "static")
949
+ return { ...t.mapStaticDef(e.def, "CUSTOM_LAYOUT"), children: s };
950
+ const l = e.fn;
951
+ return ((a) => {
952
+ const n = l(a);
953
+ return { ...t.mapStaticDef(n, "CUSTOM_LAYOUT"), children: s };
954
+ });
955
+ }
956
+ function Ce(e) {
957
+ return e.children;
958
+ }
959
+ const { gsl: $t, gslByUid: Yt } = c({
960
+ itemType: "CUSTOM_LAYOUT",
961
+ entryShape: "compound",
962
+ mapToWidget: fe,
963
+ buildCustomWidget: _e,
964
+ getChildren: Ce
965
+ }), Y = {
966
+ INPUTS: /* @__PURE__ */ new Set([
967
+ "INPUTS",
968
+ "TEXTAREA",
969
+ "PASSWORD",
970
+ "SELECT",
971
+ "DROPDOWN",
972
+ "RADIOGROUP",
973
+ "CHECKBOX",
974
+ "CALENDAR",
975
+ "DATE_INPUT",
976
+ "DATE_PICKER",
977
+ "RANGE_CALENDAR",
978
+ "RANGE_DATE_INPUT",
979
+ "RANGE_DATE_PICKER",
980
+ "CURRENCY",
981
+ "MARKDOWN",
982
+ "LIST",
983
+ "CUSTOM_INPUT",
984
+ "REPEATER"
985
+ ]),
986
+ ACTIONS: /* @__PURE__ */ new Set(["ACTIONS", "CUSTOM_ACTION"]),
987
+ DISPLAYS: /* @__PURE__ */ new Set(["DISPLAYS", "ALERTS", "CUSTOM_DISPLAY"]),
988
+ LAYOUTS: /* @__PURE__ */ new Set(["LAYOUTS", "TABS", "ACCORDION", "CUSTOM_LAYOUT"])
989
+ };
990
+ function ve(e, t) {
991
+ const s = Y[e];
992
+ return s ? s.has(t) : e === t;
993
+ }
994
+ class Ue {
995
+ resolve(t, s) {
996
+ const l = [];
997
+ for (const n of s)
998
+ n.kind === "aggregated" ? this.collectFromAggregated(n, t, l) : this.collectFromLeaf(n, t, l);
999
+ const a = this.rollUpSensibleDefaults(l);
1000
+ return {
1001
+ leafSelectors: l,
1002
+ sensibleDefaults: a
1003
+ };
1004
+ }
1005
+ collectFromAggregated(t, s, l) {
1006
+ if (t.matcher(s))
1007
+ for (const a of t.children)
1008
+ this.collectFromLeaf(a, s, l);
1009
+ }
1010
+ collectFromLeaf(t, s, l) {
1011
+ ve(t.selectorType, s.itemType ?? "") && t.matcher(s) && l.push(t);
1012
+ }
1013
+ rollUpSensibleDefaults(t) {
1014
+ const s = /* @__PURE__ */ new Map(), l = (n, i) => {
1015
+ const r = s.get(n) ?? [];
1016
+ r.push(i), s.set(n, r);
1017
+ };
1018
+ for (const n of t) {
1019
+ const i = Y[n.selectorType];
1020
+ if (i)
1021
+ for (const r of i) l(r, n);
1022
+ else
1023
+ l(n.selectorType, n);
1024
+ }
1025
+ const a = {};
1026
+ for (const [n, i] of s)
1027
+ j(n) && (a[n] = f(n).rollUpSensibleDefaults(i));
1028
+ return a;
1029
+ }
1030
+ }
1031
+ const Oe = new Ue();
1032
+ class Le {
1033
+ constructor(t) {
1034
+ this.objectUtils = t;
1035
+ }
1036
+ merge(t, s, l) {
1037
+ let a = {}, n = null;
1038
+ typeof t == "function" && (n = t);
1039
+ const i = this.collectDecorators(l);
1040
+ for (const u of i) {
1041
+ if (n != null) {
1042
+ n = this.composeRuntimeFunctions(n, u);
1043
+ continue;
1044
+ }
1045
+ if (typeof u == "function") {
1046
+ const p = u({
1047
+ ...a,
1048
+ ...typeof t == "function" ? {} : t
1049
+ });
1050
+ if (typeof p == "function") {
1051
+ n = this.createPromotedFunction(
1052
+ a,
1053
+ t,
1054
+ p,
1055
+ s,
1056
+ l
1057
+ );
1058
+ continue;
1059
+ }
1060
+ a = this.objectUtils.deepMerge(a, p);
1061
+ } else
1062
+ a = this.objectUtils.deepMerge(a, u);
1063
+ }
1064
+ if (n != null)
1065
+ return {
1066
+ kind: "dynamic",
1067
+ fn: this.wrapWithSensibleDefaults(n, a, s, l)
1068
+ };
1069
+ const r = this.objectUtils.deepMerge(t, a);
1070
+ return { kind: "static", def: this.applySensibleDefaults({ ...r }, s, l) };
1071
+ }
1072
+ // ── Collect all decorators in priority order ──
1073
+ collectDecorators(t) {
1074
+ const s = [];
1075
+ for (const l of t.leafSelectors) {
1076
+ const a = l.config;
1077
+ a.override != null && s.push(a.override);
1078
+ }
1079
+ return s;
1080
+ }
1081
+ // ── Apply sensible defaults via registry ──
1082
+ applySensibleDefaults(t, s, l) {
1083
+ if (!j(s)) return t;
1084
+ const a = l.sensibleDefaults[s] ?? {};
1085
+ return f(s).applySensibleDefaults(t, a);
1086
+ }
1087
+ // ── Create promoted FunctionWidget ──
1088
+ createPromotedFunction(t, s, l, a, n) {
1089
+ return (i) => {
1090
+ const r = l(i);
1091
+ let o = this.objectUtils.deepMerge(t, r);
1092
+ return o = this.objectUtils.deepMerge(o, s), this.applySensibleDefaults(o, a, n);
1093
+ };
1094
+ }
1095
+ // ── Wrap runtime function with accumulated static decorators and sensible defaults ──
1096
+ wrapWithSensibleDefaults(t, s, l, a) {
1097
+ return (n) => {
1098
+ let i = t(n);
1099
+ return Object.keys(s).length > 0 && (i = this.objectUtils.deepMerge(s, i)), this.applySensibleDefaults(i, l, a);
1100
+ };
1101
+ }
1102
+ // ── Compose two runtime functions ──
1103
+ composeRuntimeFunctions(t, s) {
1104
+ return typeof s == "function" ? (l) => {
1105
+ const a = t(l), n = s(a);
1106
+ return typeof n == "function" ? n(l) : this.objectUtils.deepMerge(n, a);
1107
+ } : (l) => {
1108
+ const a = t(l);
1109
+ return this.objectUtils.deepMerge(a, s);
1110
+ };
1111
+ }
1112
+ }
1113
+ const Ee = new Le(x);
1114
+ class De {
1115
+ mapToWidget(t, s) {
1116
+ if (t.kind === "dynamic") {
1117
+ const l = t.fn;
1118
+ return ((a) => {
1119
+ const n = l(a);
1120
+ return this.mapStaticDef(n, s);
1121
+ });
1122
+ }
1123
+ return this.mapStaticDef(t.def, s);
1124
+ }
1125
+ mapStaticDef(t, s) {
1126
+ const l = f(s).mapToWidget(t);
1127
+ return this.applyBaseWidgetFields(l, t);
1128
+ }
1129
+ /**
1130
+ * Injects BaseWidget-level fields that all widget types share.
1131
+ * Centralized here so individual mappers don't need to repeat the pattern.
1132
+ */
1133
+ applyBaseWidgetFields(t, s) {
1134
+ return s.size != null && (t.size = s.size), s.defaultValue != null && t.kind === "input" && (t.defaultValue = s.defaultValue), s.on != null && (t.on = s.on), s.include != null && (t.include = s.include), s.exclude != null && (t.exclude = s.exclude), t;
1135
+ }
1136
+ }
1137
+ const Ie = new De();
1138
+ class Pe {
1139
+ /**
1140
+ * Ensures the output is always a uniform GslSelector[] of aggregated selectors.
1141
+ *
1142
+ * Callers can pass flat leaf selectors (single styling rules) or pre-grouped
1143
+ * aggregated selectors. This method separates them into two buckets, then wraps
1144
+ * any bare leaves into a catch-all aggregated selector so downstream code only
1145
+ * deals with one shape.
1146
+ */
1147
+ normalizeSelectors(t) {
1148
+ const s = Array.isArray(t) ? t : [t], l = [], a = [];
1149
+ for (const n of s)
1150
+ n.kind === "leaf" ? a.push(n) : l.push(n);
1151
+ return a.length > 0 && l.unshift({
1152
+ kind: "aggregated",
1153
+ matcher: () => !0,
1154
+ children: a
1155
+ }), l;
1156
+ }
1157
+ extractFormConfig() {
1158
+ return {
1159
+ suppressAutomaticStack: !1,
1160
+ suppressAutomaticSubmit: !1,
1161
+ onSubmit: (t) => console.log("Form submitted:", t)
1162
+ };
1163
+ }
1164
+ }
1165
+ const We = new Pe(), we = {
1166
+ input: /* @__PURE__ */ new Set(["disabled", "readonly", "label", "validator", "size"]),
1167
+ action: /* @__PURE__ */ new Set(["disabled", "label", "size"]),
1168
+ layout: /* @__PURE__ */ new Set(["size"]),
1169
+ display: /* @__PURE__ */ new Set([])
1170
+ }, w = {
1171
+ onChange: "change",
1172
+ onLoad: "load",
1173
+ onFilter: "filter",
1174
+ onClick: "click"
1175
+ };
1176
+ class Be {
1177
+ /**
1178
+ * Extracts `states` from a merge result, combining with state-targeted
1179
+ * GSL leaf selectors from `_gslStates`.
1180
+ *
1181
+ * Returns a cleaned merge result (no states) and accumulated state data.
1182
+ */
1183
+ extractFromMergeResult(t, s) {
1184
+ const l = {};
1185
+ for (const r of s) {
1186
+ const o = r.targetState, u = r.config, p = u.override && typeof u.override != "function" ? u.override : u;
1187
+ l[o] = {
1188
+ ...l[o] || {},
1189
+ ...p
1190
+ };
1191
+ }
1192
+ if (t.kind === "dynamic") {
1193
+ const r = t.fn;
1194
+ return {
1195
+ cleanedResult: { kind: "dynamic", fn: (u) => {
1196
+ const p = r(u), { states: y, ...d } = p;
1197
+ return d;
1198
+ } },
1199
+ stateData: { stateOverrides: l }
1200
+ };
1201
+ }
1202
+ const { states: a, ...n } = t.def, i = {};
1203
+ for (const [r, o] of Object.entries(l))
1204
+ i[r] = { ...o };
1205
+ if (a)
1206
+ for (const [r, o] of Object.entries(
1207
+ a
1208
+ ))
1209
+ i[r] = { ...i[r] || {}, ...o };
1210
+ return {
1211
+ cleanedResult: { kind: "static", def: n },
1212
+ stateData: { stateOverrides: i }
1213
+ };
1214
+ }
1215
+ /**
1216
+ * Applies state overrides to a core widget. Each override produces:
1217
+ * - `visible: true/false` → `include: { in }` / `exclude: { from }`
1218
+ * - Core suffixable props → `'prop.stateName': value` at widget root
1219
+ * - Event handlers → `on: { 'eventType.stateName': eventId }` with registry wiring
1220
+ * - Custom props → `props: { 'prop.stateName': value }`
1221
+ */
1222
+ applyToWidget(t, s, l, a) {
1223
+ const { stateOverrides: n } = s;
1224
+ if (Object.keys(n).length === 0)
1225
+ return t;
1226
+ const i = { ...t }, r = t.kind, o = we[r] || /* @__PURE__ */ new Set();
1227
+ t.props && (i.props = { ...t.props }), t.on && (i.on = { ...t.on });
1228
+ for (const [u, p] of Object.entries(n))
1229
+ for (const [y, d] of Object.entries(p))
1230
+ y === "visible" ? this.applyVisibility(i, u, d) : w[y] ? this.applyStateEvent(i, u, y, d, l, a) : o.has(y) ? i[`${y}.${u}`] = d : (i.props || (i.props = {}), i.props[`${y}.${u}`] = d);
1231
+ return i;
1232
+ }
1233
+ hasStateData(t) {
1234
+ return Object.keys(t.stateOverrides).length > 0;
1235
+ }
1236
+ // ── Visibility helpers ──
1237
+ applyVisibility(t, s, l) {
1238
+ if (l) {
1239
+ const a = t.include?.in || [];
1240
+ t.include = { ...t.include || {}, in: [...a, s] };
1241
+ } else {
1242
+ const a = t.exclude?.from || [];
1243
+ t.exclude = { ...t.exclude || {}, from: [...a, s] };
1244
+ }
1245
+ }
1246
+ // ── State-suffixed event helpers ──
1247
+ applyStateEvent(t, s, l, a, n, i) {
1248
+ const r = w[l];
1249
+ if (t.on || (t.on = {}), typeof a == "function") {
1250
+ const o = i.next();
1251
+ n.set(o, a), t.on[`${r}.${s}`] = o;
1252
+ } else typeof a == "string" && (t.on[`${r}.${s}`] = a);
1253
+ }
1254
+ }
1255
+ const Me = new Be();
1256
+ function Ne() {
1257
+ let e = 0;
1258
+ return { next: () => `event_${e++}` };
1259
+ }
1260
+ class Re {
1261
+ constructor(t, s, l, a, n) {
1262
+ this.resolver = t, this.merger = s, this.mapper = l, this.eventWiring = a, this.stateExpansion = n;
1263
+ }
1264
+ walkAndMap(t, s, l) {
1265
+ const a = /* @__PURE__ */ new Map(), n = Ne(), i = { value: 0 }, r = /* @__PURE__ */ new Set();
1266
+ return { widgets: this.walkItems(
1267
+ t,
1268
+ s,
1269
+ a,
1270
+ l,
1271
+ n,
1272
+ i,
1273
+ r
1274
+ ), eventRegistry: a };
1275
+ }
1276
+ walkItems(t, s, l, a, n, i, r) {
1277
+ return t.flatMap((o) => {
1278
+ if (o.type !== "ITEMS")
1279
+ throw new Error("Unexpected gui shortcut type");
1280
+ return o.items.map((u) => this.processItem(
1281
+ u,
1282
+ o.itemType,
1283
+ o.tags,
1284
+ s,
1285
+ l,
1286
+ a,
1287
+ n,
1288
+ i,
1289
+ r
1290
+ ));
1291
+ });
1292
+ }
1293
+ processItem(t, s, l, a, n, i, r, o, u) {
1294
+ const p = s, y = f(s), d = y.parseEntry(t), S = this.buildBaseDef(d), _ = this.buildDecoratorForMatching(S, p, l), C = this.resolver.resolve(_, a), I = C.leafSelectors.filter((h) => h.targetState != null), P = {
1295
+ leafSelectors: C.leafSelectors.filter((h) => h.targetState == null),
1296
+ sensibleDefaults: C.sensibleDefaults
1297
+ };
1298
+ let k = this.merger.merge(S, p, P);
1299
+ y.afterMerge && (k = y.afterMerge(k, {
1300
+ eventRegistry: n,
1301
+ formConfig: i,
1302
+ eventIdGenerator: r
1303
+ })), k = this.eventWiring.wireInputLayoutEvents(
1304
+ k,
1305
+ n,
1306
+ r
1307
+ );
1308
+ const { cleanedResult: W, stateData: L } = this.stateExpansion.extractFromMergeResult(
1309
+ k,
1310
+ I
1311
+ );
1312
+ let T;
1313
+ if (y.buildCustomWidget) {
1314
+ const h = this.buildCustomWidgetContext(
1315
+ d.children,
1316
+ a,
1317
+ n,
1318
+ i,
1319
+ r,
1320
+ o,
1321
+ u
1322
+ );
1323
+ T = this.buildCustomWidget(y, W, h);
1324
+ } else
1325
+ T = this.mapper.mapToWidget(W, p);
1326
+ if (typeof T != "function") {
1327
+ const h = T;
1328
+ h.uid || (h.path && !u.has(h.path) ? (h.uid = h.path, u.add(h.path)) : h.uid = `dx_${o.value++}`);
1329
+ }
1330
+ if (this.stateExpansion.hasStateData(L))
1331
+ if (typeof T == "function") {
1332
+ const h = T;
1333
+ T = ((z) => {
1334
+ const K = h(z);
1335
+ return this.stateExpansion.applyToWidget(
1336
+ K,
1337
+ L,
1338
+ n,
1339
+ r
1340
+ );
1341
+ });
1342
+ } else
1343
+ T = this.stateExpansion.applyToWidget(
1344
+ T,
1345
+ L,
1346
+ n,
1347
+ r
1348
+ );
1349
+ return T;
1350
+ }
1351
+ buildCustomWidgetContext(t, s, l, a, n, i, r) {
1352
+ return {
1353
+ children: t,
1354
+ mapStaticDef: (o, u) => this.mapper.mapStaticDef(o, u),
1355
+ walkChildren: (o) => this.walkItems(
1356
+ o,
1357
+ s,
1358
+ l,
1359
+ a,
1360
+ n,
1361
+ i,
1362
+ r
1363
+ )
1364
+ };
1365
+ }
1366
+ buildCustomWidget(t, s, l) {
1367
+ return t.buildCustomWidget(s, l);
1368
+ }
1369
+ /**
1370
+ * Resolves the base definition from a parsed entry, injecting the path for keyed entries.
1371
+ * For runtime (function) providers, wraps them to inject the path at evaluation time.
1372
+ */
1373
+ buildBaseDef(t) {
1374
+ const s = t.baseDef;
1375
+ return typeof s == "function" ? (l) => {
1376
+ const n = s(l ?? {});
1377
+ return t.path != null ? { ...n, path: t.path } : n;
1378
+ } : t.path != null ? { ...s, path: t.path } : s;
1379
+ }
1380
+ buildDecoratorForMatching(t, s, l) {
1381
+ if (typeof t == "function")
1382
+ return { itemType: s, tags: [...l] };
1383
+ const a = [...l, ..."tags" in t && t.tags ? t.tags : []], n = "uid" in t ? t.uid : void 0, i = "type" in t ? t.type : void 0;
1384
+ return { itemType: s, tags: a, uid: n, type: i };
1385
+ }
1386
+ }
1387
+ class xe {
1388
+ constructor(t, s, l) {
1389
+ this.selectorNormalizer = t, this.eventWiring = s, this.walker = l;
1390
+ }
1391
+ processDxFacade(t, s = [], l) {
1392
+ const { defs: a, gslSelectors: n, formConfig: i } = this.prepareForm(
1393
+ t,
1394
+ s,
1395
+ l
1396
+ ), { widgets: r, eventRegistry: o } = this.walker.walkAndMap(
1397
+ a,
1398
+ n,
1399
+ i
1400
+ ), u = r[0];
1401
+ return this.buildResult({ form: u }, o, i);
1402
+ }
1403
+ /**
1404
+ * Normalizes raw form definitions and applies form-level defaults.
1405
+ *
1406
+ * Steps:
1407
+ * 1. Normalize definitions — ensure a flat array; convert bare functions to display widgets.
1408
+ * 2. Normalize selectors — convert mixed leaf/aggregated selectors into a uniform
1409
+ * aggregated shape, and extract form-level config (see {@link FormConfig}).
1410
+ * 3. Auto-submit — unless suppressed, append a submit button if none was declared.
1411
+ * Throws if more than one submit button is found.
1412
+ * 4. Auto-stack — unless suppressed, wrap all definitions in a synthetic root
1413
+ * flex column layout so the form renders as a single vertical container.
1414
+ */
1415
+ prepareForm(t, s, l) {
1416
+ const n = (Array.isArray(t) ? [...t] : [t]).map(
1417
+ (u) => typeof u == "function" ? H(u) : u
1418
+ ), i = this.selectorNormalizer.normalizeSelectors(s), r = {
1419
+ ...this.selectorNormalizer.extractFormConfig(),
1420
+ ...l
1421
+ }, o = this.eventWiring.countSubmitButtons(n);
1422
+ if (o > 1)
1423
+ throw new Error(
1424
+ `Only one submit button is allowed per form, but ${o} were found. A button is a submit button if it has uid: '#submit' or onClick: 'submit'.`
1425
+ );
1426
+ if (!r.suppressAutomaticSubmit && o === 0 && n.push(X()), !r.suppressAutomaticStack) {
1427
+ const u = {
1428
+ def: { uid: "#root", direction: "column", widgetName: "flex" },
1429
+ children: n
1430
+ };
1431
+ return {
1432
+ defs: [{ type: "ITEMS", itemType: U.LAYOUTS, items: [u], tags: [] }],
1433
+ gslSelectors: i,
1434
+ formConfig: r
1435
+ };
1436
+ }
1437
+ return { defs: n, gslSelectors: i, formConfig: r };
1438
+ }
1439
+ /**
1440
+ * Converts DX `$`-separated state names to core's `:`-separated names.
1441
+ * E.g. `{ register$adult: 'expr' }` → `{ 'register:adult': 'expr' }`.
1442
+ */
1443
+ convertStateNames(t) {
1444
+ const s = {};
1445
+ for (const [l, a] of Object.entries(t))
1446
+ s[l.replace(/\$/g, ":")] = a;
1447
+ return s;
1448
+ }
1449
+ buildResult(t, s, l) {
1450
+ l.states && Object.keys(l.states).length > 0 && (t = {
1451
+ ...t,
1452
+ states: this.convertStateNames(l.states)
1453
+ });
1454
+ const a = { form: t };
1455
+ return s.size > 0 && (a.events = (n) => {
1456
+ const i = s.get(n.name);
1457
+ if (i) {
1458
+ const r = (u) => {
1459
+ if (u && typeof u == "object" && "path" in u && !("type" in u)) {
1460
+ const { path: p, ...y } = u;
1461
+ for (const [d, S] of Object.entries(y))
1462
+ n.callback({
1463
+ type: "OVERRIDE_WIDGET_PROP",
1464
+ payload: { path: p, prop: d, value: S }
1465
+ });
1466
+ } else
1467
+ n.callback(u);
1468
+ }, o = {
1469
+ ...n,
1470
+ callback: r,
1471
+ update: r
1472
+ };
1473
+ i(o);
1474
+ }
1475
+ }), l.dependencies && (a.dependencies = l.dependencies), l.widgetLoaders && (a.widgetLoaders = l.widgetLoaders), l.validateOn && (a.validateOn = l.validateOn), l.itemRenderers && (a.itemRenderers = l.itemRenderers), a;
1476
+ }
1477
+ }
1478
+ const Fe = new Re(
1479
+ Oe,
1480
+ Ee,
1481
+ Ie,
1482
+ O,
1483
+ Me
1484
+ ), je = new xe(We, O, Fe);
1485
+ function $e(e) {
1486
+ return typeof e == "function" ? !0 : Array.isArray(e) ? e.length === 0 || e.every(B) : B(e);
1487
+ }
1488
+ function B(e) {
1489
+ if (typeof e == "function") return !0;
1490
+ if (e === null || typeof e != "object") return !1;
1491
+ const t = e;
1492
+ return t.type === "ITEMS" && typeof t.itemType == "string";
1493
+ }
1494
+ const M = Object.freeze({}), Ye = Object.freeze({}), N = /* @__PURE__ */ new WeakMap();
1495
+ function E(e, t) {
1496
+ return e == null ? t : typeof e == "object" ? e : {};
1497
+ }
1498
+ function zt(e, t, s) {
1499
+ if (!$e(e))
1500
+ return { formDef: e };
1501
+ const l = E(e, M), a = E(t, M), n = E(s, Ye);
1502
+ let i = N.get(l);
1503
+ i || (i = /* @__PURE__ */ new WeakMap(), N.set(l, i));
1504
+ let r = i.get(a);
1505
+ r || (r = /* @__PURE__ */ new WeakMap(), i.set(a, r));
1506
+ const o = r.get(n);
1507
+ if (o) return o;
1508
+ const u = je.processDxFacade(
1509
+ e,
1510
+ t,
1511
+ s
1512
+ ), p = {
1513
+ formDef: u.form,
1514
+ formEvent: u.events,
1515
+ dependencies: u.dependencies,
1516
+ widgetLoaders: u.widgetLoaders,
1517
+ validateOn: u.validateOn,
1518
+ itemRenderers: u.itemRenderers
1519
+ };
1520
+ return r.set(n, p), p;
1521
+ }
1522
+ export {
1523
+ $t as $,
1524
+ St as A,
1525
+ Tt as B,
1526
+ At as C,
1527
+ kt as D,
1528
+ ft as E,
1529
+ re as F,
1530
+ U as G,
1531
+ _t as H,
1532
+ Ct as I,
1533
+ vt as J,
1534
+ Ut as K,
1535
+ Ot as L,
1536
+ Lt as M,
1537
+ Et as N,
1538
+ Dt as O,
1539
+ It as P,
1540
+ Pt as Q,
1541
+ Wt as R,
1542
+ wt as S,
1543
+ Bt as T,
1544
+ Mt as U,
1545
+ Nt as V,
1546
+ Rt as W,
1547
+ xt as X,
1548
+ Ft as Y,
1549
+ jt as Z,
1550
+ Ke as _,
1551
+ Ve as a,
1552
+ Yt as a0,
1553
+ H as a1,
1554
+ X as a2,
1555
+ G as a3,
1556
+ R as a4,
1557
+ c as a5,
1558
+ b as a6,
1559
+ je as a7,
1560
+ $e as a8,
1561
+ m as a9,
1562
+ A as aa,
1563
+ zt as ab,
1564
+ Ge as b,
1565
+ Xe as c,
1566
+ He as d,
1567
+ Ze as e,
1568
+ qe as f,
1569
+ Je as g,
1570
+ Qe as h,
1571
+ et as i,
1572
+ tt as j,
1573
+ st as k,
1574
+ lt as l,
1575
+ at as m,
1576
+ nt as n,
1577
+ it as o,
1578
+ rt as p,
1579
+ ot as q,
1580
+ ut as r,
1581
+ pt as s,
1582
+ ct as t,
1583
+ dt as u,
1584
+ yt as v,
1585
+ bt as w,
1586
+ mt as x,
1587
+ ht as y,
1588
+ gt as z
1589
+ };