@xmachines/play-vue 1.0.0-beta.2 → 1.0.0-beta.21

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 (74) hide show
  1. package/README.md +214 -84
  2. package/dist/PlayRenderer.js +7 -0
  3. package/dist/PlayRenderer.js.map +1 -0
  4. package/dist/PlayRenderer.vue_vue_type_script_lang.js +57 -0
  5. package/dist/PlayRenderer.vue_vue_type_script_lang.js.map +1 -0
  6. package/dist/define-registry.d.ts +79 -0
  7. package/dist/define-registry.d.ts.map +1 -0
  8. package/dist/define-registry.js +21 -0
  9. package/dist/define-registry.js.map +1 -0
  10. package/dist/index.d.ts +15 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +5 -5
  13. package/dist/node_modules/@json-render/core/dist/chunk-AFLK3Q4T.js +111 -0
  14. package/dist/node_modules/@json-render/core/dist/chunk-AFLK3Q4T.js.map +1 -0
  15. package/dist/node_modules/@json-render/core/dist/index.js +956 -0
  16. package/dist/node_modules/@json-render/core/dist/index.js.map +1 -0
  17. package/dist/node_modules/@json-render/core/dist/store-utils.js +1 -0
  18. package/dist/node_modules/@json-render/vue/dist/chunk-WIPZLAF7.js +57 -0
  19. package/dist/node_modules/@json-render/vue/dist/chunk-WIPZLAF7.js.map +1 -0
  20. package/dist/node_modules/@json-render/vue/dist/index.js +796 -0
  21. package/dist/node_modules/@json-render/vue/dist/index.js.map +1 -0
  22. package/dist/node_modules/@json-render/xstate/dist/index.js +20 -0
  23. package/dist/node_modules/@json-render/xstate/dist/index.js.map +1 -0
  24. package/dist/node_modules/@xstate/store/dist/store-69e7e2d5.esm.js +227 -0
  25. package/dist/node_modules/@xstate/store/dist/store-69e7e2d5.esm.js.map +1 -0
  26. package/dist/node_modules/zod/v4/classic/errors.js +25 -0
  27. package/dist/node_modules/zod/v4/classic/errors.js.map +1 -0
  28. package/dist/node_modules/zod/v4/classic/iso.js +33 -0
  29. package/dist/node_modules/zod/v4/classic/iso.js.map +1 -0
  30. package/dist/node_modules/zod/v4/classic/parse.js +8 -0
  31. package/dist/node_modules/zod/v4/classic/parse.js.map +1 -0
  32. package/dist/node_modules/zod/v4/classic/schemas.js +362 -0
  33. package/dist/node_modules/zod/v4/classic/schemas.js.map +1 -0
  34. package/dist/node_modules/zod/v4/core/api.js +530 -0
  35. package/dist/node_modules/zod/v4/core/api.js.map +1 -0
  36. package/dist/node_modules/zod/v4/core/checks.js +285 -0
  37. package/dist/node_modules/zod/v4/core/checks.js.map +1 -0
  38. package/dist/node_modules/zod/v4/core/core.js +46 -0
  39. package/dist/node_modules/zod/v4/core/core.js.map +1 -0
  40. package/dist/node_modules/zod/v4/core/doc.js +25 -0
  41. package/dist/node_modules/zod/v4/core/doc.js.map +1 -0
  42. package/dist/node_modules/zod/v4/core/errors.js +43 -0
  43. package/dist/node_modules/zod/v4/core/errors.js.map +1 -0
  44. package/dist/node_modules/zod/v4/core/json-schema-processors.js +183 -0
  45. package/dist/node_modules/zod/v4/core/json-schema-processors.js.map +1 -0
  46. package/dist/node_modules/zod/v4/core/parse.js +70 -0
  47. package/dist/node_modules/zod/v4/core/parse.js.map +1 -0
  48. package/dist/node_modules/zod/v4/core/regexes.js +27 -0
  49. package/dist/node_modules/zod/v4/core/regexes.js.map +1 -0
  50. package/dist/node_modules/zod/v4/core/registries.js +42 -0
  51. package/dist/node_modules/zod/v4/core/registries.js.map +1 -0
  52. package/dist/node_modules/zod/v4/core/schemas.js +823 -0
  53. package/dist/node_modules/zod/v4/core/schemas.js.map +1 -0
  54. package/dist/node_modules/zod/v4/core/to-json-schema.js +224 -0
  55. package/dist/node_modules/zod/v4/core/to-json-schema.js.map +1 -0
  56. package/dist/node_modules/zod/v4/core/util.js +268 -0
  57. package/dist/node_modules/zod/v4/core/util.js.map +1 -0
  58. package/dist/node_modules/zod/v4/core/versions.js +10 -0
  59. package/dist/node_modules/zod/v4/core/versions.js.map +1 -0
  60. package/dist/types.d.ts +31 -7
  61. package/dist/types.d.ts.map +1 -1
  62. package/dist/useActor.d.ts +35 -0
  63. package/dist/useActor.d.ts.map +1 -0
  64. package/dist/useActor.js +15 -0
  65. package/dist/useActor.js.map +1 -0
  66. package/package.json +31 -23
  67. package/dist/PlayRenderer.vue.js +0 -8
  68. package/dist/PlayRenderer.vue.js.map +0 -1
  69. package/dist/PlayRenderer.vue2.js +0 -48
  70. package/dist/PlayRenderer.vue2.js.map +0 -1
  71. package/dist/_virtual/_plugin-vue_export-helper.js +0 -10
  72. package/dist/_virtual/_plugin-vue_export-helper.js.map +0 -1
  73. package/dist/index.css +0 -1
  74. package/dist/index.js.map +0 -1
