@tempots/beatui 0.69.0 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ar-aMLQTGVh.js → ar-BbgpGwJp.js} +1 -1
- package/dist/auth/index.cjs.js +1 -1
- package/dist/auth/index.es.js +106 -105
- package/dist/beatui.css +401 -0
- package/dist/beatui.tailwind.css +401 -0
- package/dist/{de-DBFOC44R.js → de-R7lPfyZ4.js} +1 -1
- package/dist/deep-merge-CQQCMLwG.js +1636 -0
- package/dist/deep-merge-DZxfgKqX.cjs +1 -0
- package/dist/duration-input-D-SIoDoo.cjs +1 -0
- package/dist/duration-input-DKxZ6OCa.js +277 -0
- package/dist/{es-C4xOThaT.js → es-DV0Jr_BZ.js} +1 -1
- package/dist/{fa-B7X_xydY.js → fa-DXvHejs9.js} +1 -1
- package/dist/{fr-AmjzbxN_.js → fr-D8FOMX0o.js} +1 -1
- package/dist/{he-DY-9yiOC.js → he-B19Qsx-u.js} +1 -1
- package/dist/{hi-Clkyp5Fu.js → hi-DozFnE3b.js} +1 -1
- package/dist/{index-GLoRnI6r.js → index-CYb1YxDX.js} +1 -1
- package/dist/{index-CzuXAuLZ.js → index-DdpYvBeh.js} +3 -3
- package/dist/index.cjs.js +4 -4
- package/dist/index.es.js +2852 -3104
- package/dist/{it-BC32WmGF.js → it-But8uzNi.js} +1 -1
- package/dist/{ja-JNSZS_Hv.js → ja-DkwTnFdU.js} +1 -1
- package/dist/json-schema/index.cjs.js +7 -7
- package/dist/json-schema/index.es.js +3814 -3609
- package/dist/json-structure/index.cjs.js +1 -0
- package/dist/json-structure/index.es.js +3157 -0
- package/dist/{ko-B8l0TJp0.js → ko-Cqv-IjhX.js} +1 -1
- package/dist/modal-5P9mU_a4.cjs +1 -0
- package/dist/{modal-DJWj5M5e.js → modal-MofsfmAe.js} +2 -2
- package/dist/{nl-BpYESHP8.js → nl-YSiU3rFI.js} +1 -1
- package/dist/notice-Cqq8g17n.js +209 -0
- package/dist/notice-DP209Ed8.cjs +1 -0
- package/dist/{pl-_sWhGdrs.js → pl-DXmHc2Nh.js} +1 -1
- package/dist/prosemirror/index.es.js +1 -1
- package/dist/{pt-BmiQvHUz.js → pt-Bf3z_-26.js} +1 -1
- package/dist/{ru-DacnqexG.js → ru-Sy00qUeG.js} +1 -1
- package/dist/tailwind/vite-plugin.es.js +1 -0
- package/dist/{toolbar-Bk5-22ln.js → toolbar-C_Ec0_XC.js} +1 -1
- package/dist/{tr-BSS5b_v6.js → tr-BDxG3qd6.js} +1 -1
- package/dist/{translations-zGwuSQWQ.js → translations-BmsRhth7.js} +1 -1
- package/dist/{translations-BUTBIDsS.js → translations-DQxouiBG.js} +24 -24
- package/dist/types/components/form/index.d.ts +1 -0
- package/dist/types/components/form/utils/deep-merge.d.ts +27 -0
- package/dist/types/components/form/utils/index.d.ts +1 -0
- package/dist/types/components/json-schema/controls/null-control.d.ts +1 -1
- package/dist/types/components/json-schema/index.d.ts +1 -0
- package/dist/types/components/json-schema/json-schema-form.d.ts +22 -3
- package/dist/types/components/json-schema/schema-defaults.d.ts +39 -0
- package/dist/types/components/json-structure/controls/any-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/array-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/binary-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/boolean-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/choice-control.d.ts +19 -0
- package/dist/types/components/json-structure/controls/decimal-control.d.ts +17 -0
- package/dist/types/components/json-structure/controls/deprecation-utils.d.ts +14 -0
- package/dist/types/components/json-structure/controls/enum-const-controls.d.ts +22 -0
- package/dist/types/components/json-structure/controls/generic-control.d.ts +31 -0
- package/dist/types/components/json-structure/controls/index.d.ts +21 -0
- package/dist/types/components/json-structure/controls/integer-control.d.ts +18 -0
- package/dist/types/components/json-structure/controls/map-control.d.ts +17 -0
- package/dist/types/components/json-structure/controls/object-control.d.ts +17 -0
- package/dist/types/components/json-structure/controls/set-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/string-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/temporal-control.d.ts +18 -0
- package/dist/types/components/json-structure/controls/tuple-control.d.ts +19 -0
- package/dist/types/components/json-structure/controls/union-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/uri-control.d.ts +15 -0
- package/dist/types/components/json-structure/controls/uuid-control.d.ts +15 -0
- package/dist/types/components/json-structure/extends-utils.d.ts +36 -0
- package/dist/types/components/json-structure/index.d.ts +25 -0
- package/dist/types/components/json-structure/json-structure-form.d.ts +96 -0
- package/dist/types/components/json-structure/ref-utils.d.ts +55 -0
- package/dist/types/components/json-structure/structure-context.d.ts +176 -0
- package/dist/types/components/json-structure/structure-defaults.d.ts +46 -0
- package/dist/types/components/json-structure/structure-types.d.ts +173 -0
- package/dist/types/components/json-structure/validation/error-transform.d.ts +56 -0
- package/dist/types/components/json-structure/validation/index.d.ts +5 -0
- package/dist/types/components/json-structure/validation/sdk-validator.d.ts +46 -0
- package/dist/types/components/json-structure/widgets/default-widgets.d.ts +27 -0
- package/dist/types/components/json-structure/widgets/index.d.ts +6 -0
- package/dist/types/components/json-structure/widgets/widget-registry.d.ts +143 -0
- package/dist/types/components/json-structure/widgets/widget-utils.d.ts +79 -0
- package/dist/types/json-structure/index.d.ts +9 -0
- package/dist/{ur-C6Ky6OCl.js → ur-55zdT2TQ.js} +1 -1
- package/dist/{notice-Um1LwKBF.js → use-form-B7A865EM.js} +329 -532
- package/dist/use-form-DVJXMMoN.cjs +2 -0
- package/dist/{vi-Bx2gx2S0.js → vi-C7K7W0hM.js} +1 -1
- package/dist/widget-customization-29Hl2gKT.js +1171 -0
- package/dist/widget-customization-BXiewbt-.cjs +1 -0
- package/dist/{zh-eixtg-Ce.js → zh-DvJBV9D8.js} +1 -1
- package/package.json +10 -2
- package/dist/modal-D_paG9Sr.cjs +0 -1
- package/dist/notice-CgT9ma2m.cjs +0 -2
- package/dist/widget-customization-BcbRhAAR.cjs +0 -1
- package/dist/widget-customization-D6Y_Qm7o.js +0 -2788
|
@@ -0,0 +1,3157 @@
|
|
|
1
|
+
import { _ as J, g as Ke, t as Z, N as Je, b as pe, c as de, U as Ze, e as He, a as Xe, T as Ye, L as fe, f as me, h as Qe, G as et, i as tt, S as nt, j as rt } from "../deep-merge-CQQCMLwG.js";
|
|
2
|
+
import { html as p, attr as m, Fragment as H, MapSignal as U, Value as I, computedOf as w, prop as it, WithElement as st, OnDispose as at } from "@tempots/dom";
|
|
3
|
+
import { c as b, b as ne, I as B, S as V, L as ye, e as ut, M as ot, g as re, A as G, h as ct, a as ie } from "../use-form-B7A865EM.js";
|
|
4
|
+
import { T as lt, B as E } from "../translations-DQxouiBG.js";
|
|
5
|
+
import { N as pt, B as dt, D as ft, a as mt, P as yt, b as gt, c as ht, d as bt, e as vt, F as xt } from "../duration-input-DKxZ6OCa.js";
|
|
6
|
+
import { f as $t } from "../colors-pQZlNrwM.js";
|
|
7
|
+
function It(e) {
|
|
8
|
+
return e === "int64" || e === "int128" || e === "uint64" || e === "uint128";
|
|
9
|
+
}
|
|
10
|
+
function P(e) {
|
|
11
|
+
return e === "int8" || e === "int16" || e === "int32" || e === "int64" || e === "int128" || e === "uint8" || e === "uint16" || e === "uint32" || e === "uint64" || e === "uint128";
|
|
12
|
+
}
|
|
13
|
+
function X(e) {
|
|
14
|
+
return e === "float" || e === "double" || e === "decimal";
|
|
15
|
+
}
|
|
16
|
+
function wt(e) {
|
|
17
|
+
return P(e) || X(e);
|
|
18
|
+
}
|
|
19
|
+
function Y(e) {
|
|
20
|
+
return e === "date" || e === "datetime" || e === "time" || e === "duration";
|
|
21
|
+
}
|
|
22
|
+
function Tt(e) {
|
|
23
|
+
return e === "string" || e === "boolean" || e === "null" || wt(e) || Y(e) || e === "uuid" || e === "uri" || e === "binary";
|
|
24
|
+
}
|
|
25
|
+
function ur(e) {
|
|
26
|
+
return e === "object" || e === "array" || e === "set" || e === "map" || e === "tuple" || e === "choice" || e === "any";
|
|
27
|
+
}
|
|
28
|
+
function C(e) {
|
|
29
|
+
return typeof e == "object" && e !== null && "$ref" in e;
|
|
30
|
+
}
|
|
31
|
+
function jt(e) {
|
|
32
|
+
return typeof e == "object" && e !== null && !("type" in e) && !("$ref" in e) && !("enum" in e) && !("const" in e);
|
|
33
|
+
}
|
|
34
|
+
function At(e) {
|
|
35
|
+
return typeof e == "object" && e !== null && ("type" in e || "$ref" in e || "enum" in e || "const" in e);
|
|
36
|
+
}
|
|
37
|
+
function k(e) {
|
|
38
|
+
return e.type === "object" && "properties" in e;
|
|
39
|
+
}
|
|
40
|
+
function ge(e) {
|
|
41
|
+
return e.type === "array" && "items" in e;
|
|
42
|
+
}
|
|
43
|
+
function he(e) {
|
|
44
|
+
return e.type === "set" && "items" in e;
|
|
45
|
+
}
|
|
46
|
+
function be(e) {
|
|
47
|
+
return e.type === "map" && "values" in e;
|
|
48
|
+
}
|
|
49
|
+
function ve(e) {
|
|
50
|
+
return e.type === "tuple" && "tuple" in e;
|
|
51
|
+
}
|
|
52
|
+
function xe(e) {
|
|
53
|
+
return e.type === "choice" && "choices" in e;
|
|
54
|
+
}
|
|
55
|
+
function Mt(e) {
|
|
56
|
+
return "enum" in e && Array.isArray(e.enum);
|
|
57
|
+
}
|
|
58
|
+
function Dt(e) {
|
|
59
|
+
return "const" in e;
|
|
60
|
+
}
|
|
61
|
+
function se(e) {
|
|
62
|
+
return e === void 0 ? null : typeof e == "string" || Array.isArray(e) ? e : (C(e), null);
|
|
63
|
+
}
|
|
64
|
+
function St(e) {
|
|
65
|
+
return e === void 0 ? !1 : e === "null" ? !0 : Array.isArray(e) ? e.includes("null") : !1;
|
|
66
|
+
}
|
|
67
|
+
function Q(e) {
|
|
68
|
+
return typeof e == "string" ? e === "null" ? [] : [e] : Array.isArray(e) ? e.filter((t) => t !== "null") : [];
|
|
69
|
+
}
|
|
70
|
+
const W = {
|
|
71
|
+
int8: { min: -128n, max: 127n },
|
|
72
|
+
int16: { min: -32768n, max: 32767n },
|
|
73
|
+
int32: { min: -2147483648n, max: 2147483647n },
|
|
74
|
+
int64: { min: -9223372036854775808n, max: 9223372036854775807n },
|
|
75
|
+
int128: {
|
|
76
|
+
min: -170141183460469231731687303715884105728n,
|
|
77
|
+
max: 170141183460469231731687303715884105727n
|
|
78
|
+
},
|
|
79
|
+
uint8: { min: 0n, max: 255n },
|
|
80
|
+
uint16: { min: 0n, max: 65535n },
|
|
81
|
+
uint32: { min: 0n, max: 4294967295n },
|
|
82
|
+
uint64: { min: 0n, max: 18446744073709551615n },
|
|
83
|
+
uint128: { min: 0n, max: 340282366920938463463374607431768211455n }
|
|
84
|
+
};
|
|
85
|
+
function Ot(e) {
|
|
86
|
+
return e.startsWith("#/") ? e.slice(2).split("/") : e.includes("/") ? e.split("/") : ["definitions", e];
|
|
87
|
+
}
|
|
88
|
+
function Ct(e, t) {
|
|
89
|
+
let n = e;
|
|
90
|
+
for (const r of t) {
|
|
91
|
+
if (n == null || typeof n != "object")
|
|
92
|
+
return;
|
|
93
|
+
n = n[r];
|
|
94
|
+
}
|
|
95
|
+
return n;
|
|
96
|
+
}
|
|
97
|
+
function N(e, t) {
|
|
98
|
+
const n = Ot(e), r = Ct(t, n);
|
|
99
|
+
if (r == null) {
|
|
100
|
+
console.warn(`Failed to resolve $ref: ${e}`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (At(r))
|
|
104
|
+
return r;
|
|
105
|
+
if (jt(r)) {
|
|
106
|
+
console.warn(`$ref "${e}" points to a namespace, not a type definition`);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function or(e, t) {
|
|
111
|
+
return N(e.$ref, t);
|
|
112
|
+
}
|
|
113
|
+
class Rt {
|
|
114
|
+
schema;
|
|
115
|
+
visited = /* @__PURE__ */ new Set();
|
|
116
|
+
constructor(t) {
|
|
117
|
+
this.schema = t;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Resolve a reference, tracking visited refs to prevent infinite loops
|
|
121
|
+
*/
|
|
122
|
+
resolve(t) {
|
|
123
|
+
if (this.visited.has(t)) {
|
|
124
|
+
console.warn(`Circular reference detected: ${t}`);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
this.visited.add(t);
|
|
128
|
+
try {
|
|
129
|
+
const n = N(t, this.schema);
|
|
130
|
+
if (n?.type && C(n.type)) {
|
|
131
|
+
const r = this.resolve(n.type.$ref);
|
|
132
|
+
if (r) {
|
|
133
|
+
const { type: s, ...a } = n;
|
|
134
|
+
return { ...r, ...a };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return n;
|
|
138
|
+
} finally {
|
|
139
|
+
this.visited.delete(t);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Resolve a type definition, handling any $ref in its type specifier
|
|
144
|
+
*/
|
|
145
|
+
resolveDefinition(t) {
|
|
146
|
+
if (t.type && C(t.type)) {
|
|
147
|
+
const n = this.resolve(t.type.$ref);
|
|
148
|
+
if (n) {
|
|
149
|
+
const { type: r, ...s } = t;
|
|
150
|
+
return { ...n, ...s };
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return t;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Reset the visited tracking (use between independent resolution calls)
|
|
157
|
+
*/
|
|
158
|
+
reset() {
|
|
159
|
+
this.visited.clear();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function ee(e) {
|
|
163
|
+
return new Rt(e);
|
|
164
|
+
}
|
|
165
|
+
class te {
|
|
166
|
+
schema;
|
|
167
|
+
definition;
|
|
168
|
+
path;
|
|
169
|
+
readOnly;
|
|
170
|
+
locale;
|
|
171
|
+
widgetRegistry;
|
|
172
|
+
isPropertyRequired;
|
|
173
|
+
suppressLabel;
|
|
174
|
+
refResolver;
|
|
175
|
+
constructor(t) {
|
|
176
|
+
this.schema = t.schema, this.definition = t.definition, this.path = t.path, this.readOnly = t.readOnly ?? !1, this.locale = t.locale, this.widgetRegistry = t.widgetRegistry, this.isPropertyRequired = t.isPropertyRequired ?? !1, this.suppressLabel = t.suppressLabel ?? !1, this.refResolver = t.refResolver ?? ee(t.schema);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Create a new context with updated fields
|
|
180
|
+
*/
|
|
181
|
+
with(t) {
|
|
182
|
+
return new te({
|
|
183
|
+
schema: this.schema,
|
|
184
|
+
definition: t.definition ?? this.definition,
|
|
185
|
+
path: t.path ?? this.path,
|
|
186
|
+
readOnly: t.readOnly ?? this.readOnly,
|
|
187
|
+
locale: t.locale ?? this.locale,
|
|
188
|
+
widgetRegistry: t.widgetRegistry ?? this.widgetRegistry,
|
|
189
|
+
isPropertyRequired: t.isPropertyRequired ?? this.isPropertyRequired,
|
|
190
|
+
suppressLabel: t.suppressLabel ?? this.suppressLabel,
|
|
191
|
+
refResolver: this.refResolver
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Create a child context by appending to the path
|
|
196
|
+
*/
|
|
197
|
+
append(t) {
|
|
198
|
+
return this.with({ path: [...this.path, t] });
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Check if this is the root context
|
|
202
|
+
*/
|
|
203
|
+
get isRoot() {
|
|
204
|
+
return this.path.length === 0;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get the property name (last segment of path)
|
|
208
|
+
*/
|
|
209
|
+
get name() {
|
|
210
|
+
const t = this.path[this.path.length - 1];
|
|
211
|
+
return typeof t == "string" ? t : void 0;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Get the widget name (dot-separated path)
|
|
215
|
+
*/
|
|
216
|
+
get widgetName() {
|
|
217
|
+
return this.path.map(String).join(".");
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Get the resolved type(s) from the definition
|
|
221
|
+
*/
|
|
222
|
+
get resolvedType() {
|
|
223
|
+
const t = this.definition.type;
|
|
224
|
+
if (!t) return null;
|
|
225
|
+
if (C(t)) {
|
|
226
|
+
const n = this.refResolver.resolve(t.$ref);
|
|
227
|
+
return n?.type ? se(n.type) : null;
|
|
228
|
+
}
|
|
229
|
+
return se(t);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Get the primary type (first non-null type)
|
|
233
|
+
*/
|
|
234
|
+
get primaryType() {
|
|
235
|
+
const t = this.resolvedType;
|
|
236
|
+
return t ? typeof t == "string" ? t === "null" ? null : t : Q(t)[0] ?? null : null;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Check if this type is nullable
|
|
240
|
+
*/
|
|
241
|
+
get isNullable() {
|
|
242
|
+
return St(this.definition.type);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Check if this is a required field
|
|
246
|
+
*/
|
|
247
|
+
get isRequired() {
|
|
248
|
+
return this.isPropertyRequired;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Check if this is an optional field (can be absent)
|
|
252
|
+
*/
|
|
253
|
+
get isOptional() {
|
|
254
|
+
return !this.isPropertyRequired;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Check if this field is deprecated
|
|
258
|
+
*/
|
|
259
|
+
get isDeprecated() {
|
|
260
|
+
return this.definition.deprecated === !0;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Check if this type is abstract
|
|
264
|
+
*/
|
|
265
|
+
get isAbstract() {
|
|
266
|
+
return this.definition.abstract === !0;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Check if this is a primitive type
|
|
270
|
+
*/
|
|
271
|
+
get isPrimitive() {
|
|
272
|
+
const t = this.primaryType;
|
|
273
|
+
return t != null && Tt(t);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Get the description from the definition
|
|
277
|
+
*/
|
|
278
|
+
get description() {
|
|
279
|
+
return this.definition.description;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Get examples from the definition
|
|
283
|
+
*/
|
|
284
|
+
get examples() {
|
|
285
|
+
return this.definition.examples;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Get the default value from the definition
|
|
289
|
+
*/
|
|
290
|
+
get defaultValue() {
|
|
291
|
+
return this.definition.default;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Get the unit for numeric values
|
|
295
|
+
*/
|
|
296
|
+
get unit() {
|
|
297
|
+
return this.definition.unit;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Get the currency for monetary values
|
|
301
|
+
*/
|
|
302
|
+
get currency() {
|
|
303
|
+
return this.definition.currency;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Get the label for this field
|
|
307
|
+
*
|
|
308
|
+
* Resolution order:
|
|
309
|
+
* 1. Locale-specific altname (if locale is set)
|
|
310
|
+
* 2. Definition name
|
|
311
|
+
* 3. Humanized path name
|
|
312
|
+
*/
|
|
313
|
+
get label() {
|
|
314
|
+
if (this.locale && this.definition.altnames) {
|
|
315
|
+
const n = `lang:${this.locale}`, r = this.definition.altnames[n];
|
|
316
|
+
if (r) return r;
|
|
317
|
+
}
|
|
318
|
+
if (this.definition.name)
|
|
319
|
+
return this.definition.name;
|
|
320
|
+
const t = this.name;
|
|
321
|
+
return t ? J(Ke(t)) : "";
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Get altnames from the definition
|
|
325
|
+
*/
|
|
326
|
+
get altnames() {
|
|
327
|
+
return this.definition.altnames;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Get the JSON path string (for validation error matching)
|
|
331
|
+
*/
|
|
332
|
+
get jsonPath() {
|
|
333
|
+
return this.path.length === 0 ? "" : "/" + this.path.map(String).join("/");
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Resolve a $ref using the shared resolver
|
|
337
|
+
*/
|
|
338
|
+
resolveRef(t) {
|
|
339
|
+
return this.refResolver.resolve(t);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Check if this definition has an enum constraint
|
|
343
|
+
*/
|
|
344
|
+
get hasEnum() {
|
|
345
|
+
return "enum" in this.definition && Array.isArray(this.definition.enum);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Get enum values if present
|
|
349
|
+
*/
|
|
350
|
+
get enumValues() {
|
|
351
|
+
if ("enum" in this.definition)
|
|
352
|
+
return this.definition.enum;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Check if this definition has a const constraint
|
|
356
|
+
*/
|
|
357
|
+
get hasConst() {
|
|
358
|
+
return "const" in this.definition;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Get const value if present
|
|
362
|
+
*/
|
|
363
|
+
get constValue() {
|
|
364
|
+
if ("const" in this.definition)
|
|
365
|
+
return this.definition.const;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Get string format if defined (for string types)
|
|
369
|
+
*/
|
|
370
|
+
get format() {
|
|
371
|
+
if ("format" in this.definition)
|
|
372
|
+
return this.definition.format;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function kt(e, t) {
|
|
376
|
+
let n;
|
|
377
|
+
const r = ee(e);
|
|
378
|
+
if (e.$root) {
|
|
379
|
+
const s = r.resolve(e.$root);
|
|
380
|
+
s ? n = s : (console.warn(`Failed to resolve $root: ${e.$root}`), n = e);
|
|
381
|
+
} else e.type || e.properties ? n = e : n = { type: "any" };
|
|
382
|
+
return new te({
|
|
383
|
+
schema: e,
|
|
384
|
+
definition: n,
|
|
385
|
+
path: [],
|
|
386
|
+
readOnly: t?.readOnly,
|
|
387
|
+
locale: t?.locale,
|
|
388
|
+
widgetRegistry: t?.widgetRegistry,
|
|
389
|
+
refResolver: r
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
function $e(e, t, n) {
|
|
393
|
+
const r = [], s = [];
|
|
394
|
+
if (!e.$extends)
|
|
395
|
+
return { merged: e, inheritanceChain: r, errors: s };
|
|
396
|
+
const a = Array.isArray(e.$extends) ? e.$extends : [e.$extends], u = /* @__PURE__ */ new Set(), i = (l, y = 0) => {
|
|
397
|
+
if (y > 100)
|
|
398
|
+
return s.push({
|
|
399
|
+
path: l.join(" -> "),
|
|
400
|
+
message: "Maximum inheritance depth exceeded"
|
|
401
|
+
}), [];
|
|
402
|
+
const h = [];
|
|
403
|
+
for (const f of l) {
|
|
404
|
+
if (u.has(f)) {
|
|
405
|
+
s.push({
|
|
406
|
+
path: f,
|
|
407
|
+
message: `Circular inheritance detected: ${f}`
|
|
408
|
+
});
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
u.add(f), r.push(f);
|
|
412
|
+
const g = N(f, t);
|
|
413
|
+
if (!g) {
|
|
414
|
+
s.push({
|
|
415
|
+
path: f,
|
|
416
|
+
message: `Failed to resolve base type: ${f}`
|
|
417
|
+
});
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
if (g.$extends) {
|
|
421
|
+
const d = Array.isArray(g.$extends) ? g.$extends : [g.$extends], v = i(d, y + 1);
|
|
422
|
+
h.push(...v);
|
|
423
|
+
}
|
|
424
|
+
h.push(g), u.delete(f);
|
|
425
|
+
}
|
|
426
|
+
return h;
|
|
427
|
+
}, o = i(a);
|
|
428
|
+
return { merged: Nt(o, e), inheritanceChain: r, errors: s };
|
|
429
|
+
}
|
|
430
|
+
function Nt(e, t) {
|
|
431
|
+
if (e.length === 0)
|
|
432
|
+
return t;
|
|
433
|
+
let n = { ...e[0] };
|
|
434
|
+
for (let a = 1; a < e.length; a++)
|
|
435
|
+
n = ae(n, e[a]);
|
|
436
|
+
n = ae(n, t);
|
|
437
|
+
const { $extends: r, ...s } = n;
|
|
438
|
+
return s;
|
|
439
|
+
}
|
|
440
|
+
function ae(e, t) {
|
|
441
|
+
return k(e) && k(t) ? qt(e, t) : { ...e, ...t };
|
|
442
|
+
}
|
|
443
|
+
function qt(e, t) {
|
|
444
|
+
const n = {
|
|
445
|
+
...e.properties ?? {},
|
|
446
|
+
...t.properties ?? {}
|
|
447
|
+
}, r = ue(e.required), s = ue(t.required), a = Pt([...r, ...s]), u = {
|
|
448
|
+
...e,
|
|
449
|
+
...t,
|
|
450
|
+
type: "object",
|
|
451
|
+
properties: n
|
|
452
|
+
};
|
|
453
|
+
return a.length > 0 && (u.required = a), u;
|
|
454
|
+
}
|
|
455
|
+
function ue(e) {
|
|
456
|
+
return e ? e.length === 0 ? [] : Array.isArray(e[0]) ? e.flat() : e : [];
|
|
457
|
+
}
|
|
458
|
+
function Pt(e) {
|
|
459
|
+
return [...new Set(e)];
|
|
460
|
+
}
|
|
461
|
+
function cr(e) {
|
|
462
|
+
const t = ee(e);
|
|
463
|
+
return {
|
|
464
|
+
resolve: (n) => (t.reset(), $e(n, e))
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
function Ft() {
|
|
468
|
+
return p.span(
|
|
469
|
+
m.class("bc-json-structure-deprecated-badge"),
|
|
470
|
+
m.style(
|
|
471
|
+
"font-size: var(--font-size-xs); color: var(--color-warning-500, #d97706); background: var(--color-warning-100, #fef3c7); padding: 0.125em 0.5em; border-radius: var(--radius-sm); margin-inline-start: 0.5em; font-weight: normal;"
|
|
472
|
+
),
|
|
473
|
+
"(deprecated)"
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
function T(e, t) {
|
|
477
|
+
return !e || !t ? e ?? "" : p.span(e, Ft());
|
|
478
|
+
}
|
|
479
|
+
function Lt(e) {
|
|
480
|
+
const t = e.examples?.[0] != null ? String(e.examples[0]) : void 0;
|
|
481
|
+
return {
|
|
482
|
+
label: e.suppressLabel ? void 0 : T(e.label, e.isDeprecated),
|
|
483
|
+
description: e.description,
|
|
484
|
+
required: e.isRequired,
|
|
485
|
+
disabled: e.readOnly || e.isDeprecated,
|
|
486
|
+
placeholder: t
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
function Ie({
|
|
490
|
+
ctx: e,
|
|
491
|
+
controller: t
|
|
492
|
+
}) {
|
|
493
|
+
const n = Lt(e);
|
|
494
|
+
return b(lt, {
|
|
495
|
+
...n,
|
|
496
|
+
controller: Z(t)
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
function Vt(e) {
|
|
500
|
+
return {
|
|
501
|
+
label: e.suppressLabel ? void 0 : T(e.label, e.isDeprecated),
|
|
502
|
+
description: e.description,
|
|
503
|
+
required: e.isRequired,
|
|
504
|
+
disabled: e.readOnly || e.isDeprecated
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
function we({
|
|
508
|
+
ctx: e,
|
|
509
|
+
controller: t
|
|
510
|
+
}) {
|
|
511
|
+
const n = Vt(e), r = b(ne, {
|
|
512
|
+
...n,
|
|
513
|
+
controller: t
|
|
514
|
+
});
|
|
515
|
+
return e.isNullable ? b(ne, {
|
|
516
|
+
...n,
|
|
517
|
+
controller: t,
|
|
518
|
+
after: Je(
|
|
519
|
+
t.signal,
|
|
520
|
+
t.disabled,
|
|
521
|
+
(s) => t.change(s)
|
|
522
|
+
)
|
|
523
|
+
}) : r;
|
|
524
|
+
}
|
|
525
|
+
function Et(e, t) {
|
|
526
|
+
const n = W[t], r = Te(e, n.min), s = je(e, n.max), a = e.examples?.[0] != null ? String(e.examples[0]) : void 0;
|
|
527
|
+
return {
|
|
528
|
+
label: e.suppressLabel ? void 0 : T(e.label, e.isDeprecated),
|
|
529
|
+
description: e.description,
|
|
530
|
+
required: e.isRequired,
|
|
531
|
+
disabled: e.readOnly || e.isDeprecated,
|
|
532
|
+
// Convert to numbers for NumberInput
|
|
533
|
+
min: typeof r == "bigint" ? Number(r) : r,
|
|
534
|
+
max: typeof s == "bigint" ? Number(s) : s,
|
|
535
|
+
step: 1,
|
|
536
|
+
placeholder: a
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
function Ut(e, t) {
|
|
540
|
+
const n = W[t], r = Te(e, n.min), s = je(e, n.max), a = e.examples?.[0] != null ? String(e.examples[0]) : void 0;
|
|
541
|
+
return {
|
|
542
|
+
label: e.suppressLabel ? void 0 : T(e.label, e.isDeprecated),
|
|
543
|
+
description: e.description,
|
|
544
|
+
required: e.isRequired,
|
|
545
|
+
disabled: e.readOnly || e.isDeprecated,
|
|
546
|
+
// Ensure bigint for BigintInput
|
|
547
|
+
min: typeof r == "number" ? BigInt(r) : r,
|
|
548
|
+
max: typeof s == "number" ? BigInt(s) : s,
|
|
549
|
+
placeholder: a
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
function Te(e, t) {
|
|
553
|
+
const n = e.definition;
|
|
554
|
+
if (n.minimum !== void 0) {
|
|
555
|
+
const r = typeof n.minimum == "string" ? BigInt(n.minimum) : n.minimum;
|
|
556
|
+
return typeof r == "bigint" ? r > t ? r : t : BigInt(r) > t ? r : Number(t);
|
|
557
|
+
}
|
|
558
|
+
if (n.exclusiveMinimum !== void 0) {
|
|
559
|
+
const r = typeof n.exclusiveMinimum == "string" ? BigInt(n.exclusiveMinimum) : n.exclusiveMinimum, s = typeof r == "bigint" ? r + 1n : r + 1;
|
|
560
|
+
return typeof s == "bigint" ? s > t ? s : t : BigInt(s) > t ? s : Number(t);
|
|
561
|
+
}
|
|
562
|
+
return t >= BigInt(Number.MIN_SAFE_INTEGER) && t <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(t) : t;
|
|
563
|
+
}
|
|
564
|
+
function je(e, t) {
|
|
565
|
+
const n = e.definition;
|
|
566
|
+
if (n.maximum !== void 0) {
|
|
567
|
+
const r = typeof n.maximum == "string" ? BigInt(n.maximum) : n.maximum;
|
|
568
|
+
return typeof r == "bigint" ? r < t ? r : t : BigInt(r) < t ? r : Number(t);
|
|
569
|
+
}
|
|
570
|
+
if (n.exclusiveMaximum !== void 0) {
|
|
571
|
+
const r = typeof n.exclusiveMaximum == "string" ? BigInt(n.exclusiveMaximum) : n.exclusiveMaximum, s = typeof r == "bigint" ? r - 1n : r - 1;
|
|
572
|
+
return typeof s == "bigint" ? s < t ? s : t : BigInt(s) < t ? s : Number(t);
|
|
573
|
+
}
|
|
574
|
+
return t >= BigInt(Number.MIN_SAFE_INTEGER) && t <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(t) : t;
|
|
575
|
+
}
|
|
576
|
+
function Ae({
|
|
577
|
+
ctx: e,
|
|
578
|
+
controller: t,
|
|
579
|
+
intType: n
|
|
580
|
+
}) {
|
|
581
|
+
if (It(n)) {
|
|
582
|
+
const s = Ut(e, n);
|
|
583
|
+
return e.isNullable ? b(pt, {
|
|
584
|
+
...s,
|
|
585
|
+
controller: t
|
|
586
|
+
}) : b(dt, {
|
|
587
|
+
...s,
|
|
588
|
+
controller: t
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
const r = Et(e, n);
|
|
592
|
+
return e.isNullable ? b(pe, {
|
|
593
|
+
...r,
|
|
594
|
+
controller: t
|
|
595
|
+
}) : b(de, {
|
|
596
|
+
...r,
|
|
597
|
+
controller: t
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
function Bt(e, t) {
|
|
601
|
+
const n = e.definition;
|
|
602
|
+
let r;
|
|
603
|
+
n.multipleOf !== void 0 ? r = n.multipleOf : t === "decimal" && n.scale !== void 0 ? r = Math.pow(10, -n.scale) : r = void 0;
|
|
604
|
+
const s = n.minimum !== void 0 ? typeof n.minimum == "string" ? parseFloat(n.minimum) : n.minimum : void 0, a = n.maximum !== void 0 ? typeof n.maximum == "string" ? parseFloat(n.maximum) : n.maximum : void 0, u = n.exclusiveMinimum !== void 0 ? typeof n.exclusiveMinimum == "string" ? parseFloat(n.exclusiveMinimum) : n.exclusiveMinimum : void 0, i = n.exclusiveMaximum !== void 0 ? typeof n.exclusiveMaximum == "string" ? parseFloat(n.exclusiveMaximum) : n.exclusiveMaximum : void 0;
|
|
605
|
+
let o = e.description;
|
|
606
|
+
if (u !== void 0 || i !== void 0) {
|
|
607
|
+
const l = [];
|
|
608
|
+
u !== void 0 && l.push(`> ${u}`), i !== void 0 && l.push(`< ${i}`);
|
|
609
|
+
const y = `Valid range: ${l.join(" and ")}`;
|
|
610
|
+
o = o ? `${o} (${y})` : y;
|
|
611
|
+
}
|
|
612
|
+
const c = e.examples?.[0] != null ? String(e.examples[0]) : void 0;
|
|
613
|
+
return {
|
|
614
|
+
label: e.suppressLabel ? void 0 : T(e.label, e.isDeprecated),
|
|
615
|
+
description: o,
|
|
616
|
+
required: e.isRequired,
|
|
617
|
+
disabled: e.readOnly || e.isDeprecated,
|
|
618
|
+
min: s ?? u,
|
|
619
|
+
max: a ?? i,
|
|
620
|
+
step: r,
|
|
621
|
+
placeholder: c
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
function Me({
|
|
625
|
+
ctx: e,
|
|
626
|
+
controller: t,
|
|
627
|
+
floatType: n
|
|
628
|
+
}) {
|
|
629
|
+
const r = Bt(e, n);
|
|
630
|
+
return e.isNullable ? b(pe, {
|
|
631
|
+
...r,
|
|
632
|
+
controller: t
|
|
633
|
+
}) : b(de, {
|
|
634
|
+
...r,
|
|
635
|
+
controller: t
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
function Wt(e) {
|
|
639
|
+
return {
|
|
640
|
+
label: e.suppressLabel ? void 0 : T(e.label, e.isDeprecated),
|
|
641
|
+
description: e.description,
|
|
642
|
+
required: e.isRequired,
|
|
643
|
+
disabled: e.readOnly || e.isDeprecated,
|
|
644
|
+
placeholder: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
function De({
|
|
648
|
+
ctx: e,
|
|
649
|
+
controller: t
|
|
650
|
+
}) {
|
|
651
|
+
const n = Wt(e);
|
|
652
|
+
return b(Ze, {
|
|
653
|
+
...n,
|
|
654
|
+
controller: Z(t)
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
function _t(e) {
|
|
658
|
+
return {
|
|
659
|
+
label: e.suppressLabel ? void 0 : T(e.label, e.isDeprecated),
|
|
660
|
+
description: e.description,
|
|
661
|
+
required: e.isRequired,
|
|
662
|
+
disabled: e.readOnly || e.isDeprecated
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
function Se({
|
|
666
|
+
ctx: e,
|
|
667
|
+
controller: t,
|
|
668
|
+
temporalType: n
|
|
669
|
+
}) {
|
|
670
|
+
const r = _t(e);
|
|
671
|
+
switch (n) {
|
|
672
|
+
case "date":
|
|
673
|
+
return e.isNullable ? b(bt, {
|
|
674
|
+
...r,
|
|
675
|
+
controller: t
|
|
676
|
+
}) : b(vt, {
|
|
677
|
+
...r,
|
|
678
|
+
controller: t
|
|
679
|
+
});
|
|
680
|
+
case "datetime":
|
|
681
|
+
return e.isNullable ? b(gt, {
|
|
682
|
+
...r,
|
|
683
|
+
controller: t
|
|
684
|
+
}) : b(ht, {
|
|
685
|
+
...r,
|
|
686
|
+
controller: t
|
|
687
|
+
});
|
|
688
|
+
case "time":
|
|
689
|
+
return e.isNullable ? b(mt, {
|
|
690
|
+
...r,
|
|
691
|
+
controller: t
|
|
692
|
+
}) : b(yt, {
|
|
693
|
+
...r,
|
|
694
|
+
controller: t
|
|
695
|
+
});
|
|
696
|
+
case "duration":
|
|
697
|
+
return e.isNullable ? b(He, {
|
|
698
|
+
...r,
|
|
699
|
+
controller: t
|
|
700
|
+
}) : b(ft, {
|
|
701
|
+
...r,
|
|
702
|
+
controller: t
|
|
703
|
+
});
|
|
704
|
+
default:
|
|
705
|
+
return console.warn(`Unknown temporal type: ${n}`), H();
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
function zt(e) {
|
|
709
|
+
return {
|
|
710
|
+
label: e.suppressLabel ? void 0 : T(e.label, e.isDeprecated),
|
|
711
|
+
description: e.description,
|
|
712
|
+
required: e.isRequired,
|
|
713
|
+
disabled: e.readOnly || e.isDeprecated,
|
|
714
|
+
placeholder: "https://example.com"
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
function Oe({
|
|
718
|
+
ctx: e,
|
|
719
|
+
controller: t
|
|
720
|
+
}) {
|
|
721
|
+
const n = zt(e);
|
|
722
|
+
return b(Xe, {
|
|
723
|
+
...n,
|
|
724
|
+
controller: Z(t)
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
function Gt(e) {
|
|
728
|
+
return {
|
|
729
|
+
label: e.suppressLabel ? void 0 : T(e.label, e.isDeprecated),
|
|
730
|
+
description: e.description,
|
|
731
|
+
required: e.isRequired,
|
|
732
|
+
disabled: e.readOnly || e.isDeprecated
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
function Ce({
|
|
736
|
+
ctx: e,
|
|
737
|
+
controller: t
|
|
738
|
+
}) {
|
|
739
|
+
const n = Gt(e);
|
|
740
|
+
return b(xt, {
|
|
741
|
+
...n,
|
|
742
|
+
controller: t
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
function Kt(e) {
|
|
746
|
+
return {
|
|
747
|
+
label: e.suppressLabel ? void 0 : T(e.label, e.isDeprecated),
|
|
748
|
+
description: e.description,
|
|
749
|
+
required: e.isRequired,
|
|
750
|
+
disabled: e.readOnly || e.isDeprecated,
|
|
751
|
+
placeholder: "Enter JSON value"
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
function Jt(e) {
|
|
755
|
+
return e.transform(
|
|
756
|
+
// To input: serialize value to JSON string
|
|
757
|
+
(t) => t === void 0 ? void 0 : JSON.stringify(t, null, 2),
|
|
758
|
+
// From input: parse JSON string back to value
|
|
759
|
+
(t) => {
|
|
760
|
+
if (!(t === void 0 || t.trim() === ""))
|
|
761
|
+
try {
|
|
762
|
+
return JSON.parse(t);
|
|
763
|
+
} catch {
|
|
764
|
+
return t;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
);
|
|
768
|
+
}
|
|
769
|
+
function K({
|
|
770
|
+
ctx: e,
|
|
771
|
+
controller: t
|
|
772
|
+
}) {
|
|
773
|
+
const n = Kt(e);
|
|
774
|
+
return b(Ye, {
|
|
775
|
+
...n,
|
|
776
|
+
controller: Jt(t)
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
function Zt(e) {
|
|
780
|
+
return {
|
|
781
|
+
label: e.suppressLabel ? void 0 : e.label,
|
|
782
|
+
description: e.description,
|
|
783
|
+
required: e.isRequired
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
function Ht(e, t) {
|
|
787
|
+
return !t || t.length === 0 ? !1 : typeof t[0] == "string" ? t.includes(e) : Array.isArray(t[0]) ? t.some((n) => n.includes(e)) : !1;
|
|
788
|
+
}
|
|
789
|
+
function Xt(e) {
|
|
790
|
+
if (e.default !== void 0)
|
|
791
|
+
return e.default;
|
|
792
|
+
if (e.examples && e.examples.length > 0)
|
|
793
|
+
return e.examples[0];
|
|
794
|
+
if (!e.type) return;
|
|
795
|
+
const t = Array.isArray(e.type) ? e.type[0] : e.type;
|
|
796
|
+
if (!(typeof t == "object" && "$ref" in t))
|
|
797
|
+
switch (t) {
|
|
798
|
+
case "string":
|
|
799
|
+
return "";
|
|
800
|
+
case "boolean":
|
|
801
|
+
return !1;
|
|
802
|
+
case "null":
|
|
803
|
+
return null;
|
|
804
|
+
case "object":
|
|
805
|
+
return {};
|
|
806
|
+
case "array":
|
|
807
|
+
case "set":
|
|
808
|
+
return [];
|
|
809
|
+
case "map":
|
|
810
|
+
return {};
|
|
811
|
+
case "any":
|
|
812
|
+
return;
|
|
813
|
+
default:
|
|
814
|
+
return t === "int8" || t === "int16" || t === "int32" || t === "int64" || t === "uint8" || t === "uint16" || t === "uint32" || t === "uint64" || t === "float" || t === "double" || t === "decimal" ? 0 : void 0;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
function Yt(e, t = "property") {
|
|
818
|
+
if (!e.has(t)) return t;
|
|
819
|
+
let n = 1;
|
|
820
|
+
for (; e.has(`${t}${n}`); )
|
|
821
|
+
n++;
|
|
822
|
+
return `${t}${n}`;
|
|
823
|
+
}
|
|
824
|
+
function Re({
|
|
825
|
+
ctx: e,
|
|
826
|
+
controller: t
|
|
827
|
+
}) {
|
|
828
|
+
const n = e.definition;
|
|
829
|
+
return n.type !== "object" || !("properties" in n) ? (console.warn("StructureObjectControl requires an ObjectTypeDefinition"), p.div("Invalid object definition")) : U(t.signal, (r) => {
|
|
830
|
+
const s = n.properties, a = n.required, u = n.additionalProperties, i = u !== !1, o = typeof u == "object" && u !== null ? u : { type: "any" }, c = n.minProperties ?? 0, l = n.maxProperties ?? 1 / 0, y = $t(s), h = new Set(
|
|
831
|
+
y.map(([x]) => x)
|
|
832
|
+
), f = Object.keys(r ?? {}), g = f.filter((x) => !h.has(x)), d = i && f.length < l && !e.readOnly, v = f.length > c && !e.readOnly, $ = y.map(([x, O]) => {
|
|
833
|
+
const D = x, z = t.field(D), Ge = Ht(D, a);
|
|
834
|
+
return j({
|
|
835
|
+
ctx: e.with({
|
|
836
|
+
definition: O,
|
|
837
|
+
isPropertyRequired: Ge,
|
|
838
|
+
suppressLabel: !1
|
|
839
|
+
}).append(D),
|
|
840
|
+
controller: z
|
|
841
|
+
});
|
|
842
|
+
}), A = g.map((x) => {
|
|
843
|
+
const O = t.field(x);
|
|
844
|
+
return p.div(
|
|
845
|
+
m.class("bc-json-structure-additional-property"),
|
|
846
|
+
p.div(
|
|
847
|
+
m.class("bc-json-structure-additional-property-header"),
|
|
848
|
+
p.strong(`${x}:`),
|
|
849
|
+
E(
|
|
850
|
+
{
|
|
851
|
+
variant: "text",
|
|
852
|
+
size: "xs",
|
|
853
|
+
onClick: () => {
|
|
854
|
+
const D = { ...I.get(t.signal) ?? {} };
|
|
855
|
+
delete D[x], t.change(D);
|
|
856
|
+
},
|
|
857
|
+
disabled: !v
|
|
858
|
+
},
|
|
859
|
+
"Remove"
|
|
860
|
+
)
|
|
861
|
+
),
|
|
862
|
+
p.div(
|
|
863
|
+
m.class("bc-json-structure-additional-property-value"),
|
|
864
|
+
j({
|
|
865
|
+
ctx: e.with({
|
|
866
|
+
definition: o,
|
|
867
|
+
isPropertyRequired: !1,
|
|
868
|
+
suppressLabel: !0
|
|
869
|
+
}).append(x),
|
|
870
|
+
controller: O
|
|
871
|
+
})
|
|
872
|
+
)
|
|
873
|
+
);
|
|
874
|
+
}), q = d ? E(
|
|
875
|
+
{
|
|
876
|
+
variant: "outline",
|
|
877
|
+
size: "sm",
|
|
878
|
+
onClick: () => {
|
|
879
|
+
const x = I.get(t.signal) ?? {}, O = new Set(Object.keys(x)), D = Yt(O), z = Xt(o);
|
|
880
|
+
t.change({
|
|
881
|
+
...x,
|
|
882
|
+
[D]: z
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
},
|
|
886
|
+
"Add Property"
|
|
887
|
+
) : null, S = p.div(
|
|
888
|
+
m.class("bc-json-structure-object-fields"),
|
|
889
|
+
...$,
|
|
890
|
+
...A,
|
|
891
|
+
q
|
|
892
|
+
), R = p.div(
|
|
893
|
+
m.class("bc-json-structure-object"),
|
|
894
|
+
S
|
|
895
|
+
);
|
|
896
|
+
return !e.suppressLabel && e.name ? B({
|
|
897
|
+
...Zt(e),
|
|
898
|
+
content: R
|
|
899
|
+
}) : R;
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
function Qt(e) {
|
|
903
|
+
return {
|
|
904
|
+
label: e.suppressLabel ? void 0 : e.label,
|
|
905
|
+
description: e.description,
|
|
906
|
+
required: e.isRequired
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
function en(e) {
|
|
910
|
+
if (e.default !== void 0)
|
|
911
|
+
return e.default;
|
|
912
|
+
if (e.examples && e.examples.length > 0)
|
|
913
|
+
return e.examples[0];
|
|
914
|
+
if (!e.type) return;
|
|
915
|
+
const t = Array.isArray(e.type) ? e.type[0] : e.type;
|
|
916
|
+
if (!(typeof t == "object" && "$ref" in t))
|
|
917
|
+
switch (t) {
|
|
918
|
+
case "string":
|
|
919
|
+
return "";
|
|
920
|
+
case "boolean":
|
|
921
|
+
return !1;
|
|
922
|
+
case "null":
|
|
923
|
+
return null;
|
|
924
|
+
case "object":
|
|
925
|
+
return {};
|
|
926
|
+
case "array":
|
|
927
|
+
case "set":
|
|
928
|
+
return [];
|
|
929
|
+
case "map":
|
|
930
|
+
return {};
|
|
931
|
+
case "any":
|
|
932
|
+
return;
|
|
933
|
+
default:
|
|
934
|
+
return t === "int8" || t === "int16" || t === "int32" || t === "int64" || t === "int128" || t === "uint8" || t === "uint16" || t === "uint32" || t === "uint64" || t === "uint128" || t === "float" || t === "double" || t === "decimal" ? 0 : void 0;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
function ke({
|
|
938
|
+
ctx: e,
|
|
939
|
+
controller: t
|
|
940
|
+
}) {
|
|
941
|
+
const n = e.definition;
|
|
942
|
+
if (n.type !== "array" || !("items" in n))
|
|
943
|
+
return console.warn("StructureArrayControl requires an ArrayTypeDefinition"), p.div("Invalid array definition");
|
|
944
|
+
const r = n.items, s = n.minItems ?? 0, a = n.maxItems ?? 1 / 0, u = w(t.signal)((o) => (o?.length ?? 0) < a), i = w(t.signal)((o) => (o?.length ?? 0) > s);
|
|
945
|
+
return fe({
|
|
946
|
+
...Qt(e),
|
|
947
|
+
controller: t,
|
|
948
|
+
createItem: () => en(r),
|
|
949
|
+
showAdd: !0,
|
|
950
|
+
addDisabled: w(u)((o) => !o || e.readOnly),
|
|
951
|
+
showRemove: !0,
|
|
952
|
+
removeDisabled: w(i)((o) => !o || e.readOnly),
|
|
953
|
+
element: (o) => {
|
|
954
|
+
const c = o.position.index, l = o.item;
|
|
955
|
+
return j({
|
|
956
|
+
ctx: e.with({
|
|
957
|
+
definition: r,
|
|
958
|
+
suppressLabel: !0
|
|
959
|
+
}).append(c),
|
|
960
|
+
controller: l
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
function tn(e) {
|
|
966
|
+
return {
|
|
967
|
+
label: e.suppressLabel ? void 0 : e.label,
|
|
968
|
+
description: e.description,
|
|
969
|
+
required: e.isRequired
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
function nn(e) {
|
|
973
|
+
if (e.default !== void 0)
|
|
974
|
+
return e.default;
|
|
975
|
+
if (e.examples && e.examples.length > 0)
|
|
976
|
+
return e.examples[0];
|
|
977
|
+
if (!e.type) return;
|
|
978
|
+
const t = Array.isArray(e.type) ? e.type[0] : e.type;
|
|
979
|
+
if (!(typeof t == "object" && "$ref" in t))
|
|
980
|
+
switch (t) {
|
|
981
|
+
case "string":
|
|
982
|
+
return "";
|
|
983
|
+
case "boolean":
|
|
984
|
+
return !1;
|
|
985
|
+
case "null":
|
|
986
|
+
return null;
|
|
987
|
+
case "object":
|
|
988
|
+
return {};
|
|
989
|
+
case "array":
|
|
990
|
+
case "set":
|
|
991
|
+
return [];
|
|
992
|
+
case "map":
|
|
993
|
+
return {};
|
|
994
|
+
case "any":
|
|
995
|
+
return;
|
|
996
|
+
default:
|
|
997
|
+
return t === "int8" || t === "int16" || t === "int32" || t === "int64" || t === "int128" || t === "uint8" || t === "uint16" || t === "uint32" || t === "uint64" || t === "uint128" || t === "float" || t === "double" || t === "decimal" ? 0 : void 0;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
function Ne({
|
|
1001
|
+
ctx: e,
|
|
1002
|
+
controller: t
|
|
1003
|
+
}) {
|
|
1004
|
+
const n = e.definition;
|
|
1005
|
+
if (n.type !== "set" || !("items" in n))
|
|
1006
|
+
return console.warn("StructureSetControl requires a SetTypeDefinition"), p.div("Invalid set definition");
|
|
1007
|
+
const r = n.items, s = n.minItems ?? 0, a = n.maxItems ?? 1 / 0, u = w(t.signal)((c) => (c?.length ?? 0) < a), i = w(t.signal)((c) => (c?.length ?? 0) > s), o = w(t.signal)((c) => {
|
|
1008
|
+
if (!c || c.length === 0) return /* @__PURE__ */ new Set();
|
|
1009
|
+
const l = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Set();
|
|
1010
|
+
for (let h = 0; h < c.length; h++) {
|
|
1011
|
+
const f = JSON.stringify(c[h]);
|
|
1012
|
+
l.has(f) ? (y.add(l.get(f)), y.add(h)) : l.set(f, h);
|
|
1013
|
+
}
|
|
1014
|
+
return y;
|
|
1015
|
+
});
|
|
1016
|
+
return fe({
|
|
1017
|
+
...tn(e),
|
|
1018
|
+
controller: t,
|
|
1019
|
+
createItem: () => nn(r),
|
|
1020
|
+
showAdd: !0,
|
|
1021
|
+
addDisabled: w(u)((c) => !c || e.readOnly),
|
|
1022
|
+
showRemove: !0,
|
|
1023
|
+
removeDisabled: w(i)((c) => !c || e.readOnly),
|
|
1024
|
+
element: (c) => {
|
|
1025
|
+
const l = c.position.index, y = c.item, h = o.map((g) => g.has(l)), f = j({
|
|
1026
|
+
ctx: e.with({
|
|
1027
|
+
definition: r,
|
|
1028
|
+
suppressLabel: !0
|
|
1029
|
+
}).append(l),
|
|
1030
|
+
controller: y
|
|
1031
|
+
});
|
|
1032
|
+
return h.map((g) => g ? V(
|
|
1033
|
+
m.class("bc-stack--gap-1"),
|
|
1034
|
+
f,
|
|
1035
|
+
ye(
|
|
1036
|
+
m.class("bc-json-structure-set-error"),
|
|
1037
|
+
"⚠️ Duplicate value - sets must contain unique items"
|
|
1038
|
+
)
|
|
1039
|
+
) : f);
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
function rn(e) {
|
|
1044
|
+
return {
|
|
1045
|
+
label: e.suppressLabel ? void 0 : e.label,
|
|
1046
|
+
description: e.description,
|
|
1047
|
+
required: e.isRequired
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
function sn(e) {
|
|
1051
|
+
if (e.default !== void 0)
|
|
1052
|
+
return e.default;
|
|
1053
|
+
if (e.examples && e.examples.length > 0)
|
|
1054
|
+
return e.examples[0];
|
|
1055
|
+
if (!e.type) return;
|
|
1056
|
+
const t = Array.isArray(e.type) ? e.type[0] : e.type;
|
|
1057
|
+
if (!(typeof t == "object" && "$ref" in t))
|
|
1058
|
+
switch (t) {
|
|
1059
|
+
case "string":
|
|
1060
|
+
return "";
|
|
1061
|
+
case "boolean":
|
|
1062
|
+
return !1;
|
|
1063
|
+
case "null":
|
|
1064
|
+
return null;
|
|
1065
|
+
case "object":
|
|
1066
|
+
return {};
|
|
1067
|
+
case "array":
|
|
1068
|
+
case "set":
|
|
1069
|
+
return [];
|
|
1070
|
+
case "map":
|
|
1071
|
+
return {};
|
|
1072
|
+
case "any":
|
|
1073
|
+
return;
|
|
1074
|
+
default:
|
|
1075
|
+
return t === "int8" || t === "int16" || t === "int32" || t === "int64" || t === "int128" || t === "uint8" || t === "uint16" || t === "uint32" || t === "uint64" || t === "uint128" || t === "float" || t === "double" || t === "decimal" ? 0 : void 0;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
function an(e, t = "key") {
|
|
1079
|
+
if (!e.has(t)) return t;
|
|
1080
|
+
let n = 1;
|
|
1081
|
+
for (; e.has(`${t}${n}`); )
|
|
1082
|
+
n++;
|
|
1083
|
+
return `${t}${n}`;
|
|
1084
|
+
}
|
|
1085
|
+
function qe({
|
|
1086
|
+
ctx: e,
|
|
1087
|
+
controller: t
|
|
1088
|
+
}) {
|
|
1089
|
+
const n = e.definition;
|
|
1090
|
+
if (n.type !== "map" || !("values" in n))
|
|
1091
|
+
return console.warn("StructureMapControl requires a MapTypeDefinition"), p.div("Invalid map definition");
|
|
1092
|
+
const r = n.values, s = n.minProperties ?? 0, a = n.maxProperties ?? 1 / 0;
|
|
1093
|
+
return U(t.signal, (u) => {
|
|
1094
|
+
const i = Object.keys(u ?? {}), o = i.length, c = o < a && !e.readOnly, l = o > s && !e.readOnly, y = i.map((d) => {
|
|
1095
|
+
const v = t.field(d);
|
|
1096
|
+
return p.div(
|
|
1097
|
+
m.class("bc-json-structure-map-entry"),
|
|
1098
|
+
p.div(
|
|
1099
|
+
m.class("bc-json-structure-map-entry-header"),
|
|
1100
|
+
p.strong(m.class("bc-json-structure-map-entry-key"), `${d}:`),
|
|
1101
|
+
E(
|
|
1102
|
+
{
|
|
1103
|
+
variant: "text",
|
|
1104
|
+
size: "xs",
|
|
1105
|
+
onClick: () => {
|
|
1106
|
+
const $ = { ...I.get(t.signal) ?? {} };
|
|
1107
|
+
delete $[d], t.change($);
|
|
1108
|
+
},
|
|
1109
|
+
disabled: !l
|
|
1110
|
+
},
|
|
1111
|
+
"Remove"
|
|
1112
|
+
)
|
|
1113
|
+
),
|
|
1114
|
+
p.div(
|
|
1115
|
+
m.class("bc-json-structure-map-entry-value"),
|
|
1116
|
+
j({
|
|
1117
|
+
ctx: e.with({
|
|
1118
|
+
definition: r,
|
|
1119
|
+
suppressLabel: !0
|
|
1120
|
+
}).append(d),
|
|
1121
|
+
controller: v
|
|
1122
|
+
})
|
|
1123
|
+
)
|
|
1124
|
+
);
|
|
1125
|
+
}), h = c ? E(
|
|
1126
|
+
{
|
|
1127
|
+
variant: "outline",
|
|
1128
|
+
size: "sm",
|
|
1129
|
+
onClick: () => {
|
|
1130
|
+
const d = I.get(t.signal) ?? {}, v = new Set(Object.keys(d)), $ = an(v), A = sn(r);
|
|
1131
|
+
t.change({
|
|
1132
|
+
...d,
|
|
1133
|
+
[$]: A
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
},
|
|
1137
|
+
"Add Entry"
|
|
1138
|
+
) : null, f = p.div(
|
|
1139
|
+
m.class("bc-json-structure-map-entries"),
|
|
1140
|
+
...y,
|
|
1141
|
+
h
|
|
1142
|
+
), g = p.div(
|
|
1143
|
+
m.class("bc-json-structure-map"),
|
|
1144
|
+
f
|
|
1145
|
+
);
|
|
1146
|
+
return !e.suppressLabel && e.name ? B({
|
|
1147
|
+
...rn(e),
|
|
1148
|
+
content: g
|
|
1149
|
+
}) : g;
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
function un(e) {
|
|
1153
|
+
return {
|
|
1154
|
+
label: e.suppressLabel ? void 0 : e.label,
|
|
1155
|
+
description: e.description,
|
|
1156
|
+
required: e.isRequired
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
function on(e) {
|
|
1160
|
+
if (e.default !== void 0)
|
|
1161
|
+
return e.default;
|
|
1162
|
+
if (e.examples && e.examples.length > 0)
|
|
1163
|
+
return e.examples[0];
|
|
1164
|
+
if (!e.type) return;
|
|
1165
|
+
const t = Array.isArray(e.type) ? e.type[0] : e.type;
|
|
1166
|
+
if (!(typeof t == "object" && "$ref" in t))
|
|
1167
|
+
switch (t) {
|
|
1168
|
+
case "string":
|
|
1169
|
+
return "";
|
|
1170
|
+
case "boolean":
|
|
1171
|
+
return !1;
|
|
1172
|
+
case "null":
|
|
1173
|
+
return null;
|
|
1174
|
+
case "object":
|
|
1175
|
+
return {};
|
|
1176
|
+
case "array":
|
|
1177
|
+
case "set":
|
|
1178
|
+
return [];
|
|
1179
|
+
case "map":
|
|
1180
|
+
return {};
|
|
1181
|
+
case "any":
|
|
1182
|
+
return;
|
|
1183
|
+
default:
|
|
1184
|
+
return t === "int8" || t === "int16" || t === "int32" || t === "int64" || t === "int128" || t === "uint8" || t === "uint16" || t === "uint32" || t === "uint64" || t === "uint128" || t === "float" || t === "double" || t === "decimal" ? 0 : void 0;
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
function Pe({
|
|
1188
|
+
ctx: e,
|
|
1189
|
+
controller: t
|
|
1190
|
+
}) {
|
|
1191
|
+
const n = e.definition;
|
|
1192
|
+
if (n.type !== "tuple" || !("tuple" in n) || !("properties" in n))
|
|
1193
|
+
return console.warn("StructureTupleControl requires a TupleTypeDefinition"), p.div("Invalid tuple definition");
|
|
1194
|
+
const r = n.tuple, s = n.properties, a = t.signal.value;
|
|
1195
|
+
if (!Array.isArray(a) || a.length !== r.length) {
|
|
1196
|
+
const i = r.map((o) => {
|
|
1197
|
+
const c = s[o];
|
|
1198
|
+
return c ? on(c) : void 0;
|
|
1199
|
+
});
|
|
1200
|
+
t.change(i);
|
|
1201
|
+
}
|
|
1202
|
+
const u = un(e);
|
|
1203
|
+
return p.div(
|
|
1204
|
+
m.class("bc-json-structure-tuple"),
|
|
1205
|
+
// Optional label and description
|
|
1206
|
+
u.label && p.label(
|
|
1207
|
+
m.class("bc-json-structure-tuple-label"),
|
|
1208
|
+
u.label,
|
|
1209
|
+
u.required && p.span(m.class("bc-required-indicator"), "*")
|
|
1210
|
+
),
|
|
1211
|
+
u.description && p.div(
|
|
1212
|
+
m.class("bc-json-structure-tuple-description"),
|
|
1213
|
+
u.description
|
|
1214
|
+
),
|
|
1215
|
+
// Render tuple elements
|
|
1216
|
+
p.div(
|
|
1217
|
+
m.class("bc-json-structure-tuple-elements"),
|
|
1218
|
+
...r.map((i, o) => {
|
|
1219
|
+
const c = s[i];
|
|
1220
|
+
if (!c)
|
|
1221
|
+
return console.warn(
|
|
1222
|
+
`Tuple element "${i}" at index ${o} not found in properties`
|
|
1223
|
+
), p.div(
|
|
1224
|
+
m.class("bc-json-structure-tuple-element"),
|
|
1225
|
+
p.span(`Missing definition for "${i}"`)
|
|
1226
|
+
);
|
|
1227
|
+
const l = t.item(o), y = c.name || i;
|
|
1228
|
+
return p.div(
|
|
1229
|
+
m.class("bc-json-structure-tuple-element"),
|
|
1230
|
+
// Element position indicator and label
|
|
1231
|
+
p.div(
|
|
1232
|
+
m.class("bc-json-structure-tuple-element-header"),
|
|
1233
|
+
p.span(
|
|
1234
|
+
m.class("bc-json-structure-tuple-position"),
|
|
1235
|
+
`[${o}]`
|
|
1236
|
+
),
|
|
1237
|
+
p.span(
|
|
1238
|
+
m.class("bc-json-structure-tuple-element-name"),
|
|
1239
|
+
y
|
|
1240
|
+
)
|
|
1241
|
+
),
|
|
1242
|
+
// Element control
|
|
1243
|
+
p.div(
|
|
1244
|
+
m.class("bc-json-structure-tuple-element-control"),
|
|
1245
|
+
j({
|
|
1246
|
+
ctx: e.with({
|
|
1247
|
+
definition: c,
|
|
1248
|
+
suppressLabel: !0
|
|
1249
|
+
// Label already shown in header
|
|
1250
|
+
}).append(o),
|
|
1251
|
+
controller: l
|
|
1252
|
+
})
|
|
1253
|
+
)
|
|
1254
|
+
);
|
|
1255
|
+
})
|
|
1256
|
+
)
|
|
1257
|
+
);
|
|
1258
|
+
}
|
|
1259
|
+
function cn({
|
|
1260
|
+
options: e,
|
|
1261
|
+
selected: t,
|
|
1262
|
+
onChange: n,
|
|
1263
|
+
disabled: r
|
|
1264
|
+
}) {
|
|
1265
|
+
return me({
|
|
1266
|
+
options: e.map((s) => ({
|
|
1267
|
+
type: "value",
|
|
1268
|
+
value: s.value,
|
|
1269
|
+
label: s.label
|
|
1270
|
+
})),
|
|
1271
|
+
value: t,
|
|
1272
|
+
onChange: n,
|
|
1273
|
+
disabled: r
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
function ln({
|
|
1277
|
+
ctx: e,
|
|
1278
|
+
selector: t,
|
|
1279
|
+
inner: n
|
|
1280
|
+
}) {
|
|
1281
|
+
const r = V(
|
|
1282
|
+
m.class("bc-stack--gap-2 bc-stack--align-start"),
|
|
1283
|
+
t,
|
|
1284
|
+
n
|
|
1285
|
+
);
|
|
1286
|
+
return e.isRoot ? r : B({
|
|
1287
|
+
label: e.suppressLabel ? void 0 : e.label,
|
|
1288
|
+
description: e.description,
|
|
1289
|
+
required: e.isRequired,
|
|
1290
|
+
content: r
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
function pn(e, t, n) {
|
|
1294
|
+
if (!e || typeof e != "object")
|
|
1295
|
+
return null;
|
|
1296
|
+
const r = e;
|
|
1297
|
+
if (n && n in r) {
|
|
1298
|
+
const a = r[n];
|
|
1299
|
+
if (typeof a == "string" && a in t)
|
|
1300
|
+
return a;
|
|
1301
|
+
}
|
|
1302
|
+
const s = Object.keys(r);
|
|
1303
|
+
if (s.length === 1) {
|
|
1304
|
+
const a = s[0];
|
|
1305
|
+
if (a in t)
|
|
1306
|
+
return a;
|
|
1307
|
+
}
|
|
1308
|
+
return null;
|
|
1309
|
+
}
|
|
1310
|
+
function dn(e, t, n) {
|
|
1311
|
+
if (!e || typeof e != "object")
|
|
1312
|
+
return;
|
|
1313
|
+
const r = e;
|
|
1314
|
+
if (n && n in r) {
|
|
1315
|
+
const { [n]: s, ...a } = r;
|
|
1316
|
+
return a;
|
|
1317
|
+
}
|
|
1318
|
+
if (t in r)
|
|
1319
|
+
return r[t];
|
|
1320
|
+
}
|
|
1321
|
+
function oe(e, t, n) {
|
|
1322
|
+
return n ? e && typeof e == "object" ? {
|
|
1323
|
+
[n]: t,
|
|
1324
|
+
...e
|
|
1325
|
+
} : {
|
|
1326
|
+
[n]: t
|
|
1327
|
+
} : {
|
|
1328
|
+
[t]: e
|
|
1329
|
+
};
|
|
1330
|
+
}
|
|
1331
|
+
function fn(e) {
|
|
1332
|
+
if (e.default !== void 0)
|
|
1333
|
+
return e.default;
|
|
1334
|
+
if (e.examples && e.examples.length > 0)
|
|
1335
|
+
return e.examples[0];
|
|
1336
|
+
const t = Array.isArray(e.type) ? e.type[0] : e.type;
|
|
1337
|
+
if (!(!t || typeof t == "object"))
|
|
1338
|
+
switch (t) {
|
|
1339
|
+
case "string":
|
|
1340
|
+
return "";
|
|
1341
|
+
case "boolean":
|
|
1342
|
+
return !1;
|
|
1343
|
+
case "null":
|
|
1344
|
+
return null;
|
|
1345
|
+
case "object":
|
|
1346
|
+
return {};
|
|
1347
|
+
case "array":
|
|
1348
|
+
case "set":
|
|
1349
|
+
return [];
|
|
1350
|
+
case "map":
|
|
1351
|
+
return {};
|
|
1352
|
+
default:
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
function Fe({
|
|
1357
|
+
ctx: e,
|
|
1358
|
+
controller: t
|
|
1359
|
+
}) {
|
|
1360
|
+
const n = e.definition;
|
|
1361
|
+
if (!n.choices || typeof n.choices != "object")
|
|
1362
|
+
return console.warn("StructureChoiceControl requires choices property"), p.div(
|
|
1363
|
+
m.class("bc-json-structure-error"),
|
|
1364
|
+
"Invalid choice definition: missing choices"
|
|
1365
|
+
);
|
|
1366
|
+
const r = n.choices, s = n.selector, a = Object.keys(r);
|
|
1367
|
+
if (a.length === 0)
|
|
1368
|
+
return p.div(
|
|
1369
|
+
m.class("bc-json-structure-error"),
|
|
1370
|
+
"Choice type has no variants defined"
|
|
1371
|
+
);
|
|
1372
|
+
const u = a.map((d) => {
|
|
1373
|
+
const $ = r[d].name || d;
|
|
1374
|
+
return { value: d, label: $ };
|
|
1375
|
+
}), i = w(t.signal)((d) => pn(d, r, s)), o = I.get(i) || a[0], c = it(o);
|
|
1376
|
+
t.onDispose(c.dispose);
|
|
1377
|
+
let l = !1;
|
|
1378
|
+
const y = i.on((d) => {
|
|
1379
|
+
!l && d !== null && c.set(d);
|
|
1380
|
+
});
|
|
1381
|
+
t.onDispose(y);
|
|
1382
|
+
const f = cn({
|
|
1383
|
+
options: u,
|
|
1384
|
+
selected: c,
|
|
1385
|
+
onChange: (d) => {
|
|
1386
|
+
l = !0, c.set(d);
|
|
1387
|
+
const v = r[d];
|
|
1388
|
+
if (v) {
|
|
1389
|
+
const $ = fn(v), A = oe($, d, s);
|
|
1390
|
+
t.change(A);
|
|
1391
|
+
}
|
|
1392
|
+
},
|
|
1393
|
+
disabled: e.readOnly || e.isDeprecated
|
|
1394
|
+
}), g = U(c, (d) => {
|
|
1395
|
+
const v = r[I.get(d)];
|
|
1396
|
+
if (!v)
|
|
1397
|
+
return p.div(
|
|
1398
|
+
m.class("bc-json-structure-error"),
|
|
1399
|
+
`Choice variant not found: ${I.get(d)}`
|
|
1400
|
+
);
|
|
1401
|
+
const $ = w(t.signal)(
|
|
1402
|
+
(S) => dn(S, I.get(d), s)
|
|
1403
|
+
), A = (S) => {
|
|
1404
|
+
const R = oe(
|
|
1405
|
+
S,
|
|
1406
|
+
I.get(d),
|
|
1407
|
+
s
|
|
1408
|
+
);
|
|
1409
|
+
t.change(R);
|
|
1410
|
+
}, q = new ut(
|
|
1411
|
+
[...t.path, I.get(d)],
|
|
1412
|
+
A,
|
|
1413
|
+
$,
|
|
1414
|
+
t.status,
|
|
1415
|
+
{
|
|
1416
|
+
disabled: t.disabled
|
|
1417
|
+
},
|
|
1418
|
+
void 0
|
|
1419
|
+
// Use default equality
|
|
1420
|
+
);
|
|
1421
|
+
return t.onDispose(() => q.dispose()), j({
|
|
1422
|
+
ctx: e.with({
|
|
1423
|
+
definition: v,
|
|
1424
|
+
suppressLabel: !0
|
|
1425
|
+
// Choice selector acts as the label
|
|
1426
|
+
}).append(I.get(d)),
|
|
1427
|
+
controller: q
|
|
1428
|
+
});
|
|
1429
|
+
});
|
|
1430
|
+
return ln({
|
|
1431
|
+
ctx: e,
|
|
1432
|
+
selector: f,
|
|
1433
|
+
inner: g
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1436
|
+
function mn(e) {
|
|
1437
|
+
return {
|
|
1438
|
+
label: e.suppressLabel ? void 0 : T(e.label, e.isDeprecated),
|
|
1439
|
+
description: e.description,
|
|
1440
|
+
required: e.isRequired,
|
|
1441
|
+
disabled: e.readOnly || e.isDeprecated
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
function Le({
|
|
1445
|
+
ctx: e,
|
|
1446
|
+
controller: t
|
|
1447
|
+
}) {
|
|
1448
|
+
const n = mn(e);
|
|
1449
|
+
return Qe({
|
|
1450
|
+
...n,
|
|
1451
|
+
options: (e.enumValues ?? []).map((r) => ({
|
|
1452
|
+
type: "value",
|
|
1453
|
+
value: r,
|
|
1454
|
+
label: String(r)
|
|
1455
|
+
})),
|
|
1456
|
+
controller: t
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
function Ve({
|
|
1460
|
+
ctx: e,
|
|
1461
|
+
controller: t
|
|
1462
|
+
}) {
|
|
1463
|
+
return H(
|
|
1464
|
+
st(() => {
|
|
1465
|
+
I.get(t.signal) !== e.constValue && t.change(e.constValue);
|
|
1466
|
+
}),
|
|
1467
|
+
et(ot(e.label, ": "), ye(String(e.constValue)))
|
|
1468
|
+
);
|
|
1469
|
+
}
|
|
1470
|
+
function yn(e) {
|
|
1471
|
+
return {
|
|
1472
|
+
label: e.suppressLabel ? void 0 : e.label,
|
|
1473
|
+
description: e.description,
|
|
1474
|
+
required: e.isRequired,
|
|
1475
|
+
disabled: e.readOnly || e.isDeprecated
|
|
1476
|
+
};
|
|
1477
|
+
}
|
|
1478
|
+
function gn(e, t) {
|
|
1479
|
+
if (e === null) return t.includes("null") ? "null" : null;
|
|
1480
|
+
if (e === void 0)
|
|
1481
|
+
return t.includes("string") ? "string" : t[0] ?? null;
|
|
1482
|
+
switch (typeof e) {
|
|
1483
|
+
case "string":
|
|
1484
|
+
return t.includes("uuid") ? "uuid" : t.includes("uri") ? "uri" : t.includes("date") ? "date" : t.includes("datetime") ? "datetime" : t.includes("time") ? "time" : t.includes("duration") ? "duration" : t.includes("string") ? "string" : null;
|
|
1485
|
+
case "number": {
|
|
1486
|
+
if (Number.isInteger(e)) {
|
|
1487
|
+
if (t.includes("int32")) return "int32";
|
|
1488
|
+
if (t.includes("int64")) return "int64";
|
|
1489
|
+
if (t.includes("uint32")) return "uint32";
|
|
1490
|
+
if (t.includes("uint64")) return "uint64";
|
|
1491
|
+
if (t.includes("int16")) return "int16";
|
|
1492
|
+
if (t.includes("int8")) return "int8";
|
|
1493
|
+
if (t.includes("uint16")) return "uint16";
|
|
1494
|
+
if (t.includes("uint8")) return "uint8";
|
|
1495
|
+
}
|
|
1496
|
+
return t.includes("double") ? "double" : t.includes("float") ? "float" : t.includes("decimal") ? "decimal" : null;
|
|
1497
|
+
}
|
|
1498
|
+
case "bigint":
|
|
1499
|
+
return t.includes("int128") ? "int128" : t.includes("int64") ? "int64" : t.includes("uint128") ? "uint128" : t.includes("uint64") ? "uint64" : null;
|
|
1500
|
+
case "boolean":
|
|
1501
|
+
return t.includes("boolean") ? "boolean" : null;
|
|
1502
|
+
case "object":
|
|
1503
|
+
return e instanceof File || e instanceof Blob ? t.includes("binary") ? "binary" : null : Array.isArray(e) ? t.includes("array") ? "array" : t.includes("set") ? "set" : t.includes("tuple") ? "tuple" : null : t.includes("object") ? "object" : t.includes("map") ? "map" : null;
|
|
1504
|
+
default:
|
|
1505
|
+
return null;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
function hn(e, t) {
|
|
1509
|
+
try {
|
|
1510
|
+
switch (t) {
|
|
1511
|
+
case "string":
|
|
1512
|
+
case "uuid":
|
|
1513
|
+
case "uri":
|
|
1514
|
+
case "date":
|
|
1515
|
+
case "datetime":
|
|
1516
|
+
case "time":
|
|
1517
|
+
case "duration":
|
|
1518
|
+
return e == null ? { ok: !0, value: void 0 } : { ok: !0, value: String(e) };
|
|
1519
|
+
case "int8":
|
|
1520
|
+
case "int16":
|
|
1521
|
+
case "int32":
|
|
1522
|
+
case "uint8":
|
|
1523
|
+
case "uint16":
|
|
1524
|
+
case "uint32":
|
|
1525
|
+
return typeof e == "number" && Number.isInteger(e) ? { ok: !0, value: e } : typeof e == "string" ? /^[-+]?\d+$/.test(e.trim()) ? { ok: !0, value: parseInt(e, 10) } : { ok: !1 } : typeof e == "boolean" ? { ok: !0, value: e ? 1 : 0 } : { ok: !1 };
|
|
1526
|
+
case "int64":
|
|
1527
|
+
case "int128":
|
|
1528
|
+
case "uint64":
|
|
1529
|
+
case "uint128": {
|
|
1530
|
+
if (typeof e == "bigint") return { ok: !0, value: e };
|
|
1531
|
+
if (typeof e == "number" && Number.isInteger(e))
|
|
1532
|
+
return { ok: !0, value: BigInt(e) };
|
|
1533
|
+
if (typeof e == "string")
|
|
1534
|
+
try {
|
|
1535
|
+
return { ok: !0, value: BigInt(e.trim()) };
|
|
1536
|
+
} catch {
|
|
1537
|
+
return { ok: !1 };
|
|
1538
|
+
}
|
|
1539
|
+
return { ok: !1 };
|
|
1540
|
+
}
|
|
1541
|
+
case "float":
|
|
1542
|
+
case "double":
|
|
1543
|
+
case "decimal": {
|
|
1544
|
+
if (typeof e == "number") return { ok: !0, value: e };
|
|
1545
|
+
if (typeof e == "string") {
|
|
1546
|
+
const n = Number(e);
|
|
1547
|
+
return Number.isFinite(n) ? { ok: !0, value: n } : { ok: !1 };
|
|
1548
|
+
}
|
|
1549
|
+
return typeof e == "boolean" ? { ok: !0, value: e ? 1 : 0 } : { ok: !1 };
|
|
1550
|
+
}
|
|
1551
|
+
case "boolean": {
|
|
1552
|
+
if (typeof e == "boolean") return { ok: !0, value: e };
|
|
1553
|
+
if (typeof e == "string") {
|
|
1554
|
+
const n = e.trim().toLowerCase();
|
|
1555
|
+
return n === "true" || n === "1" || n === "yes" ? { ok: !0, value: !0 } : n === "false" || n === "0" || n === "no" ? { ok: !0, value: !1 } : { ok: !1 };
|
|
1556
|
+
}
|
|
1557
|
+
return typeof e == "number" ? { ok: !0, value: e !== 0 } : { ok: !1 };
|
|
1558
|
+
}
|
|
1559
|
+
case "array":
|
|
1560
|
+
case "set":
|
|
1561
|
+
case "tuple":
|
|
1562
|
+
return Array.isArray(e) ? { ok: !0, value: e } : { ok: !1 };
|
|
1563
|
+
case "object":
|
|
1564
|
+
case "map":
|
|
1565
|
+
return e != null && typeof e == "object" && !Array.isArray(e) ? { ok: !0, value: e } : { ok: !1 };
|
|
1566
|
+
case "binary":
|
|
1567
|
+
return e instanceof File || e instanceof Blob ? { ok: !0, value: e } : { ok: !1 };
|
|
1568
|
+
case "null":
|
|
1569
|
+
return { ok: !0, value: null };
|
|
1570
|
+
case "any":
|
|
1571
|
+
case "choice":
|
|
1572
|
+
return { ok: !0, value: e };
|
|
1573
|
+
default:
|
|
1574
|
+
return { ok: !1 };
|
|
1575
|
+
}
|
|
1576
|
+
} catch {
|
|
1577
|
+
return { ok: !1 };
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
function bn(e) {
|
|
1581
|
+
switch (e) {
|
|
1582
|
+
case "null":
|
|
1583
|
+
return null;
|
|
1584
|
+
case "array":
|
|
1585
|
+
case "set":
|
|
1586
|
+
case "tuple":
|
|
1587
|
+
return [];
|
|
1588
|
+
case "object":
|
|
1589
|
+
case "map":
|
|
1590
|
+
return {};
|
|
1591
|
+
case "binary":
|
|
1592
|
+
return;
|
|
1593
|
+
default:
|
|
1594
|
+
return;
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
function vn(e) {
|
|
1598
|
+
return e.map((t) => ({
|
|
1599
|
+
key: t,
|
|
1600
|
+
label: J(t),
|
|
1601
|
+
detect: (n) => gn(n, [t]) === t,
|
|
1602
|
+
convert: (n) => hn(n, t),
|
|
1603
|
+
defaultValue: () => bn(t)
|
|
1604
|
+
}));
|
|
1605
|
+
}
|
|
1606
|
+
function xn({
|
|
1607
|
+
options: e,
|
|
1608
|
+
selected: t,
|
|
1609
|
+
onChange: n
|
|
1610
|
+
}) {
|
|
1611
|
+
if ((e.length <= 3 ? "segmented" : "select") === "segmented") {
|
|
1612
|
+
const a = Object.fromEntries(
|
|
1613
|
+
e.map((u) => [u.value, u.label])
|
|
1614
|
+
);
|
|
1615
|
+
return nt({
|
|
1616
|
+
options: a,
|
|
1617
|
+
value: t,
|
|
1618
|
+
onChange: (u) => n(u),
|
|
1619
|
+
size: "sm"
|
|
1620
|
+
});
|
|
1621
|
+
}
|
|
1622
|
+
return me({
|
|
1623
|
+
options: e.map((a) => ({
|
|
1624
|
+
type: "value",
|
|
1625
|
+
value: a.value,
|
|
1626
|
+
label: a.label
|
|
1627
|
+
})),
|
|
1628
|
+
value: t,
|
|
1629
|
+
onChange: n
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
function $n({
|
|
1633
|
+
ctx: e,
|
|
1634
|
+
showSelector: t,
|
|
1635
|
+
selector: n,
|
|
1636
|
+
inner: r
|
|
1637
|
+
}) {
|
|
1638
|
+
return e.isRoot ? t ? V(m.class("bc-stack--gap-2"), n, r) : r : B({
|
|
1639
|
+
...yn(e),
|
|
1640
|
+
content: t ? V(
|
|
1641
|
+
m.class("bc-stack--gap-2 bc-stack--align-start"),
|
|
1642
|
+
n,
|
|
1643
|
+
r
|
|
1644
|
+
) : r
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1647
|
+
function In({
|
|
1648
|
+
ctx: e,
|
|
1649
|
+
controller: t
|
|
1650
|
+
}) {
|
|
1651
|
+
const n = e.definition, r = n.type;
|
|
1652
|
+
let s = [];
|
|
1653
|
+
if (Array.isArray(r))
|
|
1654
|
+
s = r;
|
|
1655
|
+
else
|
|
1656
|
+
return console.warn("StructureUnionControl called with non-array type"), j({ ctx: e, controller: t });
|
|
1657
|
+
const a = s.includes("null"), u = Q(r), i = a && u.length > 0 ? u : s, o = vn(i), c = new tt(
|
|
1658
|
+
t.path,
|
|
1659
|
+
t.change,
|
|
1660
|
+
t.signal,
|
|
1661
|
+
t.status,
|
|
1662
|
+
{ disabled: t.disabled },
|
|
1663
|
+
o
|
|
1664
|
+
);
|
|
1665
|
+
t.onDispose(() => c.dispose());
|
|
1666
|
+
const l = (f) => xn({
|
|
1667
|
+
options: i.map((g) => ({ value: g, label: J(g) })),
|
|
1668
|
+
selected: c.activeBranch,
|
|
1669
|
+
onChange: f
|
|
1670
|
+
}), y = (f) => {
|
|
1671
|
+
c.switchToBranch(f, !1);
|
|
1672
|
+
}, h = U(c.activeBranch, (f) => {
|
|
1673
|
+
const g = I.get(f), d = c.getBranchController(g), v = e.with({
|
|
1674
|
+
definition: { ...n, type: g },
|
|
1675
|
+
// Suppress inner labels only when union is nested (non-root)
|
|
1676
|
+
suppressLabel: !e.isRoot
|
|
1677
|
+
});
|
|
1678
|
+
return j({
|
|
1679
|
+
ctx: v,
|
|
1680
|
+
controller: d
|
|
1681
|
+
});
|
|
1682
|
+
});
|
|
1683
|
+
return $n({
|
|
1684
|
+
ctx: e,
|
|
1685
|
+
showSelector: i.length > 1,
|
|
1686
|
+
selector: l(y),
|
|
1687
|
+
inner: h
|
|
1688
|
+
});
|
|
1689
|
+
}
|
|
1690
|
+
function j({
|
|
1691
|
+
ctx: e,
|
|
1692
|
+
controller: t
|
|
1693
|
+
}) {
|
|
1694
|
+
let n = e;
|
|
1695
|
+
const r = e.definition;
|
|
1696
|
+
if (r.type && C(r.type)) {
|
|
1697
|
+
const i = e.resolveRef(r.type.$ref);
|
|
1698
|
+
if (i) {
|
|
1699
|
+
const { type: o, ...c } = r, l = { ...i, ...c };
|
|
1700
|
+
n = e.with({ definition: l });
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
if (n.definition.$extends) {
|
|
1704
|
+
const { merged: i } = $e(n.definition, e.schema);
|
|
1705
|
+
n = n.with({ definition: i });
|
|
1706
|
+
}
|
|
1707
|
+
const s = n.widgetRegistry;
|
|
1708
|
+
if (s) {
|
|
1709
|
+
const i = s.findBestWidget(n);
|
|
1710
|
+
if (i)
|
|
1711
|
+
return i.registration.factory({
|
|
1712
|
+
controller: t,
|
|
1713
|
+
ctx: n
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
if (Mt(n.definition))
|
|
1717
|
+
return Le({
|
|
1718
|
+
ctx: n,
|
|
1719
|
+
controller: t
|
|
1720
|
+
});
|
|
1721
|
+
if (Dt(n.definition))
|
|
1722
|
+
return Ve({
|
|
1723
|
+
ctx: n,
|
|
1724
|
+
controller: t
|
|
1725
|
+
});
|
|
1726
|
+
const a = n.resolvedType;
|
|
1727
|
+
if (Array.isArray(a) && Q(a).length > 1)
|
|
1728
|
+
return In({
|
|
1729
|
+
ctx: n,
|
|
1730
|
+
controller: t
|
|
1731
|
+
});
|
|
1732
|
+
const u = n.primaryType;
|
|
1733
|
+
if (!u)
|
|
1734
|
+
return K({
|
|
1735
|
+
ctx: n,
|
|
1736
|
+
controller: t
|
|
1737
|
+
});
|
|
1738
|
+
if (k(n.definition)) {
|
|
1739
|
+
const i = t instanceof re ? t : t.object();
|
|
1740
|
+
return Re({
|
|
1741
|
+
ctx: n,
|
|
1742
|
+
controller: i
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1745
|
+
if (ge(n.definition)) {
|
|
1746
|
+
const i = t instanceof G ? t : t.array();
|
|
1747
|
+
return ke({
|
|
1748
|
+
ctx: n,
|
|
1749
|
+
controller: i
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
if (he(n.definition)) {
|
|
1753
|
+
const i = t instanceof G ? t : t.array();
|
|
1754
|
+
return Ne({
|
|
1755
|
+
ctx: n,
|
|
1756
|
+
controller: i
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
if (be(n.definition)) {
|
|
1760
|
+
const i = t instanceof re ? t : t.object();
|
|
1761
|
+
return qe({
|
|
1762
|
+
ctx: n,
|
|
1763
|
+
controller: i
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
if (ve(n.definition)) {
|
|
1767
|
+
const i = t instanceof G ? t : t.array();
|
|
1768
|
+
return Pe({
|
|
1769
|
+
ctx: n,
|
|
1770
|
+
controller: i
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
if (xe(n.definition))
|
|
1774
|
+
return Fe({
|
|
1775
|
+
ctx: n,
|
|
1776
|
+
controller: t
|
|
1777
|
+
});
|
|
1778
|
+
switch (u) {
|
|
1779
|
+
case "string":
|
|
1780
|
+
return Ie({
|
|
1781
|
+
ctx: n,
|
|
1782
|
+
controller: t
|
|
1783
|
+
});
|
|
1784
|
+
case "boolean":
|
|
1785
|
+
return we({
|
|
1786
|
+
ctx: n,
|
|
1787
|
+
controller: t
|
|
1788
|
+
});
|
|
1789
|
+
case "uuid":
|
|
1790
|
+
return De({
|
|
1791
|
+
ctx: n,
|
|
1792
|
+
controller: t
|
|
1793
|
+
});
|
|
1794
|
+
case "uri":
|
|
1795
|
+
return Oe({
|
|
1796
|
+
ctx: n,
|
|
1797
|
+
controller: t
|
|
1798
|
+
});
|
|
1799
|
+
case "binary":
|
|
1800
|
+
return Ce({
|
|
1801
|
+
ctx: n,
|
|
1802
|
+
controller: t
|
|
1803
|
+
});
|
|
1804
|
+
case "null":
|
|
1805
|
+
return Tn(n);
|
|
1806
|
+
case "any":
|
|
1807
|
+
return K({
|
|
1808
|
+
ctx: n,
|
|
1809
|
+
controller: t
|
|
1810
|
+
});
|
|
1811
|
+
default:
|
|
1812
|
+
return P(u) ? Ae({
|
|
1813
|
+
ctx: n,
|
|
1814
|
+
controller: t,
|
|
1815
|
+
intType: u
|
|
1816
|
+
}) : X(u) ? Me({
|
|
1817
|
+
ctx: n,
|
|
1818
|
+
controller: t,
|
|
1819
|
+
floatType: u
|
|
1820
|
+
}) : Y(u) ? Se({
|
|
1821
|
+
ctx: n,
|
|
1822
|
+
controller: t,
|
|
1823
|
+
temporalType: u
|
|
1824
|
+
}) : (console.warn(`Unknown type: ${u}`), jn(n, u));
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
function wn({
|
|
1828
|
+
schema: e,
|
|
1829
|
+
controller: t,
|
|
1830
|
+
widgetRegistry: n,
|
|
1831
|
+
readOnly: r,
|
|
1832
|
+
locale: s
|
|
1833
|
+
}) {
|
|
1834
|
+
const a = kt(e, {
|
|
1835
|
+
widgetRegistry: n,
|
|
1836
|
+
readOnly: r,
|
|
1837
|
+
locale: s
|
|
1838
|
+
});
|
|
1839
|
+
return j({ ctx: a, controller: t });
|
|
1840
|
+
}
|
|
1841
|
+
function Tn(e) {
|
|
1842
|
+
return p.div(
|
|
1843
|
+
m.class("bc-json-structure-placeholder"),
|
|
1844
|
+
p.span(`[Null: ${e.label}]`),
|
|
1845
|
+
p.em("null")
|
|
1846
|
+
);
|
|
1847
|
+
}
|
|
1848
|
+
function jn(e, t) {
|
|
1849
|
+
return p.div(
|
|
1850
|
+
m.class("bc-json-structure-unknown"),
|
|
1851
|
+
p.span(`Unknown type: ${t}`),
|
|
1852
|
+
p.em(`at path: ${e.jsonPath}`)
|
|
1853
|
+
);
|
|
1854
|
+
}
|
|
1855
|
+
function Ee(e, t) {
|
|
1856
|
+
return new An(e, t);
|
|
1857
|
+
}
|
|
1858
|
+
class An {
|
|
1859
|
+
schema;
|
|
1860
|
+
options;
|
|
1861
|
+
constructor(t, n) {
|
|
1862
|
+
this.schema = t, this.options = n ?? {};
|
|
1863
|
+
}
|
|
1864
|
+
validate(t) {
|
|
1865
|
+
const n = [];
|
|
1866
|
+
return this.validateValue(
|
|
1867
|
+
t,
|
|
1868
|
+
this.schema,
|
|
1869
|
+
"",
|
|
1870
|
+
n
|
|
1871
|
+
), {
|
|
1872
|
+
isValid: n.length === 0,
|
|
1873
|
+
errors: n
|
|
1874
|
+
};
|
|
1875
|
+
}
|
|
1876
|
+
validateAt(t, n) {
|
|
1877
|
+
return this.validate(t);
|
|
1878
|
+
}
|
|
1879
|
+
validateValue(t, n, r, s) {
|
|
1880
|
+
if (this.options.stopOnFirstError && s.length > 0)
|
|
1881
|
+
return;
|
|
1882
|
+
if (t === null) {
|
|
1883
|
+
const c = n.type;
|
|
1884
|
+
if (c === "null" || Array.isArray(c) && c.includes("null")) return;
|
|
1885
|
+
s.push({
|
|
1886
|
+
path: r,
|
|
1887
|
+
type: "type",
|
|
1888
|
+
expected: c,
|
|
1889
|
+
actual: "null"
|
|
1890
|
+
});
|
|
1891
|
+
return;
|
|
1892
|
+
}
|
|
1893
|
+
if ("enum" in n && Array.isArray(n.enum)) {
|
|
1894
|
+
n.enum.includes(t) || s.push({
|
|
1895
|
+
path: r,
|
|
1896
|
+
type: "enum",
|
|
1897
|
+
expected: n.enum,
|
|
1898
|
+
actual: t
|
|
1899
|
+
});
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1902
|
+
if ("const" in n) {
|
|
1903
|
+
t !== n.const && s.push({
|
|
1904
|
+
path: r,
|
|
1905
|
+
type: "const",
|
|
1906
|
+
expected: n.const,
|
|
1907
|
+
actual: t
|
|
1908
|
+
});
|
|
1909
|
+
return;
|
|
1910
|
+
}
|
|
1911
|
+
const a = n.type;
|
|
1912
|
+
if (!a) return;
|
|
1913
|
+
const i = (Array.isArray(a) ? a : [a]).filter(
|
|
1914
|
+
(c) => typeof c == "string"
|
|
1915
|
+
);
|
|
1916
|
+
!i.some(
|
|
1917
|
+
(c) => this.checkType(t, c, n, r, s)
|
|
1918
|
+
) && i.length > 0 && s.push({
|
|
1919
|
+
path: r,
|
|
1920
|
+
type: "type",
|
|
1921
|
+
expected: a,
|
|
1922
|
+
actual: typeof t
|
|
1923
|
+
});
|
|
1924
|
+
}
|
|
1925
|
+
checkType(t, n, r, s, a) {
|
|
1926
|
+
switch (n) {
|
|
1927
|
+
case "string":
|
|
1928
|
+
return this.validateString(t, r, s, a);
|
|
1929
|
+
case "boolean":
|
|
1930
|
+
return typeof t == "boolean";
|
|
1931
|
+
case "null":
|
|
1932
|
+
return t === null;
|
|
1933
|
+
case "object":
|
|
1934
|
+
return this.validateObject(t, r, s, a);
|
|
1935
|
+
case "array":
|
|
1936
|
+
return this.validateArray(t, r, s, a);
|
|
1937
|
+
case "set":
|
|
1938
|
+
return this.validateSet(t, r, s, a);
|
|
1939
|
+
case "map":
|
|
1940
|
+
return this.validateMap(t, r, s, a);
|
|
1941
|
+
case "tuple":
|
|
1942
|
+
return this.validateTuple(t, r, s, a);
|
|
1943
|
+
case "choice":
|
|
1944
|
+
return this.validateChoice(t, r, s, a);
|
|
1945
|
+
case "any":
|
|
1946
|
+
return !0;
|
|
1947
|
+
default:
|
|
1948
|
+
return P(n) ? this.validateInteger(t, n, r, s, a) : X(n) ? this.validateFloat(t, r, s, a) : Y(n) ? this.validateTemporal(t, n, s, a) : n === "uuid" ? this.validateUuid(t, s, a) : n === "uri" ? this.validateUri(t, s, a) : n === "binary" ? this.validateBinary(t, s, a) : !1;
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
validateString(t, n, r, s) {
|
|
1952
|
+
if (typeof t != "string") return !1;
|
|
1953
|
+
const a = n;
|
|
1954
|
+
if (a.minLength !== void 0 && t.length < a.minLength && s.push({
|
|
1955
|
+
path: r,
|
|
1956
|
+
type: "minLength",
|
|
1957
|
+
expected: a.minLength,
|
|
1958
|
+
actual: t.length
|
|
1959
|
+
}), a.maxLength !== void 0 && t.length > a.maxLength && s.push({
|
|
1960
|
+
path: r,
|
|
1961
|
+
type: "maxLength",
|
|
1962
|
+
expected: a.maxLength,
|
|
1963
|
+
actual: t.length
|
|
1964
|
+
}), a.pattern !== void 0)
|
|
1965
|
+
try {
|
|
1966
|
+
new RegExp(a.pattern).test(t) || s.push({
|
|
1967
|
+
path: r,
|
|
1968
|
+
type: "pattern",
|
|
1969
|
+
expected: a.pattern,
|
|
1970
|
+
actual: t
|
|
1971
|
+
});
|
|
1972
|
+
} catch {
|
|
1973
|
+
}
|
|
1974
|
+
return !0;
|
|
1975
|
+
}
|
|
1976
|
+
validateInteger(t, n, r, s, a) {
|
|
1977
|
+
if (typeof t != "number" && typeof t != "bigint") return !1;
|
|
1978
|
+
if (typeof t == "number" && !Number.isInteger(t))
|
|
1979
|
+
return a.push({ path: s, type: "type", expected: n, actual: "float" }), !1;
|
|
1980
|
+
if (P(n)) {
|
|
1981
|
+
const u = W[n], i = typeof t == "bigint" ? t : BigInt(Math.round(t));
|
|
1982
|
+
(i < u.min || i > u.max) && a.push({
|
|
1983
|
+
path: s,
|
|
1984
|
+
type: "integer_bounds",
|
|
1985
|
+
expected: { min: u.min.toString(), max: u.max.toString() },
|
|
1986
|
+
actual: i.toString(),
|
|
1987
|
+
context: { type: n }
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1990
|
+
return this.validateNumericConstraints(t, r, s, a), !0;
|
|
1991
|
+
}
|
|
1992
|
+
validateFloat(t, n, r, s) {
|
|
1993
|
+
return typeof t != "number" ? !1 : (this.validateNumericConstraints(t, n, r, s), !0);
|
|
1994
|
+
}
|
|
1995
|
+
validateNumericConstraints(t, n, r, s) {
|
|
1996
|
+
const a = n, u = typeof t == "bigint" ? Number(t) : t;
|
|
1997
|
+
if (a.minimum !== void 0) {
|
|
1998
|
+
const i = typeof a.minimum == "string" ? Number(a.minimum) : a.minimum;
|
|
1999
|
+
u < i && s.push({ path: r, type: "minimum", expected: i, actual: u });
|
|
2000
|
+
}
|
|
2001
|
+
if (a.maximum !== void 0) {
|
|
2002
|
+
const i = typeof a.maximum == "string" ? Number(a.maximum) : a.maximum;
|
|
2003
|
+
u > i && s.push({ path: r, type: "maximum", expected: i, actual: u });
|
|
2004
|
+
}
|
|
2005
|
+
if (a.exclusiveMinimum !== void 0) {
|
|
2006
|
+
const i = typeof a.exclusiveMinimum == "string" ? Number(a.exclusiveMinimum) : a.exclusiveMinimum;
|
|
2007
|
+
u <= i && s.push({
|
|
2008
|
+
path: r,
|
|
2009
|
+
type: "exclusiveMinimum",
|
|
2010
|
+
expected: i,
|
|
2011
|
+
actual: u
|
|
2012
|
+
});
|
|
2013
|
+
}
|
|
2014
|
+
if (a.exclusiveMaximum !== void 0) {
|
|
2015
|
+
const i = typeof a.exclusiveMaximum == "string" ? Number(a.exclusiveMaximum) : a.exclusiveMaximum;
|
|
2016
|
+
u >= i && s.push({
|
|
2017
|
+
path: r,
|
|
2018
|
+
type: "exclusiveMaximum",
|
|
2019
|
+
expected: i,
|
|
2020
|
+
actual: u
|
|
2021
|
+
});
|
|
2022
|
+
}
|
|
2023
|
+
a.multipleOf !== void 0 && typeof t == "number" && t % a.multipleOf !== 0 && s.push({
|
|
2024
|
+
path: r,
|
|
2025
|
+
type: "multipleOf",
|
|
2026
|
+
expected: a.multipleOf,
|
|
2027
|
+
actual: t
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
validateTemporal(t, n, r, s) {
|
|
2031
|
+
if (typeof t != "string") return !1;
|
|
2032
|
+
const u = {
|
|
2033
|
+
date: /^\d{4}-\d{2}-\d{2}$/,
|
|
2034
|
+
datetime: /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/,
|
|
2035
|
+
time: /^\d{2}:\d{2}:\d{2}(\.\d+)?$/,
|
|
2036
|
+
duration: /^P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(\d+H)?(\d+M)?(\d+S)?)?$/
|
|
2037
|
+
}[n];
|
|
2038
|
+
return u && !u.test(t) ? (s.push({ path: r, type: "format", expected: n, actual: t }), !1) : !0;
|
|
2039
|
+
}
|
|
2040
|
+
validateUuid(t, n, r) {
|
|
2041
|
+
return typeof t != "string" ? !1 : /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t) ? !0 : (r.push({ path: n, type: "format", expected: "uuid", actual: t }), !1);
|
|
2042
|
+
}
|
|
2043
|
+
validateUri(t, n, r) {
|
|
2044
|
+
if (typeof t != "string") return !1;
|
|
2045
|
+
try {
|
|
2046
|
+
return new URL(t), !0;
|
|
2047
|
+
} catch {
|
|
2048
|
+
return r.push({ path: n, type: "format", expected: "uri", actual: t }), !1;
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
validateBinary(t, n, r) {
|
|
2052
|
+
return t instanceof Uint8Array ? !0 : typeof t != "string" ? !1 : /^[A-Za-z0-9+/]*={0,2}$/.test(t) ? !0 : (r.push({ path: n, type: "format", expected: "binary", actual: t }), !1);
|
|
2053
|
+
}
|
|
2054
|
+
validateObject(t, n, r, s) {
|
|
2055
|
+
if (typeof t != "object" || t === null || Array.isArray(t))
|
|
2056
|
+
return !1;
|
|
2057
|
+
if (!k(n)) return !0;
|
|
2058
|
+
const a = t, u = n.required;
|
|
2059
|
+
if (u) {
|
|
2060
|
+
const i = Array.isArray(u[0]) ? u.flat() : u;
|
|
2061
|
+
for (const o of i)
|
|
2062
|
+
o in a || s.push({
|
|
2063
|
+
path: r ? `${r}/${o}` : `/${o}`,
|
|
2064
|
+
type: "required",
|
|
2065
|
+
expected: o
|
|
2066
|
+
});
|
|
2067
|
+
}
|
|
2068
|
+
for (const [i, o] of Object.entries(a)) {
|
|
2069
|
+
const c = n.properties?.[i];
|
|
2070
|
+
if (c) {
|
|
2071
|
+
const l = r ? `${r}/${i}` : `/${i}`;
|
|
2072
|
+
this.validateValue(o, c, l, s);
|
|
2073
|
+
} else if (n.additionalProperties === !1)
|
|
2074
|
+
s.push({
|
|
2075
|
+
path: r ? `${r}/${i}` : `/${i}`,
|
|
2076
|
+
type: "additionalProperties",
|
|
2077
|
+
actual: i
|
|
2078
|
+
});
|
|
2079
|
+
else if (typeof n.additionalProperties == "object") {
|
|
2080
|
+
const l = r ? `${r}/${i}` : `/${i}`;
|
|
2081
|
+
this.validateValue(
|
|
2082
|
+
o,
|
|
2083
|
+
n.additionalProperties,
|
|
2084
|
+
l,
|
|
2085
|
+
s
|
|
2086
|
+
);
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
return !0;
|
|
2090
|
+
}
|
|
2091
|
+
validateArray(t, n, r, s) {
|
|
2092
|
+
if (!Array.isArray(t)) return !1;
|
|
2093
|
+
if (!ge(n)) return !0;
|
|
2094
|
+
const a = n;
|
|
2095
|
+
a.minItems !== void 0 && t.length < a.minItems && s.push({
|
|
2096
|
+
path: r,
|
|
2097
|
+
type: "minItems",
|
|
2098
|
+
expected: a.minItems,
|
|
2099
|
+
actual: t.length
|
|
2100
|
+
}), a.maxItems !== void 0 && t.length > a.maxItems && s.push({
|
|
2101
|
+
path: r,
|
|
2102
|
+
type: "maxItems",
|
|
2103
|
+
expected: a.maxItems,
|
|
2104
|
+
actual: t.length
|
|
2105
|
+
});
|
|
2106
|
+
for (let u = 0; u < t.length; u++) {
|
|
2107
|
+
const i = `${r}/${u}`;
|
|
2108
|
+
this.validateValue(t[u], n.items, i, s);
|
|
2109
|
+
}
|
|
2110
|
+
return !0;
|
|
2111
|
+
}
|
|
2112
|
+
validateSet(t, n, r, s) {
|
|
2113
|
+
if (!Array.isArray(t)) return !1;
|
|
2114
|
+
if (!he(n)) return !0;
|
|
2115
|
+
const a = /* @__PURE__ */ new Set();
|
|
2116
|
+
for (let u = 0; u < t.length; u++) {
|
|
2117
|
+
const i = JSON.stringify(t[u]);
|
|
2118
|
+
a.has(i) && s.push({
|
|
2119
|
+
path: `${r}/${u}`,
|
|
2120
|
+
type: "uniqueItems",
|
|
2121
|
+
actual: t[u]
|
|
2122
|
+
}), a.add(i);
|
|
2123
|
+
}
|
|
2124
|
+
return this.validateArray(t, n, r, s);
|
|
2125
|
+
}
|
|
2126
|
+
validateMap(t, n, r, s) {
|
|
2127
|
+
if (typeof t != "object" || t === null || Array.isArray(t))
|
|
2128
|
+
return !1;
|
|
2129
|
+
if (!be(n)) return !0;
|
|
2130
|
+
const a = t;
|
|
2131
|
+
for (const [u, i] of Object.entries(a)) {
|
|
2132
|
+
const o = `${r}/${u}`;
|
|
2133
|
+
this.validateValue(i, n.values, o, s);
|
|
2134
|
+
}
|
|
2135
|
+
return !0;
|
|
2136
|
+
}
|
|
2137
|
+
validateTuple(t, n, r, s) {
|
|
2138
|
+
if (!Array.isArray(t)) return !1;
|
|
2139
|
+
if (!ve(n)) return !0;
|
|
2140
|
+
const a = n.tuple.length;
|
|
2141
|
+
t.length !== a && s.push({
|
|
2142
|
+
path: r,
|
|
2143
|
+
type: "tuple_length",
|
|
2144
|
+
expected: a,
|
|
2145
|
+
actual: t.length
|
|
2146
|
+
});
|
|
2147
|
+
for (let u = 0; u < n.tuple.length; u++) {
|
|
2148
|
+
const i = n.tuple[u], o = n.properties?.[i];
|
|
2149
|
+
o && u < t.length && this.validateValue(t[u], o, `${r}/${u}`, s);
|
|
2150
|
+
}
|
|
2151
|
+
return !0;
|
|
2152
|
+
}
|
|
2153
|
+
validateChoice(t, n, r, s) {
|
|
2154
|
+
if (typeof t != "object" || t === null || Array.isArray(t))
|
|
2155
|
+
return !1;
|
|
2156
|
+
if (!xe(n)) return !0;
|
|
2157
|
+
const a = t, u = Object.keys(n.choices), i = Object.keys(a).find((c) => u.includes(c));
|
|
2158
|
+
if (!i)
|
|
2159
|
+
return s.push({
|
|
2160
|
+
path: r,
|
|
2161
|
+
type: "choice",
|
|
2162
|
+
expected: u,
|
|
2163
|
+
actual: Object.keys(a)
|
|
2164
|
+
}), !1;
|
|
2165
|
+
const o = n.choices[i];
|
|
2166
|
+
return o && this.validateValue(
|
|
2167
|
+
a[i],
|
|
2168
|
+
o,
|
|
2169
|
+
`${r}/${i}`,
|
|
2170
|
+
s
|
|
2171
|
+
), !0;
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
function lr(e, t, n) {
|
|
2175
|
+
return Ee(e, n).validate(t);
|
|
2176
|
+
}
|
|
2177
|
+
function Mn(e, t) {
|
|
2178
|
+
const n = Dn(e, t);
|
|
2179
|
+
return {
|
|
2180
|
+
path: e.path,
|
|
2181
|
+
message: n,
|
|
2182
|
+
code: e.type
|
|
2183
|
+
};
|
|
2184
|
+
}
|
|
2185
|
+
function Ue(e, t) {
|
|
2186
|
+
return e.map((n) => {
|
|
2187
|
+
const r = t?.get(n.path);
|
|
2188
|
+
return Mn(n, r);
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2191
|
+
function Dn(e, t) {
|
|
2192
|
+
switch (e.type) {
|
|
2193
|
+
// Type errors
|
|
2194
|
+
case "type":
|
|
2195
|
+
return `Expected ${ce(e.expected)}, got ${Sn(e.actual)}`;
|
|
2196
|
+
case "type_mismatch":
|
|
2197
|
+
return `Value must be of type ${ce(e.expected)}`;
|
|
2198
|
+
// String validation
|
|
2199
|
+
case "minLength":
|
|
2200
|
+
return `Must be at least ${e.expected} characters`;
|
|
2201
|
+
case "maxLength":
|
|
2202
|
+
return `Must be no more than ${e.expected} characters`;
|
|
2203
|
+
case "pattern":
|
|
2204
|
+
return On(e, t);
|
|
2205
|
+
case "format":
|
|
2206
|
+
return Cn(e);
|
|
2207
|
+
// Numeric validation
|
|
2208
|
+
case "minimum":
|
|
2209
|
+
return `Must be at least ${e.expected}`;
|
|
2210
|
+
case "maximum":
|
|
2211
|
+
return `Must be at most ${e.expected}`;
|
|
2212
|
+
case "exclusiveMinimum":
|
|
2213
|
+
return `Must be greater than ${e.expected}`;
|
|
2214
|
+
case "exclusiveMaximum":
|
|
2215
|
+
return `Must be less than ${e.expected}`;
|
|
2216
|
+
case "multipleOf":
|
|
2217
|
+
return `Must be a multiple of ${e.expected}`;
|
|
2218
|
+
case "integer_bounds":
|
|
2219
|
+
return Rn(e);
|
|
2220
|
+
// Array/Set validation
|
|
2221
|
+
case "minItems":
|
|
2222
|
+
return `Must have at least ${e.expected} items`;
|
|
2223
|
+
case "maxItems":
|
|
2224
|
+
return `Must have no more than ${e.expected} items`;
|
|
2225
|
+
case "uniqueItems":
|
|
2226
|
+
return "All items must be unique";
|
|
2227
|
+
case "contains":
|
|
2228
|
+
return "Must contain at least one matching item";
|
|
2229
|
+
case "minContains":
|
|
2230
|
+
return `Must contain at least ${e.expected} matching items`;
|
|
2231
|
+
case "maxContains":
|
|
2232
|
+
return `Must contain no more than ${e.expected} matching items`;
|
|
2233
|
+
// Object validation
|
|
2234
|
+
case "required":
|
|
2235
|
+
return "This field is required";
|
|
2236
|
+
case "minProperties":
|
|
2237
|
+
return `Must have at least ${e.expected} properties`;
|
|
2238
|
+
case "maxProperties":
|
|
2239
|
+
return `Must have no more than ${e.expected} properties`;
|
|
2240
|
+
case "additionalProperties":
|
|
2241
|
+
return `Unknown property: ${e.actual}`;
|
|
2242
|
+
case "dependentRequired":
|
|
2243
|
+
return kn(e);
|
|
2244
|
+
// Enum/Const validation
|
|
2245
|
+
case "enum":
|
|
2246
|
+
return Nn(e);
|
|
2247
|
+
case "const":
|
|
2248
|
+
return `Must be exactly ${JSON.stringify(e.expected)}`;
|
|
2249
|
+
// Reference errors
|
|
2250
|
+
case "ref_not_found":
|
|
2251
|
+
return `Invalid reference: ${e.expected}`;
|
|
2252
|
+
case "circular_ref":
|
|
2253
|
+
return "Circular reference detected";
|
|
2254
|
+
// Generic
|
|
2255
|
+
case "invalid":
|
|
2256
|
+
return "Invalid value";
|
|
2257
|
+
default:
|
|
2258
|
+
return e.context?.message ?? `Validation error: ${e.type}`;
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
function ce(e) {
|
|
2262
|
+
return typeof e == "string" ? le(e) : Array.isArray(e) ? e.map(le).join(" or ") : String(e);
|
|
2263
|
+
}
|
|
2264
|
+
function Sn(e) {
|
|
2265
|
+
return e === null ? "null" : e === void 0 ? "undefined" : typeof e;
|
|
2266
|
+
}
|
|
2267
|
+
function le(e) {
|
|
2268
|
+
return {
|
|
2269
|
+
string: "text",
|
|
2270
|
+
boolean: "true/false",
|
|
2271
|
+
int8: "integer (-128 to 127)",
|
|
2272
|
+
int16: "integer (-32768 to 32767)",
|
|
2273
|
+
int32: "integer",
|
|
2274
|
+
int64: "large integer",
|
|
2275
|
+
int128: "very large integer",
|
|
2276
|
+
uint8: "positive integer (0 to 255)",
|
|
2277
|
+
uint16: "positive integer (0 to 65535)",
|
|
2278
|
+
uint32: "positive integer",
|
|
2279
|
+
uint64: "large positive integer",
|
|
2280
|
+
uint128: "very large positive integer",
|
|
2281
|
+
float: "decimal number",
|
|
2282
|
+
double: "decimal number",
|
|
2283
|
+
decimal: "decimal number",
|
|
2284
|
+
date: "date",
|
|
2285
|
+
datetime: "date and time",
|
|
2286
|
+
time: "time",
|
|
2287
|
+
duration: "duration",
|
|
2288
|
+
uuid: "UUID",
|
|
2289
|
+
uri: "URL",
|
|
2290
|
+
binary: "binary data",
|
|
2291
|
+
object: "object",
|
|
2292
|
+
array: "list",
|
|
2293
|
+
set: "unique list",
|
|
2294
|
+
map: "key-value pairs",
|
|
2295
|
+
tuple: "ordered list",
|
|
2296
|
+
choice: "one of multiple options",
|
|
2297
|
+
any: "any value",
|
|
2298
|
+
null: "empty"
|
|
2299
|
+
}[e] ?? e;
|
|
2300
|
+
}
|
|
2301
|
+
function On(e, t) {
|
|
2302
|
+
const n = t?.description;
|
|
2303
|
+
if (n && e.type === "pattern")
|
|
2304
|
+
return `Does not match required format: ${n}`;
|
|
2305
|
+
const r = e.expected;
|
|
2306
|
+
if (r) {
|
|
2307
|
+
const a = {
|
|
2308
|
+
"^[a-zA-Z]+$": "letters only",
|
|
2309
|
+
"^[0-9]+$": "numbers only",
|
|
2310
|
+
"^[a-zA-Z0-9]+$": "letters and numbers only",
|
|
2311
|
+
"^\\S+$": "no spaces allowed",
|
|
2312
|
+
"^[a-z]+$": "lowercase letters only",
|
|
2313
|
+
"^[A-Z]+$": "uppercase letters only"
|
|
2314
|
+
}[r];
|
|
2315
|
+
if (a)
|
|
2316
|
+
return `Must be ${a}`;
|
|
2317
|
+
}
|
|
2318
|
+
return "Does not match required format";
|
|
2319
|
+
}
|
|
2320
|
+
function Cn(e) {
|
|
2321
|
+
const t = e.expected;
|
|
2322
|
+
return {
|
|
2323
|
+
email: "Must be a valid email address",
|
|
2324
|
+
"date-time": "Must be a valid date and time",
|
|
2325
|
+
date: "Must be a valid date",
|
|
2326
|
+
time: "Must be a valid time",
|
|
2327
|
+
uri: "Must be a valid URL",
|
|
2328
|
+
"uri-reference": "Must be a valid URL or relative path",
|
|
2329
|
+
uuid: "Must be a valid UUID",
|
|
2330
|
+
hostname: "Must be a valid hostname",
|
|
2331
|
+
ipv4: "Must be a valid IPv4 address",
|
|
2332
|
+
ipv6: "Must be a valid IPv6 address",
|
|
2333
|
+
regex: "Must be a valid regular expression",
|
|
2334
|
+
"json-pointer": "Must be a valid JSON pointer"
|
|
2335
|
+
}[t] ?? `Must be a valid ${t}`;
|
|
2336
|
+
}
|
|
2337
|
+
function Rn(e) {
|
|
2338
|
+
const t = e.context?.type;
|
|
2339
|
+
if (t && P(t)) {
|
|
2340
|
+
const n = W[t];
|
|
2341
|
+
return `Must be between ${n.min} and ${n.max}`;
|
|
2342
|
+
}
|
|
2343
|
+
return "Value is out of range for this integer type";
|
|
2344
|
+
}
|
|
2345
|
+
function kn(e) {
|
|
2346
|
+
const t = e.context?.dependent, n = e.context?.required;
|
|
2347
|
+
return t && n?.length ? `When "${t}" is present, "${n.join('", "')}" must also be provided` : "Missing required dependent fields";
|
|
2348
|
+
}
|
|
2349
|
+
function Nn(e) {
|
|
2350
|
+
const t = e.expected;
|
|
2351
|
+
return t && t.length <= 5 ? `Must be one of: ${t.map((r) => JSON.stringify(r)).join(", ")}` : "Invalid value";
|
|
2352
|
+
}
|
|
2353
|
+
function pr(e) {
|
|
2354
|
+
const t = /* @__PURE__ */ new Map();
|
|
2355
|
+
for (const n of e) {
|
|
2356
|
+
const r = t.get(n.path) ?? [];
|
|
2357
|
+
r.push(n), t.set(n.path, r);
|
|
2358
|
+
}
|
|
2359
|
+
return t;
|
|
2360
|
+
}
|
|
2361
|
+
function dr(e, t) {
|
|
2362
|
+
return e.filter((n) => n.path === t);
|
|
2363
|
+
}
|
|
2364
|
+
function fr(e, t) {
|
|
2365
|
+
return e.some((n) => n.path === t);
|
|
2366
|
+
}
|
|
2367
|
+
function mr(e, t) {
|
|
2368
|
+
const n = t === "" ? "/" : `${t}/`;
|
|
2369
|
+
return e.filter((r) => r.path.startsWith(n));
|
|
2370
|
+
}
|
|
2371
|
+
class _ {
|
|
2372
|
+
registrations = /* @__PURE__ */ new Map();
|
|
2373
|
+
parent;
|
|
2374
|
+
constructor(t) {
|
|
2375
|
+
this.parent = t ?? null;
|
|
2376
|
+
}
|
|
2377
|
+
register(t, n) {
|
|
2378
|
+
this.registrations.set(t, n);
|
|
2379
|
+
}
|
|
2380
|
+
unregister(t) {
|
|
2381
|
+
this.registrations.delete(t);
|
|
2382
|
+
}
|
|
2383
|
+
get(t) {
|
|
2384
|
+
return this.registrations.get(t) ?? this.parent?.get(t);
|
|
2385
|
+
}
|
|
2386
|
+
has(t) {
|
|
2387
|
+
return this.registrations.has(t) || (this.parent?.has(t) ?? !1);
|
|
2388
|
+
}
|
|
2389
|
+
names() {
|
|
2390
|
+
const t = this.parent?.names() ?? [], n = Array.from(this.registrations.keys());
|
|
2391
|
+
return [.../* @__PURE__ */ new Set([...t, ...n])];
|
|
2392
|
+
}
|
|
2393
|
+
getForType(t) {
|
|
2394
|
+
const n = [];
|
|
2395
|
+
this.parent && n.push(...this.parent.getForType(t));
|
|
2396
|
+
for (const r of this.registrations.values())
|
|
2397
|
+
r.supportedTypes?.includes(t) && n.push(r);
|
|
2398
|
+
return n;
|
|
2399
|
+
}
|
|
2400
|
+
getForFormat(t) {
|
|
2401
|
+
const n = [];
|
|
2402
|
+
this.parent && n.push(...this.parent.getForFormat(t));
|
|
2403
|
+
for (const r of this.registrations.values())
|
|
2404
|
+
r.supportedFormats?.includes(t) && n.push(r);
|
|
2405
|
+
return n;
|
|
2406
|
+
}
|
|
2407
|
+
findBestWidget(t) {
|
|
2408
|
+
const n = [];
|
|
2409
|
+
for (const s of this.names()) {
|
|
2410
|
+
const a = this.get(s);
|
|
2411
|
+
if (!a) continue;
|
|
2412
|
+
const u = this.scoreWidget(a, t);
|
|
2413
|
+
u > 0 && n.push({ name: s, registration: a, score: u });
|
|
2414
|
+
}
|
|
2415
|
+
if (n.length === 0)
|
|
2416
|
+
return null;
|
|
2417
|
+
n.sort((s, a) => a.score !== s.score ? a.score - s.score : (a.registration.priority ?? 0) - (s.registration.priority ?? 0));
|
|
2418
|
+
const r = n[0];
|
|
2419
|
+
return { name: r.name, registration: r.registration };
|
|
2420
|
+
}
|
|
2421
|
+
/**
|
|
2422
|
+
* Score how well a widget matches the context
|
|
2423
|
+
*/
|
|
2424
|
+
scoreWidget(t, n) {
|
|
2425
|
+
let r = 0;
|
|
2426
|
+
if (t.matcher)
|
|
2427
|
+
if (t.matcher(n))
|
|
2428
|
+
r += 100;
|
|
2429
|
+
else
|
|
2430
|
+
return 0;
|
|
2431
|
+
const s = n.primaryType;
|
|
2432
|
+
s && t.supportedTypes?.includes(s) && (r += 50);
|
|
2433
|
+
const a = n.format;
|
|
2434
|
+
return a && t.supportedFormats?.includes(a) && (r += 30), r += t.priority ?? 0, r;
|
|
2435
|
+
}
|
|
2436
|
+
createChild() {
|
|
2437
|
+
return new _(this);
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
let L = null;
|
|
2441
|
+
function F() {
|
|
2442
|
+
return L || (L = new _()), L;
|
|
2443
|
+
}
|
|
2444
|
+
function yr(e) {
|
|
2445
|
+
L = e;
|
|
2446
|
+
}
|
|
2447
|
+
function gr(e) {
|
|
2448
|
+
return new _(e);
|
|
2449
|
+
}
|
|
2450
|
+
function hr(e, t, n) {
|
|
2451
|
+
return {
|
|
2452
|
+
name: `type:${e}`,
|
|
2453
|
+
registration: {
|
|
2454
|
+
factory: t,
|
|
2455
|
+
displayName: n?.displayName ?? `${e} widget`,
|
|
2456
|
+
description: n?.description,
|
|
2457
|
+
supportedTypes: [e],
|
|
2458
|
+
priority: n?.priority ?? 0,
|
|
2459
|
+
canFallback: n?.canFallback ?? !1
|
|
2460
|
+
}
|
|
2461
|
+
};
|
|
2462
|
+
}
|
|
2463
|
+
function br(e, t, n) {
|
|
2464
|
+
return {
|
|
2465
|
+
name: `format:${e}`,
|
|
2466
|
+
registration: {
|
|
2467
|
+
factory: t,
|
|
2468
|
+
displayName: n?.displayName ?? `${e} widget`,
|
|
2469
|
+
description: n?.description,
|
|
2470
|
+
supportedFormats: [e],
|
|
2471
|
+
priority: n?.priority ?? 10,
|
|
2472
|
+
// Format widgets have higher priority than type widgets
|
|
2473
|
+
canFallback: n?.canFallback ?? !1
|
|
2474
|
+
}
|
|
2475
|
+
};
|
|
2476
|
+
}
|
|
2477
|
+
function vr(e, t, n, r) {
|
|
2478
|
+
return {
|
|
2479
|
+
name: `type:${e}:format:${t}`,
|
|
2480
|
+
registration: {
|
|
2481
|
+
factory: n,
|
|
2482
|
+
displayName: r?.displayName ?? `${e}/${t} widget`,
|
|
2483
|
+
description: r?.description,
|
|
2484
|
+
supportedTypes: [e],
|
|
2485
|
+
supportedFormats: [t],
|
|
2486
|
+
priority: r?.priority ?? 20,
|
|
2487
|
+
// Type+format widgets have highest priority
|
|
2488
|
+
canFallback: r?.canFallback ?? !1
|
|
2489
|
+
}
|
|
2490
|
+
};
|
|
2491
|
+
}
|
|
2492
|
+
function xr(e, t, n, r) {
|
|
2493
|
+
return {
|
|
2494
|
+
name: e,
|
|
2495
|
+
registration: {
|
|
2496
|
+
factory: n,
|
|
2497
|
+
displayName: r?.displayName ?? e,
|
|
2498
|
+
description: r?.description,
|
|
2499
|
+
matcher: t,
|
|
2500
|
+
priority: r?.priority ?? 50,
|
|
2501
|
+
// Custom matchers have very high priority
|
|
2502
|
+
canFallback: r?.canFallback ?? !1
|
|
2503
|
+
}
|
|
2504
|
+
};
|
|
2505
|
+
}
|
|
2506
|
+
function qn(e, t) {
|
|
2507
|
+
if (t) {
|
|
2508
|
+
const r = t.findBestWidget(e);
|
|
2509
|
+
if (r)
|
|
2510
|
+
return r;
|
|
2511
|
+
}
|
|
2512
|
+
return F().findBestWidget(e);
|
|
2513
|
+
}
|
|
2514
|
+
function $r(e) {
|
|
2515
|
+
const t = e.definition, n = {};
|
|
2516
|
+
if (typeof t == "object" && "x:ui" in t) {
|
|
2517
|
+
const r = t["x:ui"];
|
|
2518
|
+
r.widget && typeof r.widget == "object" && (n.options = r.widget), typeof r.priority == "number" && (n.priority = r.priority);
|
|
2519
|
+
}
|
|
2520
|
+
if (typeof t == "object" && "widget" in t) {
|
|
2521
|
+
const r = t.widget;
|
|
2522
|
+
typeof r == "object" && r !== null && (n.options = {
|
|
2523
|
+
...n.options ?? {},
|
|
2524
|
+
...r
|
|
2525
|
+
});
|
|
2526
|
+
}
|
|
2527
|
+
return Object.keys(n).length > 0 ? n : void 0;
|
|
2528
|
+
}
|
|
2529
|
+
function Be(e) {
|
|
2530
|
+
const t = e.definition;
|
|
2531
|
+
if (typeof t == "object" && "x:ui" in t) {
|
|
2532
|
+
const n = t["x:ui"];
|
|
2533
|
+
if (typeof n.widget == "string")
|
|
2534
|
+
return n.widget;
|
|
2535
|
+
}
|
|
2536
|
+
if (typeof t == "object" && "widget" in t) {
|
|
2537
|
+
const n = t.widget;
|
|
2538
|
+
if (n && typeof n.type == "string")
|
|
2539
|
+
return n.type;
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
function Ir(e) {
|
|
2543
|
+
return Be(e) !== void 0;
|
|
2544
|
+
}
|
|
2545
|
+
function wr(e, t) {
|
|
2546
|
+
const n = Be(e);
|
|
2547
|
+
if (n) {
|
|
2548
|
+
if (t) {
|
|
2549
|
+
const a = t.get(n);
|
|
2550
|
+
if (a)
|
|
2551
|
+
return { name: n, registration: a };
|
|
2552
|
+
}
|
|
2553
|
+
const s = F().get(n);
|
|
2554
|
+
if (s)
|
|
2555
|
+
return { name: n, registration: s };
|
|
2556
|
+
console.warn(
|
|
2557
|
+
`Widget "${n}" specified in definition but not found in registry`,
|
|
2558
|
+
{ path: e.jsonPath }
|
|
2559
|
+
);
|
|
2560
|
+
}
|
|
2561
|
+
return qn(e, t);
|
|
2562
|
+
}
|
|
2563
|
+
function Tr(e, t, n) {
|
|
2564
|
+
return {
|
|
2565
|
+
...e,
|
|
2566
|
+
...t,
|
|
2567
|
+
...n
|
|
2568
|
+
};
|
|
2569
|
+
}
|
|
2570
|
+
function Pn(e = F()) {
|
|
2571
|
+
e.register("string", {
|
|
2572
|
+
factory: ({ controller: i, ctx: o }) => Ie({
|
|
2573
|
+
ctx: o,
|
|
2574
|
+
controller: i
|
|
2575
|
+
}),
|
|
2576
|
+
displayName: "String",
|
|
2577
|
+
description: "Text input for string values",
|
|
2578
|
+
supportedTypes: ["string"],
|
|
2579
|
+
priority: 0,
|
|
2580
|
+
canFallback: !0
|
|
2581
|
+
}), e.register("boolean", {
|
|
2582
|
+
factory: ({ controller: i, ctx: o }) => we({
|
|
2583
|
+
ctx: o,
|
|
2584
|
+
controller: i
|
|
2585
|
+
}),
|
|
2586
|
+
displayName: "Boolean",
|
|
2587
|
+
description: "Checkbox for boolean values",
|
|
2588
|
+
supportedTypes: ["boolean"],
|
|
2589
|
+
priority: 0,
|
|
2590
|
+
canFallback: !0
|
|
2591
|
+
}), e.register("uuid", {
|
|
2592
|
+
factory: ({ controller: i, ctx: o }) => De({
|
|
2593
|
+
ctx: o,
|
|
2594
|
+
controller: i
|
|
2595
|
+
}),
|
|
2596
|
+
displayName: "UUID",
|
|
2597
|
+
description: "Input for UUID values",
|
|
2598
|
+
supportedTypes: ["uuid"],
|
|
2599
|
+
priority: 0,
|
|
2600
|
+
canFallback: !0
|
|
2601
|
+
}), e.register("uri", {
|
|
2602
|
+
factory: ({ controller: i, ctx: o }) => Oe({
|
|
2603
|
+
ctx: o,
|
|
2604
|
+
controller: i
|
|
2605
|
+
}),
|
|
2606
|
+
displayName: "URI",
|
|
2607
|
+
description: "Input for URI/URL values",
|
|
2608
|
+
supportedTypes: ["uri"],
|
|
2609
|
+
priority: 0,
|
|
2610
|
+
canFallback: !0
|
|
2611
|
+
}), e.register("binary", {
|
|
2612
|
+
factory: ({ controller: i, ctx: o }) => Ce({
|
|
2613
|
+
ctx: o,
|
|
2614
|
+
controller: i
|
|
2615
|
+
}),
|
|
2616
|
+
displayName: "Binary",
|
|
2617
|
+
description: "File upload for binary data",
|
|
2618
|
+
supportedTypes: ["binary"],
|
|
2619
|
+
priority: 0,
|
|
2620
|
+
canFallback: !0
|
|
2621
|
+
}), e.register("any", {
|
|
2622
|
+
factory: ({ controller: i, ctx: o }) => K({
|
|
2623
|
+
ctx: o,
|
|
2624
|
+
controller: i
|
|
2625
|
+
}),
|
|
2626
|
+
displayName: "Any",
|
|
2627
|
+
description: "Generic control for any type",
|
|
2628
|
+
supportedTypes: ["any"],
|
|
2629
|
+
priority: 0,
|
|
2630
|
+
canFallback: !0
|
|
2631
|
+
});
|
|
2632
|
+
const t = [
|
|
2633
|
+
"int8",
|
|
2634
|
+
"int16",
|
|
2635
|
+
"int32",
|
|
2636
|
+
"int64",
|
|
2637
|
+
"int128",
|
|
2638
|
+
"uint8",
|
|
2639
|
+
"uint16",
|
|
2640
|
+
"uint32",
|
|
2641
|
+
"uint64",
|
|
2642
|
+
"uint128"
|
|
2643
|
+
], n = ({ controller: i, ctx: o }) => Ae({
|
|
2644
|
+
ctx: o,
|
|
2645
|
+
controller: i,
|
|
2646
|
+
intType: o.primaryType
|
|
2647
|
+
});
|
|
2648
|
+
for (const i of t)
|
|
2649
|
+
e.register(i, {
|
|
2650
|
+
factory: n,
|
|
2651
|
+
displayName: i.toUpperCase(),
|
|
2652
|
+
description: `Number input for ${i} values`,
|
|
2653
|
+
supportedTypes: [i],
|
|
2654
|
+
priority: 0,
|
|
2655
|
+
canFallback: !0
|
|
2656
|
+
});
|
|
2657
|
+
const r = ["float", "double", "decimal"], s = ({ controller: i, ctx: o }) => Me({
|
|
2658
|
+
ctx: o,
|
|
2659
|
+
controller: i,
|
|
2660
|
+
floatType: o.primaryType
|
|
2661
|
+
});
|
|
2662
|
+
for (const i of r)
|
|
2663
|
+
e.register(i, {
|
|
2664
|
+
factory: s,
|
|
2665
|
+
displayName: i.charAt(0).toUpperCase() + i.slice(1),
|
|
2666
|
+
description: `Number input for ${i} values`,
|
|
2667
|
+
supportedTypes: [i],
|
|
2668
|
+
priority: 0,
|
|
2669
|
+
canFallback: !0
|
|
2670
|
+
});
|
|
2671
|
+
const a = ["date", "datetime", "time", "duration"], u = ({ controller: i, ctx: o }) => Se({
|
|
2672
|
+
ctx: o,
|
|
2673
|
+
controller: i,
|
|
2674
|
+
temporalType: o.primaryType
|
|
2675
|
+
});
|
|
2676
|
+
for (const i of a)
|
|
2677
|
+
e.register(i, {
|
|
2678
|
+
factory: u,
|
|
2679
|
+
displayName: i.charAt(0).toUpperCase() + i.slice(1),
|
|
2680
|
+
description: `Input for ${i} values`,
|
|
2681
|
+
supportedTypes: [i],
|
|
2682
|
+
priority: 0,
|
|
2683
|
+
canFallback: !0
|
|
2684
|
+
});
|
|
2685
|
+
e.register("object", {
|
|
2686
|
+
factory: ({ controller: i, ctx: o }) => Re({
|
|
2687
|
+
ctx: o,
|
|
2688
|
+
controller: i
|
|
2689
|
+
}),
|
|
2690
|
+
displayName: "Object",
|
|
2691
|
+
description: "Form for object values",
|
|
2692
|
+
supportedTypes: ["object"],
|
|
2693
|
+
priority: 0,
|
|
2694
|
+
canFallback: !0
|
|
2695
|
+
}), e.register("array", {
|
|
2696
|
+
factory: ({ controller: i, ctx: o }) => ke({
|
|
2697
|
+
ctx: o,
|
|
2698
|
+
controller: i
|
|
2699
|
+
}),
|
|
2700
|
+
displayName: "Array",
|
|
2701
|
+
description: "List control for array values",
|
|
2702
|
+
supportedTypes: ["array"],
|
|
2703
|
+
priority: 0,
|
|
2704
|
+
canFallback: !0
|
|
2705
|
+
}), e.register("set", {
|
|
2706
|
+
factory: ({ controller: i, ctx: o }) => Ne({
|
|
2707
|
+
ctx: o,
|
|
2708
|
+
controller: i
|
|
2709
|
+
}),
|
|
2710
|
+
displayName: "Set",
|
|
2711
|
+
description: "Set control for unique values",
|
|
2712
|
+
supportedTypes: ["set"],
|
|
2713
|
+
priority: 0,
|
|
2714
|
+
canFallback: !0
|
|
2715
|
+
}), e.register("map", {
|
|
2716
|
+
factory: ({ controller: i, ctx: o }) => qe({
|
|
2717
|
+
ctx: o,
|
|
2718
|
+
controller: i
|
|
2719
|
+
}),
|
|
2720
|
+
displayName: "Map",
|
|
2721
|
+
description: "Map control for key-value pairs",
|
|
2722
|
+
supportedTypes: ["map"],
|
|
2723
|
+
priority: 0,
|
|
2724
|
+
canFallback: !0
|
|
2725
|
+
}), e.register("tuple", {
|
|
2726
|
+
factory: ({ controller: i, ctx: o }) => Pe({
|
|
2727
|
+
ctx: o,
|
|
2728
|
+
controller: i
|
|
2729
|
+
}),
|
|
2730
|
+
displayName: "Tuple",
|
|
2731
|
+
description: "Tuple control for fixed-length arrays",
|
|
2732
|
+
supportedTypes: ["tuple"],
|
|
2733
|
+
priority: 0,
|
|
2734
|
+
canFallback: !0
|
|
2735
|
+
}), e.register("choice", {
|
|
2736
|
+
factory: ({ controller: i, ctx: o }) => Fe({
|
|
2737
|
+
ctx: o,
|
|
2738
|
+
controller: i
|
|
2739
|
+
}),
|
|
2740
|
+
displayName: "Choice",
|
|
2741
|
+
description: "Choice control for union types",
|
|
2742
|
+
supportedTypes: ["choice"],
|
|
2743
|
+
priority: 0,
|
|
2744
|
+
canFallback: !0
|
|
2745
|
+
}), e.register("enum", {
|
|
2746
|
+
factory: ({ controller: i, ctx: o }) => Le({
|
|
2747
|
+
ctx: o,
|
|
2748
|
+
controller: i
|
|
2749
|
+
}),
|
|
2750
|
+
displayName: "Enum",
|
|
2751
|
+
description: "Dropdown for enumerated values",
|
|
2752
|
+
priority: 10,
|
|
2753
|
+
// Higher priority than base types
|
|
2754
|
+
canFallback: !1,
|
|
2755
|
+
matcher: (i) => i.hasEnum
|
|
2756
|
+
}), e.register("const", {
|
|
2757
|
+
factory: ({ controller: i, ctx: o }) => Ve({
|
|
2758
|
+
ctx: o,
|
|
2759
|
+
controller: i
|
|
2760
|
+
}),
|
|
2761
|
+
displayName: "Const",
|
|
2762
|
+
description: "Display for constant values",
|
|
2763
|
+
priority: 20,
|
|
2764
|
+
// Highest priority
|
|
2765
|
+
canFallback: !1,
|
|
2766
|
+
matcher: (i) => i.hasConst
|
|
2767
|
+
});
|
|
2768
|
+
}
|
|
2769
|
+
function Fn(e = F()) {
|
|
2770
|
+
return e.has("string") && e.has("object") && e.has("array");
|
|
2771
|
+
}
|
|
2772
|
+
function jr(e = F()) {
|
|
2773
|
+
Fn(e) || Pn(e);
|
|
2774
|
+
}
|
|
2775
|
+
function Ln(e) {
|
|
2776
|
+
let t = e;
|
|
2777
|
+
if (e.$root) {
|
|
2778
|
+
const n = N(e.$root, e);
|
|
2779
|
+
n && (t = n);
|
|
2780
|
+
}
|
|
2781
|
+
return M(t, e, /* @__PURE__ */ new Set());
|
|
2782
|
+
}
|
|
2783
|
+
function M(e, t, n) {
|
|
2784
|
+
if (e.type && C(e.type)) {
|
|
2785
|
+
const r = e.type.$ref;
|
|
2786
|
+
if (n.has(r))
|
|
2787
|
+
return;
|
|
2788
|
+
n.add(r);
|
|
2789
|
+
const s = N(r, t);
|
|
2790
|
+
if (s) {
|
|
2791
|
+
const a = {
|
|
2792
|
+
...s,
|
|
2793
|
+
...e,
|
|
2794
|
+
type: s.type
|
|
2795
|
+
// Use resolved type, not the ref
|
|
2796
|
+
}, u = M(a, t, n);
|
|
2797
|
+
return n.delete(r), u;
|
|
2798
|
+
}
|
|
2799
|
+
n.delete(r);
|
|
2800
|
+
return;
|
|
2801
|
+
}
|
|
2802
|
+
return e.default !== void 0 ? e.default : Array.isArray(e.examples) && e.examples.length > 0 ? e.examples[0] : "const" in e && e.const !== void 0 ? e.const : "enum" in e && Array.isArray(e.enum) && e.enum.length > 0 ? e.enum[0] : Hn(e) ? null : Vn(e, t, n);
|
|
2803
|
+
}
|
|
2804
|
+
function Vn(e, t, n) {
|
|
2805
|
+
const r = We(e);
|
|
2806
|
+
if (k(e))
|
|
2807
|
+
return Un(e, t, n);
|
|
2808
|
+
if (r === "choice" && "choices" in e)
|
|
2809
|
+
return Bn(e, t, n);
|
|
2810
|
+
if (r === "tuple" && "tuple" in e && "properties" in e)
|
|
2811
|
+
return Wn(e, t, n);
|
|
2812
|
+
if (r === "array")
|
|
2813
|
+
return _n(e, t, n);
|
|
2814
|
+
if (r === "set")
|
|
2815
|
+
return zn(e, t, n);
|
|
2816
|
+
if (r === "map")
|
|
2817
|
+
return {};
|
|
2818
|
+
if (r === "string")
|
|
2819
|
+
return Gn(e);
|
|
2820
|
+
if (Xn(r))
|
|
2821
|
+
return Kn(e);
|
|
2822
|
+
if (Yn(r))
|
|
2823
|
+
return Jn(e);
|
|
2824
|
+
if (r === "boolean")
|
|
2825
|
+
return !1;
|
|
2826
|
+
if (r === "null")
|
|
2827
|
+
return null;
|
|
2828
|
+
if (Qn(r))
|
|
2829
|
+
return Zn(r);
|
|
2830
|
+
if (r === "uuid" || r === "uri" || r === "uri-reference" || r === "binary" || r === "bytes")
|
|
2831
|
+
return "";
|
|
2832
|
+
}
|
|
2833
|
+
function En(e) {
|
|
2834
|
+
if (!e || e.length === 0)
|
|
2835
|
+
return /* @__PURE__ */ new Set();
|
|
2836
|
+
if (Array.isArray(e[0])) {
|
|
2837
|
+
const t = e.flat();
|
|
2838
|
+
return new Set(t);
|
|
2839
|
+
}
|
|
2840
|
+
return new Set(e);
|
|
2841
|
+
}
|
|
2842
|
+
function Un(e, t, n) {
|
|
2843
|
+
if (!k(e))
|
|
2844
|
+
return {};
|
|
2845
|
+
const r = En(e.required), s = {};
|
|
2846
|
+
for (const [a, u] of Object.entries(e.properties))
|
|
2847
|
+
if (r.has(a))
|
|
2848
|
+
if (u.type && C(u.type)) {
|
|
2849
|
+
const i = u.type.$ref;
|
|
2850
|
+
if (n.has(i))
|
|
2851
|
+
continue;
|
|
2852
|
+
n.add(i);
|
|
2853
|
+
const o = N(i, t);
|
|
2854
|
+
if (o) {
|
|
2855
|
+
const c = {
|
|
2856
|
+
...o,
|
|
2857
|
+
...u,
|
|
2858
|
+
type: o.type
|
|
2859
|
+
}, l = M(c, t, n);
|
|
2860
|
+
l !== void 0 && (s[a] = l);
|
|
2861
|
+
}
|
|
2862
|
+
n.delete(i);
|
|
2863
|
+
} else {
|
|
2864
|
+
const i = M(u, t, n);
|
|
2865
|
+
i !== void 0 && (s[a] = i);
|
|
2866
|
+
}
|
|
2867
|
+
return s;
|
|
2868
|
+
}
|
|
2869
|
+
function Bn(e, t, n) {
|
|
2870
|
+
if (!("choices" in e))
|
|
2871
|
+
return;
|
|
2872
|
+
const r = e.choices, s = Object.keys(r);
|
|
2873
|
+
if (s.length === 0)
|
|
2874
|
+
return;
|
|
2875
|
+
const a = s[0], u = r[a];
|
|
2876
|
+
if ("selector" in e && e.selector) {
|
|
2877
|
+
const o = e.selector, c = M(u, t, n);
|
|
2878
|
+
return typeof c == "object" && c !== null ? {
|
|
2879
|
+
[o]: a,
|
|
2880
|
+
...c
|
|
2881
|
+
} : {
|
|
2882
|
+
[o]: a
|
|
2883
|
+
};
|
|
2884
|
+
}
|
|
2885
|
+
const i = M(u, t, n);
|
|
2886
|
+
return { [a]: i };
|
|
2887
|
+
}
|
|
2888
|
+
function Wn(e, t, n) {
|
|
2889
|
+
if (!("tuple" in e) || !("properties" in e))
|
|
2890
|
+
return {};
|
|
2891
|
+
const r = e.tuple, s = e.properties, a = new Set(
|
|
2892
|
+
e.required ?? r
|
|
2893
|
+
), u = {};
|
|
2894
|
+
for (const i of r) {
|
|
2895
|
+
if (!a.has(i))
|
|
2896
|
+
continue;
|
|
2897
|
+
const o = s[i];
|
|
2898
|
+
if (o) {
|
|
2899
|
+
const c = M(o, t, n);
|
|
2900
|
+
c !== void 0 && (u[i] = c);
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
return u;
|
|
2904
|
+
}
|
|
2905
|
+
function _n(e, t, n) {
|
|
2906
|
+
const r = ("minItems" in e ? e.minItems : 0) ?? 0;
|
|
2907
|
+
if (r === 0)
|
|
2908
|
+
return [];
|
|
2909
|
+
const s = "items" in e ? e.items : void 0;
|
|
2910
|
+
if (!s)
|
|
2911
|
+
return Array(r).fill(null);
|
|
2912
|
+
const a = M(s, t, n);
|
|
2913
|
+
return Array(r).fill(a ?? null);
|
|
2914
|
+
}
|
|
2915
|
+
function zn(e, t, n) {
|
|
2916
|
+
const r = ("minItems" in e ? e.minItems : 0) ?? 0;
|
|
2917
|
+
if (r === 0)
|
|
2918
|
+
return [];
|
|
2919
|
+
const s = "items" in e ? e.items : void 0;
|
|
2920
|
+
if (!s)
|
|
2921
|
+
return Array(r).fill(null);
|
|
2922
|
+
const a = M(s, t, n);
|
|
2923
|
+
return Array(r).fill(a ?? null);
|
|
2924
|
+
}
|
|
2925
|
+
function Gn(e) {
|
|
2926
|
+
switch ("format" in e ? e.format : void 0) {
|
|
2927
|
+
case "date":
|
|
2928
|
+
return _e();
|
|
2929
|
+
case "date-time":
|
|
2930
|
+
return ze();
|
|
2931
|
+
case "time":
|
|
2932
|
+
return "00:00:00";
|
|
2933
|
+
case "email":
|
|
2934
|
+
case "uri":
|
|
2935
|
+
case "uri-reference":
|
|
2936
|
+
case "uuid":
|
|
2937
|
+
default:
|
|
2938
|
+
return "";
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
function Kn(e) {
|
|
2942
|
+
const t = We(e), n = t === "int64" || t === "uint64" || t === "int128" || t === "uint128";
|
|
2943
|
+
let r = "minimum" in e ? e.minimum : void 0, s = "maximum" in e ? e.maximum : void 0;
|
|
2944
|
+
const a = "exclusiveMinimum" in e ? e.exclusiveMinimum : void 0, u = "exclusiveMaximum" in e ? e.exclusiveMaximum : void 0;
|
|
2945
|
+
a !== void 0 && (r = a + 1), u !== void 0 && (s = u - 1);
|
|
2946
|
+
let i;
|
|
2947
|
+
r !== void 0 && s !== void 0 ? i = Math.round((r + s) / 2) : r !== void 0 ? i = r : s !== void 0 ? i = 0 <= s ? 0 : s : i = 0;
|
|
2948
|
+
const o = "multipleOf" in e ? e.multipleOf : void 0;
|
|
2949
|
+
return o !== void 0 && o > 0 && (i = Math.round(i / o) * o, r !== void 0 && i < r && (i = Math.ceil(r / o) * o), s !== void 0 && i > s && (i = Math.floor(s / o) * o)), n ? BigInt(Math.round(i)) : Math.round(i);
|
|
2950
|
+
}
|
|
2951
|
+
function Jn(e) {
|
|
2952
|
+
let t = "minimum" in e ? e.minimum : void 0, n = "maximum" in e ? e.maximum : void 0;
|
|
2953
|
+
const r = "exclusiveMinimum" in e ? e.exclusiveMinimum : void 0, s = "exclusiveMaximum" in e ? e.exclusiveMaximum : void 0, a = "multipleOf" in e ? e.multipleOf : 1e-3;
|
|
2954
|
+
r !== void 0 && (t = r + a), s !== void 0 && (n = s - a);
|
|
2955
|
+
let u;
|
|
2956
|
+
t !== void 0 && n !== void 0 ? u = (t + n) / 2 : t !== void 0 ? u = t : n !== void 0 ? u = 0 <= n ? 0 : n : u = 0;
|
|
2957
|
+
const i = "multipleOf" in e ? e.multipleOf : void 0;
|
|
2958
|
+
return i !== void 0 && i > 0 && (u = Math.round(u / i) * i, t !== void 0 && u < t && (u = Math.ceil(t / i) * i), n !== void 0 && u > n && (u = Math.floor(n / i) * i)), u;
|
|
2959
|
+
}
|
|
2960
|
+
function Zn(e) {
|
|
2961
|
+
switch (e) {
|
|
2962
|
+
case "date":
|
|
2963
|
+
return _e();
|
|
2964
|
+
case "time":
|
|
2965
|
+
return "00:00:00";
|
|
2966
|
+
case "datetime":
|
|
2967
|
+
return ze();
|
|
2968
|
+
case "duration":
|
|
2969
|
+
return "PT0S";
|
|
2970
|
+
default:
|
|
2971
|
+
return "";
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
function Hn(e) {
|
|
2975
|
+
return Array.isArray(e.type) ? e.type.some(
|
|
2976
|
+
(t) => typeof t == "string" ? t === "null" : !1
|
|
2977
|
+
) : !1;
|
|
2978
|
+
}
|
|
2979
|
+
function We(e) {
|
|
2980
|
+
const t = e.type;
|
|
2981
|
+
if (typeof t == "string")
|
|
2982
|
+
return t;
|
|
2983
|
+
if (Array.isArray(t)) {
|
|
2984
|
+
for (const n of t)
|
|
2985
|
+
if (typeof n == "string" && n !== "null")
|
|
2986
|
+
return n;
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
function Xn(e) {
|
|
2990
|
+
return e ? [
|
|
2991
|
+
"int8",
|
|
2992
|
+
"int16",
|
|
2993
|
+
"int32",
|
|
2994
|
+
"int64",
|
|
2995
|
+
"int128",
|
|
2996
|
+
"uint8",
|
|
2997
|
+
"uint16",
|
|
2998
|
+
"uint32",
|
|
2999
|
+
"uint64",
|
|
3000
|
+
"uint128"
|
|
3001
|
+
].includes(e) : !1;
|
|
3002
|
+
}
|
|
3003
|
+
function Yn(e) {
|
|
3004
|
+
return e ? ["float", "double", "decimal"].includes(e) : !1;
|
|
3005
|
+
}
|
|
3006
|
+
function Qn(e) {
|
|
3007
|
+
return e ? ["date", "time", "datetime", "duration"].includes(e) : !1;
|
|
3008
|
+
}
|
|
3009
|
+
function _e() {
|
|
3010
|
+
return (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
3011
|
+
}
|
|
3012
|
+
function ze() {
|
|
3013
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
3014
|
+
}
|
|
3015
|
+
function er(e) {
|
|
3016
|
+
if (e.isValid)
|
|
3017
|
+
return ie.valid;
|
|
3018
|
+
const t = Ue(e.errors), n = /* @__PURE__ */ new Map();
|
|
3019
|
+
for (const u of t) {
|
|
3020
|
+
const i = n.get(u.path) || [];
|
|
3021
|
+
i.push(u), n.set(u.path, i);
|
|
3022
|
+
}
|
|
3023
|
+
const r = (u, i) => {
|
|
3024
|
+
if (u.length === 0)
|
|
3025
|
+
return {
|
|
3026
|
+
message: i.map((y) => y.message).join("; ")
|
|
3027
|
+
};
|
|
3028
|
+
const [o, ...c] = u, l = r(c, i);
|
|
3029
|
+
return {
|
|
3030
|
+
dependencies: {
|
|
3031
|
+
[o]: l
|
|
3032
|
+
}
|
|
3033
|
+
};
|
|
3034
|
+
}, s = {}, a = {};
|
|
3035
|
+
for (const [u, i] of n.entries())
|
|
3036
|
+
if (u === "" || u === "/")
|
|
3037
|
+
s.message = i.map((o) => o.message).join("; ");
|
|
3038
|
+
else {
|
|
3039
|
+
const o = u.split("/").filter((c) => c !== "");
|
|
3040
|
+
if (o.length === 1)
|
|
3041
|
+
a[o[0]] = {
|
|
3042
|
+
message: i.map((c) => c.message).join("; ")
|
|
3043
|
+
};
|
|
3044
|
+
else {
|
|
3045
|
+
const [c, ...l] = o;
|
|
3046
|
+
a[c] = r(l, i);
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
return Object.keys(a).length > 0 && (s.dependencies = a), ie.invalid(s);
|
|
3050
|
+
}
|
|
3051
|
+
function Ar({
|
|
3052
|
+
schema: e,
|
|
3053
|
+
initialValue: t,
|
|
3054
|
+
validationMode: n,
|
|
3055
|
+
validateDebounceMs: r,
|
|
3056
|
+
widgetRegistry: s,
|
|
3057
|
+
readOnly: a,
|
|
3058
|
+
locale: u,
|
|
3059
|
+
onChange: i,
|
|
3060
|
+
onValidate: o,
|
|
3061
|
+
applySchemaDefaults: c = !0
|
|
3062
|
+
}, l) {
|
|
3063
|
+
const y = t !== void 0 ? I.get(t) : void 0, h = Ln(e);
|
|
3064
|
+
let f;
|
|
3065
|
+
t === void 0 ? f = h ?? {} : c ? f = rt(
|
|
3066
|
+
h,
|
|
3067
|
+
y
|
|
3068
|
+
) : f = y;
|
|
3069
|
+
const g = Ee(e), d = n ?? "onTouched", v = (R) => {
|
|
3070
|
+
const x = g.validate(R);
|
|
3071
|
+
if (o && !x.isValid) {
|
|
3072
|
+
const O = Ue(x.errors);
|
|
3073
|
+
o(O);
|
|
3074
|
+
}
|
|
3075
|
+
return er(x);
|
|
3076
|
+
}, { controller: $, setStatus: A } = ct({
|
|
3077
|
+
initialValue: f,
|
|
3078
|
+
validationMode: d,
|
|
3079
|
+
validateDebounceMs: r,
|
|
3080
|
+
validate: d === "onSubmit" ? void 0 : v,
|
|
3081
|
+
onChange: i
|
|
3082
|
+
}), S = H(
|
|
3083
|
+
at(() => {
|
|
3084
|
+
$.dispose();
|
|
3085
|
+
}),
|
|
3086
|
+
wn({
|
|
3087
|
+
schema: e,
|
|
3088
|
+
controller: $,
|
|
3089
|
+
widgetRegistry: s,
|
|
3090
|
+
readOnly: a,
|
|
3091
|
+
locale: u
|
|
3092
|
+
})
|
|
3093
|
+
);
|
|
3094
|
+
return l({ Form: S, controller: $, setStatus: A });
|
|
3095
|
+
}
|
|
3096
|
+
export {
|
|
3097
|
+
_ as DefaultWidgetRegistry,
|
|
3098
|
+
W as INTEGER_BOUNDS,
|
|
3099
|
+
Ar as JSONStructureForm,
|
|
3100
|
+
Rt as RefResolver,
|
|
3101
|
+
te as StructureContext,
|
|
3102
|
+
wn as StructureControl,
|
|
3103
|
+
j as StructureGenericControl,
|
|
3104
|
+
cr as createExtendsResolver,
|
|
3105
|
+
ee as createRefResolver,
|
|
3106
|
+
kt as createStructureContext,
|
|
3107
|
+
Ee as createValidator,
|
|
3108
|
+
gr as createWidgetRegistry,
|
|
3109
|
+
jr as ensureDefaultWidgets,
|
|
3110
|
+
Ln as extractStructureDefaults,
|
|
3111
|
+
br as forFormat,
|
|
3112
|
+
xr as forMatcher,
|
|
3113
|
+
hr as forType,
|
|
3114
|
+
vr as forTypeAndFormat,
|
|
3115
|
+
Mn as formatValidationError,
|
|
3116
|
+
Ue as formatValidationErrors,
|
|
3117
|
+
mr as getChildErrors,
|
|
3118
|
+
dr as getErrorsForPath,
|
|
3119
|
+
Be as getExplicitWidgetName,
|
|
3120
|
+
F as getGlobalWidgetRegistry,
|
|
3121
|
+
Q as getNonNullTypes,
|
|
3122
|
+
se as getResolvedType,
|
|
3123
|
+
$r as getWidgetOptions,
|
|
3124
|
+
pr as groupErrorsByPath,
|
|
3125
|
+
Dt as hasConstValue,
|
|
3126
|
+
Ir as hasCustomWidget,
|
|
3127
|
+
Fn as hasDefaultWidgets,
|
|
3128
|
+
Mt as hasEnumValue,
|
|
3129
|
+
fr as hasErrorsAtPath,
|
|
3130
|
+
ge as isArrayTypeDefinition,
|
|
3131
|
+
It as isBigIntType,
|
|
3132
|
+
xe as isChoiceTypeDefinition,
|
|
3133
|
+
ur as isCompoundType,
|
|
3134
|
+
X as isFloatType,
|
|
3135
|
+
P as isIntegerType,
|
|
3136
|
+
be as isMapTypeDefinition,
|
|
3137
|
+
jt as isNamespace,
|
|
3138
|
+
St as isNullableType,
|
|
3139
|
+
wt as isNumericType,
|
|
3140
|
+
k as isObjectTypeDefinition,
|
|
3141
|
+
Tt as isPrimitiveType,
|
|
3142
|
+
he as isSetTypeDefinition,
|
|
3143
|
+
Y as isTemporalType,
|
|
3144
|
+
ve as isTupleTypeDefinition,
|
|
3145
|
+
At as isTypeDefinition,
|
|
3146
|
+
C as isTypeReference,
|
|
3147
|
+
Tr as mergeWidgetOptions,
|
|
3148
|
+
Ot as parseRefPath,
|
|
3149
|
+
Pn as registerDefaultWidgets,
|
|
3150
|
+
$e as resolveExtends,
|
|
3151
|
+
N as resolveRef,
|
|
3152
|
+
or as resolveTypeReference,
|
|
3153
|
+
qn as resolveWidget,
|
|
3154
|
+
wr as resolveWidgetWithOverride,
|
|
3155
|
+
yr as setGlobalWidgetRegistry,
|
|
3156
|
+
lr as validate
|
|
3157
|
+
};
|