treege 3.0.0-beta.19 → 3.0.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -3
- package/dist/{ThemeContext-CQoWKClD.js → ThemeContext-BIT4DHqC.js} +65 -47
- package/dist/{TreegeEditor-BP0R2rMo.js → TreegeEditor-LKN_xeXZ.js} +2 -2
- package/dist/TreegeRenderer--ZEq_w_0.js +1812 -0
- package/dist/editor.js +2 -2
- package/dist/main.js +18 -16
- package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +1 -1
- package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
- package/dist/renderer/hooks/useTranslate.d.ts +6 -4
- package/dist/renderer/index.d.ts +1 -0
- package/dist/renderer/utils/sanitize.d.ts +85 -0
- package/dist/renderer.js +18 -16
- package/dist/shared/locales/ar.json.d.ts +3 -3
- package/dist/shared/locales/de.json.d.ts +3 -3
- package/dist/shared/locales/en.json.d.ts +3 -3
- package/dist/shared/locales/es.json.d.ts +3 -3
- package/dist/shared/locales/fr.json.d.ts +3 -3
- package/dist/shared/locales/it.json.d.ts +3 -3
- package/dist/shared/locales/pt.json.d.ts +3 -3
- package/package.json +3 -1
- package/dist/TreegeRenderer-ClfGb4Mq.js +0 -1754
|
@@ -1,1754 +0,0 @@
|
|
|
1
|
-
import { j as t, i as W, L as be, b as Ue, e as Nt, F as E, f as D, I as X, C as De, h as Re, k as ke, l as Ae, m as Ee, n as O, o as P, P as me, p as fe, B as le, q as pe, r as Ge, s as y, t as Ve, v as Me, S as We, w as Ke, x as Je, y as Qe, z as Xe, A as Ye, D as wt, E as vt, G as je, g as ne, N as ue, a as St, c as Ft, T as Ct } from "./ThemeContext-CQoWKClD.js";
|
|
2
|
-
import * as ze from "react";
|
|
3
|
-
import { createContext as Ze, useContext as et, useMemo as G, useRef as K, useState as B, useCallback as Q, useEffect as J, forwardRef as It } from "react";
|
|
4
|
-
import { MapPin as Be, ChevronsUpDown as tt, Check as st, ChevronLeftIcon as Tt, ChevronRightIcon as Dt, ChevronDownIcon as Oe, Loader2 as ye, CircleIcon as Rt } from "lucide-react";
|
|
5
|
-
import { getDefaultClassNames as rt, DayPicker as kt } from "react-day-picker";
|
|
6
|
-
import * as ae from "@radix-ui/react-tooltip";
|
|
7
|
-
import * as Ie from "@radix-ui/react-radio-group";
|
|
8
|
-
import "cmdk";
|
|
9
|
-
import "@radix-ui/react-dialog";
|
|
10
|
-
import "clsx";
|
|
11
|
-
import "tailwind-merge";
|
|
12
|
-
import "@radix-ui/react-label";
|
|
13
|
-
import "@radix-ui/react-popover";
|
|
14
|
-
import "@radix-ui/react-checkbox";
|
|
15
|
-
import "@radix-ui/react-select";
|
|
16
|
-
import "@radix-ui/react-switch";
|
|
17
|
-
import "@radix-ui/react-separator";
|
|
18
|
-
const nt = Ze(void 0), at = () => et(nt), Ls = ({
|
|
19
|
-
children: e,
|
|
20
|
-
components: r,
|
|
21
|
-
googleApiKey: n,
|
|
22
|
-
language: s,
|
|
23
|
-
theme: o,
|
|
24
|
-
validationMode: i
|
|
25
|
-
}) => {
|
|
26
|
-
const a = {
|
|
27
|
-
components: r,
|
|
28
|
-
googleApiKey: n,
|
|
29
|
-
language: s,
|
|
30
|
-
theme: o,
|
|
31
|
-
validationMode: i
|
|
32
|
-
};
|
|
33
|
-
return /* @__PURE__ */ t.jsx(nt.Provider, { value: a, children: e });
|
|
34
|
-
}, qe = (e) => e == null ? null : typeof e == "boolean" || typeof e == "number" ? e : typeof e == "string" ? e === "" ? null : e : typeof e == "object" ? JSON.stringify(e) : String(e), At = (e, r, n) => {
|
|
35
|
-
const s = qe(e), o = qe(r);
|
|
36
|
-
if (s === null || o === null)
|
|
37
|
-
switch (n) {
|
|
38
|
-
case "===":
|
|
39
|
-
return s === o;
|
|
40
|
-
case "!==":
|
|
41
|
-
return s !== o;
|
|
42
|
-
default:
|
|
43
|
-
return !1;
|
|
44
|
-
}
|
|
45
|
-
if ([">", "<", ">=", "<="].includes(n)) {
|
|
46
|
-
const i = Number(s), a = Number(o);
|
|
47
|
-
if (!(Number.isNaN(i) || Number.isNaN(a)))
|
|
48
|
-
switch (n) {
|
|
49
|
-
case ">":
|
|
50
|
-
return i > a;
|
|
51
|
-
case "<":
|
|
52
|
-
return i < a;
|
|
53
|
-
case ">=":
|
|
54
|
-
return i >= a;
|
|
55
|
-
case "<=":
|
|
56
|
-
return i <= a;
|
|
57
|
-
default:
|
|
58
|
-
return !1;
|
|
59
|
-
}
|
|
60
|
-
return !1;
|
|
61
|
-
}
|
|
62
|
-
switch (n) {
|
|
63
|
-
case "===": {
|
|
64
|
-
const i = Number(s), a = Number(o);
|
|
65
|
-
return Number.isNaN(i) || Number.isNaN(a) ? String(s) === String(o) : i === a;
|
|
66
|
-
}
|
|
67
|
-
case "!==": {
|
|
68
|
-
const i = Number(s), a = Number(o);
|
|
69
|
-
return Number.isNaN(i) || Number.isNaN(a) ? String(s) !== String(o) : i !== a;
|
|
70
|
-
}
|
|
71
|
-
default:
|
|
72
|
-
return !1;
|
|
73
|
-
}
|
|
74
|
-
}, Ne = (e, r, n) => {
|
|
75
|
-
const { field: s, operator: o, value: i } = e;
|
|
76
|
-
if (!(s && o) || i === void 0)
|
|
77
|
-
return !0;
|
|
78
|
-
let a = r[s];
|
|
79
|
-
if (a === void 0 && n) {
|
|
80
|
-
const l = n.get(s);
|
|
81
|
-
l && W(l) && (a = r[l.id]);
|
|
82
|
-
}
|
|
83
|
-
return At(a, i, o);
|
|
84
|
-
}, Et = (e, r, n) => {
|
|
85
|
-
if (!e || e.length === 0)
|
|
86
|
-
return !0;
|
|
87
|
-
if (e.length === 1)
|
|
88
|
-
return Ne(e[0], r, n);
|
|
89
|
-
let s = Ne(e[0], r, n);
|
|
90
|
-
for (let o = 1; o < e.length; o += 1) {
|
|
91
|
-
const i = e[o], a = Ne(i, r, n), l = e[o - 1].logicalOperator || be.AND;
|
|
92
|
-
if (l === be.AND) {
|
|
93
|
-
if (s = s && a, !s)
|
|
94
|
-
return !1;
|
|
95
|
-
} else if (l === be.OR && (s = s || a, s))
|
|
96
|
-
return !0;
|
|
97
|
-
}
|
|
98
|
-
return s;
|
|
99
|
-
}, Ot = (e) => e.filter(W), Pe = (e) => {
|
|
100
|
-
if (e.data.name)
|
|
101
|
-
return e.data.name;
|
|
102
|
-
if (e.data.label) {
|
|
103
|
-
if (e.data.label.en)
|
|
104
|
-
return e.data.label.en;
|
|
105
|
-
const r = Object.values(e.data.label).find(Boolean);
|
|
106
|
-
if (r)
|
|
107
|
-
return r;
|
|
108
|
-
}
|
|
109
|
-
return e.id;
|
|
110
|
-
}, Pt = (e, r) => {
|
|
111
|
-
const n = r.find((s) => s.id === e);
|
|
112
|
-
return n ? Pe(n) : void 0;
|
|
113
|
-
}, we = (e) => e == null || typeof e == "string" && e.trim() === "" ? !0 : Array.isArray(e) && e.length === 0, $t = (e, r) => {
|
|
114
|
-
if (!e)
|
|
115
|
-
return !1;
|
|
116
|
-
const n = r[e];
|
|
117
|
-
return n != null;
|
|
118
|
-
}, $e = (e, r) => {
|
|
119
|
-
const n = {};
|
|
120
|
-
return r.forEach((s) => {
|
|
121
|
-
const o = s.id, i = Pe(s);
|
|
122
|
-
e[o] !== void 0 && (n[i] = e[o]);
|
|
123
|
-
}), n;
|
|
124
|
-
}, Le = (e, r, n) => {
|
|
125
|
-
if (!r)
|
|
126
|
-
return e;
|
|
127
|
-
switch (r) {
|
|
128
|
-
case "toString":
|
|
129
|
-
return String(e);
|
|
130
|
-
case "toNumber":
|
|
131
|
-
return Number(e);
|
|
132
|
-
case "toBoolean":
|
|
133
|
-
if (typeof e == "string") {
|
|
134
|
-
const s = e.trim().toLowerCase();
|
|
135
|
-
if (["true", "1", "yes", "on"].includes(s))
|
|
136
|
-
return !0;
|
|
137
|
-
if (["false", "0", "no", "off", ""].includes(s))
|
|
138
|
-
return !1;
|
|
139
|
-
}
|
|
140
|
-
return typeof e == "number" ? e !== 0 : typeof e == "boolean" ? e : !!e;
|
|
141
|
-
case "toArray":
|
|
142
|
-
return Array.isArray(e) ? e : [e];
|
|
143
|
-
case "toObject":
|
|
144
|
-
if (n && Array.isArray(n)) {
|
|
145
|
-
if (typeof e != "object" || e === null)
|
|
146
|
-
return e;
|
|
147
|
-
const s = {};
|
|
148
|
-
return n.forEach((o) => {
|
|
149
|
-
o.sourceKey && o.targetKey && (s[o.targetKey] = e[o.sourceKey]);
|
|
150
|
-
}), s;
|
|
151
|
-
}
|
|
152
|
-
return e;
|
|
153
|
-
default:
|
|
154
|
-
return e;
|
|
155
|
-
}
|
|
156
|
-
}, He = (e, r) => {
|
|
157
|
-
if (Object.is(e, r))
|
|
158
|
-
return !0;
|
|
159
|
-
if (!(e && r) || typeof e != "object" || typeof r != "object")
|
|
160
|
-
return !1;
|
|
161
|
-
try {
|
|
162
|
-
return JSON.stringify(e) === JSON.stringify(r);
|
|
163
|
-
} catch {
|
|
164
|
-
return !1;
|
|
165
|
-
}
|
|
166
|
-
}, _t = (e, r, n) => {
|
|
167
|
-
const s = {};
|
|
168
|
-
return e.forEach((o) => {
|
|
169
|
-
const { defaultValue: i } = o.data;
|
|
170
|
-
if (!i || i.type !== "reference" || !i.referenceField)
|
|
171
|
-
return;
|
|
172
|
-
const a = o.id, { referenceField: l, transformFunction: c, objectMapping: m } = i, u = r[l], d = n[l];
|
|
173
|
-
if (u === d || u === void 0 || u === null)
|
|
174
|
-
return;
|
|
175
|
-
const f = Le(u, c, m), g = Le(d, c, m), h = r[a], p = He(h, g), j = He(h, f);
|
|
176
|
-
!p || j || (s[a] = f);
|
|
177
|
-
}), s;
|
|
178
|
-
}, Vt = (e) => {
|
|
179
|
-
const r = /* @__PURE__ */ new Map();
|
|
180
|
-
return e.forEach((n) => {
|
|
181
|
-
const s = r.get(n.source);
|
|
182
|
-
s ? s.push(n) : r.set(n.source, [n]);
|
|
183
|
-
}), r;
|
|
184
|
-
}, Mt = (e, r, n) => {
|
|
185
|
-
const s = [], o = [], i = [];
|
|
186
|
-
e.forEach((m) => {
|
|
187
|
-
const u = m.data?.isFallback, d = m.data?.conditions?.length;
|
|
188
|
-
u ? i.push(m) : d ? o.push(m) : s.push(m);
|
|
189
|
-
});
|
|
190
|
-
const a = [...s];
|
|
191
|
-
if (o.length === 0)
|
|
192
|
-
return i.length > 0 && a.length === 0 && a.push(...i), { edgesToFollow: a, waitingForInput: !1 };
|
|
193
|
-
if (!o.every((m) => {
|
|
194
|
-
const u = m.data?.conditions;
|
|
195
|
-
return u ? u.every((d) => {
|
|
196
|
-
if (!d.field)
|
|
197
|
-
return !0;
|
|
198
|
-
const f = n.get(d.field), g = W(f) ? f.id : d.field;
|
|
199
|
-
return $t(g, r);
|
|
200
|
-
}) : !1;
|
|
201
|
-
}))
|
|
202
|
-
return i.length > 0 && a.push(...i), { edgesToFollow: a, waitingForInput: a.length === 0 };
|
|
203
|
-
const c = o.filter((m) => Et(m.data?.conditions, r, n));
|
|
204
|
-
return c.length > 0 ? (a.push(...c), { edgesToFollow: a, waitingForInput: !1 }) : (a.push(...i), { edgesToFollow: a, waitingForInput: !1 });
|
|
205
|
-
}, ot = (e, r) => !r.some((n) => n.target === e), zt = (e, r) => {
|
|
206
|
-
const n = e.filter((s) => ot(s.id, r));
|
|
207
|
-
return n.find(W) || n[0];
|
|
208
|
-
}, Bt = (e, r, n, s) => {
|
|
209
|
-
e.forEach((o) => {
|
|
210
|
-
const i = s.get(o);
|
|
211
|
-
if (!i)
|
|
212
|
-
return;
|
|
213
|
-
let { parentId: a } = i;
|
|
214
|
-
const l = /* @__PURE__ */ new Set();
|
|
215
|
-
for (; a && !l.has(a); ) {
|
|
216
|
-
if (l.add(a), r.add(a), !n.has(a)) {
|
|
217
|
-
const c = n.get(o);
|
|
218
|
-
c !== void 0 && n.set(a, c);
|
|
219
|
-
}
|
|
220
|
-
a = s.get(a)?.parentId;
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
}, qt = (e, r, n) => {
|
|
224
|
-
const s = zt(e, r);
|
|
225
|
-
if (!s)
|
|
226
|
-
return {
|
|
227
|
-
endOfPathReached: !0,
|
|
228
|
-
visibleNodeIds: /* @__PURE__ */ new Set(),
|
|
229
|
-
visibleNodes: [],
|
|
230
|
-
visibleRootNodes: []
|
|
231
|
-
};
|
|
232
|
-
const o = new Map(e.map((p) => [p.id, p])), i = Vt(r), a = [], l = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set();
|
|
233
|
-
let m = !1;
|
|
234
|
-
const u = (p) => {
|
|
235
|
-
if (c.has(p))
|
|
236
|
-
return;
|
|
237
|
-
c.add(p);
|
|
238
|
-
const j = o.get(p);
|
|
239
|
-
if (!j)
|
|
240
|
-
return;
|
|
241
|
-
l.add(p), a.push(j);
|
|
242
|
-
const T = i.get(p) || [], { edgesToFollow: _, waitingForInput: R } = Mt(T, n, o);
|
|
243
|
-
if (R) {
|
|
244
|
-
m = !0;
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
_.forEach((w) => {
|
|
248
|
-
u(w.target);
|
|
249
|
-
});
|
|
250
|
-
};
|
|
251
|
-
u(s.id);
|
|
252
|
-
const d = new Map(a.map((p, j) => [p.id, j])), f = new Set(l);
|
|
253
|
-
Bt(l, f, d, o);
|
|
254
|
-
const g = e.filter((p) => f.has(p.id)).sort((p, j) => (d.get(p.id) ?? Number.MAX_SAFE_INTEGER) - (d.get(j.id) ?? Number.MAX_SAFE_INTEGER)), h = g.filter((p) => !(p.parentId && f.has(p.parentId)));
|
|
255
|
-
return {
|
|
256
|
-
endOfPathReached: !m,
|
|
257
|
-
visibleNodeIds: f,
|
|
258
|
-
visibleNodes: g,
|
|
259
|
-
visibleRootNodes: h
|
|
260
|
-
};
|
|
261
|
-
}, Lt = (e) => {
|
|
262
|
-
if (e.length === 1)
|
|
263
|
-
return e[0];
|
|
264
|
-
const r = new Set(e.map((s) => s.id)), n = /* @__PURE__ */ new Set();
|
|
265
|
-
return e.forEach((s) => {
|
|
266
|
-
s.nodes.forEach((o) => {
|
|
267
|
-
if (Ue(o)) {
|
|
268
|
-
const i = o.data.targetId;
|
|
269
|
-
i && r.has(i) && n.add(i);
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
}), e.find((s) => !n.has(s.id)) || e[0];
|
|
273
|
-
}, it = (e, r, n, s, o = /* @__PURE__ */ new Set()) => {
|
|
274
|
-
const i = /* @__PURE__ */ new Set();
|
|
275
|
-
for (const a of e)
|
|
276
|
-
if (n.has(a)) {
|
|
277
|
-
const l = s.get(a), c = l ? r.get(l) : void 0;
|
|
278
|
-
if (c) {
|
|
279
|
-
if (l && o.has(l))
|
|
280
|
-
continue;
|
|
281
|
-
l && o.add(l);
|
|
282
|
-
const m = new Set(c.nodes.map((d) => d.id)), u = it(m, r, n, s, o);
|
|
283
|
-
for (const d of u)
|
|
284
|
-
i.add(d);
|
|
285
|
-
}
|
|
286
|
-
} else
|
|
287
|
-
i.add(a);
|
|
288
|
-
return i;
|
|
289
|
-
}, Ht = (e, r) => {
|
|
290
|
-
const n = /* @__PURE__ */ new Set();
|
|
291
|
-
return r.forEach((s) => {
|
|
292
|
-
e.has(s.source) && e.has(s.target) && n.add(s.source);
|
|
293
|
-
}), Array.from(e).filter((s) => !n.has(s));
|
|
294
|
-
}, lt = (e) => {
|
|
295
|
-
if (!e)
|
|
296
|
-
return { edges: [], id: "empty", nodes: [] };
|
|
297
|
-
const r = Array.isArray(e) ? e : [e];
|
|
298
|
-
if (r.length === 0)
|
|
299
|
-
return { edges: [], id: "empty", nodes: [] };
|
|
300
|
-
const n = Lt(r);
|
|
301
|
-
if (r.length === 1)
|
|
302
|
-
return n;
|
|
303
|
-
const s = new Map(r.map((f) => [f.id, f])), o = [], i = [...n.edges], a = /* @__PURE__ */ new Set([n.id]), l = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), u = (f) => {
|
|
304
|
-
const g = [];
|
|
305
|
-
return f.forEach((h) => {
|
|
306
|
-
if (!Ue(h)) {
|
|
307
|
-
g.push(h);
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
const p = h.data.targetId;
|
|
311
|
-
if (!p)
|
|
312
|
-
return;
|
|
313
|
-
const j = s.get(p);
|
|
314
|
-
if (!j) {
|
|
315
|
-
console.warn(`Flow with id "${p}" not found`);
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
const T = j.nodes.find((_) => !_.parentId);
|
|
319
|
-
if (!T) {
|
|
320
|
-
console.warn(`Flow "${p}" has no root node; preserving FlowNode "${h.id}"`), g.push(h);
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
l.set(h.id, T.id), c.set(h.id, p), a.has(p) || (a.add(p), i.push(...j.edges), g.push(...u(j.nodes)));
|
|
324
|
-
}), g;
|
|
325
|
-
};
|
|
326
|
-
o.push(...u(n.nodes)), i.forEach((f) => {
|
|
327
|
-
if (l.has(f.source)) {
|
|
328
|
-
const g = m.get(f.source);
|
|
329
|
-
g ? g.push(f) : m.set(f.source, [f]);
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
const d = i.map((f) => {
|
|
333
|
-
if (l.has(f.source))
|
|
334
|
-
return null;
|
|
335
|
-
const g = l.get(f.target);
|
|
336
|
-
return g ? { ...f, target: g } : f;
|
|
337
|
-
}).filter((f) => f !== null);
|
|
338
|
-
return l.forEach((f, g) => {
|
|
339
|
-
const h = m.get(g);
|
|
340
|
-
if (!h?.length)
|
|
341
|
-
return;
|
|
342
|
-
const p = c.get(g), j = p ? s.get(p) : void 0;
|
|
343
|
-
if (!j)
|
|
344
|
-
return;
|
|
345
|
-
const T = new Set(j.nodes.map((w) => w.id)), _ = it(
|
|
346
|
-
T,
|
|
347
|
-
s,
|
|
348
|
-
l,
|
|
349
|
-
c,
|
|
350
|
-
new Set(p ? [p] : [])
|
|
351
|
-
);
|
|
352
|
-
Ht(_, d).forEach((w) => {
|
|
353
|
-
h.forEach((x) => {
|
|
354
|
-
const b = l.get(x.target) ?? x.target, v = x.id ?? `${g}__${x.target}`;
|
|
355
|
-
d.push({
|
|
356
|
-
...x,
|
|
357
|
-
id: `${w}__${v}`,
|
|
358
|
-
source: w,
|
|
359
|
-
target: b
|
|
360
|
-
});
|
|
361
|
-
});
|
|
362
|
-
});
|
|
363
|
-
}), {
|
|
364
|
-
edges: d,
|
|
365
|
-
id: n.id,
|
|
366
|
-
nodes: o
|
|
367
|
-
};
|
|
368
|
-
}, ct = Ze(null), Ut = ({ children: e, value: r }) => /* @__PURE__ */ t.jsx(ct.Provider, { value: r, children: e }), he = () => {
|
|
369
|
-
const r = et(ct) ?? {
|
|
370
|
-
flows: null,
|
|
371
|
-
formErrors: {},
|
|
372
|
-
formValues: {},
|
|
373
|
-
googleApiKey: void 0,
|
|
374
|
-
inputNodes: [],
|
|
375
|
-
language: "",
|
|
376
|
-
setFieldValue: () => {
|
|
377
|
-
}
|
|
378
|
-
}, n = G(() => r.flows ? lt(r.flows).edges : [], [r.flows]);
|
|
379
|
-
return {
|
|
380
|
-
...r,
|
|
381
|
-
edges: n
|
|
382
|
-
};
|
|
383
|
-
}, q = (e) => {
|
|
384
|
-
const r = he(), n = e ?? r.language;
|
|
385
|
-
return Nt(n);
|
|
386
|
-
}, Gt = (e, r = {}, n = "en") => {
|
|
387
|
-
const s = G(() => lt(e), [e]), { nodes: o, edges: i } = s, a = G(() => Ot(o), [o]), l = q(n), c = K({}), [m, u] = B({}), [d, f] = B(() => {
|
|
388
|
-
const x = { ...r };
|
|
389
|
-
return o.forEach((b) => {
|
|
390
|
-
if (W(b)) {
|
|
391
|
-
const v = b.id;
|
|
392
|
-
if (x[v] !== void 0)
|
|
393
|
-
return;
|
|
394
|
-
const { defaultValue: F } = b.data;
|
|
395
|
-
if (!F)
|
|
396
|
-
return;
|
|
397
|
-
if (F.type === "static" && F.staticValue !== void 0 && (x[v] = F.staticValue), F.type === "reference" && F.referenceField) {
|
|
398
|
-
const { referenceField: $ } = F, L = x[$];
|
|
399
|
-
L !== void 0 && (x[v] = L);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
}), x;
|
|
403
|
-
}), { endOfPathReached: g, visibleNodes: h, visibleRootNodes: p } = G(
|
|
404
|
-
() => qt(o, i, d),
|
|
405
|
-
[o, i, d]
|
|
406
|
-
), j = Q((x, b) => {
|
|
407
|
-
f((v) => ({
|
|
408
|
-
...v,
|
|
409
|
-
[x]: b
|
|
410
|
-
})), u((v) => {
|
|
411
|
-
const F = { ...v };
|
|
412
|
-
return delete F[x], F;
|
|
413
|
-
});
|
|
414
|
-
}, []), T = Q((x) => {
|
|
415
|
-
Object.keys(x).length !== 0 && (f((b) => ({
|
|
416
|
-
...b,
|
|
417
|
-
...x
|
|
418
|
-
})), u((b) => {
|
|
419
|
-
const v = { ...b };
|
|
420
|
-
return Object.keys(x).forEach((F) => {
|
|
421
|
-
delete v[F];
|
|
422
|
-
}), v;
|
|
423
|
-
}));
|
|
424
|
-
}, []), _ = Q(
|
|
425
|
-
(x) => {
|
|
426
|
-
const b = {};
|
|
427
|
-
h.forEach(($) => {
|
|
428
|
-
if (W($)) {
|
|
429
|
-
const L = $.id, ee = d[L];
|
|
430
|
-
if ($.data.required && we(ee)) {
|
|
431
|
-
b[L] = l($.data.errorMessage) || l("validation.required");
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
if (!we(ee) && $.data.pattern)
|
|
435
|
-
try {
|
|
436
|
-
new RegExp($.data.pattern).test(String(ee)) || (b[L] = l($.data.errorMessage) || l("validation.invalidFormat"));
|
|
437
|
-
} catch (Y) {
|
|
438
|
-
console.error(`Invalid pattern for field ${L}:`, Y);
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
const v = x ? x(d, h) : {}, F = {
|
|
443
|
-
...b,
|
|
444
|
-
...v
|
|
445
|
-
};
|
|
446
|
-
return u(F), {
|
|
447
|
-
errors: F,
|
|
448
|
-
hasCustomErrors: Object.keys(v).length > 0,
|
|
449
|
-
isValid: Object.keys(F).length === 0
|
|
450
|
-
};
|
|
451
|
-
},
|
|
452
|
-
[h, d, l]
|
|
453
|
-
), R = G(() => {
|
|
454
|
-
const x = [];
|
|
455
|
-
return h.forEach((b) => {
|
|
456
|
-
if (!W(b))
|
|
457
|
-
return;
|
|
458
|
-
const v = b.id, F = d[v];
|
|
459
|
-
if (b.data.required && we(F)) {
|
|
460
|
-
const $ = l(b.data.label) || v;
|
|
461
|
-
x.push($);
|
|
462
|
-
}
|
|
463
|
-
}), x;
|
|
464
|
-
}, [h, d, l]);
|
|
465
|
-
return {
|
|
466
|
-
canSubmit: !G(() => h.some((x) => W(x) && x.data.type === "submit"), [h]) && g && o.length > 0,
|
|
467
|
-
formErrors: m,
|
|
468
|
-
formValues: d,
|
|
469
|
-
inputNodes: a,
|
|
470
|
-
mergedFlow: s,
|
|
471
|
-
missingRequiredFields: R,
|
|
472
|
-
prevFormValuesRef: c,
|
|
473
|
-
setFieldValue: j,
|
|
474
|
-
setFormErrors: u,
|
|
475
|
-
setMultipleFieldValues: T,
|
|
476
|
-
t: l,
|
|
477
|
-
validateForm: _,
|
|
478
|
-
visibleNodes: h,
|
|
479
|
-
visibleRootNodes: p
|
|
480
|
-
};
|
|
481
|
-
}, Wt = ({ children: e, onSubmit: r }) => /* @__PURE__ */ t.jsx("form", { onSubmit: r, className: "mx-auto max-w-2xl gap-y-3", children: e }), Kt = ({ node: e, children: r }) => {
|
|
482
|
-
const n = q();
|
|
483
|
-
return /* @__PURE__ */ t.jsxs("section", { className: "mb-6 rounded-lg border p-4", children: [
|
|
484
|
-
e.data.label && /* @__PURE__ */ t.jsx("h3", { className: "mb-4 font-semibold text-lg", children: n(e.data.label) }),
|
|
485
|
-
r
|
|
486
|
-
] });
|
|
487
|
-
}, Jt = async (e, r) => {
|
|
488
|
-
if (!e || e.trim().length < 3)
|
|
489
|
-
return [];
|
|
490
|
-
try {
|
|
491
|
-
const n = await fetch(
|
|
492
|
-
`https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(e)}&format=jsonv2&addressdetails=1&limit=5`,
|
|
493
|
-
{
|
|
494
|
-
headers: {
|
|
495
|
-
Accept: "application/json",
|
|
496
|
-
"User-Agent": "Treege Renderer",
|
|
497
|
-
...r && { "Accept-Language": r }
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
);
|
|
501
|
-
return n.ok ? (await n.json()).map((o) => ({
|
|
502
|
-
label: o.display_name,
|
|
503
|
-
value: o.display_name
|
|
504
|
-
})) : [];
|
|
505
|
-
} catch (n) {
|
|
506
|
-
return console.error("Nominatim fetch error:", n), [];
|
|
507
|
-
}
|
|
508
|
-
}, Qt = (e) => !e || e.trim().length < 3 ? Promise.resolve([]) : new Promise((r) => {
|
|
509
|
-
if (!window.google?.maps?.places) {
|
|
510
|
-
console.warn("Google Places SDK not loaded yet"), r([]);
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
new window.google.maps.places.AutocompleteService().getPlacePredictions({ input: e }, (s, o) => {
|
|
514
|
-
if (o !== google.maps.places.PlacesServiceStatus.OK || !s) {
|
|
515
|
-
console.warn("Google Places API status:", o), r([]);
|
|
516
|
-
return;
|
|
517
|
-
}
|
|
518
|
-
r(
|
|
519
|
-
s.map((i) => ({
|
|
520
|
-
label: i.description,
|
|
521
|
-
value: i.description
|
|
522
|
-
}))
|
|
523
|
-
);
|
|
524
|
-
});
|
|
525
|
-
}), Xt = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, id: l, name: c }) => {
|
|
526
|
-
const [m, u] = B(""), [d, f] = B([]), [g, h] = B(!1), { googleApiKey: p, language: j } = he(), T = q(), _ = Q(
|
|
527
|
-
(w) => {
|
|
528
|
-
n(w.value), u(w.value), h(!1);
|
|
529
|
-
},
|
|
530
|
-
[n]
|
|
531
|
-
);
|
|
532
|
-
J(() => {
|
|
533
|
-
if (!m || m.trim().length < 3) {
|
|
534
|
-
f([]);
|
|
535
|
-
return;
|
|
536
|
-
}
|
|
537
|
-
const w = setTimeout(async () => {
|
|
538
|
-
const x = p ? await Qt(m) : await Jt(m, j);
|
|
539
|
-
f(x);
|
|
540
|
-
}, 300);
|
|
541
|
-
return () => clearTimeout(w);
|
|
542
|
-
}, [m, p, j]);
|
|
543
|
-
const R = Q(
|
|
544
|
-
(w) => {
|
|
545
|
-
n(w), u(w), w.length >= 3 && h(!0);
|
|
546
|
-
},
|
|
547
|
-
[n]
|
|
548
|
-
);
|
|
549
|
-
return /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
550
|
-
p && /* @__PURE__ */ t.jsx("script", { async: !0, src: `https://maps.googleapis.com/maps/api/js?key=${p}&libraries=places` }),
|
|
551
|
-
/* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
552
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: l, children: [
|
|
553
|
-
o || e.data.name,
|
|
554
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
555
|
-
] }),
|
|
556
|
-
/* @__PURE__ */ t.jsxs("div", { className: "relative", children: [
|
|
557
|
-
/* @__PURE__ */ t.jsx(
|
|
558
|
-
X,
|
|
559
|
-
{
|
|
560
|
-
type: "text",
|
|
561
|
-
id: l,
|
|
562
|
-
name: c,
|
|
563
|
-
value: r || "",
|
|
564
|
-
onChange: (w) => R(w.target.value),
|
|
565
|
-
onFocus: () => {
|
|
566
|
-
d.length > 0 && h(!0);
|
|
567
|
-
},
|
|
568
|
-
placeholder: i || T("renderer.defaultAddressInput.enterAddress"),
|
|
569
|
-
className: "pr-10",
|
|
570
|
-
autoComplete: "off"
|
|
571
|
-
}
|
|
572
|
-
),
|
|
573
|
-
/* @__PURE__ */ t.jsx(Be, { className: "-translate-y-1/2 pointer-events-none absolute top-1/2 right-3 h-4 w-4 text-muted-foreground" }),
|
|
574
|
-
g && /* @__PURE__ */ t.jsx("div", { className: "absolute z-50 mt-1 w-full rounded-md border bg-popover shadow-md", children: /* @__PURE__ */ t.jsx(De, { children: /* @__PURE__ */ t.jsxs(Re, { children: [
|
|
575
|
-
/* @__PURE__ */ t.jsx(ke, { children: T("renderer.defaultAddressInput.noAddressesFound") }),
|
|
576
|
-
/* @__PURE__ */ t.jsx(Ae, { children: d.map((w, x) => /* @__PURE__ */ t.jsxs(
|
|
577
|
-
Ee,
|
|
578
|
-
{
|
|
579
|
-
value: w.value,
|
|
580
|
-
onSelect: () => _(w),
|
|
581
|
-
onMouseDown: (b) => b.preventDefault(),
|
|
582
|
-
children: [
|
|
583
|
-
/* @__PURE__ */ t.jsx(Be, { className: "mr-2 h-4 w-4" }),
|
|
584
|
-
w.label
|
|
585
|
-
]
|
|
586
|
-
},
|
|
587
|
-
x
|
|
588
|
-
)) })
|
|
589
|
-
] }) }) })
|
|
590
|
-
] }),
|
|
591
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
592
|
-
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
593
|
-
] })
|
|
594
|
-
] });
|
|
595
|
-
}, Yt = ({
|
|
596
|
-
node: e,
|
|
597
|
-
value: r,
|
|
598
|
-
setValue: n,
|
|
599
|
-
error: s,
|
|
600
|
-
label: o,
|
|
601
|
-
placeholder: i,
|
|
602
|
-
helperText: a,
|
|
603
|
-
id: l
|
|
604
|
-
}) => {
|
|
605
|
-
const c = q(), [m, u] = B(!1), d = `${l}-trigger`, f = `${l}-error`, g = e.data.options || [], h = g.find((p) => p.value === r);
|
|
606
|
-
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
607
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: d, children: [
|
|
608
|
-
o || e.data.name,
|
|
609
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
610
|
-
] }),
|
|
611
|
-
/* @__PURE__ */ t.jsxs(me, { open: m, onOpenChange: u, children: [
|
|
612
|
-
/* @__PURE__ */ t.jsx(fe, { asChild: !0, children: /* @__PURE__ */ t.jsxs(
|
|
613
|
-
le,
|
|
614
|
-
{
|
|
615
|
-
id: d,
|
|
616
|
-
variant: "outline",
|
|
617
|
-
role: "combobox",
|
|
618
|
-
"aria-expanded": m,
|
|
619
|
-
"aria-invalid": !!s || void 0,
|
|
620
|
-
"aria-describedby": s ? f : void 0,
|
|
621
|
-
className: "w-full justify-between font-normal",
|
|
622
|
-
children: [
|
|
623
|
-
r ? h?.label ? c(h.label) : r : i || c("renderer.defaultAutocompleteInput.selectOption"),
|
|
624
|
-
/* @__PURE__ */ t.jsx(tt, { className: "ml-2 size-4 shrink-0 opacity-50" })
|
|
625
|
-
]
|
|
626
|
-
}
|
|
627
|
-
) }),
|
|
628
|
-
/* @__PURE__ */ t.jsx(pe, { className: "w-full p-0", align: "start", children: /* @__PURE__ */ t.jsxs(De, { children: [
|
|
629
|
-
/* @__PURE__ */ t.jsx(Ge, { placeholder: i || c("renderer.defaultAutocompleteInput.search") }),
|
|
630
|
-
/* @__PURE__ */ t.jsxs(Re, { children: [
|
|
631
|
-
/* @__PURE__ */ t.jsx(ke, { children: c("renderer.defaultAutocompleteInput.noResults") }),
|
|
632
|
-
/* @__PURE__ */ t.jsx(Ae, { children: g.map((p) => /* @__PURE__ */ t.jsxs(
|
|
633
|
-
Ee,
|
|
634
|
-
{
|
|
635
|
-
value: p.value,
|
|
636
|
-
disabled: p.disabled,
|
|
637
|
-
onSelect: (j) => {
|
|
638
|
-
n(j === r ? "" : j), u(!1);
|
|
639
|
-
},
|
|
640
|
-
children: [
|
|
641
|
-
/* @__PURE__ */ t.jsx(st, { className: y("mr-2 size-4", r === p.value ? "opacity-100" : "opacity-0") }),
|
|
642
|
-
c(p.label)
|
|
643
|
-
]
|
|
644
|
-
},
|
|
645
|
-
p.value
|
|
646
|
-
)) })
|
|
647
|
-
] })
|
|
648
|
-
] }) })
|
|
649
|
-
] }),
|
|
650
|
-
s && /* @__PURE__ */ t.jsx(O, { id: f, children: s }),
|
|
651
|
-
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
652
|
-
] });
|
|
653
|
-
}, Zt = ({ node: e, value: r, setValue: n, error: s, label: o, helperText: i, id: a, name: l }) => {
|
|
654
|
-
const c = q();
|
|
655
|
-
if (e.data.options && e.data.options.length > 0) {
|
|
656
|
-
const m = Array.isArray(r) ? r.map(String) : [], u = (d, f) => {
|
|
657
|
-
const g = f ? [...m, d] : m.filter((h) => h !== d);
|
|
658
|
-
n(g);
|
|
659
|
-
};
|
|
660
|
-
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
661
|
-
/* @__PURE__ */ t.jsxs(D, { className: "mb-1", children: [
|
|
662
|
-
o || e.data.name,
|
|
663
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
664
|
-
] }),
|
|
665
|
-
/* @__PURE__ */ t.jsx("div", { className: "space-y-2", children: e.data.options.map((d, f) => /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
666
|
-
/* @__PURE__ */ t.jsx(
|
|
667
|
-
Ve,
|
|
668
|
-
{
|
|
669
|
-
id: `${a}-${d.value}`,
|
|
670
|
-
name: l,
|
|
671
|
-
checked: m.includes(String(d.value)),
|
|
672
|
-
onCheckedChange: (g) => u(String(d.value), !!g),
|
|
673
|
-
disabled: d.disabled
|
|
674
|
-
}
|
|
675
|
-
),
|
|
676
|
-
/* @__PURE__ */ t.jsx(D, { htmlFor: `${a}-${d.value}`, className: "cursor-pointer font-normal text-sm", children: c(d.label) ? c(d.label) : d.value })
|
|
677
|
-
] }, d.value + f)) }),
|
|
678
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
679
|
-
i && !s && /* @__PURE__ */ t.jsx(P, { children: i })
|
|
680
|
-
] });
|
|
681
|
-
}
|
|
682
|
-
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
683
|
-
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
684
|
-
/* @__PURE__ */ t.jsx(
|
|
685
|
-
Ve,
|
|
686
|
-
{
|
|
687
|
-
id: a,
|
|
688
|
-
name: l,
|
|
689
|
-
checked: typeof r == "boolean" ? r : !1,
|
|
690
|
-
onCheckedChange: (m) => n(!!m)
|
|
691
|
-
}
|
|
692
|
-
),
|
|
693
|
-
/* @__PURE__ */ t.jsxs("div", { children: [
|
|
694
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: a, className: "cursor-pointer font-medium text-sm", children: [
|
|
695
|
-
o || e.data.name,
|
|
696
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
697
|
-
] }),
|
|
698
|
-
i && !s && /* @__PURE__ */ t.jsx(P, { children: i })
|
|
699
|
-
] })
|
|
700
|
-
] }),
|
|
701
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s })
|
|
702
|
-
] });
|
|
703
|
-
};
|
|
704
|
-
function dt({
|
|
705
|
-
className: e,
|
|
706
|
-
classNames: r,
|
|
707
|
-
showOutsideDays: n = !0,
|
|
708
|
-
captionLayout: s = "label",
|
|
709
|
-
buttonVariant: o = "ghost",
|
|
710
|
-
formatters: i,
|
|
711
|
-
components: a,
|
|
712
|
-
...l
|
|
713
|
-
}) {
|
|
714
|
-
const c = rt();
|
|
715
|
-
return /* @__PURE__ */ t.jsx(
|
|
716
|
-
kt,
|
|
717
|
-
{
|
|
718
|
-
showOutsideDays: n,
|
|
719
|
-
className: y(
|
|
720
|
-
"group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
|
|
721
|
-
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
|
722
|
-
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
|
723
|
-
e
|
|
724
|
-
),
|
|
725
|
-
captionLayout: s,
|
|
726
|
-
formatters: {
|
|
727
|
-
formatMonthDropdown: (m) => m.toLocaleString("default", { month: "short" }),
|
|
728
|
-
...i
|
|
729
|
-
},
|
|
730
|
-
classNames: {
|
|
731
|
-
button_next: y(
|
|
732
|
-
Me({ variant: o }),
|
|
733
|
-
"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
|
|
734
|
-
c.button_next
|
|
735
|
-
),
|
|
736
|
-
button_previous: y(
|
|
737
|
-
Me({ variant: o }),
|
|
738
|
-
"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
|
|
739
|
-
c.button_previous
|
|
740
|
-
),
|
|
741
|
-
caption_label: y(
|
|
742
|
-
"select-none font-medium",
|
|
743
|
-
s === "label" ? "text-sm" : "rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5",
|
|
744
|
-
c.caption_label
|
|
745
|
-
),
|
|
746
|
-
day: y(
|
|
747
|
-
"relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",
|
|
748
|
-
c.day
|
|
749
|
-
),
|
|
750
|
-
disabled: y("text-muted-foreground opacity-50", c.disabled),
|
|
751
|
-
dropdown: y("absolute bg-popover inset-0 opacity-0", c.dropdown),
|
|
752
|
-
dropdown_root: y(
|
|
753
|
-
"relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",
|
|
754
|
-
c.dropdown_root
|
|
755
|
-
),
|
|
756
|
-
dropdowns: y("w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5", c.dropdowns),
|
|
757
|
-
hidden: y("invisible", c.hidden),
|
|
758
|
-
month: y("flex flex-col w-full gap-4", c.month),
|
|
759
|
-
month_caption: y("flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)", c.month_caption),
|
|
760
|
-
months: y("flex gap-4 flex-col md:flex-row relative", c.months),
|
|
761
|
-
nav: y("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between", c.nav),
|
|
762
|
-
outside: y("text-muted-foreground aria-selected:text-muted-foreground", c.outside),
|
|
763
|
-
range_end: y("rounded-r-md bg-accent", c.range_end),
|
|
764
|
-
range_middle: y("rounded-none", c.range_middle),
|
|
765
|
-
range_start: y("rounded-l-md bg-accent", c.range_start),
|
|
766
|
-
root: y("w-fit", c.root),
|
|
767
|
-
table: "w-full border-collapse",
|
|
768
|
-
today: y("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none", c.today),
|
|
769
|
-
week: y("flex w-full mt-2", c.week),
|
|
770
|
-
week_number: y("text-[0.8rem] select-none text-muted-foreground", c.week_number),
|
|
771
|
-
week_number_header: y("select-none w-(--cell-size)", c.week_number_header),
|
|
772
|
-
weekday: y("text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none", c.weekday),
|
|
773
|
-
weekdays: y("flex", c.weekdays),
|
|
774
|
-
...r
|
|
775
|
-
},
|
|
776
|
-
components: {
|
|
777
|
-
Chevron: ({ className: m, orientation: u, ...d }) => u === "left" ? /* @__PURE__ */ t.jsx(Tt, { className: y("size-4", m), ...d }) : u === "right" ? /* @__PURE__ */ t.jsx(Dt, { className: y("size-4", m), ...d }) : /* @__PURE__ */ t.jsx(Oe, { className: y("size-4", m), ...d }),
|
|
778
|
-
DayButton: es,
|
|
779
|
-
Root: ({ className: m, rootRef: u, ...d }) => /* @__PURE__ */ t.jsx("div", { "data-slot": "calendar", ref: u, className: y(m), ...d }),
|
|
780
|
-
WeekNumber: ({ children: m, ...u }) => /* @__PURE__ */ t.jsx("td", { ...u, children: /* @__PURE__ */ t.jsx("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children: m }) }),
|
|
781
|
-
...a
|
|
782
|
-
},
|
|
783
|
-
...l
|
|
784
|
-
}
|
|
785
|
-
);
|
|
786
|
-
}
|
|
787
|
-
function es({ className: e, day: r, modifiers: n, ...s }) {
|
|
788
|
-
const o = rt(), i = ze.useRef(null);
|
|
789
|
-
return ze.useEffect(() => {
|
|
790
|
-
n.focused && i.current?.focus();
|
|
791
|
-
}, [n.focused]), /* @__PURE__ */ t.jsx(
|
|
792
|
-
le,
|
|
793
|
-
{
|
|
794
|
-
ref: i,
|
|
795
|
-
variant: "ghost",
|
|
796
|
-
size: "icon",
|
|
797
|
-
"data-day": r.date.toLocaleDateString(),
|
|
798
|
-
"data-selected-single": n.selected && !n.range_start && !n.range_end && !n.range_middle,
|
|
799
|
-
"data-range-start": n.range_start,
|
|
800
|
-
"data-range-end": n.range_end,
|
|
801
|
-
"data-range-middle": n.range_middle,
|
|
802
|
-
className: y(
|
|
803
|
-
"flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-start=true]:rounded-l-md data-[range-end=true]:bg-primary data-[range-middle=true]:bg-accent data-[range-start=true]:bg-primary data-[selected-single=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:text-accent-foreground data-[range-start=true]:text-primary-foreground data-[selected-single=true]:text-primary-foreground group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground [&>span]:text-xs [&>span]:opacity-70",
|
|
804
|
-
o.day,
|
|
805
|
-
e
|
|
806
|
-
),
|
|
807
|
-
...s
|
|
808
|
-
}
|
|
809
|
-
);
|
|
810
|
-
}
|
|
811
|
-
const ts = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, id: l, name: c }) => {
|
|
812
|
-
const [m, u] = B(!1), d = q(), f = r ? new Date(r) : void 0, g = (h) => {
|
|
813
|
-
if (e.data.disablePast) {
|
|
814
|
-
const p = /* @__PURE__ */ new Date();
|
|
815
|
-
return p.setHours(0, 0, 0, 0), h < p;
|
|
816
|
-
}
|
|
817
|
-
return !1;
|
|
818
|
-
};
|
|
819
|
-
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
820
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: l, children: [
|
|
821
|
-
o || e.data.name,
|
|
822
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
823
|
-
] }),
|
|
824
|
-
/* @__PURE__ */ t.jsxs(me, { open: m, onOpenChange: u, children: [
|
|
825
|
-
/* @__PURE__ */ t.jsx(fe, { asChild: !0, children: /* @__PURE__ */ t.jsxs(le, { variant: "outline", id: l, name: c, className: "w-full justify-between font-normal", children: [
|
|
826
|
-
f ? f.toLocaleDateString() : i || d("renderer.defaultInputs.selectDate"),
|
|
827
|
-
/* @__PURE__ */ t.jsx(Oe, { className: "size-4" })
|
|
828
|
-
] }) }),
|
|
829
|
-
/* @__PURE__ */ t.jsx(pe, { className: "w-auto overflow-hidden p-0", align: "start", children: /* @__PURE__ */ t.jsx(
|
|
830
|
-
dt,
|
|
831
|
-
{
|
|
832
|
-
mode: "single",
|
|
833
|
-
selected: f,
|
|
834
|
-
captionLayout: "dropdown",
|
|
835
|
-
disabled: g,
|
|
836
|
-
onSelect: (h) => {
|
|
837
|
-
n(h ? h.toISOString() : ""), u(!1);
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
) })
|
|
841
|
-
] }),
|
|
842
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
843
|
-
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
844
|
-
] });
|
|
845
|
-
}, ss = ({ node: e, value: r, setValue: n, error: s, label: o, helperText: i, id: a }) => {
|
|
846
|
-
const [l, c] = B(!1), m = q(), u = Array.isArray(r) ? r : [], d = u[0] ? new Date(u[0]) : void 0, f = u[1] ? new Date(u[1]) : void 0, g = (j) => {
|
|
847
|
-
n([j?.from ? j.from.toISOString() : void 0, j?.to ? j.to.toISOString() : void 0]);
|
|
848
|
-
}, h = () => d && f ? `${d.toLocaleDateString()} - ${f.toLocaleDateString()}` : d ? d.toLocaleDateString() : m("renderer.defaultInputs.selectDateRange"), p = (j) => {
|
|
849
|
-
if (e.data.disablePast) {
|
|
850
|
-
const T = /* @__PURE__ */ new Date();
|
|
851
|
-
return T.setHours(0, 0, 0, 0), j < T;
|
|
852
|
-
}
|
|
853
|
-
return !1;
|
|
854
|
-
};
|
|
855
|
-
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
856
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: a, children: [
|
|
857
|
-
o || e.data.name,
|
|
858
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
859
|
-
] }),
|
|
860
|
-
/* @__PURE__ */ t.jsxs(me, { open: l, onOpenChange: c, children: [
|
|
861
|
-
/* @__PURE__ */ t.jsx(fe, { asChild: !0, children: /* @__PURE__ */ t.jsxs(le, { id: a, variant: "outline", className: "w-full justify-between font-normal", children: [
|
|
862
|
-
h(),
|
|
863
|
-
/* @__PURE__ */ t.jsx(Oe, { className: "size-4" })
|
|
864
|
-
] }) }),
|
|
865
|
-
/* @__PURE__ */ t.jsx(pe, { className: "w-auto overflow-hidden p-0", align: "start", children: /* @__PURE__ */ t.jsx(
|
|
866
|
-
dt,
|
|
867
|
-
{
|
|
868
|
-
mode: "range",
|
|
869
|
-
selected: { from: d, to: f },
|
|
870
|
-
captionLayout: "dropdown",
|
|
871
|
-
disabled: p,
|
|
872
|
-
onSelect: g,
|
|
873
|
-
numberOfMonths: 2
|
|
874
|
-
}
|
|
875
|
-
) })
|
|
876
|
-
] }),
|
|
877
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
878
|
-
i && !s && /* @__PURE__ */ t.jsx(P, { children: i })
|
|
879
|
-
] });
|
|
880
|
-
}, ut = (e) => new Promise((r, n) => {
|
|
881
|
-
const s = new FileReader();
|
|
882
|
-
s.onload = () => {
|
|
883
|
-
const o = s.result;
|
|
884
|
-
r({
|
|
885
|
-
data: o,
|
|
886
|
-
lastModified: e.lastModified,
|
|
887
|
-
name: e.name,
|
|
888
|
-
size: e.size,
|
|
889
|
-
type: e.type
|
|
890
|
-
});
|
|
891
|
-
}, s.onerror = () => {
|
|
892
|
-
n(new Error(`Failed to read file: ${e.name}`));
|
|
893
|
-
}, s.readAsDataURL(e);
|
|
894
|
-
}), Hs = (e) => {
|
|
895
|
-
const r = e.data.split(",")[1], n = atob(r), s = new ArrayBuffer(n.length), o = new Uint8Array(s);
|
|
896
|
-
for (let a = 0; a < n.length; a++)
|
|
897
|
-
o[a] = n.charCodeAt(a);
|
|
898
|
-
const i = new Blob([s], { type: e.type });
|
|
899
|
-
return new File([i], e.name, {
|
|
900
|
-
lastModified: e.lastModified,
|
|
901
|
-
type: e.type
|
|
902
|
-
});
|
|
903
|
-
}, rs = (e) => Promise.all(e.map((r) => ut(r))), ns = ({ node: e, setValue: r, error: n, label: s, placeholder: o, helperText: i, name: a, id: l }) => {
|
|
904
|
-
const c = async (m) => {
|
|
905
|
-
const { files: u } = m.target;
|
|
906
|
-
if (!u || u.length === 0) {
|
|
907
|
-
r(null);
|
|
908
|
-
return;
|
|
909
|
-
}
|
|
910
|
-
if (e.data.multiple) {
|
|
911
|
-
const f = await rs(Array.from(u));
|
|
912
|
-
r(f);
|
|
913
|
-
return;
|
|
914
|
-
}
|
|
915
|
-
const d = await ut(u[0]);
|
|
916
|
-
r(d);
|
|
917
|
-
};
|
|
918
|
-
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
919
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: l, children: [
|
|
920
|
-
s || e.data.name,
|
|
921
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
922
|
-
] }),
|
|
923
|
-
/* @__PURE__ */ t.jsx(X, { type: "file", name: a, id: l, onChange: c, multiple: e.data.multiple, placeholder: o }),
|
|
924
|
-
n && /* @__PURE__ */ t.jsx(O, { children: n }),
|
|
925
|
-
i && !n && /* @__PURE__ */ t.jsx(P, { children: i })
|
|
926
|
-
] });
|
|
927
|
-
}, as = ({ value: e, name: r, id: n }) => /* @__PURE__ */ t.jsx(X, { type: "hidden", id: n, name: r, value: e ?? "" });
|
|
928
|
-
function _e({ delayDuration: e = 0, ...r }) {
|
|
929
|
-
return /* @__PURE__ */ t.jsx(ae.Provider, { "data-slot": "tooltip-provider", delayDuration: e, ...r });
|
|
930
|
-
}
|
|
931
|
-
function mt({ ...e }) {
|
|
932
|
-
return /* @__PURE__ */ t.jsx(_e, { children: /* @__PURE__ */ t.jsx(ae.Root, { "data-slot": "tooltip", ...e }) });
|
|
933
|
-
}
|
|
934
|
-
function ft({ ...e }) {
|
|
935
|
-
return /* @__PURE__ */ t.jsx(ae.Trigger, { "data-slot": "tooltip-trigger", ...e });
|
|
936
|
-
}
|
|
937
|
-
function pt({ className: e, sideOffset: r = 0, children: n, ...s }) {
|
|
938
|
-
return /* @__PURE__ */ t.jsx(ae.Portal, { children: /* @__PURE__ */ t.jsxs(
|
|
939
|
-
ae.Content,
|
|
940
|
-
{
|
|
941
|
-
"data-slot": "tooltip-content",
|
|
942
|
-
sideOffset: r,
|
|
943
|
-
className: y(
|
|
944
|
-
"fade-in-0 zoom-in-95 data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in text-balance rounded-md bg-foreground px-3 py-1.5 text-background text-xs data-[state=closed]:animate-out",
|
|
945
|
-
e
|
|
946
|
-
),
|
|
947
|
-
...s,
|
|
948
|
-
children: [
|
|
949
|
-
n,
|
|
950
|
-
/* @__PURE__ */ t.jsx(ae.Arrow, { className: "z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" })
|
|
951
|
-
]
|
|
952
|
-
}
|
|
953
|
-
) });
|
|
954
|
-
}
|
|
955
|
-
const ve = (e, r) => r ? r.split(".").reduce((s, o) => {
|
|
956
|
-
if (s == null)
|
|
957
|
-
return;
|
|
958
|
-
const i = o.match(/^(\w+)\[(\d+)]$/);
|
|
959
|
-
if (i) {
|
|
960
|
-
const [, a, l] = i, c = s[a];
|
|
961
|
-
return Array.isArray(c) ? c[Number.parseInt(l, 10)] : c;
|
|
962
|
-
}
|
|
963
|
-
return s[o];
|
|
964
|
-
}, e) : e, Te = (e) => {
|
|
965
|
-
const r = e.matchAll(/{{([\w-]+)}}/g);
|
|
966
|
-
return Array.from(r, (n) => n[1]);
|
|
967
|
-
}, Se = (e, r) => Te(e).every((s) => {
|
|
968
|
-
const o = r[s];
|
|
969
|
-
return o != null && o !== "";
|
|
970
|
-
}), Fe = (e, r, n = !1) => e.replace(/{{([\w-]+)}}/g, (s, o) => {
|
|
971
|
-
const i = String(r[o] || "");
|
|
972
|
-
return n ? encodeURIComponent(i) : i;
|
|
973
|
-
}), os = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, id: l, name: c }) => {
|
|
974
|
-
const [m, u] = B(!1), [d, f] = B(null), [g, h] = B([]), [p, j] = B(""), [T, _] = B(!1), { formValues: R, inputNodes: w } = he(), x = q(), { httpConfig: b } = e.data, v = K(!1), F = K(""), $ = K(b), L = K(R), ee = K(w), Y = K(n), ce = K(null), te = G(() => b?.url ? Te(b.url) : [], [b?.url]), se = te.length > 0, oe = G(() => te.map((C) => `${C}:${String(R[C] ?? "")}`).join("|"), [te, R]), ie = G(() => b?.url ? se ? Se(b.url, R) : !0 : !1, [b?.url, se, R]), U = Q(
|
|
975
|
-
async (C) => {
|
|
976
|
-
const I = $.current, z = L.current, N = Y.current;
|
|
977
|
-
if (!I?.url) {
|
|
978
|
-
f(x("renderer.defaultHttpInput.noUrlConfigured"));
|
|
979
|
-
return;
|
|
980
|
-
}
|
|
981
|
-
if (!(I.url && !Se(I.url, z))) {
|
|
982
|
-
u(!0), f(null);
|
|
983
|
-
try {
|
|
984
|
-
const V = Fe(I.url, z, !0), k = I.searchParam && C ? `${V}${V.includes("?") ? "&" : "?"}${I.searchParam}=${encodeURIComponent(C)}` : V, A = {};
|
|
985
|
-
I.headers?.forEach((re) => {
|
|
986
|
-
A[re.key] = Fe(re.value, z);
|
|
987
|
-
});
|
|
988
|
-
const S = ["POST", "PUT", "PATCH"].includes(I.method || "") ? I.sendFormData ? JSON.stringify($e(z, ee.current)) : I.body ? Fe(I.body, z) : void 0 : void 0, M = await fetch(k, {
|
|
989
|
-
body: S || void 0,
|
|
990
|
-
headers: {
|
|
991
|
-
"Content-Type": "application/json",
|
|
992
|
-
...A
|
|
993
|
-
},
|
|
994
|
-
method: I.method || "GET"
|
|
995
|
-
});
|
|
996
|
-
if (!M.ok) {
|
|
997
|
-
f(`HTTP ${M.status}: ${M.statusText}`), u(!1);
|
|
998
|
-
return;
|
|
999
|
-
}
|
|
1000
|
-
const H = await M.json(), Z = I.responsePath ? ve(H, I.responsePath) : H;
|
|
1001
|
-
if (I.responseMapping && Array.isArray(Z)) {
|
|
1002
|
-
const { valueField: re = "value", labelField: ge = "label" } = I.responseMapping, xe = Z.map((de) => ({
|
|
1003
|
-
label: String(ve(de, ge) || ""),
|
|
1004
|
-
value: String(ve(de, re) || "")
|
|
1005
|
-
}));
|
|
1006
|
-
h(xe);
|
|
1007
|
-
} else
|
|
1008
|
-
N(typeof Z == "string" ? Z : JSON.stringify(Z));
|
|
1009
|
-
} catch (V) {
|
|
1010
|
-
const k = V instanceof Error ? V.message : x("renderer.defaultHttpInput.fetchFailed");
|
|
1011
|
-
f(k), console.error("HTTP Input fetch error:", V);
|
|
1012
|
-
} finally {
|
|
1013
|
-
u(!1);
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
},
|
|
1017
|
-
[x]
|
|
1018
|
-
);
|
|
1019
|
-
if (J(() => {
|
|
1020
|
-
$.current = b, L.current = R, ee.current = w, Y.current = n, ce.current = U;
|
|
1021
|
-
}, [b, R, w, n, U]), J(() => {
|
|
1022
|
-
if (v.current)
|
|
1023
|
-
return;
|
|
1024
|
-
v.current = !0;
|
|
1025
|
-
const C = $.current, I = L.current, z = ce.current, N = C?.url && Se(C.url, I);
|
|
1026
|
-
if (C?.fetchOnMount && N && z && (z(), C.url)) {
|
|
1027
|
-
const V = Te(C.url);
|
|
1028
|
-
F.current = V.map((k) => `${k}:${String(I[k] ?? "")}`).join("|");
|
|
1029
|
-
}
|
|
1030
|
-
}, []), J(() => {
|
|
1031
|
-
if (!v.current || !se || F.current === oe || !ie)
|
|
1032
|
-
return;
|
|
1033
|
-
const C = setTimeout(() => {
|
|
1034
|
-
U(), F.current = oe;
|
|
1035
|
-
}, 500);
|
|
1036
|
-
return () => clearTimeout(C);
|
|
1037
|
-
}, [oe, se, ie, U]), J(() => {
|
|
1038
|
-
if (!(b?.searchParam && p))
|
|
1039
|
-
return;
|
|
1040
|
-
const C = setTimeout(() => {
|
|
1041
|
-
U(p);
|
|
1042
|
-
}, 300);
|
|
1043
|
-
return () => clearTimeout(C);
|
|
1044
|
-
}, [p, b?.searchParam, U]), b?.responseMapping) {
|
|
1045
|
-
const C = Array.isArray(r) ? r[0] : r, I = g.find((S) => S.value === C);
|
|
1046
|
-
if (b.searchParam) {
|
|
1047
|
-
const M = m && b?.showLoading ? /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1048
|
-
/* @__PURE__ */ t.jsx(ye, { className: "h-4 w-4 animate-spin" }),
|
|
1049
|
-
/* @__PURE__ */ t.jsx("span", { className: "text-muted-foreground", children: I?.label || i || x("renderer.defaultHttpInput.search") })
|
|
1050
|
-
] }) : I?.label || i || x("renderer.defaultHttpInput.search");
|
|
1051
|
-
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1052
|
-
/* @__PURE__ */ t.jsxs(D, { children: [
|
|
1053
|
-
o || e.data.name,
|
|
1054
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1055
|
-
] }),
|
|
1056
|
-
/* @__PURE__ */ t.jsxs(me, { open: T, onOpenChange: _, children: [
|
|
1057
|
-
/* @__PURE__ */ t.jsx(fe, { asChild: !0, children: /* @__PURE__ */ t.jsxs(le, { variant: "outline", role: "combobox", "aria-expanded": T, className: "w-full justify-between", children: [
|
|
1058
|
-
M,
|
|
1059
|
-
/* @__PURE__ */ t.jsx(tt, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
|
|
1060
|
-
] }) }),
|
|
1061
|
-
/* @__PURE__ */ t.jsx(pe, { className: "w-[300px] p-0", align: "start", children: /* @__PURE__ */ t.jsxs(De, { shouldFilter: !1, children: [
|
|
1062
|
-
/* @__PURE__ */ t.jsx(
|
|
1063
|
-
Ge,
|
|
1064
|
-
{
|
|
1065
|
-
placeholder: x("renderer.defaultHttpInput.search"),
|
|
1066
|
-
value: p,
|
|
1067
|
-
onValueChange: (H) => {
|
|
1068
|
-
j(H), f(null);
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
),
|
|
1072
|
-
/* @__PURE__ */ t.jsxs(Re, { children: [
|
|
1073
|
-
m && /* @__PURE__ */ t.jsx("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ t.jsx(ye, { className: "h-4 w-4 animate-spin" }) }),
|
|
1074
|
-
!m && d && /* @__PURE__ */ t.jsxs("div", { className: "p-4 text-destructive text-sm", children: [
|
|
1075
|
-
/* @__PURE__ */ t.jsx("div", { children: d }),
|
|
1076
|
-
/* @__PURE__ */ t.jsx("button", { type: "button", onClick: () => U(p), className: "mt-2 block text-primary hover:underline", children: x("renderer.defaultHttpInput.retry") })
|
|
1077
|
-
] }),
|
|
1078
|
-
!(m || d) && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
1079
|
-
/* @__PURE__ */ t.jsx(ke, { children: x("renderer.defaultHttpInput.noResults") }),
|
|
1080
|
-
/* @__PURE__ */ t.jsx(Ae, { children: g.map((H) => /* @__PURE__ */ t.jsxs(
|
|
1081
|
-
Ee,
|
|
1082
|
-
{
|
|
1083
|
-
value: H.value,
|
|
1084
|
-
onSelect: () => {
|
|
1085
|
-
n(H.value), _(!1);
|
|
1086
|
-
},
|
|
1087
|
-
children: [
|
|
1088
|
-
/* @__PURE__ */ t.jsx(st, { className: y("mr-2 h-4 w-4", r === H.value ? "opacity-100" : "opacity-0") }),
|
|
1089
|
-
H.label
|
|
1090
|
-
]
|
|
1091
|
-
},
|
|
1092
|
-
H.value
|
|
1093
|
-
)) })
|
|
1094
|
-
] })
|
|
1095
|
-
] })
|
|
1096
|
-
] }) })
|
|
1097
|
-
] }),
|
|
1098
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1099
|
-
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1100
|
-
] });
|
|
1101
|
-
}
|
|
1102
|
-
const z = m && b?.showLoading, N = te.filter((S) => {
|
|
1103
|
-
const M = R[S];
|
|
1104
|
-
return M == null || M === "";
|
|
1105
|
-
}), V = N.map((S) => Pt(S, w) || S), k = g.length === 0 && !z ? N.length > 0 ? `${x("renderer.defaultHttpInput.waitingForRequiredFields")}: ${V.join(", ")}` : x("renderer.defaultHttpInput.noDataAvailable") : void 0, A = /* @__PURE__ */ t.jsxs(
|
|
1106
|
-
We,
|
|
1107
|
-
{
|
|
1108
|
-
value: Array.isArray(r) ? r[0] ?? "" : r ?? "",
|
|
1109
|
-
onValueChange: (S) => n(S),
|
|
1110
|
-
disabled: z || g.length === 0,
|
|
1111
|
-
name: c,
|
|
1112
|
-
children: [
|
|
1113
|
-
/* @__PURE__ */ t.jsxs(Ke, { id: l, name: c, className: "w-full", children: [
|
|
1114
|
-
z && /* @__PURE__ */ t.jsx(ye, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
1115
|
-
/* @__PURE__ */ t.jsx(Je, { placeholder: i || x("renderer.defaultHttpInput.selectOption") })
|
|
1116
|
-
] }),
|
|
1117
|
-
/* @__PURE__ */ t.jsx(Qe, { children: /* @__PURE__ */ t.jsx(Xe, { children: g.map((S, M) => /* @__PURE__ */ t.jsx(Ye, { value: S.value, children: S.label }, S.value + M)) }) })
|
|
1118
|
-
]
|
|
1119
|
-
}
|
|
1120
|
-
);
|
|
1121
|
-
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1122
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: l, children: [
|
|
1123
|
-
o || e.data.name,
|
|
1124
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1125
|
-
] }),
|
|
1126
|
-
k ? /* @__PURE__ */ t.jsx(_e, { children: /* @__PURE__ */ t.jsxs(mt, { children: [
|
|
1127
|
-
/* @__PURE__ */ t.jsx(ft, { asChild: !0, children: /* @__PURE__ */ t.jsx("div", { className: "w-full", children: A }) }),
|
|
1128
|
-
/* @__PURE__ */ t.jsx(pt, { children: /* @__PURE__ */ t.jsx("p", { children: k }) })
|
|
1129
|
-
] }) }) : A,
|
|
1130
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1131
|
-
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1132
|
-
] });
|
|
1133
|
-
}
|
|
1134
|
-
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1135
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: l, children: [
|
|
1136
|
-
o || e.data.name,
|
|
1137
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1138
|
-
] }),
|
|
1139
|
-
/* @__PURE__ */ t.jsx(X, { type: "text", name: c, id: l, value: typeof r == "string" ? r : JSON.stringify(r), readOnly: !0, disabled: !0 }),
|
|
1140
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1141
|
-
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1142
|
-
] });
|
|
1143
|
-
}, is = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, name: l, id: c }) => /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1144
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: c, children: [
|
|
1145
|
-
o || e.data.name,
|
|
1146
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1147
|
-
] }),
|
|
1148
|
-
/* @__PURE__ */ t.jsx(
|
|
1149
|
-
X,
|
|
1150
|
-
{
|
|
1151
|
-
id: c,
|
|
1152
|
-
type: "number",
|
|
1153
|
-
name: l,
|
|
1154
|
-
value: r ?? "",
|
|
1155
|
-
onChange: (m) => n(m.target.value === "" ? null : Number(m.target.value)),
|
|
1156
|
-
placeholder: i
|
|
1157
|
-
}
|
|
1158
|
-
),
|
|
1159
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1160
|
-
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1161
|
-
] }), ls = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, name: l, id: c }) => /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1162
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: c, children: [
|
|
1163
|
-
o || e.data.name,
|
|
1164
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1165
|
-
] }),
|
|
1166
|
-
/* @__PURE__ */ t.jsx(
|
|
1167
|
-
X,
|
|
1168
|
-
{
|
|
1169
|
-
id: c,
|
|
1170
|
-
name: l,
|
|
1171
|
-
type: "password",
|
|
1172
|
-
value: r ?? "",
|
|
1173
|
-
onChange: (m) => n(m.target.value),
|
|
1174
|
-
placeholder: i,
|
|
1175
|
-
autoComplete: "new-password"
|
|
1176
|
-
}
|
|
1177
|
-
),
|
|
1178
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1179
|
-
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1180
|
-
] });
|
|
1181
|
-
function cs({ className: e, ...r }) {
|
|
1182
|
-
return /* @__PURE__ */ t.jsx(Ie.Root, { "data-slot": "radio-group", className: y("grid gap-3", e), ...r });
|
|
1183
|
-
}
|
|
1184
|
-
function ds({ className: e, ...r }) {
|
|
1185
|
-
return /* @__PURE__ */ t.jsx(
|
|
1186
|
-
Ie.Item,
|
|
1187
|
-
{
|
|
1188
|
-
"data-slot": "radio-group-item",
|
|
1189
|
-
className: y(
|
|
1190
|
-
"aspect-square size-4 shrink-0 rounded-full border border-input text-primary shadow-xs outline-none transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:bg-input/30 dark:aria-invalid:ring-destructive/40",
|
|
1191
|
-
e
|
|
1192
|
-
),
|
|
1193
|
-
...r,
|
|
1194
|
-
children: /* @__PURE__ */ t.jsx(Ie.Indicator, { "data-slot": "radio-group-indicator", className: "relative flex items-center justify-center", children: /* @__PURE__ */ t.jsx(Rt, { className: "-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/2 size-2 fill-primary" }) })
|
|
1195
|
-
}
|
|
1196
|
-
);
|
|
1197
|
-
}
|
|
1198
|
-
const us = ({ node: e, value: r, setValue: n, error: s, label: o, helperText: i, id: a, name: l }) => {
|
|
1199
|
-
const c = q(), m = r ? String(r) : "";
|
|
1200
|
-
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1201
|
-
/* @__PURE__ */ t.jsxs(D, { className: "mb-1", htmlFor: a, children: [
|
|
1202
|
-
o || e.data.name,
|
|
1203
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1204
|
-
] }),
|
|
1205
|
-
/* @__PURE__ */ t.jsx(cs, { value: m, onValueChange: (u) => n(u), id: a, name: l, children: e.data.options?.map((u, d) => /* @__PURE__ */ t.jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
1206
|
-
/* @__PURE__ */ t.jsx(ds, { value: String(u.value), id: `${a}-${u.value}`, disabled: u.disabled }),
|
|
1207
|
-
/* @__PURE__ */ t.jsx(D, { htmlFor: `${a}-${u.value}`, className: "cursor-pointer font-normal text-sm", children: c(u.label) ? c(u.label) : u.value })
|
|
1208
|
-
] }, u.value + d)) }),
|
|
1209
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1210
|
-
i && !s && /* @__PURE__ */ t.jsx(P, { children: i })
|
|
1211
|
-
] });
|
|
1212
|
-
}, ms = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, name: l, id: c }) => {
|
|
1213
|
-
const m = q(), u = r ? String(r) : "";
|
|
1214
|
-
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1215
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: c, children: [
|
|
1216
|
-
o || e.data.name,
|
|
1217
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1218
|
-
] }),
|
|
1219
|
-
/* @__PURE__ */ t.jsxs(We, { name: l, value: u, onValueChange: (d) => n(d), children: [
|
|
1220
|
-
/* @__PURE__ */ t.jsx(Ke, { id: c, name: l, className: "w-full", children: /* @__PURE__ */ t.jsx(Je, { placeholder: i || m("renderer.defaultSelectInput.selectOption") }) }),
|
|
1221
|
-
/* @__PURE__ */ t.jsx(Qe, { children: /* @__PURE__ */ t.jsx(Xe, { children: e.data.options?.map((d, f) => /* @__PURE__ */ t.jsx(Ye, { value: String(d.value), disabled: d.disabled, children: m(d.label) ? m(d.label) : d.value }, `${d.value}-${f}`)) }) })
|
|
1222
|
-
] }),
|
|
1223
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1224
|
-
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1225
|
-
] });
|
|
1226
|
-
}, ht = It(
|
|
1227
|
-
({ label: e, id: r, disabled: n, onBlur: s, onClick: o, onFocus: i, onPointerDown: a, onPointerLeave: l, onPointerMove: c, ...m }, u) => {
|
|
1228
|
-
const d = q();
|
|
1229
|
-
return /* @__PURE__ */ t.jsx(
|
|
1230
|
-
"button",
|
|
1231
|
-
{
|
|
1232
|
-
ref: u,
|
|
1233
|
-
id: r,
|
|
1234
|
-
onBlur: s,
|
|
1235
|
-
onClick: o,
|
|
1236
|
-
onFocus: i,
|
|
1237
|
-
onPointerDown: a,
|
|
1238
|
-
disabled: n,
|
|
1239
|
-
onPointerLeave: l,
|
|
1240
|
-
onPointerMove: c,
|
|
1241
|
-
type: "submit",
|
|
1242
|
-
className: "mt-4 rounded-md bg-blue-500 px-4 py-2 font-medium text-white transition-colors hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
1243
|
-
...m,
|
|
1244
|
-
children: e || d("renderer.defaultSubmitButton.submit")
|
|
1245
|
-
}
|
|
1246
|
-
);
|
|
1247
|
-
}
|
|
1248
|
-
), gt = ({ children: e, missingFields: r = [] }) => {
|
|
1249
|
-
const n = r.length > 0, s = q();
|
|
1250
|
-
return n ? /* @__PURE__ */ t.jsx(_e, { children: /* @__PURE__ */ t.jsxs(mt, { children: [
|
|
1251
|
-
/* @__PURE__ */ t.jsx(ft, { asChild: !0, children: e }),
|
|
1252
|
-
/* @__PURE__ */ t.jsx(pt, { children: /* @__PURE__ */ t.jsxs("div", { className: "space-y-1", children: [
|
|
1253
|
-
/* @__PURE__ */ t.jsxs("p", { className: "font-semibold", children: [
|
|
1254
|
-
s("renderer.defaultSubmitButton.requiredFieldsMissing"),
|
|
1255
|
-
":"
|
|
1256
|
-
] }),
|
|
1257
|
-
/* @__PURE__ */ t.jsx("ul", { className: "list-inside list-disc", children: r.map((o, i) => /* @__PURE__ */ t.jsx("li", { children: o }, i)) })
|
|
1258
|
-
] }) })
|
|
1259
|
-
] }) }) : e;
|
|
1260
|
-
}, fs = ({ missingRequiredFields: e, isSubmitting: r, label: n }) => {
|
|
1261
|
-
const s = at(), o = s?.components?.submitButton, i = s?.components?.submitButtonWrapper, a = o || ht, l = i || gt;
|
|
1262
|
-
return /* @__PURE__ */ t.jsx(l, { missingFields: e, children: /* @__PURE__ */ t.jsx(a, { label: n, disabled: r }) });
|
|
1263
|
-
}, ps = ({ node: e, value: r, setValue: n, error: s, label: o, helperText: i, name: a, id: l }) => /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1264
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: l, children: [
|
|
1265
|
-
o || e.data.name,
|
|
1266
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1267
|
-
] }),
|
|
1268
|
-
/* @__PURE__ */ t.jsx(wt, { id: l, name: a, checked: r, onCheckedChange: n }),
|
|
1269
|
-
i && !s && /* @__PURE__ */ t.jsx(P, { children: i }),
|
|
1270
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s })
|
|
1271
|
-
] }), hs = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, name: l, id: c }) => /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1272
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: c, children: [
|
|
1273
|
-
o || e.data.name,
|
|
1274
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1275
|
-
] }),
|
|
1276
|
-
/* @__PURE__ */ t.jsx(
|
|
1277
|
-
vt,
|
|
1278
|
-
{
|
|
1279
|
-
id: c,
|
|
1280
|
-
name: l,
|
|
1281
|
-
value: r ?? "",
|
|
1282
|
-
onChange: (m) => n(m.target.value),
|
|
1283
|
-
placeholder: i,
|
|
1284
|
-
className: "w-full rounded-md border px-3 py-2",
|
|
1285
|
-
rows: 4
|
|
1286
|
-
}
|
|
1287
|
-
),
|
|
1288
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1289
|
-
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1290
|
-
] }), gs = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, name: l, id: c }) => /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1291
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: c, children: [
|
|
1292
|
-
o || e.data.name,
|
|
1293
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1294
|
-
] }),
|
|
1295
|
-
/* @__PURE__ */ t.jsx(X, { type: "text", id: c, name: l, value: r ?? "", onChange: (m) => n(m.target.value), placeholder: i }),
|
|
1296
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1297
|
-
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1298
|
-
] }), xs = ({ node: e, value: r, setValue: n, error: s, label: o, placeholder: i, helperText: a, name: l, id: c }) => /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1299
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: c, children: [
|
|
1300
|
-
o || e.data.name,
|
|
1301
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1302
|
-
] }),
|
|
1303
|
-
/* @__PURE__ */ t.jsx(
|
|
1304
|
-
X,
|
|
1305
|
-
{
|
|
1306
|
-
type: "time",
|
|
1307
|
-
id: c,
|
|
1308
|
-
name: l,
|
|
1309
|
-
value: r ?? "",
|
|
1310
|
-
onChange: (m) => n(m.target.value),
|
|
1311
|
-
placeholder: i,
|
|
1312
|
-
className: "bg-background [color-scheme:light] dark:[color-scheme:dark]"
|
|
1313
|
-
}
|
|
1314
|
-
),
|
|
1315
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1316
|
-
a && !s && /* @__PURE__ */ t.jsx(P, { children: a })
|
|
1317
|
-
] }), bs = ({ node: e, value: r, setValue: n, error: s, label: o, helperText: i, id: a, name: l }) => {
|
|
1318
|
-
const c = q(), m = Array.isArray(r) ? r : [], u = m[0] || "", d = m[1] || "", f = (h) => {
|
|
1319
|
-
n([h, d]);
|
|
1320
|
-
}, g = (h) => {
|
|
1321
|
-
n([u, h]);
|
|
1322
|
-
};
|
|
1323
|
-
return /* @__PURE__ */ t.jsxs(E, { className: "mb-4", children: [
|
|
1324
|
-
/* @__PURE__ */ t.jsxs(D, { htmlFor: `${a}-start`, children: [
|
|
1325
|
-
o || e.data.name,
|
|
1326
|
-
e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
|
|
1327
|
-
] }),
|
|
1328
|
-
/* @__PURE__ */ t.jsxs("div", { className: "flex gap-2", children: [
|
|
1329
|
-
/* @__PURE__ */ t.jsx(
|
|
1330
|
-
X,
|
|
1331
|
-
{
|
|
1332
|
-
id: `${a}-start`,
|
|
1333
|
-
name: `${l}-start`,
|
|
1334
|
-
"aria-label": `${o || e.data.name} - ${c("renderer.defaultInputs.startTime")}`,
|
|
1335
|
-
"aria-invalid": !!s,
|
|
1336
|
-
"aria-describedby": s ? `${e.id}-error` : void 0,
|
|
1337
|
-
type: "time",
|
|
1338
|
-
value: u,
|
|
1339
|
-
onChange: (h) => f(h.target.value),
|
|
1340
|
-
placeholder: c("renderer.defaultInputs.startTime"),
|
|
1341
|
-
className: "flex-1 bg-background [color-scheme:light] dark:[color-scheme:dark]"
|
|
1342
|
-
}
|
|
1343
|
-
),
|
|
1344
|
-
/* @__PURE__ */ t.jsx(
|
|
1345
|
-
X,
|
|
1346
|
-
{
|
|
1347
|
-
id: `${a}-end`,
|
|
1348
|
-
name: `${l}-end`,
|
|
1349
|
-
"aria-label": `${o || e.data.name} - ${c("renderer.defaultInputs.endTime")}`,
|
|
1350
|
-
"aria-invalid": !!s,
|
|
1351
|
-
"aria-describedby": s ? `${e.id}-error` : void 0,
|
|
1352
|
-
type: "time",
|
|
1353
|
-
value: d,
|
|
1354
|
-
onChange: (h) => g(h.target.value),
|
|
1355
|
-
placeholder: c("renderer.defaultInputs.endTime"),
|
|
1356
|
-
className: "flex-1 bg-background [color-scheme:light] dark:[color-scheme:dark]"
|
|
1357
|
-
}
|
|
1358
|
-
)
|
|
1359
|
-
] }),
|
|
1360
|
-
s && /* @__PURE__ */ t.jsx(O, { children: s }),
|
|
1361
|
-
i && !s && /* @__PURE__ */ t.jsx(P, { children: i })
|
|
1362
|
-
] });
|
|
1363
|
-
}, js = {
|
|
1364
|
-
address: Xt,
|
|
1365
|
-
autocomplete: Yt,
|
|
1366
|
-
checkbox: Zt,
|
|
1367
|
-
date: ts,
|
|
1368
|
-
daterange: ss,
|
|
1369
|
-
file: ns,
|
|
1370
|
-
hidden: as,
|
|
1371
|
-
http: os,
|
|
1372
|
-
number: is,
|
|
1373
|
-
password: ls,
|
|
1374
|
-
radio: us,
|
|
1375
|
-
select: ms,
|
|
1376
|
-
submit: fs,
|
|
1377
|
-
switch: ps,
|
|
1378
|
-
text: gs,
|
|
1379
|
-
textarea: hs,
|
|
1380
|
-
time: xs,
|
|
1381
|
-
timerange: bs
|
|
1382
|
-
}, ys = ({ node: e }) => {
|
|
1383
|
-
const n = q()(e.data?.label);
|
|
1384
|
-
return n ? /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
1385
|
-
/* @__PURE__ */ t.jsx(je, { className: "my-8 flex-1" }),
|
|
1386
|
-
/* @__PURE__ */ t.jsx("h4", { className: "font-semibold text-sm", children: n }),
|
|
1387
|
-
/* @__PURE__ */ t.jsx(je, { className: "my-8 flex-1" })
|
|
1388
|
-
] }) : /* @__PURE__ */ t.jsx(je, { className: "my-8" });
|
|
1389
|
-
}, Ns = ({ node: e }) => {
|
|
1390
|
-
const { edges: r } = he(), n = q(), s = ot(e.id, r);
|
|
1391
|
-
return /* @__PURE__ */ t.jsx("h2", { className: y("mb-5 font-bold text-2xl", !s && "mt-10"), children: n(e.data?.label) });
|
|
1392
|
-
}, ws = {
|
|
1393
|
-
divider: ys,
|
|
1394
|
-
title: Ns
|
|
1395
|
-
}, vs = async (e) => {
|
|
1396
|
-
try {
|
|
1397
|
-
const { url: r, method: n = "GET", headers: s = [], body: o } = e;
|
|
1398
|
-
if (!r || r.trim() === "")
|
|
1399
|
-
return {
|
|
1400
|
-
error: "No URL provided",
|
|
1401
|
-
success: !1
|
|
1402
|
-
};
|
|
1403
|
-
const i = {
|
|
1404
|
-
"Content-Type": "application/json"
|
|
1405
|
-
};
|
|
1406
|
-
s.forEach((u) => {
|
|
1407
|
-
u.key && u.value && (i[u.key] = u.value);
|
|
1408
|
-
});
|
|
1409
|
-
const a = {
|
|
1410
|
-
headers: i,
|
|
1411
|
-
method: n
|
|
1412
|
-
};
|
|
1413
|
-
o && n && ["POST", "PUT", "PATCH"].includes(n) && (a.body = o);
|
|
1414
|
-
const l = await fetch(r, a);
|
|
1415
|
-
let c;
|
|
1416
|
-
return l.headers.get("content-type")?.includes("application/json") ? c = await l.json() : c = await l.text(), l.ok ? {
|
|
1417
|
-
data: c,
|
|
1418
|
-
status: l.status,
|
|
1419
|
-
statusText: l.statusText,
|
|
1420
|
-
success: !0
|
|
1421
|
-
} : {
|
|
1422
|
-
data: c,
|
|
1423
|
-
error: `HTTP ${l.status}: ${l.statusText}`,
|
|
1424
|
-
status: l.status,
|
|
1425
|
-
statusText: l.statusText,
|
|
1426
|
-
success: !1
|
|
1427
|
-
};
|
|
1428
|
-
} catch (r) {
|
|
1429
|
-
return {
|
|
1430
|
-
error: r instanceof Error ? r.message : "An unknown error occurred",
|
|
1431
|
-
success: !1
|
|
1432
|
-
};
|
|
1433
|
-
}
|
|
1434
|
-
}, Ce = (e, r, n = {}) => {
|
|
1435
|
-
if (!e)
|
|
1436
|
-
return "";
|
|
1437
|
-
const { encode: s = !1, json: o = !1 } = n;
|
|
1438
|
-
return e.replace(/\{\{([\w-]+)}}/g, (i, a) => {
|
|
1439
|
-
const l = r[a.trim()];
|
|
1440
|
-
if (l == null)
|
|
1441
|
-
return o ? "null" : "";
|
|
1442
|
-
if (s)
|
|
1443
|
-
return encodeURIComponent(String(l));
|
|
1444
|
-
if (o) {
|
|
1445
|
-
if (typeof l == "string")
|
|
1446
|
-
return `"${l.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
1447
|
-
if (typeof l == "number" || typeof l == "boolean")
|
|
1448
|
-
return String(l);
|
|
1449
|
-
if (typeof l == "object")
|
|
1450
|
-
return JSON.stringify(l);
|
|
1451
|
-
}
|
|
1452
|
-
return String(l);
|
|
1453
|
-
});
|
|
1454
|
-
}, Ss = (e, r) => e ? e.replace(/\{\{response\.([\w.-]+)}}/g, (n, s) => {
|
|
1455
|
-
const o = Fs(r, s.trim());
|
|
1456
|
-
return o != null ? String(o) : "";
|
|
1457
|
-
}) : "", Fs = (e, r) => {
|
|
1458
|
-
if (!(!e || typeof e != "object"))
|
|
1459
|
-
return r.split(".").reduce((n, s) => {
|
|
1460
|
-
if (!(n == null || typeof n != "object"))
|
|
1461
|
-
return n[s];
|
|
1462
|
-
}, e);
|
|
1463
|
-
}, Cs = async (e, r, n) => {
|
|
1464
|
-
if (!e.url || e.url.trim() === "")
|
|
1465
|
-
return {
|
|
1466
|
-
error: "No URL configured for submission",
|
|
1467
|
-
success: !1
|
|
1468
|
-
};
|
|
1469
|
-
const s = Ce(e.url, r, { encode: !0 });
|
|
1470
|
-
if (!s || s.trim() === "")
|
|
1471
|
-
return {
|
|
1472
|
-
error: "Invalid URL after template replacement",
|
|
1473
|
-
success: !1
|
|
1474
|
-
};
|
|
1475
|
-
const o = e.headers?.map((c) => ({
|
|
1476
|
-
key: c.key,
|
|
1477
|
-
value: Ce(c.value, r)
|
|
1478
|
-
})), i = e.sendFormData ? JSON.stringify($e(r, n)) : e.body ? Ce(e.body, r, { json: !0 }) : void 0, a = await vs({
|
|
1479
|
-
body: i,
|
|
1480
|
-
headers: o,
|
|
1481
|
-
method: e.method || "POST",
|
|
1482
|
-
url: s
|
|
1483
|
-
});
|
|
1484
|
-
if (!a.success)
|
|
1485
|
-
return {
|
|
1486
|
-
data: a.data,
|
|
1487
|
-
error: a.error,
|
|
1488
|
-
success: !1
|
|
1489
|
-
};
|
|
1490
|
-
const l = e.redirectUrl ? (() => {
|
|
1491
|
-
const c = Ss(e.redirectUrl, a.data);
|
|
1492
|
-
return c && c.trim() !== "" ? c : void 0;
|
|
1493
|
-
})() : void 0;
|
|
1494
|
-
return {
|
|
1495
|
-
data: a.data,
|
|
1496
|
-
redirectUrl: l,
|
|
1497
|
-
success: !0
|
|
1498
|
-
};
|
|
1499
|
-
}, Is = (e) => {
|
|
1500
|
-
if (!e)
|
|
1501
|
-
return;
|
|
1502
|
-
e.startsWith("http://") || e.startsWith("https://") ? window.location.href = e : window.history?.pushState ? (window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate"))) : window.location.href = e;
|
|
1503
|
-
}, Ts = (e, r, n, s) => {
|
|
1504
|
-
const [o, i] = B(!1), [a, l] = B(null), c = G(() => {
|
|
1505
|
-
const d = e.find((f) => W(f) && f.data?.type === "submit");
|
|
1506
|
-
return d && W(d) ? d : null;
|
|
1507
|
-
}, [e]), m = Q(
|
|
1508
|
-
async (d) => {
|
|
1509
|
-
if (!c?.data?.submitConfig)
|
|
1510
|
-
return null;
|
|
1511
|
-
const f = c.data.submitConfig;
|
|
1512
|
-
if (!f.url || f.url.trim() === "")
|
|
1513
|
-
return null;
|
|
1514
|
-
l(null), f.showLoading !== !1 && i(!0);
|
|
1515
|
-
try {
|
|
1516
|
-
const g = await Cs(f, r, s);
|
|
1517
|
-
if (g.success) {
|
|
1518
|
-
const h = ne(f.successMessage, n);
|
|
1519
|
-
if (h && l({ message: h, type: "success" }), d && d(g.data), g.redirectUrl) {
|
|
1520
|
-
const p = g.redirectUrl;
|
|
1521
|
-
setTimeout(() => Is(p), 1e3);
|
|
1522
|
-
}
|
|
1523
|
-
} else {
|
|
1524
|
-
const h = ne(f.errorMessage, n) || g.error || "An error occurred during submission";
|
|
1525
|
-
l({ message: h, type: "error" });
|
|
1526
|
-
}
|
|
1527
|
-
return g;
|
|
1528
|
-
} catch (g) {
|
|
1529
|
-
const h = ne(f.errorMessage, n) || (g instanceof Error ? g.message : "An unexpected error occurred");
|
|
1530
|
-
return l({ message: h, type: "error" }), {
|
|
1531
|
-
error: h,
|
|
1532
|
-
success: !1
|
|
1533
|
-
};
|
|
1534
|
-
} finally {
|
|
1535
|
-
i(!1);
|
|
1536
|
-
}
|
|
1537
|
-
},
|
|
1538
|
-
[c, r, n, s]
|
|
1539
|
-
);
|
|
1540
|
-
return {
|
|
1541
|
-
clearSubmitMessage: Q(() => {
|
|
1542
|
-
l(null);
|
|
1543
|
-
}, []),
|
|
1544
|
-
handleSubmitWithConfig: m,
|
|
1545
|
-
hasSubmitConfig: !!c?.data?.submitConfig,
|
|
1546
|
-
isSubmitting: o,
|
|
1547
|
-
submitButtonNode: c,
|
|
1548
|
-
submitMessage: a
|
|
1549
|
-
};
|
|
1550
|
-
}, Us = ({
|
|
1551
|
-
components: e,
|
|
1552
|
-
flows: r,
|
|
1553
|
-
googleApiKey: n,
|
|
1554
|
-
initialValues: s = {},
|
|
1555
|
-
language: o,
|
|
1556
|
-
onChange: i,
|
|
1557
|
-
onSubmit: a,
|
|
1558
|
-
theme: l,
|
|
1559
|
-
validate: c,
|
|
1560
|
-
validationMode: m
|
|
1561
|
-
}) => {
|
|
1562
|
-
const u = at(), d = {
|
|
1563
|
-
components: {
|
|
1564
|
-
form: e?.form ?? u?.components?.form,
|
|
1565
|
-
group: e?.group ?? u?.components?.group,
|
|
1566
|
-
inputs: { ...u?.components?.inputs, ...e?.inputs },
|
|
1567
|
-
submitButton: e?.submitButton ?? u?.components?.submitButton,
|
|
1568
|
-
submitButtonWrapper: e?.submitButtonWrapper ?? u?.components?.submitButtonWrapper,
|
|
1569
|
-
ui: { ...u?.components?.ui, ...e?.ui }
|
|
1570
|
-
},
|
|
1571
|
-
googleApiKey: n ?? u?.googleApiKey,
|
|
1572
|
-
language: o ?? u?.language ?? "en",
|
|
1573
|
-
theme: l ?? u?.theme ?? "dark",
|
|
1574
|
-
validationMode: m ?? u?.validationMode ?? "onSubmit"
|
|
1575
|
-
}, {
|
|
1576
|
-
canSubmit: f,
|
|
1577
|
-
mergedFlow: g,
|
|
1578
|
-
formErrors: h,
|
|
1579
|
-
formValues: p,
|
|
1580
|
-
inputNodes: j,
|
|
1581
|
-
missingRequiredFields: T,
|
|
1582
|
-
prevFormValuesRef: _,
|
|
1583
|
-
visibleNodes: R,
|
|
1584
|
-
visibleRootNodes: w,
|
|
1585
|
-
setFieldValue: x,
|
|
1586
|
-
setMultipleFieldValues: b,
|
|
1587
|
-
validateForm: v,
|
|
1588
|
-
t: F
|
|
1589
|
-
} = Gt(r, s, d.language), { handleSubmitWithConfig: $, hasSubmitConfig: L, isSubmitting: ee, submitMessage: Y, clearSubmitMessage: ce } = Ts(
|
|
1590
|
-
R,
|
|
1591
|
-
p,
|
|
1592
|
-
d.language,
|
|
1593
|
-
j
|
|
1594
|
-
), te = d.components.form || Wt, se = d.components.submitButton || ht, oe = d.components.submitButtonWrapper || gt, ie = K(i), U = K(c), C = G(() => $e(p, j), [p, j]), I = Q(
|
|
1595
|
-
async (N) => {
|
|
1596
|
-
N.preventDefault();
|
|
1597
|
-
const { isValid: V, errors: k } = v(U.current);
|
|
1598
|
-
if (!V) {
|
|
1599
|
-
const A = Object.keys(k)[0];
|
|
1600
|
-
A && document.getElementById(A)?.focus();
|
|
1601
|
-
return;
|
|
1602
|
-
}
|
|
1603
|
-
if (L) {
|
|
1604
|
-
const A = await $((S) => {
|
|
1605
|
-
a && a(C, { httpResponse: S });
|
|
1606
|
-
});
|
|
1607
|
-
if (A === null) {
|
|
1608
|
-
a?.(C);
|
|
1609
|
-
return;
|
|
1610
|
-
}
|
|
1611
|
-
if (!A.success)
|
|
1612
|
-
return;
|
|
1613
|
-
} else a && a(C);
|
|
1614
|
-
},
|
|
1615
|
-
[v, L, $, a, C]
|
|
1616
|
-
), z = Q(
|
|
1617
|
-
(N) => {
|
|
1618
|
-
const { type: V } = N;
|
|
1619
|
-
switch (V) {
|
|
1620
|
-
case ue.input: {
|
|
1621
|
-
if (!W(N))
|
|
1622
|
-
return null;
|
|
1623
|
-
const k = N.data, A = k.type || "text", S = d.components.inputs?.[A], M = js[A], H = S || M, Z = N.id, re = p[Z], ge = h[Z], xe = (yt) => x(Z, yt), de = ne(k.label, d.language), xt = ne(k.placeholder, d.language), bt = ne(k.helperText, d.language), jt = Pe(N);
|
|
1624
|
-
return /* @__PURE__ */ t.jsx(
|
|
1625
|
-
H,
|
|
1626
|
-
{
|
|
1627
|
-
id: N.id,
|
|
1628
|
-
node: N,
|
|
1629
|
-
value: re,
|
|
1630
|
-
error: ge,
|
|
1631
|
-
label: de,
|
|
1632
|
-
placeholder: xt,
|
|
1633
|
-
helperText: bt,
|
|
1634
|
-
name: jt,
|
|
1635
|
-
setValue: xe,
|
|
1636
|
-
missingRequiredFields: T
|
|
1637
|
-
},
|
|
1638
|
-
N.id
|
|
1639
|
-
);
|
|
1640
|
-
}
|
|
1641
|
-
case ue.group: {
|
|
1642
|
-
if (!Ft(N))
|
|
1643
|
-
return null;
|
|
1644
|
-
const k = d.components.group || Kt, A = R.filter((S) => S.parentId === N.id);
|
|
1645
|
-
return /* @__PURE__ */ t.jsx(k, { node: N, children: A.map((S) => z(S)) }, N.id);
|
|
1646
|
-
}
|
|
1647
|
-
case ue.ui: {
|
|
1648
|
-
if (!St(N))
|
|
1649
|
-
return null;
|
|
1650
|
-
const A = N.data.type || "title", S = d.components.ui?.[A], M = ws[A], H = S || M;
|
|
1651
|
-
return /* @__PURE__ */ t.jsx(H, { node: N }, N.id);
|
|
1652
|
-
}
|
|
1653
|
-
case ue.flow:
|
|
1654
|
-
return null;
|
|
1655
|
-
default:
|
|
1656
|
-
return console.warn("Unknown node type:", V), null;
|
|
1657
|
-
}
|
|
1658
|
-
},
|
|
1659
|
-
[d.components, d.language, R, p, h, x, T]
|
|
1660
|
-
);
|
|
1661
|
-
return J(() => {
|
|
1662
|
-
ie.current = i;
|
|
1663
|
-
}, [i]), J(() => {
|
|
1664
|
-
U.current = c;
|
|
1665
|
-
}, [c]), J(() => {
|
|
1666
|
-
ie.current?.(C);
|
|
1667
|
-
}, [C]), J(() => {
|
|
1668
|
-
d.validationMode === "onChange" && v(U.current);
|
|
1669
|
-
}, [d.validationMode, v]), J(() => {
|
|
1670
|
-
const N = _t(j, p, _.current);
|
|
1671
|
-
Object.keys(N).length > 0 && b(N), _.current = p;
|
|
1672
|
-
}, [p, j, b, _]), /* @__PURE__ */ t.jsx(Ct, { theme: d.theme, storageKey: "treege-renderer-theme", children: /* @__PURE__ */ t.jsxs(
|
|
1673
|
-
Ut,
|
|
1674
|
-
{
|
|
1675
|
-
value: {
|
|
1676
|
-
flows: g,
|
|
1677
|
-
formErrors: h,
|
|
1678
|
-
formValues: p,
|
|
1679
|
-
googleApiKey: d.googleApiKey,
|
|
1680
|
-
inputNodes: j,
|
|
1681
|
-
language: d.language,
|
|
1682
|
-
setFieldValue: x
|
|
1683
|
-
},
|
|
1684
|
-
children: [
|
|
1685
|
-
/* @__PURE__ */ t.jsxs(te, { onSubmit: I, children: [
|
|
1686
|
-
w.map((N) => z(N)),
|
|
1687
|
-
f && /* @__PURE__ */ t.jsx(oe, { missingFields: T, children: /* @__PURE__ */ t.jsx(se, { label: F("renderer.defaultSubmitButton.submit"), disabled: ee }) })
|
|
1688
|
-
] }),
|
|
1689
|
-
/* @__PURE__ */ t.jsx("p", { className: "py-2 text-muted-foreground text-xs", children: "Powered by Treege" }),
|
|
1690
|
-
Y && /* @__PURE__ */ t.jsx(
|
|
1691
|
-
"div",
|
|
1692
|
-
{
|
|
1693
|
-
className: `my-4 rounded-md p-4 ${Y.type === "success" ? "bg-green-50 text-green-800 dark:bg-green-900/20 dark:text-green-300" : "bg-red-50 text-red-800 dark:bg-red-900/20 dark:text-red-300"}`,
|
|
1694
|
-
role: "alert",
|
|
1695
|
-
children: /* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1696
|
-
/* @__PURE__ */ t.jsx("p", { className: "font-medium text-sm", children: Y.message }),
|
|
1697
|
-
/* @__PURE__ */ t.jsx(
|
|
1698
|
-
"button",
|
|
1699
|
-
{
|
|
1700
|
-
type: "button",
|
|
1701
|
-
onClick: ce,
|
|
1702
|
-
className: "ml-4 font-medium text-sm underline hover:no-underline focus:outline-none",
|
|
1703
|
-
children: F("common.close")
|
|
1704
|
-
}
|
|
1705
|
-
)
|
|
1706
|
-
] })
|
|
1707
|
-
}
|
|
1708
|
-
)
|
|
1709
|
-
]
|
|
1710
|
-
}
|
|
1711
|
-
) });
|
|
1712
|
-
};
|
|
1713
|
-
export {
|
|
1714
|
-
ut as A,
|
|
1715
|
-
Hs as B,
|
|
1716
|
-
rs as C,
|
|
1717
|
-
Kt as D,
|
|
1718
|
-
ot as E,
|
|
1719
|
-
zt as F,
|
|
1720
|
-
qt as G,
|
|
1721
|
-
lt as H,
|
|
1722
|
-
we as I,
|
|
1723
|
-
$t as J,
|
|
1724
|
-
$e as K,
|
|
1725
|
-
Le as L,
|
|
1726
|
-
_t as M,
|
|
1727
|
-
Ls as T,
|
|
1728
|
-
Gt as a,
|
|
1729
|
-
Us as b,
|
|
1730
|
-
Xt as c,
|
|
1731
|
-
Yt as d,
|
|
1732
|
-
Zt as e,
|
|
1733
|
-
ts as f,
|
|
1734
|
-
ss as g,
|
|
1735
|
-
ns as h,
|
|
1736
|
-
as as i,
|
|
1737
|
-
os as j,
|
|
1738
|
-
is as k,
|
|
1739
|
-
ls as l,
|
|
1740
|
-
us as m,
|
|
1741
|
-
ms as n,
|
|
1742
|
-
ps as o,
|
|
1743
|
-
hs as p,
|
|
1744
|
-
gs as q,
|
|
1745
|
-
xs as r,
|
|
1746
|
-
bs as s,
|
|
1747
|
-
js as t,
|
|
1748
|
-
at as u,
|
|
1749
|
-
ys as v,
|
|
1750
|
-
Ns as w,
|
|
1751
|
-
ws as x,
|
|
1752
|
-
Ne as y,
|
|
1753
|
-
Et as z
|
|
1754
|
-
};
|