@reformer/core 1.0.0-beta.3

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 (150) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/dist/behaviors.d.ts +2 -0
  4. package/dist/behaviors.js +230 -0
  5. package/dist/core/behavior/behavior-applicator.d.ts +71 -0
  6. package/dist/core/behavior/behavior-applicator.js +92 -0
  7. package/dist/core/behavior/behavior-context.d.ts +29 -0
  8. package/dist/core/behavior/behavior-context.js +38 -0
  9. package/dist/core/behavior/behavior-registry.d.ts +97 -0
  10. package/dist/core/behavior/behavior-registry.js +198 -0
  11. package/dist/core/behavior/behaviors/compute-from.d.ts +41 -0
  12. package/dist/core/behavior/behaviors/compute-from.js +84 -0
  13. package/dist/core/behavior/behaviors/copy-from.d.ts +31 -0
  14. package/dist/core/behavior/behaviors/copy-from.js +64 -0
  15. package/dist/core/behavior/behaviors/enable-when.d.ts +49 -0
  16. package/dist/core/behavior/behaviors/enable-when.js +81 -0
  17. package/dist/core/behavior/behaviors/index.d.ts +11 -0
  18. package/dist/core/behavior/behaviors/index.js +11 -0
  19. package/dist/core/behavior/behaviors/reset-when.d.ts +51 -0
  20. package/dist/core/behavior/behaviors/reset-when.js +63 -0
  21. package/dist/core/behavior/behaviors/revalidate-when.d.ts +30 -0
  22. package/dist/core/behavior/behaviors/revalidate-when.js +51 -0
  23. package/dist/core/behavior/behaviors/sync-fields.d.ts +28 -0
  24. package/dist/core/behavior/behaviors/sync-fields.js +66 -0
  25. package/dist/core/behavior/behaviors/transform-value.d.ts +120 -0
  26. package/dist/core/behavior/behaviors/transform-value.js +110 -0
  27. package/dist/core/behavior/behaviors/watch-field.d.ts +35 -0
  28. package/dist/core/behavior/behaviors/watch-field.js +56 -0
  29. package/dist/core/behavior/compose-behavior.d.ts +106 -0
  30. package/dist/core/behavior/compose-behavior.js +166 -0
  31. package/dist/core/behavior/create-field-path.d.ts +20 -0
  32. package/dist/core/behavior/create-field-path.js +69 -0
  33. package/dist/core/behavior/index.d.ts +12 -0
  34. package/dist/core/behavior/index.js +17 -0
  35. package/dist/core/behavior/types.d.ts +152 -0
  36. package/dist/core/behavior/types.js +7 -0
  37. package/dist/core/context/form-context-impl.d.ts +29 -0
  38. package/dist/core/context/form-context-impl.js +37 -0
  39. package/dist/core/factories/index.d.ts +6 -0
  40. package/dist/core/factories/index.js +6 -0
  41. package/dist/core/factories/node-factory.d.ts +209 -0
  42. package/dist/core/factories/node-factory.js +281 -0
  43. package/dist/core/nodes/array-node.d.ts +308 -0
  44. package/dist/core/nodes/array-node.js +534 -0
  45. package/dist/core/nodes/field-node.d.ts +269 -0
  46. package/dist/core/nodes/field-node.js +510 -0
  47. package/dist/core/nodes/form-node.d.ts +342 -0
  48. package/dist/core/nodes/form-node.js +343 -0
  49. package/dist/core/nodes/group-node/field-registry.d.ts +191 -0
  50. package/dist/core/nodes/group-node/field-registry.js +215 -0
  51. package/dist/core/nodes/group-node/index.d.ts +11 -0
  52. package/dist/core/nodes/group-node/index.js +11 -0
  53. package/dist/core/nodes/group-node/proxy-builder.d.ts +71 -0
  54. package/dist/core/nodes/group-node/proxy-builder.js +161 -0
  55. package/dist/core/nodes/group-node/state-manager.d.ts +184 -0
  56. package/dist/core/nodes/group-node/state-manager.js +265 -0
  57. package/dist/core/nodes/group-node.d.ts +494 -0
  58. package/dist/core/nodes/group-node.js +770 -0
  59. package/dist/core/types/deep-schema.d.ts +78 -0
  60. package/dist/core/types/deep-schema.js +11 -0
  61. package/dist/core/types/field-path.d.ts +42 -0
  62. package/dist/core/types/field-path.js +4 -0
  63. package/dist/core/types/form-context.d.ts +83 -0
  64. package/dist/core/types/form-context.js +25 -0
  65. package/dist/core/types/group-node-proxy.d.ts +135 -0
  66. package/dist/core/types/group-node-proxy.js +31 -0
  67. package/dist/core/types/index.d.ts +163 -0
  68. package/dist/core/types/index.js +4 -0
  69. package/dist/core/types/validation-schema.d.ts +104 -0
  70. package/dist/core/types/validation-schema.js +10 -0
  71. package/dist/core/utils/create-form.d.ts +61 -0
  72. package/dist/core/utils/create-form.js +24 -0
  73. package/dist/core/utils/debounce.d.ts +160 -0
  74. package/dist/core/utils/debounce.js +197 -0
  75. package/dist/core/utils/error-handler.d.ts +180 -0
  76. package/dist/core/utils/error-handler.js +226 -0
  77. package/dist/core/utils/field-path-navigator.d.ts +240 -0
  78. package/dist/core/utils/field-path-navigator.js +374 -0
  79. package/dist/core/utils/index.d.ts +14 -0
  80. package/dist/core/utils/index.js +14 -0
  81. package/dist/core/utils/registry-helpers.d.ts +50 -0
  82. package/dist/core/utils/registry-helpers.js +79 -0
  83. package/dist/core/utils/registry-stack.d.ts +69 -0
  84. package/dist/core/utils/registry-stack.js +86 -0
  85. package/dist/core/utils/resources.d.ts +41 -0
  86. package/dist/core/utils/resources.js +69 -0
  87. package/dist/core/utils/subscription-manager.d.ts +180 -0
  88. package/dist/core/utils/subscription-manager.js +214 -0
  89. package/dist/core/utils/type-guards.d.ts +116 -0
  90. package/dist/core/utils/type-guards.js +169 -0
  91. package/dist/core/validation/core/apply-when.d.ts +28 -0
  92. package/dist/core/validation/core/apply-when.js +41 -0
  93. package/dist/core/validation/core/apply.d.ts +63 -0
  94. package/dist/core/validation/core/apply.js +38 -0
  95. package/dist/core/validation/core/index.d.ts +8 -0
  96. package/dist/core/validation/core/index.js +8 -0
  97. package/dist/core/validation/core/validate-async.d.ts +42 -0
  98. package/dist/core/validation/core/validate-async.js +45 -0
  99. package/dist/core/validation/core/validate-tree.d.ts +35 -0
  100. package/dist/core/validation/core/validate-tree.js +37 -0
  101. package/dist/core/validation/core/validate.d.ts +32 -0
  102. package/dist/core/validation/core/validate.js +38 -0
  103. package/dist/core/validation/field-path.d.ts +43 -0
  104. package/dist/core/validation/field-path.js +147 -0
  105. package/dist/core/validation/index.d.ts +21 -0
  106. package/dist/core/validation/index.js +33 -0
  107. package/dist/core/validation/validate-form.d.ts +85 -0
  108. package/dist/core/validation/validate-form.js +152 -0
  109. package/dist/core/validation/validation-applicator.d.ts +89 -0
  110. package/dist/core/validation/validation-applicator.js +217 -0
  111. package/dist/core/validation/validation-context.d.ts +47 -0
  112. package/dist/core/validation/validation-context.js +75 -0
  113. package/dist/core/validation/validation-registry.d.ts +156 -0
  114. package/dist/core/validation/validation-registry.js +298 -0
  115. package/dist/core/validation/validators/array-validators.d.ts +63 -0
  116. package/dist/core/validation/validators/array-validators.js +86 -0
  117. package/dist/core/validation/validators/date.d.ts +38 -0
  118. package/dist/core/validation/validators/date.js +117 -0
  119. package/dist/core/validation/validators/email.d.ts +44 -0
  120. package/dist/core/validation/validators/email.js +60 -0
  121. package/dist/core/validation/validators/index.d.ts +14 -0
  122. package/dist/core/validation/validators/index.js +14 -0
  123. package/dist/core/validation/validators/max-length.d.ts +45 -0
  124. package/dist/core/validation/validators/max-length.js +60 -0
  125. package/dist/core/validation/validators/max.d.ts +45 -0
  126. package/dist/core/validation/validators/max.js +60 -0
  127. package/dist/core/validation/validators/min-length.d.ts +45 -0
  128. package/dist/core/validation/validators/min-length.js +60 -0
  129. package/dist/core/validation/validators/min.d.ts +45 -0
  130. package/dist/core/validation/validators/min.js +60 -0
  131. package/dist/core/validation/validators/number.d.ts +38 -0
  132. package/dist/core/validation/validators/number.js +90 -0
  133. package/dist/core/validation/validators/pattern.d.ts +47 -0
  134. package/dist/core/validation/validators/pattern.js +62 -0
  135. package/dist/core/validation/validators/phone.d.ts +34 -0
  136. package/dist/core/validation/validators/phone.js +58 -0
  137. package/dist/core/validation/validators/required.d.ts +48 -0
  138. package/dist/core/validation/validators/required.js +69 -0
  139. package/dist/core/validation/validators/url.d.ts +29 -0
  140. package/dist/core/validation/validators/url.js +55 -0
  141. package/dist/create-field-path-CdPF3lIK.js +704 -0
  142. package/dist/hooks/useFormControl.d.ts +48 -0
  143. package/dist/hooks/useFormControl.js +298 -0
  144. package/dist/index.d.ts +10 -0
  145. package/dist/index.js +8 -0
  146. package/dist/node-factory-D7DOnSSN.js +3200 -0
  147. package/dist/validators.d.ts +2 -0
  148. package/dist/validators.js +298 -0
  149. package/llms.txt +847 -0
  150. package/package.json +86 -0
