@notmrabhi/flowforge 0.1.10 → 0.1.12

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