@awesome-flow/noise 0.7.0 → 0.7.1

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 (53) hide show
  1. package/dist/abstract/index.cjs +1 -3490
  2. package/dist/abstract/index.d.cts +2 -2
  3. package/dist/abstract/index.d.ts +2 -2
  4. package/dist/abstract/index.js +1 -3522
  5. package/dist/modules/index.cjs +1 -44
  6. package/dist/modules/index.js +1 -18
  7. package/dist/nodes/generators/index.cjs +1 -346
  8. package/dist/nodes/generators/index.d.cts +7 -7
  9. package/dist/nodes/generators/index.d.ts +7 -7
  10. package/dist/nodes/generators/index.js +1 -311
  11. package/dist/nodes/groups/index.cjs +1 -113
  12. package/dist/nodes/groups/index.d.cts +2 -2
  13. package/dist/nodes/groups/index.d.ts +2 -2
  14. package/dist/nodes/groups/index.js +1 -92
  15. package/dist/nodes/index.cjs +1 -3425
  16. package/dist/nodes/index.js +1 -3435
  17. package/dist/nodes/modifiers/index.cjs +1 -1478
  18. package/dist/nodes/modifiers/index.d.cts +6 -6
  19. package/dist/nodes/modifiers/index.d.ts +6 -6
  20. package/dist/nodes/modifiers/index.js +1 -1491
  21. package/dist/nodes/output/index.cjs +1 -1344
  22. package/dist/nodes/output/index.d.cts +3 -3
  23. package/dist/nodes/output/index.d.ts +3 -3
  24. package/dist/nodes/output/index.js +1 -1368
  25. package/dist/nodes/selectors/index.cjs +1 -1322
  26. package/dist/nodes/selectors/index.d.cts +1 -1
  27. package/dist/nodes/selectors/index.d.ts +1 -1
  28. package/dist/nodes/selectors/index.js +1 -1348
  29. package/dist/nodes/transformers/index.cjs +1 -337
  30. package/dist/nodes/transformers/index.d.cts +5 -5
  31. package/dist/nodes/transformers/index.d.ts +5 -5
  32. package/dist/nodes/transformers/index.js +1 -319
  33. package/dist/templates/generators/index.cjs +1 -1221
  34. package/dist/templates/generators/index.d.cts +5 -5
  35. package/dist/templates/generators/index.d.ts +5 -5
  36. package/dist/templates/generators/index.js +1 -1239
  37. package/dist/templates/groups/index.cjs +1 -1203
  38. package/dist/templates/groups/index.js +1 -1230
  39. package/dist/templates/index.cjs +1 -1263
  40. package/dist/templates/index.js +1 -1260
  41. package/dist/templates/modifiers/index.cjs +1 -1219
  42. package/dist/templates/modifiers/index.d.cts +9 -9
  43. package/dist/templates/modifiers/index.d.ts +9 -9
  44. package/dist/templates/modifiers/index.js +1 -1238
  45. package/dist/templates/output/index.cjs +1 -1209
  46. package/dist/templates/output/index.d.cts +3 -3
  47. package/dist/templates/output/index.d.ts +3 -3
  48. package/dist/templates/output/index.js +1 -1233
  49. package/dist/templates/selectors/index.cjs +1 -1205
  50. package/dist/templates/selectors/index.js +1 -1231
  51. package/dist/templates/transformers/index.cjs +1 -1211
  52. package/dist/templates/transformers/index.js +1 -1234
  53. package/package.json +9 -7
