treege 3.0.0-beta.4 → 3.0.0-beta.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/LICENSE +18 -12
  2. package/README.md +306 -52
  3. package/dist/DefaultInputs-8yJMEyMh.js +1557 -0
  4. package/dist/ThemeContext-Ejgu9Mwr.js +1603 -0
  5. package/dist/editor/components/input/ComboboxWithCreate.d.ts +2 -1
  6. package/dist/editor/constants/defaultNode.d.ts +1 -1
  7. package/dist/editor/constants/edgeTypes.d.ts +3 -2
  8. package/dist/editor/constants/inputTypeIcons.d.ts +3 -0
  9. package/dist/editor/constants/nodeSpacing.d.ts +33 -0
  10. package/dist/editor/constants/nodeTypes.d.ts +5 -5
  11. package/dist/editor/context/TreegeEditorContext.d.ts +53 -1
  12. package/dist/editor/features/TreegeEditor/TreegeEditor.d.ts +1 -1
  13. package/dist/editor/features/TreegeEditor/dialogs/ChangeNodeTypeDialog.d.ts +2 -0
  14. package/dist/editor/features/TreegeEditor/dialogs/DeleteNodeDialog.d.ts +2 -0
  15. package/dist/editor/features/TreegeEditor/edges/ConditionalEdge.d.ts +2 -2
  16. package/dist/editor/features/TreegeEditor/edges/DefaultEdge.d.ts +3 -0
  17. package/dist/editor/features/TreegeEditor/forms/SubmitConfigForm.d.ts +7 -0
  18. package/dist/editor/features/TreegeEditor/inputs/ComboboxPattern.d.ts +2 -1
  19. package/dist/editor/features/TreegeEditor/inputs/OptionImageField.d.ts +6 -0
  20. package/dist/editor/features/TreegeEditor/nodes/GroupNode.d.ts +2 -2
  21. package/dist/editor/features/TreegeEditor/nodes/TreegeNode.d.ts +6 -0
  22. package/dist/editor/features/TreegeEditor/nodes/components/BottomHandleDropdown.d.ts +6 -0
  23. package/dist/editor/features/TreegeEditor/nodes/components/NodeInputPreview.d.ts +7 -0
  24. package/dist/editor/features/TreegeEditor/nodes/components/NodeLabelInput.d.ts +9 -0
  25. package/dist/editor/features/TreegeEditor/nodes/components/NodeMoreMenu.d.ts +6 -0
  26. package/dist/editor/features/TreegeEditor/nodes/components/NodeTypeBadge.d.ts +7 -0
  27. package/dist/editor/features/TreegeEditor/nodes/components/OptionsEditor.d.ts +7 -0
  28. package/dist/editor/features/TreegeEditor/nodes/components/RequiredBadge.d.ts +6 -0
  29. package/dist/editor/features/TreegeEditor/nodes/layout/NodeWrapper.d.ts +2 -1
  30. package/dist/editor/features/TreegeEditor/panel/AIGeneratorDialog.d.ts +16 -0
  31. package/dist/editor/hooks/useAutoLayout.d.ts +15 -0
  32. package/dist/editor/hooks/useFlowActions.d.ts +5 -2
  33. package/dist/editor/hooks/useFlowConnections.d.ts +4 -0
  34. package/dist/editor/hooks/useNodesSelection.d.ts +5 -5
  35. package/dist/editor/types/ai.d.ts +65 -0
  36. package/dist/editor/types/editor.d.ts +9 -8
  37. package/dist/editor/utils/aiFlowGenerator.d.ts +5 -0
  38. package/dist/editor/utils/dagreLayout.d.ts +17 -0
  39. package/dist/editor/utils/edge.d.ts +14 -0
  40. package/dist/editor/utils/image.d.ts +7 -0
  41. package/dist/editor/utils/inputTypeIcon.d.ts +6 -0
  42. package/dist/editor-DWJ95r4g.js +4001 -0
  43. package/dist/editor.js +3 -8
  44. package/dist/main.js +4 -53
  45. package/dist/renderer/context/TreegeRendererContext.d.ts +4 -1
  46. package/dist/renderer/features/TreegeRenderer/native/TreegeRenderer.d.ts +19 -11
  47. package/dist/renderer/features/TreegeRenderer/native/components/DefaultFormWrapper.d.ts +7 -7
  48. package/dist/renderer/features/TreegeRenderer/native/components/DefaultGroup.d.ts +7 -7
  49. package/dist/renderer/features/TreegeRenderer/native/components/DefaultInputs.d.ts +21 -15
  50. package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButton.d.ts +9 -7
  51. package/dist/renderer/features/TreegeRenderer/native/components/DefaultSubmitButtonWrapper.d.ts +11 -0
  52. package/dist/renderer/features/TreegeRenderer/native/components/DefaultUI.d.ts +8 -7
  53. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAddressInput.d.ts +3 -0
  54. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultAutocompleteInput.d.ts +3 -0
  55. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultCheckboxInput.d.ts +3 -0
  56. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateInput.d.ts +3 -0
  57. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultDateRangeInput.d.ts +3 -0
  58. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultFileInput.d.ts +3 -0
  59. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHiddenInput.d.ts +3 -0
  60. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultHttpInput.d.ts +3 -0
  61. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultNumberInput.d.ts +3 -0
  62. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultPasswordInput.d.ts +3 -0
  63. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultRadioInput.d.ts +3 -0
  64. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSelectInput.d.ts +3 -0
  65. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultSwitchInput.d.ts +3 -0
  66. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextInput.d.ts +3 -0
  67. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTextareaInput.d.ts +3 -0
  68. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeInput.d.ts +3 -0
  69. package/dist/renderer/features/TreegeRenderer/native/components/inputs/DefaultTimeRangeInput.d.ts +3 -0
  70. package/dist/renderer/features/TreegeRenderer/useTreegeRenderer.d.ts +84 -24
  71. package/dist/renderer/features/TreegeRenderer/web/TreegeRenderer.d.ts +1 -1
  72. package/dist/renderer/features/TreegeRenderer/web/components/DefaultSubmitButton.d.ts +1 -1
  73. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAddressInput.d.ts +1 -1
  74. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultAutocompleteInput.d.ts +1 -1
  75. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultCheckboxInput.d.ts +1 -1
  76. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateInput.d.ts +1 -1
  77. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultDateRangeInput.d.ts +1 -1
  78. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultFileInput.d.ts +1 -1
  79. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHiddenInput.d.ts +1 -1
  80. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultHttpInput.d.ts +1 -1
  81. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultNumberInput.d.ts +1 -1
  82. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultPasswordInput.d.ts +1 -1
  83. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultRadioInput.d.ts +1 -1
  84. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSelectInput.d.ts +1 -1
  85. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSubmitInput.d.ts +3 -0
  86. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultSwitchInput.d.ts +1 -1
  87. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextAreaInput.d.ts +1 -1
  88. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTextInput.d.ts +1 -1
  89. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeInput.d.ts +1 -1
  90. package/dist/renderer/features/TreegeRenderer/web/components/inputs/DefaultTimeRangeInput.d.ts +1 -1
  91. package/dist/renderer/hooks/useRenderNode.d.ts +55 -0
  92. package/dist/renderer/hooks/useSubmitHandler.d.ts +34 -0
  93. package/dist/renderer/hooks/useTranslate.d.ts +6 -4
  94. package/dist/renderer/index.d.ts +2 -0
  95. package/dist/renderer/index.native.d.ts +19 -0
  96. package/dist/renderer/types/renderer.d.ts +60 -6
  97. package/dist/renderer/utils/form.d.ts +22 -2
  98. package/dist/renderer/utils/http.d.ts +101 -0
  99. package/dist/renderer/utils/node.d.ts +18 -1
  100. package/dist/renderer/utils/sanitize.d.ts +85 -0
  101. package/dist/renderer/utils/sanitize.native.d.ts +69 -0
  102. package/dist/renderer/utils/submit.d.ts +47 -0
  103. package/dist/renderer-native.d.ts +2 -0
  104. package/dist/renderer-native.js +3496 -0
  105. package/dist/renderer.js +3 -46
  106. package/dist/shared/components/ui/badge.d.ts +2 -2
  107. package/dist/shared/components/ui/button.d.ts +2 -2
  108. package/dist/shared/components/ui/collapsible.d.ts +1 -1
  109. package/dist/shared/components/ui/command.d.ts +1 -1
  110. package/dist/shared/components/ui/dropdown-menu.d.ts +1 -1
  111. package/dist/shared/components/ui/form.d.ts +1 -1
  112. package/dist/shared/components/ui/popover.d.ts +4 -2
  113. package/dist/shared/components/ui/select.d.ts +3 -1
  114. package/dist/shared/components/ui/sheet.d.ts +1 -1
  115. package/dist/shared/components/ui/tooltip.d.ts +1 -1
  116. package/dist/shared/constants/colors.d.ts +45 -0
  117. package/dist/shared/constants/inputType.d.ts +1 -0
  118. package/dist/shared/context/ThemeContext.d.ts +2 -0
  119. package/dist/shared/context/ThemeContext.native.d.ts +22 -0
  120. package/dist/shared/hooks/useThemeColors.d.ts +37 -0
  121. package/dist/shared/locales/ar.json.d.ts +117 -10
  122. package/dist/shared/locales/de.json.d.ts +118 -11
  123. package/dist/shared/locales/en.json.d.ts +119 -12
  124. package/dist/shared/locales/es.json.d.ts +118 -11
  125. package/dist/shared/locales/fr.json.d.ts +118 -11
  126. package/dist/shared/locales/it.json.d.ts +118 -11
  127. package/dist/shared/locales/pt.json.d.ts +118 -11
  128. package/dist/shared/types/edge.d.ts +6 -0
  129. package/dist/shared/types/node.d.ts +64 -0
  130. package/package.json +38 -12
  131. package/dist/ThemeContext-D4xMOrdt.js +0 -759
  132. package/dist/TreegeEditor-Cv0caawk.js +0 -2152
  133. package/dist/TreegeRenderer-BOCobRLr.js +0 -1414
  134. package/dist/_name_.css +0 -1
  135. package/dist/editor/features/TreegeEditor/inputs/SelectInputType.d.ts +0 -7
  136. package/dist/editor/features/TreegeEditor/nodes/FlowNode.d.ts +0 -6
  137. package/dist/editor/features/TreegeEditor/nodes/InputNode.d.ts +0 -6
  138. package/dist/editor/features/TreegeEditor/nodes/UINode.d.ts +0 -6
