@notmrabhi/flowforge 0.1.4 → 0.1.6

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.
@@ -1,3235 +0,0 @@
1
- import b, { useState as F, useRef as Y, useEffect as me, useCallback as he, useMemo as ce } from "react";
2
- import { useFormik as jt } from "formik";
3
- import { A as Mt, F as _e, n as Pt, j as Lt, l as Vt, B as st, f as ze, a as Ve, t as Ge, T as qt, c as Wt, V as Ut } from "./index-CIbEqy9U.js";
4
- import { Box as u, Collapse as Bt, Tooltip as ee, Dialog as it, Typography as _, IconButton as ke, Stepper as Zt, Step as Ht, StepLabel as Yt, Drawer as Gt, Chip as Jt, Divider as Kt } from "@mui/material";
5
- import { MdSearch as ot, MdClose as te, MdCheck as Te, MdAdd as Fe, MdArrowBack as ct, MdEdit as Xt, MdDeleteOutline as Qt, MdSettings as ut, MdArrowForward as er } from "react-icons/md";
6
- import { FaWpforms as tr } from "react-icons/fa6";
7
- import { g as rr } from "./_commonjsHelpers-DaMA6jEr.js";
8
- function de(r) {
9
- this._maxSize = r, this.clear();
10
- }
11
- de.prototype.clear = function() {
12
- this._size = 0, this._values = /* @__PURE__ */ Object.create(null);
13
- };
14
- de.prototype.get = function(r) {
15
- return this._values[r];
16
- };
17
- de.prototype.set = function(r, e) {
18
- return this._size >= this._maxSize && this.clear(), r in this._values || this._size++, this._values[r] = e;
19
- };
20
- var nr = /[^.^\]^[]+|(?=\[\]|\.\.)/g, dt = /^\d+$/, ar = /^\d/, lr = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g, sr = /^\s*(['"]?)(.*?)(\1)\s*$/, qe = 512, Je = new de(qe);
21
- new de(qe);
22
- var Ke = new de(qe), ae = {
23
- split: Ie,
24
- normalizePath: Xe,
25
- getter: function(r, e) {
26
- var t = Xe(r);
27
- return Ke.get(r) || Ke.set(r, function(a) {
28
- for (var l = 0, s = t.length; l < s; )
29
- if (a != null || !e) a = a[t[l++]];
30
- else return;
31
- return a;
32
- });
33
- },
34
- join: function(r) {
35
- return r.reduce(function(e, t) {
36
- return e + (We(t) || dt.test(t) ? "[" + t + "]" : (e ? "." : "") + t);
37
- }, "");
38
- },
39
- forEach: function(r, e, t) {
40
- ir(Array.isArray(r) ? r : Ie(r), e, t);
41
- }
42
- };
43
- function Xe(r) {
44
- return Je.get(r) || Je.set(
45
- r,
46
- Ie(r).map(function(e) {
47
- return e.replace(sr, "$2");
48
- })
49
- );
50
- }
51
- function Ie(r) {
52
- return r.match(nr) || [""];
53
- }
54
- function ir(r, e, t) {
55
- var n = r.length, a, l, s, i;
56
- for (l = 0; l < n; l++)
57
- a = r[l], a && (ur(a) && (a = '"' + a + '"'), i = We(a), s = !i && /^\d+$/.test(a), e.call(t, a, i, s, l, r));
58
- }
59
- function We(r) {
60
- return typeof r == "string" && r && ["'", '"'].indexOf(r.charAt(0)) !== -1;
61
- }
62
- function or(r) {
63
- return r.match(ar) && !r.match(dt);
64
- }
65
- function cr(r) {
66
- return lr.test(r);
67
- }
68
- function ur(r) {
69
- return !We(r) && (or(r) || cr(r));
70
- }
71
- const dr = /[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g, ft = (r) => r.match(dr) || [], fr = (r, e) => ft(r).join(e).toLowerCase(), pr = (r) => ft(r).reduce(
72
- (e, t) => `${e}${e ? t[0].toUpperCase() + t.slice(1).toLowerCase() : t.toLowerCase()}`,
73
- ""
74
- ), mr = (r) => fr(r, "_");
75
- var Ne = {
76
- camelCase: pr,
77
- snakeCase: mr
78
- }, Ue = { exports: {} };
79
- Ue.exports = function(r) {
80
- return pt(hr(r), r);
81
- };
82
- Ue.exports.array = pt;
83
- function pt(r, e) {
84
- var t = r.length, n = new Array(t), a = {}, l = t, s = br(e), i = gr(r);
85
- for (e.forEach(function(d) {
86
- if (!i.has(d[0]) || !i.has(d[1]))
87
- throw new Error("Unknown node. There is an unknown node in the supplied edges.");
88
- }); l--; )
89
- a[l] || o(r[l], l, /* @__PURE__ */ new Set());
90
- return n;
91
- function o(d, p, m) {
92
- if (m.has(d)) {
93
- var f;
94
- try {
95
- f = ", node was:" + JSON.stringify(d);
96
- } catch {
97
- f = "";
98
- }
99
- throw new Error("Cyclic dependency" + f);
100
- }
101
- if (!i.has(d))
102
- throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: " + JSON.stringify(d));
103
- if (!a[p]) {
104
- a[p] = !0;
105
- var c = s.get(d) || /* @__PURE__ */ new Set();
106
- if (c = Array.from(c), p = c.length) {
107
- m.add(d);
108
- do {
109
- var g = c[--p];
110
- o(g, i.get(g), m);
111
- } while (p);
112
- m.delete(d);
113
- }
114
- n[--t] = d;
115
- }
116
- }
117
- }
118
- function hr(r) {
119
- for (var e = /* @__PURE__ */ new Set(), t = 0, n = r.length; t < n; t++) {
120
- var a = r[t];
121
- e.add(a[0]), e.add(a[1]);
122
- }
123
- return Array.from(e);
124
- }
125
- function br(r) {
126
- for (var e = /* @__PURE__ */ new Map(), t = 0, n = r.length; t < n; t++) {
127
- var a = r[t];
128
- e.has(a[0]) || e.set(a[0], /* @__PURE__ */ new Set()), e.has(a[1]) || e.set(a[1], /* @__PURE__ */ new Set()), e.get(a[0]).add(a[1]);
129
- }
130
- return e;
131
- }
132
- function gr(r) {
133
- for (var e = /* @__PURE__ */ new Map(), t = 0, n = r.length; t < n; t++)
134
- e.set(r[t], t);
135
- return e;
136
- }
137
- var xr = Ue.exports;
138
- const yr = /* @__PURE__ */ rr(xr), Er = Object.prototype.toString, vr = Error.prototype.toString, Rr = RegExp.prototype.toString, Sr = typeof Symbol < "u" ? Symbol.prototype.toString : () => "", kr = /^Symbol\((.*)\)(.*)$/;
139
- function wr(r) {
140
- return r != +r ? "NaN" : r === 0 && 1 / r < 0 ? "-0" : "" + r;
141
- }
142
- function Qe(r, e = !1) {
143
- if (r == null || r === !0 || r === !1) return "" + r;
144
- const t = typeof r;
145
- if (t === "number") return wr(r);
146
- if (t === "string") return e ? `"${r}"` : r;
147
- if (t === "function") return "[Function " + (r.name || "anonymous") + "]";
148
- if (t === "symbol") return Sr.call(r).replace(kr, "Symbol($1)");
149
- const n = Er.call(r).slice(8, -1);
150
- return n === "Date" ? isNaN(r.getTime()) ? "" + r : r.toISOString(r) : n === "Error" || r instanceof Error ? "[" + vr.call(r) + "]" : n === "RegExp" ? Rr.call(r) : null;
151
- }
152
- function J(r, e) {
153
- let t = Qe(r, e);
154
- return t !== null ? t : JSON.stringify(r, function(n, a) {
155
- let l = Qe(this[n], e);
156
- return l !== null ? l : a;
157
- }, 2);
158
- }
159
- function mt(r) {
160
- return r == null ? [] : [].concat(r);
161
- }
162
- let ht, bt, gt, Cr = /\$\{\s*(\w+)\s*\}/g;
163
- ht = Symbol.toStringTag;
164
- class et {
165
- constructor(e, t, n, a) {
166
- this.name = void 0, this.message = void 0, this.value = void 0, this.path = void 0, this.type = void 0, this.params = void 0, this.errors = void 0, this.inner = void 0, this[ht] = "Error", this.name = "ValidationError", this.value = t, this.path = n, this.type = a, this.errors = [], this.inner = [], mt(e).forEach((l) => {
167
- if (D.isError(l)) {
168
- this.errors.push(...l.errors);
169
- const s = l.inner.length ? l.inner : [l];
170
- this.inner.push(...s);
171
- } else
172
- this.errors.push(l);
173
- }), this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0];
174
- }
175
- }
176
- bt = Symbol.hasInstance;
177
- gt = Symbol.toStringTag;
178
- class D extends Error {
179
- static formatError(e, t) {
180
- const n = t.label || t.path || "this";
181
- return t = Object.assign({}, t, {
182
- path: n,
183
- originalPath: t.path
184
- }), typeof e == "string" ? e.replace(Cr, (a, l) => J(t[l])) : typeof e == "function" ? e(t) : e;
185
- }
186
- static isError(e) {
187
- return e && e.name === "ValidationError";
188
- }
189
- constructor(e, t, n, a, l) {
190
- const s = new et(e, t, n, a);
191
- if (l)
192
- return s;
193
- super(), this.value = void 0, this.path = void 0, this.type = void 0, this.params = void 0, this.errors = [], this.inner = [], this[gt] = "Error", this.name = s.name, this.message = s.message, this.type = s.type, this.value = s.value, this.path = s.path, this.errors = s.errors, this.inner = s.inner, Error.captureStackTrace && Error.captureStackTrace(this, D);
194
- }
195
- static [bt](e) {
196
- return et[Symbol.hasInstance](e) || super[Symbol.hasInstance](e);
197
- }
198
- }
199
- let H = {
200
- default: "${path} is invalid",
201
- required: "${path} is a required field",
202
- defined: "${path} must be defined",
203
- notNull: "${path} cannot be null",
204
- oneOf: "${path} must be one of the following values: ${values}",
205
- notOneOf: "${path} must not be one of the following values: ${values}",
206
- notType: ({
207
- path: r,
208
- type: e,
209
- value: t,
210
- originalValue: n
211
- }) => {
212
- const a = n != null && n !== t ? ` (cast from the value \`${J(n, !0)}\`).` : ".";
213
- return e !== "mixed" ? `${r} must be a \`${e}\` type, but the final value was: \`${J(t, !0)}\`` + a : `${r} must match the configured type. The validated value was: \`${J(t, !0)}\`` + a;
214
- }
215
- }, M = {
216
- length: "${path} must be exactly ${length} characters",
217
- min: "${path} must be at least ${min} characters",
218
- max: "${path} must be at most ${max} characters",
219
- matches: '${path} must match the following: "${regex}"',
220
- email: "${path} must be a valid email",
221
- url: "${path} must be a valid URL",
222
- uuid: "${path} must be a valid UUID",
223
- datetime: "${path} must be a valid ISO date-time",
224
- datetime_precision: "${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",
225
- datetime_offset: '${path} must be a valid ISO date-time with UTC "Z" timezone',
226
- trim: "${path} must be a trimmed string",
227
- lowercase: "${path} must be a lowercase string",
228
- uppercase: "${path} must be a upper case string"
229
- }, Q = {
230
- min: "${path} must be greater than or equal to ${min}",
231
- max: "${path} must be less than or equal to ${max}",
232
- lessThan: "${path} must be less than ${less}",
233
- moreThan: "${path} must be greater than ${more}",
234
- positive: "${path} must be a positive number",
235
- negative: "${path} must be a negative number",
236
- integer: "${path} must be an integer"
237
- }, De = {
238
- min: "${path} field must be later than ${min}",
239
- max: "${path} field must be at earlier than ${max}"
240
- }, je = {
241
- isValue: "${path} field must be ${value}"
242
- }, xe = {
243
- noUnknown: "${path} field has unspecified keys: ${unknown}",
244
- exact: "${path} object contains unknown properties: ${properties}"
245
- }, ye = {
246
- min: "${path} field must have at least ${min} items",
247
- max: "${path} field must have less than or equal to ${max} items",
248
- length: "${path} must have ${length} items"
249
- }, Tr = {
250
- notType: (r) => {
251
- const {
252
- path: e,
253
- value: t,
254
- spec: n
255
- } = r, a = n.types.length;
256
- if (Array.isArray(t)) {
257
- if (t.length < a) return `${e} tuple value has too few items, expected a length of ${a} but got ${t.length} for value: \`${J(t, !0)}\``;
258
- if (t.length > a) return `${e} tuple value has too many items, expected a length of ${a} but got ${t.length} for value: \`${J(t, !0)}\``;
259
- }
260
- return D.formatError(H.notType, r);
261
- }
262
- };
263
- Object.assign(/* @__PURE__ */ Object.create(null), {
264
- mixed: H,
265
- string: M,
266
- number: Q,
267
- date: De,
268
- object: xe,
269
- array: ye,
270
- boolean: je,
271
- tuple: Tr
272
- });
273
- const Oe = (r) => r && r.__isYupSchema__;
274
- class we {
275
- static fromOptions(e, t) {
276
- if (!t.then && !t.otherwise) throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");
277
- let {
278
- is: n,
279
- then: a,
280
- otherwise: l
281
- } = t, s = typeof n == "function" ? n : (...i) => i.every((o) => o === n);
282
- return new we(e, (i, o) => {
283
- var d;
284
- let p = s(...i) ? a : l;
285
- return (d = p == null ? void 0 : p(o)) != null ? d : o;
286
- });
287
- }
288
- constructor(e, t) {
289
- this.fn = void 0, this.refs = e, this.refs = e, this.fn = t;
290
- }
291
- resolve(e, t) {
292
- let n = this.refs.map((l) => (
293
- // TODO: ? operator here?
294
- l.getValue(t == null ? void 0 : t.value, t == null ? void 0 : t.parent, t == null ? void 0 : t.context)
295
- )), a = this.fn(n, e, t);
296
- if (a === void 0 || // @ts-ignore this can be base
297
- a === e)
298
- return e;
299
- if (!Oe(a)) throw new TypeError("conditions must return a schema object");
300
- return a.resolve(t);
301
- }
302
- }
303
- const be = {
304
- context: "$",
305
- value: "."
306
- };
307
- class le {
308
- constructor(e, t = {}) {
309
- if (this.key = void 0, this.isContext = void 0, this.isValue = void 0, this.isSibling = void 0, this.path = void 0, this.getter = void 0, this.map = void 0, typeof e != "string") throw new TypeError("ref must be a string, got: " + e);
310
- if (this.key = e.trim(), e === "") throw new TypeError("ref must be a non-empty string");
311
- this.isContext = this.key[0] === be.context, this.isValue = this.key[0] === be.value, this.isSibling = !this.isContext && !this.isValue;
312
- let n = this.isContext ? be.context : this.isValue ? be.value : "";
313
- this.path = this.key.slice(n.length), this.getter = this.path && ae.getter(this.path, !0), this.map = t.map;
314
- }
315
- getValue(e, t, n) {
316
- let a = this.isContext ? n : this.isValue ? e : t;
317
- return this.getter && (a = this.getter(a || {})), this.map && (a = this.map(a)), a;
318
- }
319
- /**
320
- *
321
- * @param {*} value
322
- * @param {Object} options
323
- * @param {Object=} options.context
324
- * @param {Object=} options.parent
325
- */
326
- cast(e, t) {
327
- return this.getValue(e, t == null ? void 0 : t.parent, t == null ? void 0 : t.context);
328
- }
329
- resolve() {
330
- return this;
331
- }
332
- describe() {
333
- return {
334
- type: "ref",
335
- key: this.key
336
- };
337
- }
338
- toString() {
339
- return `Ref(${this.key})`;
340
- }
341
- static isRef(e) {
342
- return e && e.__isYupRef;
343
- }
344
- }
345
- le.prototype.__isYupRef = !0;
346
- const B = (r) => r == null;
347
- function ie(r) {
348
- function e({
349
- value: t,
350
- path: n = "",
351
- options: a,
352
- originalValue: l,
353
- schema: s
354
- }, i, o) {
355
- const {
356
- name: d,
357
- test: p,
358
- params: m,
359
- message: f,
360
- skipAbsent: c
361
- } = r;
362
- let {
363
- parent: g,
364
- context: h,
365
- abortEarly: y = s.spec.abortEarly,
366
- disableStackTrace: E = s.spec.disableStackTrace
367
- } = a;
368
- const w = {
369
- value: t,
370
- parent: g,
371
- context: h
372
- };
373
- function $(T = {}) {
374
- const v = xt(Object.assign({
375
- value: t,
376
- originalValue: l,
377
- label: s.spec.label,
378
- path: T.path || n,
379
- spec: s.spec,
380
- disableStackTrace: T.disableStackTrace || E
381
- }, m, T.params), w), X = new D(D.formatError(T.message || f, v), t, v.path, T.type || d, v.disableStackTrace);
382
- return X.params = v, X;
383
- }
384
- const C = y ? i : o;
385
- let I = {
386
- path: n,
387
- parent: g,
388
- type: d,
389
- from: a.from,
390
- createError: $,
391
- resolve(T) {
392
- return yt(T, w);
393
- },
394
- options: a,
395
- originalValue: l,
396
- schema: s
397
- };
398
- const V = (T) => {
399
- D.isError(T) ? C(T) : T ? o(null) : C($());
400
- }, K = (T) => {
401
- D.isError(T) ? C(T) : i(T);
402
- };
403
- if (c && B(t))
404
- return V(!0);
405
- let j;
406
- try {
407
- var q;
408
- if (j = p.call(I, t, I), typeof ((q = j) == null ? void 0 : q.then) == "function") {
409
- if (a.sync)
410
- throw new Error(`Validation test of type: "${I.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);
411
- return Promise.resolve(j).then(V, K);
412
- }
413
- } catch (T) {
414
- K(T);
415
- return;
416
- }
417
- V(j);
418
- }
419
- return e.OPTIONS = r, e;
420
- }
421
- function xt(r, e) {
422
- if (!r) return r;
423
- for (const t of Object.keys(r))
424
- r[t] = yt(r[t], e);
425
- return r;
426
- }
427
- function yt(r, e) {
428
- return le.isRef(r) ? r.getValue(e.value, e.parent, e.context) : r;
429
- }
430
- function Fr(r, e, t, n = t) {
431
- let a, l, s;
432
- return e ? (ae.forEach(e, (i, o, d) => {
433
- let p = o ? i.slice(1, i.length - 1) : i;
434
- r = r.resolve({
435
- context: n,
436
- parent: a,
437
- value: t
438
- });
439
- let m = r.type === "tuple", f = d ? parseInt(p, 10) : 0;
440
- if (r.innerType || m) {
441
- if (m && !d) throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${s}" must contain an index to the tuple element, e.g. "${s}[0]"`);
442
- if (t && f >= t.length)
443
- throw new Error(`Yup.reach cannot resolve an array item at index: ${i}, in the path: ${e}. because there is no value at that index. `);
444
- a = t, t = t && t[f], r = m ? r.spec.types[f] : r.innerType;
445
- }
446
- if (!d) {
447
- if (!r.fields || !r.fields[p]) throw new Error(`The schema does not contain the path: ${e}. (failed at: ${s} which is a type: "${r.type}")`);
448
- a = t, t = t && t[p], r = r.fields[p];
449
- }
450
- l = p, s = o ? "[" + i + "]" : "." + i;
451
- }), {
452
- schema: r,
453
- parent: a,
454
- parentPath: l
455
- }) : {
456
- parent: a,
457
- parentPath: e,
458
- schema: r
459
- };
460
- }
461
- class Ce extends Set {
462
- describe() {
463
- const e = [];
464
- for (const t of this.values())
465
- e.push(le.isRef(t) ? t.describe() : t);
466
- return e;
467
- }
468
- resolveAll(e) {
469
- let t = [];
470
- for (const n of this.values())
471
- t.push(e(n));
472
- return t;
473
- }
474
- clone() {
475
- return new Ce(this.values());
476
- }
477
- merge(e, t) {
478
- const n = this.clone();
479
- return e.forEach((a) => n.add(a)), t.forEach((a) => n.delete(a)), n;
480
- }
481
- }
482
- function ue(r, e = /* @__PURE__ */ new Map()) {
483
- if (Oe(r) || !r || typeof r != "object") return r;
484
- if (e.has(r)) return e.get(r);
485
- let t;
486
- if (r instanceof Date)
487
- t = new Date(r.getTime()), e.set(r, t);
488
- else if (r instanceof RegExp)
489
- t = new RegExp(r), e.set(r, t);
490
- else if (Array.isArray(r)) {
491
- t = new Array(r.length), e.set(r, t);
492
- for (let n = 0; n < r.length; n++) t[n] = ue(r[n], e);
493
- } else if (r instanceof Map) {
494
- t = /* @__PURE__ */ new Map(), e.set(r, t);
495
- for (const [n, a] of r.entries()) t.set(n, ue(a, e));
496
- } else if (r instanceof Set) {
497
- t = /* @__PURE__ */ new Set(), e.set(r, t);
498
- for (const n of r) t.add(ue(n, e));
499
- } else if (r instanceof Object) {
500
- t = {}, e.set(r, t);
501
- for (const [n, a] of Object.entries(r)) t[n] = ue(a, e);
502
- } else
503
- throw Error(`Unable to clone ${r}`);
504
- return t;
505
- }
506
- function Or(r) {
507
- if (!(r != null && r.length))
508
- return;
509
- const e = [];
510
- let t = "", n = !1, a = !1;
511
- for (let l = 0; l < r.length; l++) {
512
- const s = r[l];
513
- if (s === "[" && !a) {
514
- t && (e.push(...t.split(".").filter(Boolean)), t = ""), n = !0;
515
- continue;
516
- }
517
- if (s === "]" && !a) {
518
- t && (/^\d+$/.test(t) ? e.push(t) : e.push(t.replace(/^"|"$/g, "")), t = ""), n = !1;
519
- continue;
520
- }
521
- if (s === '"') {
522
- a = !a;
523
- continue;
524
- }
525
- if (s === "." && !n && !a) {
526
- t && (e.push(t), t = "");
527
- continue;
528
- }
529
- t += s;
530
- }
531
- return t && e.push(...t.split(".").filter(Boolean)), e;
532
- }
533
- function $r(r, e) {
534
- const t = e ? `${e}.${r.path}` : r.path;
535
- return r.errors.map((n) => ({
536
- message: n,
537
- path: Or(t)
538
- }));
539
- }
540
- function Et(r, e) {
541
- var t;
542
- if (!((t = r.inner) != null && t.length) && r.errors.length)
543
- return $r(r, e);
544
- const n = e ? `${e}.${r.path}` : r.path;
545
- return r.inner.flatMap((a) => Et(a, n));
546
- }
547
- class L {
548
- constructor(e) {
549
- this.type = void 0, this.deps = [], this.tests = void 0, this.transforms = void 0, this.conditions = [], this._mutate = void 0, this.internalTests = {}, this._whitelist = new Ce(), this._blacklist = new Ce(), this.exclusiveTests = /* @__PURE__ */ Object.create(null), this._typeCheck = void 0, this.spec = void 0, this.tests = [], this.transforms = [], this.withMutation(() => {
550
- this.typeError(H.notType);
551
- }), this.type = e.type, this._typeCheck = e.check, this.spec = Object.assign({
552
- strip: !1,
553
- strict: !1,
554
- abortEarly: !0,
555
- recursive: !0,
556
- disableStackTrace: !1,
557
- nullable: !1,
558
- optional: !0,
559
- coerce: !0
560
- }, e == null ? void 0 : e.spec), this.withMutation((t) => {
561
- t.nonNullable();
562
- });
563
- }
564
- // TODO: remove
565
- get _type() {
566
- return this.type;
567
- }
568
- clone(e) {
569
- if (this._mutate)
570
- return e && Object.assign(this.spec, e), this;
571
- const t = Object.create(Object.getPrototypeOf(this));
572
- return t.type = this.type, t._typeCheck = this._typeCheck, t._whitelist = this._whitelist.clone(), t._blacklist = this._blacklist.clone(), t.internalTests = Object.assign({}, this.internalTests), t.exclusiveTests = Object.assign({}, this.exclusiveTests), t.deps = [...this.deps], t.conditions = [...this.conditions], t.tests = [...this.tests], t.transforms = [...this.transforms], t.spec = ue(Object.assign({}, this.spec, e)), t;
573
- }
574
- label(e) {
575
- let t = this.clone();
576
- return t.spec.label = e, t;
577
- }
578
- meta(...e) {
579
- if (e.length === 0) return this.spec.meta;
580
- let t = this.clone();
581
- return t.spec.meta = Object.assign(t.spec.meta || {}, e[0]), t;
582
- }
583
- withMutation(e) {
584
- let t = this._mutate;
585
- this._mutate = !0;
586
- let n = e(this);
587
- return this._mutate = t, n;
588
- }
589
- concat(e) {
590
- if (!e || e === this) return this;
591
- if (e.type !== this.type && this.type !== "mixed") throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);
592
- let t = this, n = e.clone();
593
- const a = Object.assign({}, t.spec, n.spec);
594
- return n.spec = a, n.internalTests = Object.assign({}, t.internalTests, n.internalTests), n._whitelist = t._whitelist.merge(e._whitelist, e._blacklist), n._blacklist = t._blacklist.merge(e._blacklist, e._whitelist), n.tests = t.tests, n.exclusiveTests = t.exclusiveTests, n.withMutation((l) => {
595
- e.tests.forEach((s) => {
596
- l.test(s.OPTIONS);
597
- });
598
- }), n.transforms = [...t.transforms, ...n.transforms], n;
599
- }
600
- isType(e) {
601
- return e == null ? !!(this.spec.nullable && e === null || this.spec.optional && e === void 0) : this._typeCheck(e);
602
- }
603
- resolve(e) {
604
- let t = this;
605
- if (t.conditions.length) {
606
- let n = t.conditions;
607
- t = t.clone(), t.conditions = [], t = n.reduce((a, l) => l.resolve(a, e), t), t = t.resolve(e);
608
- }
609
- return t;
610
- }
611
- resolveOptions(e) {
612
- var t, n, a, l;
613
- return Object.assign({}, e, {
614
- from: e.from || [],
615
- strict: (t = e.strict) != null ? t : this.spec.strict,
616
- abortEarly: (n = e.abortEarly) != null ? n : this.spec.abortEarly,
617
- recursive: (a = e.recursive) != null ? a : this.spec.recursive,
618
- disableStackTrace: (l = e.disableStackTrace) != null ? l : this.spec.disableStackTrace
619
- });
620
- }
621
- /**
622
- * Run the configured transform pipeline over an input value.
623
- */
624
- cast(e, t = {}) {
625
- let n = this.resolve(Object.assign({}, t, {
626
- value: e
627
- // parent: options.parent,
628
- // context: options.context,
629
- })), a = t.assert === "ignore-optionality", l = n._cast(e, t);
630
- if (t.assert !== !1 && !n.isType(l)) {
631
- if (a && B(l))
632
- return l;
633
- let s = J(e), i = J(l);
634
- throw new TypeError(`The value of ${t.path || "field"} could not be cast to a value that satisfies the schema type: "${n.type}".
635
-
636
- attempted value: ${s}
637
- ` + (i !== s ? `result of cast: ${i}` : ""));
638
- }
639
- return l;
640
- }
641
- _cast(e, t) {
642
- let n = e === void 0 ? e : this.transforms.reduce((a, l) => l.call(this, a, e, this, t), e);
643
- return n === void 0 && (n = this.getDefault(t)), n;
644
- }
645
- _validate(e, t = {}, n, a) {
646
- let {
647
- path: l,
648
- originalValue: s = e,
649
- strict: i = this.spec.strict
650
- } = t, o = e;
651
- i || (o = this._cast(o, Object.assign({
652
- assert: !1
653
- }, t)));
654
- let d = [];
655
- for (let p of Object.values(this.internalTests))
656
- p && d.push(p);
657
- this.runTests({
658
- path: l,
659
- value: o,
660
- originalValue: s,
661
- options: t,
662
- tests: d
663
- }, n, (p) => {
664
- if (p.length)
665
- return a(p, o);
666
- this.runTests({
667
- path: l,
668
- value: o,
669
- originalValue: s,
670
- options: t,
671
- tests: this.tests
672
- }, n, a);
673
- });
674
- }
675
- /**
676
- * Executes a set of validations, either schema, produced Tests or a nested
677
- * schema validate result.
678
- */
679
- runTests(e, t, n) {
680
- let a = !1, {
681
- tests: l,
682
- value: s,
683
- originalValue: i,
684
- path: o,
685
- options: d
686
- } = e, p = (h) => {
687
- a || (a = !0, t(h, s));
688
- }, m = (h) => {
689
- a || (a = !0, n(h, s));
690
- }, f = l.length, c = [];
691
- if (!f) return m([]);
692
- let g = {
693
- value: s,
694
- originalValue: i,
695
- path: o,
696
- options: d,
697
- schema: this
698
- };
699
- for (let h = 0; h < l.length; h++) {
700
- const y = l[h];
701
- y(g, p, function(w) {
702
- w && (Array.isArray(w) ? c.push(...w) : c.push(w)), --f <= 0 && m(c);
703
- });
704
- }
705
- }
706
- asNestedTest({
707
- key: e,
708
- index: t,
709
- parent: n,
710
- parentPath: a,
711
- originalParent: l,
712
- options: s
713
- }) {
714
- const i = e ?? t;
715
- if (i == null)
716
- throw TypeError("Must include `key` or `index` for nested validations");
717
- const o = typeof i == "number";
718
- let d = n[i];
719
- const p = Object.assign({}, s, {
720
- // Nested validations fields are always strict:
721
- // 1. parent isn't strict so the casting will also have cast inner values
722
- // 2. parent is strict in which case the nested values weren't cast either
723
- strict: !0,
724
- parent: n,
725
- value: d,
726
- originalValue: l[i],
727
- // FIXME: tests depend on `index` being passed around deeply,
728
- // we should not let the options.key/index bleed through
729
- key: void 0,
730
- // index: undefined,
731
- [o ? "index" : "key"]: i,
732
- path: o || i.includes(".") ? `${a || ""}[${o ? i : `"${i}"`}]` : (a ? `${a}.` : "") + e
733
- });
734
- return (m, f, c) => this.resolve(p)._validate(d, p, f, c);
735
- }
736
- validate(e, t) {
737
- var n;
738
- let a = this.resolve(Object.assign({}, t, {
739
- value: e
740
- })), l = (n = t == null ? void 0 : t.disableStackTrace) != null ? n : a.spec.disableStackTrace;
741
- return new Promise((s, i) => a._validate(e, t, (o, d) => {
742
- D.isError(o) && (o.value = d), i(o);
743
- }, (o, d) => {
744
- o.length ? i(new D(o, d, void 0, void 0, l)) : s(d);
745
- }));
746
- }
747
- validateSync(e, t) {
748
- var n;
749
- let a = this.resolve(Object.assign({}, t, {
750
- value: e
751
- })), l, s = (n = t == null ? void 0 : t.disableStackTrace) != null ? n : a.spec.disableStackTrace;
752
- return a._validate(e, Object.assign({}, t, {
753
- sync: !0
754
- }), (i, o) => {
755
- throw D.isError(i) && (i.value = o), i;
756
- }, (i, o) => {
757
- if (i.length) throw new D(i, e, void 0, void 0, s);
758
- l = o;
759
- }), l;
760
- }
761
- isValid(e, t) {
762
- return this.validate(e, t).then(() => !0, (n) => {
763
- if (D.isError(n)) return !1;
764
- throw n;
765
- });
766
- }
767
- isValidSync(e, t) {
768
- try {
769
- return this.validateSync(e, t), !0;
770
- } catch (n) {
771
- if (D.isError(n)) return !1;
772
- throw n;
773
- }
774
- }
775
- _getDefault(e) {
776
- let t = this.spec.default;
777
- return t == null ? t : typeof t == "function" ? t.call(this, e) : ue(t);
778
- }
779
- getDefault(e) {
780
- return this.resolve(e || {})._getDefault(e);
781
- }
782
- default(e) {
783
- return arguments.length === 0 ? this._getDefault() : this.clone({
784
- default: e
785
- });
786
- }
787
- strict(e = !0) {
788
- return this.clone({
789
- strict: e
790
- });
791
- }
792
- nullability(e, t) {
793
- const n = this.clone({
794
- nullable: e
795
- });
796
- return n.internalTests.nullable = ie({
797
- message: t,
798
- name: "nullable",
799
- test(a) {
800
- return a === null ? this.schema.spec.nullable : !0;
801
- }
802
- }), n;
803
- }
804
- optionality(e, t) {
805
- const n = this.clone({
806
- optional: e
807
- });
808
- return n.internalTests.optionality = ie({
809
- message: t,
810
- name: "optionality",
811
- test(a) {
812
- return a === void 0 ? this.schema.spec.optional : !0;
813
- }
814
- }), n;
815
- }
816
- optional() {
817
- return this.optionality(!0);
818
- }
819
- defined(e = H.defined) {
820
- return this.optionality(!1, e);
821
- }
822
- nullable() {
823
- return this.nullability(!0);
824
- }
825
- nonNullable(e = H.notNull) {
826
- return this.nullability(!1, e);
827
- }
828
- required(e = H.required) {
829
- return this.clone().withMutation((t) => t.nonNullable(e).defined(e));
830
- }
831
- notRequired() {
832
- return this.clone().withMutation((e) => e.nullable().optional());
833
- }
834
- transform(e) {
835
- let t = this.clone();
836
- return t.transforms.push(e), t;
837
- }
838
- /**
839
- * Adds a test function to the schema's queue of tests.
840
- * tests can be exclusive or non-exclusive.
841
- *
842
- * - exclusive tests, will replace any existing tests of the same name.
843
- * - non-exclusive: can be stacked
844
- *
845
- * If a non-exclusive test is added to a schema with an exclusive test of the same name
846
- * the exclusive test is removed and further tests of the same name will be stacked.
847
- *
848
- * If an exclusive test is added to a schema with non-exclusive tests of the same name
849
- * the previous tests are removed and further tests of the same name will replace each other.
850
- */
851
- test(...e) {
852
- let t;
853
- if (e.length === 1 ? typeof e[0] == "function" ? t = {
854
- test: e[0]
855
- } : t = e[0] : e.length === 2 ? t = {
856
- name: e[0],
857
- test: e[1]
858
- } : t = {
859
- name: e[0],
860
- message: e[1],
861
- test: e[2]
862
- }, t.message === void 0 && (t.message = H.default), typeof t.test != "function") throw new TypeError("`test` is a required parameters");
863
- let n = this.clone(), a = ie(t), l = t.exclusive || t.name && n.exclusiveTests[t.name] === !0;
864
- if (t.exclusive && !t.name)
865
- throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");
866
- return t.name && (n.exclusiveTests[t.name] = !!t.exclusive), n.tests = n.tests.filter((s) => !(s.OPTIONS.name === t.name && (l || s.OPTIONS.test === a.OPTIONS.test))), n.tests.push(a), n;
867
- }
868
- when(e, t) {
869
- !Array.isArray(e) && typeof e != "string" && (t = e, e = ".");
870
- let n = this.clone(), a = mt(e).map((l) => new le(l));
871
- return a.forEach((l) => {
872
- l.isSibling && n.deps.push(l.key);
873
- }), n.conditions.push(typeof t == "function" ? new we(a, t) : we.fromOptions(a, t)), n;
874
- }
875
- typeError(e) {
876
- let t = this.clone();
877
- return t.internalTests.typeError = ie({
878
- message: e,
879
- name: "typeError",
880
- skipAbsent: !0,
881
- test(n) {
882
- return this.schema._typeCheck(n) ? !0 : this.createError({
883
- params: {
884
- type: this.schema.type
885
- }
886
- });
887
- }
888
- }), t;
889
- }
890
- oneOf(e, t = H.oneOf) {
891
- let n = this.clone();
892
- return e.forEach((a) => {
893
- n._whitelist.add(a), n._blacklist.delete(a);
894
- }), n.internalTests.whiteList = ie({
895
- message: t,
896
- name: "oneOf",
897
- skipAbsent: !0,
898
- test(a) {
899
- let l = this.schema._whitelist, s = l.resolveAll(this.resolve);
900
- return s.includes(a) ? !0 : this.createError({
901
- params: {
902
- values: Array.from(l).join(", "),
903
- resolved: s
904
- }
905
- });
906
- }
907
- }), n;
908
- }
909
- notOneOf(e, t = H.notOneOf) {
910
- let n = this.clone();
911
- return e.forEach((a) => {
912
- n._blacklist.add(a), n._whitelist.delete(a);
913
- }), n.internalTests.blacklist = ie({
914
- message: t,
915
- name: "notOneOf",
916
- test(a) {
917
- let l = this.schema._blacklist, s = l.resolveAll(this.resolve);
918
- return s.includes(a) ? this.createError({
919
- params: {
920
- values: Array.from(l).join(", "),
921
- resolved: s
922
- }
923
- }) : !0;
924
- }
925
- }), n;
926
- }
927
- strip(e = !0) {
928
- let t = this.clone();
929
- return t.spec.strip = e, t;
930
- }
931
- /**
932
- * Return a serialized description of the schema including validations, flags, types etc.
933
- *
934
- * @param options Provide any needed context for resolving runtime schema alterations (lazy, when conditions, etc).
935
- */
936
- describe(e) {
937
- const t = (e ? this.resolve(e) : this).clone(), {
938
- label: n,
939
- meta: a,
940
- optional: l,
941
- nullable: s
942
- } = t.spec;
943
- return {
944
- meta: a,
945
- label: n,
946
- optional: l,
947
- nullable: s,
948
- default: t.getDefault(e),
949
- type: t.type,
950
- oneOf: t._whitelist.describe(),
951
- notOneOf: t._blacklist.describe(),
952
- tests: t.tests.filter((o, d, p) => p.findIndex((m) => m.OPTIONS.name === o.OPTIONS.name) === d).map((o) => {
953
- const d = o.OPTIONS.params && e ? xt(Object.assign({}, o.OPTIONS.params), e) : o.OPTIONS.params;
954
- return {
955
- name: o.OPTIONS.name,
956
- params: d
957
- };
958
- })
959
- };
960
- }
961
- get "~standard"() {
962
- const e = this;
963
- return {
964
- version: 1,
965
- vendor: "yup",
966
- async validate(n) {
967
- try {
968
- return {
969
- value: await e.validate(n, {
970
- abortEarly: !1
971
- })
972
- };
973
- } catch (a) {
974
- if (a instanceof D)
975
- return {
976
- issues: Et(a)
977
- };
978
- throw a;
979
- }
980
- }
981
- };
982
- }
983
- }
984
- L.prototype.__isYupSchema__ = !0;
985
- for (const r of ["validate", "validateSync"]) L.prototype[`${r}At`] = function(e, t, n = {}) {
986
- const {
987
- parent: a,
988
- parentPath: l,
989
- schema: s
990
- } = Fr(this, e, t, n.context);
991
- return s[r](a && a[l], Object.assign({}, n, {
992
- parent: a,
993
- path: e
994
- }));
995
- };
996
- for (const r of ["equals", "is"]) L.prototype[r] = L.prototype.oneOf;
997
- for (const r of ["not", "nope"]) L.prototype[r] = L.prototype.notOneOf;
998
- function vt() {
999
- return new Rt();
1000
- }
1001
- class Rt extends L {
1002
- constructor() {
1003
- super({
1004
- type: "boolean",
1005
- check(e) {
1006
- return e instanceof Boolean && (e = e.valueOf()), typeof e == "boolean";
1007
- }
1008
- }), this.withMutation(() => {
1009
- this.transform((e, t) => {
1010
- if (this.spec.coerce && !this.isType(e)) {
1011
- if (/^(true|1)$/i.test(String(e))) return !0;
1012
- if (/^(false|0)$/i.test(String(e))) return !1;
1013
- }
1014
- return e;
1015
- });
1016
- });
1017
- }
1018
- isTrue(e = je.isValue) {
1019
- return this.test({
1020
- message: e,
1021
- name: "is-value",
1022
- exclusive: !0,
1023
- params: {
1024
- value: "true"
1025
- },
1026
- test(t) {
1027
- return B(t) || t === !0;
1028
- }
1029
- });
1030
- }
1031
- isFalse(e = je.isValue) {
1032
- return this.test({
1033
- message: e,
1034
- name: "is-value",
1035
- exclusive: !0,
1036
- params: {
1037
- value: "false"
1038
- },
1039
- test(t) {
1040
- return B(t) || t === !1;
1041
- }
1042
- });
1043
- }
1044
- default(e) {
1045
- return super.default(e);
1046
- }
1047
- defined(e) {
1048
- return super.defined(e);
1049
- }
1050
- optional() {
1051
- return super.optional();
1052
- }
1053
- required(e) {
1054
- return super.required(e);
1055
- }
1056
- notRequired() {
1057
- return super.notRequired();
1058
- }
1059
- nullable() {
1060
- return super.nullable();
1061
- }
1062
- nonNullable(e) {
1063
- return super.nonNullable(e);
1064
- }
1065
- strip(e) {
1066
- return super.strip(e);
1067
- }
1068
- }
1069
- vt.prototype = Rt.prototype;
1070
- const _r = /^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;
1071
- function Nr(r) {
1072
- const e = Me(r);
1073
- if (!e) return Date.parse ? Date.parse(r) : Number.NaN;
1074
- if (e.z === void 0 && e.plusMinus === void 0)
1075
- return new Date(e.year, e.month, e.day, e.hour, e.minute, e.second, e.millisecond).valueOf();
1076
- let t = 0;
1077
- return e.z !== "Z" && e.plusMinus !== void 0 && (t = e.hourOffset * 60 + e.minuteOffset, e.plusMinus === "+" && (t = 0 - t)), Date.UTC(e.year, e.month, e.day, e.hour, e.minute + t, e.second, e.millisecond);
1078
- }
1079
- function Me(r) {
1080
- var e, t;
1081
- const n = _r.exec(r);
1082
- return n ? {
1083
- year: G(n[1]),
1084
- month: G(n[2], 1) - 1,
1085
- day: G(n[3], 1),
1086
- hour: G(n[4]),
1087
- minute: G(n[5]),
1088
- second: G(n[6]),
1089
- millisecond: n[7] ? (
1090
- // allow arbitrary sub-second precision beyond milliseconds
1091
- G(n[7].substring(0, 3))
1092
- ) : 0,
1093
- precision: (e = (t = n[7]) == null ? void 0 : t.length) != null ? e : void 0,
1094
- z: n[8] || void 0,
1095
- plusMinus: n[9] || void 0,
1096
- hourOffset: G(n[10]),
1097
- minuteOffset: G(n[11])
1098
- } : null;
1099
- }
1100
- function G(r, e = 0) {
1101
- return Number(r) || e;
1102
- }
1103
- let Ar = (
1104
- // eslint-disable-next-line
1105
- /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
1106
- ), zr = (
1107
- // eslint-disable-next-line
1108
- /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i
1109
- ), Ir = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i, Dr = "^\\d{4}-\\d{2}-\\d{2}", jr = "\\d{2}:\\d{2}:\\d{2}", Mr = "(([+-]\\d{2}(:?\\d{2})?)|Z)", Pr = new RegExp(`${Dr}T${jr}(\\.\\d+)?${Mr}$`), Lr = (r) => B(r) || r === r.trim(), Vr = {}.toString();
1110
- function Ee() {
1111
- return new St();
1112
- }
1113
- class St extends L {
1114
- constructor() {
1115
- super({
1116
- type: "string",
1117
- check(e) {
1118
- return e instanceof String && (e = e.valueOf()), typeof e == "string";
1119
- }
1120
- }), this.withMutation(() => {
1121
- this.transform((e, t) => {
1122
- if (!this.spec.coerce || this.isType(e) || Array.isArray(e)) return e;
1123
- const n = e != null && e.toString ? e.toString() : e;
1124
- return n === Vr ? e : n;
1125
- });
1126
- });
1127
- }
1128
- required(e) {
1129
- return super.required(e).withMutation((t) => t.test({
1130
- message: e || H.required,
1131
- name: "required",
1132
- skipAbsent: !0,
1133
- test: (n) => !!n.length
1134
- }));
1135
- }
1136
- notRequired() {
1137
- return super.notRequired().withMutation((e) => (e.tests = e.tests.filter((t) => t.OPTIONS.name !== "required"), e));
1138
- }
1139
- length(e, t = M.length) {
1140
- return this.test({
1141
- message: t,
1142
- name: "length",
1143
- exclusive: !0,
1144
- params: {
1145
- length: e
1146
- },
1147
- skipAbsent: !0,
1148
- test(n) {
1149
- return n.length === this.resolve(e);
1150
- }
1151
- });
1152
- }
1153
- min(e, t = M.min) {
1154
- return this.test({
1155
- message: t,
1156
- name: "min",
1157
- exclusive: !0,
1158
- params: {
1159
- min: e
1160
- },
1161
- skipAbsent: !0,
1162
- test(n) {
1163
- return n.length >= this.resolve(e);
1164
- }
1165
- });
1166
- }
1167
- max(e, t = M.max) {
1168
- return this.test({
1169
- name: "max",
1170
- exclusive: !0,
1171
- message: t,
1172
- params: {
1173
- max: e
1174
- },
1175
- skipAbsent: !0,
1176
- test(n) {
1177
- return n.length <= this.resolve(e);
1178
- }
1179
- });
1180
- }
1181
- matches(e, t) {
1182
- let n = !1, a, l;
1183
- return t && (typeof t == "object" ? {
1184
- excludeEmptyString: n = !1,
1185
- message: a,
1186
- name: l
1187
- } = t : a = t), this.test({
1188
- name: l || "matches",
1189
- message: a || M.matches,
1190
- params: {
1191
- regex: e
1192
- },
1193
- skipAbsent: !0,
1194
- test: (s) => s === "" && n || s.search(e) !== -1
1195
- });
1196
- }
1197
- email(e = M.email) {
1198
- return this.matches(Ar, {
1199
- name: "email",
1200
- message: e,
1201
- excludeEmptyString: !0
1202
- });
1203
- }
1204
- url(e = M.url) {
1205
- return this.matches(zr, {
1206
- name: "url",
1207
- message: e,
1208
- excludeEmptyString: !0
1209
- });
1210
- }
1211
- uuid(e = M.uuid) {
1212
- return this.matches(Ir, {
1213
- name: "uuid",
1214
- message: e,
1215
- excludeEmptyString: !1
1216
- });
1217
- }
1218
- datetime(e) {
1219
- let t = "", n, a;
1220
- return e && (typeof e == "object" ? {
1221
- message: t = "",
1222
- allowOffset: n = !1,
1223
- precision: a = void 0
1224
- } = e : t = e), this.matches(Pr, {
1225
- name: "datetime",
1226
- message: t || M.datetime,
1227
- excludeEmptyString: !0
1228
- }).test({
1229
- name: "datetime_offset",
1230
- message: t || M.datetime_offset,
1231
- params: {
1232
- allowOffset: n
1233
- },
1234
- skipAbsent: !0,
1235
- test: (l) => {
1236
- if (!l || n) return !0;
1237
- const s = Me(l);
1238
- return s ? !!s.z : !1;
1239
- }
1240
- }).test({
1241
- name: "datetime_precision",
1242
- message: t || M.datetime_precision,
1243
- params: {
1244
- precision: a
1245
- },
1246
- skipAbsent: !0,
1247
- test: (l) => {
1248
- if (!l || a == null) return !0;
1249
- const s = Me(l);
1250
- return s ? s.precision === a : !1;
1251
- }
1252
- });
1253
- }
1254
- //-- transforms --
1255
- ensure() {
1256
- return this.default("").transform((e) => e === null ? "" : e);
1257
- }
1258
- trim(e = M.trim) {
1259
- return this.transform((t) => t != null ? t.trim() : t).test({
1260
- message: e,
1261
- name: "trim",
1262
- test: Lr
1263
- });
1264
- }
1265
- lowercase(e = M.lowercase) {
1266
- return this.transform((t) => B(t) ? t : t.toLowerCase()).test({
1267
- message: e,
1268
- name: "string_case",
1269
- exclusive: !0,
1270
- skipAbsent: !0,
1271
- test: (t) => B(t) || t === t.toLowerCase()
1272
- });
1273
- }
1274
- uppercase(e = M.uppercase) {
1275
- return this.transform((t) => B(t) ? t : t.toUpperCase()).test({
1276
- message: e,
1277
- name: "string_case",
1278
- exclusive: !0,
1279
- skipAbsent: !0,
1280
- test: (t) => B(t) || t === t.toUpperCase()
1281
- });
1282
- }
1283
- }
1284
- Ee.prototype = St.prototype;
1285
- let qr = (r) => r != +r;
1286
- function kt() {
1287
- return new wt();
1288
- }
1289
- class wt extends L {
1290
- constructor() {
1291
- super({
1292
- type: "number",
1293
- check(e) {
1294
- return e instanceof Number && (e = e.valueOf()), typeof e == "number" && !qr(e);
1295
- }
1296
- }), this.withMutation(() => {
1297
- this.transform((e, t) => {
1298
- if (!this.spec.coerce) return e;
1299
- let n = e;
1300
- if (typeof n == "string") {
1301
- if (n = n.replace(/\s/g, ""), n === "") return NaN;
1302
- n = +n;
1303
- }
1304
- return this.isType(n) || n === null ? n : parseFloat(n);
1305
- });
1306
- });
1307
- }
1308
- min(e, t = Q.min) {
1309
- return this.test({
1310
- message: t,
1311
- name: "min",
1312
- exclusive: !0,
1313
- params: {
1314
- min: e
1315
- },
1316
- skipAbsent: !0,
1317
- test(n) {
1318
- return n >= this.resolve(e);
1319
- }
1320
- });
1321
- }
1322
- max(e, t = Q.max) {
1323
- return this.test({
1324
- message: t,
1325
- name: "max",
1326
- exclusive: !0,
1327
- params: {
1328
- max: e
1329
- },
1330
- skipAbsent: !0,
1331
- test(n) {
1332
- return n <= this.resolve(e);
1333
- }
1334
- });
1335
- }
1336
- lessThan(e, t = Q.lessThan) {
1337
- return this.test({
1338
- message: t,
1339
- name: "max",
1340
- exclusive: !0,
1341
- params: {
1342
- less: e
1343
- },
1344
- skipAbsent: !0,
1345
- test(n) {
1346
- return n < this.resolve(e);
1347
- }
1348
- });
1349
- }
1350
- moreThan(e, t = Q.moreThan) {
1351
- return this.test({
1352
- message: t,
1353
- name: "min",
1354
- exclusive: !0,
1355
- params: {
1356
- more: e
1357
- },
1358
- skipAbsent: !0,
1359
- test(n) {
1360
- return n > this.resolve(e);
1361
- }
1362
- });
1363
- }
1364
- positive(e = Q.positive) {
1365
- return this.moreThan(0, e);
1366
- }
1367
- negative(e = Q.negative) {
1368
- return this.lessThan(0, e);
1369
- }
1370
- integer(e = Q.integer) {
1371
- return this.test({
1372
- name: "integer",
1373
- message: e,
1374
- skipAbsent: !0,
1375
- test: (t) => Number.isInteger(t)
1376
- });
1377
- }
1378
- truncate() {
1379
- return this.transform((e) => B(e) ? e : e | 0);
1380
- }
1381
- round(e) {
1382
- var t;
1383
- let n = ["ceil", "floor", "round", "trunc"];
1384
- if (e = ((t = e) == null ? void 0 : t.toLowerCase()) || "round", e === "trunc") return this.truncate();
1385
- if (n.indexOf(e.toLowerCase()) === -1) throw new TypeError("Only valid options for round() are: " + n.join(", "));
1386
- return this.transform((a) => B(a) ? a : Math[e](a));
1387
- }
1388
- }
1389
- kt.prototype = wt.prototype;
1390
- let Wr = /* @__PURE__ */ new Date(""), Ur = (r) => Object.prototype.toString.call(r) === "[object Date]";
1391
- class Be extends L {
1392
- constructor() {
1393
- super({
1394
- type: "date",
1395
- check(e) {
1396
- return Ur(e) && !isNaN(e.getTime());
1397
- }
1398
- }), this.withMutation(() => {
1399
- this.transform((e, t) => !this.spec.coerce || this.isType(e) || e === null ? e : (e = Nr(e), isNaN(e) ? Be.INVALID_DATE : new Date(e)));
1400
- });
1401
- }
1402
- prepareParam(e, t) {
1403
- let n;
1404
- if (le.isRef(e))
1405
- n = e;
1406
- else {
1407
- let a = this.cast(e);
1408
- if (!this._typeCheck(a)) throw new TypeError(`\`${t}\` must be a Date or a value that can be \`cast()\` to a Date`);
1409
- n = a;
1410
- }
1411
- return n;
1412
- }
1413
- min(e, t = De.min) {
1414
- let n = this.prepareParam(e, "min");
1415
- return this.test({
1416
- message: t,
1417
- name: "min",
1418
- exclusive: !0,
1419
- params: {
1420
- min: e
1421
- },
1422
- skipAbsent: !0,
1423
- test(a) {
1424
- return a >= this.resolve(n);
1425
- }
1426
- });
1427
- }
1428
- max(e, t = De.max) {
1429
- let n = this.prepareParam(e, "max");
1430
- return this.test({
1431
- message: t,
1432
- name: "max",
1433
- exclusive: !0,
1434
- params: {
1435
- max: e
1436
- },
1437
- skipAbsent: !0,
1438
- test(a) {
1439
- return a <= this.resolve(n);
1440
- }
1441
- });
1442
- }
1443
- }
1444
- Be.INVALID_DATE = Wr;
1445
- function Br(r, e = []) {
1446
- let t = [], n = /* @__PURE__ */ new Set(), a = new Set(e.map(([s, i]) => `${s}-${i}`));
1447
- function l(s, i) {
1448
- let o = ae.split(s)[0];
1449
- n.add(o), a.has(`${i}-${o}`) || t.push([i, o]);
1450
- }
1451
- for (const s of Object.keys(r)) {
1452
- let i = r[s];
1453
- n.add(s), le.isRef(i) && i.isSibling ? l(i.path, s) : Oe(i) && "deps" in i && i.deps.forEach((o) => l(o, s));
1454
- }
1455
- return yr.array(Array.from(n), t).reverse();
1456
- }
1457
- function tt(r, e) {
1458
- let t = 1 / 0;
1459
- return r.some((n, a) => {
1460
- var l;
1461
- if ((l = e.path) != null && l.includes(n))
1462
- return t = a, !0;
1463
- }), t;
1464
- }
1465
- function Ct(r) {
1466
- return (e, t) => tt(r, e) - tt(r, t);
1467
- }
1468
- const Tt = (r, e, t) => {
1469
- if (typeof r != "string")
1470
- return r;
1471
- let n = r;
1472
- try {
1473
- n = JSON.parse(r);
1474
- } catch {
1475
- }
1476
- return t.isType(n) ? n : r;
1477
- };
1478
- function ve(r) {
1479
- if ("fields" in r) {
1480
- const e = {};
1481
- for (const [t, n] of Object.entries(r.fields))
1482
- e[t] = ve(n);
1483
- return r.setFields(e);
1484
- }
1485
- if (r.type === "array") {
1486
- const e = r.optional();
1487
- return e.innerType && (e.innerType = ve(e.innerType)), e;
1488
- }
1489
- return r.type === "tuple" ? r.optional().clone({
1490
- types: r.spec.types.map(ve)
1491
- }) : "optional" in r ? r.optional() : r;
1492
- }
1493
- const Zr = (r, e) => {
1494
- const t = [...ae.normalizePath(e)];
1495
- if (t.length === 1) return t[0] in r;
1496
- let n = t.pop(), a = ae.getter(ae.join(t), !0)(r);
1497
- return !!(a && n in a);
1498
- };
1499
- let rt = (r) => Object.prototype.toString.call(r) === "[object Object]";
1500
- function nt(r, e) {
1501
- let t = Object.keys(r.fields);
1502
- return Object.keys(e).filter((n) => t.indexOf(n) === -1);
1503
- }
1504
- const Hr = Ct([]);
1505
- function Pe(r) {
1506
- return new Ft(r);
1507
- }
1508
- class Ft extends L {
1509
- constructor(e) {
1510
- super({
1511
- type: "object",
1512
- check(t) {
1513
- return rt(t) || typeof t == "function";
1514
- }
1515
- }), this.fields = /* @__PURE__ */ Object.create(null), this._sortErrors = Hr, this._nodes = [], this._excludedEdges = [], this.withMutation(() => {
1516
- e && this.shape(e);
1517
- });
1518
- }
1519
- _cast(e, t = {}) {
1520
- var n;
1521
- let a = super._cast(e, t);
1522
- if (a === void 0) return this.getDefault(t);
1523
- if (!this._typeCheck(a)) return a;
1524
- let l = this.fields, s = (n = t.stripUnknown) != null ? n : this.spec.noUnknown, i = [].concat(this._nodes, Object.keys(a).filter((m) => !this._nodes.includes(m))), o = {}, d = Object.assign({}, t, {
1525
- parent: o,
1526
- __validating: t.__validating || !1
1527
- }), p = !1;
1528
- for (const m of i) {
1529
- let f = l[m], c = m in a, g = a[m];
1530
- if (f) {
1531
- let h;
1532
- d.path = (t.path ? `${t.path}.` : "") + m, f = f.resolve({
1533
- value: g,
1534
- context: t.context,
1535
- parent: o
1536
- });
1537
- let y = f instanceof L ? f.spec : void 0, E = y == null ? void 0 : y.strict;
1538
- if (y != null && y.strip) {
1539
- p = p || m in a;
1540
- continue;
1541
- }
1542
- h = !t.__validating || !E ? f.cast(g, d) : g, h !== void 0 && (o[m] = h);
1543
- } else c && !s && (o[m] = g);
1544
- (c !== m in o || o[m] !== g) && (p = !0);
1545
- }
1546
- return p ? o : a;
1547
- }
1548
- _validate(e, t = {}, n, a) {
1549
- let {
1550
- from: l = [],
1551
- originalValue: s = e,
1552
- recursive: i = this.spec.recursive
1553
- } = t;
1554
- t.from = [{
1555
- schema: this,
1556
- value: s
1557
- }, ...l], t.__validating = !0, t.originalValue = s, super._validate(e, t, n, (o, d) => {
1558
- if (!i || !rt(d)) {
1559
- a(o, d);
1560
- return;
1561
- }
1562
- s = s || d;
1563
- let p = [];
1564
- for (let m of this._nodes) {
1565
- let f = this.fields[m];
1566
- !f || le.isRef(f) || p.push(f.asNestedTest({
1567
- options: t,
1568
- key: m,
1569
- parent: d,
1570
- parentPath: t.path,
1571
- originalParent: s
1572
- }));
1573
- }
1574
- this.runTests({
1575
- tests: p,
1576
- value: d,
1577
- originalValue: s,
1578
- options: t
1579
- }, n, (m) => {
1580
- a(m.sort(this._sortErrors).concat(o), d);
1581
- });
1582
- });
1583
- }
1584
- clone(e) {
1585
- const t = super.clone(e);
1586
- return t.fields = Object.assign({}, this.fields), t._nodes = this._nodes, t._excludedEdges = this._excludedEdges, t._sortErrors = this._sortErrors, t;
1587
- }
1588
- concat(e) {
1589
- let t = super.concat(e), n = t.fields;
1590
- for (let [a, l] of Object.entries(this.fields)) {
1591
- const s = n[a];
1592
- n[a] = s === void 0 ? l : s;
1593
- }
1594
- return t.withMutation((a) => (
1595
- // XXX: excludes here is wrong
1596
- a.setFields(n, [...this._excludedEdges, ...e._excludedEdges])
1597
- ));
1598
- }
1599
- _getDefault(e) {
1600
- if ("default" in this.spec)
1601
- return super._getDefault(e);
1602
- if (!this._nodes.length)
1603
- return;
1604
- let t = {};
1605
- return this._nodes.forEach((n) => {
1606
- var a;
1607
- const l = this.fields[n];
1608
- let s = e;
1609
- (a = s) != null && a.value && (s = Object.assign({}, s, {
1610
- parent: s.value,
1611
- value: s.value[n]
1612
- })), t[n] = l && "getDefault" in l ? l.getDefault(s) : void 0;
1613
- }), t;
1614
- }
1615
- setFields(e, t) {
1616
- let n = this.clone();
1617
- return n.fields = e, n._nodes = Br(e, t), n._sortErrors = Ct(Object.keys(e)), t && (n._excludedEdges = t), n;
1618
- }
1619
- shape(e, t = []) {
1620
- return this.clone().withMutation((n) => {
1621
- let a = n._excludedEdges;
1622
- return t.length && (Array.isArray(t[0]) || (t = [t]), a = [...n._excludedEdges, ...t]), n.setFields(Object.assign(n.fields, e), a);
1623
- });
1624
- }
1625
- partial() {
1626
- const e = {};
1627
- for (const [t, n] of Object.entries(this.fields))
1628
- e[t] = "optional" in n && n.optional instanceof Function ? n.optional() : n;
1629
- return this.setFields(e);
1630
- }
1631
- deepPartial() {
1632
- return ve(this);
1633
- }
1634
- pick(e) {
1635
- const t = {};
1636
- for (const n of e)
1637
- this.fields[n] && (t[n] = this.fields[n]);
1638
- return this.setFields(t, this._excludedEdges.filter(([n, a]) => e.includes(n) && e.includes(a)));
1639
- }
1640
- omit(e) {
1641
- const t = [];
1642
- for (const n of Object.keys(this.fields))
1643
- e.includes(n) || t.push(n);
1644
- return this.pick(t);
1645
- }
1646
- from(e, t, n) {
1647
- let a = ae.getter(e, !0);
1648
- return this.transform((l) => {
1649
- if (!l) return l;
1650
- let s = l;
1651
- return Zr(l, e) && (s = Object.assign({}, l), n || delete s[e], s[t] = a(l)), s;
1652
- });
1653
- }
1654
- /** Parse an input JSON string to an object */
1655
- json() {
1656
- return this.transform(Tt);
1657
- }
1658
- /**
1659
- * Similar to `noUnknown` but only validates that an object is the right shape without stripping the unknown keys
1660
- */
1661
- exact(e) {
1662
- return this.test({
1663
- name: "exact",
1664
- exclusive: !0,
1665
- message: e || xe.exact,
1666
- test(t) {
1667
- if (t == null) return !0;
1668
- const n = nt(this.schema, t);
1669
- return n.length === 0 || this.createError({
1670
- params: {
1671
- properties: n.join(", ")
1672
- }
1673
- });
1674
- }
1675
- });
1676
- }
1677
- stripUnknown() {
1678
- return this.clone({
1679
- noUnknown: !0
1680
- });
1681
- }
1682
- noUnknown(e = !0, t = xe.noUnknown) {
1683
- typeof e != "boolean" && (t = e, e = !0);
1684
- let n = this.test({
1685
- name: "noUnknown",
1686
- exclusive: !0,
1687
- message: t,
1688
- test(a) {
1689
- if (a == null) return !0;
1690
- const l = nt(this.schema, a);
1691
- return !e || l.length === 0 || this.createError({
1692
- params: {
1693
- unknown: l.join(", ")
1694
- }
1695
- });
1696
- }
1697
- });
1698
- return n.spec.noUnknown = e, n;
1699
- }
1700
- unknown(e = !0, t = xe.noUnknown) {
1701
- return this.noUnknown(!e, t);
1702
- }
1703
- transformKeys(e) {
1704
- return this.transform((t) => {
1705
- if (!t) return t;
1706
- const n = {};
1707
- for (const a of Object.keys(t)) n[e(a)] = t[a];
1708
- return n;
1709
- });
1710
- }
1711
- camelCase() {
1712
- return this.transformKeys(Ne.camelCase);
1713
- }
1714
- snakeCase() {
1715
- return this.transformKeys(Ne.snakeCase);
1716
- }
1717
- constantCase() {
1718
- return this.transformKeys((e) => Ne.snakeCase(e).toUpperCase());
1719
- }
1720
- describe(e) {
1721
- const t = (e ? this.resolve(e) : this).clone(), n = super.describe(e);
1722
- n.fields = {};
1723
- for (const [l, s] of Object.entries(t.fields)) {
1724
- var a;
1725
- let i = e;
1726
- (a = i) != null && a.value && (i = Object.assign({}, i, {
1727
- parent: i.value,
1728
- value: i.value[l]
1729
- })), n.fields[l] = s.describe(i);
1730
- }
1731
- return n;
1732
- }
1733
- }
1734
- Pe.prototype = Ft.prototype;
1735
- function Ot(r) {
1736
- return new $t(r);
1737
- }
1738
- class $t extends L {
1739
- constructor(e) {
1740
- super({
1741
- type: "array",
1742
- spec: {
1743
- types: e
1744
- },
1745
- check(t) {
1746
- return Array.isArray(t);
1747
- }
1748
- }), this.innerType = void 0, this.innerType = e;
1749
- }
1750
- _cast(e, t) {
1751
- const n = super._cast(e, t);
1752
- if (!this._typeCheck(n) || !this.innerType)
1753
- return n;
1754
- let a = !1;
1755
- const l = n.map((s, i) => {
1756
- const o = this.innerType.cast(s, Object.assign({}, t, {
1757
- path: `${t.path || ""}[${i}]`,
1758
- parent: n,
1759
- originalValue: s,
1760
- value: s,
1761
- index: i
1762
- }));
1763
- return o !== s && (a = !0), o;
1764
- });
1765
- return a ? l : n;
1766
- }
1767
- _validate(e, t = {}, n, a) {
1768
- var l;
1769
- let s = this.innerType, i = (l = t.recursive) != null ? l : this.spec.recursive;
1770
- t.originalValue != null && t.originalValue, super._validate(e, t, n, (o, d) => {
1771
- var p;
1772
- if (!i || !s || !this._typeCheck(d)) {
1773
- a(o, d);
1774
- return;
1775
- }
1776
- let m = new Array(d.length);
1777
- for (let c = 0; c < d.length; c++) {
1778
- var f;
1779
- m[c] = s.asNestedTest({
1780
- options: t,
1781
- index: c,
1782
- parent: d,
1783
- parentPath: t.path,
1784
- originalParent: (f = t.originalValue) != null ? f : e
1785
- });
1786
- }
1787
- this.runTests({
1788
- value: d,
1789
- tests: m,
1790
- originalValue: (p = t.originalValue) != null ? p : e,
1791
- options: t
1792
- }, n, (c) => a(c.concat(o), d));
1793
- });
1794
- }
1795
- clone(e) {
1796
- const t = super.clone(e);
1797
- return t.innerType = this.innerType, t;
1798
- }
1799
- /** Parse an input JSON string to an object */
1800
- json() {
1801
- return this.transform(Tt);
1802
- }
1803
- concat(e) {
1804
- let t = super.concat(e);
1805
- return t.innerType = this.innerType, e.innerType && (t.innerType = t.innerType ? (
1806
- // @ts-expect-error Lazy doesn't have concat and will break
1807
- t.innerType.concat(e.innerType)
1808
- ) : e.innerType), t;
1809
- }
1810
- of(e) {
1811
- let t = this.clone();
1812
- if (!Oe(e)) throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: " + J(e));
1813
- return t.innerType = e, t.spec = Object.assign({}, t.spec, {
1814
- types: e
1815
- }), t;
1816
- }
1817
- length(e, t = ye.length) {
1818
- return this.test({
1819
- message: t,
1820
- name: "length",
1821
- exclusive: !0,
1822
- params: {
1823
- length: e
1824
- },
1825
- skipAbsent: !0,
1826
- test(n) {
1827
- return n.length === this.resolve(e);
1828
- }
1829
- });
1830
- }
1831
- min(e, t) {
1832
- return t = t || ye.min, this.test({
1833
- message: t,
1834
- name: "min",
1835
- exclusive: !0,
1836
- params: {
1837
- min: e
1838
- },
1839
- skipAbsent: !0,
1840
- // FIXME(ts): Array<typeof T>
1841
- test(n) {
1842
- return n.length >= this.resolve(e);
1843
- }
1844
- });
1845
- }
1846
- max(e, t) {
1847
- return t = t || ye.max, this.test({
1848
- message: t,
1849
- name: "max",
1850
- exclusive: !0,
1851
- params: {
1852
- max: e
1853
- },
1854
- skipAbsent: !0,
1855
- test(n) {
1856
- return n.length <= this.resolve(e);
1857
- }
1858
- });
1859
- }
1860
- ensure() {
1861
- return this.default(() => []).transform((e, t) => this._typeCheck(e) ? e : t == null ? [] : [].concat(t));
1862
- }
1863
- compact(e) {
1864
- let t = e ? (n, a, l) => !e(n, a, l) : (n) => !!n;
1865
- return this.transform((n) => n != null ? n.filter(t) : n);
1866
- }
1867
- describe(e) {
1868
- const t = (e ? this.resolve(e) : this).clone(), n = super.describe(e);
1869
- if (t.innerType) {
1870
- var a;
1871
- let l = e;
1872
- (a = l) != null && a.value && (l = Object.assign({}, l, {
1873
- parent: l.value,
1874
- value: l.value[0]
1875
- })), n.innerType = t.innerType.describe(l);
1876
- }
1877
- return n;
1878
- }
1879
- }
1880
- Ot.prototype = $t.prototype;
1881
- class Yr {
1882
- constructor() {
1883
- this.sources = /* @__PURE__ */ new Map();
1884
- }
1885
- register(e, t) {
1886
- this.sources.set(e, t);
1887
- }
1888
- get(e) {
1889
- return this.sources.get(e);
1890
- }
1891
- has(e) {
1892
- return this.sources.has(e);
1893
- }
1894
- }
1895
- const Gr = new Yr(), Jr = 8, k = {
1896
- wrapper: (r) => ({
1897
- border: `1px solid ${r ? _e.BORDER_COLOR_ERROR : _e.BORDER_COLOR}`,
1898
- borderRadius: _e.BORDER_RADIUS,
1899
- overflow: "hidden",
1900
- background: "#fff",
1901
- fontSize: 13
1902
- }),
1903
- toolbar: {
1904
- display: "flex",
1905
- alignItems: "center",
1906
- justifyContent: "space-between",
1907
- padding: "6px 12px",
1908
- borderBottom: "1px solid #e0e0e0",
1909
- minHeight: 40,
1910
- background: "#fff"
1911
- },
1912
- selectedLink: {
1913
- fontSize: 13,
1914
- color: "#1976d2",
1915
- cursor: "pointer",
1916
- background: "none",
1917
- border: "none",
1918
- padding: 0,
1919
- fontWeight: 500
1920
- },
1921
- searchWrap: {
1922
- display: "flex",
1923
- alignItems: "center",
1924
- gap: 6,
1925
- border: "1px solid #e0e0e0",
1926
- borderRadius: 4,
1927
- padding: "3px 8px",
1928
- background: "#fafafa",
1929
- flex: "0 0 220px"
1930
- },
1931
- searchInput: {
1932
- border: "none",
1933
- outline: "none",
1934
- fontSize: 13,
1935
- background: "transparent",
1936
- width: "100%"
1937
- },
1938
- table: {
1939
- width: "100%",
1940
- borderCollapse: "collapse"
1941
- },
1942
- thead: {
1943
- background: "#f5f5f5"
1944
- },
1945
- th: (r) => ({
1946
- textAlign: "left",
1947
- padding: "0 16px",
1948
- height: 44,
1949
- fontSize: 12,
1950
- fontWeight: 600,
1951
- color: "rgba(0,0,0,0.6)",
1952
- borderBottom: "1px solid #e0e0e0",
1953
- whiteSpace: "nowrap",
1954
- width: r,
1955
- letterSpacing: "0.01em"
1956
- }),
1957
- checkTh: {
1958
- width: 48,
1959
- padding: "0 0 0 12px",
1960
- height: 44,
1961
- borderBottom: "1px solid #e0e0e0",
1962
- background: "#f5f5f5"
1963
- },
1964
- td: {
1965
- padding: "0 16px",
1966
- height: 48,
1967
- borderBottom: "1px solid #f0f0f0",
1968
- color: "rgba(0,0,0,0.87)",
1969
- verticalAlign: "middle"
1970
- },
1971
- checkTd: {
1972
- padding: "0 0 0 12px",
1973
- height: 48,
1974
- borderBottom: "1px solid #f0f0f0",
1975
- verticalAlign: "middle",
1976
- width: 48
1977
- },
1978
- statusRow: {
1979
- textAlign: "center",
1980
- padding: "24px 16px",
1981
- color: "rgba(0,0,0,0.38)",
1982
- fontSize: 13
1983
- },
1984
- footer: {
1985
- display: "flex",
1986
- alignItems: "center",
1987
- justifyContent: "flex-end",
1988
- gap: 16,
1989
- padding: "4px 8px",
1990
- borderTop: "1px solid #e0e0e0",
1991
- fontSize: 12,
1992
- color: "rgba(0,0,0,0.6)",
1993
- background: "#fafafa",
1994
- minHeight: 40
1995
- },
1996
- pageBtn: (r) => ({
1997
- display: "flex",
1998
- alignItems: "center",
1999
- justifyContent: "center",
2000
- width: 28,
2001
- height: 28,
2002
- borderRadius: "50%",
2003
- border: "none",
2004
- background: "transparent",
2005
- cursor: r ? "default" : "pointer",
2006
- color: r ? "rgba(0,0,0,0.26)" : "rgba(0,0,0,0.54)",
2007
- fontSize: 16,
2008
- transition: "background 0.15s"
2009
- }),
2010
- // Modal
2011
- overlay: {
2012
- position: "fixed",
2013
- inset: 0,
2014
- background: "rgba(0,0,0,0.5)",
2015
- zIndex: 9999,
2016
- display: "flex",
2017
- alignItems: "center",
2018
- justifyContent: "center"
2019
- },
2020
- modal: {
2021
- background: "#fff",
2022
- borderRadius: 8,
2023
- width: 560,
2024
- maxWidth: "90vw",
2025
- maxHeight: "80vh",
2026
- display: "flex",
2027
- flexDirection: "column",
2028
- boxShadow: "0 8px 32px rgba(0,0,0,0.18)"
2029
- },
2030
- modalHeader: {
2031
- display: "flex",
2032
- alignItems: "center",
2033
- justifyContent: "space-between",
2034
- padding: "16px 20px",
2035
- borderBottom: "1px solid #e0e0e0",
2036
- fontSize: 16,
2037
- fontWeight: 600,
2038
- color: "rgba(0,0,0,0.87)"
2039
- },
2040
- modalCloseBtn: {
2041
- background: "none",
2042
- border: "none",
2043
- cursor: "pointer",
2044
- color: "rgba(0,0,0,0.54)",
2045
- display: "flex",
2046
- alignItems: "center",
2047
- padding: 4,
2048
- borderRadius: 4
2049
- },
2050
- modalSearch: {
2051
- display: "flex",
2052
- alignItems: "center",
2053
- gap: 8,
2054
- margin: "12px 20px",
2055
- border: "1px solid #e0e0e0",
2056
- borderRadius: 20,
2057
- padding: "6px 12px",
2058
- background: "#fafafa"
2059
- },
2060
- modalSearchInput: {
2061
- flex: 1,
2062
- border: "none",
2063
- outline: "none",
2064
- fontSize: 14,
2065
- background: "transparent"
2066
- },
2067
- modalList: {
2068
- flex: 1,
2069
- overflowY: "auto",
2070
- padding: "0 20px 8px"
2071
- },
2072
- modalRow: {
2073
- display: "flex",
2074
- alignItems: "center",
2075
- justifyContent: "space-between",
2076
- padding: "10px 0",
2077
- borderBottom: "1px solid #f0f0f0",
2078
- fontSize: 14,
2079
- color: "rgba(0,0,0,0.87)"
2080
- },
2081
- modalRemoveBtn: {
2082
- background: "none",
2083
- border: "none",
2084
- cursor: "pointer",
2085
- color: "#e53935",
2086
- display: "flex",
2087
- alignItems: "center",
2088
- padding: 2,
2089
- borderRadius: 4,
2090
- flexShrink: 0
2091
- },
2092
- modalFooter: {
2093
- display: "flex",
2094
- justifyContent: "flex-end",
2095
- padding: "12px 20px",
2096
- borderTop: "1px solid #e0e0e0"
2097
- },
2098
- closeBtn: {
2099
- padding: "6px 20px",
2100
- border: "1px solid #e0e0e0",
2101
- borderRadius: 4,
2102
- background: "#fff",
2103
- cursor: "pointer",
2104
- fontSize: 14,
2105
- color: "rgba(0,0,0,0.87)"
2106
- }
2107
- };
2108
- function at({ checked: r, onChange: e, indeterminate: t, disabled: n }) {
2109
- const a = Y(null);
2110
- return me(() => {
2111
- a.current && (a.current.indeterminate = !!t);
2112
- }, [t]), /* @__PURE__ */ b.createElement(
2113
- "input",
2114
- {
2115
- ref: a,
2116
- type: "checkbox",
2117
- checked: r,
2118
- onChange: e,
2119
- disabled: n,
2120
- style: {
2121
- width: 16,
2122
- height: 16,
2123
- cursor: n ? "default" : "pointer",
2124
- accentColor: "#1976d2"
2125
- }
2126
- }
2127
- );
2128
- }
2129
- function Kr({ selected: r, onRemove: e, onClose: t }) {
2130
- const [n, a] = F(""), l = r.filter(
2131
- (s) => s.label.toLowerCase().includes(n.toLowerCase())
2132
- );
2133
- return /* @__PURE__ */ b.createElement("div", { style: k.overlay, onClick: t }, /* @__PURE__ */ b.createElement("div", { style: k.modal, onClick: (s) => s.stopPropagation() }, /* @__PURE__ */ b.createElement("div", { style: k.modalHeader }, /* @__PURE__ */ b.createElement("span", null, "Selected Rows"), /* @__PURE__ */ b.createElement("button", { type: "button", style: k.modalCloseBtn, onClick: t }, /* @__PURE__ */ b.createElement(te, { size: 20 }))), /* @__PURE__ */ b.createElement("div", { style: k.modalSearch }, /* @__PURE__ */ b.createElement(ot, { size: 18, color: "rgba(0,0,0,0.38)" }), /* @__PURE__ */ b.createElement(
2134
- "input",
2135
- {
2136
- autoFocus: !0,
2137
- type: "text",
2138
- placeholder: "Search",
2139
- value: n,
2140
- onChange: (s) => a(s.target.value),
2141
- style: k.modalSearchInput
2142
- }
2143
- )), /* @__PURE__ */ b.createElement("div", { style: k.modalList }, l.length === 0 && /* @__PURE__ */ b.createElement("div", { style: { textAlign: "center", padding: "24px 0", color: "rgba(0,0,0,0.38)", fontSize: 13 } }, "No items found"), l.map((s) => /* @__PURE__ */ b.createElement("div", { key: s.value, style: k.modalRow }, /* @__PURE__ */ b.createElement("span", null, s.label), /* @__PURE__ */ b.createElement(
2144
- "button",
2145
- {
2146
- type: "button",
2147
- style: k.modalRemoveBtn,
2148
- onClick: () => e(s.value),
2149
- title: "Remove"
2150
- },
2151
- /* @__PURE__ */ b.createElement(te, { size: 16 })
2152
- )))), /* @__PURE__ */ b.createElement("div", { style: k.modalFooter }, /* @__PURE__ */ b.createElement("button", { type: "button", style: k.closeBtn, onClick: t }, "Close"))));
2153
- }
2154
- function Xr({ field: r, value: e, onChange: t, onBlur: n, error: a, touched: l }) {
2155
- const s = r, i = !!(l && a), o = s.isMulti ?? !1, d = s.pageSize ?? Jr, p = s.id ?? s.name ?? "", [m, f] = F(""), [c, g] = F(1), [h, y] = F([]), [E, w] = F(!1), [$, C] = F(!1), [I, V] = F(null), [K, U] = F(!1), j = Y(null), q = Y(0), T = Y(!0);
2156
- me(() => () => {
2157
- T.current = !1, j.current && clearTimeout(j.current);
2158
- }, []);
2159
- const v = o ? Array.isArray(e) ? e : [] : e ? [e] : [], X = v.length, fe = he(
2160
- (x, O) => {
2161
- if (s.fetchOptions) return s.fetchOptions(x, O);
2162
- if (s.dataSource) {
2163
- const N = Gr.get(s.dataSource);
2164
- return N ? N.fetch(x, O) : Promise.reject(new Error(`[FlowForge] DataSource "${s.dataSource}" is not registered.`));
2165
- }
2166
- return Promise.reject(new Error(`[FlowForge] table-picker "${s.id}" requires fetchOptions or dataSource.`));
2167
- },
2168
- // eslint-disable-next-line react-hooks/exhaustive-deps
2169
- [s.fetchOptions, s.dataSource, s.id]
2170
- ), z = he(
2171
- (x, O) => {
2172
- const N = ++q.current;
2173
- C(!0), fe(x, O).then((A) => {
2174
- !T.current || N !== q.current || (y(A.options.slice(0, d)), w(A.hasNextPage));
2175
- }).catch(() => {
2176
- !T.current || N !== q.current || (y([]), w(!1));
2177
- }).finally(() => {
2178
- !T.current || N !== q.current || C(!1);
2179
- });
2180
- },
2181
- [fe, d]
2182
- );
2183
- me(() => {
2184
- z("", 1);
2185
- }, []);
2186
- const re = (x) => {
2187
- const O = x.target.value;
2188
- f(O), g(1), j.current && clearTimeout(j.current), j.current = setTimeout(() => z(O, 1), 300);
2189
- }, ne = (x) => {
2190
- if (o) {
2191
- const O = Array.isArray(e) ? e : [], N = O.some((A) => A.value === x.value);
2192
- t(N ? O.filter((A) => A.value !== x.value) : [...O, x]);
2193
- } else
2194
- t((e == null ? void 0 : e.value) === x.value ? null : x);
2195
- n == null || n();
2196
- }, pe = () => {
2197
- if (!o) return;
2198
- const x = Array.isArray(e) ? e : [];
2199
- if (h.every((N) => x.some((A) => A.value === N.value)))
2200
- t(x.filter((N) => !h.some((A) => A.value === N.value)));
2201
- else {
2202
- const N = h.filter((A) => !x.some((Dt) => Dt.value === A.value));
2203
- t([...x, ...N]);
2204
- }
2205
- }, P = (x) => {
2206
- if (o) {
2207
- const N = (Array.isArray(e) ? e : []).filter((A) => A.value !== x);
2208
- t(N), N.length === 0 && U(!1);
2209
- } else
2210
- t(null), U(!1);
2211
- n == null || n();
2212
- }, se = s.columns.length + 1, W = h.length > 0 && h.every(
2213
- (x) => v.some((O) => O.value === x.value)
2214
- ), Ye = h.some(
2215
- (x) => v.some((O) => O.value === x.value)
2216
- ), $e = (x) => v.some((O) => O.value === x.value);
2217
- return /* @__PURE__ */ b.createElement("div", { style: { marginBottom: 16 } }, /* @__PURE__ */ b.createElement(
2218
- Mt,
2219
- {
2220
- label: s.label,
2221
- required: s.required,
2222
- showOptional: s.showOptional,
2223
- info: s.info,
2224
- htmlFor: p,
2225
- dataTestId: s.dataTestId ?? p
2226
- }
2227
- ), /* @__PURE__ */ b.createElement("div", { style: k.wrapper(i), onBlur: n, id: p }, /* @__PURE__ */ b.createElement("div", { style: k.toolbar }, X > 0 ? /* @__PURE__ */ b.createElement(
2228
- "button",
2229
- {
2230
- type: "button",
2231
- style: k.selectedLink,
2232
- onClick: () => U(!0)
2233
- },
2234
- X,
2235
- " ",
2236
- X === 1 ? "Item" : "Items",
2237
- " Selected"
2238
- ) : /* @__PURE__ */ b.createElement("span", { style: { fontSize: 13, color: "rgba(0,0,0,0.38)" } }, "No selection"), /* @__PURE__ */ b.createElement("div", { style: k.searchWrap }, /* @__PURE__ */ b.createElement(ot, { size: 15, color: "rgba(0,0,0,0.38)" }), /* @__PURE__ */ b.createElement(
2239
- "input",
2240
- {
2241
- type: "text",
2242
- placeholder: s.placeholder ?? "Search…",
2243
- value: m,
2244
- onChange: re,
2245
- style: k.searchInput,
2246
- "aria-label": `Search ${s.label ?? ""}`
2247
- }
2248
- ))), /* @__PURE__ */ b.createElement("div", { style: { overflowX: "auto" } }, /* @__PURE__ */ b.createElement("table", { style: k.table }, /* @__PURE__ */ b.createElement("thead", { style: k.thead }, /* @__PURE__ */ b.createElement("tr", null, /* @__PURE__ */ b.createElement("th", { style: k.checkTh }, o && /* @__PURE__ */ b.createElement(
2249
- at,
2250
- {
2251
- checked: W,
2252
- indeterminate: !W && Ye,
2253
- onChange: pe,
2254
- disabled: $ || h.length === 0
2255
- }
2256
- )), s.columns.map((x) => /* @__PURE__ */ b.createElement("th", { key: x.key, style: k.th(x.width) }, x.label)))), /* @__PURE__ */ b.createElement("tbody", null, $ ? /* @__PURE__ */ b.createElement("tr", null, /* @__PURE__ */ b.createElement("td", { colSpan: se, style: k.statusRow }, "Loading…")) : h.length === 0 ? /* @__PURE__ */ b.createElement("tr", null, /* @__PURE__ */ b.createElement("td", { colSpan: se, style: k.statusRow }, "No results found")) : h.map((x) => {
2257
- const O = $e(x), N = I === x.value;
2258
- return /* @__PURE__ */ b.createElement(
2259
- "tr",
2260
- {
2261
- key: x.value,
2262
- style: {
2263
- cursor: "pointer",
2264
- background: O ? "rgba(25,118,210,0.06)" : N ? "rgba(0,0,0,0.03)" : "#fff",
2265
- transition: "background 0.1s"
2266
- },
2267
- onClick: () => ne(x),
2268
- onMouseEnter: () => V(x.value),
2269
- onMouseLeave: () => V(null),
2270
- "aria-selected": O
2271
- },
2272
- /* @__PURE__ */ b.createElement("td", { style: k.checkTd }, o ? /* @__PURE__ */ b.createElement(
2273
- at,
2274
- {
2275
- checked: O,
2276
- onChange: () => ne(x)
2277
- }
2278
- ) : /* @__PURE__ */ b.createElement(
2279
- "input",
2280
- {
2281
- type: "radio",
2282
- checked: O,
2283
- onChange: () => ne(x),
2284
- onClick: (A) => A.stopPropagation(),
2285
- name: p,
2286
- style: { accentColor: "#1976d2", width: 16, height: 16, cursor: "pointer" }
2287
- }
2288
- )),
2289
- s.columns.map((A) => /* @__PURE__ */ b.createElement("td", { key: A.key, style: k.td }, String(x[A.key] ?? "")))
2290
- );
2291
- })))), /* @__PURE__ */ b.createElement("div", { style: k.footer }, /* @__PURE__ */ b.createElement("span", null, `${(c - 1) * d + 1}–${(c - 1) * d + h.length} of many`), /* @__PURE__ */ b.createElement("div", { style: { display: "flex", alignItems: "center", gap: 4 } }, /* @__PURE__ */ b.createElement(
2292
- "button",
2293
- {
2294
- type: "button",
2295
- onClick: () => {
2296
- const x = c - 1;
2297
- g(x), z(m, x);
2298
- },
2299
- disabled: c <= 1,
2300
- style: k.pageBtn(c <= 1),
2301
- "aria-label": "Previous page"
2302
- },
2303
- "‹"
2304
- ), /* @__PURE__ */ b.createElement(
2305
- "button",
2306
- {
2307
- type: "button",
2308
- onClick: () => {
2309
- const x = c + 1;
2310
- g(x), z(m, x);
2311
- },
2312
- disabled: !E,
2313
- style: k.pageBtn(!E),
2314
- "aria-label": "Next page"
2315
- },
2316
- "›"
2317
- )))), s.helperText && !i && /* @__PURE__ */ b.createElement("small", { style: Pt }, s.helperText), i && /* @__PURE__ */ b.createElement("small", { "data-testid": `${p}-error`, style: Lt }, a), K && /* @__PURE__ */ b.createElement(
2318
- Kr,
2319
- {
2320
- selected: v,
2321
- onRemove: P,
2322
- onClose: () => U(!1)
2323
- }
2324
- ));
2325
- }
2326
- class Qr {
2327
- constructor() {
2328
- this.fields = /* @__PURE__ */ new Map(), this.register({ type: "text", label: "Text" }), this.register({ type: "textarea", label: "Textarea" }), this.register({
2329
- type: "number",
2330
- label: "Number",
2331
- configSchema: {
2332
- fields: [
2333
- { id: "min", type: "number", label: "Minimum limit" },
2334
- { id: "max", type: "number", label: "Maximum limit" },
2335
- { id: "step", type: "number", label: "Step size" },
2336
- { id: "prefix", type: "text", label: "Prefix (e.g. $)" },
2337
- { id: "suffix", type: "text", label: "Suffix (e.g. USD)" }
2338
- ]
2339
- }
2340
- }), this.register({ type: "toggle", label: "Toggle/Switch" }), this.register({ type: "select", label: "Select" }), this.register({ type: "descriptive-select", label: "Descriptive Select" }), this.register({ type: "radio-group", label: "Radio Group" }), this.register({ type: "key-value", label: "Key-Value" }), this.register({ type: "reference", label: "Reference" }), this.register({ type: "cron", label: "Cron" }), this.register({ type: "object", label: "Object" }), this.register({ type: "schema", label: "Schema (nested form)" }), this.register({ type: "tabs", label: "Tabs" }), this.register({ type: "date", label: "Date" }), this.register({ type: "datetime", label: "Date & Time" }), this.register({ type: "time", label: "Time" }), this.register({
2341
- type: "tags",
2342
- label: "Tags",
2343
- configSchema: { fields: [
2344
- { id: "placeholder", type: "text", label: "Placeholder text" },
2345
- { id: "maxTags", type: "number", label: "Max tags (leave empty for unlimited)" }
2346
- ] }
2347
- }), this.register({
2348
- type: "slider",
2349
- label: "Slider",
2350
- configSchema: { fields: [
2351
- { id: "min", type: "number", label: "Minimum value" },
2352
- { id: "max", type: "number", label: "Maximum value" },
2353
- { id: "step", type: "number", label: "Step size" },
2354
- { id: "showValue", type: "toggle", label: "Show current value" },
2355
- { id: "marks", type: "toggle", label: "Show tick marks" }
2356
- ] }
2357
- }), this.register({
2358
- type: "color",
2359
- label: "Color",
2360
- configSchema: { fields: [
2361
- { id: "showHex", type: "toggle", label: "Show hex input" }
2362
- ] }
2363
- }), this.register({
2364
- type: "file",
2365
- label: "File Upload",
2366
- configSchema: { fields: [
2367
- { id: "accept", type: "text", label: "Accepted file types (e.g. .pdf,.png)" },
2368
- { id: "maxSizeMb", type: "number", label: "Max file size (MB)" },
2369
- { id: "multiple", type: "toggle", label: "Allow multiple files" }
2370
- ] }
2371
- }), this.register({
2372
- type: "json-editor",
2373
- label: "JSON Editor",
2374
- configSchema: { fields: [
2375
- { id: "rows", type: "number", label: "Editor height (rows)" }
2376
- ] }
2377
- }), this.register({
2378
- type: "code",
2379
- label: "Code",
2380
- configSchema: { fields: [
2381
- {
2382
- id: "language",
2383
- type: "select",
2384
- label: "Language",
2385
- options: [
2386
- { value: "javascript", label: "JavaScript" },
2387
- { value: "typescript", label: "TypeScript" },
2388
- { value: "python", label: "Python" },
2389
- { value: "json", label: "JSON" }
2390
- ]
2391
- },
2392
- { id: "rows", type: "number", label: "Editor height (rows)" }
2393
- ] }
2394
- }), this.register({
2395
- type: "rich-text",
2396
- label: "Rich Text",
2397
- configSchema: { fields: [
2398
- { id: "rows", type: "number", label: "Editor height (rows)" },
2399
- { id: "toolbar", type: "toggle", label: "Show toolbar" }
2400
- ] }
2401
- }), this.register({
2402
- type: "table-picker",
2403
- label: "Table Picker",
2404
- component: Xr,
2405
- configSchema: {
2406
- fields: [
2407
- { id: "label", type: "text", label: "Label" },
2408
- { id: "required", type: "toggle", label: "Required" },
2409
- { id: "isMulti", type: "toggle", label: "Multi-select" },
2410
- { id: "pageSize", type: "number", label: "Page size" }
2411
- ]
2412
- }
2413
- });
2414
- }
2415
- register(e) {
2416
- this.fields.set(e.type, e), e.component && Vt.register(e.type, e.component);
2417
- }
2418
- get(e) {
2419
- return this.fields.get(e);
2420
- }
2421
- getAll() {
2422
- return Array.from(this.fields.values());
2423
- }
2424
- /** Gets all allowed options for the Type Picker in SchemaBuilder */
2425
- getTypeOptions() {
2426
- return this.getAll().map((e) => ({
2427
- value: e.type,
2428
- label: e.label
2429
- }));
2430
- }
2431
- }
2432
- const Ze = new Qr();
2433
- function He(r) {
2434
- const e = {};
2435
- for (const t of r) {
2436
- let n;
2437
- try {
2438
- n = st(t);
2439
- } catch {
2440
- continue;
2441
- }
2442
- if (!n || t.hidden) continue;
2443
- if (t.validation) {
2444
- e[n] = t.validation;
2445
- continue;
2446
- }
2447
- let a;
2448
- const l = Ze.get(t.type);
2449
- if (l != null && l.buildValidation)
2450
- a = l.buildValidation(t);
2451
- else
2452
- switch (t.type) {
2453
- case "select":
2454
- case "descriptive-select":
2455
- case "radio-group":
2456
- a = Ee(), t.required && (a = a.required(`${t.label ?? n} is required`));
2457
- break;
2458
- case "number":
2459
- case "slider": {
2460
- let s = kt().typeError(`${t.label ?? n} must be a number`);
2461
- t.min != null && (s = s.min(t.min, `${t.label ?? n} must be at least ${t.min}`)), t.max != null && (s = s.max(t.max, `${t.label ?? n} must be at most ${t.max}`)), t.required && (s = s.required(`${t.label ?? n} is required`)), a = s;
2462
- break;
2463
- }
2464
- case "toggle":
2465
- case "checkbox":
2466
- a = vt(), t.required && (a = a.oneOf([!0], `${t.label ?? n} must be checked`));
2467
- break;
2468
- case "array":
2469
- case "tags": {
2470
- let s = Ot();
2471
- t.required && (s = s.min(1, `${t.label ?? n} must have at least one item`)), t.maxTags != null && (s = s.max(t.maxTags, `${t.label ?? n} can have at most ${t.maxTags} items`)), a = s;
2472
- break;
2473
- }
2474
- case "object":
2475
- case "schema": {
2476
- const s = t.children ?? [];
2477
- a = s.length > 0 ? He(s) : Pe(), t.required && (a = a.required(`${t.label ?? n} is required`));
2478
- break;
2479
- }
2480
- case "date":
2481
- case "datetime":
2482
- case "time": {
2483
- let s = Ee();
2484
- t.required && (s = s.required(`${t.label ?? n} is required`)), a = s;
2485
- break;
2486
- }
2487
- default: {
2488
- const s = t.inputType;
2489
- let i = Ee();
2490
- s === "email" ? i = i.email(`${t.label ?? n} must be a valid email address`) : s === "url" && (i = i.url(`${t.label ?? n} must be a valid URL`));
2491
- const o = t.minLength, d = t.maxLength;
2492
- o != null && (i = i.min(o, `${t.label ?? n} must be at least ${o} characters`)), d != null && (i = i.max(d, `${t.label ?? n} must be at most ${d} characters`)), t.required && (i = i.trim().required(`${t.label ?? n} is required`)), a = i;
2493
- break;
2494
- }
2495
- }
2496
- e[n] = a;
2497
- }
2498
- return Pe().shape(e);
2499
- }
2500
- function Sn({
2501
- schema: r,
2502
- initialValues: e,
2503
- onSubmit: t,
2504
- showErrorsImmediately: n = !1
2505
- }) {
2506
- const a = r.fields ?? [], l = ce(
2507
- () => He(a),
2508
- [a]
2509
- ), s = ce(() => {
2510
- if (n)
2511
- return a.reduce((h, y) => {
2512
- const E = st(y);
2513
- return E && (h[E] = !0), h;
2514
- }, {});
2515
- }, [a, n]), [i, o] = F({}), [d, p] = F({}), m = Y(e);
2516
- me(() => {
2517
- m.current !== e && (m.current = e, o({}), p({}));
2518
- }, [e]);
2519
- const f = jt({
2520
- initialValues: e,
2521
- validationSchema: l,
2522
- initialTouched: s,
2523
- validateOnMount: n,
2524
- validateOnChange: !0,
2525
- validateOnBlur: !0,
2526
- enableReinitialize: !0,
2527
- onSubmit: async (h) => {
2528
- const y = ze({ values: h, conditionConfig: d });
2529
- await t(h, y);
2530
- }
2531
- }), c = he(() => {
2532
- f.submitForm();
2533
- }, [f]), g = he((h) => {
2534
- f.resetForm(h ? { values: h } : void 0), o({}), p({});
2535
- }, [f]);
2536
- return {
2537
- values: f.values,
2538
- errors: f.errors,
2539
- isValid: f.isValid,
2540
- isDirty: f.dirty,
2541
- isSubmitting: f.isSubmitting,
2542
- formulaConfig: i,
2543
- conditionConfig: d,
2544
- submit: c,
2545
- reset: g,
2546
- setFieldValue: f.setFieldValue,
2547
- // Internals for DynamicFormRenderer
2548
- _schema: r,
2549
- _formik: f,
2550
- _formulaConfig: i,
2551
- _onFormulaConfigChange: o,
2552
- _conditionConfig: d,
2553
- _onConditionConfigChange: p
2554
- };
2555
- }
2556
- const en = Ze.getTypeOptions(), S = "form-control font-14", R = "text-14 text-dark fw-medium mb-1 align-items-center d-flex gap-1", Z = {
2557
- fontSize: 10,
2558
- fontWeight: 700,
2559
- color: "#94a3b8",
2560
- textTransform: "uppercase",
2561
- letterSpacing: 0.6,
2562
- marginBottom: 8,
2563
- display: "block"
2564
- }, tn = [
2565
- { value: "text", label: "Text" },
2566
- { value: "number", label: "Number" },
2567
- { value: "email", label: "Email" },
2568
- { value: "url", label: "URL" },
2569
- { value: "password", label: "Password" },
2570
- { value: "select", label: "Select" },
2571
- { value: "object", label: "Object (sub-fields)" },
2572
- { value: "array", label: "Array (nested)" }
2573
- ], rn = [
2574
- { value: 3, label: "1/4" },
2575
- { value: 4, label: "1/3" },
2576
- { value: 6, label: "1/2" },
2577
- { value: 8, label: "2/3" },
2578
- { value: 12, label: "Full" }
2579
- ];
2580
- function nn({ value: r, onChange: e }) {
2581
- const t = r ?? 12;
2582
- return /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("span", { className: R }, "Column width"), /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", gap: 0.5 } }, rn.map((n) => /* @__PURE__ */ React.createElement(ee, { key: n.value, title: `colSpan: ${n.value}`, placement: "top" }, /* @__PURE__ */ React.createElement(
2583
- u,
2584
- {
2585
- component: "button",
2586
- onClick: () => e(n.value),
2587
- sx: {
2588
- flex: 1,
2589
- border: "1px solid",
2590
- borderColor: t === n.value ? "#6366f1" : "#dee2e6",
2591
- borderRadius: "6px",
2592
- cursor: "pointer",
2593
- bgcolor: t === n.value ? "#eef2ff" : "#fff",
2594
- color: t === n.value ? "#6366f1" : "#6c757d",
2595
- fontSize: 11,
2596
- fontWeight: 600,
2597
- py: 0.6,
2598
- px: 0,
2599
- "&:hover": { borderColor: "#6366f1", bgcolor: "#f5f3ff" }
2600
- }
2601
- },
2602
- n.label
2603
- )))), /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", gap: "3px", mt: 0.75 } }, Array.from({ length: 12 }).map((n, a) => /* @__PURE__ */ React.createElement(u, { key: a, sx: { flex: 1, height: 4, borderRadius: "2px", bgcolor: a < t ? "#6366f1" : "#e2e8f0", transition: "background 0.12s" } }))));
2604
- }
2605
- function _t({ options: r = [], onChange: e }) {
2606
- function t(n, a, l) {
2607
- e(r.map((s, i) => i === n ? { ...s, [a]: l } : s));
2608
- }
2609
- return /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("span", { className: R }, "Options ", /* @__PURE__ */ React.createElement("span", { style: { color: "#dc3545" } }, "*")), /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", flexDirection: "column", gap: 0.5, mb: 0.75 } }, r.map((n, a) => /* @__PURE__ */ React.createElement(u, { key: a, sx: { display: "flex", gap: 0.5, alignItems: "center" } }, /* @__PURE__ */ React.createElement("input", { className: S, style: { flex: 1 }, placeholder: "Label", value: n.label, onChange: (l) => t(a, "label", l.target.value) }), /* @__PURE__ */ React.createElement("input", { className: S, style: { flex: 1 }, placeholder: "Value", value: n.value, onChange: (l) => t(a, "value", l.target.value) }), /* @__PURE__ */ React.createElement(u, { component: "button", onClick: () => e(r.filter((l, s) => s !== a)), sx: { background: "none", border: "none", cursor: "pointer", color: "#94a3b8", display: "flex", p: 0.25, "&:hover": { color: "#dc2626" } } }, /* @__PURE__ */ React.createElement(te, { size: 13 }))))), /* @__PURE__ */ React.createElement(u, { component: "button", onClick: () => e([...r, { label: "", value: "" }]), sx: { display: "flex", alignItems: "center", gap: 0.5, background: "none", border: "1px dashed #dee2e6", cursor: "pointer", fontSize: 11, fontWeight: 600, px: 1, py: 0.5, borderRadius: "6px", color: "#6366f1", width: "100%", "&:hover": { borderColor: "#6366f1", bgcolor: "#f5f3ff" } } }, /* @__PURE__ */ React.createElement(Fe, { size: 13 }), " Add option"));
2610
- }
2611
- const Nt = [
2612
- { value: "operator", label: "Operator (predefined)" },
2613
- { value: "select", label: "Select" },
2614
- { value: "text", label: "Text" }
2615
- ];
2616
- function an({ col: r, onChange: e, onDelete: t }) {
2617
- const n = r.type === "select", a = r.type === "operator";
2618
- return /* @__PURE__ */ React.createElement(u, { sx: { border: "1px solid #e2e8f0", borderRadius: "7px", p: 1.25, bgcolor: "#fff", display: "flex", flexDirection: "column", gap: 1 } }, /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", alignItems: "center", gap: 0.75 } }, /* @__PURE__ */ React.createElement(u, { sx: { fontSize: 10, fontWeight: 700, px: 0.75, py: 0.2, borderRadius: "4px", bgcolor: a ? "#fef9c3" : "#eef2ff", color: a ? "#92400e" : "#6366f1", flexShrink: 0 } }, a ? "OPERATOR" : r.type.toUpperCase()), /* @__PURE__ */ React.createElement(u, { sx: { fontSize: 12, fontWeight: 600, color: "#0f172a", flex: 1 } }, r.label || r.id || "Unnamed"), /* @__PURE__ */ React.createElement(u, { component: "button", onClick: t, sx: { background: "none", border: "none", cursor: "pointer", color: "#94a3b8", display: "flex", p: 0.25, "&:hover": { color: "#dc2626" } } }, /* @__PURE__ */ React.createElement(te, { size: 13 }))), /* @__PURE__ */ React.createElement(u, { sx: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 1 } }, /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Column type"), /* @__PURE__ */ React.createElement("select", { value: r.type, onChange: (l) => e({ ...r, type: l.target.value, options: void 0 }), className: S, style: { cursor: "pointer" } }, Nt.map((l) => /* @__PURE__ */ React.createElement("option", { key: l.value, value: l.value }, l.label)))), /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Column key ", /* @__PURE__ */ React.createElement("span", { style: { color: "#dc3545" } }, "*")), /* @__PURE__ */ React.createElement("input", { className: `${S} ${r.id ? "" : "border-danger"}`, value: r.id, onChange: (l) => e({ ...r, id: l.target.value }), placeholder: "e.g. field, operator, value" }), !r.id && /* @__PURE__ */ React.createElement("span", { style: { fontSize: 10, color: "#dc3545" } }, "Required — used as data key"))), !a && /* @__PURE__ */ React.createElement(u, { sx: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 1 } }, /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Label"), /* @__PURE__ */ React.createElement("input", { className: S, value: r.label ?? "", onChange: (l) => e({ ...r, label: l.target.value || void 0 }), placeholder: "Column label" })), /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Placeholder"), /* @__PURE__ */ React.createElement("input", { className: S, value: r.placeholder ?? "", onChange: (l) => e({ ...r, placeholder: l.target.value || void 0 }), placeholder: "Hint…" }))), n && /* @__PURE__ */ React.createElement(_t, { options: r.options ?? [], onChange: (l) => e({ ...r, options: l }) }), a && /* @__PURE__ */ React.createElement(u, { sx: { bgcolor: "#fefce8", border: "1px solid #fef08a", borderRadius: "6px", px: 1.25, py: 0.75 } }, /* @__PURE__ */ React.createElement(u, { sx: { fontSize: 11, color: "#78350f" } }, "Predefined: equals, not equals, contains, starts with, ends with, is present, is not present, greater than, less than…")), !a && /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", alignItems: "center", gap: 0.75 } }, /* @__PURE__ */ React.createElement("input", { type: "checkbox", id: `formula-${r.id}`, checked: !!r.formula, onChange: (l) => e({ ...r, formula: l.target.checked || void 0 }), style: { cursor: "pointer", width: 14, height: 14 } }), /* @__PURE__ */ React.createElement("label", { htmlFor: `formula-${r.id}`, className: R, style: { margin: 0, cursor: "pointer" } }, "Formula input (chip editor)")));
2619
- }
2620
- function ln({ condition: r, onChange: e }) {
2621
- const t = !!r;
2622
- function n() {
2623
- e(t ? void 0 : { fields: [] });
2624
- }
2625
- function a(i) {
2626
- if (!r) return;
2627
- const o = i === "operator" ? "operator" : r.fields.filter((d) => d.type !== "operator").length === 0 ? "field" : "value";
2628
- e({ ...r, fields: [...r.fields, { id: o, type: i }] });
2629
- }
2630
- function l(i, o) {
2631
- if (!r) return;
2632
- const d = [...r.fields];
2633
- d[i] = o, e({ ...r, fields: d });
2634
- }
2635
- function s(i) {
2636
- r && e({ ...r, fields: r.fields.filter((o, d) => d !== i) });
2637
- }
2638
- return /* @__PURE__ */ React.createElement(u, { sx: { borderTop: "1px solid #e2e8f0", pt: 1.5 } }, /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", alignItems: "center", gap: 0.75, mb: t ? 1.25 : 0 } }, /* @__PURE__ */ React.createElement("input", { type: "checkbox", id: "enable-condition", checked: t, onChange: n, style: { cursor: "pointer", width: 14, height: 14 } }), /* @__PURE__ */ React.createElement("span", { style: { ...Z, margin: 0, color: t ? "#6366f1" : "#94a3b8" } }, "Condition row")), t && r && /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", flexDirection: "column", gap: 1 } }, r.fields.map((i, o) => /* @__PURE__ */ React.createElement(an, { key: o, col: i, onChange: (d) => l(o, d), onDelete: () => s(o) })), /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", gap: 0.5 } }, Nt.map((i) => /* @__PURE__ */ React.createElement(u, { key: i.value, component: "button", onClick: () => a(i.value), sx: { flex: 1, background: "none", border: "1px dashed #dee2e6", cursor: "pointer", fontSize: 11, fontWeight: 600, py: 0.5, borderRadius: "6px", color: i.value === "operator" ? "#92400e" : "#6366f1", "&:hover": { borderColor: "#6366f1", bgcolor: "#f5f3ff" } } }, "+ ", i.value === "operator" ? "Operator" : i.label.split(" ")[0]))), /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", alignItems: "center", gap: 2, flexWrap: "wrap" } }, /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", alignItems: "center", gap: 0.75 } }, /* @__PURE__ */ React.createElement("input", { type: "checkbox", id: "allow-groups", checked: !!r.allowGroups, onChange: (i) => e({ ...r, allowGroups: i.target.checked || void 0 }), style: { cursor: "pointer", width: 14, height: 14 } }), /* @__PURE__ */ React.createElement("label", { htmlFor: "allow-groups", className: R, style: { margin: 0, cursor: "pointer" } }, "Allow nested groups")), r.allowGroups && /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", alignItems: "center", gap: 0.75 } }, /* @__PURE__ */ React.createElement("label", { className: R, style: { margin: 0 } }, "Max depth"), /* @__PURE__ */ React.createElement("input", { type: "number", min: 1, max: 5, className: S, style: { width: 60, textAlign: "center" }, value: r.maxGroupDepth ?? "", onChange: (i) => e({ ...r, maxGroupDepth: i.target.value ? Number(i.target.value) : void 0 }), placeholder: "∞" })))));
2639
- }
2640
- function oe({ id: r, label: e, checked: t, onChange: n }) {
2641
- return /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", alignItems: "center", gap: 0.75 } }, /* @__PURE__ */ React.createElement("input", { type: "checkbox", id: r, checked: t, onChange: (a) => n(a.target.checked), style: { cursor: "pointer", width: 14, height: 14, flexShrink: 0 } }), /* @__PURE__ */ React.createElement("label", { htmlFor: r, className: R, style: { margin: 0, cursor: "pointer" } }, e));
2642
- }
2643
- function sn({ views: r = [], onChange: e }) {
2644
- function t(a, l, s) {
2645
- e(r.map((i, o) => o === a ? { ...i, [l]: s } : i));
2646
- }
2647
- function n() {
2648
- const a = `tab${r.length + 1}`;
2649
- e([...r, { id: a, label: `Tab ${r.length + 1}` }]);
2650
- }
2651
- return /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("span", { className: R }, "Views"), /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", flexDirection: "column", gap: 0.5, mb: 0.75 } }, r.map((a, l) => /* @__PURE__ */ React.createElement(u, { key: l, sx: { display: "flex", gap: 0.5, alignItems: "center" } }, /* @__PURE__ */ React.createElement("input", { className: S, style: { flex: 1 }, placeholder: "Label", value: a.label, onChange: (s) => t(l, "label", s.target.value) }), /* @__PURE__ */ React.createElement("input", { className: S, style: { flex: 1 }, placeholder: "ID (no spaces)", value: a.id, onChange: (s) => t(l, "id", s.target.value.replace(/\s/g, "_")) }), /* @__PURE__ */ React.createElement(u, { component: "button", onClick: () => e(r.filter((s, i) => i !== l)), sx: { background: "none", border: "none", cursor: "pointer", color: "#94a3b8", display: "flex", p: 0.25, "&:hover": { color: "#dc2626" } } }, /* @__PURE__ */ React.createElement(te, { size: 13 }))))), /* @__PURE__ */ React.createElement(u, { component: "button", onClick: n, sx: { display: "flex", alignItems: "center", gap: 0.5, background: "none", border: "1px dashed #dee2e6", cursor: "pointer", fontSize: 11, fontWeight: 600, px: 1, py: 0.5, borderRadius: "6px", color: "#6366f1", width: "100%", "&:hover": { borderColor: "#6366f1", bgcolor: "#f5f3ff" } } }, /* @__PURE__ */ React.createElement(Fe, { size: 13 }), " Add view"));
2652
- }
2653
- function ge({ label: r, value: e, options: t, onChange: n }) {
2654
- return /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("span", { className: R }, r), /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", border: "1px solid #dee2e6", borderRadius: "7px", overflow: "hidden" } }, t.map((a) => /* @__PURE__ */ React.createElement(
2655
- u,
2656
- {
2657
- key: a.value,
2658
- component: "button",
2659
- onClick: () => n(a.value),
2660
- sx: {
2661
- flex: 1,
2662
- border: "none",
2663
- borderRight: "1px solid #dee2e6",
2664
- cursor: "pointer",
2665
- fontSize: 12,
2666
- fontWeight: 600,
2667
- py: 0.6,
2668
- bgcolor: e === a.value ? "#eef2ff" : "#fff",
2669
- color: e === a.value ? "#6366f1" : "#6c757d",
2670
- "&:last-child": { borderRight: "none" },
2671
- "&:hover": { bgcolor: "#f5f3ff" }
2672
- }
2673
- },
2674
- a.label
2675
- ))));
2676
- }
2677
- function At({ field: r, onChange: e, onSave: t, onCancel: n, noFooter: a }) {
2678
- const [l, s] = F(!1), i = r.id ?? r.name ?? "", o = r, d = r.type === "select" || r.type === "descriptive-select" || r.type === "radio-group", p = Ze.get(r.type), m = p == null ? void 0 : p.configSchema;
2679
- function f(c, g) {
2680
- e({ ...r, [c]: g });
2681
- }
2682
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(u, { sx: { flex: 1, overflowY: "auto", px: 2.5, py: 2, display: "flex", flexDirection: "column", gap: 1.75 } }, /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("span", { style: Z }, "Required"), /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", flexDirection: "column", gap: 1 } }, /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Type"), /* @__PURE__ */ React.createElement("select", { value: r.type, onChange: (c) => f("type", c.target.value), className: S, style: { cursor: "pointer" } }, en.map((c) => /* @__PURE__ */ React.createElement("option", { key: c.value, value: c.value }, c.label)))), /* @__PURE__ */ React.createElement(u, { sx: { display: "grid", gridTemplateColumns: r.type === "tabs" ? "1fr" : "1fr 1fr", gap: 1 } }, /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Field ID ", /* @__PURE__ */ React.createElement("span", { style: { color: "#dc3545" } }, "*")), /* @__PURE__ */ React.createElement("input", { className: S, value: r.id ?? r.name ?? "", onChange: (c) => f("id", c.target.value), placeholder: "e.g. email" })), r.type !== "tabs" && /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Label ", /* @__PURE__ */ React.createElement("span", { style: { color: "#dc3545" } }, "*")), /* @__PURE__ */ React.createElement("input", { className: S, value: r.label ?? "", onChange: (c) => f("label", c.target.value), placeholder: "Display label" }))), r.type !== "tabs" && /* @__PURE__ */ React.createElement(nn, { value: r.colSpan, onChange: (c) => f("colSpan", c === 12 ? void 0 : c) }))), m && /* @__PURE__ */ React.createElement(u, { sx: { borderTop: "1px solid #e2e8f0", pt: 1.5 } }, /* @__PURE__ */ React.createElement("span", { style: Z }, "Specific Settings"), /* @__PURE__ */ React.createElement(
2683
- Ve,
2684
- {
2685
- schema: { layout: "flat", compact: !0, fields: m.fields },
2686
- initialValues: r,
2687
- onValuesChange: (c) => e({ ...r, ...c }),
2688
- onSubmit: () => {
2689
- }
2690
- }
2691
- )), r.type === "tabs" && /* @__PURE__ */ React.createElement(u, { sx: { borderTop: "1px solid #e2e8f0", pt: 1.5, display: "flex", flexDirection: "column", gap: 1.5 } }, /* @__PURE__ */ React.createElement("span", { style: Z }, "Content"), /* @__PURE__ */ React.createElement(
2692
- sn,
2693
- {
2694
- views: (o.tabs ?? []).map((c) => ({ id: c.id, label: c.label })),
2695
- onChange: (c) => {
2696
- const g = o.tabs ?? [], h = c.map((y) => {
2697
- const E = g.find((w) => w.id === y.id);
2698
- return E ? { ...E, ...y } : { ...y, fields: [] };
2699
- });
2700
- e({ ...r, tabs: h });
2701
- }
2702
- }
2703
- ), /* @__PURE__ */ React.createElement("span", { style: { ...Z, marginTop: 4 } }, "Interaction"), /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Disabled"), /* @__PURE__ */ React.createElement("input", { className: S, value: o.disabledExpr ?? "", onChange: (c) => e({ ...r, disabledExpr: c.target.value || void 0 }), placeholder: "false" })), /* @__PURE__ */ React.createElement("span", { style: { ...Z, marginTop: 4 } }, "Appearance"), /* @__PURE__ */ React.createElement(
2704
- ge,
2705
- {
2706
- label: "Alignment",
2707
- value: o.alignment ?? "left",
2708
- options: [
2709
- { value: "left", label: "|←" },
2710
- { value: "center-left", label: "←|" },
2711
- { value: "center", label: "|·|" },
2712
- { value: "center-right", label: "|→" },
2713
- { value: "right", label: "→|" }
2714
- ],
2715
- onChange: (c) => e({ ...r, alignment: c })
2716
- }
2717
- ), /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Hidden"), /* @__PURE__ */ React.createElement("input", { className: S, value: o.hiddenExpr ?? "", onChange: (c) => e({ ...r, hiddenExpr: c.target.value || void 0 }), placeholder: "false" })), /* @__PURE__ */ React.createElement(
2718
- ge,
2719
- {
2720
- label: "Variant",
2721
- value: o.variant ?? "line",
2722
- options: [{ value: "pill", label: "Pill" }, { value: "line", label: "Line" }],
2723
- onChange: (c) => e({ ...r, variant: c })
2724
- }
2725
- ), /* @__PURE__ */ React.createElement(u, { sx: { display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: 1 } }, /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Active color"), /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React.createElement("input", { type: "color", value: o.activeColor ?? "#6366f1", onChange: (c) => e({ ...r, activeColor: c.target.value }), style: { width: 28, height: 28, border: "1px solid #dee2e6", borderRadius: 6, cursor: "pointer", padding: 2, background: "#fff" } }), /* @__PURE__ */ React.createElement("input", { className: S, value: o.activeColor ?? "", onChange: (c) => e({ ...r, activeColor: c.target.value || void 0 }), placeholder: "#6366f1", style: { flex: 1 } }))), /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Active text"), /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React.createElement("input", { type: "color", value: o.activeTextColor ?? "#ffffff", onChange: (c) => e({ ...r, activeTextColor: c.target.value }), style: { width: 28, height: 28, border: "1px solid #dee2e6", borderRadius: 6, cursor: "pointer", padding: 2, background: "#fff" } }), /* @__PURE__ */ React.createElement("input", { className: S, value: o.activeTextColor ?? "", onChange: (c) => e({ ...r, activeTextColor: c.target.value || void 0 }), placeholder: "auto", style: { flex: 1 } }))), /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Inactive text"), /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React.createElement("input", { type: "color", value: o.inactiveTextColor ?? "#64748b", onChange: (c) => e({ ...r, inactiveTextColor: c.target.value }), style: { width: 28, height: 28, border: "1px solid #dee2e6", borderRadius: 6, cursor: "pointer", padding: 2, background: "#fff" } }), /* @__PURE__ */ React.createElement("input", { className: S, value: o.inactiveTextColor ?? "", onChange: (c) => e({ ...r, inactiveTextColor: c.target.value || void 0 }), placeholder: "#64748b", style: { flex: 1 } })))), /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Styles"), /* @__PURE__ */ React.createElement("input", { className: S, value: o.styles ?? "", onChange: (c) => e({ ...r, styles: c.target.value || void 0 }), placeholder: "None" })), /* @__PURE__ */ React.createElement("span", { style: { ...Z, marginTop: 4 } }, "Spacing"), /* @__PURE__ */ React.createElement(
2726
- ge,
2727
- {
2728
- label: "Height",
2729
- value: o.height ?? "auto",
2730
- options: [{ value: "auto", label: "Auto" }, { value: "fixed", label: "Fixed" }],
2731
- onChange: (c) => e({ ...r, height: c })
2732
- }
2733
- ), /* @__PURE__ */ React.createElement(
2734
- ge,
2735
- {
2736
- label: "Margin",
2737
- value: o.margin ?? "normal",
2738
- options: [{ value: "normal", label: "Normal" }, { value: "none", label: "None" }],
2739
- onChange: (c) => e({ ...r, margin: c })
2740
- }
2741
- )), d && /* @__PURE__ */ React.createElement(u, { sx: { borderTop: "1px solid #e2e8f0", pt: 1.5 } }, /* @__PURE__ */ React.createElement("span", { style: Z }, "Options"), /* @__PURE__ */ React.createElement(_t, { options: o.options ?? [], onChange: (c) => e({ ...r, options: c }) })), r.type === "array" && /* @__PURE__ */ React.createElement(u, { sx: { borderTop: "1px solid #e2e8f0", pt: 1.5, display: "flex", flexDirection: "column", gap: 1 } }, /* @__PURE__ */ React.createElement("span", { style: Z }, "Array settings"), /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Item type"), /* @__PURE__ */ React.createElement("select", { className: S, style: { cursor: "pointer" }, value: o.itemType ?? "text", onChange: (c) => e({ ...r, itemType: c.target.value }) }, tn.map((c) => /* @__PURE__ */ React.createElement("option", { key: c.value, value: c.value }, c.label)))), /* @__PURE__ */ React.createElement(u, { sx: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 1 } }, /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Item label"), /* @__PURE__ */ React.createElement("input", { className: S, value: o.itemLabel ?? "", onChange: (c) => e({ ...r, itemLabel: c.target.value || void 0 }), placeholder: 'e.g. "Member"' })), /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Add button label"), /* @__PURE__ */ React.createElement("input", { className: S, value: o.addLabel ?? "", onChange: (c) => e({ ...r, addLabel: c.target.value || void 0 }), placeholder: "Add item" }))), /* @__PURE__ */ React.createElement(u, { sx: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 1 } }, /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Min items"), /* @__PURE__ */ React.createElement("input", { type: "number", min: 0, className: S, value: o.minItems ?? "", onChange: (c) => e({ ...r, minItems: c.target.value ? Number(c.target.value) : void 0 }), placeholder: "0" })), /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Max items"), /* @__PURE__ */ React.createElement("input", { type: "number", min: 1, className: S, value: o.maxItems ?? "", onChange: (c) => e({ ...r, maxItems: c.target.value ? Number(c.target.value) : void 0 }), placeholder: "∞" }))), !["object", "array", "select"].includes(o.itemType ?? "text") && /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Item placeholder"), /* @__PURE__ */ React.createElement("input", { className: S, value: o.itemPlaceholder ?? "", onChange: (c) => e({ ...r, itemPlaceholder: c.target.value || void 0 }), placeholder: "Enter value…" }))), /* @__PURE__ */ React.createElement(
2742
- ln,
2743
- {
2744
- condition: r.condition,
2745
- onChange: (c) => e({ ...r, condition: c })
2746
- }
2747
- ), /* @__PURE__ */ React.createElement(u, { sx: { borderTop: "1px solid #e2e8f0", pt: 1.5 } }, /* @__PURE__ */ React.createElement(u, { component: "button", onClick: () => s((c) => !c), sx: { background: "none", border: "none", cursor: "pointer", display: "flex", alignItems: "center", gap: 0.5, p: 0, mb: l ? 1.25 : 0 } }, /* @__PURE__ */ React.createElement("span", { style: { ...Z, margin: 0, color: l ? "#6366f1" : "#94a3b8" } }, l ? "▾" : "▸", " Optional settings")), /* @__PURE__ */ React.createElement(Bt, { in: l }, /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", flexDirection: "column", gap: 1.25 } }, /* @__PURE__ */ React.createElement(u, { sx: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 1 } }, /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Placeholder"), /* @__PURE__ */ React.createElement("input", { className: S, value: r.placeholder ?? "", onChange: (c) => f("placeholder", c.target.value || void 0), placeholder: "Hint text…" })), /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Helper text"), /* @__PURE__ */ React.createElement("input", { className: S, value: r.helperText ?? "", onChange: (c) => f("helperText", c.target.value || void 0), placeholder: "Description…" }))), /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement("label", { className: R }, "Info tooltip"), /* @__PURE__ */ React.createElement("input", { className: S, value: r.info ?? "", onChange: (c) => f("info", c.target.value || void 0), placeholder: "Shown in ℹ tooltip" })), /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", flexWrap: "wrap", gap: 1.5 } }, /* @__PURE__ */ React.createElement(oe, { id: `${i}-req`, label: "Required", checked: !!r.required, onChange: (c) => f("required", c || void 0) }), /* @__PURE__ */ React.createElement(oe, { id: `${i}-dis`, label: "Disabled", checked: !!r.disabled, onChange: (c) => f("disabled", c || void 0) }), /* @__PURE__ */ React.createElement(oe, { id: `${i}-hid`, label: "Hidden", checked: !!r.hidden, onChange: (c) => f("hidden", c || void 0) }), /* @__PURE__ */ React.createElement(oe, { id: `${i}-opt`, label: "Show optional", checked: !!r.showOptional, onChange: (c) => f("showOptional", c || void 0) }), /* @__PURE__ */ React.createElement(oe, { id: `${i}-div`, label: "Divider after", checked: !!r.dividerAfter, onChange: (c) => f("dividerAfter", c || void 0) }), /* @__PURE__ */ React.createElement(oe, { id: `${i}-frm`, label: "Formula input", checked: !!r.formula, onChange: (c) => f("formula", c || void 0) })))))), !a && /* @__PURE__ */ React.createElement(u, { sx: { borderTop: "1px solid #e2e8f0", px: 2.5, py: 1.5, display: "flex", gap: 1, justifyContent: "flex-end", bgcolor: "#f8fafc", flexShrink: 0 } }, /* @__PURE__ */ React.createElement(u, { component: "button", onClick: n, sx: { background: "none", border: "1px solid #dee2e6", cursor: "pointer", fontSize: 13, fontWeight: 500, px: 2, py: 0.75, borderRadius: "7px", color: "#6c757d", "&:hover": { bgcolor: "#f8f9fa" } } }, "Cancel"), /* @__PURE__ */ React.createElement(u, { component: "button", onClick: t, sx: { border: "none", cursor: "pointer", fontSize: 13, fontWeight: 600, px: 2.5, py: 0.75, borderRadius: "7px", bgcolor: "#6366f1", color: "#fff", display: "flex", alignItems: "center", gap: 0.75, "&:hover": { bgcolor: "#4f46e5" } } }, /* @__PURE__ */ React.createElement(Te, { size: 15 }), " Save")));
2748
- }
2749
- const Re = {
2750
- text: "#0f172a",
2751
- textMuted: "#64748b",
2752
- borderInput: "rgba(0,0,0,0.23)",
2753
- bg: "#ffffff"
2754
- }, on = {
2755
- md: "6px"
2756
- }, zt = {
2757
- sm: 11,
2758
- md: 13
2759
- }, Ae = {
2760
- width: "100%",
2761
- fontSize: zt.md,
2762
- fontFamily: "inherit",
2763
- padding: "8px 12px",
2764
- border: `1px solid ${Re.borderInput}`,
2765
- borderRadius: on.md,
2766
- outline: "none",
2767
- background: Re.bg,
2768
- color: Re.text,
2769
- boxSizing: "border-box",
2770
- transition: "border-color 0.15s, box-shadow 0.15s"
2771
- };
2772
- function lt() {
2773
- return { type: "text", id: "", label: "", colSpan: 12 };
2774
- }
2775
- function cn(r) {
2776
- return r.type === "object" || r.type === "array" || r.type === "schema";
2777
- }
2778
- function un(r) {
2779
- if (r.type === "object") return "Child Fields";
2780
- if (r.type === "schema") return "Schema Fields";
2781
- const e = r.itemType ?? "text";
2782
- return e === "object" ? "Item Fields" : e === "select" ? "Item Options" : "Item Config";
2783
- }
2784
- function dn({ field: r, onChange: e }) {
2785
- var a;
2786
- const t = r, n = t.itemType ?? "text";
2787
- if (r.type === "object")
2788
- return /* @__PURE__ */ React.createElement(u, { sx: { p: 2.5 } }, /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 12, color: "#64748b", mb: 2 } }, "Define the fields nested inside this object. Each child field can itself be an object or array."), /* @__PURE__ */ React.createElement(
2789
- Se,
2790
- {
2791
- value: r.children ?? [],
2792
- onChange: (l) => e({ ...r, children: l }),
2793
- label: "Child fields"
2794
- }
2795
- ));
2796
- if (r.type === "schema")
2797
- return /* @__PURE__ */ React.createElement(u, { sx: { p: 2.5 } }, /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 12, color: "#64748b", mb: 2 } }, "Define the fields inside this schema. When the form is filled, their values are collected into a single object as this field's value."), /* @__PURE__ */ React.createElement(
2798
- Se,
2799
- {
2800
- value: r.children ?? [],
2801
- onChange: (l) => e({ ...r, children: l }),
2802
- label: "Schema fields"
2803
- }
2804
- ));
2805
- if (r.type === "array") {
2806
- if (n === "object")
2807
- return /* @__PURE__ */ React.createElement(u, { sx: { p: 2.5 } }, /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 12, color: "#64748b", mb: 2 } }, "Define the fields for each item in the array. Each item will be an object with these fields."), /* @__PURE__ */ React.createElement(
2808
- Se,
2809
- {
2810
- value: t.itemFields ?? [],
2811
- onChange: (l) => e({ ...r, itemFields: l }),
2812
- label: "Item fields"
2813
- }
2814
- ));
2815
- if (n === "select") {
2816
- const l = t.itemOptions ?? [];
2817
- return /* @__PURE__ */ React.createElement(u, { sx: { p: 2.5 } }, /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 12, color: "#64748b", mb: 2 } }, "Options available in each select item."), /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", flexDirection: "column", gap: 0.5, mb: 0.75 } }, l.map((s, i) => /* @__PURE__ */ React.createElement(u, { key: i, sx: { display: "flex", gap: 0.5, alignItems: "center" } }, /* @__PURE__ */ React.createElement(
2818
- "input",
2819
- {
2820
- style: { ...Ae, flex: 1, padding: "6px 10px" },
2821
- placeholder: "Label",
2822
- value: s.label,
2823
- onChange: (o) => {
2824
- const d = l.map((p, m) => m === i ? { ...p, label: o.target.value } : p);
2825
- e({ ...r, itemOptions: d });
2826
- }
2827
- }
2828
- ), /* @__PURE__ */ React.createElement(
2829
- "input",
2830
- {
2831
- style: { ...Ae, flex: 1, padding: "6px 10px" },
2832
- placeholder: "Value",
2833
- value: s.value,
2834
- onChange: (o) => {
2835
- const d = l.map((p, m) => m === i ? { ...p, value: o.target.value } : p);
2836
- e({ ...r, itemOptions: d });
2837
- }
2838
- }
2839
- ), /* @__PURE__ */ React.createElement(
2840
- u,
2841
- {
2842
- component: "button",
2843
- onClick: () => e({ ...r, itemOptions: l.filter((o, d) => d !== i) }),
2844
- sx: { background: "none", border: "none", cursor: "pointer", color: "#94a3b8", display: "flex", p: 0.25, "&:hover": { color: "#dc2626" } }
2845
- },
2846
- "✕"
2847
- )))), /* @__PURE__ */ React.createElement(
2848
- u,
2849
- {
2850
- component: "button",
2851
- onClick: () => e({ ...r, itemOptions: [...l, { label: "", value: "" }] }),
2852
- sx: { display: "flex", alignItems: "center", gap: 0.5, background: "none", border: "1px dashed #dee2e6", cursor: "pointer", fontSize: 11, fontWeight: 600, px: 1, py: 0.5, borderRadius: "6px", color: "#6366f1", width: "100%", justifyContent: "center", "&:hover": { borderColor: "#6366f1", bgcolor: "#f5f3ff" } }
2853
- },
2854
- "+ Add option"
2855
- ));
2856
- }
2857
- if (n === "array") {
2858
- const l = ((a = t.itemSchema) == null ? void 0 : a.itemType) ?? "text", s = [
2859
- { value: "text", label: "Text" },
2860
- { value: "number", label: "Number" },
2861
- { value: "email", label: "Email" },
2862
- { value: "url", label: "URL" },
2863
- { value: "password", label: "Password" },
2864
- { value: "select", label: "Select" },
2865
- { value: "object", label: "Object" }
2866
- ];
2867
- return /* @__PURE__ */ React.createElement(u, { sx: { p: 2.5 } }, /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 12, color: "#64748b", mb: 2 } }, "Each item is itself an array. Configure the type of items inside the nested array."), /* @__PURE__ */ React.createElement("label", { style: { fontSize: zt.sm, fontWeight: 600, color: Re.textMuted, display: "block", marginBottom: 3 } }, "Nested item type"), /* @__PURE__ */ React.createElement(
2868
- "select",
2869
- {
2870
- style: { ...Ae, padding: "6px 10px", cursor: "pointer" },
2871
- value: l,
2872
- onChange: (i) => e({ ...r, itemSchema: { ...t.itemSchema ?? {}, itemType: i.target.value } })
2873
- },
2874
- s.map((i) => /* @__PURE__ */ React.createElement("option", { key: i.value, value: i.value }, i.label))
2875
- ));
2876
- }
2877
- return /* @__PURE__ */ React.createElement(u, { sx: { p: 2.5 } }, /* @__PURE__ */ React.createElement(u, { sx: { border: "1.5px dashed #e2e8f0", borderRadius: "8px", py: 3, textAlign: "center" } }, /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 13, color: "#94a3b8" } }, "No extra configuration needed for ", /* @__PURE__ */ React.createElement("strong", null, n), " items."), /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 11, color: "#cbd5e1", mt: 0.5 } }, "Item placeholder and labels are set in the previous step.")));
2878
- }
2879
- return null;
2880
- }
2881
- function fn({ field: r }) {
2882
- var s;
2883
- const [e, t] = F({}), n = r.id ?? r.name ?? "preview", a = [
2884
- { value: 3, label: "1/4" },
2885
- { value: 4, label: "1/3" },
2886
- { value: 6, label: "1/2" },
2887
- { value: 8, label: "2/3" },
2888
- { value: 12, label: "Full" }
2889
- ], l = r.colSpan && r.colSpan < 12 ? ((s = a.find((i) => i.value === r.colSpan)) == null ? void 0 : s.label) ?? r.colSpan : "Full";
2890
- return /* @__PURE__ */ React.createElement(u, { sx: { p: 2.5 } }, /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", alignItems: "center", mb: 2, px: 1.25, py: 0.75, bgcolor: "#f0fdf4", border: "1px solid #bbf7d0", borderRadius: "7px" } }, /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 11, color: "#15803d", fontWeight: 500, flex: 1 } }, "Live preview — interact to test the field"), /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 11, color: "#64748b" } }, "Width: ", l)), /* @__PURE__ */ React.createElement(
2891
- Ve,
2892
- {
2893
- schema: { layout: "flat", fields: [r] },
2894
- initialValues: { [n]: r.type === "array" ? [] : r.type === "object" || r.type === "schema" ? {} : "" },
2895
- onSubmit: () => {
2896
- },
2897
- conditionConfig: e,
2898
- onConditionConfigChange: t
2899
- }
2900
- ));
2901
- }
2902
- function Le({ open: r, initial: e, onSave: t, onClose: n, editMode: a = !1 }) {
2903
- const [l, s] = F(1), [i, o] = F(() => e ?? lt());
2904
- function d() {
2905
- o(e ?? lt()), s(1);
2906
- }
2907
- const p = cn(i), m = p ? 3 : 2, f = p ? ["Configure", un(i), "Preview"] : ["Configure", "Preview"], c = !!(i.id || i.name) && !!i.type;
2908
- function g() {
2909
- s((C) => Math.min(C + 1, m));
2910
- }
2911
- function h() {
2912
- s((C) => Math.max(C - 1, 1));
2913
- }
2914
- function y() {
2915
- t(i), n();
2916
- }
2917
- const E = l - 1, w = l === m, $ = p && l === 3 || !p && l === 2;
2918
- return /* @__PURE__ */ React.createElement(
2919
- it,
2920
- {
2921
- open: r,
2922
- onClose: n,
2923
- TransitionProps: { onEnter: d },
2924
- maxWidth: "sm",
2925
- fullWidth: !0,
2926
- PaperProps: { sx: { borderRadius: "12px", overflow: "hidden", display: "flex", flexDirection: "column", maxHeight: "90vh" } }
2927
- },
2928
- /* @__PURE__ */ React.createElement(u, { sx: { px: 2.5, pt: 1.75, pb: 0, borderBottom: "1px solid #e2e8f0", flexShrink: 0 } }, /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", alignItems: "center", mb: 1.5 } }, /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 14, fontWeight: 700, color: "#0f172a", flex: 1 } }, a ? "Edit Field" : "Add Field"), /* @__PURE__ */ React.createElement(ke, { size: "small", onClick: n, sx: { color: "#94a3b8" } }, /* @__PURE__ */ React.createElement(te, { size: 17 }))), /* @__PURE__ */ React.createElement(Zt, { activeStep: E, sx: { pb: 1.5 } }, f.map((C, I) => /* @__PURE__ */ React.createElement(Ht, { key: C, completed: E > I }, /* @__PURE__ */ React.createElement(Yt, null, C))))),
2929
- /* @__PURE__ */ React.createElement(u, { sx: { flex: 1, overflowY: "auto" } }, l === 1 && /* @__PURE__ */ React.createElement(At, { field: i, onChange: o, onSave: g, onCancel: n, noFooter: !0 }), l === 2 && p && /* @__PURE__ */ React.createElement(dn, { field: i, onChange: o }), $ && /* @__PURE__ */ React.createElement(fn, { field: i })),
2930
- /* @__PURE__ */ React.createElement(u, { sx: { borderTop: "1px solid #e2e8f0", px: 2.5, py: 1.5, display: "flex", alignItems: "center", gap: 1, flexShrink: 0, bgcolor: "#f8fafc" } }, l > 1 && /* @__PURE__ */ React.createElement(u, { component: "button", onClick: h, sx: { display: "flex", alignItems: "center", gap: 0.5, background: "none", border: "none", cursor: "pointer", fontSize: 13, fontWeight: 500, color: "#6c757d", px: 0, "&:hover": { color: "#0f172a" } } }, /* @__PURE__ */ React.createElement(ct, { size: 14 }), " Back"), /* @__PURE__ */ React.createElement(u, { sx: { flex: 1 } }), /* @__PURE__ */ React.createElement(u, { component: "button", onClick: n, sx: { background: "none", border: "1px solid #dee2e6", cursor: "pointer", fontSize: 13, fontWeight: 500, px: 2, py: 0.75, borderRadius: "7px", color: "#6c757d", "&:hover": { bgcolor: "#f8f9fa" } } }, "Cancel"), w ? /* @__PURE__ */ React.createElement(u, { component: "button", onClick: y, sx: { border: "none", cursor: "pointer", fontSize: 13, fontWeight: 600, px: 2.5, py: 0.75, borderRadius: "7px", bgcolor: "#6366f1", color: "#fff", display: "flex", alignItems: "center", gap: 0.75, "&:hover": { bgcolor: "#4f46e5" } } }, /* @__PURE__ */ React.createElement(Te, { size: 15 }), " ", a ? "Save changes" : "Add field") : /* @__PURE__ */ React.createElement(u, { component: "button", onClick: g, disabled: !c, sx: { border: "none", cursor: c ? "pointer" : "not-allowed", fontSize: 13, fontWeight: 600, px: 2.5, py: 0.75, borderRadius: "7px", bgcolor: c ? "#6366f1" : "#c7d2fe", color: "#fff", "&:hover": { bgcolor: c ? "#4f46e5" : "#c7d2fe" } } }, "Next →"))
2931
- );
2932
- }
2933
- function pn({ field: r, index: e, total: t, onEdit: n, onDelete: a, onMoveUp: l, onMoveDown: s }) {
2934
- const i = r.label || r.id || r.name || "Untitled", o = r.id ?? r.name ?? "";
2935
- return /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", alignItems: "center", gap: 1, px: 1.5, py: 1, border: "1px solid #e2e8f0", borderRadius: "8px", bgcolor: "#fff" } }, /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", flexDirection: "column", gap: 0.25, color: "#cbd5e1" } }, /* @__PURE__ */ React.createElement(u, { component: "button", onClick: l, disabled: e === 0, sx: { background: "none", border: "none", p: 0, cursor: e === 0 ? "default" : "pointer", color: e === 0 ? "#e2e8f0" : "#94a3b8", lineHeight: 1, fontSize: 10, "&:hover": { color: e === 0 ? "#e2e8f0" : "#475569" } } }, "▲"), /* @__PURE__ */ React.createElement(u, { component: "button", onClick: s, disabled: e === t - 1, sx: { background: "none", border: "none", p: 0, cursor: e === t - 1 ? "default" : "pointer", color: e === t - 1 ? "#e2e8f0" : "#94a3b8", lineHeight: 1, fontSize: 10, "&:hover": { color: e === t - 1 ? "#e2e8f0" : "#475569" } } }, "▼")), /* @__PURE__ */ React.createElement(u, { sx: { fontSize: 10, fontWeight: 700, px: 0.75, py: 0.2, borderRadius: "4px", bgcolor: "#eef2ff", color: "#6366f1", flexShrink: 0 } }, r.type), /* @__PURE__ */ React.createElement(u, { sx: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 13, fontWeight: 600, color: "#0f172a", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, i, r.required && /* @__PURE__ */ React.createElement(u, { component: "span", sx: { color: "#dc3545", ml: 0.25 } }, "*")), /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 11, color: "#94a3b8", fontFamily: "monospace" } }, o)), /* @__PURE__ */ React.createElement(ee, { title: "Edit field", placement: "top" }, /* @__PURE__ */ React.createElement(u, { component: "button", onClick: n, sx: { background: "none", border: "none", cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", width: 28, height: 28, borderRadius: "6px", p: 0, color: "#94a3b8", "&:hover": { bgcolor: "#f1f5f9", color: "#475569" } } }, /* @__PURE__ */ React.createElement(Xt, { size: 14 }))), /* @__PURE__ */ React.createElement(ee, { title: "Remove field", placement: "top" }, /* @__PURE__ */ React.createElement(u, { component: "button", onClick: a, sx: { background: "none", border: "none", cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", width: 28, height: 28, borderRadius: "6px", p: 0, color: "#94a3b8", "&:hover": { bgcolor: "#fee2e2", color: "#dc2626" } } }, /* @__PURE__ */ React.createElement(Qt, { size: 16 }))));
2936
- }
2937
- function mn({ open: r, value: e, onSave: t, onClose: n }) {
2938
- const [a, l] = F(e), [s, i] = F(null);
2939
- function o() {
2940
- l(e), i(null);
2941
- }
2942
- function d(g) {
2943
- l((h) => h.filter((y, E) => E !== g));
2944
- }
2945
- function p(g, h) {
2946
- l((y) => {
2947
- const E = [...y], w = g + h;
2948
- return w < 0 || w >= E.length ? y : ([E[g], E[w]] = [E[w], E[g]], E);
2949
- });
2950
- }
2951
- function m(g) {
2952
- s !== null && (l((h) => {
2953
- const y = [...h];
2954
- return y[s] = g, y;
2955
- }), i(null));
2956
- }
2957
- function f() {
2958
- t(a), n();
2959
- }
2960
- const c = JSON.stringify(a) !== JSON.stringify(e);
2961
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
2962
- it,
2963
- {
2964
- open: r,
2965
- onClose: n,
2966
- TransitionProps: { onEnter: o },
2967
- maxWidth: "sm",
2968
- fullWidth: !0,
2969
- PaperProps: { sx: { borderRadius: "12px", overflow: "hidden", display: "flex", flexDirection: "column", maxHeight: "85vh" } }
2970
- },
2971
- /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", alignItems: "center", px: 2.5, py: 1.75, borderBottom: "1px solid #e2e8f0", flexShrink: 0 } }, /* @__PURE__ */ React.createElement(u, { sx: { flex: 1 } }, /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 14, fontWeight: 700, color: "#0f172a" } }, "Edit Schema"), /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 11, color: "#94a3b8" } }, a.length, " field", a.length !== 1 ? "s" : "", " defined")), /* @__PURE__ */ React.createElement(ke, { size: "small", onClick: n, sx: { color: "#94a3b8" } }, /* @__PURE__ */ React.createElement(te, { size: 17 }))),
2972
- /* @__PURE__ */ React.createElement(u, { sx: { flex: 1, overflowY: "auto", p: 2.5 } }, a.length === 0 ? /* @__PURE__ */ React.createElement(u, { sx: { border: "1.5px dashed rgba(0,0,0,0.12)", borderRadius: "8px", py: 4, textAlign: "center" } }, /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 13, color: "#94a3b8" } }, "No fields defined yet")) : /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", flexDirection: "column", gap: 0.75 } }, a.map((g, h) => /* @__PURE__ */ React.createElement(
2973
- pn,
2974
- {
2975
- key: `${g.id ?? g.name}-${h}`,
2976
- field: g,
2977
- index: h,
2978
- total: a.length,
2979
- onEdit: () => i(h),
2980
- onDelete: () => d(h),
2981
- onMoveUp: () => p(h, -1),
2982
- onMoveDown: () => p(h, 1)
2983
- }
2984
- )))),
2985
- /* @__PURE__ */ React.createElement(u, { sx: { borderTop: "1px solid #e2e8f0", px: 2.5, py: 1.5, display: "flex", alignItems: "center", gap: 1, flexShrink: 0, bgcolor: "#f8fafc" } }, c ? /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 11, color: "#f59e0b", fontWeight: 500, flex: 1 } }, "Unsaved changes") : /* @__PURE__ */ React.createElement(u, { sx: { flex: 1 } }), /* @__PURE__ */ React.createElement(u, { component: "button", onClick: n, sx: { background: "none", border: "1px solid #dee2e6", cursor: "pointer", fontSize: 13, fontWeight: 500, px: 2, py: 0.75, borderRadius: "7px", color: "#6c757d", "&:hover": { bgcolor: "#f8f9fa" } } }, "Cancel"), /* @__PURE__ */ React.createElement(u, { component: "button", onClick: f, sx: { border: "none", cursor: "pointer", fontSize: 13, fontWeight: 600, px: 2.5, py: 0.75, borderRadius: "7px", bgcolor: "#6366f1", color: "#fff", display: "flex", alignItems: "center", gap: 0.75, "&:hover": { bgcolor: "#4f46e5" } } }, /* @__PURE__ */ React.createElement(Te, { size: 15 }), " Done"))
2986
- ), s !== null && /* @__PURE__ */ React.createElement(
2987
- Le,
2988
- {
2989
- open: s !== null,
2990
- initial: a[s],
2991
- onSave: m,
2992
- onClose: () => i(null),
2993
- editMode: !0
2994
- }
2995
- ));
2996
- }
2997
- function It(r) {
2998
- const e = {};
2999
- for (const t of r) {
3000
- const n = t.id ?? t.name ?? "";
3001
- n && (t.type === "array" ? e[n] = [] : t.type === "object" || t.type === "schema" ? e[n] = It(t.children ?? []) : e[n] = "");
3002
- }
3003
- return e;
3004
- }
3005
- function Se({
3006
- value: r,
3007
- onChange: e,
3008
- suggestions: t,
3009
- label: n = "Fields",
3010
- onPayload: a,
3011
- validate: l = !0,
3012
- onValidityChange: s,
3013
- variableGroups: i,
3014
- initialValues: o,
3015
- initialFormulaConfig: d,
3016
- initialConditionConfig: p
3017
- }) {
3018
- const [m, f] = F(!1), [c, g] = F(!1), [h, y] = F(null), [E, w] = F(d ?? {}), [$, C] = F(p ?? {}), I = Y(o ?? {}), V = ce(() => It(r), [r]), K = ce(
3019
- () => o && Object.keys(o).length > 0 ? { ...V, ...o } : V,
3020
- // eslint-disable-next-line react-hooks/exhaustive-deps
3021
- [V, o]
3022
- ), U = ce(
3023
- () => l ? He(r) : void 0,
3024
- [l, r]
3025
- );
3026
- me(() => {
3027
- a && a({
3028
- schema: r,
3029
- formulaConfig: E,
3030
- conditionConfig: $,
3031
- conditionExpressions: Ge($),
3032
- values: I.current,
3033
- evaluationPayload: ze({ values: I.current, conditionConfig: $ })
3034
- });
3035
- }, [$, E, r]);
3036
- const j = he((z) => {
3037
- I.current = z, a && a({
3038
- schema: r,
3039
- formulaConfig: E,
3040
- conditionConfig: $,
3041
- conditionExpressions: Ge($),
3042
- values: z,
3043
- evaluationPayload: ze({ values: z, conditionConfig: $ })
3044
- });
3045
- }, [r, E, $, a]);
3046
- function q(z) {
3047
- e([...r, z]);
3048
- }
3049
- function T(z) {
3050
- if (!h) return;
3051
- const { containerFieldId: re, tabId: ne } = h, pe = r.map((P) => {
3052
- if ((P.id ?? P.name) !== re) return P;
3053
- const se = P.tabs ?? [];
3054
- return {
3055
- ...P,
3056
- tabs: se.map(
3057
- (W) => W.id === ne ? { ...W, fields: [...W.fields ?? [], z] } : W
3058
- )
3059
- };
3060
- });
3061
- e(pe), y(null);
3062
- }
3063
- function v(z, re, ne) {
3064
- const pe = r.map((P) => {
3065
- if ((P.id ?? P.name) !== z) return P;
3066
- const se = P.tabs ?? [];
3067
- return {
3068
- ...P,
3069
- tabs: se.map(
3070
- (W) => W.id === re ? { ...W, fields: (W.fields ?? []).filter((Ye, $e) => $e !== ne) } : W
3071
- )
3072
- };
3073
- });
3074
- e(pe);
3075
- }
3076
- const X = ce(() => ({
3077
- openAddFieldDialog: (z, re) => y({ containerFieldId: z, tabId: re }),
3078
- removeFieldFromTab: v
3079
- // eslint-disable-next-line react-hooks/exhaustive-deps
3080
- }), [r, e]), fe = /* @__PURE__ */ React.createElement("div", { className: "schema-builder-root" }, r.length > 0 && /* @__PURE__ */ React.createElement("div", { className: "schema-builder-header" }, /* @__PURE__ */ React.createElement("div", { className: "schema-builder-actions" }, /* @__PURE__ */ React.createElement(ee, { title: "Edit schema", placement: "top" }, /* @__PURE__ */ React.createElement(
3081
- "button",
3082
- {
3083
- className: "sb-btn sb-btn-outline",
3084
- onClick: () => g(!0)
3085
- },
3086
- /* @__PURE__ */ React.createElement(ut, { size: 13 }),
3087
- " Edit Schema"
3088
- )), /* @__PURE__ */ React.createElement(ee, { title: "Add a new field", placement: "top" }, /* @__PURE__ */ React.createElement(
3089
- "button",
3090
- {
3091
- className: "sb-btn sb-btn-primary",
3092
- onClick: () => f(!0)
3093
- },
3094
- /* @__PURE__ */ React.createElement(Fe, { size: 14 }),
3095
- " Add Field"
3096
- )))), r.length > 0 ? /* @__PURE__ */ React.createElement(qt.Provider, { value: X }, /* @__PURE__ */ React.createElement(
3097
- Ve,
3098
- {
3099
- schema: { layout: "flat", fields: r },
3100
- initialValues: K,
3101
- onSubmit: () => {
3102
- },
3103
- validationSchema: U,
3104
- onValidityChange: s,
3105
- onValuesChange: a ? j : void 0,
3106
- formulaConfig: E,
3107
- onFormulaConfigChange: w,
3108
- conditionConfig: $,
3109
- onConditionConfigChange: C
3110
- }
3111
- )) : /* @__PURE__ */ React.createElement("div", { className: "schema-builder-empty-state" }, /* @__PURE__ */ React.createElement(tr, { size: 40, className: "schema-builder-empty-icon" }), /* @__PURE__ */ React.createElement("p", { className: "schema-builder-empty-title" }, "Tell us what fields should be in the list, and assign values to them."), /* @__PURE__ */ React.createElement("div", { className: "schema-builder-empty-actions" }, /* @__PURE__ */ React.createElement(
3112
- "button",
3113
- {
3114
- className: "btn",
3115
- onClick: () => f(!0)
3116
- },
3117
- "Add field"
3118
- ))), /* @__PURE__ */ React.createElement(
3119
- Le,
3120
- {
3121
- open: m,
3122
- onSave: q,
3123
- onClose: () => f(!1)
3124
- }
3125
- ), /* @__PURE__ */ React.createElement(
3126
- mn,
3127
- {
3128
- open: c,
3129
- value: r,
3130
- onSave: e,
3131
- onClose: () => g(!1)
3132
- }
3133
- ), /* @__PURE__ */ React.createElement(
3134
- Le,
3135
- {
3136
- open: !!h,
3137
- onSave: T,
3138
- onClose: () => y(null)
3139
- }
3140
- ));
3141
- return i ? /* @__PURE__ */ React.createElement(Wt, { groups: i }, /* @__PURE__ */ React.createElement(Ut, { width: 260, mode: "popover" }), fe) : fe;
3142
- }
3143
- function hn({ fields: r, onOpen: e }) {
3144
- return /* @__PURE__ */ React.createElement(u, { sx: { border: "1px solid #e2e8f0", borderRadius: "8px", bgcolor: "#fff", overflow: "hidden" } }, r.length > 0 ? /* @__PURE__ */ React.createElement(u, { sx: { px: 1.5, py: 1.25, display: "flex", flexWrap: "wrap", gap: 0.5 } }, r.map((t, n) => {
3145
- const a = t.id ?? t.name ?? "";
3146
- return /* @__PURE__ */ React.createElement(ee, { key: n, title: `${t.type} · ${a}`, placement: "top" }, /* @__PURE__ */ React.createElement(
3147
- Jt,
3148
- {
3149
- label: t.label || a,
3150
- size: "small",
3151
- sx: { fontSize: 11, fontWeight: 500, height: 22, bgcolor: "#f1f5f9", color: "#334155", border: "1px solid #e2e8f0", "& .MuiChip-label": { px: 1 } }
3152
- }
3153
- ));
3154
- })) : /* @__PURE__ */ React.createElement(u, { sx: { px: 1.5, py: 1.5 } }, /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 12, color: "#94a3b8" } }, "No fields defined yet")), /* @__PURE__ */ React.createElement(Kt, { sx: { borderColor: "#f1f5f9" } }), /* @__PURE__ */ React.createElement(u, { onClick: e, sx: { display: "flex", alignItems: "center", gap: 0.75, px: 1.5, py: 1, cursor: "pointer", "&:hover": { bgcolor: "#f8fafc" }, transition: "background 0.12s" } }, r.length === 0 ? /* @__PURE__ */ React.createElement(Fe, { size: 14, color: "#6366f1" }) : /* @__PURE__ */ React.createElement(ut, { size: 13, color: "#6366f1" }), /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 12, fontWeight: 600, color: "#6366f1", flex: 1 } }, r.length === 0 ? "Add fields" : "Configure fields"), /* @__PURE__ */ React.createElement(er, { size: 13, color: "#94a3b8" })));
3155
- }
3156
- function kn({
3157
- value: r,
3158
- onChange: e,
3159
- suggestions: t,
3160
- onPayload: n,
3161
- onDone: a,
3162
- validate: l,
3163
- onValidityChange: s,
3164
- label: i = "Fields",
3165
- drawerTitle: o = "Configure Fields",
3166
- drawerWidth: d = 580
3167
- }) {
3168
- const [p, m] = F(!1), [f, c] = F({ type: "list" }), [g, h] = F(r), y = Y(null), E = Y(void 0), w = Y(void 0), $ = Y(void 0), [C, I] = F(null);
3169
- function V() {
3170
- h(r), c({ type: "list" }), m(!0);
3171
- }
3172
- function K() {
3173
- const v = y.current;
3174
- v && (E.current = v.values, w.current = v.formulaConfig, $.current = v.conditionConfig), e(g), m(!1), a == null || a(g, v);
3175
- }
3176
- function U() {
3177
- const v = y.current;
3178
- v && (E.current = v.values, w.current = v.formulaConfig, $.current = v.conditionConfig), h(r), m(!1);
3179
- }
3180
- function j() {
3181
- if (f.type !== "edit" || !C) return;
3182
- const v = [...g];
3183
- v[f.index] = C, h(v), c({ type: "list" }), I(null);
3184
- }
3185
- function q() {
3186
- c({ type: "list" }), I(null);
3187
- }
3188
- const T = JSON.stringify(g) !== JSON.stringify(r);
3189
- return f.type === "edit" && g[f.index], /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(u, null, /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 12, fontWeight: 700, color: "#64748b", textTransform: "uppercase", letterSpacing: 0.5, mb: 0.75 } }, i), /* @__PURE__ */ React.createElement(hn, { fields: r, onOpen: V })), /* @__PURE__ */ React.createElement(
3190
- Gt,
3191
- {
3192
- anchor: "right",
3193
- open: p,
3194
- onClose: U,
3195
- PaperProps: { sx: { width: d, display: "flex", flexDirection: "column", boxShadow: "-4px 0 24px rgba(0,0,0,0.12)", overflow: "hidden" } }
3196
- },
3197
- /* @__PURE__ */ React.createElement(u, { sx: { display: "flex", alignItems: "center", px: 2, py: 1.5, borderBottom: "1px solid #e2e8f0", flexShrink: 0, gap: 1 } }, f.type === "edit" && /* @__PURE__ */ React.createElement(ee, { title: "Back to fields", placement: "bottom" }, /* @__PURE__ */ React.createElement(ke, { size: "small", onClick: q, sx: { color: "#64748b" } }, /* @__PURE__ */ React.createElement(ct, { size: 17 }))), /* @__PURE__ */ React.createElement(u, { sx: { flex: 1 } }, /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 14, fontWeight: 700, color: "#0f172a" } }, f.type === "edit" ? (C == null ? void 0 : C.label) || (C == null ? void 0 : C.id) || "Edit field" : o), /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 11, color: "#94a3b8" } }, f.type === "edit" ? "Configure field properties" : `${g.length} field${g.length !== 1 ? "s" : ""} defined`)), f.type === "list" && /* @__PURE__ */ React.createElement(ee, { title: "Close", placement: "bottom" }, /* @__PURE__ */ React.createElement(ke, { size: "small", onClick: U, sx: { color: "#94a3b8" } }, /* @__PURE__ */ React.createElement(te, { size: 17 })))),
3198
- f.type === "list" && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(u, { sx: { flex: 1, overflowY: "auto", p: 2.5 } }, /* @__PURE__ */ React.createElement(
3199
- Se,
3200
- {
3201
- value: g,
3202
- onChange: h,
3203
- suggestions: t,
3204
- onPayload: (v) => {
3205
- y.current = v, E.current = v.values, w.current = v.formulaConfig, $.current = v.conditionConfig, n == null || n(v);
3206
- },
3207
- validate: l,
3208
- onValidityChange: s,
3209
- label: i,
3210
- initialValues: E.current,
3211
- initialFormulaConfig: w.current,
3212
- initialConditionConfig: $.current
3213
- }
3214
- )), /* @__PURE__ */ React.createElement(u, { sx: { borderTop: "1px solid #e2e8f0", px: 2.5, py: 1.5, display: "flex", alignItems: "center", gap: 1, flexShrink: 0, bgcolor: "#f8fafc" } }, T ? /* @__PURE__ */ React.createElement(_, { sx: { fontSize: 11, color: "#f59e0b", fontWeight: 500, flex: 1 } }, "Unsaved changes") : /* @__PURE__ */ React.createElement(u, { sx: { flex: 1 } }), /* @__PURE__ */ React.createElement(u, { component: "button", onClick: U, sx: { background: "none", border: "1px solid #dee2e6", cursor: "pointer", fontSize: 13, fontWeight: 500, px: 2, py: 0.75, borderRadius: "7px", color: "#6c757d", "&:hover": { bgcolor: "#f8f9fa" } } }, "Cancel"), /* @__PURE__ */ React.createElement(u, { component: "button", onClick: K, sx: { border: "none", cursor: "pointer", fontSize: 13, fontWeight: 600, px: 2.5, py: 0.75, borderRadius: "7px", bgcolor: "#6366f1", color: "#fff", display: "flex", alignItems: "center", gap: 0.75, "&:hover": { bgcolor: "#4f46e5" } } }, /* @__PURE__ */ React.createElement(Te, { size: 15 }), " Done"))),
3215
- f.type === "edit" && C && /* @__PURE__ */ React.createElement(
3216
- At,
3217
- {
3218
- field: C,
3219
- onChange: I,
3220
- onSave: j,
3221
- onCancel: q
3222
- }
3223
- )
3224
- ));
3225
- }
3226
- export {
3227
- en as F,
3228
- Se as S,
3229
- Xr as T,
3230
- Ze as a,
3231
- kn as b,
3232
- He as c,
3233
- Gr as d,
3234
- Sn as u
3235
- };