@@ -0,0 +1,956 @@
1
+ import { _enum as e, any as t, array as n, boolean as r, lazy as i, literal as a, number as o, object as s, record as c, string as l, union as u, unknown as d } from "../../../zod/v4/classic/schemas.js";
2
+ import { DynamicValueSchema as f, getByPath as p, resolveDynamicValue as m } from "./chunk-AFLK3Q4T.js";
3
+ //#region ../../node_modules/@json-render/core/dist/index.mjs
4
+ var h = u([o(), s({ $state: l() })]), g = {
5
+ eq: d().optional(),
6
+ neq: d().optional(),
7
+ gt: h.optional(),
8
+ gte: h.optional(),
9
+ lt: h.optional(),
10
+ lte: h.optional(),
11
+ not: a(!0).optional()
12
+ }, _ = u([
13
+ s({
14
+ $state: l(),
15
+ ...g
16
+ }),
17
+ s({
18
+ $item: l(),
19
+ ...g
20
+ }),
21
+ s({
22
+ $index: a(!0),
23
+ ...g
24
+ })
25
+ ]), v = i(() => u([
26
+ r(),
27
+ _,
28
+ n(_),
29
+ s({ $and: n(v) }),
30
+ s({ $or: n(v) })
31
+ ]));
32
+ function y(e, t) {
33
+ return typeof e == "object" && e && "$state" in e && typeof e.$state == "string" ? p(t.stateModel, e.$state) : e;
34
+ }
35
+ function b(e) {
36
+ return "$item" in e;
37
+ }
38
+ function x(e) {
39
+ return "$index" in e;
40
+ }
41
+ function S(e, t) {
42
+ return x(e) ? t.repeatIndex : b(e) ? t.repeatItem === void 0 ? void 0 : e.$item === "" ? t.repeatItem : p(t.repeatItem, e.$item) : p(t.stateModel, e.$state);
43
+ }
44
+ function C(e, t) {
45
+ let n = S(e, t), r;
46
+ if (e.eq !== void 0) r = n === y(e.eq, t);
47
+ else if (e.neq !== void 0) r = n !== y(e.neq, t);
48
+ else if (e.gt !== void 0) {
49
+ let i = y(e.gt, t);
50
+ r = typeof n == "number" && typeof i == "number" ? n > i : !1;
51
+ } else if (e.gte !== void 0) {
52
+ let i = y(e.gte, t);
53
+ r = typeof n == "number" && typeof i == "number" ? n >= i : !1;
54
+ } else if (e.lt !== void 0) {
55
+ let i = y(e.lt, t);
56
+ r = typeof n == "number" && typeof i == "number" ? n < i : !1;
57
+ } else if (e.lte !== void 0) {
58
+ let i = y(e.lte, t);
59
+ r = typeof n == "number" && typeof i == "number" ? n <= i : !1;
60
+ } else r = !!n;
61
+ return e.not === !0 ? !r : r;
62
+ }
63
+ function w(e) {
64
+ return typeof e == "object" && !!e && !Array.isArray(e) && "$and" in e;
65
+ }
66
+ function T(e) {
67
+ return typeof e == "object" && !!e && !Array.isArray(e) && "$or" in e;
68
+ }
69
+ function E(e, t) {
70
+ return e === void 0 ? !0 : typeof e == "boolean" ? e : Array.isArray(e) ? e.every((e) => C(e, t)) : w(e) ? e.$and.every((e) => E(e, t)) : T(e) ? e.$or.some((e) => E(e, t)) : C(e, t);
71
+ }
72
+ function ee(e) {
73
+ return typeof e == "object" && !!e && "$state" in e && typeof e.$state == "string";
74
+ }
75
+ function D(e) {
76
+ return typeof e == "object" && !!e && "$item" in e && typeof e.$item == "string";
77
+ }
78
+ function O(e) {
79
+ return typeof e == "object" && !!e && "$index" in e && e.$index === !0;
80
+ }
81
+ function k(e) {
82
+ return typeof e == "object" && !!e && "$bindState" in e && typeof e.$bindState == "string";
83
+ }
84
+ function A(e) {
85
+ return typeof e == "object" && !!e && "$bindItem" in e && typeof e.$bindItem == "string";
86
+ }
87
+ function j(e) {
88
+ return typeof e == "object" && !!e && "$cond" in e && "$then" in e && "$else" in e;
89
+ }
90
+ function te(e) {
91
+ return typeof e == "object" && !!e && "$computed" in e && typeof e.$computed == "string";
92
+ }
93
+ function ne(e) {
94
+ return typeof e == "object" && !!e && "$template" in e && typeof e.$template == "string";
95
+ }
96
+ var re = 100, M = /* @__PURE__ */ new Set(), N = 100, P = /* @__PURE__ */ new Set();
97
+ function F(e, t) {
98
+ if (t.repeatBasePath == null) {
99
+ console.warn(`$bindItem used outside repeat scope: "${e}"`);
100
+ return;
101
+ }
102
+ return e === "" ? t.repeatBasePath : t.repeatBasePath + "/" + e;
103
+ }
104
+ function I(e, t) {
105
+ if (e == null) return e;
106
+ if (ee(e)) return p(t.stateModel, e.$state);
107
+ if (D(e)) return t.repeatItem === void 0 ? void 0 : e.$item === "" ? t.repeatItem : p(t.repeatItem, e.$item);
108
+ if (O(e)) return t.repeatIndex;
109
+ if (k(e)) return p(t.stateModel, e.$bindState);
110
+ if (A(e)) {
111
+ let n = F(e.$bindItem, t);
112
+ return n === void 0 ? void 0 : p(t.stateModel, n);
113
+ }
114
+ if (j(e)) return I(E(e.$cond, t) ? e.$then : e.$else, t);
115
+ if (te(e)) {
116
+ let n = t.functions?.[e.$computed];
117
+ if (!n) {
118
+ M.has(e.$computed) || (M.size < re && M.add(e.$computed), console.warn(`Unknown $computed function: "${e.$computed}"`));
119
+ return;
120
+ }
121
+ let r = {};
122
+ if (e.args) for (let [n, i] of Object.entries(e.args)) r[n] = I(i, t);
123
+ return n(r);
124
+ }
125
+ if (ne(e)) return e.$template.replace(/\$\{([^}]+)\}/g, (e, n) => {
126
+ let r = n;
127
+ r.startsWith("/") || (P.has(r) || (P.size < N && P.add(r), console.warn(`$template path "${r}" should be a JSON Pointer starting with "/". Automatically resolving as "/${r}".`)), r = "/" + r);
128
+ let i = p(t.stateModel, r);
129
+ return i == null ? "" : String(i);
130
+ });
131
+ if (Array.isArray(e)) return e.map((e) => I(e, t));
132
+ if (typeof e == "object") {
133
+ let n = {};
134
+ for (let [r, i] of Object.entries(e)) n[r] = I(i, t);
135
+ return n;
136
+ }
137
+ return e;
138
+ }
139
+ function ie(e, t) {
140
+ let n = {};
141
+ for (let [r, i] of Object.entries(e)) n[r] = I(i, t);
142
+ return n;
143
+ }
144
+ function ae(e, t) {
145
+ let n;
146
+ for (let [r, i] of Object.entries(e)) if (k(i)) n ||= {}, n[r] = i.$bindState;
147
+ else if (A(i)) {
148
+ let e = F(i.$bindItem, t);
149
+ e !== void 0 && (n ||= {}, n[r] = e);
150
+ }
151
+ return n;
152
+ }
153
+ function oe(e, t) {
154
+ return D(e) ? F(e.$item, t) : O(e) ? t.repeatIndex : I(e, t);
155
+ }
156
+ var se = s({
157
+ title: l(),
158
+ message: l(),
159
+ confirmLabel: l().optional(),
160
+ cancelLabel: l().optional(),
161
+ variant: e(["default", "danger"]).optional()
162
+ }), ce = u([
163
+ s({ navigate: l() }),
164
+ s({ set: c(l(), d()) }),
165
+ s({ action: l() })
166
+ ]), le = u([s({ set: c(l(), d()) }), s({ action: l() })]);
167
+ s({
168
+ action: l(),
169
+ params: c(l(), f).optional(),
170
+ confirm: se.optional(),
171
+ onSuccess: ce.optional(),
172
+ onError: le.optional(),
173
+ preventDefault: r().optional()
174
+ });
175
+ function ue(e, t) {
176
+ let n = {};
177
+ if (e.params) for (let [r, i] of Object.entries(e.params)) n[r] = m(i, t);
178
+ let r = e.confirm;
179
+ return r &&= {
180
+ ...r,
181
+ message: L(r.message, t),
182
+ title: L(r.title, t)
183
+ }, {
184
+ action: e.action,
185
+ params: n,
186
+ confirm: r,
187
+ onSuccess: e.onSuccess,
188
+ onError: e.onError
189
+ };
190
+ }
191
+ function L(e, t) {
192
+ return e.replace(/\$\{([^}]+)\}/g, (e, n) => {
193
+ let r = m({ $state: n }, t);
194
+ return String(r ?? "");
195
+ });
196
+ }
197
+ async function R(e) {
198
+ let { action: t, handler: n, setState: r, navigate: i, executeAction: a } = e;
199
+ try {
200
+ if (await n(t.params), t.onSuccess) if ("navigate" in t.onSuccess && i) i(t.onSuccess.navigate);
201
+ else if ("set" in t.onSuccess) for (let [e, n] of Object.entries(t.onSuccess.set)) r(e, n);
202
+ else "action" in t.onSuccess && a && await a(t.onSuccess.action);
203
+ } catch (e) {
204
+ if (t.onError) if ("set" in t.onError) for (let [n, i] of Object.entries(t.onError.set)) r(n, typeof i == "string" && i === "$error.message" ? e.message : i);
205
+ else "action" in t.onError && a && await a(t.onError.action);
206
+ else throw e;
207
+ }
208
+ }
209
+ s({
210
+ checks: n(s({
211
+ type: l(),
212
+ args: c(l(), f).optional(),
213
+ message: l()
214
+ })).optional(),
215
+ validateOn: e([
216
+ "change",
217
+ "blur",
218
+ "submit"
219
+ ]).optional(),
220
+ enabled: v.optional()
221
+ });
222
+ var z = (e, t) => e === t?.other, B = {
223
+ required: (e) => e == null ? !1 : typeof e == "string" ? e.trim().length > 0 : Array.isArray(e) ? e.length > 0 : !0,
224
+ email: (e) => typeof e == "string" ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e) : !1,
225
+ minLength: (e, t) => {
226
+ if (typeof e != "string") return !1;
227
+ let n = t?.min;
228
+ return typeof n == "number" ? e.length >= n : !1;
229
+ },
230
+ maxLength: (e, t) => {
231
+ if (typeof e != "string") return !1;
232
+ let n = t?.max;
233
+ return typeof n == "number" ? e.length <= n : !1;
234
+ },
235
+ pattern: (e, t) => {
236
+ if (typeof e != "string") return !1;
237
+ let n = t?.pattern;
238
+ if (typeof n != "string") return !1;
239
+ try {
240
+ return new RegExp(n).test(e);
241
+ } catch {
242
+ return !1;
243
+ }
244
+ },
245
+ min: (e, t) => {
246
+ if (typeof e != "number") return !1;
247
+ let n = t?.min;
248
+ return typeof n == "number" ? e >= n : !1;
249
+ },
250
+ max: (e, t) => {
251
+ if (typeof e != "number") return !1;
252
+ let n = t?.max;
253
+ return typeof n == "number" ? e <= n : !1;
254
+ },
255
+ numeric: (e) => typeof e == "number" ? !isNaN(e) : typeof e == "string" ? !isNaN(parseFloat(e)) : !1,
256
+ url: (e) => {
257
+ if (typeof e != "string") return !1;
258
+ try {
259
+ return new URL(e), !0;
260
+ } catch {
261
+ return !1;
262
+ }
263
+ },
264
+ matches: z,
265
+ equalTo: z,
266
+ lessThan: (e, t) => {
267
+ let n = t?.other;
268
+ if (e == null || n == null || e === "" || n === "") return !1;
269
+ if (typeof e == "number" && typeof n == "number" || typeof e == "string" && typeof n == "string") return e < n;
270
+ let r = Number(e), i = Number(n);
271
+ return !isNaN(r) && !isNaN(i) ? r < i : !1;
272
+ },
273
+ greaterThan: (e, t) => {
274
+ let n = t?.other;
275
+ if (e == null || n == null || e === "" || n === "") return !1;
276
+ if (typeof e == "number" && typeof n == "number" || typeof e == "string" && typeof n == "string") return e > n;
277
+ let r = Number(e), i = Number(n);
278
+ return !isNaN(r) && !isNaN(i) ? r > i : !1;
279
+ },
280
+ requiredIf: (e, t) => t?.field ? e == null ? !1 : typeof e == "string" ? e.trim().length > 0 : Array.isArray(e) ? e.length > 0 : !0 : !0
281
+ };
282
+ function V(e, t) {
283
+ let { value: n, stateModel: r, customFunctions: i } = t, a = {};
284
+ if (e.args) for (let [t, n] of Object.entries(e.args)) a[t] = I(n, { stateModel: r });
285
+ let o = B[e.type] ?? i?.[e.type];
286
+ if (!o) return console.warn(`Unknown validation function: ${e.type}`), {
287
+ type: e.type,
288
+ valid: !0,
289
+ message: e.message
290
+ };
291
+ let s = o(n, a);
292
+ return {
293
+ type: e.type,
294
+ valid: s,
295
+ message: e.message
296
+ };
297
+ }
298
+ function H(e, t) {
299
+ let n = [], r = [];
300
+ if (e.enabled && !E(e.enabled, { stateModel: t.stateModel })) return {
301
+ valid: !0,
302
+ errors: [],
303
+ checks: []
304
+ };
305
+ if (e.checks) for (let i of e.checks) {
306
+ let e = V(i, t);
307
+ n.push(e), e.valid || r.push(e.message);
308
+ }
309
+ return {
310
+ valid: r.length === 0,
311
+ errors: r,
312
+ checks: n
313
+ };
314
+ }
315
+ var U = ["patch"];
316
+ function de(e) {
317
+ return e?.modes?.length ? e.modes : U;
318
+ }
319
+ function fe() {
320
+ return [
321
+ "PATCH MODE (RFC 6902 JSON Patch):",
322
+ "Output one JSON object per line. Each line is a patch operation.",
323
+ "- Add: {\"op\":\"add\",\"path\":\"/elements/new-key\",\"value\":{...}}",
324
+ "- Replace: {\"op\":\"replace\",\"path\":\"/elements/existing-key\",\"value\":{...}}",
325
+ "- Remove: {\"op\":\"remove\",\"path\":\"/elements/old-key\"}",
326
+ "Only output patches for what needs to change."
327
+ ].join("\n");
328
+ }
329
+ function pe() {
330
+ return [
331
+ "MERGE MODE (RFC 7396 JSON Merge Patch):",
332
+ "Output a single JSON object on one line with __json_edit set to true.",
333
+ "Include only the keys that changed. Unmentioned keys are preserved.",
334
+ "Set a key to null to delete it.",
335
+ "",
336
+ "Example (update a title and add an element):",
337
+ "{\"__json_edit\":true,\"elements\":{\"main\":{\"props\":{\"title\":\"New Title\"}},\"new-el\":{\"type\":\"Card\",\"props\":{},\"children\":[]}}}",
338
+ "",
339
+ "Example (delete an element):",
340
+ "{\"__json_edit\":true,\"elements\":{\"old-widget\":null}}"
341
+ ].join("\n");
342
+ }
343
+ function me() {
344
+ return [
345
+ "DIFF MODE (unified diff):",
346
+ "Output a unified diff inside a ```diff code fence.",
347
+ "The diff applies against the JSON-serialized current spec.",
348
+ "",
349
+ "Example:",
350
+ "```diff",
351
+ "--- a/spec.json",
352
+ "+++ b/spec.json",
353
+ "@@ -3,1 +3,1 @@",
354
+ "- \"title\": \"Login\"",
355
+ "+ \"title\": \"Welcome Back\"",
356
+ "```"
357
+ ].join("\n");
358
+ }
359
+ function he() {
360
+ return [
361
+ "PATCH MODE (RFC 6902 JSON Patch):",
362
+ "Output RFC 6902 JSON Patch lines inside a ```yaml-patch code fence.",
363
+ "Each line is one JSON patch operation.",
364
+ "",
365
+ "Example:",
366
+ "```yaml-patch",
367
+ "{\"op\":\"replace\",\"path\":\"/elements/main/props/title\",\"value\":\"New Title\"}",
368
+ "{\"op\":\"add\",\"path\":\"/elements/new-el\",\"value\":{\"type\":\"Card\",\"props\":{},\"children\":[]}}",
369
+ "```"
370
+ ].join("\n");
371
+ }
372
+ function ge() {
373
+ return [
374
+ "MERGE MODE (RFC 7396 JSON Merge Patch):",
375
+ "Output only the changed parts in a ```yaml-edit code fence.",
376
+ "Uses deep merge semantics: only keys you include are updated. Unmentioned elements and props are preserved.",
377
+ "Set a key to null to delete it.",
378
+ "",
379
+ "Example edit (update title, add a new element):",
380
+ "```yaml-edit",
381
+ "elements:",
382
+ " main:",
383
+ " props:",
384
+ " title: Updated Title",
385
+ " new-chart:",
386
+ " type: Card",
387
+ " props: {}",
388
+ " children: []",
389
+ "```",
390
+ "",
391
+ "Example deletion:",
392
+ "```yaml-edit",
393
+ "elements:",
394
+ " old-widget: null",
395
+ "```"
396
+ ].join("\n");
397
+ }
398
+ function _e() {
399
+ return [
400
+ "DIFF MODE (unified diff):",
401
+ "Output a unified diff inside a ```diff code fence.",
402
+ "The diff applies against the YAML-serialized current spec.",
403
+ "",
404
+ "Example:",
405
+ "```diff",
406
+ "--- a/spec.yaml",
407
+ "+++ b/spec.yaml",
408
+ "@@ -6,1 +6,1 @@",
409
+ "- title: Login",
410
+ "+ title: Welcome Back",
411
+ "```"
412
+ ].join("\n");
413
+ }
414
+ function ve(e) {
415
+ if (e.length === 1) return "";
416
+ let t = ["Choose the best edit strategy for the requested change:"];
417
+ return e.includes("patch") && t.push("- PATCH: best for precise, targeted single-field updates"), e.includes("merge") && t.push("- MERGE: best for structural changes (add/remove elements, reparent children, update multiple props at once)"), e.includes("diff") && t.push("- DIFF: best for small text-level changes when you can see the exact lines to change"), t.join("\n");
418
+ }
419
+ function ye(e, t) {
420
+ let n = de(e), r = [];
421
+ r.push("EDITING EXISTING SPECS:"), r.push("");
422
+ let i = ve(n);
423
+ i && (r.push(i), r.push(""));
424
+ for (let e of n) {
425
+ if (t === "json") switch (e) {
426
+ case "patch":
427
+ r.push(fe());
428
+ break;
429
+ case "merge":
430
+ r.push(pe());
431
+ break;
432
+ case "diff":
433
+ r.push(me());
434
+ break;
435
+ }
436
+ else switch (e) {
437
+ case "patch":
438
+ r.push(he());
439
+ break;
440
+ case "merge":
441
+ r.push(ge());
442
+ break;
443
+ case "diff":
444
+ r.push(_e());
445
+ break;
446
+ }
447
+ r.push("");
448
+ }
449
+ return r.join("\n");
450
+ }
451
+ function be() {
452
+ return {
453
+ string: () => ({ kind: "string" }),
454
+ number: () => ({ kind: "number" }),
455
+ boolean: () => ({ kind: "boolean" }),
456
+ array: (e) => ({
457
+ kind: "array",
458
+ inner: e
459
+ }),
460
+ object: (e) => ({
461
+ kind: "object",
462
+ inner: e
463
+ }),
464
+ record: (e) => ({
465
+ kind: "record",
466
+ inner: e
467
+ }),
468
+ any: () => ({ kind: "any" }),
469
+ zod: () => ({ kind: "zod" }),
470
+ ref: (e) => ({
471
+ kind: "ref",
472
+ inner: e
473
+ }),
474
+ propsOf: (e) => ({
475
+ kind: "propsOf",
476
+ inner: e
477
+ }),
478
+ map: (e) => ({
479
+ kind: "map",
480
+ inner: e
481
+ }),
482
+ optional: () => ({ optional: !0 })
483
+ };
484
+ }
485
+ function xe(e, t) {
486
+ return {
487
+ definition: e(be()),
488
+ promptTemplate: t?.promptTemplate,
489
+ defaultRules: t?.defaultRules,
490
+ builtInActions: t?.builtInActions,
491
+ createCatalog(e) {
492
+ return Se(this, e);
493
+ }
494
+ };
495
+ }
496
+ function Se(e, t) {
497
+ let n = t.components, r = t.actions, i = n ? Object.keys(n) : [], a = r ? Object.keys(r) : [], o = Ce(e.definition, t);
498
+ return {
499
+ schema: e,
500
+ data: t,
501
+ componentNames: i,
502
+ actionNames: a,
503
+ prompt(e = {}) {
504
+ return G(this, e);
505
+ },
506
+ jsonSchema(e = {}) {
507
+ return $(o, e.strict ?? !1);
508
+ },
509
+ validate(e) {
510
+ let t = o.safeParse(e);
511
+ return t.success ? {
512
+ success: !0,
513
+ data: t.data
514
+ } : {
515
+ success: !1,
516
+ error: t.error
517
+ };
518
+ },
519
+ zodSchema() {
520
+ return o;
521
+ },
522
+ get _specType() {
523
+ throw Error("_specType is only for type inference");
524
+ }
525
+ };
526
+ }
527
+ function Ce(e, t) {
528
+ return W(e.spec, t);
529
+ }
530
+ function W(i, u) {
531
+ switch (i.kind) {
532
+ case "string": return l();
533
+ case "number": return o();
534
+ case "boolean": return r();
535
+ case "any": return t();
536
+ case "array": return n(W(i.inner, u));
537
+ case "object": {
538
+ let e = i.inner, t = {};
539
+ for (let [n, r] of Object.entries(e)) {
540
+ let e = W(r, u);
541
+ r.optional && (e = e.optional()), t[n] = e;
542
+ }
543
+ return s(t);
544
+ }
545
+ case "record": {
546
+ let e = W(i.inner, u);
547
+ return c(l(), e);
548
+ }
549
+ case "ref": {
550
+ let t = i.inner, n = we(t, u);
551
+ return n.length === 0 ? l() : n.length === 1 ? a(n[0]) : e(n);
552
+ }
553
+ case "propsOf": {
554
+ let e = i.inner, t = Te(e, u);
555
+ return t.length === 0 ? c(l(), d()) : t.length === 1 ? t[0] : c(l(), d());
556
+ }
557
+ default: return d();
558
+ }
559
+ }
560
+ function we(e, t) {
561
+ let n = e.split("."), r = { catalog: t };
562
+ for (let e of n) if (r && typeof r == "object") r = r[e];
563
+ else return [];
564
+ return r && typeof r == "object" ? Object.keys(r) : [];
565
+ }
566
+ function Te(e, t) {
567
+ let n = e.split("."), r = { catalog: t };
568
+ for (let e of n) if (r && typeof r == "object") r = r[e];
569
+ else return [];
570
+ return r && typeof r == "object" ? Object.values(r).map((e) => e.props).filter((e) => e !== void 0) : [];
571
+ }
572
+ function G(e, t) {
573
+ if (e.schema.promptTemplate) {
574
+ let n = {
575
+ catalog: e.data,
576
+ componentNames: e.componentNames,
577
+ actionNames: e.actionNames,
578
+ options: t,
579
+ formatZodType: X
580
+ };
581
+ return e.schema.promptTemplate(n);
582
+ }
583
+ let { system: n = "You are a UI generator that outputs JSON.", customRules: r = [], mode: i = "standalone" } = t, a = i === "chat" ? (console.warn("[json-render] mode \"chat\" is deprecated, use \"inline\" instead"), "inline") : i === "generate" ? (console.warn("[json-render] mode \"generate\" is deprecated, use \"standalone\" instead"), "standalone") : i, o = [];
584
+ o.push(n), o.push(""), a === "inline" ? (o.push("OUTPUT FORMAT (text + JSONL, RFC 6902 JSON Patch):"), o.push("You respond conversationally. When generating UI, first write a brief explanation (1-3 sentences), then output JSONL patch lines wrapped in a ```spec code fence."), o.push("The JSONL lines use RFC 6902 JSON Patch operations to build a UI tree. Always wrap them in a ```spec fence block:"), o.push(" ```spec"), o.push(" {\"op\":\"add\",\"path\":\"/root\",\"value\":\"main\"}"), o.push(" {\"op\":\"add\",\"path\":\"/elements/main\",\"value\":{\"type\":\"Card\",\"props\":{\"title\":\"Hello\"},\"children\":[]}}"), o.push(" ```"), o.push("If the user's message does not require a UI (e.g. a greeting or clarifying question), respond with text only — no JSONL.")) : (o.push("OUTPUT FORMAT (JSONL, RFC 6902 JSON Patch):"), o.push("Output JSONL (one JSON object per line) using RFC 6902 JSON Patch operations to build a UI tree.")), o.push("Each line is a JSON patch operation (add, remove, replace). Start with /root, then stream /elements and /state patches interleaved so the UI fills in progressively as it streams."), o.push(""), o.push("Example output (each line is a separate JSON object):"), o.push("");
585
+ let s = e.data.components, c = e.componentNames, l = c[0] || "Component", u = c.length > 1 ? c[1] : l, d = s?.[l], f = s?.[u], p = d ? K(d) : {}, m = f ? K(f) : {}, h = f?.props ? Ee(f.props) : null, g = h ? {
586
+ ...m,
587
+ [h]: { $item: "title" }
588
+ } : m, _ = [
589
+ JSON.stringify({
590
+ op: "add",
591
+ path: "/root",
592
+ value: "main"
593
+ }),
594
+ JSON.stringify({
595
+ op: "add",
596
+ path: "/elements/main",
597
+ value: {
598
+ type: l,
599
+ props: p,
600
+ children: ["child-1", "list"]
601
+ }
602
+ }),
603
+ JSON.stringify({
604
+ op: "add",
605
+ path: "/elements/child-1",
606
+ value: {
607
+ type: u,
608
+ props: m,
609
+ children: []
610
+ }
611
+ }),
612
+ JSON.stringify({
613
+ op: "add",
614
+ path: "/elements/list",
615
+ value: {
616
+ type: l,
617
+ props: p,
618
+ repeat: {
619
+ statePath: "/items",
620
+ key: "id"
621
+ },
622
+ children: ["item"]
623
+ }
624
+ }),
625
+ JSON.stringify({
626
+ op: "add",
627
+ path: "/elements/item",
628
+ value: {
629
+ type: u,
630
+ props: g,
631
+ children: []
632
+ }
633
+ }),
634
+ JSON.stringify({
635
+ op: "add",
636
+ path: "/state/items",
637
+ value: []
638
+ }),
639
+ JSON.stringify({
640
+ op: "add",
641
+ path: "/state/items/0",
642
+ value: {
643
+ id: "1",
644
+ title: "First Item"
645
+ }
646
+ }),
647
+ JSON.stringify({
648
+ op: "add",
649
+ path: "/state/items/1",
650
+ value: {
651
+ id: "2",
652
+ title: "Second Item"
653
+ }
654
+ })
655
+ ].join("\n");
656
+ o.push(`${_}
657
+
658
+ Note: state patches appear right after the elements that use them, so the UI fills in as it streams. ONLY use component types from the AVAILABLE COMPONENTS list below.`), o.push(""), o.push("INITIAL STATE:"), o.push("Specs include a /state field to seed the state model. Components with { $bindState } or { $bindItem } read from and write to this state, and $state expressions read from it."), o.push("CRITICAL: You MUST include state patches whenever your UI displays data via $state, $bindState, $bindItem, $item, or $index expressions, or uses repeat to iterate over arrays. Without state, these references resolve to nothing and repeat lists render zero items."), o.push("Output state patches right after the elements that reference them, so the UI fills in progressively as it streams."), o.push("Stream state progressively - output one patch per array item instead of one giant blob:"), o.push(" For arrays: {\"op\":\"add\",\"path\":\"/state/posts/0\",\"value\":{\"id\":\"1\",\"title\":\"First Post\",...}} then /state/posts/1, /state/posts/2, etc."), o.push(" For scalars: {\"op\":\"add\",\"path\":\"/state/newTodoText\",\"value\":\"\"}"), o.push(" Initialize the array first if needed: {\"op\":\"add\",\"path\":\"/state/posts\",\"value\":[]}"), o.push("When content comes from the state model, use { \"$state\": \"/some/path\" } dynamic props to display it instead of hardcoding the same value in both state and props. The state model is the single source of truth."), o.push("Include realistic sample data in state. For blogs: 3-4 posts with titles, excerpts, authors, dates. For product lists: 3-5 items with names, prices, descriptions. Never leave arrays empty."), o.push(""), o.push("DYNAMIC LISTS (repeat field):"), o.push("Any element can have a top-level \"repeat\" field to render its children once per item in a state array: { \"repeat\": { \"statePath\": \"/arrayPath\", \"key\": \"id\" } }."), o.push("The element itself renders once (as the container), and its children are expanded once per array item. \"statePath\" is the state array path. \"key\" is an optional field name on each item for stable React keys."), o.push(`Example: ${JSON.stringify({
659
+ type: l,
660
+ props: p,
661
+ repeat: {
662
+ statePath: "/todos",
663
+ key: "id"
664
+ },
665
+ children: ["todo-item"]
666
+ })}`), o.push("Inside children of a repeated element, use { \"$item\": \"field\" } to read a field from the current item, and { \"$index\": true } to get the current array index. For two-way binding to an item field use { \"$bindItem\": \"completed\" } on the appropriate prop."), o.push("ALWAYS use the repeat field for lists backed by state arrays. NEVER hardcode individual elements for each array item."), o.push("IMPORTANT: \"repeat\" is a top-level field on the element (sibling of type/props/children), NOT inside props."), o.push(""), o.push("ARRAY STATE ACTIONS:"), o.push("Use action \"pushState\" to append items to arrays. Params: { statePath: \"/arrayPath\", value: { ...item }, clearStatePath: \"/inputPath\" }."), o.push("Values inside pushState can contain { \"$state\": \"/statePath\" } references to read current state (e.g. the text from an input field)."), o.push("Use \"$id\" inside a pushState value to auto-generate a unique ID."), o.push("Example: on: { \"press\": { \"action\": \"pushState\", \"params\": { \"statePath\": \"/todos\", \"value\": { \"id\": \"$id\", \"title\": { \"$state\": \"/newTodoText\" }, \"completed\": false }, \"clearStatePath\": \"/newTodoText\" } } }"), o.push("Use action \"removeState\" to remove items from arrays by index. Params: { statePath: \"/arrayPath\", index: N }. Inside a repeated element's children, use { \"$index\": true } for the current item index. Action params support the same expressions as props: { \"$item\": \"field\" } resolves to the absolute state path, { \"$index\": true } resolves to the index number, and { \"$state\": \"/path\" } reads a value from state."), o.push("For lists where users can add/remove items (todos, carts, etc.), use pushState and removeState instead of hardcoding with setState."), o.push(""), o.push("IMPORTANT: State paths use RFC 6901 JSON Pointer syntax (e.g. \"/todos/0/title\"). Do NOT use JavaScript-style dot notation (e.g. \"/todos.length\" is WRONG). To generate unique IDs for new items, use \"$id\" instead of trying to read array length."), o.push("");
667
+ let v = s;
668
+ if (v) {
669
+ o.push(`AVAILABLE COMPONENTS (${e.componentNames.length}):`), o.push("");
670
+ for (let [e, t] of Object.entries(v)) {
671
+ let n = t.props ? X(t.props) : "{}", r = t.slots && t.slots.length > 0 ? " [accepts children]" : "", i = t.events && t.events.length > 0 ? ` [events: ${t.events.join(", ")}]` : "", a = t.description ? ` - ${t.description}` : "";
672
+ o.push(`- ${e}: ${n}${a}${r}${i}`);
673
+ }
674
+ o.push("");
675
+ }
676
+ let y = e.data.actions, b = e.schema.builtInActions ?? [], x = y && e.actionNames.length > 0, S = b.length > 0;
677
+ if (x || S) {
678
+ o.push("AVAILABLE ACTIONS:"), o.push("");
679
+ for (let e of b) o.push(`- ${e.name}: ${e.description} [built-in]`);
680
+ if (x) for (let [e, t] of Object.entries(y)) o.push(`- ${e}${t.description ? `: ${t.description}` : ""}`);
681
+ o.push("");
682
+ }
683
+ o.push("EVENTS (the `on` field):"), o.push("Elements can have an optional `on` field to bind events to actions. The `on` field is a top-level field on the element (sibling of type/props/children), NOT inside props."), o.push("Each key in `on` is an event name (from the component's supported events), and the value is an action binding: `{ \"action\": \"<actionName>\", \"params\": { ... } }`."), o.push(""), o.push("Example:"), o.push(` ${JSON.stringify({
684
+ type: l,
685
+ props: p,
686
+ on: { press: {
687
+ action: "setState",
688
+ params: {
689
+ statePath: "/saved",
690
+ value: !0
691
+ }
692
+ } },
693
+ children: []
694
+ })}`), o.push(""), o.push("Action params can use dynamic references to read from state: { \"$state\": \"/statePath\" }."), o.push("IMPORTANT: Do NOT put action/actionParams inside props. Always use the `on` field for event bindings."), o.push(""), o.push("VISIBILITY CONDITIONS:"), o.push("Elements can have an optional `visible` field to conditionally show/hide based on state. IMPORTANT: `visible` is a top-level field on the element object (sibling of type/props/children), NOT inside props."), o.push(`Correct: ${JSON.stringify({
695
+ type: l,
696
+ props: p,
697
+ visible: {
698
+ $state: "/activeTab",
699
+ eq: "home"
700
+ },
701
+ children: ["..."]
702
+ })}`), o.push("- `{ \"$state\": \"/path\" }` - visible when state at path is truthy"), o.push("- `{ \"$state\": \"/path\", \"not\": true }` - visible when state at path is falsy"), o.push("- `{ \"$state\": \"/path\", \"eq\": \"value\" }` - visible when state equals value"), o.push("- `{ \"$state\": \"/path\", \"neq\": \"value\" }` - visible when state does not equal value"), o.push("- `{ \"$state\": \"/path\", \"gt\": N }` / `gte` / `lt` / `lte` - numeric comparisons"), o.push("- Use ONE operator per condition (eq, neq, gt, gte, lt, lte). Do not combine multiple operators."), o.push("- Any condition can add `\"not\": true` to invert its result"), o.push("- `[condition, condition]` - all conditions must be true (implicit AND)"), o.push("- `{ \"$and\": [condition, condition] }` - explicit AND (use when nesting inside $or)"), o.push("- `{ \"$or\": [condition, condition] }` - at least one must be true (OR)"), o.push("- `true` / `false` - always visible/hidden"), o.push(""), o.push("Use a component with on.press bound to setState to update state and drive visibility."), o.push(`Example: A ${l} with on: { "press": { "action": "setState", "params": { "statePath": "/activeTab", "value": "home" } } } sets state, then a container with visible: { "$state": "/activeTab", "eq": "home" } shows only when that tab is active.`), o.push(""), o.push("For tab patterns where the first/default tab should be visible when no tab is selected yet, use $or to handle both cases: visible: { \"$or\": [{ \"$state\": \"/activeTab\", \"eq\": \"home\" }, { \"$state\": \"/activeTab\", \"not\": true }] }. This ensures the first tab is visible both when explicitly selected AND when /activeTab is not yet set."), o.push(""), o.push("DYNAMIC PROPS:"), o.push("Any prop value can be a dynamic expression that resolves based on state. Three forms are supported:"), o.push(""), o.push("1. Read-only state: `{ \"$state\": \"/statePath\" }` - resolves to the value at that state path (one-way read)."), o.push(" Example: `\"color\": { \"$state\": \"/theme/primary\" }` reads the color from state."), o.push(""), o.push("2. Two-way binding: `{ \"$bindState\": \"/statePath\" }` - resolves to the value at the state path AND enables write-back. Use on form input props (value, checked, pressed, etc.)."), o.push(" Example: `\"value\": { \"$bindState\": \"/form/email\" }` binds the input value to /form/email."), o.push(" Inside repeat scopes: `\"checked\": { \"$bindItem\": \"completed\" }` binds to the current item's completed field."), o.push(""), o.push("3. Conditional: `{ \"$cond\": <condition>, \"$then\": <value>, \"$else\": <value> }` - evaluates the condition (same syntax as visibility conditions) and picks the matching value."), o.push(" Example: `\"color\": { \"$cond\": { \"$state\": \"/activeTab\", \"eq\": \"home\" }, \"$then\": \"#007AFF\", \"$else\": \"#8E8E93\" }`"), o.push(""), o.push("Use $bindState for form inputs (text fields, checkboxes, selects, sliders, etc.) and $state for read-only data display. Inside repeat scopes, use $bindItem for form inputs bound to the current item. Use dynamic props instead of duplicating elements with opposing visible conditions when only prop values differ."), o.push(""), o.push("4. Template: `{ \"$template\": \"Hello, ${/name}!\" }` - interpolates `${/path}` references in the string with values from the state model."), o.push(" Example: `\"label\": { \"$template\": \"Items: ${/cart/count} | Total: ${/cart/total}\" }` renders \"Items: 3 | Total: 42.00\" when /cart/count is 3 and /cart/total is 42.00."), o.push("");
703
+ let C = e.data.functions;
704
+ if (C && Object.keys(C).length > 0) {
705
+ o.push("5. Computed: `{ \"$computed\": \"<functionName>\", \"args\": { \"key\": <expression> } }` - calls a registered function with resolved args and returns the result."), o.push(" Example: `\"value\": { \"$computed\": \"fullName\", \"args\": { \"first\": { \"$state\": \"/form/firstName\" }, \"last\": { \"$state\": \"/form/lastName\" } } }`"), o.push(" Available functions:");
706
+ for (let e of Object.keys(C)) o.push(` - ${e}`);
707
+ o.push("");
708
+ }
709
+ s && Object.entries(s).some(([, e]) => e.props ? X(e.props).includes("checks") : !1) && (o.push("VALIDATION:"), o.push("Form components that accept a `checks` prop support client-side validation."), o.push("Each check is an object: { \"type\": \"<name>\", \"message\": \"...\", \"args\": { ... } }"), o.push(""), o.push("Built-in validation types:"), o.push(" - required — value must be non-empty"), o.push(" - email — valid email format"), o.push(" - minLength — minimum string length (args: { \"min\": N })"), o.push(" - maxLength — maximum string length (args: { \"max\": N })"), o.push(" - pattern — match a regex (args: { \"pattern\": \"regex\" })"), o.push(" - min — minimum numeric value (args: { \"min\": N })"), o.push(" - max — maximum numeric value (args: { \"max\": N })"), o.push(" - numeric — value must be a number"), o.push(" - url — valid URL format"), o.push(" - matches — must equal another field (args: { \"other\": { \"$state\": \"/path\" } })"), o.push(" - equalTo — alias for matches (args: { \"other\": { \"$state\": \"/path\" } })"), o.push(" - lessThan — value must be less than another field (args: { \"other\": { \"$state\": \"/path\" } })"), o.push(" - greaterThan — value must be greater than another field (args: { \"other\": { \"$state\": \"/path\" } })"), o.push(" - requiredIf — required only when another field is truthy (args: { \"field\": { \"$state\": \"/path\" } })"), o.push(""), o.push("Example:"), o.push(" \"checks\": [{ \"type\": \"required\", \"message\": \"Email is required\" }, { \"type\": \"email\", \"message\": \"Invalid email\" }]"), o.push(""), o.push("IMPORTANT: When using checks, the component must also have a { $bindState } or { $bindItem } on its value/checked prop for two-way binding."), o.push("Always include validation checks on form inputs for a good user experience (e.g. required, email, minLength)."), o.push("")), (x || S) && (o.push("STATE WATCHERS:"), o.push("Elements can have an optional `watch` field to react to state changes and trigger actions. The `watch` field is a top-level field on the element (sibling of type/props/children), NOT inside props."), o.push("Maps state paths (JSON Pointers) to action bindings. When the value at a watched path changes, the bound actions fire automatically."), o.push(""), o.push("Example (cascading select — country changes trigger city loading):"), o.push(` ${JSON.stringify({
710
+ type: "Select",
711
+ props: {
712
+ value: { $bindState: "/form/country" },
713
+ options: [
714
+ "US",
715
+ "Canada",
716
+ "UK"
717
+ ]
718
+ },
719
+ watch: { "/form/country": {
720
+ action: "loadCities",
721
+ params: { country: { $state: "/form/country" } }
722
+ } },
723
+ children: []
724
+ })}`), o.push(""), o.push("Use `watch` for cascading dependencies where changing one field should trigger side effects (loading data, resetting dependent fields, computing derived values)."), o.push("IMPORTANT: `watch` is a top-level field on the element (sibling of type/props/children), NOT inside props. Watchers only fire when the value changes, not on initial render."), o.push(""));
725
+ let w = t.editModes;
726
+ w && w.length > 0 && o.push(ye({ modes: w }, "json")), o.push("RULES:");
727
+ let T = a === "inline" ? [
728
+ "When generating UI, wrap all JSONL patches in a ```spec code fence - one JSON object per line inside the fence",
729
+ "Write a brief conversational response before any JSONL output",
730
+ "First set root: {\"op\":\"add\",\"path\":\"/root\",\"value\":\"<root-key>\"}",
731
+ "Then add each element: {\"op\":\"add\",\"path\":\"/elements/<key>\",\"value\":{...}}",
732
+ "Output /state patches right after the elements that use them, one per array item for progressive loading. REQUIRED whenever using $state, $bindState, $bindItem, $item, $index, or repeat.",
733
+ "ONLY use components listed above",
734
+ "Each element value needs: type, props, children (array of child keys)",
735
+ "Use unique keys for the element map entries (e.g., 'header', 'metric-1', 'chart-revenue')"
736
+ ] : [
737
+ "Output ONLY JSONL patches - one JSON object per line, no markdown, no code fences",
738
+ "First set root: {\"op\":\"add\",\"path\":\"/root\",\"value\":\"<root-key>\"}",
739
+ "Then add each element: {\"op\":\"add\",\"path\":\"/elements/<key>\",\"value\":{...}}",
740
+ "Output /state patches right after the elements that use them, one per array item for progressive loading. REQUIRED whenever using $state, $bindState, $bindItem, $item, $index, or repeat.",
741
+ "ONLY use components listed above",
742
+ "Each element value needs: type, props, children (array of child keys)",
743
+ "Use unique keys for the element map entries (e.g., 'header', 'metric-1', 'chart-revenue')"
744
+ ], E = e.schema.defaultRules ?? [];
745
+ return [
746
+ ...T,
747
+ ...E,
748
+ ...r
749
+ ].forEach((e, t) => {
750
+ o.push(`${t + 1}. ${e}`);
751
+ }), o.join("\n");
752
+ }
753
+ function K(e) {
754
+ return e.example && Object.keys(e.example).length > 0 ? e.example : e.props ? q(e.props) : {};
755
+ }
756
+ function q(e) {
757
+ if (!e || !e._def) return {};
758
+ let t = e._def, n = Y(e);
759
+ if (n !== "ZodObject" && n !== "object") return {};
760
+ let r = typeof t.shape == "function" ? t.shape() : t.shape;
761
+ if (!r) return {};
762
+ let i = {};
763
+ for (let [e, t] of Object.entries(r)) {
764
+ let n = Y(t);
765
+ n === "ZodOptional" || n === "optional" || n === "ZodNullable" || n === "nullable" || (i[e] = J(t));
766
+ }
767
+ return i;
768
+ }
769
+ function J(e) {
770
+ if (!e || !e._def) return "...";
771
+ let t = e._def;
772
+ switch (Y(e)) {
773
+ case "ZodString":
774
+ case "string": return "example";
775
+ case "ZodNumber":
776
+ case "number": return 0;
777
+ case "ZodBoolean":
778
+ case "boolean": return !0;
779
+ case "ZodLiteral":
780
+ case "literal": return t.value;
781
+ case "ZodEnum":
782
+ case "enum":
783
+ if (Array.isArray(t.values) && t.values.length > 0) return t.values[0];
784
+ if (t.entries && typeof t.entries == "object") {
785
+ let e = Object.values(t.entries);
786
+ return e.length > 0 ? e[0] : "example";
787
+ }
788
+ return "example";
789
+ case "ZodOptional":
790
+ case "optional":
791
+ case "ZodNullable":
792
+ case "nullable":
793
+ case "ZodDefault":
794
+ case "default": {
795
+ let e = t.innerType ?? t.wrapped;
796
+ return e ? J(e) : null;
797
+ }
798
+ case "ZodArray":
799
+ case "array": return [];
800
+ case "ZodObject":
801
+ case "object": return q(e);
802
+ case "ZodUnion":
803
+ case "union": {
804
+ let e = t.options;
805
+ return e && e.length > 0 ? J(e[0]) : "...";
806
+ }
807
+ default: return "...";
808
+ }
809
+ }
810
+ function Ee(e) {
811
+ if (!e || !e._def) return null;
812
+ let t = e._def, n = Y(e);
813
+ if (n !== "ZodObject" && n !== "object") return null;
814
+ let r = typeof t.shape == "function" ? t.shape() : t.shape;
815
+ if (!r) return null;
816
+ for (let [e, t] of Object.entries(r)) {
817
+ let n = Y(t);
818
+ if (!(n === "ZodOptional" || n === "optional" || n === "ZodNullable" || n === "nullable") && (n === "ZodString" || n === "string")) return e;
819
+ }
820
+ return null;
821
+ }
822
+ function Y(e) {
823
+ if (!e || !e._def) return "";
824
+ let t = e._def;
825
+ return t.typeName ?? t.type ?? "";
826
+ }
827
+ function X(e) {
828
+ if (!e || !e._def) return "unknown";
829
+ let t = e._def;
830
+ switch (Y(e)) {
831
+ case "ZodString":
832
+ case "string": return "string";
833
+ case "ZodNumber":
834
+ case "number": return "number";
835
+ case "ZodBoolean":
836
+ case "boolean": return "boolean";
837
+ case "ZodLiteral":
838
+ case "literal": return JSON.stringify(t.value);
839
+ case "ZodEnum":
840
+ case "enum": {
841
+ let e;
842
+ if (Array.isArray(t.values)) e = t.values;
843
+ else if (t.entries && typeof t.entries == "object") e = Object.values(t.entries);
844
+ else return "enum";
845
+ return e.map((e) => `"${e}"`).join(" | ");
846
+ }
847
+ case "ZodArray":
848
+ case "array": {
849
+ let e = typeof t.element == "object" ? t.element : typeof t.type == "object" ? t.type : void 0;
850
+ return e ? `Array<${X(e)}>` : "Array<unknown>";
851
+ }
852
+ case "ZodObject":
853
+ case "object": {
854
+ let e = typeof t.shape == "function" ? t.shape() : t.shape;
855
+ return e ? `{ ${Object.entries(e).map(([e, t]) => {
856
+ let n = Y(t);
857
+ return `${e}${n === "ZodOptional" || n === "ZodNullable" || n === "optional" || n === "nullable" ? "?" : ""}: ${X(t)}`;
858
+ }).join(", ")} }` : "object";
859
+ }
860
+ case "ZodOptional":
861
+ case "optional":
862
+ case "ZodNullable":
863
+ case "nullable": {
864
+ let e = t.innerType ?? t.wrapped;
865
+ return e ? X(e) : "unknown";
866
+ }
867
+ case "ZodUnion":
868
+ case "union": {
869
+ let e = t.options;
870
+ return e ? e.map((e) => X(e)).join(" | ") : "unknown";
871
+ }
872
+ default: return "unknown";
873
+ }
874
+ }
875
+ function Z(e) {
876
+ return typeof e.type == "string" ? e.type : typeof e.typeName == "string" ? e.typeName : "";
877
+ }
878
+ function Q(e) {
879
+ return e.startsWith("Zod") ? e.slice(3).toLowerCase() : e.toLowerCase();
880
+ }
881
+ function $(e, t = !1) {
882
+ let n = e._def;
883
+ switch (Q(Z(n))) {
884
+ case "string": return { type: "string" };
885
+ case "number": return { type: "number" };
886
+ case "boolean": return { type: "boolean" };
887
+ case "literal": {
888
+ let e = n.values;
889
+ return { const: e ? e[0] : n.value };
890
+ }
891
+ case "enum": {
892
+ let e = n.entries;
893
+ return { enum: (e ? Object.values(e) : n.values) ?? [] };
894
+ }
895
+ case "array": {
896
+ let e = n.element ?? n.type;
897
+ return {
898
+ type: "array",
899
+ items: e ? $(e, t) : {}
900
+ };
901
+ }
902
+ case "object": {
903
+ let e = n.shape, r = typeof e == "function" ? e() : e;
904
+ if (!r) return t ? {
905
+ type: "object",
906
+ properties: {},
907
+ required: [],
908
+ additionalProperties: !1
909
+ } : { type: "object" };
910
+ let i = {}, a = [];
911
+ for (let [e, n] of Object.entries(r)) {
912
+ let r = n._def, o = Q(Z(r)), s = o === "optional" || o === "nullable";
913
+ t ? (a.push(e), s ? i[e] = { anyOf: [$(n, t), { type: "null" }] } : i[e] = $(n, t)) : (i[e] = $(n), s || a.push(e));
914
+ }
915
+ return {
916
+ type: "object",
917
+ properties: i,
918
+ required: a.length > 0 ? a : void 0,
919
+ additionalProperties: !1
920
+ };
921
+ }
922
+ case "record": {
923
+ let e = n.valueType;
924
+ return t ? {
925
+ type: "object",
926
+ properties: {},
927
+ required: [],
928
+ additionalProperties: !1
929
+ } : {
930
+ type: "object",
931
+ additionalProperties: e ? $(e) : !0
932
+ };
933
+ }
934
+ case "optional":
935
+ case "nullable": {
936
+ let e = n.innerType;
937
+ return e ? $(e, t) : {};
938
+ }
939
+ case "union": {
940
+ let e = n.options;
941
+ return e ? { anyOf: e.map((e) => $(e, t)) } : {};
942
+ }
943
+ case "any":
944
+ case "unknown": return t ? {
945
+ type: "object",
946
+ properties: {},
947
+ required: [],
948
+ additionalProperties: !1
949
+ } : {};
950
+ default: return {};
951
+ }
952
+ }
953
+ //#endregion
954
+ export { xe as defineSchema, E as evaluateVisibility, R as executeAction, ue as resolveAction, oe as resolveActionParam, ae as resolveBindings, ie as resolveElementProps, H as runValidation };
955
+
956
+ //# sourceMappingURL=index.js.map