@@ -1,1414 +0,0 @@
1
- "use client";
2
- import { j as t, i as q, L as ne, b as Fe, e as Qe, F as D, f as F, I as z, C as pe, h as fe, k as xe, l as ge, m as be, n as k, o as A, P as Y, p as Z, B as H, q as ee, r as Se, s as b, t as Ne, v as ve, S as Ce, w as Ie, x as De, y as ke, z as Ae, A as Re, D as Xe, E as Ye, G as le, N as X, a as Ze, c as et, T as tt } from "./ThemeContext-D4xMOrdt.js";
3
- import * as ye from "react";
4
- import { createContext as Ee, useContext as _e, useMemo as L, useState as E, useCallback as V, useEffect as B, useRef as me } from "react";
5
- import { MapPin as we, ChevronsUpDown as Pe, Check as Oe, ChevronLeftIcon as at, ChevronRightIcon as st, ChevronDownIcon as je, Loader2 as ie, CircleIcon as rt } from "lucide-react";
6
- import { getDefaultClassNames as ze, DayPicker as nt } from "react-day-picker";
7
- import * as he from "@radix-ui/react-radio-group";
8
- import * as G from "@radix-ui/react-tooltip";
9
- const $e = Ee(void 0), lt = () => _e($e), la = ({
10
- children: e,
11
- components: r,
12
- googleApiKey: n,
13
- language: a,
14
- theme: s,
15
- validationMode: l
16
- }) => {
17
- const i = {
18
- components: r,
19
- googleApiKey: n,
20
- language: a,
21
- theme: s,
22
- validationMode: l
23
- };
24
- return /* @__PURE__ */ t.jsx($e.Provider, { value: i, children: e });
25
- }, Te = (e) => e == null ? null : typeof e == "boolean" || typeof e == "number" || typeof e == "string" ? e : typeof e == "object" ? JSON.stringify(e) : String(e), it = (e, r, n) => {
26
- const a = Te(e), s = Te(r);
27
- if (a === null || s === null)
28
- switch (n) {
29
- case "===":
30
- return a === s;
31
- case "!==":
32
- return a !== s;
33
- default:
34
- return !1;
35
- }
36
- if ([">", "<", ">=", "<="].includes(n)) {
37
- const l = Number(a), i = Number(s);
38
- if (!(Number.isNaN(l) || Number.isNaN(i)))
39
- switch (n) {
40
- case ">":
41
- return l > i;
42
- case "<":
43
- return l < i;
44
- case ">=":
45
- return l >= i;
46
- case "<=":
47
- return l <= i;
48
- default:
49
- return !1;
50
- }
51
- return !1;
52
- }
53
- switch (n) {
54
- case "===": {
55
- const l = Number(a), i = Number(s);
56
- return Number.isNaN(l) || Number.isNaN(i) ? String(a) === String(s) : l === i;
57
- }
58
- case "!==": {
59
- const l = Number(a), i = Number(s);
60
- return Number.isNaN(l) || Number.isNaN(i) ? String(a) !== String(s) : l !== i;
61
- }
62
- default:
63
- return !1;
64
- }
65
- }, oe = (e, r, n) => {
66
- const { field: a, operator: s, value: l } = e;
67
- if (!(a && s) || l === void 0)
68
- return !0;
69
- let i = r[a];
70
- if (i === void 0 && n) {
71
- const o = n.get(a);
72
- o && q(o) && (i = r[o.id]);
73
- }
74
- return it(i, l, s);
75
- }, ot = (e, r, n) => {
76
- if (!e || e.length === 0)
77
- return !0;
78
- if (e.length === 1)
79
- return oe(e[0], r, n);
80
- let a = oe(e[0], r, n);
81
- for (let s = 1; s < e.length; s += 1) {
82
- const l = e[s], i = oe(l, r, n), o = e[s - 1].logicalOperator || ne.AND;
83
- if (o === ne.AND) {
84
- if (a = a && i, !a)
85
- return !1;
86
- } else if (o === ne.OR && (a = a || i, a))
87
- return !0;
88
- }
89
- return a;
90
- }, de = (e) => e == null || typeof e == "string" && e.trim() === "" ? !0 : Array.isArray(e) && e.length === 0, dt = (e, r) => {
91
- if (!e)
92
- return !1;
93
- const n = r[e];
94
- return n != null;
95
- }, ct = (e, r) => {
96
- const n = {};
97
- return r.forEach((a) => {
98
- const s = a.id, l = a.data.name || s;
99
- e[s] !== void 0 && (n[l] = e[s]);
100
- }), n;
101
- }, ut = (e) => {
102
- const r = /* @__PURE__ */ new Map();
103
- return e.forEach((n) => {
104
- const a = r.get(n.source);
105
- a ? a.push(n) : r.set(n.source, [n]);
106
- }), r;
107
- }, mt = (e, r, n) => {
108
- const a = [], s = [], l = [];
109
- e.forEach((m) => {
110
- const c = m.data?.isFallback, f = m.data?.conditions?.length;
111
- c ? l.push(m) : f ? s.push(m) : a.push(m);
112
- });
113
- const i = [...a];
114
- if (s.length === 0)
115
- return l.length > 0 && i.length === 0 && i.push(...l), { edgesToFollow: i, waitingForInput: !1 };
116
- if (!s.every((m) => {
117
- const c = m.data?.conditions;
118
- return c ? c.every((f) => {
119
- if (!f.field)
120
- return !0;
121
- const p = n.get(f.field), x = q(p) ? p.id : f.field;
122
- return dt(x, r);
123
- }) : !1;
124
- }))
125
- return { edgesToFollow: i, waitingForInput: i.length === 0 };
126
- const d = s.filter((m) => ot(m.data?.conditions, r, n));
127
- return d.length > 0 ? (i.push(...d), { edgesToFollow: i, waitingForInput: !1 }) : (i.push(...l), { edgesToFollow: i, waitingForInput: !1 });
128
- }, Me = (e, r) => !r.some((n) => n.target === e), ht = (e, r) => {
129
- const n = e.filter((a) => Me(a.id, r));
130
- return n.find(q) || n[0];
131
- }, pt = (e, r, n, a) => {
132
- e.forEach((s) => {
133
- const l = a.get(s);
134
- if (!l)
135
- return;
136
- let { parentId: i } = l;
137
- const o = /* @__PURE__ */ new Set();
138
- for (; i && !o.has(i); ) {
139
- if (o.add(i), r.add(i), !n.has(i)) {
140
- const d = n.get(s);
141
- d !== void 0 && n.set(i, d);
142
- }
143
- i = a.get(i)?.parentId;
144
- }
145
- });
146
- }, ft = (e, r, n) => {
147
- const a = ht(e, r);
148
- if (!a)
149
- return {
150
- endOfPathReached: !0,
151
- visibleNodeIds: /* @__PURE__ */ new Set(),
152
- visibleNodes: [],
153
- visibleRootNodes: []
154
- };
155
- const s = new Map(e.map((h) => [h.id, h])), l = ut(r), i = [], o = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
156
- let m = !1;
157
- const c = (h) => {
158
- if (d.has(h))
159
- return;
160
- d.add(h);
161
- const u = s.get(h);
162
- if (!u)
163
- return;
164
- o.add(h), i.push(u);
165
- const S = l.get(h) || [], { edgesToFollow: N, waitingForInput: y } = mt(S, n, s);
166
- if (y) {
167
- m = !0;
168
- return;
169
- }
170
- N.forEach((j) => {
171
- c(j.target);
172
- });
173
- };
174
- c(a.id);
175
- const f = new Map(i.map((h, u) => [h.id, u])), p = new Set(o);
176
- pt(o, p, f, s);
177
- const x = e.filter((h) => p.has(h.id)).sort((h, u) => (f.get(h.id) ?? Number.MAX_SAFE_INTEGER) - (f.get(u.id) ?? Number.MAX_SAFE_INTEGER)), v = x.filter((h) => !(h.parentId && p.has(h.parentId)));
178
- return {
179
- endOfPathReached: !m,
180
- visibleNodeIds: p,
181
- visibleNodes: x,
182
- visibleRootNodes: v
183
- };
184
- }, xt = (e) => {
185
- if (e.length === 1)
186
- return e[0];
187
- const r = new Set(e.map((a) => a.id)), n = /* @__PURE__ */ new Set();
188
- return e.forEach((a) => {
189
- a.nodes.forEach((s) => {
190
- if (Fe(s)) {
191
- const l = s.data.targetId;
192
- l && r.has(l) && n.add(l);
193
- }
194
- });
195
- }), e.find((a) => !n.has(a.id)) || e[0];
196
- }, qe = (e, r, n, a, s = /* @__PURE__ */ new Set()) => {
197
- const l = /* @__PURE__ */ new Set();
198
- for (const i of e)
199
- if (n.has(i)) {
200
- const o = a.get(i), d = o ? r.get(o) : void 0;
201
- if (d) {
202
- if (o && s.has(o))
203
- continue;
204
- o && s.add(o);
205
- const m = new Set(d.nodes.map((f) => f.id)), c = qe(m, r, n, a, s);
206
- for (const f of c)
207
- l.add(f);
208
- }
209
- } else
210
- l.add(i);
211
- return l;
212
- }, gt = (e, r) => {
213
- const n = /* @__PURE__ */ new Set();
214
- return r.forEach((a) => {
215
- e.has(a.source) && e.has(a.target) && n.add(a.source);
216
- }), Array.from(e).filter((a) => !n.has(a));
217
- }, Be = (e) => {
218
- if (!e)
219
- return { edges: [], id: "empty", nodes: [] };
220
- const r = Array.isArray(e) ? e : [e];
221
- if (r.length === 0)
222
- return { edges: [], id: "empty", nodes: [] };
223
- const n = xt(r);
224
- if (r.length === 1)
225
- return n;
226
- const a = new Map(r.map((p) => [p.id, p])), s = [], l = [...n.edges], i = /* @__PURE__ */ new Set([n.id]), o = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), c = (p) => {
227
- const x = [];
228
- return p.forEach((v) => {
229
- if (!Fe(v)) {
230
- x.push(v);
231
- return;
232
- }
233
- const h = v.data.targetId;
234
- if (!h)
235
- return;
236
- const u = a.get(h);
237
- if (!u) {
238
- console.warn(`Flow with id "${h}" not found`);
239
- return;
240
- }
241
- const S = u.nodes.find((N) => !N.parentId);
242
- if (!S) {
243
- console.warn(`Flow "${h}" has no root node; preserving FlowNode "${v.id}"`), x.push(v);
244
- return;
245
- }
246
- o.set(v.id, S.id), d.set(v.id, h), i.has(h) || (i.add(h), l.push(...u.edges), x.push(...c(u.nodes)));
247
- }), x;
248
- };
249
- s.push(...c(n.nodes)), l.forEach((p) => {
250
- if (o.has(p.source)) {
251
- const x = m.get(p.source);
252
- x ? x.push(p) : m.set(p.source, [p]);
253
- }
254
- });
255
- const f = l.map((p) => {
256
- if (o.has(p.source))
257
- return null;
258
- const x = o.get(p.target);
259
- return x ? { ...p, target: x } : p;
260
- }).filter((p) => p !== null);
261
- return o.forEach((p, x) => {
262
- const v = m.get(x);
263
- if (!v?.length)
264
- return;
265
- const h = d.get(x), u = h ? a.get(h) : void 0;
266
- if (!u)
267
- return;
268
- const S = new Set(u.nodes.map((j) => j.id)), N = qe(
269
- S,
270
- a,
271
- o,
272
- d,
273
- new Set(h ? [h] : [])
274
- );
275
- gt(N, f).forEach((j) => {
276
- v.forEach((g) => {
277
- const w = o.get(g.target) ?? g.target, T = g.id ?? `${x}__${g.target}`;
278
- f.push({
279
- ...g,
280
- id: `${j}__${T}`,
281
- source: j,
282
- target: w
283
- });
284
- });
285
- });
286
- }), {
287
- edges: f,
288
- id: n.id,
289
- nodes: s
290
- };
291
- }, Ve = Ee(null), bt = ({ children: e, value: r }) => /* @__PURE__ */ t.jsx(Ve.Provider, { value: r, children: e }), te = () => {
292
- const r = _e(Ve) ?? {
293
- flows: null,
294
- formErrors: {},
295
- formValues: {},
296
- googleApiKey: void 0,
297
- language: "",
298
- setFieldValue: () => {
299
- }
300
- }, n = L(() => r.flows ? Be(r.flows).edges : [], [r.flows]);
301
- return {
302
- ...r,
303
- edges: n
304
- };
305
- }, I = (e) => {
306
- const r = te(), n = e ?? r.language;
307
- return Qe(n);
308
- }, jt = (e) => e.filter(q), Nt = (e, r) => {
309
- const n = r.find((a) => a.id === e);
310
- return n ? n.data.name || n.id : void 0;
311
- }, vt = (e, r = {}, n = "en") => {
312
- const a = L(() => Be(e), [e]), { nodes: s, edges: l } = a, i = L(() => jt(s), [s]), o = I(n), [d, m] = E({}), [c, f] = E(() => {
313
- const N = { ...r };
314
- return s.forEach((y) => {
315
- if (q(y)) {
316
- const j = y.id;
317
- if (N[j] !== void 0)
318
- return;
319
- const { defaultValue: g } = y.data;
320
- if (!g)
321
- return;
322
- if (g.type === "static" && g.staticValue !== void 0 && (N[j] = g.staticValue), g.type === "reference" && g.referenceField) {
323
- const { referenceField: w } = g, T = N[w];
324
- T !== void 0 && (N[j] = T);
325
- }
326
- }
327
- }), N;
328
- }), { endOfPathReached: p, visibleNodes: x, visibleRootNodes: v } = L(
329
- () => ft(s, l, c),
330
- [s, l, c]
331
- ), h = V((N, y) => {
332
- f((j) => ({
333
- ...j,
334
- [N]: y
335
- })), m((j) => {
336
- const g = { ...j };
337
- return delete g[N], g;
338
- });
339
- }, []), u = V(
340
- (N) => {
341
- const y = {};
342
- x.forEach((w) => {
343
- if (q(w)) {
344
- const T = w.id, _ = c[T];
345
- if (w.data.required && de(_)) {
346
- y[T] = o(w.data.errorMessage) || o("validation.required");
347
- return;
348
- }
349
- if (!de(_) && w.data.pattern)
350
- try {
351
- new RegExp(w.data.pattern).test(String(_)) || (y[T] = o(w.data.errorMessage) || o("validation.invalidFormat"));
352
- } catch (R) {
353
- console.error(`Invalid pattern for field ${T}:`, R);
354
- }
355
- }
356
- });
357
- const j = N ? N(c, x) : {}, g = {
358
- ...y,
359
- ...j
360
- };
361
- return m(g), {
362
- errors: g,
363
- hasCustomErrors: Object.keys(j).length > 0,
364
- isValid: Object.keys(g).length === 0
365
- };
366
- },
367
- [x, c, o]
368
- ), S = L(() => {
369
- const N = [];
370
- return x.forEach((y) => {
371
- if (!q(y))
372
- return;
373
- const j = y.id, g = c[j];
374
- if (y.data.required && de(g)) {
375
- const w = o(y.data.label) || j;
376
- N.push(w);
377
- }
378
- }), N;
379
- }, [x, c, o]);
380
- return {
381
- canSubmit: p && s.length > 0,
382
- formErrors: d,
383
- formValues: c,
384
- inputNodes: i,
385
- mergedFlow: a,
386
- missingRequiredFields: S,
387
- setFieldValue: h,
388
- setFormErrors: m,
389
- t: o,
390
- validateForm: u,
391
- visibleNodes: x,
392
- visibleRootNodes: v
393
- };
394
- }, yt = ({ children: e, onSubmit: r }) => /* @__PURE__ */ t.jsx("form", { onSubmit: r, className: "mx-auto max-w-2xl gap-y-3", children: e }), wt = ({ node: e, children: r }) => {
395
- const n = I();
396
- return /* @__PURE__ */ t.jsxs("section", { className: "mb-6 rounded-lg border p-4", children: [
397
- e.data.label && /* @__PURE__ */ t.jsx("h3", { className: "text-lg font-semibold mb-4", children: n(e.data.label) }),
398
- r
399
- ] });
400
- }, Tt = async (e, r) => {
401
- if (!e || e.trim().length < 3)
402
- return [];
403
- try {
404
- const n = await fetch(
405
- `https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(e)}&format=jsonv2&addressdetails=1&limit=5`,
406
- {
407
- headers: {
408
- Accept: "application/json",
409
- "User-Agent": "Treege Renderer",
410
- ...r && { "Accept-Language": r }
411
- }
412
- }
413
- );
414
- return n.ok ? (await n.json()).map((s) => ({
415
- label: s.display_name,
416
- value: s.display_name
417
- })) : [];
418
- } catch (n) {
419
- return console.error("Nominatim fetch error:", n), [];
420
- }
421
- }, Ft = (e) => !e || e.trim().length < 3 ? Promise.resolve([]) : new Promise((r) => {
422
- if (!window.google?.maps?.places) {
423
- console.warn("Google Places SDK not loaded yet"), r([]);
424
- return;
425
- }
426
- new window.google.maps.places.AutocompleteService().getPlacePredictions({ input: e }, (a, s) => {
427
- if (s !== google.maps.places.PlacesServiceStatus.OK || !a) {
428
- console.warn("Google Places API status:", s), r([]);
429
- return;
430
- }
431
- r(
432
- a.map((l) => ({
433
- label: l.description,
434
- value: l.description
435
- }))
436
- );
437
- });
438
- }), St = ({ node: e, value: r, setValue: n, error: a }) => {
439
- const [s, l] = E(""), [i, o] = E([]), [d, m] = E(!1), { googleApiKey: c, language: f } = te(), p = I(), x = e.data.name || e.id, v = V(
440
- (u) => {
441
- n(u.value), l(u.value), m(!1);
442
- },
443
- [n]
444
- );
445
- B(() => {
446
- if (!s || s.trim().length < 3) {
447
- o([]);
448
- return;
449
- }
450
- const u = setTimeout(async () => {
451
- const S = c ? await Ft(s) : await Tt(s, f);
452
- o(S);
453
- }, 300);
454
- return () => clearTimeout(u);
455
- }, [s, c, f]);
456
- const h = V(
457
- (u) => {
458
- n(u), l(u), u.length >= 3 && m(!0);
459
- },
460
- [n]
461
- );
462
- return /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
463
- c && /* @__PURE__ */ t.jsx("script", { async: !0, src: `https://maps.googleapis.com/maps/api/js?key=${c}&libraries=places` }),
464
- /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
465
- /* @__PURE__ */ t.jsxs(F, { htmlFor: x, children: [
466
- p(e.data.label) || e.data.name,
467
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
468
- ] }),
469
- /* @__PURE__ */ t.jsxs("div", { className: "relative", children: [
470
- /* @__PURE__ */ t.jsx(
471
- z,
472
- {
473
- type: "text",
474
- id: x,
475
- name: x,
476
- value: r || "",
477
- onChange: (u) => h(u.target.value),
478
- onFocus: () => {
479
- i.length > 0 && m(!0);
480
- },
481
- placeholder: p(e.data.placeholder) || p("renderer.defaultAddressInput.enterAddress"),
482
- className: "pr-10",
483
- autoComplete: "off"
484
- }
485
- ),
486
- /* @__PURE__ */ t.jsx(we, { className: "-translate-y-1/2 pointer-events-none absolute top-1/2 right-3 h-4 w-4 text-muted-foreground" }),
487
- d && /* @__PURE__ */ t.jsx("div", { className: "absolute z-50 mt-1 w-full rounded-md border bg-popover shadow-md", children: /* @__PURE__ */ t.jsx(pe, { children: /* @__PURE__ */ t.jsxs(fe, { children: [
488
- /* @__PURE__ */ t.jsx(xe, { children: p("renderer.defaultAddressInput.noAddressesFound") }),
489
- /* @__PURE__ */ t.jsx(ge, { children: i.map((u, S) => /* @__PURE__ */ t.jsxs(
490
- be,
491
- {
492
- value: u.value,
493
- onSelect: () => v(u),
494
- onMouseDown: (N) => N.preventDefault(),
495
- children: [
496
- /* @__PURE__ */ t.jsx(we, { className: "mr-2 h-4 w-4" }),
497
- u.label
498
- ]
499
- },
500
- S
501
- )) })
502
- ] }) }) })
503
- ] }),
504
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
505
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: p(e.data.helperText) })
506
- ] })
507
- ] });
508
- }, Ct = ({ node: e, value: r, setValue: n, error: a }) => {
509
- const s = I(), [l, i] = E(!1), o = e.data.name || e.id, d = `${o}-trigger`, m = `${o}-error`, c = e.data.options || [], f = c.find((p) => p.value === r);
510
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
511
- /* @__PURE__ */ t.jsxs(F, { htmlFor: d, children: [
512
- s(e.data.label) || e.data.name,
513
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
514
- ] }),
515
- /* @__PURE__ */ t.jsxs(Y, { open: l, onOpenChange: i, children: [
516
- /* @__PURE__ */ t.jsx(Z, { asChild: !0, children: /* @__PURE__ */ t.jsxs(
517
- H,
518
- {
519
- id: d,
520
- variant: "outline",
521
- role: "combobox",
522
- "aria-expanded": l,
523
- "aria-invalid": !!a || void 0,
524
- "aria-describedby": a ? m : void 0,
525
- className: "w-full justify-between font-normal",
526
- children: [
527
- r ? f?.label ? s(f.label) : r : s(e.data.placeholder) || s("renderer.defaultAutocompleteInput.selectOption"),
528
- /* @__PURE__ */ t.jsx(Pe, { className: "ml-2 size-4 shrink-0 opacity-50" })
529
- ]
530
- }
531
- ) }),
532
- /* @__PURE__ */ t.jsx(ee, { className: "w-full p-0", align: "start", children: /* @__PURE__ */ t.jsxs(pe, { children: [
533
- /* @__PURE__ */ t.jsx(Se, { placeholder: s(e.data.placeholder) || s("renderer.defaultAutocompleteInput.search") }),
534
- /* @__PURE__ */ t.jsxs(fe, { children: [
535
- /* @__PURE__ */ t.jsx(xe, { children: s("renderer.defaultAutocompleteInput.noResults") }),
536
- /* @__PURE__ */ t.jsx(ge, { children: c.map((p) => /* @__PURE__ */ t.jsxs(
537
- be,
538
- {
539
- value: p.value,
540
- disabled: p.disabled,
541
- onSelect: (x) => {
542
- n(x === r ? "" : x), i(!1);
543
- },
544
- children: [
545
- /* @__PURE__ */ t.jsx(Oe, { className: b("mr-2 size-4", r === p.value ? "opacity-100" : "opacity-0") }),
546
- s(p.label)
547
- ]
548
- },
549
- p.value
550
- )) })
551
- ] })
552
- ] }) })
553
- ] }),
554
- a && /* @__PURE__ */ t.jsx(k, { id: m, children: a }),
555
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
556
- ] });
557
- }, It = ({ node: e, value: r, setValue: n, error: a }) => {
558
- const s = I(), l = e.data.name || e.id;
559
- if (e.data.options && e.data.options.length > 0) {
560
- const i = Array.isArray(r) ? r.map(String) : [], o = (d, m) => {
561
- const c = m ? [...i, d] : i.filter((f) => f !== d);
562
- n(c);
563
- };
564
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
565
- /* @__PURE__ */ t.jsxs(F, { className: "mb-1", children: [
566
- s(e.data.label) || e.data.name,
567
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
568
- ] }),
569
- /* @__PURE__ */ t.jsx("div", { className: "space-y-2", children: e.data.options.map((d, m) => /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-3", children: [
570
- /* @__PURE__ */ t.jsx(
571
- Ne,
572
- {
573
- id: `${l}-${d.value}`,
574
- checked: i.includes(String(d.value)),
575
- onCheckedChange: (c) => o(String(d.value), !!c),
576
- disabled: d.disabled
577
- }
578
- ),
579
- /* @__PURE__ */ t.jsx(F, { htmlFor: `${l}-${d.value}`, className: "cursor-pointer font-normal text-sm", children: s(d.label) ? s(d.label) : d.value })
580
- ] }, d.value + m)) }),
581
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
582
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
583
- ] });
584
- }
585
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
586
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-3", children: [
587
- /* @__PURE__ */ t.jsx(
588
- Ne,
589
- {
590
- id: l,
591
- checked: typeof r == "boolean" ? r : !1,
592
- onCheckedChange: (i) => n(!!i)
593
- }
594
- ),
595
- /* @__PURE__ */ t.jsxs("div", { children: [
596
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, className: "cursor-pointer font-medium text-sm", children: [
597
- s(e.data.label) || e.data.name,
598
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
599
- ] }),
600
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
601
- ] })
602
- ] }),
603
- a && /* @__PURE__ */ t.jsx(k, { children: a })
604
- ] });
605
- };
606
- function Le({
607
- className: e,
608
- classNames: r,
609
- showOutsideDays: n = !0,
610
- captionLayout: a = "label",
611
- buttonVariant: s = "ghost",
612
- formatters: l,
613
- components: i,
614
- ...o
615
- }) {
616
- const d = ze();
617
- return /* @__PURE__ */ t.jsx(
618
- nt,
619
- {
620
- showOutsideDays: n,
621
- className: b(
622
- "group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
623
- String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
624
- String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
625
- e
626
- ),
627
- captionLayout: a,
628
- formatters: {
629
- formatMonthDropdown: (m) => m.toLocaleString("default", { month: "short" }),
630
- ...l
631
- },
632
- classNames: {
633
- button_next: b(
634
- ve({ variant: s }),
635
- "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
636
- d.button_next
637
- ),
638
- button_previous: b(
639
- ve({ variant: s }),
640
- "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
641
- d.button_previous
642
- ),
643
- caption_label: b(
644
- "select-none font-medium",
645
- a === "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",
646
- d.caption_label
647
- ),
648
- day: b(
649
- "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",
650
- d.day
651
- ),
652
- disabled: b("text-muted-foreground opacity-50", d.disabled),
653
- dropdown: b("absolute bg-popover inset-0 opacity-0", d.dropdown),
654
- dropdown_root: b(
655
- "relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",
656
- d.dropdown_root
657
- ),
658
- dropdowns: b("w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5", d.dropdowns),
659
- hidden: b("invisible", d.hidden),
660
- month: b("flex flex-col w-full gap-4", d.month),
661
- month_caption: b("flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)", d.month_caption),
662
- months: b("flex gap-4 flex-col md:flex-row relative", d.months),
663
- nav: b("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between", d.nav),
664
- outside: b("text-muted-foreground aria-selected:text-muted-foreground", d.outside),
665
- range_end: b("rounded-r-md bg-accent", d.range_end),
666
- range_middle: b("rounded-none", d.range_middle),
667
- range_start: b("rounded-l-md bg-accent", d.range_start),
668
- root: b("w-fit", d.root),
669
- table: "w-full border-collapse",
670
- today: b("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none", d.today),
671
- week: b("flex w-full mt-2", d.week),
672
- week_number: b("text-[0.8rem] select-none text-muted-foreground", d.week_number),
673
- week_number_header: b("select-none w-(--cell-size)", d.week_number_header),
674
- weekday: b("text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none", d.weekday),
675
- weekdays: b("flex", d.weekdays),
676
- ...r
677
- },
678
- components: {
679
- Chevron: ({ className: m, orientation: c, ...f }) => c === "left" ? /* @__PURE__ */ t.jsx(at, { className: b("size-4", m), ...f }) : c === "right" ? /* @__PURE__ */ t.jsx(st, { className: b("size-4", m), ...f }) : /* @__PURE__ */ t.jsx(je, { className: b("size-4", m), ...f }),
680
- DayButton: Dt,
681
- Root: ({ className: m, rootRef: c, ...f }) => /* @__PURE__ */ t.jsx("div", { "data-slot": "calendar", ref: c, className: b(m), ...f }),
682
- WeekNumber: ({ children: m, ...c }) => /* @__PURE__ */ t.jsx("td", { ...c, children: /* @__PURE__ */ t.jsx("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children: m }) }),
683
- ...i
684
- },
685
- ...o
686
- }
687
- );
688
- }
689
- function Dt({ className: e, day: r, modifiers: n, ...a }) {
690
- const s = ze(), l = ye.useRef(null);
691
- return ye.useEffect(() => {
692
- n.focused && l.current?.focus();
693
- }, [n.focused]), /* @__PURE__ */ t.jsx(
694
- H,
695
- {
696
- ref: l,
697
- variant: "ghost",
698
- size: "icon",
699
- "data-day": r.date.toLocaleDateString(),
700
- "data-selected-single": n.selected && !n.range_start && !n.range_end && !n.range_middle,
701
- "data-range-start": n.range_start,
702
- "data-range-end": n.range_end,
703
- "data-range-middle": n.range_middle,
704
- className: b(
705
- "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",
706
- s.day,
707
- e
708
- ),
709
- ...a
710
- }
711
- );
712
- }
713
- const kt = ({ node: e, value: r, setValue: n, error: a }) => {
714
- const s = I(), l = e.data.name || e.id, [i, o] = E(!1), d = r ? new Date(r) : void 0;
715
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
716
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
717
- s(e.data.label) || e.data.name,
718
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
719
- ] }),
720
- /* @__PURE__ */ t.jsxs(Y, { open: i, onOpenChange: o, children: [
721
- /* @__PURE__ */ t.jsx(Z, { asChild: !0, children: /* @__PURE__ */ t.jsxs(H, { variant: "outline", id: l, className: "w-full justify-between font-normal", children: [
722
- d ? d.toLocaleDateString() : s(e.data.placeholder) || s("renderer.defaultInputs.selectDate"),
723
- /* @__PURE__ */ t.jsx(je, { className: "size-4" })
724
- ] }) }),
725
- /* @__PURE__ */ t.jsx(ee, { className: "w-auto overflow-hidden p-0", align: "start", children: /* @__PURE__ */ t.jsx(
726
- Le,
727
- {
728
- mode: "single",
729
- selected: d,
730
- captionLayout: "dropdown",
731
- onSelect: (m) => {
732
- n(m ? m.toISOString() : ""), o(!1);
733
- }
734
- }
735
- ) })
736
- ] }),
737
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
738
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
739
- ] });
740
- }, At = ({ node: e, value: r, setValue: n, error: a }) => {
741
- const s = I(), [l, i] = E(!1), o = Array.isArray(r) ? r : [], d = o[0] ? new Date(o[0]) : void 0, m = o[1] ? new Date(o[1]) : void 0, c = (p) => {
742
- n([p?.from ? p.from.toISOString() : void 0, p?.to ? p.to.toISOString() : void 0]);
743
- }, f = () => d && m ? `${d.toLocaleDateString()} - ${m.toLocaleDateString()}` : d ? d.toLocaleDateString() : s("renderer.defaultInputs.selectDateRange");
744
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
745
- /* @__PURE__ */ t.jsxs(F, { children: [
746
- s(e.data.label) || e.data.name,
747
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
748
- ] }),
749
- /* @__PURE__ */ t.jsxs(Y, { open: l, onOpenChange: i, children: [
750
- /* @__PURE__ */ t.jsx(Z, { asChild: !0, children: /* @__PURE__ */ t.jsxs(H, { variant: "outline", className: "w-full justify-between font-normal", children: [
751
- f(),
752
- /* @__PURE__ */ t.jsx(je, { className: "size-4" })
753
- ] }) }),
754
- /* @__PURE__ */ t.jsx(ee, { className: "w-auto overflow-hidden p-0", align: "start", children: /* @__PURE__ */ t.jsx(
755
- Le,
756
- {
757
- mode: "range",
758
- selected: { from: d, to: m },
759
- captionLayout: "dropdown",
760
- onSelect: c,
761
- numberOfMonths: 2
762
- }
763
- ) })
764
- ] }),
765
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
766
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
767
- ] });
768
- }, Ge = (e) => new Promise((r, n) => {
769
- const a = new FileReader();
770
- a.onload = () => {
771
- const s = a.result;
772
- r({
773
- data: s,
774
- lastModified: e.lastModified,
775
- name: e.name,
776
- size: e.size,
777
- type: e.type
778
- });
779
- }, a.onerror = () => {
780
- n(new Error(`Failed to read file: ${e.name}`));
781
- }, a.readAsDataURL(e);
782
- }), ia = (e) => {
783
- const r = e.data.split(",")[1], n = atob(r), a = new ArrayBuffer(n.length), s = new Uint8Array(a);
784
- for (let i = 0; i < n.length; i++)
785
- s[i] = n.charCodeAt(i);
786
- const l = new Blob([a], { type: e.type });
787
- return new File([l], e.name, {
788
- lastModified: e.lastModified,
789
- type: e.type
790
- });
791
- }, Rt = (e) => Promise.all(e.map((r) => Ge(r))), Et = ({ node: e, setValue: r, error: n }) => {
792
- const a = I(), s = e.data.name || e.id, l = async (i) => {
793
- const { files: o } = i.target;
794
- if (!o || o.length === 0) {
795
- r(null);
796
- return;
797
- }
798
- if (e.data.multiple) {
799
- const m = await Rt(Array.from(o));
800
- r(m);
801
- return;
802
- }
803
- const d = await Ge(o[0]);
804
- r(d);
805
- };
806
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
807
- /* @__PURE__ */ t.jsxs(F, { htmlFor: s, children: [
808
- a(e.data.label) || e.data.name,
809
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
810
- ] }),
811
- /* @__PURE__ */ t.jsx(
812
- z,
813
- {
814
- type: "file",
815
- id: s,
816
- name: s,
817
- onChange: l,
818
- multiple: e.data.multiple,
819
- placeholder: a(e.data.placeholder)
820
- }
821
- ),
822
- n && /* @__PURE__ */ t.jsx(k, { children: n }),
823
- e.data.helperText && !n && /* @__PURE__ */ t.jsx(A, { children: a(e.data.helperText) })
824
- ] });
825
- }, _t = ({ node: e, value: r }) => {
826
- const n = e.data.name || e.id;
827
- return /* @__PURE__ */ t.jsx(z, { type: "hidden", name: n, value: r ?? "" });
828
- }, ce = (e, r) => r ? r.split(".").reduce((a, s) => {
829
- if (a == null)
830
- return;
831
- const l = s.match(/^(\w+)\[(\d+)]$/);
832
- if (l) {
833
- const [, i, o] = l, d = a[i];
834
- return Array.isArray(d) ? d[Number.parseInt(o, 10)] : d;
835
- }
836
- return a[s];
837
- }, e) : e, ue = (e, r) => e.replace(/{{(\w+)}}/g, (n, a) => String(r[a] || "")), Pt = ({ node: e, value: r, setValue: n, error: a }) => {
838
- const [s, l] = E(!1), [i, o] = E(null), [d, m] = E([]), [c, f] = E(""), [p, x] = E(!1), { formValues: v } = te(), h = I(), { httpConfig: u } = e.data, S = e.data.name || e.id, N = me(!1), y = V(
839
- async (j) => {
840
- if (!u?.url) {
841
- o(h("renderer.defaultHttpInput.noUrlConfigured"));
842
- return;
843
- }
844
- l(!0), o(null);
845
- try {
846
- const g = ue(u.url, v), w = u.searchParam && j ? `${g}${g.includes("?") ? "&" : "?"}${u.searchParam}=${encodeURIComponent(j)}` : g, T = {};
847
- u.headers?.forEach((M) => {
848
- T[M.key] = ue(M.value, v);
849
- });
850
- const _ = u.body && ["POST", "PUT", "PATCH"].includes(u.method || "") ? ue(u.body, v) : void 0, R = await fetch(w, {
851
- body: _ || void 0,
852
- headers: {
853
- "Content-Type": "application/json",
854
- ...T
855
- },
856
- method: u.method || "GET"
857
- });
858
- if (!R.ok) {
859
- o(`HTTP ${R.status}: ${R.statusText}`), l(!1);
860
- return;
861
- }
862
- const U = await R.json(), $ = u.responsePath ? ce(U, u.responsePath) : U;
863
- if (u.responseMapping && Array.isArray($)) {
864
- const { valueField: M = "value", labelField: ae = "label" } = u.responseMapping, K = $.map((C) => ({
865
- label: String(ce(C, ae) || ""),
866
- value: String(ce(C, M) || "")
867
- }));
868
- m(K);
869
- } else
870
- n(typeof $ == "string" ? $ : JSON.stringify($));
871
- } catch (g) {
872
- const w = g instanceof Error ? g.message : h("renderer.defaultHttpInput.fetchFailed");
873
- o(w), console.error("HTTP Input fetch error:", g);
874
- } finally {
875
- l(!1);
876
- }
877
- },
878
- [u, v, n, h]
879
- );
880
- if (B(() => {
881
- u?.fetchOnMount && !N.current && (N.current = !0, y());
882
- }, [u?.fetchOnMount, y]), B(() => {
883
- if (!(u?.searchParam && c))
884
- return;
885
- const j = setTimeout(() => {
886
- y(c);
887
- }, 300);
888
- return () => clearTimeout(j);
889
- }, [c, u?.searchParam, y]), u?.responseMapping) {
890
- const j = Array.isArray(r) ? r[0] : r, g = d.find((T) => T.value === j);
891
- if (u.searchParam) {
892
- const _ = s && u?.showLoading ? /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
893
- /* @__PURE__ */ t.jsx(ie, { className: "h-4 w-4 animate-spin" }),
894
- /* @__PURE__ */ t.jsx("span", { className: "text-muted-foreground", children: g?.label || h(e.data.placeholder) || "Search..." })
895
- ] }) : g?.label || h(e.data.placeholder) || "Search...";
896
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
897
- /* @__PURE__ */ t.jsxs(F, { children: [
898
- h(e.data.label) || e.data.name,
899
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
900
- ] }),
901
- /* @__PURE__ */ t.jsxs(Y, { open: p, onOpenChange: x, children: [
902
- /* @__PURE__ */ t.jsx(Z, { asChild: !0, children: /* @__PURE__ */ t.jsxs(H, { variant: "outline", role: "combobox", "aria-expanded": p, className: "w-full justify-between", children: [
903
- _,
904
- /* @__PURE__ */ t.jsx(Pe, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
905
- ] }) }),
906
- /* @__PURE__ */ t.jsx(ee, { className: "w-[300px] p-0", align: "start", children: /* @__PURE__ */ t.jsxs(pe, { shouldFilter: !1, children: [
907
- /* @__PURE__ */ t.jsx(
908
- Se,
909
- {
910
- placeholder: "Search...",
911
- value: c,
912
- onValueChange: (R) => {
913
- f(R), o(null);
914
- }
915
- }
916
- ),
917
- /* @__PURE__ */ t.jsxs(fe, { children: [
918
- s && /* @__PURE__ */ t.jsx("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ t.jsx(ie, { className: "h-4 w-4 animate-spin" }) }),
919
- !s && i && /* @__PURE__ */ t.jsxs("div", { className: "p-4 text-destructive text-sm", children: [
920
- /* @__PURE__ */ t.jsx("div", { children: i }),
921
- /* @__PURE__ */ t.jsx("button", { type: "button", onClick: () => y(c), className: "mt-2 block text-primary hover:underline", children: "Retry" })
922
- ] }),
923
- !(s || i) && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
924
- /* @__PURE__ */ t.jsx(xe, { children: "No results found." }),
925
- /* @__PURE__ */ t.jsx(ge, { children: d.map((R) => /* @__PURE__ */ t.jsxs(
926
- be,
927
- {
928
- value: R.value,
929
- onSelect: () => {
930
- n(R.value), x(!1);
931
- },
932
- children: [
933
- /* @__PURE__ */ t.jsx(Oe, { className: b("mr-2 h-4 w-4", r === R.value ? "opacity-100" : "opacity-0") }),
934
- R.label
935
- ]
936
- },
937
- R.value
938
- )) })
939
- ] })
940
- ] })
941
- ] }) })
942
- ] }),
943
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
944
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: h(e.data.helperText) })
945
- ] });
946
- }
947
- const w = s && u?.showLoading;
948
- return d.length === 0 && !w ? /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
949
- /* @__PURE__ */ t.jsxs(F, { htmlFor: S, children: [
950
- h(e.data.label) || e.data.name,
951
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
952
- ] }),
953
- /* @__PURE__ */ t.jsx("div", { className: "py-2 text-muted-foreground text-sm", children: 'No data available. Configure "Fetch on mount" or add a search parameter.' }),
954
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
955
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: h(e.data.helperText) })
956
- ] }) : /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
957
- /* @__PURE__ */ t.jsxs(F, { htmlFor: S, children: [
958
- h(e.data.label) || e.data.name,
959
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
960
- ] }),
961
- /* @__PURE__ */ t.jsxs(Ce, { value: Array.isArray(r) ? r[0] ?? "" : r ?? "", onValueChange: (T) => n(T), disabled: w, children: [
962
- /* @__PURE__ */ t.jsxs(Ie, { id: S, className: "w-full", children: [
963
- w && /* @__PURE__ */ t.jsx(ie, { className: "mr-2 h-4 w-4 animate-spin" }),
964
- /* @__PURE__ */ t.jsx(De, { placeholder: h(e.data.placeholder) || h("renderer.defaultHttpInput.selectOption") })
965
- ] }),
966
- /* @__PURE__ */ t.jsx(ke, { children: /* @__PURE__ */ t.jsx(Ae, { children: d.map((T, _) => /* @__PURE__ */ t.jsx(Re, { value: T.value, children: T.label }, T.value + _)) }) })
967
- ] }),
968
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
969
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: h(e.data.helperText) })
970
- ] });
971
- }
972
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
973
- /* @__PURE__ */ t.jsxs(F, { htmlFor: S, children: [
974
- h(e.data.label) || e.data.name,
975
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
976
- ] }),
977
- /* @__PURE__ */ t.jsx(z, { type: "text", id: S, name: S, value: typeof r == "string" ? r : JSON.stringify(r), readOnly: !0, disabled: !0 }),
978
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
979
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: h(e.data.helperText) })
980
- ] });
981
- }, Ot = ({ node: e, value: r, setValue: n, error: a }) => {
982
- const s = I(), l = e.data.name || e.id;
983
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
984
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
985
- s(e.data.label) || e.data.name,
986
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
987
- ] }),
988
- /* @__PURE__ */ t.jsx(
989
- z,
990
- {
991
- type: "number",
992
- id: l,
993
- name: l,
994
- value: r ?? "",
995
- onChange: (i) => n(i.target.value === "" ? null : Number(i.target.value)),
996
- placeholder: s(e.data.placeholder)
997
- }
998
- ),
999
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
1000
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1001
- ] });
1002
- }, zt = ({ node: e, value: r, setValue: n, error: a }) => {
1003
- const s = I(), l = e.data.name || e.id;
1004
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1005
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
1006
- s(e.data.label) || e.data.name,
1007
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1008
- ] }),
1009
- /* @__PURE__ */ t.jsx(
1010
- z,
1011
- {
1012
- type: "password",
1013
- id: l,
1014
- name: l,
1015
- value: r ?? "",
1016
- onChange: (i) => n(i.target.value),
1017
- placeholder: s(e.data.placeholder),
1018
- autoComplete: "new-password"
1019
- }
1020
- ),
1021
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
1022
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1023
- ] });
1024
- };
1025
- function $t({ className: e, ...r }) {
1026
- return /* @__PURE__ */ t.jsx(he.Root, { "data-slot": "radio-group", className: b("grid gap-3", e), ...r });
1027
- }
1028
- function Mt({ className: e, ...r }) {
1029
- return /* @__PURE__ */ t.jsx(
1030
- he.Item,
1031
- {
1032
- "data-slot": "radio-group-item",
1033
- className: b(
1034
- "border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
1035
- e
1036
- ),
1037
- ...r,
1038
- children: /* @__PURE__ */ t.jsx(he.Indicator, { "data-slot": "radio-group-indicator", className: "relative flex items-center justify-center", children: /* @__PURE__ */ t.jsx(rt, { className: "fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2" }) })
1039
- }
1040
- );
1041
- }
1042
- const qt = ({ node: e, value: r, setValue: n, error: a }) => {
1043
- const s = I(), l = e.data.name || e.id, i = r ? String(r) : "";
1044
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1045
- /* @__PURE__ */ t.jsxs(F, { className: "mb-1", children: [
1046
- s(e.data.label) || e.data.name,
1047
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1048
- ] }),
1049
- /* @__PURE__ */ t.jsx($t, { value: i, onValueChange: (o) => n(o), children: e.data.options?.map((o, d) => /* @__PURE__ */ t.jsxs("div", { className: "flex items-center space-x-2", children: [
1050
- /* @__PURE__ */ t.jsx(Mt, { value: String(o.value), id: `${l}-${o.value}`, disabled: o.disabled }),
1051
- /* @__PURE__ */ t.jsx(F, { htmlFor: `${l}-${o.value}`, className: "cursor-pointer font-normal text-sm", children: s(o.label) ? s(o.label) : o.value })
1052
- ] }, o.value + d)) }),
1053
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
1054
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1055
- ] });
1056
- }, Bt = ({ node: e, value: r, setValue: n, error: a }) => {
1057
- const s = I(), l = e.data.name || e.id, i = r ? String(r) : "";
1058
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1059
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
1060
- s(e.data.label) || e.data.name,
1061
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1062
- ] }),
1063
- /* @__PURE__ */ t.jsxs(Ce, { value: i, onValueChange: (o) => n(o), children: [
1064
- /* @__PURE__ */ t.jsx(Ie, { id: l, className: "w-full", children: /* @__PURE__ */ t.jsx(De, { placeholder: s(e.data.placeholder) || s("renderer.defaultSelectInput.selectOption") }) }),
1065
- /* @__PURE__ */ t.jsx(ke, { children: /* @__PURE__ */ t.jsx(Ae, { children: e.data.options?.map((o, d) => /* @__PURE__ */ t.jsx(Re, { value: String(o.value), disabled: o.disabled, children: s(o.label) ? s(o.label) : o.value }, `${o.value}-${d}`)) }) })
1066
- ] }),
1067
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
1068
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1069
- ] });
1070
- }, Vt = ({ node: e, value: r, setValue: n, error: a }) => {
1071
- const s = I(), l = e.data.name || e.id;
1072
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1073
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
1074
- s(e.data.label) || e.data.name,
1075
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1076
- ] }),
1077
- /* @__PURE__ */ t.jsx(Xe, { id: l, checked: r, onCheckedChange: n }),
1078
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) }),
1079
- a && /* @__PURE__ */ t.jsx(k, { children: a })
1080
- ] });
1081
- }, Lt = ({ node: e, value: r, setValue: n, error: a }) => {
1082
- const s = I(), l = e.data.name || e.id;
1083
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1084
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
1085
- s(e.data.label) || e.data.name,
1086
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1087
- ] }),
1088
- /* @__PURE__ */ t.jsx(
1089
- Ye,
1090
- {
1091
- id: l,
1092
- name: l,
1093
- value: r ?? "",
1094
- onChange: (i) => n(i.target.value),
1095
- placeholder: s(e.data.placeholder),
1096
- className: "w-full rounded-md border px-3 py-2",
1097
- rows: 4
1098
- }
1099
- ),
1100
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
1101
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1102
- ] });
1103
- }, Gt = ({ node: e, value: r, setValue: n, error: a }) => {
1104
- const s = I(), l = e.data.name || e.id;
1105
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1106
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
1107
- s(e.data.label) || e.data.name,
1108
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1109
- ] }),
1110
- /* @__PURE__ */ t.jsx(
1111
- z,
1112
- {
1113
- type: "text",
1114
- id: l,
1115
- name: l,
1116
- value: r ?? "",
1117
- onChange: (i) => n(i.target.value),
1118
- placeholder: s(e.data.placeholder)
1119
- }
1120
- ),
1121
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
1122
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1123
- ] });
1124
- }, Ut = ({ node: e, value: r, setValue: n, error: a }) => {
1125
- const s = I(), l = e.data.name || e.id;
1126
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1127
- /* @__PURE__ */ t.jsxs(F, { htmlFor: l, children: [
1128
- s(e.data.label) || e.data.name,
1129
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1130
- ] }),
1131
- /* @__PURE__ */ t.jsx(
1132
- z,
1133
- {
1134
- type: "time",
1135
- id: l,
1136
- name: l,
1137
- value: r ?? "",
1138
- onChange: (i) => n(i.target.value),
1139
- placeholder: s(e.data.placeholder),
1140
- className: "bg-background [color-scheme:light] dark:[color-scheme:dark]"
1141
- }
1142
- ),
1143
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
1144
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1145
- ] });
1146
- }, Wt = ({ node: e, value: r, setValue: n, error: a }) => {
1147
- const s = I(), l = Array.isArray(r) ? r : [], i = l[0] || "", o = l[1] || "", d = (c) => {
1148
- n([c, o]);
1149
- }, m = (c) => {
1150
- n([i, c]);
1151
- };
1152
- return /* @__PURE__ */ t.jsxs(D, { className: "mb-4", children: [
1153
- /* @__PURE__ */ t.jsxs(F, { children: [
1154
- s(e.data.label) || e.data.name,
1155
- e.data.required && /* @__PURE__ */ t.jsx("span", { className: "text-red-500", children: "*" })
1156
- ] }),
1157
- /* @__PURE__ */ t.jsxs("div", { className: "flex gap-2", children: [
1158
- /* @__PURE__ */ t.jsx(
1159
- z,
1160
- {
1161
- "aria-label": `${s(e.data.label) || e.data.name} - ${s("renderer.defaultInputs.startTime")}`,
1162
- "aria-invalid": !!a,
1163
- "aria-describedby": a ? `${e.id}-error` : void 0,
1164
- type: "time",
1165
- value: i,
1166
- onChange: (c) => d(c.target.value),
1167
- placeholder: s("renderer.defaultInputs.startTime"),
1168
- className: "flex-1 bg-background [color-scheme:light] dark:[color-scheme:dark]"
1169
- }
1170
- ),
1171
- /* @__PURE__ */ t.jsx(
1172
- z,
1173
- {
1174
- "aria-label": `${s(e.data.label) || e.data.name} - ${s("renderer.defaultInputs.endTime")}`,
1175
- "aria-invalid": !!a,
1176
- "aria-describedby": a ? `${e.id}-error` : void 0,
1177
- type: "time",
1178
- value: o,
1179
- onChange: (c) => m(c.target.value),
1180
- placeholder: s("renderer.defaultInputs.endTime"),
1181
- className: "flex-1 bg-background [color-scheme:light] dark:[color-scheme:dark]"
1182
- }
1183
- )
1184
- ] }),
1185
- a && /* @__PURE__ */ t.jsx(k, { children: a }),
1186
- e.data.helperText && !a && /* @__PURE__ */ t.jsx(A, { children: s(e.data.helperText) })
1187
- ] });
1188
- }, Ht = {
1189
- address: St,
1190
- autocomplete: Ct,
1191
- checkbox: It,
1192
- date: kt,
1193
- daterange: At,
1194
- file: Et,
1195
- hidden: _t,
1196
- http: Pt,
1197
- number: Ot,
1198
- password: zt,
1199
- radio: qt,
1200
- select: Bt,
1201
- switch: Vt,
1202
- text: Gt,
1203
- textarea: Lt,
1204
- time: Ut,
1205
- timerange: Wt
1206
- }, Kt = ({ label: e = "Submit", ...r }) => /* @__PURE__ */ t.jsx(
1207
- "button",
1208
- {
1209
- type: "submit",
1210
- 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",
1211
- ...r,
1212
- children: e
1213
- }
1214
- ), Jt = ({ node: e }) => {
1215
- const n = I()(e.data?.label);
1216
- return n ? /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-x-3", children: [
1217
- /* @__PURE__ */ t.jsx(le, { className: "my-8 flex-1" }),
1218
- /* @__PURE__ */ t.jsx("h4", { className: "font-semibold text-sm", children: n }),
1219
- /* @__PURE__ */ t.jsx(le, { className: "my-8 flex-1" })
1220
- ] }) : /* @__PURE__ */ t.jsx(le, { className: "my-8" });
1221
- }, Qt = ({ node: e }) => {
1222
- const { edges: r } = te(), n = I(), a = Me(e.id, r);
1223
- return /* @__PURE__ */ t.jsx("h2", { className: b("mb-5 font-bold text-2xl", !a && "mt-10"), children: n(e.data?.label) });
1224
- }, Xt = {
1225
- divider: Jt,
1226
- title: Qt
1227
- };
1228
- function Ue({ delayDuration: e = 0, ...r }) {
1229
- return /* @__PURE__ */ t.jsx(G.Provider, { "data-slot": "tooltip-provider", delayDuration: e, ...r });
1230
- }
1231
- function Yt({ ...e }) {
1232
- return /* @__PURE__ */ t.jsx(Ue, { children: /* @__PURE__ */ t.jsx(G.Root, { "data-slot": "tooltip", ...e }) });
1233
- }
1234
- function Zt({ ...e }) {
1235
- return /* @__PURE__ */ t.jsx(G.Trigger, { "data-slot": "tooltip-trigger", ...e });
1236
- }
1237
- function ea({ className: e, sideOffset: r = 0, children: n, ...a }) {
1238
- return /* @__PURE__ */ t.jsx(G.Portal, { children: /* @__PURE__ */ t.jsxs(
1239
- G.Content,
1240
- {
1241
- "data-slot": "tooltip-content",
1242
- sideOffset: r,
1243
- className: b(
1244
- "bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out 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) rounded-md px-3 py-1.5 text-xs text-balance",
1245
- e
1246
- ),
1247
- ...a,
1248
- children: [
1249
- n,
1250
- /* @__PURE__ */ t.jsx(G.Arrow, { className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
1251
- ]
1252
- }
1253
- ) });
1254
- }
1255
- const ta = ({ children: e, missingFields: r = [] }) => {
1256
- const n = r.length > 0, a = I();
1257
- return n ? /* @__PURE__ */ t.jsx(Ue, { children: /* @__PURE__ */ t.jsxs(Yt, { children: [
1258
- /* @__PURE__ */ t.jsx(Zt, { asChild: !0, children: e }),
1259
- /* @__PURE__ */ t.jsx(ea, { children: /* @__PURE__ */ t.jsxs("div", { className: "space-y-1", children: [
1260
- /* @__PURE__ */ t.jsxs("p", { className: "font-semibold", children: [
1261
- a("renderer.defaultSubmitButton.requiredFieldsMissing"),
1262
- ":"
1263
- ] }),
1264
- /* @__PURE__ */ t.jsx("ul", { className: "list-inside list-disc", children: r.map((s, l) => /* @__PURE__ */ t.jsx("li", { children: s }, l)) })
1265
- ] }) })
1266
- ] }) }) : e;
1267
- }, oa = ({
1268
- components: e,
1269
- flows: r,
1270
- googleApiKey: n,
1271
- initialValues: a = {},
1272
- language: s,
1273
- onChange: l,
1274
- onSubmit: i,
1275
- theme: o,
1276
- validate: d,
1277
- validationMode: m
1278
- }) => {
1279
- const c = lt(), f = {
1280
- components: {
1281
- form: e?.form ?? c?.components?.form,
1282
- group: e?.group ?? c?.components?.group,
1283
- inputs: { ...c?.components?.inputs, ...e?.inputs },
1284
- submitButton: e?.submitButton ?? c?.components?.submitButton,
1285
- submitButtonWrapper: e?.submitButtonWrapper ?? c?.components?.submitButtonWrapper,
1286
- ui: { ...c?.components?.ui, ...e?.ui }
1287
- },
1288
- googleApiKey: n ?? c?.googleApiKey,
1289
- language: s ?? c?.language ?? "en",
1290
- theme: o ?? c?.theme ?? "dark",
1291
- validationMode: m ?? c?.validationMode ?? "onSubmit"
1292
- }, {
1293
- canSubmit: p,
1294
- mergedFlow: x,
1295
- formErrors: v,
1296
- formValues: h,
1297
- inputNodes: u,
1298
- missingRequiredFields: S,
1299
- visibleNodes: N,
1300
- visibleRootNodes: y,
1301
- setFieldValue: j,
1302
- validateForm: g,
1303
- t: w
1304
- } = vt(r, a, f.language), T = f.components.form || yt, _ = f.components.submitButton || Kt, R = f.components.submitButtonWrapper || ta, U = me(l), $ = me(d), M = L(() => ct(h, u), [h, u]), ae = V(
1305
- (C) => {
1306
- C.preventDefault();
1307
- const { isValid: J, errors: W } = g($.current);
1308
- if (J && i) {
1309
- i(M);
1310
- return;
1311
- }
1312
- const P = Object.keys(W)[0];
1313
- if (P) {
1314
- const O = Nt(P, u);
1315
- O && document.querySelector(`[name="${O}"]`)?.focus();
1316
- }
1317
- },
1318
- [g, i, M, u]
1319
- ), K = V(
1320
- (C) => {
1321
- const { type: J } = C;
1322
- switch (J) {
1323
- case X.input: {
1324
- if (!q(C))
1325
- return null;
1326
- const P = C.data.type || "text", O = f.components.inputs?.[P], Q = Ht[P], se = O || Q, re = C.id, We = h[re], He = v[re], Ke = (Je) => j(re, Je);
1327
- return /* @__PURE__ */ t.jsx(se, { node: C, value: We, setValue: Ke, error: He }, C.id);
1328
- }
1329
- case X.group: {
1330
- if (!et(C))
1331
- return null;
1332
- const W = f.components.group || wt, P = N.filter((O) => O.parentId === C.id);
1333
- return /* @__PURE__ */ t.jsx(W, { node: C, children: P.map((O) => K(O)) }, C.id);
1334
- }
1335
- case X.ui: {
1336
- if (!Ze(C))
1337
- return null;
1338
- const P = C.data.type || "title", O = f.components.ui?.[P], Q = Xt[P], se = O || Q;
1339
- return /* @__PURE__ */ t.jsx(se, { node: C }, C.id);
1340
- }
1341
- case X.flow:
1342
- return null;
1343
- default:
1344
- return console.warn("Unknown node type:", J), null;
1345
- }
1346
- },
1347
- [f.components, N, h, v, j]
1348
- );
1349
- return B(() => {
1350
- U.current = l;
1351
- }, [l]), B(() => {
1352
- $.current = d;
1353
- }, [d]), B(() => {
1354
- U.current?.(M);
1355
- }, [M]), B(() => {
1356
- f.validationMode === "onChange" && g($.current);
1357
- }, [f.validationMode, g]), /* @__PURE__ */ t.jsx(tt, { theme: f.theme, storageKey: "treege-renderer-theme", children: /* @__PURE__ */ t.jsx(
1358
- bt,
1359
- {
1360
- value: {
1361
- flows: x,
1362
- formErrors: v,
1363
- formValues: h,
1364
- googleApiKey: f.googleApiKey,
1365
- language: f.language,
1366
- setFieldValue: j
1367
- },
1368
- children: /* @__PURE__ */ t.jsxs(T, { onSubmit: ae, children: [
1369
- y.map((C) => K(C)),
1370
- p && /* @__PURE__ */ t.jsx(R, { missingFields: S, children: /* @__PURE__ */ t.jsx(_, { label: w("renderer.defaultSubmitButton.submit") }) })
1371
- ] })
1372
- }
1373
- ) });
1374
- };
1375
- export {
1376
- Ge as A,
1377
- ia as B,
1378
- Rt as C,
1379
- wt as D,
1380
- Me as E,
1381
- ht as F,
1382
- ft as G,
1383
- Be as H,
1384
- de as I,
1385
- dt as J,
1386
- ct as K,
1387
- la as T,
1388
- vt as a,
1389
- oa as b,
1390
- St as c,
1391
- Ct as d,
1392
- It as e,
1393
- kt as f,
1394
- At as g,
1395
- Et as h,
1396
- _t as i,
1397
- Pt as j,
1398
- Ot as k,
1399
- zt as l,
1400
- qt as m,
1401
- Bt as n,
1402
- Vt as o,
1403
- Lt as p,
1404
- Gt as q,
1405
- Ut as r,
1406
- Wt as s,
1407
- Ht as t,
1408
- lt as u,
1409
- Jt as v,
1410
- Qt as w,
1411
- Xt as x,
1412
- oe as y,
1413
- ot as z
1414
- };