attaform 0.27.6 → 0.29.0

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 (192) hide show
  1. package/dist/abstract.d.mts +5 -4
  2. package/dist/abstract.mjs +4 -3
  3. package/dist/chunks/fingerprint.mjs +1 -2
  4. package/dist/chunks/fingerprint2.mjs +2 -3
  5. package/dist/dev/abstract.mjs +4 -0
  6. package/dist/{chunks → dev/chunks}/dev-key-collision-warnings.mjs +0 -1
  7. package/dist/{chunks → dev/chunks}/devtools.mjs +5 -6
  8. package/dist/{chunks/fingerprint.cjs → dev/chunks/fingerprint.mjs} +7 -10
  9. package/dist/{chunks/fingerprint2.cjs → dev/chunks/fingerprint2.mjs} +32 -35
  10. package/dist/dev/directive.mjs +1 -0
  11. package/dist/dev/history.mjs +89 -0
  12. package/dist/dev/index.mjs +5 -0
  13. package/dist/dev/runtime/plugins/attaform.mjs +40 -0
  14. package/dist/dev/shared/attaform-dev.A-TpJW0B.mjs +207 -0
  15. package/dist/dev/shared/attaform-dev.BO-71R54.mjs +820 -0
  16. package/dist/{shared/attaform.D6tk90Rc.cjs → dev/shared/attaform-dev.BgM6FdtA.mjs} +324 -73
  17. package/dist/dev/shared/attaform-dev.ButTkwHd.mjs +375 -0
  18. package/dist/{shared/attaform.BJGA_UOS.mjs → dev/shared/attaform-dev.BxfsuwBR.mjs} +8 -1
  19. package/dist/{shared/attaform.nMaz2C5P.mjs → dev/shared/attaform-dev.D8aoKb89.mjs} +190 -400
  20. package/dist/dev/shared/attaform-dev.DD5m2W51.mjs +220 -0
  21. package/dist/{shared/attaform.CKH2lGdL.mjs → dev/shared/attaform-dev.DHuydLAC.mjs} +3867 -4731
  22. package/dist/{shared/attaform.DYEr28Pt.mjs → dev/shared/attaform-dev.DrzObAZo.mjs} +6 -7
  23. package/dist/{shared/attaform.B1ZYt2Li.mjs → dev/shared/attaform-dev.q6UutkCx.mjs} +274 -672
  24. package/dist/dev/zod-v3.mjs +17 -0
  25. package/dist/dev/zod-v4.mjs +16 -0
  26. package/dist/dev/zod.mjs +5 -0
  27. package/dist/directive.d.mts +20 -0
  28. package/dist/directive.mjs +1 -0
  29. package/dist/esbuild.mjs +0 -1
  30. package/dist/history.d.mts +59 -0
  31. package/dist/history.mjs +89 -0
  32. package/dist/index.d.mts +14 -6
  33. package/dist/index.mjs +5 -4
  34. package/dist/nuxt.d.mts +10 -10
  35. package/dist/nuxt.mjs +5 -2
  36. package/dist/rollup.mjs +0 -1
  37. package/dist/rspack.d.mts +6 -1
  38. package/dist/rspack.mjs +0 -1
  39. package/dist/runtime/components/AttaformDevtoolsPanel.vue +9 -8
  40. package/dist/runtime/plugins/attaform.mjs +1 -2
  41. package/dist/shared/{attaform.CoR4mWfv.mjs → attaform.B0dKL8ST.mjs} +309 -46
  42. package/dist/shared/{attaform.Cs2Rbdlo.mjs → attaform.BK0cgu2K.mjs} +123 -140
  43. package/dist/shared/{attaform.B9Wyhfro.cjs → attaform.BndjUUYX.mjs} +11 -16
  44. package/dist/shared/{attaform.CQN9R62B.cjs → attaform.BxfsuwBR.mjs} +9 -4
  45. package/dist/shared/attaform.C2MVyuxC.mjs +811 -0
  46. package/dist/shared/{attaform.Fp3sCrVs.d.ts → attaform.CIWLMY-R.d.mts} +2 -2
  47. package/dist/shared/attaform.CZMAYwSK.mjs +6383 -0
  48. package/dist/shared/attaform.CZYt_5N_.mjs +207 -0
  49. package/dist/shared/{attaform.DniawQLP.d.cts → attaform.CsoeRi3P.d.mts} +490 -98
  50. package/dist/shared/attaform.Cvao8bW5.mjs +358 -0
  51. package/dist/shared/attaform.D0x-qSXm.mjs +197 -0
  52. package/dist/shared/{attaform.D8kliaKw.cjs → attaform.D1fnTifF.mjs} +279 -692
  53. package/dist/shared/{attaform.CHlJLAiv.d.mts → attaform.DDtqHYv1.d.mts} +155 -184
  54. package/dist/shared/{attaform.Biytrv0-.cjs → attaform.DffRL5pP.mjs} +215 -547
  55. package/dist/shared/attaform.DhnPb6nK.mjs +0 -1
  56. package/dist/shared/attaform.KvlEedlF.mjs +0 -1
  57. package/dist/shared/attaform.axHXVQO7.d.mts +44 -0
  58. package/dist/shared/attaform.v0fQtWyA.mjs +0 -1
  59. package/dist/transforms.d.mts +0 -22
  60. package/dist/transforms.mjs +1 -2
  61. package/dist/vite.d.mts +30 -9
  62. package/dist/vite.mjs +27 -4
  63. package/dist/webpack.d.mts +6 -1
  64. package/dist/webpack.mjs +0 -1
  65. package/dist/zod-v3.d.mts +13 -6
  66. package/dist/zod-v3.mjs +17 -4
  67. package/dist/zod-v4.d.mts +19 -26
  68. package/dist/zod-v4.mjs +16 -4
  69. package/dist/zod.d.mts +4 -3
  70. package/dist/zod.mjs +5 -4
  71. package/package.json +38 -20
  72. package/skills/attaform/SKILL.md +6 -2
  73. package/skills/attaform/references/custom-components.md +7 -2
  74. package/skills/attaform/references/errors.md +8 -3
  75. package/skills/attaform/references/saving.md +77 -0
  76. package/skills/attaform/references/wizards.md +10 -8
  77. package/dist/abstract.cjs +0 -48
  78. package/dist/abstract.cjs.map +0 -1
  79. package/dist/abstract.d.cts +0 -42
  80. package/dist/abstract.d.ts +0 -42
  81. package/dist/abstract.mjs.map +0 -1
  82. package/dist/chunks/dev-key-collision-warnings.cjs +0 -25
  83. package/dist/chunks/dev-key-collision-warnings.cjs.map +0 -1
  84. package/dist/chunks/dev-key-collision-warnings.mjs.map +0 -1
  85. package/dist/chunks/devtools.cjs +0 -157
  86. package/dist/chunks/devtools.cjs.map +0 -1
  87. package/dist/chunks/devtools.mjs.map +0 -1
  88. package/dist/chunks/fingerprint.cjs.map +0 -1
  89. package/dist/chunks/fingerprint.mjs.map +0 -1
  90. package/dist/chunks/fingerprint2.cjs.map +0 -1
  91. package/dist/chunks/fingerprint2.mjs.map +0 -1
  92. package/dist/esbuild.cjs +0 -28
  93. package/dist/esbuild.cjs.map +0 -1
  94. package/dist/esbuild.d.cts +0 -56
  95. package/dist/esbuild.d.ts +0 -56
  96. package/dist/esbuild.mjs.map +0 -1
  97. package/dist/index.cjs +0 -51
  98. package/dist/index.cjs.map +0 -1
  99. package/dist/index.d.cts +0 -249
  100. package/dist/index.d.ts +0 -249
  101. package/dist/index.mjs.map +0 -1
  102. package/dist/nuxt.cjs +0 -84
  103. package/dist/nuxt.cjs.map +0 -1
  104. package/dist/nuxt.d.cts +0 -66
  105. package/dist/nuxt.d.ts +0 -66
  106. package/dist/nuxt.mjs.map +0 -1
  107. package/dist/rollup.cjs +0 -24
  108. package/dist/rollup.cjs.map +0 -1
  109. package/dist/rollup.d.cts +0 -35
  110. package/dist/rollup.d.ts +0 -35
  111. package/dist/rollup.mjs.map +0 -1
  112. package/dist/rspack.cjs +0 -10
  113. package/dist/rspack.cjs.map +0 -1
  114. package/dist/rspack.d.cts +0 -40
  115. package/dist/rspack.d.ts +0 -40
  116. package/dist/rspack.mjs.map +0 -1
  117. package/dist/runtime/components/AttaformDevtoolsPanel.vue.d.ts +0 -7
  118. package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +0 -35
  119. package/dist/runtime/plugins/attaform.cjs +0 -43
  120. package/dist/runtime/plugins/attaform.cjs.map +0 -1
  121. package/dist/runtime/plugins/attaform.d.cts +0 -5
  122. package/dist/runtime/plugins/attaform.d.ts +0 -5
  123. package/dist/runtime/plugins/attaform.mjs.map +0 -1
  124. package/dist/shared/attaform.B1ZYt2Li.mjs.map +0 -1
  125. package/dist/shared/attaform.B9Wyhfro.cjs.map +0 -1
  126. package/dist/shared/attaform.BGDV42hI.d.cts +0 -232
  127. package/dist/shared/attaform.BJGA_UOS.mjs.map +0 -1
  128. package/dist/shared/attaform.Biytrv0-.cjs.map +0 -1
  129. package/dist/shared/attaform.Bn0IzhD_.cjs +0 -800
  130. package/dist/shared/attaform.Bn0IzhD_.cjs.map +0 -1
  131. package/dist/shared/attaform.C9fPTxjB.d.cts +0 -41
  132. package/dist/shared/attaform.C9fPTxjB.d.ts +0 -41
  133. package/dist/shared/attaform.CKH2lGdL.mjs.map +0 -1
  134. package/dist/shared/attaform.CQN9R62B.cjs.map +0 -1
  135. package/dist/shared/attaform.CoR4mWfv.mjs.map +0 -1
  136. package/dist/shared/attaform.Cs2Rbdlo.mjs.map +0 -1
  137. package/dist/shared/attaform.D6tk90Rc.cjs.map +0 -1
  138. package/dist/shared/attaform.D8kliaKw.cjs.map +0 -1
  139. package/dist/shared/attaform.DLknk9nF.d.mts +0 -232
  140. package/dist/shared/attaform.DMxM2kol.mjs +0 -1275
  141. package/dist/shared/attaform.DMxM2kol.mjs.map +0 -1
  142. package/dist/shared/attaform.DRUT703x.d.cts +0 -56
  143. package/dist/shared/attaform.DRUT703x.d.ts +0 -56
  144. package/dist/shared/attaform.DYEr28Pt.mjs.map +0 -1
  145. package/dist/shared/attaform.DdQN7sgN.cjs +0 -1302
  146. package/dist/shared/attaform.DdQN7sgN.cjs.map +0 -1
  147. package/dist/shared/attaform.DhnPb6nK.mjs.map +0 -1
  148. package/dist/shared/attaform.DniawQLP.d.mts +0 -4763
  149. package/dist/shared/attaform.DniawQLP.d.ts +0 -4763
  150. package/dist/shared/attaform.DoQm_Vkd.cjs +0 -58
  151. package/dist/shared/attaform.DoQm_Vkd.cjs.map +0 -1
  152. package/dist/shared/attaform.DrvMscNX.cjs +0 -7697
  153. package/dist/shared/attaform.DrvMscNX.cjs.map +0 -1
  154. package/dist/shared/attaform.F2Q8iv38.d.ts +0 -2494
  155. package/dist/shared/attaform.FmqKO1Ex.d.cts +0 -2494
  156. package/dist/shared/attaform.KvlEedlF.mjs.map +0 -1
  157. package/dist/shared/attaform.RaTzp1WF.cjs +0 -26
  158. package/dist/shared/attaform.RaTzp1WF.cjs.map +0 -1
  159. package/dist/shared/attaform.nMaz2C5P.mjs.map +0 -1
  160. package/dist/shared/attaform.v0fQtWyA.mjs.map +0 -1
  161. package/dist/shared/attaform.yUrz7C2z.cjs +0 -29
  162. package/dist/shared/attaform.yUrz7C2z.cjs.map +0 -1
  163. package/dist/transforms.cjs +0 -12
  164. package/dist/transforms.cjs.map +0 -1
  165. package/dist/transforms.d.cts +0 -73
  166. package/dist/transforms.d.ts +0 -73
  167. package/dist/transforms.mjs.map +0 -1
  168. package/dist/vite.cjs +0 -363
  169. package/dist/vite.cjs.map +0 -1
  170. package/dist/vite.d.cts +0 -133
  171. package/dist/vite.d.ts +0 -133
  172. package/dist/vite.mjs.map +0 -1
  173. package/dist/webpack.cjs +0 -10
  174. package/dist/webpack.cjs.map +0 -1
  175. package/dist/webpack.d.cts +0 -37
  176. package/dist/webpack.d.ts +0 -37
  177. package/dist/webpack.mjs.map +0 -1
  178. package/dist/zod-v3.cjs +0 -53
  179. package/dist/zod-v3.cjs.map +0 -1
  180. package/dist/zod-v3.d.cts +0 -246
  181. package/dist/zod-v3.d.ts +0 -246
  182. package/dist/zod-v3.mjs.map +0 -1
  183. package/dist/zod-v4.cjs +0 -55
  184. package/dist/zod-v4.cjs.map +0 -1
  185. package/dist/zod-v4.d.cts +0 -172
  186. package/dist/zod-v4.d.ts +0 -172
  187. package/dist/zod-v4.mjs.map +0 -1
  188. package/dist/zod.cjs +0 -51
  189. package/dist/zod.cjs.map +0 -1
  190. package/dist/zod.d.cts +0 -7
  191. package/dist/zod.d.ts +0 -7
  192. package/dist/zod.mjs.map +0 -1