@@ -1,1478 +1 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
- var __export = (target, all) => {
11
- for (var name in all)
12
- __defProp(target, name, { get: all[name], enumerable: true });
13
- };
14
- var __copyProps = (to, from, except, desc) => {
15
- if (from && typeof from === "object" || typeof from === "function") {
16
- for (let key of __getOwnPropNames(from))
17
- if (!__hasOwnProp.call(to, key) && key !== except)
18
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
- }
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
- mod
29
- ));
30
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
-
32
- // ../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js
33
- var require_fast_deep_equal = __commonJS({
34
- "../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js"(exports2, module2) {
35
- "use strict";
36
- module2.exports = function equal(a, b) {
37
- if (a === b) return true;
38
- if (a && b && typeof a == "object" && typeof b == "object") {
39
- if (a.constructor !== b.constructor) return false;
40
- var length, i, keys;
41
- if (Array.isArray(a)) {
42
- length = a.length;
43
- if (length != b.length) return false;
44
- for (i = length; i-- !== 0; )
45
- if (!equal(a[i], b[i])) return false;
46
- return true;
47
- }
48
- if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
49
- if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
50
- if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
51
- keys = Object.keys(a);
52
- length = keys.length;
53
- if (length !== Object.keys(b).length) return false;
54
- for (i = length; i-- !== 0; )
55
- if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
56
- for (i = length; i-- !== 0; ) {
57
- var key = keys[i];
58
- if (!equal(a[key], b[key])) return false;
59
- }
60
- return true;
61
- }
62
- return a !== a && b !== b;
63
- };
64
- }
65
- });
66
-
67
- // src/nodes/modifiers/index.ts
68
- var modifiers_exports = {};
69
- __export(modifiers_exports, {
70
- NoiseAbsNode: () => noise_abs_node_default,
71
- NoiseClampNode: () => noise_clamp_node_default,
72
- NoiseCombineNode: () => noise_combine_node_default,
73
- NoiseCurveNode: () => noise_curve_node_default,
74
- NoiseExponentNode: () => noise_exponent_node_default,
75
- NoiseInvertNode: () => noise_invert_node_default,
76
- NoiseNormalizeNode: () => noise_normalize_node_default,
77
- NoiseScaleBiasNode: () => noise_scale_bias_node_default,
78
- NoiseTerraceNode: () => noise_terrace_node_default
79
- });
80
- module.exports = __toCommonJS(modifiers_exports);
81
-
82
- // src/nodes/modifiers/noise-abs-node.tsx
83
- var import_layout = require("@awesome-flow/core/layout");
84
- var import_react = require("react");
85
- var import_hooks = require("@awesome-flow/core/hooks");
86
- var import_libnoise_simplex_ts = require("libnoise-simplex-ts");
87
- var import_jsx_runtime = require("react/jsx-runtime");
88
- function NoiseAbsNode({ id, selected, data, type }) {
89
- const incoming = (0, import_hooks.useIncomingComputedData)(id);
90
- const updateComputedData = (0, import_hooks.useUpdateNodeComputedData)();
91
- (0, import_react.useEffect)(() => {
92
- if (incoming?.length > 0) {
93
- const module2 = new import_libnoise_simplex_ts.Abs(incoming[0].module);
94
- updateComputedData(id, { module: module2 });
95
- }
96
- }, [incoming]);
97
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_layout.NodeContainer, { id, selected, data, type, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_layout.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" }) });
98
- }
99
- var noise_abs_node_default = NoiseAbsNode;
100
-
101
- // src/nodes/modifiers/noise-clamp-node.tsx
102
- var import_layout2 = require("@awesome-flow/core/layout");
103
- var import_react2 = require("react");
104
- var import_core = require("@mantine/core");
105
- var import_hooks2 = require("@awesome-flow/core/hooks");
106
- var import_libnoise_simplex_ts2 = require("libnoise-simplex-ts");
107
- var import_jsx_runtime2 = require("react/jsx-runtime");
108
- function NoiseClampNode({ id, selected, data, type }) {
109
- const [lowerBound, setLowerBound] = (0, import_react2.useState)(data.lowerBound);
110
- const [upperBound, setUpperBound] = (0, import_react2.useState)(data.upperBound);
111
- const incoming = (0, import_hooks2.useIncomingComputedData)(id);
112
- const updateNodeData = (0, import_hooks2.useUpdateNodeData)();
113
- const updateComputedData = (0, import_hooks2.useUpdateNodeComputedData)();
114
- (0, import_react2.useEffect)(() => {
115
- if (incoming?.length) {
116
- const module2 = new import_libnoise_simplex_ts2.Clamp(incoming[0].module, lowerBound, upperBound);
117
- updateComputedData(id, { module: module2 });
118
- }
119
- updateNodeData(id, { lowerBound, upperBound });
120
- }, [incoming, lowerBound, upperBound]);
121
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_layout2.NodeContainer, { id, selected, data, type, children: [
122
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core.Stack, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core.Group, { children: [
123
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
124
- import_core.NumberInput,
125
- {
126
- size: "xs",
127
- w: 100,
128
- value: lowerBound,
129
- onChange: (e) => setLowerBound(Number(e)),
130
- step: 0.1
131
- }
132
- ),
133
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
134
- import_core.NumberInput,
135
- {
136
- size: "xs",
137
- w: 100,
138
- value: upperBound,
139
- onChange: (e) => setUpperBound(Number(e)),
140
- step: 0.1
141
- }
142
- )
143
- ] }) }),
144
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_layout2.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
145
- ] });
146
- }
147
- var noise_clamp_node_default = NoiseClampNode;
148
-
149
- // src/nodes/modifiers/noise-combine-node.tsx
150
- var import_layout3 = require("@awesome-flow/core/layout");
151
- var import_react3 = require("react");
152
- var import_hooks3 = require("@awesome-flow/core/hooks");
153
- var import_icons_react = require("@tabler/icons-react");
154
-
155
- // src/abstract/operations.ts
156
- var import_libnoise_simplex_ts3 = require("libnoise-simplex-ts");
157
- var noiseCombineModuleMap = {
158
- ["add" /* add */]: import_libnoise_simplex_ts3.Add,
159
- ["max" /* max */]: import_libnoise_simplex_ts3.Max,
160
- ["min" /* min */]: import_libnoise_simplex_ts3.Min,
161
- ["multiply" /* multiply */]: import_libnoise_simplex_ts3.Multiply,
162
- ["power" /* power */]: import_libnoise_simplex_ts3.Power
163
- };
164
-
165
- // src/nodes/modifiers/noise-combine-node.tsx
166
- var import_jsx_runtime3 = require("react/jsx-runtime");
167
- var options = {
168
- add: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_react.IconPlus, {}),
169
- min: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_react.IconChevronLeft, {}),
170
- max: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_react.IconChevronRight, {}),
171
- multiply: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_react.IconAsterisk, {}),
172
- power: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_react.IconChevronUp, {})
173
- };
174
- function NoiseCombineNode({ id, selected, data, type }) {
175
- const updateNodeData = (0, import_hooks3.useUpdateNodeData)();
176
- const updateComputedData = (0, import_hooks3.useUpdateNodeComputedData)();
177
- const incoming = (0, import_hooks3.useIncomingComputedData)(id);
178
- (0, import_react3.useEffect)(() => {
179
- const ModuleFactory = noiseCombineModuleMap[data.operation];
180
- if (incoming?.length > 1) {
181
- const module2 = new ModuleFactory(incoming[0].module, incoming[1].module);
182
- updateComputedData(id, { module: module2 });
183
- }
184
- }, [data.operation, incoming]);
185
- const onChange = (0, import_react3.useCallback)((operation) => {
186
- updateNodeData(id, { operation });
187
- }, []);
188
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_layout3.NodeContainer, { id, selected, data, type, children: [
189
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_layout3.NodeCombobox, { options, selected: data.operation, onChange, width: 150 }),
190
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_layout3.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
191
- ] });
192
- }
193
- var noise_combine_node_default = NoiseCombineNode;
194
-
195
- // src/nodes/modifiers/noise-curve-node.tsx
196
- var import_layout4 = require("@awesome-flow/core/layout");
197
- var import_core2 = require("@mantine/core");
198
- var import_hooks4 = require("@awesome-flow/core/hooks");
199
-
200
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/use-form.mjs
201
- var import_react10 = require("react");
202
-
203
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/actions/actions.mjs
204
- var import_react4 = require("react");
205
- function validateFormName(name) {
206
- if (!/^[0-9a-zA-Z-]+$/.test(name)) {
207
- throw new Error(
208
- `[@mantine/use-form] Form name "${name}" is invalid, it should contain only letters, numbers and dashes`
209
- );
210
- }
211
- }
212
- var useIsomorphicEffect = typeof window !== "undefined" ? import_react4.useLayoutEffect : import_react4.useEffect;
213
- function useFormEvent(eventKey, handler) {
214
- useIsomorphicEffect(() => {
215
- if (eventKey) {
216
- window.addEventListener(eventKey, handler);
217
- return () => window.removeEventListener(eventKey, handler);
218
- }
219
- return void 0;
220
- }, [eventKey]);
221
- }
222
- function useFormActions(name, form) {
223
- if (name) {
224
- validateFormName(name);
225
- }
226
- useFormEvent(
227
- `mantine-form:${name}:set-field-value`,
228
- (event) => form.setFieldValue(event.detail.path, event.detail.value)
229
- );
230
- useFormEvent(
231
- `mantine-form:${name}:set-values`,
232
- (event) => form.setValues(event.detail)
233
- );
234
- useFormEvent(
235
- `mantine-form:${name}:set-initial-values`,
236
- (event) => form.setInitialValues(event.detail)
237
- );
238
- useFormEvent(
239
- `mantine-form:${name}:set-errors`,
240
- (event) => form.setErrors(event.detail)
241
- );
242
- useFormEvent(
243
- `mantine-form:${name}:set-field-error`,
244
- (event) => form.setFieldError(event.detail.path, event.detail.error)
245
- );
246
- useFormEvent(
247
- `mantine-form:${name}:clear-field-error`,
248
- (event) => form.clearFieldError(event.detail)
249
- );
250
- useFormEvent(`mantine-form:${name}:clear-errors`, form.clearErrors);
251
- useFormEvent(`mantine-form:${name}:reset`, form.reset);
252
- useFormEvent(`mantine-form:${name}:validate`, form.validate);
253
- useFormEvent(
254
- `mantine-form:${name}:validate-field`,
255
- (event) => form.validateField(event.detail)
256
- );
257
- useFormEvent(
258
- `mantine-form:${name}:reorder-list-item`,
259
- (event) => form.reorderListItem(event.detail.path, event.detail.payload)
260
- );
261
- useFormEvent(
262
- `mantine-form:${name}:remove-list-item`,
263
- (event) => form.removeListItem(event.detail.path, event.detail.index)
264
- );
265
- useFormEvent(
266
- `mantine-form:${name}:insert-list-item`,
267
- (event) => form.insertListItem(event.detail.path, event.detail.item, event.detail.index)
268
- );
269
- useFormEvent(
270
- `mantine-form:${name}:set-dirty`,
271
- (event) => form.setDirty(event.detail)
272
- );
273
- useFormEvent(
274
- `mantine-form:${name}:set-touched`,
275
- (event) => form.setTouched(event.detail)
276
- );
277
- useFormEvent(
278
- `mantine-form:${name}:reset-dirty`,
279
- (event) => form.resetDirty(event.detail)
280
- );
281
- useFormEvent(`mantine-form:${name}:reset-touched`, form.resetTouched);
282
- }
283
-
284
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/get-input-on-change/get-input-on-change.mjs
285
- function getInputOnChange(setValue) {
286
- return (val) => {
287
- if (!val) {
288
- setValue(val);
289
- } else if (typeof val === "function") {
290
- setValue(val);
291
- } else if (typeof val === "object" && "nativeEvent" in val) {
292
- const { currentTarget } = val;
293
- if (currentTarget instanceof HTMLInputElement) {
294
- if (currentTarget.type === "checkbox") {
295
- setValue(currentTarget.checked);
296
- } else {
297
- setValue(currentTarget.value);
298
- }
299
- } else if (currentTarget instanceof HTMLTextAreaElement || currentTarget instanceof HTMLSelectElement) {
300
- setValue(currentTarget.value);
301
- }
302
- } else {
303
- setValue(val);
304
- }
305
- };
306
- }
307
-
308
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-errors/use-form-errors.mjs
309
- var import_react5 = require("react");
310
-
311
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-errors/filter-errors/filter-errors.mjs
312
- function filterErrors(errors) {
313
- if (errors === null || typeof errors !== "object") {
314
- return {};
315
- }
316
- return Object.keys(errors).reduce((acc, key) => {
317
- const errorValue = errors[key];
318
- if (errorValue !== void 0 && errorValue !== null && errorValue !== false) {
319
- acc[key] = errorValue;
320
- }
321
- return acc;
322
- }, {});
323
- }
324
-
325
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-errors/use-form-errors.mjs
326
- function useFormErrors(initialErrors) {
327
- const [errorsState, setErrorsState] = (0, import_react5.useState)(filterErrors(initialErrors));
328
- const errorsRef = (0, import_react5.useRef)(errorsState);
329
- const setErrors = (0, import_react5.useCallback)((errors) => {
330
- setErrorsState((current) => {
331
- const newErrors = filterErrors(typeof errors === "function" ? errors(current) : errors);
332
- errorsRef.current = newErrors;
333
- return newErrors;
334
- });
335
- }, []);
336
- const clearErrors = (0, import_react5.useCallback)(() => setErrors({}), []);
337
- const clearFieldError = (0, import_react5.useCallback)(
338
- (path) => {
339
- if (errorsRef.current[path] === void 0) {
340
- return;
341
- }
342
- setErrors((current) => {
343
- const errors = { ...current };
344
- delete errors[path];
345
- return errors;
346
- });
347
- },
348
- [errorsState]
349
- );
350
- const setFieldError = (0, import_react5.useCallback)(
351
- (path, error) => {
352
- if (error == null || error === false) {
353
- clearFieldError(path);
354
- } else if (errorsRef.current[path] !== error) {
355
- setErrors((current) => ({ ...current, [path]: error }));
356
- }
357
- },
358
- [errorsState]
359
- );
360
- return {
361
- errorsState,
362
- setErrors,
363
- clearErrors,
364
- setFieldError,
365
- clearFieldError
366
- };
367
- }
368
-
369
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-list/use-form-list.mjs
370
- var import_react6 = require("react");
371
-
372
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/lists/clear-list-state.mjs
373
- function clearListState(field, state) {
374
- if (state === null || typeof state !== "object") {
375
- return {};
376
- }
377
- const clone = { ...state };
378
- Object.keys(state).forEach((errorKey) => {
379
- if (errorKey.includes(`${String(field)}.`)) {
380
- delete clone[errorKey];
381
- }
382
- });
383
- return clone;
384
- }
385
-
386
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/lists/change-error-indices.mjs
387
- function getIndexFromKeyAfterPath(key, path) {
388
- const split = key.substring(path.length + 1).split(".")[0];
389
- return parseInt(split, 10);
390
- }
391
- function changeErrorIndices(path, index, errors, change) {
392
- if (index === void 0) {
393
- return errors;
394
- }
395
- const pathString = `${String(path)}`;
396
- let clearedErrors = errors;
397
- if (change === -1) {
398
- clearedErrors = clearListState(`${pathString}.${index}`, clearedErrors);
399
- }
400
- const cloned = { ...clearedErrors };
401
- const changedKeys = /* @__PURE__ */ new Set();
402
- Object.entries(clearedErrors).filter(([key]) => {
403
- if (!key.startsWith(`${pathString}.`)) {
404
- return false;
405
- }
406
- const currIndex = getIndexFromKeyAfterPath(key, pathString);
407
- if (Number.isNaN(currIndex)) {
408
- return false;
409
- }
410
- return currIndex >= index;
411
- }).forEach(([key, value]) => {
412
- const currIndex = getIndexFromKeyAfterPath(key, pathString);
413
- const newKey = key.replace(
414
- `${pathString}.${currIndex}`,
415
- `${pathString}.${currIndex + change}`
416
- );
417
- cloned[newKey] = value;
418
- changedKeys.add(newKey);
419
- if (!changedKeys.has(key)) {
420
- delete cloned[key];
421
- }
422
- });
423
- return cloned;
424
- }
425
-
426
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/lists/reorder-errors.mjs
427
- function reorderErrors(path, { from, to }, errors) {
428
- const oldKeyStart = `${path}.${from}`;
429
- const newKeyStart = `${path}.${to}`;
430
- const clone = { ...errors };
431
- Object.keys(errors).every((key) => {
432
- let oldKey;
433
- let newKey;
434
- if (key.startsWith(oldKeyStart)) {
435
- oldKey = key;
436
- newKey = key.replace(oldKeyStart, newKeyStart);
437
- }
438
- if (key.startsWith(newKeyStart)) {
439
- oldKey = key.replace(newKeyStart, oldKeyStart);
440
- newKey = key;
441
- }
442
- if (oldKey && newKey) {
443
- const value1 = clone[oldKey];
444
- const value2 = clone[newKey];
445
- value2 === void 0 ? delete clone[oldKey] : clone[oldKey] = value2;
446
- value1 === void 0 ? delete clone[newKey] : clone[newKey] = value1;
447
- return false;
448
- }
449
- return true;
450
- });
451
- return clone;
452
- }
453
-
454
- // ../../node_modules/.pnpm/klona@2.0.6/node_modules/klona/full/index.mjs
455
- function set(obj, key, val) {
456
- if (typeof val.value === "object") val.value = klona(val.value);
457
- if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === "__proto__") {
458
- Object.defineProperty(obj, key, val);
459
- } else obj[key] = val.value;
460
- }
461
- function klona(x) {
462
- if (typeof x !== "object") return x;
463
- var i = 0, k, list, tmp, str = Object.prototype.toString.call(x);
464
- if (str === "[object Object]") {
465
- tmp = Object.create(x.__proto__ || null);
466
- } else if (str === "[object Array]") {
467
- tmp = Array(x.length);
468
- } else if (str === "[object Set]") {
469
- tmp = /* @__PURE__ */ new Set();
470
- x.forEach(function(val) {
471
- tmp.add(klona(val));
472
- });
473
- } else if (str === "[object Map]") {
474
- tmp = /* @__PURE__ */ new Map();
475
- x.forEach(function(val, key) {
476
- tmp.set(klona(key), klona(val));
477
- });
478
- } else if (str === "[object Date]") {
479
- tmp = /* @__PURE__ */ new Date(+x);
480
- } else if (str === "[object RegExp]") {
481
- tmp = new RegExp(x.source, x.flags);
482
- } else if (str === "[object DataView]") {
483
- tmp = new x.constructor(klona(x.buffer));
484
- } else if (str === "[object ArrayBuffer]") {
485
- tmp = x.slice(0);
486
- } else if (str.slice(-6) === "Array]") {
487
- tmp = new x.constructor(x);
488
- }
489
- if (tmp) {
490
- for (list = Object.getOwnPropertySymbols(x); i < list.length; i++) {
491
- set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
492
- }
493
- for (i = 0, list = Object.getOwnPropertyNames(x); i < list.length; i++) {
494
- if (Object.hasOwnProperty.call(tmp, k = list[i]) && tmp[k] === x[k]) continue;
495
- set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
496
- }
497
- }
498
- return tmp || x;
499
- }
500
-
501
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/paths/get-splitted-path.mjs
502
- function getSplittedPath(path) {
503
- if (typeof path !== "string") {
504
- return [];
505
- }
506
- return path.split(".");
507
- }
508
-
509
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/paths/get-path.mjs
510
- function getPath(path, values) {
511
- const splittedPath = getSplittedPath(path);
512
- if (splittedPath.length === 0 || typeof values !== "object" || values === null) {
513
- return void 0;
514
- }
515
- let value = values[splittedPath[0]];
516
- for (let i = 1; i < splittedPath.length; i += 1) {
517
- if (value === void 0) {
518
- break;
519
- }
520
- value = value[splittedPath[i]];
521
- }
522
- return value;
523
- }
524
-
525
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/paths/set-path.mjs
526
- function setPath(path, value, values) {
527
- const splittedPath = getSplittedPath(path);
528
- if (splittedPath.length === 0) {
529
- return values;
530
- }
531
- const cloned = klona(values);
532
- if (splittedPath.length === 1) {
533
- cloned[splittedPath[0]] = value;
534
- return cloned;
535
- }
536
- let val = cloned[splittedPath[0]];
537
- for (let i = 1; i < splittedPath.length - 1; i += 1) {
538
- if (val === void 0) {
539
- return cloned;
540
- }
541
- val = val[splittedPath[i]];
542
- }
543
- val[splittedPath[splittedPath.length - 1]] = value;
544
- return cloned;
545
- }
546
-
547
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/paths/reorder-path.mjs
548
- function reorderPath(path, { from, to }, values) {
549
- const currentValue = getPath(path, values);
550
- if (!Array.isArray(currentValue)) {
551
- return values;
552
- }
553
- const cloned = [...currentValue];
554
- const item = currentValue[from];
555
- cloned.splice(from, 1);
556
- cloned.splice(to, 0, item);
557
- return setPath(path, cloned, values);
558
- }
559
-
560
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/paths/insert-path.mjs
561
- function insertPath(path, value, index, values) {
562
- const currentValue = getPath(path, values);
563
- if (!Array.isArray(currentValue)) {
564
- return values;
565
- }
566
- const cloned = [...currentValue];
567
- cloned.splice(typeof index === "number" ? index : cloned.length, 0, value);
568
- return setPath(path, cloned, values);
569
- }
570
-
571
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/paths/remove-path.mjs
572
- function removePath(path, index, values) {
573
- const currentValue = getPath(path, values);
574
- if (!Array.isArray(currentValue)) {
575
- return values;
576
- }
577
- return setPath(
578
- path,
579
- currentValue.filter((_, itemIndex) => itemIndex !== index),
580
- values
581
- );
582
- }
583
-
584
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-list/use-form-list.mjs
585
- function useFormList({
586
- $values,
587
- $errors,
588
- $status
589
- }) {
590
- const reorderListItem = (0, import_react6.useCallback)((path, payload) => {
591
- $status.clearFieldDirty(path);
592
- $errors.setErrors((errs) => reorderErrors(path, payload, errs));
593
- $values.setValues({
594
- values: reorderPath(path, payload, $values.refValues.current),
595
- updateState: true
596
- });
597
- }, []);
598
- const removeListItem = (0, import_react6.useCallback)((path, index) => {
599
- $status.clearFieldDirty(path);
600
- $errors.setErrors((errs) => changeErrorIndices(path, index, errs, -1));
601
- $values.setValues({
602
- values: removePath(path, index, $values.refValues.current),
603
- updateState: true
604
- });
605
- }, []);
606
- const insertListItem = (0, import_react6.useCallback)((path, item, index) => {
607
- $status.clearFieldDirty(path);
608
- $errors.setErrors((errs) => changeErrorIndices(path, index, errs, 1));
609
- $values.setValues({
610
- values: insertPath(path, item, index, $values.refValues.current),
611
- updateState: true
612
- });
613
- }, []);
614
- return { reorderListItem, removeListItem, insertListItem };
615
- }
616
-
617
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-status/use-form-status.mjs
618
- var import_react7 = require("react");
619
- var import_fast_deep_equal = __toESM(require_fast_deep_equal(), 1);
620
-
621
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/get-status/get-status.mjs
622
- function getStatus(status, path) {
623
- const paths = Object.keys(status);
624
- if (typeof path === "string") {
625
- const nestedPaths = paths.filter((statusPath) => statusPath.startsWith(`${path}.`));
626
- return status[path] || nestedPaths.some((statusPath) => status[statusPath]) || false;
627
- }
628
- return paths.some((statusPath) => status[statusPath]);
629
- }
630
-
631
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-status/use-form-status.mjs
632
- function useFormStatus({
633
- initialDirty,
634
- initialTouched,
635
- mode,
636
- $values
637
- }) {
638
- const [touchedState, setTouchedState] = (0, import_react7.useState)(initialTouched);
639
- const [dirtyState, setDirtyState] = (0, import_react7.useState)(initialDirty);
640
- const touchedRef = (0, import_react7.useRef)(initialTouched);
641
- const dirtyRef = (0, import_react7.useRef)(initialDirty);
642
- const setTouched = (0, import_react7.useCallback)((values) => {
643
- const resolvedValues = typeof values === "function" ? values(touchedRef.current) : values;
644
- touchedRef.current = resolvedValues;
645
- if (mode === "controlled") {
646
- setTouchedState(resolvedValues);
647
- }
648
- }, []);
649
- const setDirty = (0, import_react7.useCallback)((values) => {
650
- const resolvedValues = typeof values === "function" ? values(dirtyRef.current) : values;
651
- dirtyRef.current = resolvedValues;
652
- if (mode === "controlled") {
653
- setDirtyState(resolvedValues);
654
- }
655
- }, []);
656
- const resetTouched = (0, import_react7.useCallback)(() => setTouched({}), []);
657
- const resetDirty = (values) => {
658
- const newSnapshot = values ? { ...values, ...$values.refValues.current } : $values.refValues.current;
659
- $values.setValuesSnapshot(newSnapshot);
660
- setDirty({});
661
- };
662
- const setFieldTouched = (0, import_react7.useCallback)((path, touched) => {
663
- setTouched((currentTouched) => {
664
- if (getStatus(currentTouched, path) === touched) {
665
- return currentTouched;
666
- }
667
- return { ...currentTouched, [path]: touched };
668
- });
669
- }, []);
670
- const setFieldDirty = (0, import_react7.useCallback)((path, dirty) => {
671
- setDirty((currentDirty) => {
672
- if (getStatus(currentDirty, path) === dirty) {
673
- return currentDirty;
674
- }
675
- return { ...currentDirty, [path]: dirty };
676
- });
677
- }, []);
678
- const isTouched = (0, import_react7.useCallback)(
679
- (path) => getStatus(touchedRef.current, path),
680
- []
681
- );
682
- const clearFieldDirty = (0, import_react7.useCallback)(
683
- (path) => setDirty((current) => {
684
- if (typeof path !== "string") {
685
- return current;
686
- }
687
- const result = clearListState(path, current);
688
- delete result[path];
689
- if ((0, import_fast_deep_equal.default)(result, current)) {
690
- return current;
691
- }
692
- return result;
693
- }),
694
- []
695
- );
696
- const isDirty = (0, import_react7.useCallback)((path) => {
697
- if (path) {
698
- const overriddenValue = getPath(path, dirtyRef.current);
699
- if (typeof overriddenValue === "boolean") {
700
- return overriddenValue;
701
- }
702
- const sliceOfValues = getPath(path, $values.refValues.current);
703
- const sliceOfInitialValues = getPath(path, $values.valuesSnapshot.current);
704
- return !(0, import_fast_deep_equal.default)(sliceOfValues, sliceOfInitialValues);
705
- }
706
- const isOverridden = Object.keys(dirtyRef.current).length > 0;
707
- if (isOverridden) {
708
- return getStatus(dirtyRef.current);
709
- }
710
- return !(0, import_fast_deep_equal.default)($values.refValues.current, $values.valuesSnapshot.current);
711
- }, []);
712
- const getDirty = (0, import_react7.useCallback)(() => dirtyRef.current, []);
713
- const getTouched = (0, import_react7.useCallback)(() => touchedRef.current, []);
714
- return {
715
- touchedState,
716
- dirtyState,
717
- touchedRef,
718
- dirtyRef,
719
- setTouched,
720
- setDirty,
721
- resetDirty,
722
- resetTouched,
723
- isTouched,
724
- setFieldTouched,
725
- setFieldDirty,
726
- setTouchedState,
727
- setDirtyState,
728
- clearFieldDirty,
729
- isDirty,
730
- getDirty,
731
- getTouched
732
- };
733
- }
734
-
735
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-values/use-form-values.mjs
736
- var import_react8 = require("react");
737
- function useFormValues({
738
- initialValues,
739
- onValuesChange,
740
- mode
741
- }) {
742
- const initialized = (0, import_react8.useRef)(false);
743
- const [stateValues, setStateValues] = (0, import_react8.useState)(initialValues || {});
744
- const refValues = (0, import_react8.useRef)(stateValues);
745
- const valuesSnapshot = (0, import_react8.useRef)(stateValues);
746
- const setValues = (0, import_react8.useCallback)(
747
- ({
748
- values,
749
- subscribers,
750
- updateState = true,
751
- mergeWithPreviousValues = true
752
- }) => {
753
- const previousValues = refValues.current;
754
- const resolvedValues = values instanceof Function ? values(refValues.current) : values;
755
- const updatedValues = mergeWithPreviousValues ? { ...previousValues, ...resolvedValues } : resolvedValues;
756
- refValues.current = updatedValues;
757
- updateState && setStateValues(updatedValues);
758
- onValuesChange?.(updatedValues, previousValues);
759
- subscribers?.filter(Boolean).forEach((subscriber) => subscriber({ updatedValues, previousValues }));
760
- },
761
- [onValuesChange]
762
- );
763
- const setFieldValue = (0, import_react8.useCallback)((payload) => {
764
- const currentValue = getPath(payload.path, refValues.current);
765
- const updatedValue = payload.value instanceof Function ? payload.value(currentValue) : payload.value;
766
- if (currentValue !== updatedValue) {
767
- const previousValues = refValues.current;
768
- const updatedValues = setPath(payload.path, updatedValue, refValues.current);
769
- setValues({ values: updatedValues, updateState: payload.updateState });
770
- payload.subscribers?.filter(Boolean).forEach(
771
- (subscriber) => subscriber({ path: payload.path, updatedValues, previousValues })
772
- );
773
- }
774
- }, []);
775
- const setValuesSnapshot = (0, import_react8.useCallback)((payload) => {
776
- valuesSnapshot.current = payload;
777
- }, []);
778
- const initialize = (0, import_react8.useCallback)((values, onInitialize) => {
779
- if (!initialized.current) {
780
- initialized.current = true;
781
- setValues({ values, updateState: mode === "controlled" });
782
- setValuesSnapshot(values);
783
- onInitialize();
784
- }
785
- }, []);
786
- const resetValues = (0, import_react8.useCallback)(() => {
787
- setValues({
788
- values: valuesSnapshot.current,
789
- updateState: true,
790
- mergeWithPreviousValues: false
791
- });
792
- }, []);
793
- const getValues = (0, import_react8.useCallback)(() => refValues.current, []);
794
- return {
795
- initialized,
796
- stateValues,
797
- refValues,
798
- valuesSnapshot,
799
- setValues,
800
- setFieldValue,
801
- resetValues,
802
- setValuesSnapshot,
803
- initialize,
804
- getValues
805
- };
806
- }
807
-
808
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/hooks/use-form-watch/use-form-watch.mjs
809
- var import_react9 = require("react");
810
- function useFormWatch({
811
- $status
812
- }) {
813
- const subscribers = (0, import_react9.useRef)(
814
- {}
815
- );
816
- const watch = (0, import_react9.useCallback)((path, callback) => {
817
- (0, import_react9.useEffect)(() => {
818
- subscribers.current[path] = subscribers.current[path] || [];
819
- subscribers.current[path].push(callback);
820
- return () => {
821
- subscribers.current[path] = subscribers.current[path].filter((cb) => cb !== callback);
822
- };
823
- }, [callback]);
824
- }, []);
825
- const getFieldSubscribers = (0, import_react9.useCallback)((path) => {
826
- if (!subscribers.current[path]) {
827
- return [];
828
- }
829
- return subscribers.current[path].map(
830
- (callback) => (input) => callback({
831
- previousValue: getPath(path, input.previousValues),
832
- value: getPath(path, input.updatedValues),
833
- touched: $status.isTouched(path),
834
- dirty: $status.isDirty(path)
835
- })
836
- );
837
- }, []);
838
- return {
839
- subscribers,
840
- watch,
841
- getFieldSubscribers
842
- };
843
- }
844
-
845
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/paths/get-data-path.mjs
846
- function getDataPath(formName, fieldPath) {
847
- return formName ? `${formName}-${fieldPath.toString()}` : fieldPath.toString();
848
- }
849
-
850
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/validate/validate-values.mjs
851
- function getValidationResults(errors) {
852
- const filteredErrors = filterErrors(errors);
853
- return { hasErrors: Object.keys(filteredErrors).length > 0, errors: filteredErrors };
854
- }
855
- function validateRulesRecord(rules, values, path = "", errors = {}) {
856
- if (typeof rules !== "object" || rules === null) {
857
- return errors;
858
- }
859
- return Object.keys(rules).reduce((acc, ruleKey) => {
860
- const rule = rules[ruleKey];
861
- const rulePath = `${path === "" ? "" : `${path}.`}${ruleKey}`;
862
- const value = getPath(rulePath, values);
863
- let arrayValidation = false;
864
- if (typeof rule === "function") {
865
- acc[rulePath] = rule(value, values, rulePath);
866
- }
867
- if (typeof rule === "object" && Array.isArray(value)) {
868
- arrayValidation = true;
869
- value.forEach(
870
- (_item, index) => validateRulesRecord(rule, values, `${rulePath}.${index}`, acc)
871
- );
872
- }
873
- if (typeof rule === "object" && typeof value === "object" && value !== null) {
874
- if (!arrayValidation) {
875
- validateRulesRecord(rule, values, rulePath, acc);
876
- }
877
- }
878
- return acc;
879
- }, errors);
880
- }
881
- function validateValues(validate, values) {
882
- if (typeof validate === "function") {
883
- return getValidationResults(validate(values));
884
- }
885
- return getValidationResults(validateRulesRecord(validate, values));
886
- }
887
-
888
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/validate/validate-field-value.mjs
889
- function validateFieldValue(path, rules, values) {
890
- if (typeof path !== "string") {
891
- return { hasError: false, error: null };
892
- }
893
- const results = validateValues(rules, values);
894
- const pathInError = Object.keys(results.errors).find(
895
- (errorKey) => path.split(".").every((pathPart, i) => pathPart === errorKey.split(".")[i])
896
- );
897
- return { hasError: !!pathInError, error: pathInError ? results.errors[pathInError] : null };
898
- }
899
-
900
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/form-index.mjs
901
- var FORM_INDEX = "__MANTINE_FORM_INDEX__";
902
-
903
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/validate/should-validate-on-change.mjs
904
- function shouldValidateOnChange(path, validateInputOnChange) {
905
- if (!validateInputOnChange) {
906
- return false;
907
- }
908
- if (typeof validateInputOnChange === "boolean") {
909
- return validateInputOnChange;
910
- }
911
- if (Array.isArray(validateInputOnChange)) {
912
- return validateInputOnChange.includes(path.replace(/[.][0-9]/g, `.${FORM_INDEX}`));
913
- }
914
- return false;
915
- }
916
-
917
- // ../../node_modules/.pnpm/@mantine+form@7.10.1_react@18.3.1/node_modules/@mantine/form/esm/use-form.mjs
918
- function useForm({
919
- name,
920
- mode = "controlled",
921
- initialValues,
922
- initialErrors = {},
923
- initialDirty = {},
924
- initialTouched = {},
925
- clearInputErrorOnChange = true,
926
- validateInputOnChange = false,
927
- validateInputOnBlur = false,
928
- onValuesChange,
929
- transformValues = (values) => values,
930
- enhanceGetInputProps,
931
- validate: rules
932
- } = {}) {
933
- const $errors = useFormErrors(initialErrors);
934
- const $values = useFormValues({ initialValues, onValuesChange, mode });
935
- const $status = useFormStatus({ initialDirty, initialTouched, $values, mode });
936
- const $list = useFormList({ $values, $errors, $status });
937
- const $watch = useFormWatch({ $status });
938
- const [formKey, setFormKey] = (0, import_react10.useState)(0);
939
- const [fieldKeys, setFieldKeys] = (0, import_react10.useState)({});
940
- const reset = (0, import_react10.useCallback)(() => {
941
- $values.resetValues();
942
- $errors.clearErrors();
943
- $status.resetDirty();
944
- $status.resetTouched();
945
- mode === "uncontrolled" && setFormKey((key2) => key2 + 1);
946
- }, []);
947
- const initialize = (0, import_react10.useCallback)((values) => {
948
- $values.initialize(values, () => mode === "uncontrolled" && setFormKey((key2) => key2 + 1));
949
- }, []);
950
- const setFieldValue = (0, import_react10.useCallback)(
951
- (path, value, options2) => {
952
- const shouldValidate = shouldValidateOnChange(path, validateInputOnChange);
953
- $status.clearFieldDirty(path);
954
- $status.setFieldTouched(path, true);
955
- !shouldValidate && clearInputErrorOnChange && $errors.clearFieldError(path);
956
- $values.setFieldValue({
957
- path,
958
- value,
959
- updateState: mode === "controlled",
960
- subscribers: [
961
- ...$watch.getFieldSubscribers(path),
962
- shouldValidate ? (payload) => {
963
- const validationResults = validateFieldValue(path, rules, payload.updatedValues);
964
- validationResults.hasError ? $errors.setFieldError(path, validationResults.error) : $errors.clearFieldError(path);
965
- } : null,
966
- options2?.forceUpdate !== false && mode !== "controlled" ? () => setFieldKeys((keys) => ({
967
- ...keys,
968
- [path]: (keys[path] || 0) + 1
969
- })) : null
970
- ]
971
- });
972
- },
973
- [onValuesChange, rules]
974
- );
975
- const setValues = (0, import_react10.useCallback)(
976
- (values) => {
977
- const previousValues = $values.refValues.current;
978
- $values.setValues({ values, updateState: mode === "controlled" });
979
- clearInputErrorOnChange && $errors.clearErrors();
980
- mode === "uncontrolled" && setFormKey((key2) => key2 + 1);
981
- Object.keys($watch.subscribers.current).forEach((path) => {
982
- const value = getPath(path, $values.refValues.current);
983
- const previousValue = getPath(path, previousValues);
984
- if (value !== previousValue) {
985
- $watch.getFieldSubscribers(path).forEach((cb) => cb({ previousValues, updatedValues: $values.refValues.current }));
986
- }
987
- });
988
- },
989
- [onValuesChange, clearInputErrorOnChange]
990
- );
991
- const validate = (0, import_react10.useCallback)(() => {
992
- const results = validateValues(rules, $values.refValues.current);
993
- $errors.setErrors(results.errors);
994
- return results;
995
- }, [rules]);
996
- const validateField = (0, import_react10.useCallback)(
997
- (path) => {
998
- const results = validateFieldValue(path, rules, $values.refValues.current);
999
- results.hasError ? $errors.setFieldError(path, results.error) : $errors.clearFieldError(path);
1000
- return results;
1001
- },
1002
- [rules]
1003
- );
1004
- const getInputProps = (path, { type = "input", withError = true, withFocus = true, ...otherOptions } = {}) => {
1005
- const onChange = getInputOnChange(
1006
- (value) => setFieldValue(path, value, { forceUpdate: false })
1007
- );
1008
- const payload = { onChange, "data-path": getDataPath(name, path) };
1009
- if (withError) {
1010
- payload.error = $errors.errorsState[path];
1011
- }
1012
- if (type === "checkbox") {
1013
- payload[mode === "controlled" ? "checked" : "defaultChecked"] = getPath(
1014
- path,
1015
- $values.refValues.current
1016
- );
1017
- } else {
1018
- payload[mode === "controlled" ? "value" : "defaultValue"] = getPath(
1019
- path,
1020
- $values.refValues.current
1021
- );
1022
- }
1023
- if (withFocus) {
1024
- payload.onFocus = () => $status.setFieldTouched(path, true);
1025
- payload.onBlur = () => {
1026
- if (shouldValidateOnChange(path, validateInputOnBlur)) {
1027
- const validationResults = validateFieldValue(path, rules, $values.refValues.current);
1028
- validationResults.hasError ? $errors.setFieldError(path, validationResults.error) : $errors.clearFieldError(path);
1029
- }
1030
- };
1031
- }
1032
- return Object.assign(
1033
- payload,
1034
- enhanceGetInputProps?.({
1035
- inputProps: payload,
1036
- field: path,
1037
- options: { type, withError, withFocus, ...otherOptions },
1038
- form
1039
- })
1040
- );
1041
- };
1042
- const onSubmit = (handleSubmit, handleValidationFailure) => (event) => {
1043
- event?.preventDefault();
1044
- const results = validate();
1045
- if (results.hasErrors) {
1046
- handleValidationFailure?.(results.errors, $values.refValues.current, event);
1047
- } else {
1048
- handleSubmit?.(transformValues($values.refValues.current), event);
1049
- }
1050
- };
1051
- const getTransformedValues = (input) => transformValues(input || $values.refValues.current);
1052
- const onReset = (0, import_react10.useCallback)((event) => {
1053
- event.preventDefault();
1054
- reset();
1055
- }, []);
1056
- const isValid = (0, import_react10.useCallback)(
1057
- (path) => path ? !validateFieldValue(path, rules, $values.refValues.current).hasError : !validateValues(rules, $values.refValues.current).hasErrors,
1058
- [rules]
1059
- );
1060
- const key = (path) => `${formKey}-${path}-${fieldKeys[path] || 0}`;
1061
- const getInputNode = (0, import_react10.useCallback)(
1062
- (path) => document.querySelector(`[data-path="${getDataPath(name, path)}"]`),
1063
- []
1064
- );
1065
- const form = {
1066
- watch: $watch.watch,
1067
- initialized: $values.initialized.current,
1068
- values: $values.stateValues,
1069
- getValues: $values.getValues,
1070
- setInitialValues: $values.setValuesSnapshot,
1071
- initialize,
1072
- setValues,
1073
- setFieldValue,
1074
- errors: $errors.errorsState,
1075
- setErrors: $errors.setErrors,
1076
- setFieldError: $errors.setFieldError,
1077
- clearFieldError: $errors.clearFieldError,
1078
- clearErrors: $errors.clearErrors,
1079
- resetDirty: $status.resetDirty,
1080
- setTouched: $status.setTouched,
1081
- setDirty: $status.setDirty,
1082
- isTouched: $status.isTouched,
1083
- resetTouched: $status.resetTouched,
1084
- isDirty: $status.isDirty,
1085
- getTouched: $status.getTouched,
1086
- getDirty: $status.getDirty,
1087
- reorderListItem: $list.reorderListItem,
1088
- insertListItem: $list.insertListItem,
1089
- removeListItem: $list.removeListItem,
1090
- reset,
1091
- validate,
1092
- validateField,
1093
- getInputProps,
1094
- onSubmit,
1095
- onReset,
1096
- isValid,
1097
- getTransformedValues,
1098
- key,
1099
- getInputNode
1100
- };
1101
- useFormActions(name, form);
1102
- return form;
1103
- }
1104
-
1105
- // src/nodes/modifiers/noise-curve-node.tsx
1106
- var import_react11 = require("react");
1107
- var import_libnoise_simplex_ts4 = require("libnoise-simplex-ts");
1108
- var import_icons_react2 = require("@tabler/icons-react");
1109
- var import_hooks5 = require("@mantine/hooks");
1110
- var import_abstract = require("@awesome-flow/core/abstract");
1111
- var import_jsx_runtime4 = require("react/jsx-runtime");
1112
- function NoiseCurveNode({ id, selected, data, type }) {
1113
- const incoming = (0, import_hooks4.useIncomingComputedData)(id);
1114
- const updateNodeData = (0, import_hooks4.useUpdateNodeData)();
1115
- const updateComputedData = (0, import_hooks4.useUpdateNodeComputedData)();
1116
- const [values, setValues] = (0, import_react11.useState)([]);
1117
- const form = useForm({
1118
- mode: "uncontrolled",
1119
- initialValues: {
1120
- points: []
1121
- },
1122
- validateInputOnChange: [`points.${FORM_INDEX}.input`],
1123
- clearInputErrorOnChange: true,
1124
- validate: {
1125
- points: {
1126
- input: (value, values2) => {
1127
- const counts = {};
1128
- values2.points.forEach((x) => {
1129
- counts[x.input] = (counts[x.input] || 0) + 1;
1130
- });
1131
- return counts[value] > 1;
1132
- }
1133
- }
1134
- },
1135
- onValuesChange: (0, import_react11.useCallback)((values2) => {
1136
- if (form.isValid()) {
1137
- const points = values2.points.map((v) => ({ input: v.input, output: v.output }));
1138
- setValues(points);
1139
- updateNodeData(id, { points });
1140
- }
1141
- form.validate();
1142
- }, [])
1143
- });
1144
- (0, import_react11.useEffect)(() => {
1145
- const points = data.points?.length ? data.points.map((v) => ({ input: v.input, output: v.output, key: (0, import_hooks5.randomId)() })) : [1, 2, 3, 4].map(() => ({ input: 0, output: 0, key: (0, import_hooks5.randomId)() }));
1146
- form.initialize({ points });
1147
- }, []);
1148
- (0, import_react11.useEffect)(() => {
1149
- if (incoming?.length && values?.length >= 4) {
1150
- const module2 = new import_libnoise_simplex_ts4.Curve(
1151
- incoming[0].module,
1152
- values.map((p) => new import_libnoise_simplex_ts4.Tuple(p.input, p.output))
1153
- );
1154
- updateComputedData(id, { module: module2 });
1155
- }
1156
- }, [values, incoming]);
1157
- const fields = form.getValues().points.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_core2.Group, { mt: "xs", children: [
1158
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1159
- import_core2.NumberInput,
1160
- {
1161
- size: "xs",
1162
- w: 100,
1163
- placeholder: "Input Value",
1164
- ...form.getInputProps(`points.${index}.input`),
1165
- step: 0.1
1166
- },
1167
- form.key(`points.${index}.input`)
1168
- ),
1169
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1170
- import_core2.NumberInput,
1171
- {
1172
- size: "xs",
1173
- w: 100,
1174
- placeholder: "Output Value",
1175
- ...form.getInputProps(`points.${index}.output`),
1176
- step: 0.1
1177
- },
1178
- form.key(`points.${index}.output`)
1179
- ),
1180
- data.state === import_abstract.NodeState.edit && values.length > 4 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1181
- import_core2.ActionIcon,
1182
- {
1183
- color: "red",
1184
- variant: "outline",
1185
- size: "sm",
1186
- onClick: () => form.removeListItem("points", index),
1187
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons_react2.IconX, { size: "1rem" })
1188
- }
1189
- )
1190
- ] }, item.key));
1191
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_layout4.NodeContainer, { id, selected, type, data, children: [
1192
- fields,
1193
- data.state === import_abstract.NodeState.edit && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1194
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core2.Space, { h: 10 }),
1195
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1196
- import_core2.Button,
1197
- {
1198
- variant: "outline",
1199
- size: "xs",
1200
- fullWidth: true,
1201
- onClick: () => form.insertListItem("points", { input: 0, output: 0, key: (0, import_hooks5.randomId)() }),
1202
- children: "Add control point"
1203
- }
1204
- )
1205
- ] }),
1206
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_layout4.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
1207
- ] });
1208
- }
1209
- var noise_curve_node_default = NoiseCurveNode;
1210
-
1211
- // src/nodes/modifiers/noise-exponent-node.tsx
1212
- var import_layout5 = require("@awesome-flow/core/layout");
1213
- var import_react12 = require("react");
1214
- var import_core3 = require("@mantine/core");
1215
- var import_hooks6 = require("@awesome-flow/core/hooks");
1216
- var import_libnoise_simplex_ts5 = require("libnoise-simplex-ts");
1217
- var import_jsx_runtime5 = require("react/jsx-runtime");
1218
- function NoiseExponentNode({ id, selected, data, type }) {
1219
- const [exponent, setExponent] = (0, import_react12.useState)(data.exponent);
1220
- const incoming = (0, import_hooks6.useIncomingComputedData)(id);
1221
- const updateNodeData = (0, import_hooks6.useUpdateNodeData)();
1222
- const updateComputedData = (0, import_hooks6.useUpdateNodeComputedData)();
1223
- (0, import_react12.useEffect)(() => {
1224
- if (incoming?.length > 0) {
1225
- const module2 = new import_libnoise_simplex_ts5.Exponent(incoming[0].module, exponent);
1226
- updateComputedData(id, { module: module2 });
1227
- }
1228
- updateNodeData(id, { exponent });
1229
- }, [incoming, exponent]);
1230
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_layout5.NodeContainer, { id, selected, data, type, children: [
1231
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core3.Stack, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_core3.Group, { children: [
1232
- "Exponent:",
1233
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1234
- import_core3.NumberInput,
1235
- {
1236
- size: "xs",
1237
- value: exponent,
1238
- onChange: (e) => setExponent(Number(e)),
1239
- step: 0.1
1240
- }
1241
- )
1242
- ] }) }),
1243
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_layout5.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
1244
- ] });
1245
- }
1246
- var noise_exponent_node_default = NoiseExponentNode;
1247
-
1248
- // src/nodes/modifiers/noise-invert-node.tsx
1249
- var import_layout6 = require("@awesome-flow/core/layout");
1250
- var import_react13 = require("react");
1251
- var import_hooks7 = require("@awesome-flow/core/hooks");
1252
- var import_libnoise_simplex_ts6 = require("libnoise-simplex-ts");
1253
- var import_jsx_runtime6 = require("react/jsx-runtime");
1254
- function NoiseInvertNode({ id, selected, data, type }) {
1255
- const incoming = (0, import_hooks7.useIncomingComputedData)(id);
1256
- const updateComputedData = (0, import_hooks7.useUpdateNodeComputedData)();
1257
- (0, import_react13.useEffect)(() => {
1258
- if (incoming?.length > 0) {
1259
- const module2 = new import_libnoise_simplex_ts6.Invert(incoming[0].module);
1260
- updateComputedData(id, { module: module2 });
1261
- }
1262
- }, [incoming]);
1263
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_layout6.NodeContainer, { id, selected, data, type, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_layout6.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" }) });
1264
- }
1265
- var noise_invert_node_default = NoiseInvertNode;
1266
-
1267
- // src/nodes/modifiers/noise-normalize-node.tsx
1268
- var import_layout7 = require("@awesome-flow/core/layout");
1269
- var import_react14 = require("react");
1270
- var import_core4 = require("@mantine/core");
1271
- var import_hooks8 = require("@awesome-flow/core/hooks");
1272
-
1273
- // src/modules/normalize-noise-module.ts
1274
- var import_libnoise_simplex_ts7 = require("libnoise-simplex-ts");
1275
- var NormalizeNoiseModule = class extends import_libnoise_simplex_ts7.ModifierModule {
1276
- constructor(source, lowerBound, upperBound) {
1277
- super(source);
1278
- this.lowerBound = lowerBound;
1279
- this.upperBound = upperBound;
1280
- }
1281
- getValue(x, y, z) {
1282
- return normalize(this.sourceModule.getValue(x, y, z), this.lowerBound, this.upperBound);
1283
- }
1284
- };
1285
- function normalize(value, min, max) {
1286
- return (value - min) / (max - min);
1287
- }
1288
-
1289
- // src/nodes/modifiers/noise-normalize-node.tsx
1290
- var import_jsx_runtime7 = require("react/jsx-runtime");
1291
- function NoiseNormalizeNode({ id, selected, data, type }) {
1292
- const [intervalStart, setIntervalStart] = (0, import_react14.useState)(data.intervalStart);
1293
- const [intervalEnd, setIntervalEnd] = (0, import_react14.useState)(data.intervalEnd);
1294
- const incoming = (0, import_hooks8.useIncomingComputedData)(id);
1295
- const updateNodeData = (0, import_hooks8.useUpdateNodeData)();
1296
- const updateComputedData = (0, import_hooks8.useUpdateNodeComputedData)();
1297
- (0, import_react14.useEffect)(() => {
1298
- if (incoming?.length) {
1299
- const source = incoming[0].module;
1300
- const module2 = new NormalizeNoiseModule(source, intervalStart, intervalEnd);
1301
- updateComputedData(id, { module: module2 });
1302
- }
1303
- updateNodeData(id, { intervalStart, intervalEnd });
1304
- }, [incoming, intervalStart, intervalEnd]);
1305
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_layout7.NodeContainer, { id, selected, data, type, children: [
1306
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core4.Stack, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_core4.Group, { children: [
1307
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1308
- import_core4.NumberInput,
1309
- {
1310
- size: "xs",
1311
- w: 100,
1312
- value: intervalStart,
1313
- onChange: (e) => setIntervalStart(Number(e))
1314
- }
1315
- ),
1316
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1317
- import_core4.NumberInput,
1318
- {
1319
- size: "xs",
1320
- w: 100,
1321
- value: intervalEnd,
1322
- onChange: (e) => setIntervalEnd(Number(e))
1323
- }
1324
- )
1325
- ] }) }),
1326
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_layout7.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
1327
- ] });
1328
- }
1329
- var noise_normalize_node_default = NoiseNormalizeNode;
1330
-
1331
- // src/nodes/modifiers/noise-scale-bias-node.tsx
1332
- var import_layout8 = require("@awesome-flow/core/layout");
1333
- var import_react15 = require("react");
1334
- var import_core5 = require("@mantine/core");
1335
- var import_hooks9 = require("@awesome-flow/core/hooks");
1336
- var import_libnoise_simplex_ts8 = require("libnoise-simplex-ts");
1337
- var import_jsx_runtime8 = require("react/jsx-runtime");
1338
- function NoiseScaleBiasNode({ id, selected, data, type }) {
1339
- const [scale, setScale] = (0, import_react15.useState)(data.scale);
1340
- const [bias, setBias] = (0, import_react15.useState)(data.bias);
1341
- const incoming = (0, import_hooks9.useIncomingComputedData)(id);
1342
- const updateNodeData = (0, import_hooks9.useUpdateNodeData)();
1343
- const updateComputedData = (0, import_hooks9.useUpdateNodeComputedData)();
1344
- (0, import_react15.useEffect)(() => {
1345
- if (incoming?.length > 0) {
1346
- const module2 = new import_libnoise_simplex_ts8.ScaleBias(incoming[0].module, scale, bias);
1347
- updateComputedData(id, { module: module2 });
1348
- }
1349
- updateNodeData(id, { scale, bias });
1350
- }, [incoming, scale, bias]);
1351
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_layout8.NodeContainer, { id, selected, data, type, children: [
1352
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core5.Stack, { children: [
1353
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core5.Group, { children: [
1354
- "Scale:",
1355
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1356
- import_core5.NumberInput,
1357
- {
1358
- size: "xs",
1359
- w: 100,
1360
- value: scale,
1361
- onChange: (e) => setScale(Number(e)),
1362
- step: 0.1
1363
- }
1364
- )
1365
- ] }),
1366
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core5.Group, { children: [
1367
- "Bias:",
1368
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1369
- import_core5.NumberInput,
1370
- {
1371
- size: "xs",
1372
- w: 100,
1373
- value: bias,
1374
- onChange: (e) => setBias(Number(e)),
1375
- step: 0.1
1376
- }
1377
- )
1378
- ] })
1379
- ] }),
1380
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_layout8.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
1381
- ] });
1382
- }
1383
- var noise_scale_bias_node_default = NoiseScaleBiasNode;
1384
-
1385
- // src/nodes/modifiers/noise-terrace-node.tsx
1386
- var import_layout9 = require("@awesome-flow/core/layout");
1387
- var import_core6 = require("@mantine/core");
1388
- var import_hooks10 = require("@awesome-flow/core/hooks");
1389
- var import_react16 = require("react");
1390
- var import_libnoise_simplex_ts9 = require("libnoise-simplex-ts");
1391
- var import_icons_react3 = require("@tabler/icons-react");
1392
- var import_hooks11 = require("@mantine/hooks");
1393
- var import_abstract2 = require("@awesome-flow/core/abstract");
1394
- var import_jsx_runtime9 = require("react/jsx-runtime");
1395
- function NoiseTerraceNode({ id, selected, data, type }) {
1396
- const incoming = (0, import_hooks10.useIncomingComputedData)(id);
1397
- const updateNodeData = (0, import_hooks10.useUpdateNodeData)();
1398
- const updateComputedData = (0, import_hooks10.useUpdateNodeComputedData)();
1399
- const [values, setValues] = (0, import_react16.useState)([]);
1400
- const form = useForm({
1401
- mode: "uncontrolled",
1402
- initialValues: {
1403
- points: []
1404
- },
1405
- validateInputOnChange: [`points.${FORM_INDEX}.input`],
1406
- clearInputErrorOnChange: true,
1407
- onValuesChange: (0, import_react16.useCallback)((values2) => {
1408
- if (form.isValid()) {
1409
- const points = values2.points.map((v) => v.value);
1410
- setValues(points);
1411
- updateNodeData(id, { points });
1412
- }
1413
- form.validate();
1414
- }, [])
1415
- });
1416
- (0, import_react16.useEffect)(() => {
1417
- const points = data.points?.length ? data.points.map((v) => ({ value: v, key: (0, import_hooks11.randomId)() })) : [1, 2].map(() => ({ value: 0, key: (0, import_hooks11.randomId)() }));
1418
- form.initialize({ points });
1419
- }, []);
1420
- (0, import_react16.useEffect)(() => {
1421
- if (incoming?.length && values?.length >= 2) {
1422
- const module2 = new import_libnoise_simplex_ts9.Terrace(incoming[0].module, values);
1423
- updateComputedData(id, { module: module2 });
1424
- }
1425
- }, [values, incoming]);
1426
- const fields = form.getValues().points.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_core6.Group, { mt: "xs", children: [
1427
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1428
- import_core6.NumberInput,
1429
- {
1430
- size: "xs",
1431
- placeholder: "Input Value",
1432
- ...form.getInputProps(`points.${index}.value`),
1433
- step: 0.1
1434
- },
1435
- form.key(`points.${index}.value`)
1436
- ),
1437
- data.state === import_abstract2.NodeState.edit && values.length > 2 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1438
- import_core6.ActionIcon,
1439
- {
1440
- color: "red",
1441
- variant: "outline",
1442
- size: "sm",
1443
- onClick: () => form.removeListItem("points", index),
1444
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons_react3.IconX, { size: "1rem" })
1445
- }
1446
- )
1447
- ] }, item.key));
1448
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_layout9.NodeContainer, { id, selected, type, data, children: [
1449
- fields,
1450
- data.state === import_abstract2.NodeState.edit && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1451
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core6.Space, { h: 10 }),
1452
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1453
- import_core6.Button,
1454
- {
1455
- variant: "outline",
1456
- size: "xs",
1457
- fullWidth: true,
1458
- onClick: () => form.insertListItem("points", { value: 0, key: (0, import_hooks11.randomId)() }),
1459
- children: "Add control point"
1460
- }
1461
- )
1462
- ] }),
1463
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_layout9.NodeTrackConnections, { handles: data.handles, nodeId: id, type: "target" })
1464
- ] });
1465
- }
1466
- var noise_terrace_node_default = NoiseTerraceNode;
1467
- // Annotate the CommonJS export names for ESM import in node:
1468
- 0 && (module.exports = {
1469
- NoiseAbsNode,
1470
- NoiseClampNode,
1471
- NoiseCombineNode,
1472
- NoiseCurveNode,
1473
- NoiseExponentNode,
1474
- NoiseInvertNode,
1475
- NoiseNormalizeNode,
1476
- NoiseScaleBiasNode,
1477
- NoiseTerraceNode
1478
- });
1
+ var pe=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Ve=Object.prototype.hasOwnProperty;var Ge=(e,a)=>{for(var o in a)pe(e,o,{get:a[o],enumerable:!0})},Ae=(e,a,o,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let t of Ue(a))!Ve.call(e,t)&&t!==o&&pe(e,t,{get:()=>a[t],enumerable:!(d=Te(a,t))||d.enumerable});return e};var $e=e=>Ae(pe({},"__esModule",{value:!0}),e);var Qe={};Ge(Qe,{NoiseAbsNode:()=>ce,NoiseClampNode:()=>Ce,NoiseCombineNode:()=>ge,NoiseCurveNode:()=>Ie,NoiseExponentNode:()=>ye,NoiseInvertNode:()=>Me,NoiseNormalizeNode:()=>we,NoiseScaleBiasNode:()=>Be,NoiseTerraceNode:()=>ze});module.exports=$e(Qe);var F=require("@awesome-flow/core/hooks"),X=require("@awesome-flow/core/layout"),le=require("libnoise-simplex-ts"),Ne=require("react"),ue=require("react/jsx-runtime");function Oe({id:e,selected:a,data:o,type:d}){let t=(0,F.useIncomingComputedData)(e),m=(0,F.useUpdateNodeComputedData)();return(0,Ne.useEffect)(()=>{if(t?.length>0){let r=new le.Abs(t[0].module);m(e,{module:r})}},[t]),(0,ue.jsx)(X.NodeContainer,{id:e,selected:a,data:o,type:d,children:(0,ue.jsx)(X.NodeTrackConnections,{handles:o.handles,nodeId:e,type:"target"})})}var ce=Oe;var E=require("@awesome-flow/core/hooks"),W=require("@awesome-flow/core/layout"),M=require("@mantine/core"),fe=require("libnoise-simplex-ts"),O=require("react"),y=require("react/jsx-runtime");function Re({id:e,selected:a,data:o,type:d}){let[t,m]=(0,O.useState)(o.lowerBound),[r,i]=(0,O.useState)(o.upperBound),s=(0,E.useIncomingComputedData)(e),p=(0,E.useUpdateNodeData)(),h=(0,E.useUpdateNodeComputedData)();return(0,O.useEffect)(()=>{if(s?.length){let n=new fe.Clamp(s[0].module,t,r);h(e,{module:n})}p(e,{lowerBound:t,upperBound:r})},[s,t,r]),(0,y.jsxs)(W.NodeContainer,{id:e,selected:a,data:o,type:d,children:[(0,y.jsx)(M.Stack,{children:(0,y.jsxs)(M.Group,{children:[(0,y.jsx)(M.NumberInput,{size:"xs",w:100,value:t,onChange:n=>m(Number(n)),step:.1}),(0,y.jsx)(M.NumberInput,{size:"xs",w:100,value:r,onChange:n=>i(Number(n)),step:.1})]})}),(0,y.jsx)(W.NodeTrackConnections,{handles:o.handles,nodeId:e,type:"target"})]})}var Ce=Re;var P=require("@awesome-flow/core/hooks"),z=require("@awesome-flow/core/layout"),D=require("@tabler/icons-react"),_=require("react");var f=require("libnoise-simplex-ts");var De={add:f.Add,max:f.Max,min:f.Min,multiply:f.Multiply,power:f.Power};var C=require("react/jsx-runtime"),Le={add:(0,C.jsx)(D.IconPlus,{}),min:(0,C.jsx)(D.IconChevronLeft,{}),max:(0,C.jsx)(D.IconChevronRight,{}),multiply:(0,C.jsx)(D.IconAsterisk,{}),power:(0,C.jsx)(D.IconChevronUp,{})};function Fe({id:e,selected:a,data:o,type:d}){let t=(0,P.useUpdateNodeData)(),m=(0,P.useUpdateNodeComputedData)(),r=(0,P.useIncomingComputedData)(e);(0,_.useEffect)(()=>{let s=De[o.operation];if(r?.length>1){let p=new s(r[0].module,r[1].module);m(e,{module:p})}},[o.operation,r]);let i=(0,_.useCallback)(s=>{t(e,{operation:s})},[]);return(0,C.jsxs)(z.NodeContainer,{id:e,selected:a,data:o,type:d,children:[(0,C.jsx)(z.NodeCombobox,{options:Le,selected:o.operation,onChange:i,width:150}),(0,C.jsx)(z.NodeTrackConnections,{handles:o.handles,nodeId:e,type:"target"})]})}var ge=Fe;var de=require("@awesome-flow/core/abstract"),T=require("@awesome-flow/core/hooks"),H=require("@awesome-flow/core/layout"),c=require("@mantine/core"),J=require("@mantine/form"),q=require("@mantine/hooks"),he=require("@tabler/icons-react"),K=require("libnoise-simplex-ts"),x=require("react"),l=require("react/jsx-runtime");function Xe({id:e,selected:a,data:o,type:d}){let t=(0,T.useIncomingComputedData)(e),m=(0,T.useUpdateNodeData)(),r=(0,T.useUpdateNodeComputedData)(),[i,s]=(0,x.useState)([]),p=(0,J.useForm)({mode:"uncontrolled",initialValues:{points:[]},validateInputOnChange:[`points.${J.FORM_INDEX}.input`],clearInputErrorOnChange:!0,validate:{points:{input:(n,u)=>{let b={};return u.points.forEach(me=>{b[me.input]=(b[me.input]||0)+1}),b[n]>1}}},onValuesChange:(0,x.useCallback)(n=>{if(p.validate(),p.isValid()){let u=n.points.map(b=>({input:b.input,output:b.output}));s(u),m(e,{points:u})}},[])});(0,x.useEffect)(()=>{let n=o.points?.length?o.points.map(u=>({input:u.input,output:u.output,key:(0,q.randomId)()})):[1,2,3,4].map(()=>({input:0,output:0,key:(0,q.randomId)()}));p.initialize({points:n})},[]),(0,x.useEffect)(()=>{if(t?.length&&i?.length>=4){let n=new K.Curve(t[0].module,i.map(u=>new K.Tuple(u.input,u.output)));r(e,{module:n})}},[i,t]);let h=p.getValues().points.map((n,u)=>(0,l.jsxs)(c.Group,{mt:"xs",children:[(0,l.jsx)(c.NumberInput,{size:"xs",w:100,placeholder:"Input Value",...p.getInputProps(`points.${u}.input`),step:.1},p.key(`points.${u}.input`)),(0,l.jsx)(c.NumberInput,{size:"xs",w:100,placeholder:"Output Value",...p.getInputProps(`points.${u}.output`),step:.1},p.key(`points.${u}.output`)),o.state===de.NodeState.edit&&i.length>4&&(0,l.jsx)(c.ActionIcon,{color:"red",variant:"outline",size:"sm",onClick:()=>p.removeListItem("points",u),children:(0,l.jsx)(he.IconX,{size:"1rem"})})]},n.key));return(0,l.jsxs)(H.NodeContainer,{id:e,selected:a,type:d,data:o,children:[h,o.state===de.NodeState.edit&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(c.Space,{h:10}),(0,l.jsx)(c.Button,{variant:"outline",size:"xs",fullWidth:!0,onClick:()=>p.insertListItem("points",{input:0,output:0,key:(0,q.randomId)()}),children:"Add control point"})]}),(0,l.jsx)(H.NodeTrackConnections,{handles:o.handles,nodeId:e,type:"target"})]})}var Ie=Xe;var U=require("@awesome-flow/core/hooks"),Q=require("@awesome-flow/core/layout"),V=require("@mantine/core"),be=require("libnoise-simplex-ts"),Y=require("react"),w=require("react/jsx-runtime");function We({id:e,selected:a,data:o,type:d}){let[t,m]=(0,Y.useState)(o.exponent),r=(0,U.useIncomingComputedData)(e),i=(0,U.useUpdateNodeData)(),s=(0,U.useUpdateNodeComputedData)();return(0,Y.useEffect)(()=>{if(r?.length>0){let p=new be.Exponent(r[0].module,t);s(e,{module:p})}i(e,{exponent:t})},[r,t]),(0,w.jsxs)(Q.NodeContainer,{id:e,selected:a,data:o,type:d,children:[(0,w.jsx)(V.Stack,{children:(0,w.jsxs)(V.Group,{children:["Exponent:",(0,w.jsx)(V.NumberInput,{size:"xs",value:t,onChange:p=>m(Number(p)),step:.1})]})}),(0,w.jsx)(Q.NodeTrackConnections,{handles:o.handles,nodeId:e,type:"target"})]})}var ye=We;var Z=require("@awesome-flow/core/hooks"),j=require("@awesome-flow/core/layout"),ke=require("libnoise-simplex-ts"),ve=require("react"),se=require("react/jsx-runtime");function _e({id:e,selected:a,data:o,type:d}){let t=(0,Z.useIncomingComputedData)(e),m=(0,Z.useUpdateNodeComputedData)();return(0,ve.useEffect)(()=>{if(t?.length>0){let r=new ke.Invert(t[0].module);m(e,{module:r})}},[t]),(0,se.jsx)(j.NodeContainer,{id:e,selected:a,data:o,type:d,children:(0,se.jsx)(j.NodeTrackConnections,{handles:o.handles,nodeId:e,type:"target"})})}var Me=_e;var G=require("@awesome-flow/core/hooks"),oe=require("@awesome-flow/core/layout"),S=require("@mantine/core"),R=require("react");var xe=require("libnoise-simplex-ts"),ee=class extends xe.ModifierModule{constructor(o,d,t){super(o);this.lowerBound=d;this.upperBound=t}getValue(o,d,t){return qe(this.sourceModule.getValue(o,d,t),this.lowerBound,this.upperBound)}};function qe(e,a,o){return(e-a)/(o-a)}var k=require("react/jsx-runtime");function He({id:e,selected:a,data:o,type:d}){let[t,m]=(0,R.useState)(o.intervalStart),[r,i]=(0,R.useState)(o.intervalEnd),s=(0,G.useIncomingComputedData)(e),p=(0,G.useUpdateNodeData)(),h=(0,G.useUpdateNodeComputedData)();return(0,R.useEffect)(()=>{if(s?.length){let n=s[0].module,u=new ee(n,t,r);h(e,{module:u})}p(e,{intervalStart:t,intervalEnd:r})},[s,t,r]),(0,k.jsxs)(oe.NodeContainer,{id:e,selected:a,data:o,type:d,children:[(0,k.jsx)(S.Stack,{children:(0,k.jsxs)(S.Group,{children:[(0,k.jsx)(S.NumberInput,{size:"xs",w:100,value:t,onChange:n=>m(Number(n))}),(0,k.jsx)(S.NumberInput,{size:"xs",w:100,value:r,onChange:n=>i(Number(n))})]})}),(0,k.jsx)(oe.NodeTrackConnections,{handles:o.handles,nodeId:e,type:"target"})]})}var we=He;var A=require("@awesome-flow/core/hooks"),te=require("@awesome-flow/core/layout"),v=require("@mantine/core"),Se=require("libnoise-simplex-ts"),L=require("react"),I=require("react/jsx-runtime");function Je({id:e,selected:a,data:o,type:d}){let[t,m]=(0,L.useState)(o.scale),[r,i]=(0,L.useState)(o.bias),s=(0,A.useIncomingComputedData)(e),p=(0,A.useUpdateNodeData)(),h=(0,A.useUpdateNodeComputedData)();return(0,L.useEffect)(()=>{if(s?.length>0){let n=new Se.ScaleBias(s[0].module,t,r);h(e,{module:n})}p(e,{scale:t,bias:r})},[s,t,r]),(0,I.jsxs)(te.NodeContainer,{id:e,selected:a,data:o,type:d,children:[(0,I.jsxs)(v.Stack,{children:[(0,I.jsxs)(v.Group,{children:["Scale:",(0,I.jsx)(v.NumberInput,{size:"xs",w:100,value:t,onChange:n=>m(Number(n)),step:.1})]}),(0,I.jsxs)(v.Group,{children:["Bias:",(0,I.jsx)(v.NumberInput,{size:"xs",w:100,value:r,onChange:n=>i(Number(n)),step:.1})]})]}),(0,I.jsx)(te.NodeTrackConnections,{handles:o.handles,nodeId:e,type:"target"})]})}var Be=Je;var ie=require("@awesome-flow/core/abstract"),$=require("@awesome-flow/core/hooks"),ae=require("@awesome-flow/core/layout"),g=require("@mantine/core"),re=require("@mantine/form"),ne=require("@mantine/hooks"),Ee=require("@tabler/icons-react"),Pe=require("libnoise-simplex-ts"),B=require("react"),N=require("react/jsx-runtime");function Ke({id:e,selected:a,data:o,type:d}){let t=(0,$.useIncomingComputedData)(e),m=(0,$.useUpdateNodeData)(),r=(0,$.useUpdateNodeComputedData)(),[i,s]=(0,B.useState)([]),p=(0,re.useForm)({mode:"uncontrolled",initialValues:{points:[]},validateInputOnChange:[`points.${re.FORM_INDEX}.input`],clearInputErrorOnChange:!0,onValuesChange:(0,B.useCallback)(n=>{if(p.isValid()){let u=n.points.map(b=>b.value);s(u),m(e,{points:u})}p.validate()},[])});(0,B.useEffect)(()=>{let n=o.points?.length?o.points.map(u=>({value:u,key:(0,ne.randomId)()})):[1,2].map(()=>({value:0,key:(0,ne.randomId)()}));p.initialize({points:n})},[]),(0,B.useEffect)(()=>{if(t?.length&&i?.length>=2){let n=new Pe.Terrace(t[0].module,i);r(e,{module:n})}},[i,t]);let h=p.getValues().points.map((n,u)=>(0,N.jsxs)(g.Group,{mt:"xs",children:[(0,N.jsx)(g.NumberInput,{size:"xs",placeholder:"Input Value",...p.getInputProps(`points.${u}.value`),step:.1},p.key(`points.${u}.value`)),o.state===ie.NodeState.edit&&i.length>2&&(0,N.jsx)(g.ActionIcon,{color:"red",variant:"outline",size:"sm",onClick:()=>p.removeListItem("points",u),children:(0,N.jsx)(Ee.IconX,{size:"1rem"})})]},n.key));return(0,N.jsxs)(ae.NodeContainer,{id:e,selected:a,type:d,data:o,children:[h,o.state===ie.NodeState.edit&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(g.Space,{h:10}),(0,N.jsx)(g.Button,{variant:"outline",size:"xs",fullWidth:!0,onClick:()=>p.insertListItem("points",{value:0,key:(0,ne.randomId)()}),children:"Add control point"})]}),(0,N.jsx)(ae.NodeTrackConnections,{handles:o.handles,nodeId:e,type:"target"})]})}var ze=Ke;0&&(module.exports={NoiseAbsNode,NoiseClampNode,NoiseCombineNode,NoiseCurveNode,NoiseExponentNode,NoiseInvertNode,NoiseNormalizeNode,NoiseScaleBiasNode,NoiseTerraceNode});