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