@golemui/core 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +517 -0
  2. package/README.md +11 -0
  3. package/index.d.ts +18 -0
  4. package/index.js +1598 -0
  5. package/index.umd.cjs +8 -0
  6. package/lib/context/form.context.d.ts +21 -0
  7. package/lib/context/index.d.ts +3 -0
  8. package/lib/context/widget-registry.d.ts +13 -0
  9. package/lib/context/with-widget.type.d.ts +4 -0
  10. package/lib/form-store.d.ts +12 -0
  11. package/lib/form-validator.d.ts +10 -0
  12. package/lib/form-widget.d.ts +93 -0
  13. package/lib/form.d.ts +22 -0
  14. package/lib/i18n.d.ts +87 -0
  15. package/lib/item-renderer.d.ts +24 -0
  16. package/lib/middleware/index.d.ts +2 -0
  17. package/lib/middleware/json-schema/json-schema.d.ts +67 -0
  18. package/lib/middleware/json-schema/json-schema.middleware.d.ts +19 -0
  19. package/lib/shared.d.ts +143 -0
  20. package/lib/store/actions.d.ts +121 -0
  21. package/lib/store/model.d.ts +107 -0
  22. package/lib/store/reducer.d.ts +10 -0
  23. package/lib/store/reducers/add-widget.d.ts +3 -0
  24. package/lib/store/reducers/calculate-current-state.d.ts +2 -0
  25. package/lib/store/reducers/calculate-widget-flags.d.ts +2 -0
  26. package/lib/store/reducers/calculate-widget-props.d.ts +3 -0
  27. package/lib/store/reducers/index.d.ts +13 -0
  28. package/lib/store/reducers/initialize.d.ts +3 -0
  29. package/lib/store/reducers/inject-validation-issues.d.ts +3 -0
  30. package/lib/store/reducers/override-widget-prop.d.ts +3 -0
  31. package/lib/store/reducers/remove-widget.d.ts +3 -0
  32. package/lib/store/reducers/set-data.d.ts +3 -0
  33. package/lib/store/reducers/set-form-health.d.ts +8 -0
  34. package/lib/store/reducers/set-language.d.ts +3 -0
  35. package/lib/store/reducers/set-widget-data.d.ts +3 -0
  36. package/lib/store/reducers/utils.d.ts +32 -0
  37. package/lib/store/reducers/validate-all.d.ts +3 -0
  38. package/lib/store/selectors.d.ts +21 -0
  39. package/lib/utils/array.d.ts +61 -0
  40. package/lib/utils/assert-never.d.ts +5 -0
  41. package/lib/utils/debug.d.ts +3 -0
  42. package/lib/utils/decoder.d.ts +51 -0
  43. package/lib/utils/dot-path.d.ts +16 -0
  44. package/lib/utils/form.d.ts +20 -0
  45. package/lib/utils/function.d.ts +71 -0
  46. package/lib/utils/object.d.ts +140 -0
  47. package/lib/utils/random.d.ts +1 -0
  48. package/lib/utils/repeater.d.ts +2 -0
  49. package/lib/utils/suffixable.d.ts +16 -0
  50. package/lib/utils/types.d.ts +63 -0
  51. package/package.json +30 -0