@@ -0,0 +1,358 @@
1
+ import { m as mapSegmentKeys, f as pathsEqual, i as isPathPrefix } from './attaform.CZYt_5N_.mjs';
2
+
3
+ const DEFAULT_FIELD_VALIDATION_DEBOUNCE_MS = 0;
4
+ const DEFAULT_HISTORY_MAX_SNAPSHOTS = 128;
5
+ const RESERVED_KEY_PREFIX = "__atta:";
6
+ const ANONYMOUS_FORM_KEY_PREFIX = `${RESERVED_KEY_PREFIX}anon:`;
7
+ const ANONYMOUS_WIZARD_KEY_PREFIX = `${RESERVED_KEY_PREFIX}anon-wizard:`;
8
+ const DEFAULT_MAX_RECURSION_DEPTH = 64;
9
+ function normalizeNumericOption(config) {
10
+ const { value, source, allowInfinity, min, defaultValue } = config;
11
+ if (allowInfinity && value === Infinity) return Infinity;
12
+ if (typeof value !== "number" || Number.isNaN(value) || value === Infinity || value === -Infinity) {
13
+ return defaultValue;
14
+ }
15
+ return Math.max(min, Math.floor(value));
16
+ }
17
+ function pickDefined(bag) {
18
+ const out = {};
19
+ for (const key of Object.keys(bag)) {
20
+ if (bag[key] !== void 0) out[key] = bag[key];
21
+ }
22
+ return out;
23
+ }
24
+
25
+ function callConsumerSchemaFn(fn, fallback, site) {
26
+ try {
27
+ return fn();
28
+ } catch (err) {
29
+ return fallback;
30
+ }
31
+ }
32
+ function readConsumerProp(obj, key) {
33
+ try {
34
+ return obj[key];
35
+ } catch {
36
+ return void 0;
37
+ }
38
+ }
39
+ function consumerKeys(obj) {
40
+ try {
41
+ return Object.keys(obj);
42
+ } catch {
43
+ return [];
44
+ }
45
+ }
46
+ function readConsumerIndex(arr, i) {
47
+ try {
48
+ return arr[i];
49
+ } catch {
50
+ return void 0;
51
+ }
52
+ }
53
+ function consumerSymbolKeys(obj) {
54
+ try {
55
+ return Object.getOwnPropertySymbols(obj);
56
+ } catch {
57
+ return [];
58
+ }
59
+ }
60
+ function consumerHas(obj, key) {
61
+ try {
62
+ return key in obj;
63
+ } catch {
64
+ return false;
65
+ }
66
+ }
67
+
68
+ function safeAssign(target, key, value) {
69
+ if (key === "__proto__") {
70
+ Object.defineProperty(target, key, {
71
+ value,
72
+ writable: true,
73
+ enumerable: true,
74
+ configurable: true
75
+ });
76
+ return;
77
+ }
78
+ target[key] = value;
79
+ }
80
+ function isShadowedKey(key) {
81
+ return key in Object.prototype;
82
+ }
83
+ function safeOwnRead(target, key) {
84
+ if (isShadowedKey(key)) {
85
+ const desc = Object.getOwnPropertyDescriptor(target, key);
86
+ if (desc === void 0) return void 0;
87
+ return "value" in desc ? desc.value : readConsumerProp(target, key);
88
+ }
89
+ return readConsumerProp(target, key);
90
+ }
91
+ function safeOwnHas(target, key) {
92
+ try {
93
+ return Object.prototype.hasOwnProperty.call(target, key);
94
+ } catch {
95
+ return false;
96
+ }
97
+ }
98
+ function spreadConsumerRecord(src) {
99
+ try {
100
+ return { ...src };
101
+ } catch {
102
+ const out = {};
103
+ for (const key of Object.keys(src)) {
104
+ safeAssign(out, key, readConsumerProp(src, key));
105
+ }
106
+ return out;
107
+ }
108
+ }
109
+ function copyConsumerArray(src) {
110
+ try {
111
+ return src.slice();
112
+ } catch {
113
+ const out = new Array(src.length);
114
+ for (let i = 0; i < src.length; i++) out[i] = readConsumerIndex(src, i);
115
+ return out;
116
+ }
117
+ }
118
+
119
+ function isDescendable(value) {
120
+ if (value === null || typeof value !== "object") return false;
121
+ if (Array.isArray(value)) return true;
122
+ if (value instanceof Map) return mapSegmentKeys(value) !== null;
123
+ const proto = Object.getPrototypeOf(value);
124
+ return proto === null || proto === Object.prototype;
125
+ }
126
+ function appendSegment(prefix, segment) {
127
+ const next = new Array(prefix.length + 1);
128
+ for (let i = 0; i < prefix.length; i++) {
129
+ const s = prefix[i];
130
+ next[i] = s;
131
+ }
132
+ next[prefix.length] = segment;
133
+ return next;
134
+ }
135
+ function diffAndApply(oldValue, newValue, prefix, visit) {
136
+ if (Object.is(oldValue, newValue)) return;
137
+ const oldIsDescendable = isDescendable(oldValue);
138
+ const newIsDescendable = isDescendable(newValue);
139
+ if (oldValue === void 0 && newIsDescendable) {
140
+ walkNewDescendable(newValue, prefix, visit);
141
+ return;
142
+ }
143
+ if (oldIsDescendable && newValue === void 0) {
144
+ walkOldDescendable(oldValue, prefix, visit);
145
+ return;
146
+ }
147
+ if (oldIsDescendable && newIsDescendable) {
148
+ const oldIsMap = oldValue instanceof Map;
149
+ const newIsMap = newValue instanceof Map;
150
+ if (oldIsMap && newIsMap) {
151
+ diffMapsLockstep(oldValue, newValue, prefix, visit);
152
+ return;
153
+ }
154
+ if (oldIsMap !== newIsMap) {
155
+ visit({ kind: "changed", path: prefix, oldValue, newValue });
156
+ return;
157
+ }
158
+ const oldIsArray = Array.isArray(oldValue);
159
+ const newIsArray = Array.isArray(newValue);
160
+ if (oldIsArray && newIsArray) {
161
+ diffArraysLockstep(oldValue, newValue, prefix, visit);
162
+ return;
163
+ }
164
+ if (!oldIsArray && !newIsArray) {
165
+ diffObjectsLockstep(
166
+ oldValue,
167
+ newValue,
168
+ prefix,
169
+ visit
170
+ );
171
+ return;
172
+ }
173
+ visit({ kind: "changed", path: prefix, oldValue, newValue });
174
+ return;
175
+ }
176
+ if (oldIsDescendable && !newIsDescendable) {
177
+ visit({ kind: "changed", path: prefix, oldValue, newValue });
178
+ return;
179
+ }
180
+ if (!oldIsDescendable && newIsDescendable) {
181
+ visit({ kind: "changed", path: prefix, oldValue, newValue });
182
+ return;
183
+ }
184
+ if (oldValue === void 0) {
185
+ visit({ kind: "added", path: prefix, newValue });
186
+ return;
187
+ }
188
+ if (newValue === void 0) {
189
+ visit({ kind: "removed", path: prefix, oldValue });
190
+ return;
191
+ }
192
+ visit({ kind: "changed", path: prefix, oldValue, newValue });
193
+ }
194
+ function walkNewDescendable(newValue, prefix, visit) {
195
+ if (Array.isArray(newValue)) {
196
+ for (let i = 0; i < newValue.length; i++) {
197
+ diffAndApply(void 0, readConsumerIndex(newValue, i), appendSegment(prefix, i), visit);
198
+ }
199
+ } else if (newValue instanceof Map) {
200
+ for (const [key, entry] of newValue) {
201
+ diffAndApply(void 0, entry, appendSegment(prefix, key), visit);
202
+ }
203
+ } else {
204
+ const rec = newValue;
205
+ for (const k of consumerKeys(rec)) {
206
+ diffAndApply(void 0, readConsumerProp(rec, k), appendSegment(prefix, k), visit);
207
+ }
208
+ }
209
+ }
210
+ function walkOldDescendable(oldValue, prefix, visit) {
211
+ if (Array.isArray(oldValue)) {
212
+ for (let i = 0; i < oldValue.length; i++) {
213
+ diffAndApply(readConsumerIndex(oldValue, i), void 0, appendSegment(prefix, i), visit);
214
+ }
215
+ } else if (oldValue instanceof Map) {
216
+ for (const [key, entry] of oldValue) {
217
+ diffAndApply(entry, void 0, appendSegment(prefix, key), visit);
218
+ }
219
+ } else {
220
+ const rec = oldValue;
221
+ for (const k of consumerKeys(rec)) {
222
+ diffAndApply(readConsumerProp(rec, k), void 0, appendSegment(prefix, k), visit);
223
+ }
224
+ }
225
+ }
226
+ function diffMapsLockstep(oldMap, newMap, prefix, visit) {
227
+ for (const [key, entry] of newMap) {
228
+ diffAndApply(oldMap.get(key), entry, appendSegment(prefix, key), visit);
229
+ }
230
+ for (const [key, entry] of oldMap) {
231
+ if (newMap.has(key)) continue;
232
+ diffAndApply(entry, void 0, appendSegment(prefix, key), visit);
233
+ }
234
+ }
235
+ function diffArraysLockstep(oldArr, newArr, prefix, visit) {
236
+ const max = Math.max(oldArr.length, newArr.length);
237
+ for (let i = 0; i < max; i++) {
238
+ diffAndApply(
239
+ readConsumerIndex(oldArr, i),
240
+ readConsumerIndex(newArr, i),
241
+ appendSegment(prefix, i),
242
+ visit
243
+ );
244
+ }
245
+ }
246
+ function diffObjectsLockstep(oldRec, newRec, prefix, visit) {
247
+ const seen = /* @__PURE__ */ new Set();
248
+ for (const k of consumerKeys(oldRec)) {
249
+ seen.add(k);
250
+ diffAndApply(
251
+ readConsumerProp(oldRec, k),
252
+ readConsumerProp(newRec, k),
253
+ appendSegment(prefix, k),
254
+ visit
255
+ );
256
+ }
257
+ for (const k of consumerKeys(newRec)) {
258
+ if (seen.has(k)) continue;
259
+ diffAndApply(
260
+ readConsumerProp(oldRec, k),
261
+ readConsumerProp(newRec, k),
262
+ appendSegment(prefix, k),
263
+ visit
264
+ );
265
+ }
266
+ }
267
+ function applyChangedKeys(target, source, arrayOpPath, currentPath, patches) {
268
+ if (!isDescendable(target) || !isDescendable(source)) return false;
269
+ if (target instanceof Map || source instanceof Map) return false;
270
+ const targetIsArray = Array.isArray(target);
271
+ const sourceIsArray = Array.isArray(source);
272
+ if (targetIsArray !== sourceIsArray) return false;
273
+ const depth = currentPath.length;
274
+ const changedFirstSegments = /* @__PURE__ */ new Set();
275
+ for (const patch of patches) {
276
+ if (patch.path.length === depth) return false;
277
+ changedFirstSegments.add(patch.path[depth]);
278
+ }
279
+ if (targetIsArray) {
280
+ const t = target;
281
+ const s = source;
282
+ if (arrayOpPath === null || pathsEqual(currentPath, arrayOpPath)) {
283
+ if (t.length > s.length) t.length = s.length;
284
+ for (const idx of changedFirstSegments) {
285
+ const i = typeof idx === "number" ? idx : Number(idx);
286
+ if (i >= s.length) continue;
287
+ t[i] = s[i];
288
+ }
289
+ } else {
290
+ for (const idx of changedFirstSegments) {
291
+ const i = typeof idx === "number" ? idx : Number(idx);
292
+ if (i >= s.length) continue;
293
+ const childPath = appendSegment(currentPath, i);
294
+ const curEl = t[i];
295
+ const nextEl = s[i];
296
+ if (isPathPrefix(childPath, arrayOpPath) && isDescendable(curEl) && isDescendable(nextEl) && applyChangedKeys(
297
+ curEl,
298
+ nextEl,
299
+ arrayOpPath,
300
+ childPath,
301
+ patches.filter((p) => isPathPrefix(childPath, p.path))
302
+ )) {
303
+ continue;
304
+ }
305
+ t[i] = nextEl;
306
+ }
307
+ }
308
+ } else {
309
+ const t = target;
310
+ const s = source;
311
+ const sourceKeys = new Set(Object.keys(s));
312
+ for (const k of Object.keys(t)) {
313
+ if (!sourceKeys.has(k)) delete t[k];
314
+ }
315
+ for (const k of changedFirstSegments) {
316
+ const key = String(k);
317
+ const nextVal = safeOwnRead(s, key);
318
+ if (arrayOpPath !== null) {
319
+ const curVal = safeOwnRead(t, key);
320
+ const childPath = appendSegment(currentPath, key);
321
+ if (isDescendable(curVal) && isDescendable(nextVal) && applyChangedKeys(
322
+ curVal,
323
+ nextVal,
324
+ arrayOpPath,
325
+ childPath,
326
+ patches.filter((p) => isPathPrefix(childPath, p.path))
327
+ )) {
328
+ continue;
329
+ }
330
+ }
331
+ safeAssign(t, key, nextVal);
332
+ }
333
+ }
334
+ return true;
335
+ }
336
+ function structuralSnapshot(value) {
337
+ if (!isDescendable(value)) return value;
338
+ if (value instanceof Map) {
339
+ const out2 = /* @__PURE__ */ new Map();
340
+ for (const [k, v] of value) out2.set(k, structuralSnapshot(v));
341
+ return out2;
342
+ }
343
+ if (Array.isArray(value)) {
344
+ const out2 = new Array(value.length);
345
+ for (let i = 0; i < value.length; i++) {
346
+ out2[i] = structuralSnapshot(value[i]);
347
+ }
348
+ return out2;
349
+ }
350
+ const src = value;
351
+ const out = {};
352
+ for (const k of Object.keys(src)) {
353
+ safeAssign(out, k, structuralSnapshot(safeOwnRead(src, k)));
354
+ }
355
+ return out;
356
+ }
357
+
358
+ export { ANONYMOUS_FORM_KEY_PREFIX as A, DEFAULT_HISTORY_MAX_SNAPSHOTS as D, RESERVED_KEY_PREFIX as R, safeOwnRead as a, safeAssign as b, callConsumerSchemaFn as c, consumerHas as d, safeOwnHas as e, spreadConsumerRecord as f, copyConsumerArray as g, consumerKeys as h, isShadowedKey as i, readConsumerProp as j, diffAndApply as k, DEFAULT_FIELD_VALIDATION_DEBOUNCE_MS as l, consumerSymbolKeys as m, normalizeNumericOption as n, applyChangedKeys as o, pickDefined as p, DEFAULT_MAX_RECURSION_DEPTH as q, readConsumerIndex as r, structuralSnapshot as s, ANONYMOUS_WIZARD_KEY_PREFIX as t };
@@ -0,0 +1,197 @@
1
+ import { c as RegistryNotInstalledError, O as OutsideSetupError, g as pathKeyToDotted } from './attaform.CZYt_5N_.mjs';
2
+ import { shallowReactive, getCurrentInstance, inject } from 'vue';
3
+
4
+ function detectSSR(options = {}) {
5
+ if (options.ssr !== void 0) return options.ssr;
6
+ return typeof window === "undefined" && typeof document === "undefined";
7
+ }
8
+
9
+ const kAttaformRegistry = /* @__PURE__ */ Symbol.for("attaform:registry");
10
+ const kAttaformAncestorWizard = /* @__PURE__ */ Symbol.for(
11
+ "attaform:ancestor-wizard"
12
+ );
13
+ const kAttaformWizardActiveStepResolver = /* @__PURE__ */ Symbol.for(
14
+ "attaform:wizard-active-step-resolver"
15
+ );
16
+ const kFormContext = /* @__PURE__ */ Symbol.for("attaform:form-context");
17
+ const kFormInstanceId = /* @__PURE__ */ Symbol.for("attaform:form-instance-id");
18
+ function createRegistry(options = {}) {
19
+ const ssr = detectSSR(options);
20
+ const defaults = Object.freeze({ ...options.defaults ?? {} });
21
+ const forms = shallowReactive(/* @__PURE__ */ new Map());
22
+ const wizards = shallowReactive(/* @__PURE__ */ new Map());
23
+ const pendingHydration = shallowReactive(/* @__PURE__ */ new Map());
24
+ const consumers = /* @__PURE__ */ new Map();
25
+ const pendingEvictions = /* @__PURE__ */ new Map();
26
+ function cancelPendingEviction(key) {
27
+ const pending = pendingEvictions.get(key);
28
+ if (pending === void 0) return;
29
+ pending.cancelled = true;
30
+ pendingEvictions.delete(key);
31
+ }
32
+ function trackConsumer(key) {
33
+ cancelPendingEviction(key);
34
+ consumers.set(key, (consumers.get(key) ?? 0) + 1);
35
+ let disposed = false;
36
+ return () => {
37
+ if (disposed) return;
38
+ disposed = true;
39
+ const remaining = (consumers.get(key) ?? 1) - 1;
40
+ if (remaining > 0) {
41
+ consumers.set(key, remaining);
42
+ return;
43
+ }
44
+ consumers.delete(key);
45
+ const token = { cancelled: false };
46
+ pendingEvictions.set(key, token);
47
+ queueMicrotask(() => {
48
+ if (token.cancelled) return;
49
+ if (pendingEvictions.get(key) !== token) return;
50
+ pendingEvictions.delete(key);
51
+ const state = forms.get(key);
52
+ forms.delete(key);
53
+ if (state === void 0) return;
54
+ state.dispose();
55
+ });
56
+ };
57
+ }
58
+ const wizardConsumers = /* @__PURE__ */ new Map();
59
+ const pendingWizardEvictions = /* @__PURE__ */ new Map();
60
+ function cancelPendingWizardEviction(key) {
61
+ const pending = pendingWizardEvictions.get(key);
62
+ if (pending === void 0) return;
63
+ pending.cancelled = true;
64
+ pendingWizardEvictions.delete(key);
65
+ }
66
+ function trackWizardConsumer(key) {
67
+ cancelPendingWizardEviction(key);
68
+ wizardConsumers.set(key, (wizardConsumers.get(key) ?? 0) + 1);
69
+ let disposed = false;
70
+ return () => {
71
+ if (disposed) return;
72
+ disposed = true;
73
+ const remaining = (wizardConsumers.get(key) ?? 1) - 1;
74
+ if (remaining > 0) {
75
+ wizardConsumers.set(key, remaining);
76
+ return;
77
+ }
78
+ wizardConsumers.delete(key);
79
+ const token = { cancelled: false };
80
+ pendingWizardEvictions.set(key, token);
81
+ queueMicrotask(() => {
82
+ if (token.cancelled) return;
83
+ if (pendingWizardEvictions.get(key) !== token) return;
84
+ pendingWizardEvictions.delete(key);
85
+ wizards.delete(key);
86
+ });
87
+ };
88
+ }
89
+ const prefetchEnqueued = /* @__PURE__ */ new Set();
90
+ const prefetchSkipped = /* @__PURE__ */ new Set();
91
+ function enqueuePrefetch(key) {
92
+ prefetchEnqueued.add(key);
93
+ }
94
+ function skipPrefetch(key) {
95
+ prefetchSkipped.add(key);
96
+ }
97
+ function shouldPrefetch(key) {
98
+ return prefetchEnqueued.has(key) && !prefetchSkipped.has(key);
99
+ }
100
+ return {
101
+ forms,
102
+ wizards,
103
+ pendingHydration,
104
+ ssr,
105
+ defaults,
106
+ trackConsumer,
107
+ trackWizardConsumer,
108
+ enqueuePrefetch,
109
+ skipPrefetch,
110
+ shouldPrefetch
111
+ };
112
+ }
113
+ function useRegistry() {
114
+ const instance = getCurrentInstance();
115
+ if (instance === null) {
116
+ throw new OutsideSetupError();
117
+ }
118
+ const registry = inject(kAttaformRegistry, null);
119
+ if (registry === null) {
120
+ throw new RegistryNotInstalledError();
121
+ }
122
+ return registry;
123
+ }
124
+ function getRegistryFromApp(app) {
125
+ const registry = app._attaform;
126
+ if (registry === void 0) {
127
+ throw new RegistryNotInstalledError();
128
+ }
129
+ return registry;
130
+ }
131
+ function attachRegistryToApp(app, registry) {
132
+ app.provide(kAttaformRegistry, registry);
133
+ app._attaform = registry;
134
+ }
135
+
136
+ function installAttaformOnApp(app, options, source) {
137
+ if (app._attaform !== void 0) {
138
+ return app._attaform;
139
+ }
140
+ const registry = createRegistry(options);
141
+ attachRegistryToApp(app, registry);
142
+ return registry;
143
+ }
144
+ function ensureAttaformInstalled(app) {
145
+ return installAttaformOnApp(app, {});
146
+ }
147
+ function createAttaform(options = {}) {
148
+ const plugin = {
149
+ install(app) {
150
+ installAttaformOnApp(app, options);
151
+ }
152
+ };
153
+ return plugin;
154
+ }
155
+
156
+ const ATTAFORM_STATE_VERSION = 1;
157
+ function renderAttaformState(app) {
158
+ const registry = getRegistryFromApp(app);
159
+ const forms = [];
160
+ for (const [key, state] of registry.forms) {
161
+ const transientList = [];
162
+ for (const pk of state.blankPaths) {
163
+ const d = pathKeyToDotted(pk);
164
+ if (d !== null) transientList.push(d);
165
+ }
166
+ forms.push([
167
+ key,
168
+ {
169
+ form: state.form.value,
170
+ // The wire shape stays two per-source arrays; the tagged store
171
+ // splits at the boundary and the client replays each side into
172
+ // its cell half.
173
+ schemaErrors: [...state.errorCells.entries()].filter(([, cell]) => cell.schema.length > 0).map(([key2, cell]) => [key2, cell.schema]),
174
+ userErrors: [...state.errorCells.entries()].filter(([, cell]) => cell.user.length > 0).map(([key2, cell]) => [key2, cell.user]),
175
+ fields: Array.from(state.fields.entries()),
176
+ ...transientList.length > 0 ? { blankPaths: transientList } : {}
177
+ }
178
+ ]);
179
+ }
180
+ return { v: ATTAFORM_STATE_VERSION, forms };
181
+ }
182
+ function hydrateAttaformState(app, payload) {
183
+ if (!isHydratableEnvelope(payload)) {
184
+ return;
185
+ }
186
+ const registry = getRegistryFromApp(app);
187
+ for (const [key, data] of payload.forms) {
188
+ registry.pendingHydration.set(key, data);
189
+ }
190
+ }
191
+ function isHydratableEnvelope(payload) {
192
+ return payload !== null && typeof payload === "object" && "v" in payload && payload.v === ATTAFORM_STATE_VERSION && "forms" in payload && Array.isArray(payload.forms);
193
+ }
194
+
195
+ const DEVTOOLS_WINDOW_KEY = "__attaform_devtools__";
196
+
197
+ export { DEVTOOLS_WINDOW_KEY as D, createRegistry as a, kAttaformWizardActiveStepResolver as b, createAttaform as c, kFormContext as d, ensureAttaformInstalled as e, kFormInstanceId as f, getRegistryFromApp as g, hydrateAttaformState as h, kAttaformAncestorWizard as i, kAttaformRegistry as k, renderAttaformState as r, useRegistry as u };