@@ -0,0 +1,704 @@
1
+ var P = Symbol.for("preact-signals");
2
+ function w() {
3
+ if (d > 1)
4
+ d--;
5
+ else {
6
+ for (var i, t = !1; l !== void 0; ) {
7
+ var e = l;
8
+ for (l = void 0, x++; e !== void 0; ) {
9
+ var n = e.o;
10
+ if (e.o = void 0, e.f &= -3, !(8 & e.f) && _(e)) try {
11
+ e.c();
12
+ } catch (o) {
13
+ t || (i = o, t = !0);
14
+ }
15
+ e = n;
16
+ }
17
+ }
18
+ if (x = 0, d--, t) throw i;
19
+ }
20
+ }
21
+ var r = void 0;
22
+ function C(i) {
23
+ var t = r;
24
+ r = void 0;
25
+ try {
26
+ return i();
27
+ } finally {
28
+ r = t;
29
+ }
30
+ }
31
+ var l = void 0, d = 0, x = 0, y = 0;
32
+ function k(i) {
33
+ if (r !== void 0) {
34
+ var t = i.n;
35
+ if (t === void 0 || t.t !== r)
36
+ return t = { i: 0, S: i, p: r.s, n: void 0, t: r, e: void 0, x: void 0, r: t }, r.s !== void 0 && (r.s.n = t), r.s = t, i.n = t, 32 & r.f && i.S(t), t;
37
+ if (t.i === -1)
38
+ return t.i = 0, t.n !== void 0 && (t.n.p = t.p, t.p !== void 0 && (t.p.n = t.n), t.p = r.s, t.n = void 0, r.s.n = t, r.s = t), t;
39
+ }
40
+ }
41
+ function c(i, t) {
42
+ this.v = i, this.i = 0, this.n = void 0, this.t = void 0, this.W = t?.watched, this.Z = t?.unwatched, this.name = t?.name;
43
+ }
44
+ c.prototype.brand = P;
45
+ c.prototype.h = function() {
46
+ return !0;
47
+ };
48
+ c.prototype.S = function(i) {
49
+ var t = this, e = this.t;
50
+ e !== i && i.e === void 0 && (i.x = e, this.t = i, e !== void 0 ? e.e = i : C(function() {
51
+ var n;
52
+ (n = t.W) == null || n.call(t);
53
+ }));
54
+ };
55
+ c.prototype.U = function(i) {
56
+ var t = this;
57
+ if (this.t !== void 0) {
58
+ var e = i.e, n = i.x;
59
+ e !== void 0 && (e.x = n, i.e = void 0), n !== void 0 && (n.e = e, i.x = void 0), i === this.t && (this.t = n, n === void 0 && C(function() {
60
+ var o;
61
+ (o = t.Z) == null || o.call(t);
62
+ }));
63
+ }
64
+ };
65
+ c.prototype.subscribe = function(i) {
66
+ var t = this;
67
+ return F(function() {
68
+ var e = t.value, n = r;
69
+ r = void 0;
70
+ try {
71
+ i(e);
72
+ } finally {
73
+ r = n;
74
+ }
75
+ }, { name: "sub" });
76
+ };
77
+ c.prototype.valueOf = function() {
78
+ return this.value;
79
+ };
80
+ c.prototype.toString = function() {
81
+ return this.value + "";
82
+ };
83
+ c.prototype.toJSON = function() {
84
+ return this.value;
85
+ };
86
+ c.prototype.peek = function() {
87
+ var i = r;
88
+ r = void 0;
89
+ try {
90
+ return this.value;
91
+ } finally {
92
+ r = i;
93
+ }
94
+ };
95
+ Object.defineProperty(c.prototype, "value", { get: function() {
96
+ var i = k(this);
97
+ return i !== void 0 && (i.i = this.i), this.v;
98
+ }, set: function(i) {
99
+ if (i !== this.v) {
100
+ if (x > 100) throw new Error("Cycle detected");
101
+ this.v = i, this.i++, y++, d++;
102
+ try {
103
+ for (var t = this.t; t !== void 0; t = t.x) t.t.N();
104
+ } finally {
105
+ w();
106
+ }
107
+ }
108
+ } });
109
+ function O(i, t) {
110
+ return new c(i, t);
111
+ }
112
+ function _(i) {
113
+ for (var t = i.s; t !== void 0; t = t.n) if (t.S.i !== t.i || !t.S.h() || t.S.i !== t.i) return !0;
114
+ return !1;
115
+ }
116
+ function b(i) {
117
+ for (var t = i.s; t !== void 0; t = t.n) {
118
+ var e = t.S.n;
119
+ if (e !== void 0 && (t.r = e), t.S.n = t, t.i = -1, t.n === void 0) {
120
+ i.s = t;
121
+ break;
122
+ }
123
+ }
124
+ }
125
+ function V(i) {
126
+ for (var t = i.s, e = void 0; t !== void 0; ) {
127
+ var n = t.p;
128
+ t.i === -1 ? (t.S.U(t), n !== void 0 && (n.n = t.n), t.n !== void 0 && (t.n.p = n)) : e = t, t.S.n = t.r, t.r !== void 0 && (t.r = void 0), t = n;
129
+ }
130
+ i.s = e;
131
+ }
132
+ function h(i, t) {
133
+ c.call(this, void 0), this.x = i, this.s = void 0, this.g = y - 1, this.f = 4, this.W = t?.watched, this.Z = t?.unwatched, this.name = t?.name;
134
+ }
135
+ h.prototype = new c();
136
+ h.prototype.h = function() {
137
+ if (this.f &= -3, 1 & this.f) return !1;
138
+ if ((36 & this.f) == 32 || (this.f &= -5, this.g === y)) return !0;
139
+ if (this.g = y, this.f |= 1, this.i > 0 && !_(this))
140
+ return this.f &= -2, !0;
141
+ var i = r;
142
+ try {
143
+ b(this), r = this;
144
+ var t = this.x();
145
+ (16 & this.f || this.v !== t || this.i === 0) && (this.v = t, this.f &= -17, this.i++);
146
+ } catch (e) {
147
+ this.v = e, this.f |= 16, this.i++;
148
+ }
149
+ return r = i, V(this), this.f &= -2, !0;
150
+ };
151
+ h.prototype.S = function(i) {
152
+ if (this.t === void 0) {
153
+ this.f |= 36;
154
+ for (var t = this.s; t !== void 0; t = t.n) t.S.S(t);
155
+ }
156
+ c.prototype.S.call(this, i);
157
+ };
158
+ h.prototype.U = function(i) {
159
+ if (this.t !== void 0 && (c.prototype.U.call(this, i), this.t === void 0)) {
160
+ this.f &= -33;
161
+ for (var t = this.s; t !== void 0; t = t.n) t.S.U(t);
162
+ }
163
+ };
164
+ h.prototype.N = function() {
165
+ if (!(2 & this.f)) {
166
+ this.f |= 6;
167
+ for (var i = this.t; i !== void 0; i = i.x) i.t.N();
168
+ }
169
+ };
170
+ Object.defineProperty(h.prototype, "value", { get: function() {
171
+ if (1 & this.f) throw new Error("Cycle detected");
172
+ var i = k(this);
173
+ if (this.h(), i !== void 0 && (i.i = this.i), 16 & this.f) throw this.v;
174
+ return this.v;
175
+ } });
176
+ function B(i, t) {
177
+ return new h(i, t);
178
+ }
179
+ function E(i) {
180
+ var t = i.u;
181
+ if (i.u = void 0, typeof t == "function") {
182
+ d++;
183
+ var e = r;
184
+ r = void 0;
185
+ try {
186
+ t();
187
+ } catch (n) {
188
+ throw i.f &= -2, i.f |= 8, S(i), n;
189
+ } finally {
190
+ r = e, w();
191
+ }
192
+ }
193
+ }
194
+ function S(i) {
195
+ for (var t = i.s; t !== void 0; t = t.n) t.S.U(t);
196
+ i.x = void 0, i.s = void 0, E(i);
197
+ }
198
+ function A(i) {
199
+ if (r !== this) throw new Error("Out-of-order effect");
200
+ V(this), r = i, this.f &= -2, 8 & this.f && S(this), w();
201
+ }
202
+ function u(i, t) {
203
+ this.x = i, this.u = void 0, this.s = void 0, this.o = void 0, this.f = 32, this.name = t?.name;
204
+ }
205
+ u.prototype.c = function() {
206
+ var i = this.S();
207
+ try {
208
+ if (8 & this.f || this.x === void 0) return;
209
+ var t = this.x();
210
+ typeof t == "function" && (this.u = t);
211
+ } finally {
212
+ i();
213
+ }
214
+ };
215
+ u.prototype.S = function() {
216
+ if (1 & this.f) throw new Error("Cycle detected");
217
+ this.f |= 1, this.f &= -9, E(this), b(this), d++;
218
+ var i = r;
219
+ return r = this, A.bind(this, i);
220
+ };
221
+ u.prototype.N = function() {
222
+ 2 & this.f || (this.f |= 2, this.o = l, l = this);
223
+ };
224
+ u.prototype.d = function() {
225
+ this.f |= 8, 1 & this.f || S(this);
226
+ };
227
+ u.prototype.dispose = function() {
228
+ this.d();
229
+ };
230
+ function F(i, t) {
231
+ var e = new u(i, t);
232
+ try {
233
+ e.c();
234
+ } catch (o) {
235
+ throw e.d(), o;
236
+ }
237
+ var n = e.d.bind(e);
238
+ return n[Symbol.dispose] = n, n;
239
+ }
240
+ class R {
241
+ stack = [];
242
+ /**
243
+ * Добавить элемент в стек
244
+ * @param item - Элемент для добавления
245
+ */
246
+ push(t) {
247
+ this.stack.push(t);
248
+ }
249
+ /**
250
+ * Извлечь элемент из стека
251
+ * @returns Извлеченный элемент или undefined если стек пуст
252
+ */
253
+ pop() {
254
+ return this.stack.pop();
255
+ }
256
+ /**
257
+ * Получить текущий элемент (вершину стека) без извлечения
258
+ * @returns Текущий элемент или null если стек пуст
259
+ */
260
+ getCurrent() {
261
+ return this.stack.length > 0 ? this.stack[this.stack.length - 1] : null;
262
+ }
263
+ /**
264
+ * Извлечь элемент из стека с проверкой
265
+ * Выводит предупреждение в DEV режиме если извлеченный элемент не совпадает с ожидаемым
266
+ *
267
+ * @param expected - Ожидаемый элемент
268
+ * @param name - Имя реестра для отладки (например, 'ValidationRegistry')
269
+ */
270
+ verify(t, e) {
271
+ this.pop();
272
+ }
273
+ /**
274
+ * Получить длину стека
275
+ * @returns Количество элементов в стеке
276
+ */
277
+ get length() {
278
+ return this.stack.length;
279
+ }
280
+ /**
281
+ * Проверить, пуст ли стек
282
+ * @returns true если стек пуст
283
+ */
284
+ isEmpty() {
285
+ return this.stack.length === 0;
286
+ }
287
+ /**
288
+ * Очистить стек
289
+ */
290
+ clear() {
291
+ this.stack = [];
292
+ }
293
+ }
294
+ class I {
295
+ validators = [];
296
+ conditionStack = [];
297
+ /**
298
+ * Добавить валидатор в контекст
299
+ */
300
+ addValidator(t) {
301
+ if (this.conditionStack.length > 0) {
302
+ const e = this.conditionStack[this.conditionStack.length - 1];
303
+ t.condition = e;
304
+ }
305
+ this.validators.push(t);
306
+ }
307
+ /**
308
+ * Войти в условный блок
309
+ */
310
+ enterCondition(t, e) {
311
+ this.conditionStack.push({ fieldPath: t, conditionFn: e });
312
+ }
313
+ /**
314
+ * Выйти из условного блока
315
+ */
316
+ exitCondition() {
317
+ this.conditionStack.pop();
318
+ }
319
+ /**
320
+ * Получить все зарегистрированные валидаторы
321
+ */
322
+ getValidators() {
323
+ return this.validators;
324
+ }
325
+ }
326
+ class f {
327
+ /**
328
+ * Global stack активных реестров
329
+ * Используется для изоляции форм друг от друга
330
+ */
331
+ static registryStack = new R();
332
+ contextStack = [];
333
+ validators = [];
334
+ /**
335
+ * Получить текущий активный реестр из global stack
336
+ *
337
+ * @returns Текущий активный реестр или null
338
+ *
339
+ * @example
340
+ * ```typescript
341
+ * // В schema-validators.ts
342
+ * export function required(...) {
343
+ * const registry = ValidationRegistry.getCurrent();
344
+ * if (registry) {
345
+ * registry.registerSync(...);
346
+ * }
347
+ * }
348
+ * ```
349
+ */
350
+ static getCurrent() {
351
+ return f.registryStack.getCurrent();
352
+ }
353
+ /**
354
+ * Начать регистрацию валидаторов для формы
355
+ *
356
+ * Помещает this в global stack для изоляции форм
357
+ */
358
+ beginRegistration() {
359
+ const t = new I();
360
+ return this.contextStack.push(t), f.registryStack.push(this), t;
361
+ }
362
+ /**
363
+ * Завершить регистрацию и применить валидаторы к GroupNode
364
+ *
365
+ * Извлекает this из global stack
366
+ *
367
+ * Сохраняет валидаторы в локальном состоянии (this.validators) вместо глобального WeakMap.
368
+ */
369
+ endRegistration(t) {
370
+ const e = this.contextStack.pop();
371
+ if (!e)
372
+ throw new Error("No active registration context");
373
+ f.registryStack.verify(this, "ValidationRegistry"), this.validators = e.getValidators(), this.applyValidators(t, this.validators), this.applyArrayItemValidators(t, this.validators);
374
+ }
375
+ /**
376
+ * Отменить регистрацию без применения валидаторов
377
+ * Используется для временной валидации (например, в validateForm)
378
+ *
379
+ * Извлекает this из global stack
380
+ */
381
+ cancelRegistration() {
382
+ if (!this.contextStack.pop())
383
+ throw new Error("No active registration context to cancel");
384
+ f.registryStack.verify(this, "ValidationRegistry");
385
+ }
386
+ /**
387
+ * Получить текущий контекст регистрации
388
+ */
389
+ getCurrentContext() {
390
+ return this.contextStack[this.contextStack.length - 1];
391
+ }
392
+ /**
393
+ * Зарегистрировать синхронный валидатор
394
+ */
395
+ registerSync(t, e, n) {
396
+ const o = this.getCurrentContext();
397
+ if (!o)
398
+ throw new Error("Validators can only be registered inside a validation schema function");
399
+ o.addValidator({
400
+ fieldPath: t,
401
+ type: "sync",
402
+ validator: e,
403
+ options: n
404
+ });
405
+ }
406
+ /**
407
+ * Зарегистрировать асинхронный валидатор
408
+ */
409
+ registerAsync(t, e, n) {
410
+ const o = this.getCurrentContext();
411
+ if (!o)
412
+ throw new Error("Validators can only be registered inside a validation schema function");
413
+ o.addValidator({
414
+ fieldPath: t,
415
+ type: "async",
416
+ validator: e,
417
+ options: n
418
+ });
419
+ }
420
+ /**
421
+ * Зарегистрировать tree валидатор
422
+ */
423
+ registerTree(t, e) {
424
+ const n = this.getCurrentContext();
425
+ if (!n)
426
+ throw new Error("Validators can only be registered inside a validation schema function");
427
+ n.addValidator({
428
+ fieldPath: e?.targetField || "__tree__",
429
+ type: "tree",
430
+ validator: t,
431
+ options: e
432
+ });
433
+ }
434
+ /**
435
+ * Войти в условный блок
436
+ */
437
+ enterCondition(t, e) {
438
+ const n = this.getCurrentContext();
439
+ if (!n)
440
+ throw new Error("Conditions can only be used inside a validation schema function");
441
+ n.enterCondition(t, e);
442
+ }
443
+ /**
444
+ * Выйти из условного блока
445
+ */
446
+ exitCondition() {
447
+ const t = this.getCurrentContext();
448
+ if (!t)
449
+ throw new Error("No active condition");
450
+ t.exitCondition();
451
+ }
452
+ /**
453
+ * Зарегистрировать validation schema для элементов массива
454
+ *
455
+ * Используется функцией validateItems() для регистрации схемы валидации,
456
+ * которая будет применяться к каждому элементу ArrayNode.
457
+ *
458
+ * @param fieldPath - Путь к ArrayNode полю
459
+ * @param itemSchemaFn - Validation schema для элемента массива
460
+ */
461
+ registerArrayItemValidation(t, e) {
462
+ const n = this.getCurrentContext();
463
+ if (!n)
464
+ throw new Error(
465
+ "Array item validators can only be registered inside a validation schema function"
466
+ );
467
+ n.addValidator({
468
+ fieldPath: t,
469
+ type: "array-items",
470
+ validator: e,
471
+ options: {}
472
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
473
+ });
474
+ }
475
+ /**
476
+ * Получить зарегистрированные валидаторы для этого реестра
477
+ *
478
+ * Возвращает локальный массив валидаторов (без аргумента form).
479
+ */
480
+ getValidators() {
481
+ return this.validators;
482
+ }
483
+ /**
484
+ * Применить зарегистрированные валидаторы к GroupNode
485
+ * @private
486
+ */
487
+ applyValidators(t, e) {
488
+ const n = /* @__PURE__ */ new Map();
489
+ for (const o of e) {
490
+ if (o.type === "tree" || o.type === "array-items")
491
+ continue;
492
+ const a = n.get(o.fieldPath) || [];
493
+ a.push(o), n.set(o.fieldPath, a);
494
+ }
495
+ }
496
+ /**
497
+ * Применить array-items validators к ArrayNode элементам
498
+ * @private
499
+ */
500
+ applyArrayItemValidators(t, e) {
501
+ const n = e.filter((o) => o.type === "array-items");
502
+ if (n.length !== 0)
503
+ for (const o of n) {
504
+ const a = t[o.fieldPath.split(".")[0]];
505
+ if (a && "applyValidationSchema" in a) {
506
+ const s = o.validator;
507
+ a.applyValidationSchema(s);
508
+ }
509
+ }
510
+ }
511
+ }
512
+ class U {
513
+ /**
514
+ * Форма с типизированным Proxy-доступом к полям
515
+ */
516
+ form;
517
+ _form;
518
+ constructor(t) {
519
+ this._form = t;
520
+ const e = t._proxyInstance || t;
521
+ this.form = e;
522
+ }
523
+ /**
524
+ * Безопасно установить значение поля по строковому пути
525
+ *
526
+ * Автоматически использует emitEvent: false для предотвращения циклов
527
+ */
528
+ setFieldValue(t, e) {
529
+ const n = this._form.getFieldByPath(t);
530
+ n && n.setValue(e, { emitEvent: !1 });
531
+ }
532
+ }
533
+ class v {
534
+ /**
535
+ * Stack активных контекстов регистрации
536
+ * Используется для изоляции форм друг от друга
537
+ */
538
+ static contextStack = new R();
539
+ registrations = [];
540
+ isRegistering = !1;
541
+ /**
542
+ * Получить текущий активный реестр из context stack
543
+ *
544
+ * @returns Текущий активный реестр или null
545
+ *
546
+ * @example
547
+ * ```typescript
548
+ * // В schema-behaviors.ts
549
+ * export function copyFrom(...) {
550
+ * const registry = BehaviorRegistry.getCurrent();
551
+ * if (registry) {
552
+ * registry.register({ ... });
553
+ * }
554
+ * }
555
+ * ```
556
+ */
557
+ static getCurrent() {
558
+ return v.contextStack.getCurrent();
559
+ }
560
+ /**
561
+ * Начать регистрацию behaviors
562
+ * Вызывается перед применением схемы
563
+ *
564
+ * Помещает this в context stack для изоляции форм
565
+ */
566
+ beginRegistration() {
567
+ this.isRegistering = !0, this.registrations = [], v.contextStack.push(this);
568
+ }
569
+ /**
570
+ * Зарегистрировать behavior handler
571
+ * Вызывается функциями из schema-behaviors.ts
572
+ *
573
+ * @param handler - BehaviorHandlerFn функция
574
+ * @param options - Опции behavior (debounce)
575
+ *
576
+ * @example
577
+ * ```typescript
578
+ * const handler = createCopyBehavior(target, source, { when: ... });
579
+ * registry.register(handler, { debounce: 300 });
580
+ * ```
581
+ */
582
+ register(t, e) {
583
+ this.isRegistering && this.registrations.push({
584
+ // Type assertion безопасен: handler будет вызван с правильным типом формы в createEffect
585
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
586
+ handler: t,
587
+ debounce: e?.debounce
588
+ });
589
+ }
590
+ /**
591
+ * Завершить регистрацию и применить behaviors к форме
592
+ * Создает effect подписки для всех зарегистрированных behaviors
593
+ *
594
+ * Извлекает this из context stack
595
+ *
596
+ * @param form - GroupNode формы
597
+ * @returns Количество зарегистрированных behaviors и функция cleanup
598
+ */
599
+ endRegistration(t) {
600
+ this.isRegistering = !1, v.contextStack.verify(this, "BehaviorRegistry");
601
+ const e = new U(t), n = [];
602
+ for (const a of this.registrations) {
603
+ const s = this.createEffect(a, t, e);
604
+ s && n.push(s);
605
+ }
606
+ const o = () => {
607
+ n.forEach((a) => a());
608
+ };
609
+ return {
610
+ count: this.registrations.length,
611
+ cleanup: o
612
+ };
613
+ }
614
+ /**
615
+ * Создать effect подписку для behavior
616
+ * @private
617
+ */
618
+ createEffect(t, e, n) {
619
+ const { handler: o, debounce: a = 0 } = t;
620
+ let s = null;
621
+ const p = (m) => {
622
+ a > 0 ? (s && clearTimeout(s), s = setTimeout(m, a)) : m();
623
+ }, N = () => {
624
+ s && (clearTimeout(s), s = null);
625
+ }, g = o(e, n, p);
626
+ return g ? () => {
627
+ N(), g && g();
628
+ } : null;
629
+ }
630
+ }
631
+ function $() {
632
+ const i = f.getCurrent();
633
+ return i || {
634
+ registerSync: () => {
635
+ },
636
+ registerAsync: () => {
637
+ },
638
+ registerTree: () => {
639
+ },
640
+ enterCondition: () => {
641
+ },
642
+ exitCondition: () => {
643
+ },
644
+ registerArrayItemValidation: () => {
645
+ }
646
+ };
647
+ }
648
+ function D() {
649
+ const i = v.getCurrent();
650
+ return i || {
651
+ register: () => {
652
+ }
653
+ };
654
+ }
655
+ function W() {
656
+ return T("");
657
+ }
658
+ function T(i) {
659
+ return new Proxy(
660
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
661
+ {},
662
+ {
663
+ get(t, e) {
664
+ if (e === "__path" || e === "__fieldPath")
665
+ return i || e;
666
+ if (e === "__key") {
667
+ const a = i.split(".");
668
+ return a[a.length - 1] || e;
669
+ }
670
+ const n = i ? `${i}.${e}` : e, o = {
671
+ __path: n,
672
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
673
+ __key: e,
674
+ __formType: void 0,
675
+ __fieldType: void 0
676
+ };
677
+ return new Proxy(o, {
678
+ get(a, s) {
679
+ if (s === "__path" || s === "__fieldPath")
680
+ return n;
681
+ if (s === "__key")
682
+ return e;
683
+ if (s === "__formType" || s === "__fieldType")
684
+ return;
685
+ const p = `${n}.${s}`;
686
+ return T(p);
687
+ }
688
+ });
689
+ }
690
+ }
691
+ );
692
+ }
693
+ export {
694
+ v as B,
695
+ F as E,
696
+ R,
697
+ f as V,
698
+ D as a,
699
+ U as b,
700
+ W as c,
701
+ O as d,
702
+ $ as g,
703
+ B as w
704
+ };