package/index.js ADDED
@@ -0,0 +1,1598 @@
1
+ import { BehaviorSubject as Dr, distinctUntilChanged as w, pipe as D, map as I, filter as ae, startWith as kr, Subject as Fr } from "rxjs";
2
+ var Tr = class {
3
+ constructor(e) {
4
+ this.value = e;
5
+ }
6
+ map(e) {
7
+ return k(e(this.value));
8
+ }
9
+ isOk() {
10
+ return !0;
11
+ }
12
+ }, _r = class {
13
+ constructor(e) {
14
+ this.error = e;
15
+ }
16
+ map(e) {
17
+ return v(this.error);
18
+ }
19
+ isOk() {
20
+ return !1;
21
+ }
22
+ };
23
+ function k(e) {
24
+ return new Tr(e);
25
+ }
26
+ function v(e) {
27
+ return new _r(e);
28
+ }
29
+ var C = class we {
30
+ constructor(r) {
31
+ this.decodeFn = r, this["~standard"] = { version: 1, vendor: "ts.data.json", validate: (t) => {
32
+ let n = this.decode(t);
33
+ return n.isOk() ? { value: n.value } : { issues: [{ message: n.error }] };
34
+ } }, this.decodeToPromise = this.decodePromise, this.chain = this.flatMap;
35
+ }
36
+ parse(r) {
37
+ let t = this.decode(r);
38
+ if (t.isOk()) return t.value;
39
+ throw t.error;
40
+ }
41
+ decode(r) {
42
+ return this.decodeFn(r);
43
+ }
44
+ decodePromise(r) {
45
+ return new Promise((t, n) => {
46
+ let o = this.decode(r);
47
+ return o.isOk() ? t(o.value) : n(o.error);
48
+ });
49
+ }
50
+ map(r) {
51
+ return new we((t) => {
52
+ let n = this.decodeFn(t);
53
+ return n.isOk() ? k(r(n.value)) : v(n.error);
54
+ });
55
+ }
56
+ flatMap(r) {
57
+ return new we((t) => {
58
+ let n = this.decodeFn(t);
59
+ return n.isOk() ? r(n.value).decode(t) : v(n.error);
60
+ });
61
+ }
62
+ }, Wr = (e, r, t) => `<${e}> decoder failed at index "${r}" with error: ${t}`, G = (e, r) => `${JSON.stringify(e)} is not a valid ${r}`;
63
+ function We(e, r) {
64
+ return new C((t) => {
65
+ if (t instanceof Array) {
66
+ let n = [];
67
+ for (let o = 0; o < t.length; o++) {
68
+ let s = e.decode(t[o]);
69
+ if (s.isOk()) n.push(s.value);
70
+ else return v(Wr(r, o, s.error));
71
+ }
72
+ return k(n);
73
+ } else return v(G(t, "array"));
74
+ });
75
+ }
76
+ function Pr() {
77
+ return new C((e) => typeof e == "boolean" ? k(e) : v(G(e, "boolean")));
78
+ }
79
+ function Nr(e) {
80
+ return new C((r) => e().decode(r));
81
+ }
82
+ var jr = (e, r) => `${JSON.stringify(e)} is not exactly ${JSON.stringify(r)}`;
83
+ function he(e) {
84
+ return new C((r) => r === e ? k(e) : v(jr(r, e)));
85
+ }
86
+ function pe() {
87
+ return new C((e) => typeof e == "number" ? k(e) : v(G(e, "number")));
88
+ }
89
+ var Lr = (e, r, t) => `<${e}> decoder failed at key "${r}" with error: ${t}`;
90
+ function b(e, r) {
91
+ return new C((t) => {
92
+ if (t !== null && typeof t == "object") {
93
+ let n = {};
94
+ for (let o in e) if (Object.prototype.hasOwnProperty.call(e, o)) {
95
+ let s, i = e[o];
96
+ if (i instanceof C ? s = i.decode(t[o]) : s = i.decoder.decode(t[i.fromKey]), s.isOk()) n[o] = s.value;
97
+ else return v(Lr(r, o, s.error));
98
+ }
99
+ return k(n);
100
+ } else return v(G(t, r));
101
+ });
102
+ }
103
+ var Rr = (e, r) => `<${e}> decoder failed because ${JSON.stringify(r)} can't be decoded with any of the provided oneOf decoders`;
104
+ function J(e, r) {
105
+ return new C((t) => {
106
+ for (let n = 0; n < e.length; n++) {
107
+ let o = e[n].decode(t);
108
+ if (o.isOk()) return o;
109
+ }
110
+ return v(Rr(r, t));
111
+ });
112
+ }
113
+ function m(e) {
114
+ return new C((r) => r === void 0 ? k(void 0) : e.decode(r));
115
+ }
116
+ var Ur = (e, r, t) => `<${e}> record decoder failed at key "${r}" with error: ${t}`;
117
+ function Vr(e, r) {
118
+ return new C((t) => {
119
+ if (t !== null && typeof t == "object") {
120
+ let n = {};
121
+ for (let o in t) if (Object.prototype.hasOwnProperty.call(t, o)) {
122
+ let s = e.decode(t[o]);
123
+ if (s.isOk()) n[o] = s.value;
124
+ else return v(Ur(r, o, s.error));
125
+ }
126
+ return k(n);
127
+ } else return v(G(t, r));
128
+ });
129
+ }
130
+ function O() {
131
+ return new C((e) => typeof e == "string" ? k(e) : v(G(e, "string")));
132
+ }
133
+ function R() {
134
+ return new C((e) => k(e));
135
+ }
136
+ function ee(e, r) {
137
+ return new C((t) => {
138
+ if (typeof t != "object" || t === null)
139
+ return v(`<${r}> failed. Expected object literal, got "${typeof t}"`);
140
+ const n = {};
141
+ for (const [o, s] of Object.entries(e)) {
142
+ const i = s.decoder.decode(t[o]);
143
+ if (!i.isOk())
144
+ return v(`<${r}> failed at "${o}" with ${i.error}`);
145
+ if (n[o] = i.value, s.suffixed) {
146
+ for (const [d, c] of Object.entries(t))
147
+ if (d.startsWith(o + ".")) {
148
+ const f = s.decoder.decode(c);
149
+ if (!f.isOk())
150
+ return v(`<${r}> failed at "${d}" with ${f.error}`);
151
+ n[d] = f.value;
152
+ }
153
+ }
154
+ }
155
+ return k(n);
156
+ });
157
+ }
158
+ const be = () => crypto.randomUUID().slice(0, 8), wn = (e) => typeof e != "function" && e.kind === "display", De = (e) => typeof e != "function" && e.kind === "action", _ = (e) => typeof e != "function" && e.kind === "input", er = (e) => typeof e != "function" && e.kind === "layout", Pe = (e) => typeof e == "function", Hr = b({ in: We(O(), "In[]") }, "In"), Ne = b({ when: O() }, "When"), ge = J([Hr, Ne], "In | When"), Br = b({ from: We(O(), "From[]") }, "From"), ye = J([Br, Ne], "Exclude"), ke = J([Pr(), Ne], "Bool | When"), Gr = new C(
159
+ (e) => {
160
+ const r = typeof e;
161
+ return r === "function" ? k(e) : v(`Expected a function, got '${r}'`);
162
+ }
163
+ ), L = (e) => J([e, Gr], ""), je = ee(
164
+ {
165
+ load: { suffixed: !0, decoder: L(m(O())) },
166
+ click: { suffixed: !0, decoder: L(m(O())) },
167
+ change: { suffixed: !0, decoder: L(m(O())) },
168
+ filter: { suffixed: !0, decoder: L(m(O())) }
169
+ },
170
+ "On"
171
+ ), Jr = b(
172
+ {
173
+ key: O(),
174
+ default: m(O()),
175
+ params: R()
176
+ },
177
+ "TranslationConfig"
178
+ ), rr = J(
179
+ [O(), Jr],
180
+ "Localizable"
181
+ ), me = m(O()).map((e) => e || be()), Kr = ee(
182
+ {
183
+ kind: { decoder: he("display") },
184
+ uid: { decoder: me },
185
+ type: { decoder: O() },
186
+ size: { suffixed: !0, decoder: m(pe()) },
187
+ include: { decoder: m(ge) },
188
+ exclude: { decoder: m(ye) },
189
+ props: { decoder: m(R()) }
190
+ },
191
+ "DisplayWidget"
192
+ ), Mr = ee(
193
+ {
194
+ kind: { decoder: he("action") },
195
+ uid: { decoder: me },
196
+ type: { decoder: O() },
197
+ size: { suffixed: !0, decoder: m(pe()) },
198
+ include: { decoder: m(ge) },
199
+ exclude: { decoder: m(ye) },
200
+ label: { suffixed: !0, decoder: L(rr) },
201
+ disabled: { suffixed: !0, decoder: m(ke) },
202
+ on: { decoder: m(je) },
203
+ props: { decoder: m(R()) }
204
+ },
205
+ "ActionWidget"
206
+ ), Xr = new C(
207
+ (e) => {
208
+ const r = typeof e;
209
+ if (r === "function") {
210
+ const t = e, n = t(void 0);
211
+ return t.uid = n.uid || be(), t.type = n.type, t.path = n.path, k(t);
212
+ } else
213
+ return v(`Expected a function, got '${r}'`);
214
+ }
215
+ ), Qr = ee(
216
+ {
217
+ kind: { decoder: he("input") },
218
+ uid: { decoder: me },
219
+ type: { decoder: O() },
220
+ size: { suffixed: !0, decoder: m(pe()) },
221
+ include: { decoder: m(ge) },
222
+ exclude: { decoder: m(ye) },
223
+ disabled: { suffixed: !0, decoder: m(ke) },
224
+ readonly: { suffixed: !0, decoder: m(ke) },
225
+ on: { decoder: m(je) },
226
+ props: { decoder: m(R()) },
227
+ label: {
228
+ suffixed: !0,
229
+ decoder: L(m(rr))
230
+ },
231
+ path: { decoder: O() },
232
+ defaultValue: { decoder: m(R()) },
233
+ validator: {
234
+ suffixed: !0,
235
+ decoder: L(m(R()))
236
+ }
237
+ },
238
+ "InputWidget"
239
+ ).map((e) => {
240
+ const r = { ...e };
241
+ if (e.uid || (r.uid = `${e.path}-${e.type}`), e.type === "repeater") {
242
+ const t = e.props;
243
+ t.template = Le.parse(t.template);
244
+ }
245
+ return r;
246
+ }), xr = Nr(
247
+ () => J(
248
+ [
249
+ Xr,
250
+ Qr,
251
+ Le,
252
+ Kr,
253
+ Mr
254
+ ],
255
+ "FormWidget"
256
+ )
257
+ ), Le = ee(
258
+ {
259
+ kind: { decoder: he("layout") },
260
+ uid: { decoder: me },
261
+ type: { decoder: O() },
262
+ size: { suffixed: !0, decoder: m(pe()) },
263
+ include: { decoder: m(ge) },
264
+ exclude: { decoder: m(ye) },
265
+ props: { decoder: m(R()) },
266
+ on: { decoder: m(je) },
267
+ children: { decoder: We(xr, "FormWidget[]") }
268
+ },
269
+ "LayoutWidget"
270
+ );
271
+ function Dn(e) {
272
+ return {
273
+ ...e,
274
+ form: {
275
+ uid: "",
276
+ type: "flex",
277
+ kind: "layout",
278
+ children: e.form
279
+ }
280
+ };
281
+ }
282
+ const tr = b(
283
+ {
284
+ states: m(Vr(O(), "states")),
285
+ form: Le
286
+ },
287
+ "FormDef"
288
+ ), nr = (e) => ({
289
+ formName: "",
290
+ formDef: tr.parse({
291
+ form: {
292
+ kind: "layout",
293
+ type: "flex",
294
+ children: []
295
+ }
296
+ }),
297
+ flatForm: {},
298
+ currentStates: [],
299
+ calculatedWidgets: {},
300
+ validations: {},
301
+ touchedControls: {},
302
+ injectedValidations: {},
303
+ widgetFlags: {},
304
+ widgetPropOverrides: {},
305
+ data: {},
306
+ formHealth: { status: "ok" },
307
+ touched: !1,
308
+ lang: e
309
+ }), Zr = (e) => {
310
+ throw new Error(`Unhandled case: ${JSON.stringify(e)}`);
311
+ };
312
+ function W(e, ...r) {
313
+ return r.reduce((t, n) => n(t), e);
314
+ }
315
+ function kn(...e) {
316
+ return (r) => e.reduceRight((t, n) => n(t), r);
317
+ }
318
+ function Yr(e, r) {
319
+ return {
320
+ ...e,
321
+ calculatedWidgets: {
322
+ ...e.calculatedWidgets,
323
+ [r.payload.widget.uid]: {
324
+ source: r.payload.widget,
325
+ current: {},
326
+ previous: {}
327
+ }
328
+ }
329
+ };
330
+ }
331
+ const Re = 32;
332
+ let a, p, A = (e) => (a = 0, p = e, A.newline = !1, e = $(), p[a] ? U() : e || ""), U = (e = "Unexpected token", r = a, t = p.slice(0, r).split(`
333
+ `), n = t.pop(), o = p.slice(Math.max(0, r - 40), r), s = "̭", i = (p[r] || " ") + s, d = p.slice(r + 1, r + 20)) => {
334
+ throw SyntaxError(`${e} at ${t.length + 1}:${n.length + 1}
335
+ ${p[r - 41] !== `
336
+ `, "" + o}${i}${d}`);
337
+ }, or = (e, r = a) => (Array.isArray(e) && (e.loc = r), e), K = (e, r = a, t) => {
338
+ for (; t = e(p.charCodeAt(a)); ) a += t;
339
+ return p.slice(r, a);
340
+ }, E = (e = 1) => p[a += e], Fe = (e) => a = e, $ = (e = 0, r) => {
341
+ let t, n, o, s, i;
342
+ for (r && A.asi && (A.newline = !1); (t = A.space()) && (i = A.newline, 1) && t !== r && (o = ((s = T[t]) && s(n, e)) ?? (n && i && A.asi?.(n, e, $)) ?? (!n && K(A.id))); ) n = o;
343
+ return r && (t == r ? a++ : U("Unclosed " + String.fromCharCode(r - (r > 42 ? 2 : 1)))), n;
344
+ }, Y = A.space = (e, r = a) => {
345
+ for (; (e = p.charCodeAt(a)) <= Re; )
346
+ A.asi && e === 10 && (A.newline = !0), a++;
347
+ return e;
348
+ }, qr = (e = a) => {
349
+ for (; p.charCodeAt(e) <= Re; ) e++;
350
+ return p.charCodeAt(e);
351
+ };
352
+ A.id = (e) => e >= 48 && e <= 57 || e >= 65 && e <= 90 || e >= 97 && e <= 122 || e == 36 || e == 95 || e >= 192 && e != 215 && e != 247;
353
+ let zr = (e, r = e.length) => p.substr(a, r) === e && !A.id(p.charCodeAt(a + r)), T = [], Qe = {}, F = (e, r = Re, t, n = e.charCodeAt(0), o = e.length, s = T[n], i = e.toUpperCase() !== e, d, c) => (r = Qe[e] = !s && Qe[e] || r, T[n] = (f, y, h, S = a) => (d = h, (h ? e == h : (o < 2 || e.charCodeAt(1) === p.charCodeAt(a + 1) && (o < 3 || p.substr(a, o) == e)) && (!i || !A.id(p.charCodeAt(a + o))) && (d = h = e)) && y < r && (a += o, (c = t(f)) ? or(c, S) : (a = S, d = 0, !i && !s && U()), c) || s?.(f, y, d))), g = (e, r, t = !1) => F(e, r, (n) => n && /* @__PURE__ */ ((o) => o && [e, n, o])($(r - (t ? 0.5 : 0)))), N = (e, r, t) => F(e, r, (n) => !n && (n = $(r - 0.5)) && [e, n]), re = (e, r) => F(e, 200, (t) => !t && [, r]), sr = (e, r, t) => F(
354
+ e,
355
+ r,
356
+ (n, o) => (o = $(r - (t ? 0.5 : 0)), n?.[0] !== e && (n = [e, n || null]), o?.[0] === e ? n.push(...o.slice(1)) : n.push(o || null), n)
357
+ ), Ue = (e, r) => F(e[0], r, (t) => !t && [e, $(0, e.charCodeAt(1)) || null]), ir = (e, r) => F(e[0], r, (t) => t && [e, t, $(0, e.charCodeAt(1)) || null]);
358
+ const Te = {}, l = (e, r, t = Te[e]) => Te[e] = (...n) => r(...n) || t?.(...n), u = (e) => Array.isArray(e) ? e[0] == null ? /* @__PURE__ */ ((r) => () => r)(e[1]) : (
359
+ // == catches both undefined and null
360
+ Te[e[0]]?.(...e.slice(1)) ?? U(`Unknown operator: ${e[0]}`, e?.loc)
361
+ ) : e === void 0 ? () => {
362
+ } : (r) => r?.[e], ue = 46, q = 48, de = 57, br = 69, et = 101, rt = 43, tt = 45, se = 95, nt = 110, ot = 97, st = 102, it = 65, ut = 70, ur = (e) => e.indexOf("_") < 0 ? e : e.replaceAll("_", ""), Ve = (e) => {
363
+ let r = ur(K(
364
+ (t) => (
365
+ // . is decimal only if NOT followed by another . (range operator)
366
+ t === ue && p.charCodeAt(a + 1) !== ue || t >= q && t <= de || t === se || ((t === br || t === et) && ((t = p.charCodeAt(a + 1)) >= q && t <= de || t === rt || t === tt) ? 2 : 0)
367
+ )
368
+ ));
369
+ return p.charCodeAt(a) === nt ? (E(), [, BigInt(r)]) : (e = +r) != e ? U() : [, e];
370
+ }, dt = {
371
+ 2: (e) => e === 48 || e === 49 || e === se,
372
+ 8: (e) => e >= 48 && e <= 55 || e === se,
373
+ 16: (e) => e >= q && e <= de || e >= ot && e <= st || e >= it && e <= ut || e === se
374
+ };
375
+ A.number = null;
376
+ T[ue] = (e) => !e && p.charCodeAt(a + 1) !== ue && Ve();
377
+ for (let e = q; e <= de; e++) T[e] = (r) => r ? void 0 : Ve();
378
+ T[q] = (e) => {
379
+ if (e) return;
380
+ const r = A.number;
381
+ if (r) {
382
+ for (const [t, n] of Object.entries(r))
383
+ if (t[0] === "0" && p[a + 1]?.toLowerCase() === t[1])
384
+ return E(2), [, parseInt(ur(K(dt[n])), n)];
385
+ }
386
+ return Ve();
387
+ };
388
+ const ct = 92, xe = 34, Ze = 39, lt = { n: `
389
+ `, r: "\r", t: " ", b: "\b", f: "\f", v: "\v" }, dr = (e) => (r, t, n = "") => {
390
+ if (!(r || !A.string?.[String.fromCharCode(e)]))
391
+ return E(), K((o) => o - e && (o === ct ? (n += lt[p[a + 1]] || p[a + 1], 2) : (n += p[a], 1))), p[a] === String.fromCharCode(e) ? E() : U("Bad string"), [, n];
392
+ };
393
+ T[xe] = dr(xe);
394
+ T[Ze] = dr(Ze);
395
+ A.string = { '"': !0 };
396
+ const ft = 20;
397
+ "= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map((e) => g(e, ft, !0));
398
+ const cr = (e, r, t, n) => typeof e == "string" ? (o) => r(o, e, o) : e[0] === "." ? (t = u(e[1]), n = e[2], (o) => r(t(o), n, o)) : e[0] === "[]" && e.length === 3 ? (t = u(e[1]), n = u(e[2]), (o) => r(t(o), n(o), o)) : e[0] === "()" && e.length === 2 ? cr(e[1], r) : (() => {
399
+ throw Error("Invalid assignment target");
400
+ })(), Ye = {
401
+ "=": (e, r, t) => e[r] = t,
402
+ "+=": (e, r, t) => e[r] += t,
403
+ "-=": (e, r, t) => e[r] -= t,
404
+ "*=": (e, r, t) => e[r] *= t,
405
+ "/=": (e, r, t) => e[r] /= t,
406
+ "%=": (e, r, t) => e[r] %= t,
407
+ "|=": (e, r, t) => e[r] |= t,
408
+ "&=": (e, r, t) => e[r] &= t,
409
+ "^=": (e, r, t) => e[r] ^= t,
410
+ ">>=": (e, r, t) => e[r] >>= t,
411
+ "<<=": (e, r, t) => e[r] <<= t
412
+ };
413
+ for (const e in Ye) l(e, (r, t) => (t = u(t), cr(r, (n, o, s) => Ye[e](n, o, t(s)))));
414
+ const at = 30, ht = 40, lr = 140;
415
+ g("!", lr);
416
+ N("!", lr);
417
+ g("||", at);
418
+ g("&&", ht);
419
+ l("!", (e) => (e = u(e), (r) => !e(r)));
420
+ l("||", (e, r) => (e = u(e), r = u(r), (t) => e(t) || r(t)));
421
+ l("&&", (e, r) => (e = u(e), r = u(r), (t) => e(t) && r(t)));
422
+ const pt = 50, gt = 60, yt = 70, fr = 100, mt = 140;
423
+ g("|", pt);
424
+ g("&", yt);
425
+ g("^", gt);
426
+ g(">>", fr);
427
+ g("<<", fr);
428
+ N("~", mt);
429
+ l("~", (e) => (e = u(e), (r) => ~e(r)));
430
+ l("|", (e, r) => (e = u(e), r = u(r), (t) => e(t) | r(t)));
431
+ l("&", (e, r) => (e = u(e), r = u(r), (t) => e(t) & r(t)));
432
+ l("^", (e, r) => (e = u(e), r = u(r), (t) => e(t) ^ r(t)));
433
+ l(">>", (e, r) => (e = u(e), r = u(r), (t) => e(t) >> r(t)));
434
+ l("<<", (e, r) => (e = u(e), r = u(r), (t) => e(t) << r(t)));
435
+ const Ae = 90;
436
+ g("<", Ae);
437
+ g(">", Ae);
438
+ g("<=", Ae);
439
+ g(">=", Ae);
440
+ l(">", (e, r) => (e = u(e), r = u(r), (t) => e(t) > r(t)));
441
+ l("<", (e, r) => (e = u(e), r = u(r), (t) => e(t) < r(t)));
442
+ l(">=", (e, r) => (e = u(e), r = u(r), (t) => e(t) >= r(t)));
443
+ l("<=", (e, r) => (e = u(e), r = u(r), (t) => e(t) <= r(t)));
444
+ const ar = 80;
445
+ g("==", ar);
446
+ g("!=", ar);
447
+ l("==", (e, r) => (e = u(e), r = u(r), (t) => e(t) == r(t)));
448
+ l("!=", (e, r) => (e = u(e), r = u(r), (t) => e(t) != r(t)));
449
+ const hr = 110, He = 120, pr = 140;
450
+ g("+", hr);
451
+ g("-", hr);
452
+ g("*", He);
453
+ g("/", He);
454
+ g("%", He);
455
+ N("+", pr);
456
+ N("-", pr);
457
+ l("+", (e, r) => r !== void 0 ? (e = u(e), r = u(r), (t) => e(t) + r(t)) : (e = u(e), (t) => +e(t)));
458
+ l("-", (e, r) => r !== void 0 ? (e = u(e), r = u(r), (t) => e(t) - r(t)) : (e = u(e), (t) => -e(t)));
459
+ l("*", (e, r) => (e = u(e), r = u(r), (t) => e(t) * r(t)));
460
+ l("/", (e, r) => (e = u(e), r = u(r), (t) => e(t) / r(t)));
461
+ l("%", (e, r) => (e = u(e), r = u(r), (t) => e(t) % r(t)));
462
+ const ce = 150;
463
+ F("++", ce, (e) => e ? ["++", e, null] : ["++", $(ce - 1)]);
464
+ F("--", ce, (e) => e ? ["--", e, null] : ["--", $(ce - 1)]);
465
+ const Be = (e, r, t, n) => typeof e == "string" ? (o) => r(o, e) : e[0] === "." ? (t = u(e[1]), n = e[2], (o) => r(t(o), n)) : e[0] === "[]" && e.length === 3 ? (t = u(e[1]), n = u(e[2]), (o) => r(t(o), n(o))) : e[0] === "()" && e.length === 2 ? Be(e[1], r) : (
466
+ // unwrap parens: (x)++
467
+ (() => {
468
+ throw Error("Invalid increment target");
469
+ })()
470
+ );
471
+ l("++", (e, r) => Be(e, r === null ? (t, n) => t[n]++ : (t, n) => ++t[n]));
472
+ l("--", (e, r) => Be(e, r === null ? (t, n) => t[n]-- : (t, n) => --t[n]));
473
+ const At = 5, St = 10;
474
+ sr(",", St);
475
+ sr(";", At, !0);
476
+ const gr = (...e) => (e = e.map(u), (r) => {
477
+ let t;
478
+ for (const n of e) t = n(r);
479
+ return t;
480
+ });
481
+ l(",", gr);
482
+ l(";", gr);
483
+ const $t = 170;
484
+ Ue("()", $t);
485
+ const P = (e) => e?.[0] === "_" && e[1] === "_" || e === "constructor" || e === "prototype", Ge = 170;
486
+ ir("[]", Ge);
487
+ g(".", Ge);
488
+ ir("()", Ge);
489
+ const le = (e) => {
490
+ throw Error(e);
491
+ };
492
+ l("[]", (e, r) => r === void 0 ? (e = e ? e[0] === "," ? e.slice(1) : [e] : [], e = e.map((t) => t == null ? (() => {
493
+ }) : t[0] === "..." ? (t = u(t[1]), (n) => t(n)) : (t = u(t), (n) => [t(n)])), (t) => e.flatMap((n) => n(t))) : (r == null && le("Missing index"), e = u(e), r = u(r), (t) => {
494
+ const n = r(t);
495
+ return P(n) ? void 0 : e(t)[n];
496
+ }));
497
+ l(".", (e, r) => (e = u(e), r = r[0] ? r : r[1], P(r) ? () => {
498
+ } : (t) => e(t)[r]));
499
+ l("()", (e, r) => {
500
+ if (r === void 0) return e == null ? le("Empty ()") : u(e);
501
+ const t = (o) => o?.[0] === "," && o.slice(1).some((s) => s == null || t(s));
502
+ t(r) && le("Empty argument");
503
+ const n = r ? r[0] === "," ? (r = r.slice(1).map(u), (o) => r.map((s) => s(o))) : (r = u(r), (o) => [r(o)]) : () => [];
504
+ return Je(e, (o, s, i) => o[s](...n(i)));
505
+ });
506
+ const V = (e) => typeof e == "string" || Array.isArray(e) && (e[0] === "." || e[0] === "?." || e[0] === "[]" && e.length === 3 || e[0] === "?.[]" || e[0] === "()" && e.length === 2 && V(e[1]) || e[0] === "{}"), Je = (e, r, t, n) => e == null ? le("Empty ()") : e[0] === "()" && e.length == 2 ? Je(e[1], r) : typeof e == "string" ? (o) => r(o, e, o) : e[0] === "." ? (t = u(e[1]), n = e[2], (o) => r(t(o), n, o)) : e[0] === "?." ? (t = u(e[1]), n = e[2], (o) => {
507
+ const s = t(o);
508
+ return s == null ? void 0 : r(s, n, o);
509
+ }) : e[0] === "[]" && e.length === 3 ? (t = u(e[1]), n = u(e[2]), (o) => r(t(o), n(o), o)) : e[0] === "?.[]" ? (t = u(e[1]), n = u(e[2]), (o) => {
510
+ const s = t(o);
511
+ return s == null ? void 0 : r(s, n(o), o);
512
+ }) : (e = u(e), (o) => r([e(o)], 0, o)), M = Je, vt = 32, Et = A.space;
513
+ A.comment ??= { "//": `
514
+ `, "/*": "*/" };
515
+ let $e;
516
+ A.space = () => {
517
+ $e || ($e = Object.entries(A.comment).map(([o, s]) => [o, s, o.charCodeAt(0)]));
518
+ for (var e; e = Et(); ) {
519
+ for (var r = 0, t; t = $e[r++]; )
520
+ if (e === t[2] && p.substr(a, t[0].length) === t[0]) {
521
+ var n = a + t[0].length;
522
+ if (t[1] === `
523
+ `) for (; p.charCodeAt(n) >= vt; ) n++;
524
+ else {
525
+ for (; p[n] && p.substr(n, t[1].length) !== t[1]; ) n++;
526
+ p[n] && (n += t[1].length);
527
+ }
528
+ Fe(n), e = 0;
529
+ break;
530
+ }
531
+ if (e) return e;
532
+ }
533
+ return e;
534
+ };
535
+ const yr = 80;
536
+ g("===", yr);
537
+ g("!==", yr);
538
+ l("===", (e, r) => (e = u(e), r = u(r), (t) => e(t) === r(t)));
539
+ l("!==", (e, r) => (e = u(e), r = u(r), (t) => e(t) !== r(t)));
540
+ const Ot = 30;
541
+ g("??", Ot);
542
+ l("??", (e, r) => (e = u(e), r = u(r), (t) => e(t) ?? r(t)));
543
+ const It = 130, Ct = 20;
544
+ g("**", It, !0);
545
+ g("**=", Ct, !0);
546
+ l("**", (e, r) => (e = u(e), r = u(r), (t) => e(t) ** r(t)));
547
+ const wt = (e) => {
548
+ throw Error(e);
549
+ };
550
+ l("**=", (e, r) => (V(e) || wt("Invalid assignment target"), r = u(r), M(e, (t, n, o) => t[n] **= r(o))));
551
+ const mr = 90;
552
+ g("in", mr);
553
+ g("of", mr);
554
+ l("in", (e, r) => (e = u(e), r = u(r), (t) => e(t) in r(t)));
555
+ const Dt = 20, kt = 100, Ft = (e) => {
556
+ throw Error(e);
557
+ };
558
+ g(">>>", kt);
559
+ g(">>>=", Dt, !0);
560
+ l(">>>", (e, r) => (e = u(e), r = u(r), (t) => e(t) >>> r(t)));
561
+ l(">>>=", (e, r) => (V(e) || Ft("Invalid assignment target"), r = u(r), M(e, (t, n, o) => t[n] >>>= r(o))));
562
+ const Tt = (e) => e[0]?.[0] === "," ? e[0].slice(1) : e, _e = (e, r, t) => {
563
+ if (typeof e == "string") {
564
+ t[e] = r;
565
+ return;
566
+ }
567
+ const [n, ...o] = e, s = Tt(o);
568
+ if (n === "{}") {
569
+ const i = [];
570
+ for (const d of s) {
571
+ if (Array.isArray(d) && d[0] === "...") {
572
+ const S = {};
573
+ for (const j in r) i.includes(j) || (S[j] = r[j]);
574
+ t[d[1]] = S;
575
+ break;
576
+ }
577
+ let c, f, y;
578
+ typeof d == "string" ? c = f = d : d[0] === "=" ? (typeof d[1] == "string" ? c = f = d[1] : [, c, f] = d[1], y = d[2]) : [, c, f] = d, i.push(c);
579
+ let h = r[c];
580
+ h === void 0 && y && (h = u(y)(t)), _e(f, h, t);
581
+ }
582
+ } else if (n === "[]") {
583
+ let i = 0;
584
+ for (const d of s) {
585
+ if (d === null) {
586
+ i++;
587
+ continue;
588
+ }
589
+ if (Array.isArray(d) && d[0] === "...") {
590
+ t[d[1]] = r.slice(i);
591
+ break;
592
+ }
593
+ let c = d, f;
594
+ Array.isArray(d) && d[0] === "=" && ([, c, f] = d);
595
+ let y = r[i++];
596
+ y === void 0 && f && (y = u(f)(t)), _e(c, y, t);
597
+ }
598
+ }
599
+ }, Ke = 20, Se = (e) => {
600
+ throw Error(e);
601
+ };
602
+ g("||=", Ke, !0);
603
+ g("&&=", Ke, !0);
604
+ g("??=", Ke, !0);
605
+ l("=", (e, r) => {
606
+ if (Array.isArray(e) && (e[0] === "let" || e[0] === "const" || e[0] === "var")) {
607
+ const t = e[1];
608
+ return r = u(r), typeof t == "string" ? (n) => {
609
+ n[t] = r(n);
610
+ } : (n) => _e(t, r(n), n);
611
+ }
612
+ return V(e) || Se("Invalid assignment target"), r = u(r), M(e, (t, n, o) => t[n] = r(o));
613
+ });
614
+ l("||=", (e, r) => (V(e) || Se("Invalid assignment target"), r = u(r), M(e, (t, n, o) => t[n] ||= r(o))));
615
+ l("&&=", (e, r) => (V(e) || Se("Invalid assignment target"), r = u(r), M(e, (t, n, o) => t[n] &&= r(o))));
616
+ l("??=", (e, r) => (V(e) || Se("Invalid assignment target"), r = u(r), M(e, (t, n, o) => t[n] ??= r(o))));
617
+ const Ar = (e, r, t, n = e.charCodeAt(0), o = e.length, s = T[n], i) => T[n] = (d, c, f, y = a) => !d && (f ? e == f : (o < 2 || p.substr(a, o) == e) && (f = e)) && c < r && !A.id(p.charCodeAt(a + o)) && qr(a + o) !== 58 && // allow {keyword:value}
618
+ (Fe(a + o), (i = t()) ? or(i, y) : Fe(y), i) || s?.(d, c, f);
619
+ re("true", !0);
620
+ re("false", !1);
621
+ re("null", null);
622
+ Ar("undefined", 200, () => []);
623
+ re("NaN", NaN);
624
+ re("Infinity", 1 / 0);
625
+ const ve = 20;
626
+ F("?", ve, (e, r, t) => e && (r = $(ve - 1)) && K((n) => n === 58) && (t = $(ve - 1), ["?", e, r, t]));
627
+ l("?", (e, r, t) => (e = u(e), r = u(r), t = u(t), (n) => e(n) ? r(n) : t(n)));
628
+ const _t = [], Wt = 20;
629
+ g("=>", Wt, !0);
630
+ l("=>", (e, r) => {
631
+ e = e?.[0] === "()" ? e[1] : e;
632
+ const t = e ? e[0] === "," ? e.slice(1) : [e] : [];
633
+ let n = -1, o = null;
634
+ const s = t[t.length - 1];
635
+ Array.isArray(s) && s[0] === "..." && (n = t.length - 1, o = s[1], t.length--);
636
+ const i = r?.[0] === "{}";
637
+ return r = u(i ? ["{", r[1]] : r), (d) => (...c) => {
638
+ const f = {};
639
+ t.forEach((h, S) => f[h] = c[S]), o && (f[o] = c.slice(n));
640
+ const y = new Proxy(f, {
641
+ get: (h, S) => S in h ? h[S] : d?.[S],
642
+ set: (h, S, j) => ((S in h ? h : d)[S] = j, !0),
643
+ has: (h, S) => S in h || (d ? S in d : !1)
644
+ });
645
+ try {
646
+ const h = r(y);
647
+ return i ? void 0 : h;
648
+ } catch (h) {
649
+ if (h === _t) return h[0];
650
+ throw h;
651
+ }
652
+ };
653
+ });
654
+ const Pt = 140;
655
+ N("...", Pt);
656
+ l("...", (e) => (e = u(e), (r) => Object.entries(e(r))));
657
+ const qe = 170;
658
+ F("?.", qe, (e, r) => {
659
+ if (!e) return;
660
+ const t = Y();
661
+ return t === 40 ? (E(), ["?.()", e, $(0, 41) || null]) : t === 91 ? (E(), ["?.[]", e, $(0, 93)]) : (r = $(qe), r ? ["?.", e, r] : void 0);
662
+ });
663
+ l("?.", (e, r) => (e = u(e), P(r) ? () => {
664
+ } : (t) => e(t)?.[r]));
665
+ l("?.[]", (e, r) => (e = u(e), r = u(r), (t) => {
666
+ const n = r(t);
667
+ return P(n) ? void 0 : e(t)?.[n];
668
+ }));
669
+ l("?.()", (e, r) => {
670
+ const t = r ? r[0] === "," ? (r = r.slice(1).map(u), (o) => r.map((s) => s(o))) : (r = u(r), (o) => [r(o)]) : () => [];
671
+ if (e[0] === "?.") {
672
+ const o = u(e[1]), s = e[2];
673
+ return P(s) ? () => {
674
+ } : (i) => o(i)?.[s]?.(...t(i));
675
+ }
676
+ if (e[0] === "?.[]") {
677
+ const o = u(e[1]), s = u(e[2]);
678
+ return (i) => {
679
+ const d = o(i), c = s(i);
680
+ return P(c) ? void 0 : d?.[c]?.(...t(i));
681
+ };
682
+ }
683
+ if (e[0] === ".") {
684
+ const o = u(e[1]), s = e[2];
685
+ return P(s) ? () => {
686
+ } : (i) => o(i)?.[s]?.(...t(i));
687
+ }
688
+ if (e[0] === "[]" && e.length === 3) {
689
+ const o = u(e[1]), s = u(e[2]);
690
+ return (i) => {
691
+ const d = o(i), c = s(i);
692
+ return P(c) ? void 0 : d?.[c]?.(...t(i));
693
+ };
694
+ }
695
+ const n = u(e);
696
+ return (o) => n(o)?.(...t(o));
697
+ });
698
+ const z = 140;
699
+ N("typeof", z);
700
+ N("void", z);
701
+ N("delete", z);
702
+ Ar(
703
+ "new",
704
+ z,
705
+ () => zr(".target") ? (E(7), ["new.target"]) : ["new", $(z)]
706
+ );
707
+ l("typeof", (e) => (e = u(e), (r) => typeof e(r)));
708
+ l("void", (e) => (e = u(e), (r) => (e(r), void 0)));
709
+ l("delete", (e) => {
710
+ if (e[0] === ".") {
711
+ const r = u(e[1]), t = e[2];
712
+ return (n) => delete r(n)[t];
713
+ }
714
+ if (e[0] === "[]") {
715
+ const r = u(e[1]), t = u(e[2]);
716
+ return (n) => delete r(n)[t(n)];
717
+ }
718
+ return () => !0;
719
+ });
720
+ l("new", (e) => {
721
+ const r = u(e?.[0] === "()" ? e[1] : e), t = e?.[0] === "()" ? e[2] : null, n = t ? t[0] === "," ? /* @__PURE__ */ ((o) => (s) => o.map((i) => i(s)))(t.slice(1).map(u)) : /* @__PURE__ */ ((o) => (s) => [o(s)])(u(t)) : () => [];
722
+ return (o) => new (r(o))(...n(o));
723
+ });
724
+ const Me = Symbol("accessor"), Xe = 20, Nt = 40, Sr = 41, $r = 123, vr = 125, Er = (e) => (r) => {
725
+ if (r) return;
726
+ Y();
727
+ const t = K(A.id);
728
+ if (!t || (Y(), p.charCodeAt(a) !== Nt)) return !1;
729
+ E();
730
+ const n = $(0, Sr);
731
+ return Y(), p.charCodeAt(a) !== $r ? !1 : (E(), [e, t, n, $(0, vr)]);
732
+ };
733
+ F("get", Xe - 1, Er("get"));
734
+ F("set", Xe - 1, Er("set"));
735
+ F("(", Xe - 1, (e) => {
736
+ if (!e || typeof e != "string") return;
737
+ const r = $(0, Sr) || null;
738
+ if (Y(), p.charCodeAt(a) === $r)
739
+ return E(), [":", e, ["=>", ["()", r], $(0, vr) || null]];
740
+ });
741
+ l("get", (e, r) => (r = r ? u(r) : () => {
742
+ }, (t) => [[Me, e, {
743
+ get: function() {
744
+ const n = Object.create(t || {});
745
+ return n.this = this, r(n);
746
+ }
747
+ }]]));
748
+ l("set", (e, r, t) => (t = t ? u(t) : () => {
749
+ }, (n) => [[Me, e, {
750
+ set: function(o) {
751
+ const s = Object.create(n || {});
752
+ s.this = this, s[r] = o, t(s);
753
+ }
754
+ }]]));
755
+ const jt = 20, Or = 200, Lt = (e) => e == null || typeof e == "string" || [":", ",", "...", "get", "set"].includes(e[0]);
756
+ Ue("[]", Or);
757
+ Ue("{}", Or);
758
+ g(":", jt - 1, !0);
759
+ l("{}", (e, r) => {
760
+ if (r !== void 0) return;
761
+ if (!Lt(e)) return u(["{", e]);
762
+ e = e ? e[0] !== "," ? [e] : e.slice(1) : [];
763
+ const t = e.map((n) => u(typeof n == "string" ? [":", n, n] : n));
764
+ return (n) => {
765
+ const o = {}, s = {};
766
+ for (const i of t.flatMap((d) => d(n)))
767
+ if (i[0] === Me) {
768
+ const [, d, c] = i;
769
+ s[d] = { ...s[d], ...c, configurable: !0, enumerable: !0 };
770
+ } else o[i[0]] = i[1];
771
+ for (const i in s) Object.defineProperty(o, i, s[i]);
772
+ return o;
773
+ };
774
+ });
775
+ l("{", (e) => (e = e ? u(e) : () => {
776
+ }, (r) => e(Object.create(r))));
777
+ l(":", (e, r) => (r = u(r), Array.isArray(e) ? (e = u(e), (t) => [[e(t), r(t)]]) : (t) => [[e, r(t)]]));
778
+ const Rt = 170, fe = 96, Ut = 36, Vt = 123, Ht = 92, Bt = { n: `
779
+ `, r: "\r", t: " ", b: "\b", f: "\f", v: "\v" }, ze = () => {
780
+ const e = [];
781
+ for (let r = "", t; (t = p.charCodeAt(a)) !== fe; )
782
+ t ? t === Ht ? (E(), r += Bt[p[a]] || p[a], E()) : t === Ut && p.charCodeAt(a + 1) === Vt ? (r && e.push([, r]), r = "", E(2), e.push($(0, 125))) : (r += p[a], E(), t = p.charCodeAt(a), t === fe && r && e.push([, r])) : U("Unterminated template");
783
+ return E(), e;
784
+ }, Gt = T[fe];
785
+ T[fe] = (e, r) => e && r < Rt ? A.asi && A.newline ? void 0 : (E(), ["``", e, ...ze()]) : (
786
+ // tagged
787
+ e ? (
788
+ // plain
789
+ Gt?.(e, r)
790
+ ) : (E(), ((t) => t.length < 2 && t[0]?.[0] === void 0 ? t[0] || [, ""] : ["`", ...t])(ze()))
791
+ );
792
+ l("`", (...e) => (e = e.map(u), (r) => e.map((t) => t(r)).join("")));
793
+ l("``", (e, ...r) => {
794
+ e = u(e);
795
+ const t = [], n = [];
796
+ for (const s of r)
797
+ Array.isArray(s) && s[0] === void 0 ? t.push(s[1]) : n.push(u(s));
798
+ const o = Object.assign([...t], { raw: t });
799
+ return (s) => e(s)(o, ...n.map((i) => i(s)));
800
+ });
801
+ A.string["'"] = !0;
802
+ A.number = { "0x": 16, "0b": 2, "0o": 8 };
803
+ const X = (e) => {
804
+ let r = e.formDef.states;
805
+ if (!r || Object.keys(r).length === 0 || e.formHealth.status === "errored")
806
+ return e;
807
+ r = Jt(r);
808
+ let t = [], n = { status: "ok" };
809
+ try {
810
+ t = Object.keys(r).map((o) => {
811
+ const s = r[o], i = A(s);
812
+ return u(i)({
813
+ $form: e.data,
814
+ $log: (f, y) => (y ? console.log(y, f) : console.log(f), f)
815
+ }) === !0 ? o : void 0;
816
+ }).filter((o) => o !== void 0);
817
+ } catch (o) {
818
+ n = {
819
+ status: "errored",
820
+ message: o.message
821
+ };
822
+ }
823
+ return { ...e, currentStates: t, formHealth: n };
824
+ };
825
+ function Jt(e) {
826
+ const r = {};
827
+ function t(n) {
828
+ const o = n.split(":"), s = [];
829
+ for (let i = 0; i < o.length; i++)
830
+ s.push(o.slice(0, i + 1).join(":"));
831
+ return s;
832
+ }
833
+ for (const [n, o] of Object.entries(e)) {
834
+ const s = t(n), i = [];
835
+ for (const d of s)
836
+ e[d] && i.push(`(${e[d]})`);
837
+ r[n] = i.join(" && ");
838
+ }
839
+ return r;
840
+ }
841
+ const te = (e, r) => (t) => e(t) ? r(t) : t, Kt = (e) => (r) => {
842
+ const t = r.touchedControls[e];
843
+ return r.touched && t;
844
+ }, x = (e) => e !== void 0 && typeof e == "object" && e !== null && "when" in e, Q = (e) => ({
845
+ ...e,
846
+ widgetFlags: Mt(e)
847
+ });
848
+ function Mt(e) {
849
+ return Object.values(e.flatForm).map((r) => {
850
+ if (Pe(r)) {
851
+ const t = r({
852
+ $form: e.data,
853
+ errors: void 0,
854
+ touched: void 0,
855
+ translate: void 0
856
+ });
857
+ return t.uid = r.uid, t;
858
+ }
859
+ return r;
860
+ }).filter((r) => !!(r.include && ("in" in r.include || r.include) || r.exclude && ("from" in r.exclude || "when" in r.exclude) || _(r) || De(r) && x(r.disabled) || _(r) && x(r.readonly))).reduce(
861
+ (r, t) => (r[t.uid] = r[t.uid] || {}, t.include && "in" in t.include ? r[t.uid].hidden = !t.include.in.some(
862
+ (n) => e.currentStates.includes(n)
863
+ ) : t.include && "when" in t.include && (r[t.uid].hidden = !ne(t.include.when, e.data)), t.exclude && "from" in t.exclude ? r[t.uid].hidden = t.exclude.from.some(
864
+ (n) => e.currentStates.includes(n)
865
+ ) : t.exclude && "when" in t.exclude && (r[t.uid].hidden = ne(t.exclude.when, e.data)), (_(t) || De(t)) && x(t.disabled) && (r[t.uid].disabled = ne(
866
+ t.disabled.when,
867
+ e.data
868
+ )), _(t) && x(t.readonly) && (r[t.uid].readonly = ne(
869
+ t.readonly.when,
870
+ e.data
871
+ )), r),
872
+ {}
873
+ );
874
+ }
875
+ function ne(e, r) {
876
+ const t = A(e);
877
+ return u(t)({
878
+ $form: r,
879
+ $log: (s, i) => (i ? console.log(i, s) : console.log(s), s)
880
+ }) === !0;
881
+ }
882
+ const Xt = (e) => !(typeof e != "object" || e === null || typeof e.key != "string");
883
+ function Fn(e) {
884
+ const r = new Intl.Locale(e).maximize().script;
885
+ return ["Arab", "Hebr", "Thaa", "Syrc", "Tfng", "Adlm", "Rohg"].includes(r || "") ? "rtl" : "ltr";
886
+ }
887
+ const Qt = (e = navigator.language || "en-US") => ({
888
+ /**
889
+ * Returns a generic fallback language code.
890
+ */
891
+ get lang() {
892
+ return e;
893
+ },
894
+ /**
895
+ * Returns the provided translation key without modification.
896
+ *
897
+ * @param key - Translation key
898
+ * @returns The key itself
899
+ */
900
+ translate(r) {
901
+ return r;
902
+ },
903
+ /**
904
+ * No-op teardown function since state never changes.
905
+ */
906
+ subscribe() {
907
+ return () => {
908
+ };
909
+ }
910
+ }), xt = (e) => typeof e == "string" && !e.includes(" ") && (e.startsWith("$form.") || e.startsWith("$error.") || e.startsWith("$meta.")), B = (e, r) => {
911
+ if (e === void 0)
912
+ throw new Error("obj is undefined");
913
+ return r.split(".").reduce((t, n) => t === void 0 || n === "" ? t : Array.isArray(t) ? t[parseInt(n, 10)] : t[n], e);
914
+ }, ie = (e, r, t) => {
915
+ if (e === null)
916
+ throw new Error("object is null");
917
+ if (e === void 0)
918
+ throw new Error("object is undefined");
919
+ if (r === "")
920
+ throw new Error("path cannot be empty");
921
+ const n = r.split(".");
922
+ let o = e;
923
+ for (let i = 0; i < n.length - 1; i++) {
924
+ const d = n[i], c = n[i + 1];
925
+ (o[d] == null || typeof o[d] != "object") && (o[d] = Zt(c) ? [] : {}), o = o[d];
926
+ }
927
+ const s = n[n.length - 1];
928
+ return o[s] = t, e;
929
+ };
930
+ function Zt(e) {
931
+ const r = Number(e);
932
+ return Number.isInteger(r) && r >= 0 && r.toString() === e;
933
+ }
934
+ const oe = (e, r) => (delete e[r], e);
935
+ function Tn(e) {
936
+ return JSON.parse(JSON.stringify(e));
937
+ }
938
+ const H = (e) => (r) => ({ ...r, calculatedWidgets: qt(r, e) }), Yt = (e, r) => ({
939
+ source: e,
940
+ previous: r,
941
+ current: {},
942
+ changed: !1
943
+ });
944
+ function Ee(e) {
945
+ return Array.from(new Set(e.map((r) => r.split(".")[0])));
946
+ }
947
+ function qt(e, r) {
948
+ return Object.keys(e.calculatedWidgets).reduce(
949
+ (t, n) => {
950
+ if (e.widgetFlags[n] !== void 0 && e.widgetFlags[n].hidden)
951
+ return t;
952
+ const o = e.calculatedWidgets[n], s = o.source;
953
+ if (Pe(s))
954
+ return o.previous = o.current, o.current = s({
955
+ $form: e.data,
956
+ errors: s.path ? e.validations[s.path] : void 0,
957
+ touched: s.path ? e.touchedControls[s.path] : void 0,
958
+ translate: r.translate
959
+ }), o.current.uid = n, t[n] = { ...o }, t;
960
+ const i = Yt(
961
+ s,
962
+ // previous is the new current
963
+ o.current
964
+ );
965
+ Ee(Object.keys(s)).filter((c) => c !== "props" && c !== "on").forEach((c) => {
966
+ Oe({
967
+ currentStates: e.currentStates,
968
+ widgetPropOverrides: e.widgetPropOverrides,
969
+ derivedWidget: i,
970
+ property: c,
971
+ $form: e.data,
972
+ widgetFlags: e.widgetFlags,
973
+ localization: r
974
+ });
975
+ });
976
+ const d = {
977
+ ...s.props || {},
978
+ // We may have overridden properties that aren't set on the original object, so we need to account for them
979
+ ...e.widgetPropOverrides[s.uid]
980
+ };
981
+ if (Ee(Object.keys(d)).forEach((c) => {
982
+ Oe({
983
+ currentStates: e.currentStates,
984
+ widgetPropOverrides: e.widgetPropOverrides,
985
+ derivedWidget: i,
986
+ property: "props",
987
+ subProp: c,
988
+ $form: e.data,
989
+ widgetFlags: e.widgetFlags,
990
+ localization: r
991
+ });
992
+ }), (_(s) || De(s)) && Ee(Object.keys(s.on || {})).forEach((c) => {
993
+ Oe({
994
+ currentStates: e.currentStates,
995
+ widgetPropOverrides: e.widgetPropOverrides,
996
+ derivedWidget: i,
997
+ property: "on",
998
+ // TODO: type hack: "on" is not a CoreProp
999
+ subProp: c,
1000
+ $form: e.data,
1001
+ widgetFlags: e.widgetFlags,
1002
+ localization: r
1003
+ });
1004
+ }), er(s)) {
1005
+ const c = i.previous.children || [], f = s.children.filter((y) => !e.widgetFlags[y.uid] || e.widgetFlags[y.uid].hidden !== !0);
1006
+ i.current.children = f, i.changed = c.length !== f.length || !f.every(
1007
+ (y, h) => c[h] && c[h].uid === f[h].uid
1008
+ );
1009
+ }
1010
+ return t[n] = i.changed ? i : o, delete t[n].changed, t;
1011
+ },
1012
+ {}
1013
+ );
1014
+ }
1015
+ function Oe({
1016
+ currentStates: e,
1017
+ widgetPropOverrides: r,
1018
+ derivedWidget: t,
1019
+ property: n,
1020
+ subProp: o,
1021
+ $form: s,
1022
+ widgetFlags: i,
1023
+ localization: d
1024
+ }) {
1025
+ const c = e.sort((h, S) => S.length - h.length).find((h) => (o ? t.source?.[
1026
+ n
1027
+ /* | 'on' */
1028
+ ]?.[`${o}.${h}`] : t.source[`${n}.${h}`]) !== void 0);
1029
+ let f;
1030
+ c === void 0 ? f = o ? t.source[n]?.[o] : t.source[n] : f = o ? t.source[
1031
+ n
1032
+ /* | 'on */
1033
+ ]?.[`${o}.${c}`] : t.source[`${n}.${c}`];
1034
+ const y = o ? `${n}.${o}` : n;
1035
+ typeof f == "function" ? ie(t.current, y, f({ $form: s, translate: d.translate })) : (Xt(f) && (f = d.translate(
1036
+ f.key,
1037
+ zt(f.params, s),
1038
+ f.default
1039
+ )), (n === "disabled" || n === "readonly") && x(f) && (f = i[t.current.uid][n]), ie(t.current, y, f)), n === "props" && o && r[t.source.uid] && r[t.source.uid][o] !== void 0 && ie(t.current, y, r[t.source.uid][o]), B(t.previous, y) !== B(t.current, y) && (t.changed = !0);
1040
+ }
1041
+ const zt = (e, r) => e && Object.keys(e).reduce((t, n) => {
1042
+ const o = String(e[n]);
1043
+ if (xt(o)) {
1044
+ const s = o.replace("$form.", "");
1045
+ t[n] = B(r, s) || o;
1046
+ } else
1047
+ t[n] = o;
1048
+ return t;
1049
+ }, {});
1050
+ function Ir(e) {
1051
+ return e.flatMap((r) => [
1052
+ r,
1053
+ ...er(r) ? Ir(r.children) : []
1054
+ ]);
1055
+ }
1056
+ const bt = ({ lang: e }, r) => {
1057
+ const t = {
1058
+ ...nr(e),
1059
+ formName: r.payload.formName
1060
+ };
1061
+ let n = r.payload.formDef, o = { status: "ok" };
1062
+ if (typeof n == "string") {
1063
+ try {
1064
+ n = JSON.parse(n);
1065
+ } catch (i) {
1066
+ o = {
1067
+ status: "errored",
1068
+ message: i.message
1069
+ };
1070
+ }
1071
+ if (o.status === "errored")
1072
+ return { ...t, formHealth: o };
1073
+ }
1074
+ if (Array.isArray(n.form)) {
1075
+ const i = n, d = i.form;
1076
+ i.form = {
1077
+ uid: "",
1078
+ type: "flex",
1079
+ kind: "layout",
1080
+ children: d
1081
+ };
1082
+ }
1083
+ const s = tr.decode(n);
1084
+ if (s.isOk()) {
1085
+ o = { status: "ok" };
1086
+ let i = {};
1087
+ try {
1088
+ i = Ir([s.value.form]).reduce(
1089
+ (d, c) => {
1090
+ if (d[c.uid])
1091
+ throw { existingWidget: d[c.uid], newWidget: c };
1092
+ return d[c.uid] = c, d;
1093
+ },
1094
+ {}
1095
+ );
1096
+ } catch (d) {
1097
+ o = {
1098
+ status: "errored",
1099
+ message: en(d.existingWidget, d.newWidget)
1100
+ }, i = {};
1101
+ }
1102
+ return {
1103
+ ...t,
1104
+ formDef: s.value,
1105
+ flatForm: i,
1106
+ formHealth: o
1107
+ };
1108
+ }
1109
+ return {
1110
+ ...t,
1111
+ formHealth: {
1112
+ status: "errored",
1113
+ message: s.error
1114
+ }
1115
+ };
1116
+ };
1117
+ function en(e, r) {
1118
+ const t = (n) => _(n) ? ` at "${n.path}"` : "";
1119
+ return `Duplicate UID "${r.uid}": Assigned to widget "${e.type}"${t(e)} and "${r.type}"${t(r)}.`;
1120
+ }
1121
+ function rn(e, r) {
1122
+ return {
1123
+ ...e,
1124
+ injectedValidations: {
1125
+ ...e.injectedValidations,
1126
+ [r.payload.path]: r.payload.issues
1127
+ }
1128
+ };
1129
+ }
1130
+ const tn = (e, { payload: r }) => {
1131
+ const t = Object.values(e.calculatedWidgets).find(
1132
+ ({ source: o }) => _(o) && o.path === r.path
1133
+ );
1134
+ if (!t)
1135
+ return console.warn(`Control "${r.path}" not found`), e;
1136
+ const n = e.widgetPropOverrides[t.source.uid] || {};
1137
+ return {
1138
+ ...e,
1139
+ widgetPropOverrides: {
1140
+ [t.source.uid]: { ...n, [r.prop]: r.value }
1141
+ }
1142
+ };
1143
+ };
1144
+ function nn(e, r) {
1145
+ return {
1146
+ ...e,
1147
+ widgetFlags: {
1148
+ ...oe(e.widgetFlags, r.payload.uid)
1149
+ },
1150
+ // TODO: has this already been removed in calculate-widget-props??? Do we need this at all?
1151
+ calculatedWidgets: {
1152
+ ...oe(e.calculatedWidgets, r.payload.uid)
1153
+ },
1154
+ widgetPropOverrides: {
1155
+ ...oe(e.widgetPropOverrides, r.payload.uid)
1156
+ },
1157
+ touchedControls: {
1158
+ ...W(e.touchedControls, (t) => {
1159
+ const n = e.flatForm[r.payload.uid];
1160
+ return n && _(n) ? oe(t, n.path) : t;
1161
+ })
1162
+ }
1163
+ // TODO: clear widget from injectedValidations
1164
+ };
1165
+ }
1166
+ const on = (e, r) => ({
1167
+ ...e,
1168
+ data: { ...r.payload.data }
1169
+ }), sn = (e, r) => {
1170
+ const t = B(e.data, r.payload.path);
1171
+ return r.type === "SET_WIDGET_DATA" || r.type === "SET_WIDGET_INITIAL_DATA" && t === void 0 ? {
1172
+ ...e,
1173
+ data: { ...ie(e.data, r.payload.path, r.payload.data) }
1174
+ } : e;
1175
+ }, un = (e, r) => ({
1176
+ ...e,
1177
+ formHealth: r.payload.formHealth
1178
+ }), dn = (e, r) => ({
1179
+ ...e,
1180
+ lang: r.payload.lang
1181
+ });
1182
+ function cn(e, r) {
1183
+ const t = e["~standard"].validate(r);
1184
+ if (t instanceof Promise)
1185
+ throw new TypeError("Schema validation must be synchronous");
1186
+ return t;
1187
+ }
1188
+ function ln(e) {
1189
+ return e.issues === void 0;
1190
+ }
1191
+ const Cr = Symbol("filterMap.skip");
1192
+ function fn(e, r) {
1193
+ const t = [];
1194
+ for (let n = 0; n < e.length; n++) {
1195
+ const o = r(e[n], n, e);
1196
+ o !== Cr && t.push(o);
1197
+ }
1198
+ return t;
1199
+ }
1200
+ function an(e, r, t) {
1201
+ if (e.length !== r.length)
1202
+ return !1;
1203
+ for (let n = 0; n < e.length; n++)
1204
+ if (!t(e[n], r[n], n, e, r))
1205
+ return !1;
1206
+ return !0;
1207
+ }
1208
+ const Ie = (e) => (r) => {
1209
+ const t = fn(
1210
+ Object.values(r.calculatedWidgets),
1211
+ ({ current: o }) => _(o) ? o : Cr
1212
+ ), n = r.validations;
1213
+ return {
1214
+ ...r,
1215
+ validations: t.reduce(
1216
+ (o, s) => {
1217
+ if (o[s.path] = null, s.validator) {
1218
+ const i = e(s.validator), d = B(r.data, s.path), c = cn(
1219
+ i,
1220
+ d
1221
+ );
1222
+ o[s.path] = ln(c) ? null : c.issues.map((f) => f.message);
1223
+ }
1224
+ return Array.isArray(o[s.path]) && Array.isArray(n[s.path]) && an(
1225
+ o[s.path],
1226
+ n[s.path],
1227
+ (i, d) => i === d
1228
+ ) && (o[s.path] = n[s.path]), o;
1229
+ },
1230
+ {}
1231
+ )
1232
+ };
1233
+ }, hn = ({
1234
+ validators: e,
1235
+ validateOn: r,
1236
+ localization: t
1237
+ }) => (n, o) => {
1238
+ switch (o.type) {
1239
+ case "INITIALIZE":
1240
+ return bt(n, o);
1241
+ case "SET_DATA":
1242
+ return W(
1243
+ on(n, o),
1244
+ X,
1245
+ Q,
1246
+ H(t)
1247
+ );
1248
+ case "SET_LANGUAGE":
1249
+ return W(
1250
+ dn(n, o),
1251
+ H(t)
1252
+ );
1253
+ case "ADD_WIDGET":
1254
+ return W(
1255
+ Yr(n, o),
1256
+ te(Ce, X),
1257
+ te(Ce, Q),
1258
+ te(Ce, H(t))
1259
+ );
1260
+ case "REMOVE_WIDGET":
1261
+ return W(
1262
+ nn(n, o),
1263
+ X,
1264
+ Q,
1265
+ H(t)
1266
+ );
1267
+ case "SET_WIDGET_INITIAL_DATA":
1268
+ case "SET_WIDGET_DATA":
1269
+ return W(
1270
+ sn(n, o),
1271
+ X,
1272
+ Q,
1273
+ H(t)
1274
+ );
1275
+ case "OVERRIDE_WIDGET_PROP":
1276
+ return W(
1277
+ tn(n, o),
1278
+ X,
1279
+ Q,
1280
+ H(t),
1281
+ // Apply validation here because this action can be dispatched from the form's event handlers callback
1282
+ te(Kt(o.payload.path), Ie(e))
1283
+ );
1284
+ case "SET_FORM_HEALTH":
1285
+ return un(n, o);
1286
+ case "VALIDATE_ALL":
1287
+ return W(
1288
+ {
1289
+ ...n,
1290
+ touched: !0,
1291
+ touchedControls: Object.keys(n.calculatedWidgets).reduce(
1292
+ (s, i) => {
1293
+ const d = n.calculatedWidgets[i].source;
1294
+ return _(d) && (s[d.path] = !0), s;
1295
+ },
1296
+ {}
1297
+ )
1298
+ },
1299
+ Ie(e)
1300
+ );
1301
+ case "ATTEMPT_VALIDATION": {
1302
+ const s = o.payload.reason, i = o.payload.path;
1303
+ return r === "eager" || s === r || r.includes(s) ? W(
1304
+ {
1305
+ ...n,
1306
+ touched: !0,
1307
+ touchedControls: { ...n.touchedControls, [i]: !0 }
1308
+ },
1309
+ Ie(e),
1310
+ // TODO: extract this into a separate function
1311
+ // When the widget is a Widget Function, we propagate the validation result immediately
1312
+ (c) => {
1313
+ const f = o.payload.uid, y = c.calculatedWidgets[f], h = y.source;
1314
+ if (Pe(h)) {
1315
+ const S = h({
1316
+ $form: c.data,
1317
+ errors: c.validations[i],
1318
+ touched: !0,
1319
+ translate: t.translate
1320
+ });
1321
+ return {
1322
+ ...c,
1323
+ calculatedWidgets: {
1324
+ ...c.calculatedWidgets,
1325
+ [f]: {
1326
+ ...y,
1327
+ previous: y.current,
1328
+ current: S
1329
+ }
1330
+ }
1331
+ };
1332
+ }
1333
+ return c;
1334
+ }
1335
+ ) : n;
1336
+ }
1337
+ case "INJECT_VALIDATION_ISSUES":
1338
+ return rn(n, o);
1339
+ default:
1340
+ return Zr(o);
1341
+ }
1342
+ }, Ce = (e) => e.formHealth.status === "ok";
1343
+ function pn(e = [], r, t, n) {
1344
+ const o = new Dr(nr(n.lang)), s = o.asObservable().pipe(w()), i = hn({ validators: r, validateOn: t, localization: n });
1345
+ function d(h) {
1346
+ const S = o.getValue(), j = i(S, h);
1347
+ o.next(j);
1348
+ }
1349
+ let c = d;
1350
+ const f = {
1351
+ getState: () => o.getValue(),
1352
+ dispatch: (h) => c(h)
1353
+ // reference is updated later
1354
+ };
1355
+ return c = e.map((h) => h(f)).reduceRight((h, S) => S(h), d), {
1356
+ state$: s,
1357
+ dispatch: c,
1358
+ getState: () => o.getValue()
1359
+ };
1360
+ }
1361
+ const gn = D(
1362
+ I((e) => e.data),
1363
+ w()
1364
+ ), _n = (e) => D(
1365
+ gn,
1366
+ I((r) => B(r, e)),
1367
+ w()
1368
+ ), yn = D(
1369
+ ae((e) => e.touched === !0),
1370
+ I((e) => e.validations),
1371
+ w()
1372
+ ), Wn = (e) => D(
1373
+ yn,
1374
+ I((r) => r[e]),
1375
+ w()
1376
+ ), mn = D(
1377
+ ae((e) => e.touched === !0),
1378
+ I((e) => e.injectedValidations),
1379
+ w()
1380
+ ), Pn = (e) => D(
1381
+ mn,
1382
+ I((r) => r[e]),
1383
+ w(),
1384
+ // we want to make sure combineLatest([validation$, injectedValidation$]) triggers
1385
+ kr(null)
1386
+ ), wr = D(
1387
+ I((e) => e.calculatedWidgets),
1388
+ w()
1389
+ ), Nn = (e) => D(
1390
+ wr,
1391
+ I((r) => r[e]),
1392
+ ae((r) => r !== void 0),
1393
+ I((r) => r.current),
1394
+ w()
1395
+ ), jn = (e) => D(
1396
+ wr,
1397
+ I((r) => r[e]),
1398
+ ae((r) => r !== void 0),
1399
+ I((r) => r.current.children),
1400
+ w()
1401
+ ), An = D(
1402
+ I((e) => e.widgetFlags),
1403
+ w()
1404
+ ), Ln = (e) => D(
1405
+ An,
1406
+ I((r) => r[e]),
1407
+ w()
1408
+ ), Sn = D(
1409
+ I((e) => e.touchedControls),
1410
+ w()
1411
+ ), Rn = (e) => D(
1412
+ Sn,
1413
+ I((r) => r[e]),
1414
+ w()
1415
+ ), $n = D(
1416
+ I((e) => e.formHealth),
1417
+ w(
1418
+ (e, r) => !(e.status !== r.status || e.status === "errored")
1419
+ )
1420
+ ), Un = (e) => e.pipe($n);
1421
+ class vn {
1422
+ constructor() {
1423
+ this.registry = {}, this.widgetLoaders = {}, this._ready = !1;
1424
+ }
1425
+ /**
1426
+ * When the registry has been initialized by calling `setWidgetLoaders`
1427
+ */
1428
+ get ready() {
1429
+ return this._ready;
1430
+ }
1431
+ setWidgetLoaders(r) {
1432
+ this.widgetLoaders = r, this._ready = !0;
1433
+ }
1434
+ async loadWidget(r) {
1435
+ return this.registry[r] ?? (this.registry[r] = await this.widgetLoaders[r]());
1436
+ }
1437
+ }
1438
+ class Vn {
1439
+ constructor() {
1440
+ this.widgetRegistry = new vn(), this.store = {}, this.events$ = new Fr(), this.uuid = crypto.randomUUID(), this.itemRenderers = {};
1441
+ }
1442
+ initialize(r, t = [], n, o, s, i = Qt()) {
1443
+ this.localization = i, this.widgetRegistry.setWidgetLoaders(r), this.itemRenderers = s, this.store = pn(t, n, o, i);
1444
+ }
1445
+ emitEvent(r, t, n) {
1446
+ const s = this.store.getState().currentStates.filter((i) => t.on?.[`${r}.${i}`] !== void 0);
1447
+ if (s.length > 0)
1448
+ s.forEach((i) => {
1449
+ const d = t.on?.[`${r}.${i}`];
1450
+ this.attemptValidation(r, d, t), d && this.events$.next({
1451
+ name: d,
1452
+ data: this.store.getState().data,
1453
+ detail: n ?? void 0,
1454
+ callback: (c) => {
1455
+ this.store.dispatch(c);
1456
+ }
1457
+ });
1458
+ });
1459
+ else {
1460
+ const i = t.on?.[r];
1461
+ this.attemptValidation(r, i, t), i && this.events$.next({
1462
+ name: i,
1463
+ data: this.store.getState().data,
1464
+ detail: n,
1465
+ callback: (d) => {
1466
+ this.store.dispatch(d);
1467
+ }
1468
+ });
1469
+ }
1470
+ }
1471
+ attemptValidation(r, t, n) {
1472
+ n.kind !== "layout" && (r === "change" ? this.store.dispatch({
1473
+ type: "ATTEMPT_VALIDATION",
1474
+ payload: {
1475
+ reason: "change",
1476
+ path: n.path,
1477
+ uid: n.uid
1478
+ }
1479
+ }) : r === "click" && t === "submit" && this.store.dispatch({
1480
+ type: "VALIDATE_ALL"
1481
+ }));
1482
+ }
1483
+ }
1484
+ function En(e) {
1485
+ return e.$schema !== void 0 && e.$schema.startsWith("https://json-schema.org/draft");
1486
+ }
1487
+ const Hn = (e) => (r) => (t) => (n) => {
1488
+ if (n.type === "INITIALIZE") {
1489
+ let o = n.payload.formDef === "string" ? JSON.parse(n.payload.formDef) : n.payload.formDef;
1490
+ En(o) && (o = Z(
1491
+ o,
1492
+ e,
1493
+ // TODO: Implement Json Schema Ref resolver
1494
+ () => {
1495
+ throw new Error("Ref resolving not implemented");
1496
+ }
1497
+ ), o = {
1498
+ form: o
1499
+ }), t({ ...n, payload: { ...n.payload, formDef: o } });
1500
+ } else
1501
+ t(n);
1502
+ };
1503
+ function Z(e, r, t, n = []) {
1504
+ if (e.$ref) {
1505
+ const s = t(e.$ref);
1506
+ return Z(s, r, t, n);
1507
+ }
1508
+ if (e.oneOf)
1509
+ return {
1510
+ ...r.oneOf(e),
1511
+ props: {},
1512
+ children: e.oneOf.map((i) => Z(i, r, t, n))
1513
+ };
1514
+ if (e.anyOf)
1515
+ return {
1516
+ ...r.anyOf(e),
1517
+ props: {},
1518
+ children: e.anyOf.map((i) => Z(i, r, t, n))
1519
+ };
1520
+ if (e.type === "object") {
1521
+ const s = [];
1522
+ if (e.properties)
1523
+ for (const [i, d] of Object.entries(e.properties)) {
1524
+ const c = [...n, i], f = Z(d, r, t, c);
1525
+ s.push(f);
1526
+ }
1527
+ return r.object(e, s);
1528
+ }
1529
+ if (e.type === "array")
1530
+ throw new Error(`Arrays not supported yet at path: ${n.join(".")}`);
1531
+ if (e.enum)
1532
+ return r.enum(e, n.join("."));
1533
+ const o = r[e.type];
1534
+ return o ? o(e, n.join(".")) : r.fallback(e);
1535
+ }
1536
+ const Bn = {
1537
+ log: (e, r) => (r ? console.log(r, e) : console.log(e), e)
1538
+ };
1539
+ function Gn(e, r) {
1540
+ const t = On(e.uid, r);
1541
+ return _(e) ? {
1542
+ ...e,
1543
+ uid: t,
1544
+ path: In(e.path, r)
1545
+ } : {
1546
+ ...e,
1547
+ uid: t
1548
+ };
1549
+ }
1550
+ function On(e, r) {
1551
+ if (r === -1)
1552
+ throw new Error("-1 is an invalid Repeater index");
1553
+ return `${e}[${r}]`;
1554
+ }
1555
+ function In(e, r) {
1556
+ if (r === -1)
1557
+ throw new Error("-1 is an invalid Repeater index");
1558
+ return e.replace(".items.", `.${r}.`);
1559
+ }
1560
+ export {
1561
+ Bn as Debug,
1562
+ Vn as FormContext,
1563
+ vn as WidgetRegistry,
1564
+ jn as calculatedLayoutChildrenByUid$,
1565
+ Nn as calculatedWidgetsByUid$,
1566
+ Tn as cloneObject,
1567
+ kn as compose,
1568
+ pn as createFormStore,
1569
+ nr as createInitialState,
1570
+ _n as dataByPath$,
1571
+ Dn as defineForm,
1572
+ oe as deleteKey,
1573
+ tr as formDefDecoder,
1574
+ Un as formHealth,
1575
+ B as get,
1576
+ Fn as getDirectionFromLanguage,
1577
+ Qt as identityTranslator,
1578
+ Pn as injectedValidationByPath$,
1579
+ De as isActionWidget,
1580
+ wn as isDisplayWidget,
1581
+ Pe as isFunctionWidget,
1582
+ _ as isInputWidget,
1583
+ En as isJsonSchema,
1584
+ er as isLayoutWidget,
1585
+ ln as isStandardValidateSuccess,
1586
+ Xt as isTranslationConfig,
1587
+ Hn as jsonSchemaMiddleware,
1588
+ Le as layoutWidgetDecoder,
1589
+ Gn as makeRepeaterItemConfig,
1590
+ W as pipe,
1591
+ An as selectWidgetFlags,
1592
+ ie as set,
1593
+ be as shortUUID,
1594
+ cn as standardValidate,
1595
+ Rn as touchedControlsByPath$,
1596
+ Wn as validationByPath$,
1597
+ Ln as widgetFlagsByUid$
1598
+ };