@stonecrop/stonecrop 0.13.8 → 0.13.9

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.
package/dist/stonecrop.js CHANGED
@@ -1,4 +1,4 @@
1
- import { watch as zt, onMounted as Mn, nextTick as br, readonly as $n, getCurrentInstance as zn, toRef as Ti, customRef as Li, ref as j, reactive as lr, computed as J, toValue as kt, shallowRef as Tn, unref as Di, inject as xe, provide as Xr } from "vue";
1
+ import { watch as zt, onMounted as Mn, nextTick as br, readonly as $n, getCurrentInstance as zn, toRef as Ti, customRef as Li, ref as j, reactive as lr, computed as J, toValue as At, shallowRef as Tn, unref as Di, inject as xe, provide as Xr } from "vue";
2
2
  import { defineStore as Ci, storeToRefs as Ln } from "pinia";
3
3
  const qi = typeof window < "u" && typeof document < "u";
4
4
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
@@ -85,25 +85,25 @@ function he(e, t, r) {
85
85
  const Ft = qi ? window : void 0;
86
86
  function Vi(e) {
87
87
  var t;
88
- const r = kt(e);
88
+ const r = At(e);
89
89
  return (t = r?.$el) !== null && t !== void 0 ? t : r;
90
90
  }
91
91
  function Ht(...e) {
92
92
  const t = (n, i, o, s) => (n.addEventListener(i, o, s), () => n.removeEventListener(i, o, s)), r = J(() => {
93
- const n = nr(kt(e[0])).filter((i) => i != null);
93
+ const n = nr(At(e[0])).filter((i) => i != null);
94
94
  return n.every((i) => typeof i != "string") ? n : void 0;
95
95
  });
96
96
  return Hi(() => {
97
97
  var n, i;
98
98
  return [
99
99
  (n = (i = r.value) === null || i === void 0 ? void 0 : i.map((o) => Vi(o))) !== null && n !== void 0 ? n : [Ft].filter((o) => o != null),
100
- nr(kt(r.value ? e[1] : e[0])),
100
+ nr(At(r.value ? e[1] : e[0])),
101
101
  nr(Di(r.value ? e[2] : e[1])),
102
- kt(r.value ? e[3] : e[2])
102
+ At(r.value ? e[3] : e[2])
103
103
  ];
104
104
  }, ([n, i, o, s], a, u) => {
105
105
  if (!n?.length || !i?.length || !o?.length) return;
106
- const c = Pi(s) ? { ...s } : s, f = n.flatMap((h) => i.flatMap((l) => o.map((g) => t(h, l, g, c))));
106
+ const c = Pi(s) ? { ...s } : s, f = n.flatMap((h) => i.flatMap((l) => o.map((d) => t(h, l, d, c))));
107
107
  u(() => {
108
108
  f.forEach((h) => h());
109
109
  });
@@ -155,89 +155,89 @@ const Xi = {
155
155
  }, Qr = "vueuse-storage";
156
156
  function Qi(e, t, r, n = {}) {
157
157
  var i;
158
- const { flush: o = "pre", deep: s = !0, listenToStorageChanges: a = !0, writeDefaults: u = !0, mergeDefaults: c = !1, shallow: f, window: h = Ft, eventFilter: l, onError: g = (R) => {
159
- console.error(R);
160
- }, initOnMounted: p } = n, d = (f ? Tn : j)(t), m = J(() => kt(e));
158
+ const { flush: o = "pre", deep: s = !0, listenToStorageChanges: a = !0, writeDefaults: u = !0, mergeDefaults: c = !1, shallow: f, window: h = Ft, eventFilter: l, onError: d = (E) => {
159
+ console.error(E);
160
+ }, initOnMounted: p } = n, _ = (f ? Tn : j)(t), m = J(() => At(e));
161
161
  if (!r) try {
162
162
  r = Gi("getDefaultStorage", () => Ft?.localStorage)();
163
- } catch (R) {
164
- g(R);
163
+ } catch (E) {
164
+ d(E);
165
165
  }
166
- if (!r) return d;
167
- const E = kt(t), O = Zi(E), w = (i = n.serializer) !== null && i !== void 0 ? i : Xi[O], { pause: K, resume: k } = Wi(d, (R) => ce(R), {
166
+ if (!r) return _;
167
+ const R = At(t), O = Zi(R), w = (i = n.serializer) !== null && i !== void 0 ? i : Xi[O], { pause: K, resume: A } = Wi(_, (E) => ce(E), {
168
168
  flush: o,
169
169
  deep: s,
170
170
  eventFilter: l
171
171
  });
172
172
  zt(m, () => bt(), { flush: o });
173
173
  let $ = !1;
174
- const z = (R) => {
175
- p && !$ || bt(R);
176
- }, Y = (R) => {
177
- p && !$ || Wt(R);
174
+ const z = (E) => {
175
+ p && !$ || bt(E);
176
+ }, Y = (E) => {
177
+ p && !$ || Wt(E);
178
178
  };
179
179
  h && a && (r instanceof Storage ? Ht(h, "storage", z, { passive: !0 }) : Ht(h, Qr, Y)), p ? Ki(() => {
180
180
  $ = !0, bt();
181
181
  }) : bt();
182
- function gt(R, B) {
182
+ function _t(E, B) {
183
183
  if (h) {
184
184
  const X = {
185
185
  key: m.value,
186
- oldValue: R,
186
+ oldValue: E,
187
187
  newValue: B,
188
188
  storageArea: r
189
189
  };
190
190
  h.dispatchEvent(r instanceof Storage ? new StorageEvent("storage", X) : new CustomEvent(Qr, { detail: X }));
191
191
  }
192
192
  }
193
- function ce(R) {
193
+ function ce(E) {
194
194
  try {
195
195
  const B = r.getItem(m.value);
196
- if (R == null)
197
- gt(B, null), r.removeItem(m.value);
196
+ if (E == null)
197
+ _t(B, null), r.removeItem(m.value);
198
198
  else {
199
- const X = w.write(R);
200
- B !== X && (r.setItem(m.value, X), gt(B, X));
199
+ const X = w.write(E);
200
+ B !== X && (r.setItem(m.value, X), _t(B, X));
201
201
  }
202
202
  } catch (B) {
203
- g(B);
203
+ d(B);
204
204
  }
205
205
  }
206
- function fe(R) {
207
- const B = R ? R.newValue : r.getItem(m.value);
206
+ function fe(E) {
207
+ const B = E ? E.newValue : r.getItem(m.value);
208
208
  if (B == null)
209
- return u && E != null && r.setItem(m.value, w.write(E)), E;
210
- if (!R && c) {
209
+ return u && R != null && r.setItem(m.value, w.write(R)), R;
210
+ if (!E && c) {
211
211
  const X = w.read(B);
212
- return typeof c == "function" ? c(X, E) : O === "object" && !Array.isArray(X) ? {
213
- ...E,
212
+ return typeof c == "function" ? c(X, R) : O === "object" && !Array.isArray(X) ? {
213
+ ...R,
214
214
  ...X
215
215
  } : X;
216
216
  } else return typeof B != "string" ? B : w.read(B);
217
217
  }
218
- function bt(R) {
219
- if (!(R && R.storageArea !== r)) {
220
- if (R && R.key == null) {
221
- d.value = E;
218
+ function bt(E) {
219
+ if (!(E && E.storageArea !== r)) {
220
+ if (E && E.key == null) {
221
+ _.value = R;
222
222
  return;
223
223
  }
224
- if (!(R && R.key !== m.value)) {
224
+ if (!(E && E.key !== m.value)) {
225
225
  K();
226
226
  try {
227
- const B = w.write(d.value);
228
- (R === void 0 || R?.newValue !== B) && (d.value = fe(R));
227
+ const B = w.write(_.value);
228
+ (E === void 0 || E?.newValue !== B) && (_.value = fe(E));
229
229
  } catch (B) {
230
- g(B);
230
+ d(B);
231
231
  } finally {
232
- R ? br(k) : k();
232
+ E ? br(A) : A();
233
233
  }
234
234
  }
235
235
  }
236
236
  }
237
- function Wt(R) {
238
- bt(R.detail);
237
+ function Wt(E) {
238
+ bt(E.detail);
239
239
  }
240
- return d;
240
+ return _;
241
241
  }
242
242
  function to(e, t, r = {}) {
243
243
  const { window: n = Ft } = r;
@@ -267,50 +267,50 @@ function ro(e = {}) {
267
267
  function l(O, w) {
268
268
  O in u && (t ? u[O] = w : u[O].value = w);
269
269
  }
270
- function g() {
270
+ function d() {
271
271
  s.clear();
272
272
  for (const O of h) l(O, !1);
273
273
  }
274
274
  function p(O, w, K) {
275
275
  if (!(!O || typeof w.getModifierState != "function")) {
276
- for (const [k, $] of f) if (w.getModifierState(k)) {
276
+ for (const [A, $] of f) if (w.getModifierState(A)) {
277
277
  K.forEach((z) => $.add(z));
278
278
  break;
279
279
  }
280
280
  }
281
281
  }
282
- function d(O, w) {
282
+ function _(O, w) {
283
283
  if (O) return;
284
- const K = `${w[0].toUpperCase()}${w.slice(1)}`, k = f.get(K);
285
- if (!["shift", "alt"].includes(w) || !k) return;
286
- const $ = Array.from(k), z = $.indexOf(w);
287
- $.forEach((Y, gt) => {
288
- gt >= z && (s.delete(Y), l(Y, !1));
289
- }), k.clear();
284
+ const K = `${w[0].toUpperCase()}${w.slice(1)}`, A = f.get(K);
285
+ if (!["shift", "alt"].includes(w) || !A) return;
286
+ const $ = Array.from(A), z = $.indexOf(w);
287
+ $.forEach((Y, _t) => {
288
+ _t >= z && (s.delete(Y), l(Y, !1));
289
+ }), A.clear();
290
290
  }
291
291
  function m(O, w) {
292
- var K, k;
293
- const $ = (K = O.key) === null || K === void 0 ? void 0 : K.toLowerCase(), z = [(k = O.code) === null || k === void 0 ? void 0 : k.toLowerCase(), $].filter(Boolean);
292
+ var K, A;
293
+ const $ = (K = O.key) === null || K === void 0 ? void 0 : K.toLowerCase(), z = [(A = O.code) === null || A === void 0 ? void 0 : A.toLowerCase(), $].filter(Boolean);
294
294
  if ($) {
295
295
  $ && (w ? s.add($) : s.delete($));
296
296
  for (const Y of z)
297
297
  h.add(Y), l(Y, w);
298
- p(w, O, [...s, ...z]), d(w, $), $ === "meta" && !w && (c.forEach((Y) => {
298
+ p(w, O, [...s, ...z]), _(w, $), $ === "meta" && !w && (c.forEach((Y) => {
299
299
  s.delete(Y), l(Y, !1);
300
300
  }), c.clear());
301
301
  }
302
302
  }
303
- Ht(r, "keydown", (O) => (m(O, !0), o(O)), { passive: i }), Ht(r, "keyup", (O) => (m(O, !1), o(O)), { passive: i }), Ht("blur", g, { passive: i }), Ht("focus", g, { passive: i });
304
- const E = new Proxy(u, { get(O, w, K) {
303
+ Ht(r, "keydown", (O) => (m(O, !0), o(O)), { passive: i }), Ht(r, "keyup", (O) => (m(O, !1), o(O)), { passive: i }), Ht("blur", d, { passive: i }), Ht("focus", d, { passive: i });
304
+ const R = new Proxy(u, { get(O, w, K) {
305
305
  if (typeof w != "string") return Reflect.get(O, w, K);
306
306
  if (w = w.toLowerCase(), w in n && (w = n[w]), !(w in u)) if (/[+_-]/.test(w)) {
307
307
  const $ = w.split(/[+_-]/g).map((z) => z.trim());
308
- u[w] = J(() => $.map((z) => kt(E[z])).every(Boolean));
308
+ u[w] = J(() => $.map((z) => At(R[z])).every(Boolean));
309
309
  } else u[w] = Tn(!1);
310
- const k = Reflect.get(O, w, K);
311
- return t ? kt(k) : k;
310
+ const A = Reflect.get(O, w, K);
311
+ return t ? At(A) : A;
312
312
  } });
313
- return E;
313
+ return R;
314
314
  }
315
315
  function ir() {
316
316
  return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
@@ -371,27 +371,27 @@ const Ie = Ci("hst-operation-log", () => {
371
371
  })
372
372
  );
373
373
  function h(v) {
374
- e.value = { ...e.value, ...v }, e.value.enablePersistence && (R(), X()), e.value.enableCrossTabSync && Y();
374
+ e.value = { ...e.value, ...v }, e.value.enablePersistence && (E(), X()), e.value.enableCrossTabSync && Y();
375
375
  }
376
376
  function l(v, y = "user") {
377
- const _ = {
377
+ const g = {
378
378
  ...v,
379
379
  id: ir(),
380
380
  timestamp: /* @__PURE__ */ new Date(),
381
381
  source: y,
382
382
  userId: e.value.userId
383
383
  };
384
- if (e.value.operationFilter && !e.value.operationFilter(_))
385
- return _.id;
384
+ if (e.value.operationFilter && !e.value.operationFilter(g))
385
+ return g.id;
386
386
  if (i.value && o.value.length > 0)
387
- return o.value[o.value.length - 1].operations.push(_), _.id;
388
- if (r.value < t.value.length - 1 && (t.value = t.value.slice(0, r.value + 1)), t.value.push(_), r.value++, e.value.maxOperations && t.value.length > e.value.maxOperations) {
387
+ return o.value[o.value.length - 1].operations.push(g), g.id;
388
+ if (r.value < t.value.length - 1 && (t.value = t.value.slice(0, r.value + 1)), t.value.push(g), r.value++, e.value.maxOperations && t.value.length > e.value.maxOperations) {
389
389
  const U = t.value.length - e.value.maxOperations;
390
390
  t.value = t.value.slice(U), r.value -= U;
391
391
  }
392
- return e.value.enableCrossTabSync && gt(_), _.id;
392
+ return e.value.enableCrossTabSync && _t(g), g.id;
393
393
  }
394
- function g() {
394
+ function d() {
395
395
  i.value = !0, o.value.push({
396
396
  id: ir(),
397
397
  operations: []
@@ -400,10 +400,10 @@ const Ie = Ci("hst-operation-log", () => {
400
400
  function p(v) {
401
401
  if (!i.value || o.value.length === 0)
402
402
  return null;
403
- const y = o.value.pop(), _ = y.operations;
404
- if (_.length === 0)
403
+ const y = o.value.pop(), g = y.operations;
404
+ if (g.length === 0)
405
405
  return o.value.length === 0 && (i.value = !1), null;
406
- const U = y.id, ft = _.every((Ot) => Ot.reversible), _t = {
406
+ const U = y.id, ft = g.every((Ot) => Ot.reversible), gt = {
407
407
  id: U,
408
408
  type: "batch",
409
409
  path: "",
@@ -411,19 +411,19 @@ const Ie = Ci("hst-operation-log", () => {
411
411
  fieldname: "",
412
412
  beforeValue: null,
413
413
  afterValue: null,
414
- doctype: _[0]?.doctype || "",
414
+ doctype: g[0]?.doctype || "",
415
415
  timestamp: /* @__PURE__ */ new Date(),
416
416
  source: "user",
417
417
  reversible: ft,
418
418
  irreversibleReason: ft ? void 0 : "Contains irreversible operations",
419
- descendantOperationIds: _.map((Ot) => Ot.id),
419
+ descendantOperationIds: g.map((Ot) => Ot.id),
420
420
  metadata: { description: v }
421
421
  };
422
- return _.forEach((Ot) => {
422
+ return g.forEach((Ot) => {
423
423
  Ot.ancestorOperationId = U;
424
- }), o.value.length > 0 ? o.value[o.value.length - 1].operations.push(_t) : (t.value.push(..._, _t), r.value = t.value.length - 1), e.value.enableCrossTabSync && ce(_, _t), o.value.length === 0 && (i.value = !1), U;
424
+ }), o.value.length > 0 ? o.value[o.value.length - 1].operations.push(gt) : (t.value.push(...g, gt), r.value = t.value.length - 1), e.value.enableCrossTabSync && ce(g, gt), o.value.length === 0 && (i.value = !1), U;
425
425
  }
426
- function d() {
426
+ function _() {
427
427
  o.value = [], i.value = !1;
428
428
  }
429
429
  function m(v) {
@@ -433,85 +433,85 @@ const Ie = Ci("hst-operation-log", () => {
433
433
  return typeof console < "u" && y.irreversibleReason && console.warn("Cannot undo irreversible operation:", y.irreversibleReason), !1;
434
434
  try {
435
435
  if (y.type === "batch" && y.descendantOperationIds)
436
- for (let _ = y.descendantOperationIds.length - 1; _ >= 0; _--) {
437
- const U = y.descendantOperationIds[_], ft = t.value.find((_t) => _t.id === U);
436
+ for (let g = y.descendantOperationIds.length - 1; g >= 0; g--) {
437
+ const U = y.descendantOperationIds[g], ft = t.value.find((gt) => gt.id === U);
438
438
  ft && tn(ft, v);
439
439
  }
440
440
  else
441
441
  tn(y, v);
442
442
  return r.value--, e.value.enableCrossTabSync && fe(y), !0;
443
- } catch (_) {
444
- return typeof console < "u" && console.error("Undo failed:", _), !1;
443
+ } catch (g) {
444
+ return typeof console < "u" && console.error("Undo failed:", g), !1;
445
445
  }
446
446
  }
447
- function E(v) {
447
+ function R(v) {
448
448
  if (!a.value) return !1;
449
449
  const y = t.value[r.value + 1];
450
450
  try {
451
451
  if (y.type === "batch" && y.descendantOperationIds)
452
- for (const _ of y.descendantOperationIds) {
453
- const U = t.value.find((ft) => ft.id === _);
452
+ for (const g of y.descendantOperationIds) {
453
+ const U = t.value.find((ft) => ft.id === g);
454
454
  U && en(U, v);
455
455
  }
456
456
  else
457
457
  en(y, v);
458
458
  return r.value++, e.value.enableCrossTabSync && bt(y), !0;
459
- } catch (_) {
460
- return typeof console < "u" && console.error("Redo failed:", _), !1;
459
+ } catch (g) {
460
+ return typeof console < "u" && console.error("Redo failed:", g), !1;
461
461
  }
462
462
  }
463
463
  function O() {
464
- const v = t.value.filter((_) => _.reversible).length, y = t.value.map((_) => _.timestamp);
464
+ const v = t.value.filter((g) => g.reversible).length, y = t.value.map((g) => g.timestamp);
465
465
  return {
466
466
  operations: [...t.value],
467
467
  currentIndex: r.value,
468
468
  totalOperations: t.value.length,
469
469
  reversibleOperations: v,
470
470
  irreversibleOperations: t.value.length - v,
471
- oldestOperation: y.length > 0 ? new Date(Math.min(...y.map((_) => _.getTime()))) : void 0,
472
- newestOperation: y.length > 0 ? new Date(Math.max(...y.map((_) => _.getTime()))) : void 0
471
+ oldestOperation: y.length > 0 ? new Date(Math.min(...y.map((g) => g.getTime()))) : void 0,
472
+ newestOperation: y.length > 0 ? new Date(Math.max(...y.map((g) => g.getTime()))) : void 0
473
473
  };
474
474
  }
475
475
  function w() {
476
476
  t.value = [], r.value = -1;
477
477
  }
478
478
  function K(v, y) {
479
- return t.value.filter((_) => _.doctype === v && (y === void 0 || _.recordId === y));
479
+ return t.value.filter((g) => g.doctype === v && (y === void 0 || g.recordId === y));
480
480
  }
481
- function k(v, y) {
482
- const _ = t.value.find((U) => U.id === v);
483
- _ && (_.reversible = !1, _.irreversibleReason = y);
481
+ function A(v, y) {
482
+ const g = t.value.find((U) => U.id === v);
483
+ g && (g.reversible = !1, g.irreversibleReason = y);
484
484
  }
485
- function $(v, y, _, U = "success", ft) {
486
- const _t = {
485
+ function $(v, y, g, U = "success", ft) {
486
+ const gt = {
487
487
  type: "action",
488
- path: _ && _.length > 0 ? `${v}.${_[0]}` : v,
488
+ path: g && g.length > 0 ? `${v}.${g[0]}` : v,
489
489
  fieldname: "",
490
490
  beforeValue: null,
491
491
  afterValue: null,
492
492
  doctype: v,
493
- recordId: _ && _.length > 0 ? _[0] : void 0,
493
+ recordId: g && g.length > 0 ? g[0] : void 0,
494
494
  reversible: !1,
495
495
  // Actions are typically not reversible
496
496
  actionName: y,
497
- actionRecordIds: _,
497
+ actionRecordIds: g,
498
498
  actionResult: U,
499
499
  actionError: ft
500
500
  };
501
- return l(_t);
501
+ return l(gt);
502
502
  }
503
503
  let z = null;
504
504
  function Y() {
505
505
  typeof window > "u" || !window.BroadcastChannel || (z = new BroadcastChannel("stonecrop-operation-log"), z.addEventListener("message", (v) => {
506
506
  const y = v.data;
507
507
  if (!y || typeof y != "object") return;
508
- const _ = no(y);
509
- _.clientId !== n.value && (_.type === "operation" && _.operation ? (t.value.push({ ..._.operation, source: "sync" }), r.value = t.value.length - 1) : _.type === "operation" && _.operations && (t.value.push(
510
- ..._.operations.map((U) => Object.assign({}, U, { source: "sync" }))
508
+ const g = no(y);
509
+ g.clientId !== n.value && (g.type === "operation" && g.operation ? (t.value.push({ ...g.operation, source: "sync" }), r.value = t.value.length - 1) : g.type === "operation" && g.operations && (t.value.push(
510
+ ...g.operations.map((U) => Object.assign({}, U, { source: "sync" }))
511
511
  ), r.value = t.value.length - 1));
512
512
  }));
513
513
  }
514
- function gt(v) {
514
+ function _t(v) {
515
515
  if (!z) return;
516
516
  const y = {
517
517
  type: "operation",
@@ -523,13 +523,13 @@ const Ie = Ci("hst-operation-log", () => {
523
523
  }
524
524
  function ce(v, y) {
525
525
  if (!z) return;
526
- const _ = {
526
+ const g = {
527
527
  type: "operation",
528
528
  operations: [...v, y],
529
529
  clientId: n.value,
530
530
  timestamp: /* @__PURE__ */ new Date()
531
531
  };
532
- z.postMessage(qe(_));
532
+ z.postMessage(qe(g));
533
533
  }
534
534
  function fe(v) {
535
535
  if (!z) return;
@@ -563,7 +563,7 @@ const Ie = Ci("hst-operation-log", () => {
563
563
  write: (v) => v ? JSON.stringify(v) : ""
564
564
  }
565
565
  });
566
- function R() {
566
+ function E() {
567
567
  if (!(typeof window > "u"))
568
568
  try {
569
569
  const v = Wt.value;
@@ -613,19 +613,19 @@ const Ie = Ci("hst-operation-log", () => {
613
613
  // Methods
614
614
  configure: h,
615
615
  addOperation: l,
616
- startBatch: g,
616
+ startBatch: d,
617
617
  commitBatch: p,
618
- cancelBatch: d,
618
+ cancelBatch: _,
619
619
  undo: m,
620
- redo: E,
620
+ redo: R,
621
621
  clear: w,
622
622
  getOperationsFor: K,
623
623
  getSnapshot: O,
624
- markIrreversible: k,
624
+ markIrreversible: A,
625
625
  logAction: $
626
626
  };
627
627
  });
628
- class _e {
628
+ class ge {
629
629
  /**
630
630
  * The root FieldTriggerEngine instance
631
631
  */
@@ -646,7 +646,7 @@ class _e {
646
646
  * @param options - Configuration options for the field trigger engine
647
647
  */
648
648
  constructor(t = {}) {
649
- return _e._root ? _e._root : (_e._root = this, this.options = {
649
+ return ge._root ? ge._root : (ge._root = this, this.options = {
650
650
  defaultTimeout: t.defaultTimeout ?? 5e3,
651
651
  debug: t.debug ?? !1,
652
652
  enableRollback: t.enableRollback ?? !0,
@@ -749,15 +749,15 @@ class _e {
749
749
  l && t.store && (f = this.captureSnapshot(t));
750
750
  for (const m of o)
751
751
  try {
752
- const E = await this.executeAction(m, t, r.timeout);
753
- if (a.push(E), !E.success) {
752
+ const R = await this.executeAction(m, t, r.timeout);
753
+ if (a.push(R), !R.success) {
754
754
  u = !0;
755
755
  break;
756
756
  }
757
- } catch (E) {
757
+ } catch (R) {
758
758
  const w = {
759
759
  success: !1,
760
- error: E instanceof Error ? E : new Error(String(E)),
760
+ error: R instanceof Error ? R : new Error(String(R)),
761
761
  executionTime: 0,
762
762
  action: m
763
763
  };
@@ -770,18 +770,18 @@ class _e {
770
770
  } catch (m) {
771
771
  console.error("[FieldTriggers] Rollback failed:", m);
772
772
  }
773
- const g = performance.now() - s, p = a.filter((m) => !m.success && m.error != null);
773
+ const d = performance.now() - s, p = a.filter((m) => !m.success && m.error != null);
774
774
  if (p.length > 0 && this.options.errorHandler)
775
775
  for (const m of p)
776
776
  try {
777
777
  m.error && this.options.errorHandler(m.error, t, m.action);
778
- } catch (E) {
779
- console.error("[FieldTriggers] Error in global error handler:", E);
778
+ } catch (R) {
779
+ console.error("[FieldTriggers] Error in global error handler:", R);
780
780
  }
781
781
  return {
782
782
  path: t.path,
783
783
  actionResults: a,
784
- totalExecutionTime: g,
784
+ totalExecutionTime: d,
785
785
  allSucceeded: a.every((m) => m.success),
786
786
  stoppedOnError: u,
787
787
  rolledBack: c,
@@ -966,7 +966,7 @@ class _e {
966
966
  }
967
967
  }
968
968
  function Et(e) {
969
- return new _e(e);
969
+ return new ge(e);
970
970
  }
971
971
  function as(e, t) {
972
972
  Et().registerAction(e, t);
@@ -1452,11 +1452,11 @@ class Mt {
1452
1452
  try {
1453
1453
  if (o && o.length > 0) {
1454
1454
  const l = Et();
1455
- o.forEach((g) => {
1455
+ o.forEach((d) => {
1456
1456
  try {
1457
- const p = l.getAction(g);
1458
- if (!p) throw new Error(`Action "${g}" is not registered in FieldTriggerEngine`);
1459
- const d = {
1457
+ const p = l.getAction(d);
1458
+ if (!p) throw new Error(`Action "${d}" is not registered in FieldTriggerEngine`);
1459
+ const _ = {
1460
1460
  path: `${t.slug}.${s?.[0] ?? ""}`,
1461
1461
  fieldname: r,
1462
1462
  beforeValue: void 0,
@@ -1466,7 +1466,7 @@ class Mt {
1466
1466
  recordId: a,
1467
1467
  timestamp: /* @__PURE__ */ new Date()
1468
1468
  };
1469
- p(d);
1469
+ p(_);
1470
1470
  } catch (p) {
1471
1471
  throw f = "failure", h = p instanceof Error ? p.message : "Unknown error", p;
1472
1472
  }
@@ -1710,17 +1710,17 @@ function ps(e, t, r) {
1710
1710
  return (${p})(stonecrop, path, hst)
1711
1711
  `
1712
1712
  )(n, u(), a);
1713
- } catch (d) {
1714
- throw new Error(`Custom handler failed: ${d instanceof Error ? d.message : String(d)}`, { cause: d });
1713
+ } catch (_) {
1714
+ throw new Error(`Custom handler failed: ${_ instanceof Error ? _.message : String(_)}`, { cause: _ });
1715
1715
  }
1716
1716
  }, h = async () => {
1717
- const p = c(), d = `${e.slug || e.doctype}.${t}`;
1717
+ const p = c(), _ = `${e.slug || e.doctype}.${t}`;
1718
1718
  if (p?.method === "custom") {
1719
- a.has(d) || a.set(d, {}, "system");
1719
+ a.has(_) || a.set(_, {}, "system");
1720
1720
  const m = await f(p.handler);
1721
1721
  a.set(u(), m, "system");
1722
1722
  } else
1723
- await n.fetchNestedData(d, e, t, { includeNested: [r] });
1723
+ await n.fetchNestedData(_, e, t, { includeNested: [r] });
1724
1724
  }, l = async () => {
1725
1725
  if (!i.value) {
1726
1726
  i.value = !0, s.value = null;
@@ -1732,7 +1732,7 @@ function ps(e, t, r) {
1732
1732
  i.value = !1;
1733
1733
  }
1734
1734
  }
1735
- }, g = J(() => {
1735
+ }, d = J(() => {
1736
1736
  if (o.value)
1737
1737
  return a.get(u());
1738
1738
  });
@@ -1742,16 +1742,16 @@ function ps(e, t, r) {
1742
1742
  loaded: o,
1743
1743
  error: s,
1744
1744
  // Computed
1745
- data: g,
1745
+ data: d,
1746
1746
  // Actions
1747
1747
  reload: l
1748
1748
  };
1749
1749
  }
1750
1750
  function ds(e) {
1751
1751
  e || (e = {});
1752
- const t = e.registry || xe("$registry"), r = xe("$stonecrop"), n = j(), i = j(), o = j({}), s = j(), a = j(), u = j([]), c = j(!1), f = j(null), h = j(), l = J(() => !n.value || !h.value || !e.recordId || e.recordId === "new" ? !0 : n.value.isWorkflowReady(h.value, e.recordId).ready), g = J(() => !n.value || !h.value || !e.recordId || e.recordId === "new" ? [] : n.value.isWorkflowReady(h.value, e.recordId).blockedLinks ?? []), p = r || Mt._root;
1752
+ const t = e.registry || xe("$registry"), r = xe("$stonecrop"), n = j(), i = j(), o = j({}), s = j(), a = j(), u = j([]), c = j(!1), f = j(null), h = j(), l = J(() => !n.value || !h.value || !e.recordId || e.recordId === "new" ? !0 : n.value.isWorkflowReady(h.value, e.recordId).ready), d = J(() => !n.value || !h.value || !e.recordId || e.recordId === "new" ? [] : n.value.isWorkflowReady(h.value, e.recordId).blockedLinks ?? []), p = r || Mt._root;
1753
1753
  p && (n.value = p), e?.doctype && typeof e.doctype != "string" && (h.value = e.doctype);
1754
- const d = j([]), m = j(-1), E = J(() => n.value?.getOperationLogStore().canUndo ?? !1), O = J(() => n.value?.getOperationLogStore().canRedo ?? !1), w = J(() => n.value?.getOperationLogStore().undoCount ?? 0), K = J(() => n.value?.getOperationLogStore().redoCount ?? 0), k = J(
1754
+ const _ = j([]), m = j(-1), R = J(() => n.value?.getOperationLogStore().canUndo ?? !1), O = J(() => n.value?.getOperationLogStore().canRedo ?? !1), w = J(() => n.value?.getOperationLogStore().undoCount ?? 0), K = J(() => n.value?.getOperationLogStore().redoCount ?? 0), A = J(
1755
1755
  () => n.value?.getOperationLogStore().undoRedoState ?? {
1756
1756
  canUndo: !1,
1757
1757
  canRedo: !1,
@@ -1761,7 +1761,7 @@ function ds(e) {
1761
1761
  }
1762
1762
  ), $ = (S) => n.value?.getOperationLogStore().undo(S) ?? !1, z = (S) => n.value?.getOperationLogStore().redo(S) ?? !1, Y = () => {
1763
1763
  n.value?.getOperationLogStore().startBatch();
1764
- }, gt = (S) => n.value?.getOperationLogStore().commitBatch(S) ?? null, ce = () => {
1764
+ }, _t = (S) => n.value?.getOperationLogStore().commitBatch(S) ?? null, ce = () => {
1765
1765
  n.value?.getOperationLogStore().cancelBatch();
1766
1766
  }, fe = () => {
1767
1767
  n.value?.getOperationLogStore().clear();
@@ -1771,7 +1771,7 @@ function ds(e) {
1771
1771
  totalOperations: 0,
1772
1772
  reversibleOperations: 0,
1773
1773
  irreversibleOperations: 0
1774
- }, R = (S, I) => {
1774
+ }, E = (S, I) => {
1775
1775
  n.value?.getOperationLogStore().markIrreversible(S, I);
1776
1776
  }, B = (S, I, b, D = "success", C) => n.value?.getOperationLogStore().logAction(S, I, b, D, C) ?? "", X = (S) => {
1777
1777
  n.value?.getOperationLogStore().configure(S);
@@ -1779,10 +1779,10 @@ function ds(e) {
1779
1779
  if (t && n.value)
1780
1780
  try {
1781
1781
  const S = n.value.getOperationLogStore(), I = Ln(S);
1782
- d.value = I.operations.value, m.value = I.currentIndex.value, zt(
1782
+ _.value = I.operations.value, m.value = I.currentIndex.value, zt(
1783
1783
  () => I.operations.value,
1784
1784
  (b) => {
1785
- d.value = b;
1785
+ _.value = b;
1786
1786
  }
1787
1787
  ), zt(
1788
1788
  () => I.currentIndex.value,
@@ -1903,7 +1903,7 @@ function ds(e) {
1903
1903
  }
1904
1904
  };
1905
1905
  (e.doctype || t?.router) && (Xr("hstPathProvider", v), Xr("hstChangeHandler", y));
1906
- const _ = (S, I) => {
1906
+ const g = (S, I) => {
1907
1907
  if (!n.value)
1908
1908
  throw new Error("Stonecrop instance not available");
1909
1909
  return n.value.initializeNestedData(S, I);
@@ -1915,7 +1915,7 @@ function ds(e) {
1915
1915
  if (!n.value)
1916
1916
  throw new Error("Stonecrop instance not available");
1917
1917
  return n.value.collectRecordPayload(S, I);
1918
- }, _t = (S, I) => ({
1918
+ }, gt = (S, I) => ({
1919
1919
  provideHSTPath: (C) => `${S}.${C}`,
1920
1920
  handleHSTChange: (C) => {
1921
1921
  const Nt = C.path.startsWith(S) ? C.path : `${S}.${C.fieldname}`;
@@ -1925,22 +1925,22 @@ function ds(e) {
1925
1925
  });
1926
1926
  }
1927
1927
  }), Ot = {
1928
- operations: d,
1928
+ operations: _,
1929
1929
  currentIndex: m,
1930
- undoRedoState: k,
1931
- canUndo: E,
1930
+ undoRedoState: A,
1931
+ canUndo: R,
1932
1932
  canRedo: O,
1933
1933
  undoCount: w,
1934
1934
  redoCount: K,
1935
1935
  undo: $,
1936
1936
  redo: z,
1937
1937
  startBatch: Y,
1938
- commitBatch: gt,
1938
+ commitBatch: _t,
1939
1939
  cancelBatch: ce,
1940
1940
  clear: fe,
1941
1941
  getOperationsFor: bt,
1942
1942
  getSnapshot: Wt,
1943
- markIrreversible: R,
1943
+ markIrreversible: E,
1944
1944
  logAction: B,
1945
1945
  configure: X
1946
1946
  };
@@ -1952,15 +1952,15 @@ function ds(e) {
1952
1952
  hstStore: i,
1953
1953
  formData: o,
1954
1954
  resolvedSchema: u,
1955
- initializeNestedData: _,
1955
+ initializeNestedData: g,
1956
1956
  fetchNestedData: U,
1957
1957
  collectRecordPayload: ft,
1958
- createNestedContext: _t,
1958
+ createNestedContext: gt,
1959
1959
  isLoading: c,
1960
1960
  error: f,
1961
1961
  resolvedDoctype: h,
1962
1962
  isWorkflowReady: l,
1963
- blockedLinks: g
1963
+ blockedLinks: d
1964
1964
  } : !e.doctype && t?.router ? {
1965
1965
  stonecrop: n,
1966
1966
  operationLog: Ot,
@@ -1969,15 +1969,15 @@ function ds(e) {
1969
1969
  hstStore: i,
1970
1970
  formData: o,
1971
1971
  resolvedSchema: u,
1972
- initializeNestedData: _,
1972
+ initializeNestedData: g,
1973
1973
  fetchNestedData: U,
1974
1974
  collectRecordPayload: ft,
1975
- createNestedContext: _t,
1975
+ createNestedContext: gt,
1976
1976
  isLoading: c,
1977
1977
  error: f,
1978
1978
  resolvedDoctype: h,
1979
1979
  isWorkflowReady: l,
1980
- blockedLinks: g
1980
+ blockedLinks: d
1981
1981
  } : {
1982
1982
  stonecrop: n,
1983
1983
  operationLog: Ot
@@ -2012,38 +2012,38 @@ function qn(e) {
2012
2012
  const r = (zn() ? xe("$operationLogStore", void 0) : void 0) || Ie();
2013
2013
  e && r.configure(e);
2014
2014
  const { operations: n, currentIndex: i, undoRedoState: o, canUndo: s, canRedo: a, undoCount: u, redoCount: c } = Ln(r);
2015
- function f(k) {
2016
- return r.undo(k);
2015
+ function f(A) {
2016
+ return r.undo(A);
2017
2017
  }
2018
- function h(k) {
2019
- return r.redo(k);
2018
+ function h(A) {
2019
+ return r.redo(A);
2020
2020
  }
2021
2021
  function l() {
2022
2022
  r.startBatch();
2023
2023
  }
2024
- function g(k) {
2025
- return r.commitBatch(k);
2024
+ function d(A) {
2025
+ return r.commitBatch(A);
2026
2026
  }
2027
2027
  function p() {
2028
2028
  r.cancelBatch();
2029
2029
  }
2030
- function d() {
2030
+ function _() {
2031
2031
  r.clear();
2032
2032
  }
2033
- function m(k, $) {
2034
- return r.getOperationsFor(k, $);
2033
+ function m(A, $) {
2034
+ return r.getOperationsFor(A, $);
2035
2035
  }
2036
- function E() {
2036
+ function R() {
2037
2037
  return r.getSnapshot();
2038
2038
  }
2039
- function O(k, $) {
2040
- r.markIrreversible(k, $);
2039
+ function O(A, $) {
2040
+ r.markIrreversible(A, $);
2041
2041
  }
2042
- function w(k, $, z, Y = "success", gt) {
2043
- return r.logAction(k, $, z, Y, gt);
2042
+ function w(A, $, z, Y = "success", _t) {
2043
+ return r.logAction(A, $, z, Y, _t);
2044
2044
  }
2045
- function K(k) {
2046
- r.configure(k);
2045
+ function K(A) {
2046
+ r.configure(A);
2047
2047
  }
2048
2048
  return {
2049
2049
  // State
@@ -2058,17 +2058,17 @@ function qn(e) {
2058
2058
  undo: f,
2059
2059
  redo: h,
2060
2060
  startBatch: l,
2061
- commitBatch: g,
2061
+ commitBatch: d,
2062
2062
  cancelBatch: p,
2063
- clear: d,
2063
+ clear: _,
2064
2064
  getOperationsFor: m,
2065
- getSnapshot: E,
2065
+ getSnapshot: R,
2066
2066
  markIrreversible: O,
2067
2067
  logAction: w,
2068
2068
  configure: K
2069
2069
  };
2070
2070
  }
2071
- function gs(e, t = !0) {
2071
+ function _s(e, t = !0) {
2072
2072
  if (!t) return;
2073
2073
  const { undo: r, redo: n, canUndo: i, canRedo: o } = qn(), s = ro();
2074
2074
  he(s["Ctrl+Z"], () => {
@@ -2083,7 +2083,7 @@ function gs(e, t = !0) {
2083
2083
  o.value && n(e);
2084
2084
  });
2085
2085
  }
2086
- async function _s(e, t) {
2086
+ async function gs(e, t) {
2087
2087
  const { startBatch: r, commitBatch: n, cancelBatch: i } = qn();
2088
2088
  r();
2089
2089
  try {
@@ -2183,8 +2183,8 @@ function ao(e) {
2183
2183
  var t = Je(e);
2184
2184
  return t && t === e.keys;
2185
2185
  }
2186
- var Ae = "delete", L = 5, ot = 1 << L, Q = ot - 1, A = {};
2187
- function gr() {
2186
+ var ke = "delete", L = 5, ot = 1 << L, Q = ot - 1, k = {};
2187
+ function _r() {
2188
2188
  return { value: !1 };
2189
2189
  }
2190
2190
  function ht(e) {
@@ -2210,7 +2210,7 @@ function jn() {
2210
2210
  function Ge(e, t, r) {
2211
2211
  return (e === 0 && !xn(e) || r !== void 0 && e <= -r) && (t === void 0 || r !== void 0 && t >= r);
2212
2212
  }
2213
- function ke(e, t) {
2213
+ function Ae(e, t) {
2214
2214
  return Bn(e, t, 0);
2215
2215
  }
2216
2216
  function Ze(e, t) {
@@ -2257,7 +2257,7 @@ function Kn(e) {
2257
2257
  }
2258
2258
  var rt = /* @__PURE__ */ (function(e) {
2259
2259
  function t(r) {
2260
- return r == null ? Ar() : St(r) ? r.toSeq() : co(r);
2260
+ return r == null ? kr() : St(r) ? r.toSeq() : co(r);
2261
2261
  }
2262
2262
  return e && (t.__proto__ = e), t.prototype = Object.create(e && e.prototype), t.prototype.constructor = t, t.prototype.toSeq = function() {
2263
2263
  return this;
@@ -2291,14 +2291,14 @@ var rt = /* @__PURE__ */ (function(e) {
2291
2291
  }, t;
2292
2292
  })(G), qt = /* @__PURE__ */ (function(e) {
2293
2293
  function t(r) {
2294
- return r == null ? Ar().toKeyedSeq() : at(r) ? P(r) ? r.toSeq() : r.fromEntrySeq() : Bt(r) ? r.toSeq() : kr(r);
2294
+ return r == null ? kr().toKeyedSeq() : at(r) ? P(r) ? r.toSeq() : r.fromEntrySeq() : Bt(r) ? r.toSeq() : Ar(r);
2295
2295
  }
2296
2296
  return e && (t.__proto__ = e), t.prototype = Object.create(e && e.prototype), t.prototype.constructor = t, t.prototype.toKeyedSeq = function() {
2297
2297
  return this;
2298
2298
  }, t;
2299
2299
  })(rt), dt = /* @__PURE__ */ (function(e) {
2300
2300
  function t(r) {
2301
- return r == null ? Ar() : at(r) ? P(r) ? r.entrySeq() : r.toIndexedSeq() : Bt(r) ? r.toSeq().entrySeq() : Hn(r);
2301
+ return r == null ? kr() : at(r) ? P(r) ? r.entrySeq() : r.toIndexedSeq() : Bt(r) ? r.toSeq().entrySeq() : Hn(r);
2302
2302
  }
2303
2303
  return e && (t.__proto__ = e), t.prototype = Object.create(e && e.prototype), t.prototype.constructor = t, t.of = function() {
2304
2304
  return t(arguments);
@@ -2398,10 +2398,10 @@ var uo = /* @__PURE__ */ (function(e) {
2398
2398
  });
2399
2399
  }, t;
2400
2400
  })(dt), sn;
2401
- function Ar() {
2401
+ function kr() {
2402
2402
  return sn || (sn = new Jt([]));
2403
2403
  }
2404
- function kr(e) {
2404
+ function Ar(e) {
2405
2405
  var t = Mr(e);
2406
2406
  if (t)
2407
2407
  return t.fromEntrySeq();
@@ -2461,15 +2461,15 @@ function nt(e) {
2461
2461
  case "number":
2462
2462
  return ho(t);
2463
2463
  case "string":
2464
- return t.length > yo ? lo(t) : _r(t);
2464
+ return t.length > yo ? lo(t) : gr(t);
2465
2465
  case "object":
2466
2466
  case "function":
2467
- return go(t);
2467
+ return _o(t);
2468
2468
  case "symbol":
2469
2469
  return po(t);
2470
2470
  default:
2471
2471
  if (typeof t.toString == "function")
2472
- return _r(t.toString());
2472
+ return gr(t.toString());
2473
2473
  throw new Error("Value type " + typeof t + " cannot be hashed.");
2474
2474
  }
2475
2475
  }
@@ -2489,9 +2489,9 @@ function ho(e) {
2489
2489
  }
2490
2490
  function lo(e) {
2491
2491
  var t = ur[e];
2492
- return t === void 0 && (t = _r(e), ar === mo && (ar = 0, ur = {}), ar++, ur[e] = t), t;
2492
+ return t === void 0 && (t = gr(e), ar === mo && (ar = 0, ur = {}), ar++, ur[e] = t), t;
2493
2493
  }
2494
- function _r(e) {
2494
+ function gr(e) {
2495
2495
  for (var t = 0, r = 0; r < e.length; r++)
2496
2496
  t = 31 * t + e.charCodeAt(r) | 0;
2497
2497
  return Xe(t);
@@ -2500,9 +2500,9 @@ function po(e) {
2500
2500
  var t = fn[e];
2501
2501
  return t !== void 0 || (t = Vn(), fn[e] = t), t;
2502
2502
  }
2503
- function go(e) {
2503
+ function _o(e) {
2504
2504
  var t;
2505
- if (vr && (t = yr.get(e), t !== void 0) || (t = e[Pt], t !== void 0) || !cn && (t = e.propertyIsEnumerable && e.propertyIsEnumerable[Pt], t !== void 0 || (t = _o(e), t !== void 0)))
2505
+ if (vr && (t = yr.get(e), t !== void 0) || (t = e[Pt], t !== void 0) || !cn && (t = e.propertyIsEnumerable && e.propertyIsEnumerable[Pt], t !== void 0 || (t = go(e), t !== void 0)))
2506
2506
  return t;
2507
2507
  if (t = Vn(), vr)
2508
2508
  yr.set(e, t);
@@ -2538,7 +2538,7 @@ var un = Object.isExtensible, cn = (function() {
2538
2538
  return !1;
2539
2539
  }
2540
2540
  })();
2541
- function _o(e) {
2541
+ function go(e) {
2542
2542
  if (e && e.nodeType > 0)
2543
2543
  switch (e.nodeType) {
2544
2544
  case 1:
@@ -2718,8 +2718,8 @@ function Xn(e, t, r) {
2718
2718
  return n.size = e.size, n.has = function(i) {
2719
2719
  return e.has(i);
2720
2720
  }, n.get = function(i, o) {
2721
- var s = e.get(i, A);
2722
- return s === A ? o : t.call(r, s, i, e);
2721
+ var s = e.get(i, k);
2722
+ return s === k ? o : t.call(r, s, i, e);
2723
2723
  }, n.__iterateUncached = function(i, o) {
2724
2724
  var s = this;
2725
2725
  return e.__iterate(
@@ -2788,11 +2788,11 @@ function $r(e, t) {
2788
2788
  function Qn(e, t, r, n) {
2789
2789
  var i = wt(e);
2790
2790
  return n && (i.has = function(o) {
2791
- var s = e.get(o, A);
2792
- return s !== A && !!t.call(r, s, o, e);
2791
+ var s = e.get(o, k);
2792
+ return s !== k && !!t.call(r, s, o, e);
2793
2793
  }, i.get = function(o, s) {
2794
- var a = e.get(o, A);
2795
- return a !== A && t.call(r, a, o, e) ? a : s;
2794
+ var a = e.get(o, k);
2795
+ return a !== k && t.call(r, a, o, e) ? a : s;
2796
2796
  }), i.__iterateUncached = function(o, s) {
2797
2797
  var a = this, u = 0;
2798
2798
  return e.__iterate(function(c, f, h) {
@@ -2854,7 +2854,7 @@ function zr(e, t, r, n) {
2854
2854
  return e;
2855
2855
  if (typeof i > "u" && (t < 0 || r < 0))
2856
2856
  return zr(e.toSeq().cacheResult(), t, r, n);
2857
- var o = ke(t, i), s = Ze(r, i), a = s - o, u;
2857
+ var o = Ae(t, i), s = Ze(r, i), a = s - o, u;
2858
2858
  a === a && (u = a < 0 ? 0 : a);
2859
2859
  var c = wt(e);
2860
2860
  return c.size = u === 0 ? u : e.size && u || void 0, !n && Rr(e) && u >= 0 && (c.get = function(f, h) {
@@ -2865,24 +2865,24 @@ function zr(e, t, r, n) {
2865
2865
  return 0;
2866
2866
  if (h)
2867
2867
  return this.cacheResult().__iterate(f, h);
2868
- var g = 0, p = !0, d = 0;
2869
- return e.__iterate(function(m, E) {
2870
- if (!(p && (p = g++ < o)))
2871
- return d++, f(m, n ? E : d - 1, l) !== !1 && d !== u;
2872
- }), d;
2868
+ var d = 0, p = !0, _ = 0;
2869
+ return e.__iterate(function(m, R) {
2870
+ if (!(p && (p = d++ < o)))
2871
+ return _++, f(m, n ? R : _ - 1, l) !== !1 && _ !== u;
2872
+ }), _;
2873
2873
  }, c.__iteratorUncached = function(f, h) {
2874
2874
  if (u !== 0 && h)
2875
2875
  return this.cacheResult().__iterator(f, h);
2876
2876
  if (u === 0)
2877
2877
  return new M(tt);
2878
- var l = e.__iterator(f, h), g = 0, p = 0;
2878
+ var l = e.__iterator(f, h), d = 0, p = 0;
2879
2879
  return new M(function() {
2880
- for (; g++ < o; )
2880
+ for (; d++ < o; )
2881
2881
  l.next();
2882
2882
  if (++p > u)
2883
2883
  return tt();
2884
- var d = l.next();
2885
- return n || f === ut || d.done ? d : f === ie ? F(f, p - 1, void 0, d) : F(f, p - 1, d.value[1], d);
2884
+ var _ = l.next();
2885
+ return n || f === ut || _.done ? _ : f === ie ? F(f, p - 1, void 0, _) : F(f, p - 1, _.value[1], _);
2886
2886
  });
2887
2887
  }, c;
2888
2888
  }
@@ -2931,14 +2931,14 @@ function ti(e, t, r, n) {
2931
2931
  return this.cacheResult().__iterator(o, s);
2932
2932
  var u = e.__iterator(ct, s), c = !0, f = 0;
2933
2933
  return new M(function() {
2934
- var h, l, g;
2934
+ var h, l, d;
2935
2935
  do {
2936
2936
  if (h = u.next(), h.done)
2937
2937
  return n || o === ut ? h : o === ie ? F(o, f++, void 0, h) : F(o, f++, h.value[1], h);
2938
2938
  var p = h.value;
2939
- l = p[0], g = p[1], c && (c = t.call(r, g, l, a));
2939
+ l = p[0], d = p[1], c && (c = t.call(r, d, l, a));
2940
2940
  } while (c);
2941
- return o === ct ? h : F(o, l, g, h);
2941
+ return o === ct ? h : F(o, l, d, h);
2942
2942
  });
2943
2943
  }, i;
2944
2944
  }
@@ -3000,7 +3000,7 @@ var Eo = /* @__PURE__ */ (function(e) {
3000
3000
  })(rt);
3001
3001
  function Ro(e, t) {
3002
3002
  var r = P(e), n = [e].concat(t).map(function(o) {
3003
- return at(o) ? r && (o = pt(o)) : o = r ? kr(o) : Hn(Array.isArray(o) ? o : [o]), o;
3003
+ return at(o) ? r && (o = pt(o)) : o = r ? Ar(o) : Hn(Array.isArray(o) ? o : [o]), o;
3004
3004
  }).filter(function(o) {
3005
3005
  return o.size !== 0;
3006
3006
  });
@@ -3052,7 +3052,7 @@ function Io(e, t, r) {
3052
3052
  return n(t.call(r, i, o, e));
3053
3053
  }).flatten(!0);
3054
3054
  }
3055
- function Ao(e, t) {
3055
+ function ko(e, t) {
3056
3056
  var r = wt(e);
3057
3057
  return r.size = e.size && e.size * 2 - 1, r.__iterateUncached = function(n, i) {
3058
3058
  var o = this, s = 0;
@@ -3204,9 +3204,9 @@ function si(e, t, r) {
3204
3204
  ni(
3205
3205
  s,
3206
3206
  f,
3207
- A,
3207
+ k,
3208
3208
  function(h) {
3209
- return h === A ? c : r(h, c, f);
3209
+ return h === k ? c : r(h, c, f);
3210
3210
  }
3211
3211
  );
3212
3212
  } : function(c, f) {
@@ -3215,9 +3215,9 @@ function si(e, t, r) {
3215
3215
  n[u].forEach(a);
3216
3216
  });
3217
3217
  }
3218
- var ko = Object.prototype.toString;
3218
+ var Ao = Object.prototype.toString;
3219
3219
  function Mo(e) {
3220
- if (!e || typeof e != "object" || ko.call(e) !== "[object Object]")
3220
+ if (!e || typeof e != "object" || Ao.call(e) !== "[object Object]")
3221
3221
  return !1;
3222
3222
  var t = Object.getPrototypeOf(e);
3223
3223
  if (t === null)
@@ -3298,7 +3298,7 @@ function Nr(e) {
3298
3298
  });
3299
3299
  }
3300
3300
  function To(e, t, r) {
3301
- return ae(e, t, A, function() {
3301
+ return ae(e, t, k, function() {
3302
3302
  return r;
3303
3303
  });
3304
3304
  }
@@ -3344,9 +3344,9 @@ var Ct = /* @__PURE__ */ (function(e) {
3344
3344
  }, t.prototype.get = function(n, i) {
3345
3345
  return this._root ? this._root.get(0, void 0, n, i) : i;
3346
3346
  }, t.prototype.set = function(n, i) {
3347
- return _n(this, n, i);
3347
+ return gn(this, n, i);
3348
3348
  }, t.prototype.remove = function(n) {
3349
- return _n(this, n, A);
3349
+ return gn(this, n, k);
3350
3350
  }, t.prototype.deleteAll = function(n) {
3351
3351
  var i = G(n);
3352
3352
  return i.size === 0 ? this : this.withMutations(function(o) {
@@ -3381,7 +3381,7 @@ var Ct = /* @__PURE__ */ (function(e) {
3381
3381
  Ct.isMap = xr;
3382
3382
  var N = Ct.prototype;
3383
3383
  N[ci] = !0;
3384
- N[Ae] = N.remove;
3384
+ N[ke] = N.remove;
3385
3385
  N.removeAll = N.deleteAll;
3386
3386
  N.setIn = Pr;
3387
3387
  N.removeIn = N.deleteIn = Hr;
@@ -3413,7 +3413,7 @@ Se.prototype.get = function(t, r, n, i) {
3413
3413
  return i;
3414
3414
  };
3415
3415
  Se.prototype.update = function(t, r, n, i, o, s, a) {
3416
- for (var u = o === A, c = this.entries, f = 0, h = c.length; f < h && !st(i, c[f][0]); f++)
3416
+ for (var u = o === k, c = this.entries, f = 0, h = c.length; f < h && !st(i, c[f][0]); f++)
3417
3417
  ;
3418
3418
  var l = f < h;
3419
3419
  if (l ? c[f][1] === o : u)
@@ -3421,8 +3421,8 @@ Se.prototype.update = function(t, r, n, i, o, s, a) {
3421
3421
  if (ht(a), (u || !l) && ht(s), !(u && c.length === 1)) {
3422
3422
  if (!l && !u && c.length >= Fo)
3423
3423
  return Do(t, c, i, o);
3424
- var g = t && t === this.ownerID, p = g ? c : vt(c);
3425
- return l ? u ? f === h - 1 ? p.pop() : p[f] = p.pop() : p[f] = [i, o] : p.push([i, o]), g ? (this.entries = p, this) : new Se(t, p);
3424
+ var d = t && t === this.ownerID, p = d ? c : vt(c);
3425
+ return l ? u ? f === h - 1 ? p.pop() : p[f] = p.pop() : p[f] = [i, o] : p.push([i, o]), d ? (this.entries = p, this) : new Se(t, p);
3426
3426
  }
3427
3427
  };
3428
3428
  var Zt = function(t, r, n) {
@@ -3441,9 +3441,9 @@ Zt.prototype.get = function(t, r, n, i) {
3441
3441
  Zt.prototype.update = function(t, r, n, i, o, s, a) {
3442
3442
  n === void 0 && (n = nt(i));
3443
3443
  var u = (r === 0 ? n : n >>> r) & Q, c = 1 << u, f = this.bitmap, h = (f & c) !== 0;
3444
- if (!h && o === A)
3444
+ if (!h && o === k)
3445
3445
  return this;
3446
- var l = fi(f & c - 1), g = this.nodes, p = h ? g[l] : void 0, d = Wr(
3446
+ var l = fi(f & c - 1), d = this.nodes, p = h ? d[l] : void 0, _ = Wr(
3447
3447
  p,
3448
3448
  t,
3449
3449
  r + L,
@@ -3453,16 +3453,16 @@ Zt.prototype.update = function(t, r, n, i, o, s, a) {
3453
3453
  s,
3454
3454
  a
3455
3455
  );
3456
- if (d === p)
3456
+ if (_ === p)
3457
3457
  return this;
3458
- if (!h && d && g.length >= jo)
3459
- return qo(t, g, f, u, d);
3460
- if (h && !d && g.length === 2 && vn(g[l ^ 1]))
3461
- return g[l ^ 1];
3462
- if (h && d && g.length === 1 && vn(d))
3463
- return d;
3464
- var m = t && t === this.ownerID, E = h ? d ? f : f ^ c : f | c, O = h ? d ? hi(g, l, d, m) : Po(g, l, m) : No(g, l, d, m);
3465
- return m ? (this.bitmap = E, this.nodes = O, this) : new Zt(t, E, O);
3458
+ if (!h && _ && d.length >= jo)
3459
+ return qo(t, d, f, u, _);
3460
+ if (h && !_ && d.length === 2 && vn(d[l ^ 1]))
3461
+ return d[l ^ 1];
3462
+ if (h && _ && d.length === 1 && vn(_))
3463
+ return _;
3464
+ var m = t && t === this.ownerID, R = h ? _ ? f : f ^ c : f | c, O = h ? _ ? hi(d, l, _, m) : Po(d, l, m) : No(d, l, _, m);
3465
+ return m ? (this.bitmap = R, this.nodes = O, this) : new Zt(t, R, O);
3466
3466
  };
3467
3467
  var we = function(t, r, n) {
3468
3468
  this.ownerID = t, this.count = r, this.nodes = n;
@@ -3474,7 +3474,7 @@ we.prototype.get = function(t, r, n, i) {
3474
3474
  };
3475
3475
  we.prototype.update = function(t, r, n, i, o, s, a) {
3476
3476
  n === void 0 && (n = nt(i));
3477
- var u = (r === 0 ? n : n >>> r) & Q, c = o === A, f = this.nodes, h = f[u];
3477
+ var u = (r === 0 ? n : n >>> r) & Q, c = o === k, f = this.nodes, h = f[u];
3478
3478
  if (c && !h)
3479
3479
  return this;
3480
3480
  var l = Wr(
@@ -3489,13 +3489,13 @@ we.prototype.update = function(t, r, n, i, o, s, a) {
3489
3489
  );
3490
3490
  if (l === h)
3491
3491
  return this;
3492
- var g = this.count;
3492
+ var d = this.count;
3493
3493
  if (!h)
3494
- g++;
3495
- else if (!l && (g--, g < Bo))
3496
- return Co(t, f, g, u);
3497
- var p = t && t === this.ownerID, d = hi(f, u, l, p);
3498
- return p ? (this.count = g, this.nodes = d, this) : new we(t, g, d);
3494
+ d++;
3495
+ else if (!l && (d--, d < Bo))
3496
+ return Co(t, f, d, u);
3497
+ var p = t && t === this.ownerID, _ = hi(f, u, l, p);
3498
+ return p ? (this.count = d, this.nodes = _, this) : new we(t, d, _);
3499
3499
  };
3500
3500
  var Xt = function(t, r, n) {
3501
3501
  this.ownerID = t, this.keyHash = r, this.entries = n;
@@ -3508,7 +3508,7 @@ Xt.prototype.get = function(t, r, n, i) {
3508
3508
  };
3509
3509
  Xt.prototype.update = function(t, r, n, i, o, s, a) {
3510
3510
  n === void 0 && (n = nt(i));
3511
- var u = o === A;
3511
+ var u = o === k;
3512
3512
  if (n !== this.keyHash)
3513
3513
  return u ? this : (ht(a), ht(s), Kr(this, t, r, n, [i, o]));
3514
3514
  for (var c = this.entries, f = 0, h = c.length; f < h && !st(i, c[f][0]); f++)
@@ -3518,8 +3518,8 @@ Xt.prototype.update = function(t, r, n, i, o, s, a) {
3518
3518
  return this;
3519
3519
  if (ht(a), (u || !l) && ht(s), u && h === 2)
3520
3520
  return new Rt(t, this.keyHash, c[f ^ 1]);
3521
- var g = t && t === this.ownerID, p = g ? c : vt(c);
3522
- return l ? u ? f === h - 1 ? p.pop() : p[f] = p.pop() : p[f] = [i, o] : p.push([i, o]), g ? (this.entries = p, this) : new Xt(t, this.keyHash, p);
3521
+ var d = t && t === this.ownerID, p = d ? c : vt(c);
3522
+ return l ? u ? f === h - 1 ? p.pop() : p[f] = p.pop() : p[f] = [i, o] : p.push([i, o]), d ? (this.entries = p, this) : new Xt(t, this.keyHash, p);
3523
3523
  };
3524
3524
  var Rt = function(t, r, n) {
3525
3525
  this.ownerID = t, this.keyHash = r, this.entry = n;
@@ -3528,7 +3528,7 @@ Rt.prototype.get = function(t, r, n, i) {
3528
3528
  return st(n, this.entry[0]) ? this.entry[1] : i;
3529
3529
  };
3530
3530
  Rt.prototype.update = function(t, r, n, i, o, s, a) {
3531
- var u = o === A, c = st(i, this.entry[0]);
3531
+ var u = o === k, c = st(i, this.entry[0]);
3532
3532
  if (c ? o === this.entry[1] : u)
3533
3533
  return this;
3534
3534
  if (ht(a), u) {
@@ -3596,14 +3596,14 @@ function Ur(e, t, r, n) {
3596
3596
  var i = Object.create(N);
3597
3597
  return i.size = e, i._root = t, i.__ownerID = r, i.__hash = n, i.__altered = !1, i;
3598
3598
  }
3599
- var gn;
3599
+ var _n;
3600
3600
  function yt() {
3601
- return gn || (gn = Ur(0));
3601
+ return _n || (_n = Ur(0));
3602
3602
  }
3603
- function _n(e, t, r) {
3603
+ function gn(e, t, r) {
3604
3604
  var n, i;
3605
3605
  if (e._root) {
3606
- var o = gr(), s = gr();
3606
+ var o = _r(), s = _r();
3607
3607
  if (n = Wr(
3608
3608
  e._root,
3609
3609
  e.__ownerID,
@@ -3615,9 +3615,9 @@ function _n(e, t, r) {
3615
3615
  s
3616
3616
  ), !s.value)
3617
3617
  return e;
3618
- i = e.size + (o.value ? r === A ? -1 : 1 : 0);
3618
+ i = e.size + (o.value ? r === k ? -1 : 1 : 0);
3619
3619
  } else {
3620
- if (r === A)
3620
+ if (r === k)
3621
3621
  return e;
3622
3622
  i = 1, n = new Se(e.__ownerID, [[t, r]]);
3623
3623
  }
@@ -3632,7 +3632,7 @@ function Wr(e, t, r, n, i, o, s, a) {
3632
3632
  o,
3633
3633
  s,
3634
3634
  a
3635
- ) : o === A ? e : (ht(a), ht(s), new Rt(t, n, [i, o]));
3635
+ ) : o === k ? e : (ht(a), ht(s), new Rt(t, n, [i, o]));
3636
3636
  }
3637
3637
  function vn(e) {
3638
3638
  return e.constructor === Rt || e.constructor === Xt;
@@ -3759,18 +3759,18 @@ function ae(e, t, r, n) {
3759
3759
  r,
3760
3760
  n
3761
3761
  );
3762
- return i === A ? r : i;
3762
+ return i === k ? r : i;
3763
3763
  }
3764
3764
  function di(e, t, r, n, i, o) {
3765
- var s = t === A;
3765
+ var s = t === k;
3766
3766
  if (n === r.length) {
3767
3767
  var a = s ? i : t, u = o(a);
3768
3768
  return u === a ? t : u;
3769
3769
  }
3770
3770
  if (!s && !Dt(t))
3771
3771
  throw new TypeError("Cannot update within non-data-structure value in path [" + Array.from(r).slice(0, n).map(be) + "]: " + t);
3772
- var c = r[n], f = s ? A : pi(t, c, A), h = di(
3773
- f === A ? e : St(f),
3772
+ var c = r[n], f = s ? k : pi(t, c, k), h = di(
3773
+ f === k ? e : St(f),
3774
3774
  // @ts-expect-error mixed type
3775
3775
  f,
3776
3776
  r,
@@ -3778,27 +3778,27 @@ function di(e, t, r, n, i, o) {
3778
3778
  i,
3779
3779
  o
3780
3780
  );
3781
- return h === f ? t : h === A ? Uo(t, c) : Wo(s ? e ? yt() : {} : t, c, h);
3781
+ return h === f ? t : h === k ? Uo(t, c) : Wo(s ? e ? yt() : {} : t, c, h);
3782
3782
  }
3783
3783
  function Ko(e, t) {
3784
3784
  return ae(e, t, function() {
3785
- return A;
3785
+ return k;
3786
3786
  });
3787
3787
  }
3788
3788
  function Hr(e) {
3789
3789
  return Ko(this, e);
3790
3790
  }
3791
- var gi = "@@__IMMUTABLE_LIST__@@";
3792
- function _i(e) {
3791
+ var _i = "@@__IMMUTABLE_LIST__@@";
3792
+ function gi(e) {
3793
3793
  return !!(e && // @ts-expect-error: maybeList is typed as `{}`, need to change in 6.0 to `maybeList && typeof maybeList === 'object' && IS_LIST_SYMBOL in maybeList`
3794
- e[gi]);
3794
+ e[_i]);
3795
3795
  }
3796
3796
  var Qt = /* @__PURE__ */ (function(e) {
3797
3797
  function t(r) {
3798
3798
  var n = Be();
3799
3799
  if (r == null)
3800
3800
  return n;
3801
- if (_i(r))
3801
+ if (gi(r))
3802
3802
  return r;
3803
3803
  var i = e(r), o = i.size;
3804
3804
  return o === 0 ? n : (it(o), o > 0 && o < ot ? Oe(0, o, L, null, new $t(i.toArray())) : n.withMutations(function(s) {
@@ -3829,21 +3829,21 @@ var Qt = /* @__PURE__ */ (function(e) {
3829
3829
  }, t.prototype.push = function() {
3830
3830
  var n = arguments, i = this.size;
3831
3831
  return this.withMutations(function(o) {
3832
- At(o, 0, i + n.length);
3832
+ kt(o, 0, i + n.length);
3833
3833
  for (var s = 0; s < n.length; s++)
3834
3834
  o.set(i + s, n[s]);
3835
3835
  });
3836
3836
  }, t.prototype.pop = function() {
3837
- return At(this, 0, -1);
3837
+ return kt(this, 0, -1);
3838
3838
  }, t.prototype.unshift = function() {
3839
3839
  var n = arguments;
3840
3840
  return this.withMutations(function(i) {
3841
- At(i, -n.length);
3841
+ kt(i, -n.length);
3842
3842
  for (var o = 0; o < n.length; o++)
3843
3843
  i.set(o, n[o]);
3844
3844
  });
3845
3845
  }, t.prototype.shift = function() {
3846
- return At(this, 1);
3846
+ return kt(this, 1);
3847
3847
  }, t.prototype.shuffle = function(n) {
3848
3848
  return n === void 0 && (n = Math.random), this.withMutations(function(i) {
3849
3849
  for (var o = i.size, s, a; o; )
@@ -3864,7 +3864,7 @@ var Qt = /* @__PURE__ */ (function(e) {
3864
3864
  });
3865
3865
  });
3866
3866
  }, t.prototype.setSize = function(n) {
3867
- return At(this, 0, n);
3867
+ return kt(this, 0, n);
3868
3868
  }, t.prototype.map = function(n, i) {
3869
3869
  var o = this;
3870
3870
  return this.withMutations(function(s) {
@@ -3873,9 +3873,9 @@ var Qt = /* @__PURE__ */ (function(e) {
3873
3873
  });
3874
3874
  }, t.prototype.slice = function(n, i) {
3875
3875
  var o = this.size;
3876
- return Ge(n, i, o) ? this : At(
3876
+ return Ge(n, i, o) ? this : kt(
3877
3877
  this,
3878
- ke(n, o),
3878
+ Ae(n, o),
3879
3879
  Ze(i, o)
3880
3880
  );
3881
3881
  }, t.prototype.__iterator = function(n, i) {
@@ -3900,10 +3900,10 @@ var Qt = /* @__PURE__ */ (function(e) {
3900
3900
  ) : this.size === 0 ? Be() : (this.__ownerID = n, this.__altered = !1, this);
3901
3901
  }, t;
3902
3902
  })(jt);
3903
- Qt.isList = _i;
3903
+ Qt.isList = gi;
3904
3904
  var W = Qt.prototype;
3905
- W[gi] = !0;
3906
- W[Ae] = W.remove;
3905
+ W[_i] = !0;
3906
+ W[ke] = W.remove;
3907
3907
  W.merge = W.concat;
3908
3908
  W.setIn = Pr;
3909
3909
  W.deleteIn = W.removeIn = Hr;
@@ -3967,17 +3967,17 @@ function yn(e, t) {
3967
3967
  return f === 0 ? a(c, h) : u(c, f, h);
3968
3968
  }
3969
3969
  function a(c, f) {
3970
- var h = f === i ? o && o.array : c && c.array, l = f > r ? 0 : r - f, g = n - f;
3971
- return g > ot && (g = ot), function() {
3972
- if (l === g)
3970
+ var h = f === i ? o && o.array : c && c.array, l = f > r ? 0 : r - f, d = n - f;
3971
+ return d > ot && (d = ot), function() {
3972
+ if (l === d)
3973
3973
  return ye;
3974
- var p = t ? --g : l++;
3974
+ var p = t ? --d : l++;
3975
3975
  return h && h[p];
3976
3976
  };
3977
3977
  }
3978
3978
  function u(c, f, h) {
3979
- var l, g = c && c.array, p = h > r ? 0 : r - h >> f, d = (n - h >> f) + 1;
3980
- return d > ot && (d = ot), function() {
3979
+ var l, d = c && c.array, p = h > r ? 0 : r - h >> f, _ = (n - h >> f) + 1;
3980
+ return _ > ot && (_ = ot), function() {
3981
3981
  for (; ; ) {
3982
3982
  if (l) {
3983
3983
  var m = l();
@@ -3985,13 +3985,13 @@ function yn(e, t) {
3985
3985
  return m;
3986
3986
  l = null;
3987
3987
  }
3988
- if (p === d)
3988
+ if (p === _)
3989
3989
  return ye;
3990
- var E = t ? --d : p++;
3990
+ var R = t ? --_ : p++;
3991
3991
  l = s(
3992
- g && g[E],
3992
+ d && d[R],
3993
3993
  f - L,
3994
- h + (E << f)
3994
+ h + (R << f)
3995
3995
  );
3996
3996
  }
3997
3997
  };
@@ -4009,10 +4009,10 @@ function Ho(e, t, r) {
4009
4009
  return e;
4010
4010
  if (t >= e.size || t < 0)
4011
4011
  return e.withMutations(function(s) {
4012
- t < 0 ? At(s, t).set(0, r) : At(s, 0, t + 1).set(t, r);
4012
+ t < 0 ? kt(s, t).set(0, r) : kt(s, 0, t + 1).set(t, r);
4013
4013
  });
4014
4014
  t += e._origin;
4015
- var n = e._tail, i = e._root, o = gr();
4015
+ var n = e._tail, i = e._root, o = _r();
4016
4016
  return t >= Ee(e._capacity) ? n = mr(n, e.__ownerID, 0, t, r, o) : i = mr(
4017
4017
  i,
4018
4018
  e.__ownerID,
@@ -4052,7 +4052,7 @@ function vi(e, t) {
4052
4052
  return r;
4053
4053
  }
4054
4054
  }
4055
- function At(e, t, r) {
4055
+ function kt(e, t, r) {
4056
4056
  t !== void 0 && (t |= 0), r !== void 0 && (r |= 0);
4057
4057
  var n = e.__ownerID || new Er(), i = e._origin, o = e._capacity, s = i + t, a = r === void 0 ? o : r < 0 ? o + r : i + r;
4058
4058
  if (s === i && a === o)
@@ -4070,14 +4070,14 @@ function At(e, t, r) {
4070
4070
  c && c.array.length ? [c] : [],
4071
4071
  n
4072
4072
  ), u += L;
4073
- var g = e._tail, p = l < h ? vi(e, a - 1) : l > h ? new $t([], n) : g;
4074
- if (g && l > h && s < o && g.array.length) {
4073
+ var d = e._tail, p = l < h ? vi(e, a - 1) : l > h ? new $t([], n) : d;
4074
+ if (d && l > h && s < o && d.array.length) {
4075
4075
  c = te(c, n);
4076
- for (var d = c, m = u; m > L; m -= L) {
4077
- var E = h >>> m & Q;
4078
- d = d.array[E] = te(d.array[E], n);
4076
+ for (var _ = c, m = u; m > L; m -= L) {
4077
+ var R = h >>> m & Q;
4078
+ _ = _.array[R] = te(_.array[R], n);
4079
4079
  }
4080
- d.array[h >>> L & Q] = g;
4080
+ _.array[h >>> L & Q] = d;
4081
4081
  }
4082
4082
  if (a < o && (p = p && p.removeAfter(n, 0, a)), s >= l)
4083
4083
  s -= l, a -= l, u = L, c = null, p = p && p.removeBefore(n, 0, s);
@@ -4123,7 +4123,7 @@ var It = /* @__PURE__ */ (function(e) {
4123
4123
  }, t.prototype.set = function(n, i) {
4124
4124
  return Sn(this, n, i);
4125
4125
  }, t.prototype.remove = function(n) {
4126
- return Sn(this, n, A);
4126
+ return Sn(this, n, k);
4127
4127
  }, t.prototype.__iterate = function(n, i) {
4128
4128
  var o = this;
4129
4129
  return this._list.__iterate(
@@ -4143,7 +4143,7 @@ var It = /* @__PURE__ */ (function(e) {
4143
4143
  })(Ct);
4144
4144
  It.isOrderedMap = yi;
4145
4145
  It.prototype[Lt] = !0;
4146
- It.prototype[Ae] = It.prototype.remove;
4146
+ It.prototype[ke] = It.prototype.remove;
4147
4147
  function Vr(e, t, r, n) {
4148
4148
  var i = Object.create(It.prototype);
4149
4149
  return i.size = e ? e.size : 0, i._map = e, i._list = t, i.__ownerID = r, i.__hash = n, i.__altered = !1, i;
@@ -4154,7 +4154,7 @@ function pe() {
4154
4154
  }
4155
4155
  function Sn(e, t, r) {
4156
4156
  var n = e._map, i = e._list, o = n.get(t), s = o !== void 0, a, u;
4157
- if (r === A) {
4157
+ if (r === k) {
4158
4158
  if (!s)
4159
4159
  return e;
4160
4160
  i.size >= ot && i.size >= n.size * 2 ? (u = i.filter(function(c, f) {
@@ -4224,7 +4224,7 @@ var Yr = /* @__PURE__ */ (function(e) {
4224
4224
  }, t.prototype.slice = function(n, i) {
4225
4225
  if (Ge(n, i, this.size))
4226
4226
  return this;
4227
- var o = ke(n, this.size), s = Ze(i, this.size);
4227
+ var o = Ae(n, this.size), s = Ze(i, this.size);
4228
4228
  if (s !== this.size)
4229
4229
  return e.prototype.slice.call(this, n, i);
4230
4230
  for (var a = this.size - o, u = this._head; o--; )
@@ -4344,10 +4344,10 @@ function Si(e, t) {
4344
4344
  !e.has(u)
4345
4345
  ) : i ? (
4346
4346
  // @ts-expect-error type of `get` does not "catch" the version with `notSetValue`
4347
- !st(u, e.get(c, A))
4347
+ !st(u, e.get(c, k))
4348
4348
  ) : (
4349
4349
  // @ts-expect-error type of `get` does not "catch" the version with `notSetValue`
4350
- !st(e.get(c, A), u)
4350
+ !st(e.get(c, k), u)
4351
4351
  ))
4352
4352
  return s = !1, !1;
4353
4353
  })
@@ -4379,7 +4379,7 @@ var Jo = /* @__PURE__ */ (function(e) {
4379
4379
  var i = (n - this._start) / this._step;
4380
4380
  return i >= 0 && i < this.size && i === Math.floor(i);
4381
4381
  }, t.prototype.slice = function(n, i) {
4382
- return Ge(n, i, this.size) ? this : (n = ke(n, this.size), i = Ze(i, this.size), i <= n ? new t(0, 0) : new t(
4382
+ return Ge(n, i, this.size) ? this : (n = Ae(n, this.size), i = Ze(i, this.size), i <= n ? new t(0, 0) : new t(
4383
4383
  this.get(n, this._end),
4384
4384
  this.get(i, this._end),
4385
4385
  this._step
@@ -4416,7 +4416,7 @@ function Jr(e) {
4416
4416
  }
4417
4417
  var tr = /* @__PURE__ */ (function(e) {
4418
4418
  function t(r) {
4419
- return r == null ? ge() : Jr(r) && !mt(r) ? r : ge().withMutations(function(n) {
4419
+ return r == null ? _e() : Jr(r) && !mt(r) ? r : _e().withMutations(function(n) {
4420
4420
  var i = e(r);
4421
4421
  it(i.size), i.forEach(function(o) {
4422
4422
  return n.add(o);
@@ -4428,9 +4428,9 @@ var tr = /* @__PURE__ */ (function(e) {
4428
4428
  }, t.fromKeys = function(n) {
4429
4429
  return this(pt(n).keySeq());
4430
4430
  }, t.intersect = function(n) {
4431
- return n = G(n).toArray(), n.length ? V.intersect.apply(t(n.pop()), n) : ge();
4431
+ return n = G(n).toArray(), n.length ? V.intersect.apply(t(n.pop()), n) : _e();
4432
4432
  }, t.union = function(n) {
4433
- return n = G(n).toArray(), n.length ? V.union.apply(t(n.pop()), n) : ge();
4433
+ return n = G(n).toArray(), n.length ? V.union.apply(t(n.pop()), n) : _e();
4434
4434
  }, t.prototype.toString = function() {
4435
4435
  return this.__toString("Set {", "}");
4436
4436
  }, t.prototype.has = function(n) {
@@ -4517,7 +4517,7 @@ var tr = /* @__PURE__ */ (function(e) {
4517
4517
  tr.isSet = Jr;
4518
4518
  var V = tr.prototype;
4519
4519
  V[wi] = !0;
4520
- V[Ae] = V.remove;
4520
+ V[ke] = V.remove;
4521
4521
  V.merge = V.concat = V.union;
4522
4522
  V.withMutations = ze;
4523
4523
  V.asImmutable = Me;
@@ -4528,7 +4528,7 @@ V["@@transducer/step"] = function(e, t) {
4528
4528
  V["@@transducer/result"] = function(e) {
4529
4529
  return e.asImmutable();
4530
4530
  };
4531
- V.__empty = ge;
4531
+ V.__empty = _e;
4532
4532
  V.__make = bi;
4533
4533
  function je(e, t) {
4534
4534
  return e.__ownerID ? (e.size = t.size, e._map = t, e) : t === e._map ? e : t.size === 0 ? e.__empty() : e.__make(t);
@@ -4538,12 +4538,12 @@ function bi(e, t) {
4538
4538
  return r.size = e ? e.size : 0, r._map = e, r.__ownerID = t, r;
4539
4539
  }
4540
4540
  var Rn;
4541
- function ge() {
4541
+ function _e() {
4542
4542
  return Rn || (Rn = bi(yt()));
4543
4543
  }
4544
4544
  function Oi(e, t, r) {
4545
4545
  for (var n = li(t), i = 0; i !== n.length; )
4546
- if (e = pi(e, n[i++], A), e === A)
4546
+ if (e = pi(e, n[i++], k), e === k)
4547
4547
  return r;
4548
4548
  return e;
4549
4549
  }
@@ -4551,7 +4551,7 @@ function Ei(e, t) {
4551
4551
  return Oi(this, e, t);
4552
4552
  }
4553
4553
  function Go(e, t) {
4554
- return Oi(e, t, A) !== A;
4554
+ return Oi(e, t, k) !== k;
4555
4555
  }
4556
4556
  function Zo(e) {
4557
4557
  return Go(this, e);
@@ -4820,7 +4820,7 @@ xt(G, {
4820
4820
  return wo(this, t, r);
4821
4821
  },
4822
4822
  has: function(t) {
4823
- return this.get(t, A) !== A;
4823
+ return this.get(t, k) !== k;
4824
4824
  },
4825
4825
  hasIn: Zo,
4826
4826
  isSubset: function(t) {
@@ -4980,7 +4980,7 @@ xt(jt, {
4980
4980
  var n = arguments.length;
4981
4981
  if (r = Math.max(r || 0, 0), n === 0 || n === 2 && !r)
4982
4982
  return this;
4983
- t = ke(t, t < 0 ? this.count() : this.size);
4983
+ t = Ae(t, t < 0 ? this.count() : this.size);
4984
4984
  var i = this.slice(0, t);
4985
4985
  return T(
4986
4986
  this,
@@ -5007,7 +5007,7 @@ xt(jt, {
5007
5007
  return t = Tt(this, t), t >= 0 && (this.size !== void 0 ? this.size === 1 / 0 || t < this.size : this.indexOf(t) !== -1);
5008
5008
  },
5009
5009
  interpose: function(t) {
5010
- return T(this, Ao(this, t));
5010
+ return T(this, ko(this, t));
5011
5011
  },
5012
5012
  interleave: function() {
5013
5013
  var t = [this].concat(vt(arguments)), r = Pe(this.toSeq(), dt.of, t), n = r.flatten(!0);
@@ -5024,11 +5024,11 @@ xt(jt, {
5024
5024
  },
5025
5025
  zip: function() {
5026
5026
  var t = [this].concat(vt(arguments));
5027
- return T(this, Pe(this, An, t));
5027
+ return T(this, Pe(this, kn, t));
5028
5028
  },
5029
5029
  zipAll: function() {
5030
5030
  var t = [this].concat(vt(arguments));
5031
- return T(this, Pe(this, An, t, !0));
5031
+ return T(this, Pe(this, kn, t, !0));
5032
5032
  },
5033
5033
  zipWith: function(t) {
5034
5034
  var r = vt(arguments);
@@ -5058,7 +5058,7 @@ ee.keys = ee.values;
5058
5058
  xt(qt, Te);
5059
5059
  xt(dt, ue);
5060
5060
  xt(se, ee);
5061
- function An() {
5061
+ function kn() {
5062
5062
  return vt(arguments);
5063
5063
  }
5064
5064
  function Ii(e) {
@@ -5088,14 +5088,14 @@ Ut.zip = ue.zip;
5088
5088
  Ut.zipWith = ue.zipWith;
5089
5089
  Ut.zipAll = ue.zipAll;
5090
5090
  Ut.__empty = wr;
5091
- Ut.__make = Ai;
5092
- function Ai(e, t) {
5091
+ Ut.__make = ki;
5092
+ function ki(e, t) {
5093
5093
  var r = Object.create(Ut);
5094
5094
  return r.size = e ? e.size : 0, r._map = e, r.__ownerID = t, r;
5095
5095
  }
5096
- var kn;
5096
+ var An;
5097
5097
  function wr() {
5098
- return kn || (kn = Ai(pe()));
5098
+ return An || (An = ki(pe()));
5099
5099
  }
5100
5100
  function ts(e) {
5101
5101
  if (Bt(e))
@@ -5131,9 +5131,9 @@ var H = function(t, r) {
5131
5131
  ) : es(o, l);
5132
5132
  }
5133
5133
  }
5134
- return this.__ownerID = void 0, this._values = Qt().withMutations(function(g) {
5135
- g.setSize(u._keys.length), pt(a).forEach(function(p, d) {
5136
- g.set(u._indices[d], p === u._defaultValues[d] ? void 0 : p);
5134
+ return this.__ownerID = void 0, this._values = Qt().withMutations(function(d) {
5135
+ d.setSize(u._keys.length), pt(a).forEach(function(p, _) {
5136
+ d.set(u._indices[_], p === u._defaultValues[_] ? void 0 : p);
5137
5137
  });
5138
5138
  }), this;
5139
5139
  }, o = i.prototype = Object.create(q);
@@ -5205,7 +5205,7 @@ H.isRecord = Bt;
5205
5205
  H.getDescriptiveName = Zr;
5206
5206
  var q = H.prototype;
5207
5207
  q[Un] = !0;
5208
- q[Ae] = q.remove;
5208
+ q[ke] = q.remove;
5209
5209
  q.deleteIn = q.removeIn = Hr;
5210
5210
  q.getIn = Ei;
5211
5211
  q.hasIn = Z.hasIn;
@@ -5234,7 +5234,7 @@ function Zr(e) {
5234
5234
  return e.constructor.displayName || e.constructor.name || "Record";
5235
5235
  }
5236
5236
  function re(e) {
5237
- return kr(e._keys.map(function(t) {
5237
+ return Ar(e._keys.map(function(t) {
5238
5238
  return [t, e.get(t)];
5239
5239
  }));
5240
5240
  }
@@ -5251,7 +5251,7 @@ function es(e, t) {
5251
5251
  } catch {
5252
5252
  }
5253
5253
  }
5254
- class ki {
5254
+ class Ai {
5255
5255
  /**
5256
5256
  * The doctype name
5257
5257
  * @public
@@ -5348,19 +5348,19 @@ class ki {
5348
5348
  */
5349
5349
  static fromObject(t) {
5350
5350
  const r = t.fields ? Qt(t.fields) : Qt(), n = t.actions ? Ct(t.actions) : Ct();
5351
- return new ki(t.name, r, t.workflow, n, void 0, t.links);
5351
+ return new Ai(t.name, r, t.workflow, n, void 0, t.links);
5352
5352
  }
5353
5353
  /**
5354
- * Returns the schema as a plain array for use with components that expect
5355
- * plain JavaScript arrays (e.g., AForm, ATable).
5354
+ * Returns the raw authoring schema as a plain array.
5355
+ * For the resolved schema suitable for AForm, use `registry.resolveSchema(doctype)`.
5356
5356
  *
5357
- * @returns Array of schema fields
5357
+ * @returns Array of raw DoctypeField authoring definitions
5358
5358
  *
5359
5359
  * @example
5360
5360
  * ```ts
5361
- * const schemaArray = doctype.getSchemaArray()
5362
- * // Use with AForm
5363
- * <AForm :schema="schemaArray" v-model:data="formData" />
5361
+ * const fields = doctype.getSchemaArray()
5362
+ * // Pass to resolveSchema for AForm-ready output:
5363
+ * const resolved = registry.resolveSchema(doctype)
5364
5364
  * ```
5365
5365
  *
5366
5366
  * @public
@@ -5524,209 +5524,165 @@ class me {
5524
5524
  });
5525
5525
  }
5526
5526
  /**
5527
- * Resolve nested Doctype fields in a schema by embedding child schemas inline.
5527
+ * Resolve a Doctype's authoring schema into a rendered schema array suitable for AForm.
5528
5528
  *
5529
- * Accepts a Doctype and extracts `fields` and `links` internally.
5530
- * Fields array contains both scalar fields and link fields (with fieldtype: 'Link').
5531
- * Render order is determined by the order of fields in the fields array.
5529
+ * Transforms `DoctypeField[]` (authoring space) `ResolvedField[]` (rendering space):
5530
+ * - `kind: 'field'` (not Link) → `ResolvedScalar`
5531
+ * - `kind: 'field'` (Link, no declaration) `ResolvedScalar` with `component: 'AFormLink'`
5532
+ * - `kind: 'field'` (Link, `noneOrMany`/`atLeastOne`) → `ResolvedTable`
5533
+ * - `kind: 'field'` (Link, `one`/`atMostOne`) → `ResolvedLink`
5534
+ * - `kind: 'fieldset'` → `ResolvedFieldset` (children resolved recursively)
5535
+ * - `kind: 'table'` → `ResolvedTable` (columns as `ColumnSchema[]`)
5532
5536
  *
5533
- * For each link field:
5534
- * - Looks up the corresponding link declaration in `links` by fieldname
5535
- * - `cardinality: 'noneOrMany'` or `'atLeastOne'`: auto-derives `columns` from the target's schema,
5536
- * sets `component` to `link.component ?? 'ATable'`, `config: { view: 'list' }`.
5537
- * - `cardinality: 'one'` or `'atMostOne'`: embeds the target schema as the entry's
5538
- * `schema` property, sets `component` to `link.component ?? 'AForm'`.
5539
- *
5540
- * Recurses for deeply nested doctypes. Circular references are protected against.
5541
- * Returns a new array — does not mutate the original.
5537
+ * Circular references are protected against via the `visited` set.
5542
5538
  *
5543
5539
  * @param doctype - The doctype to resolve
5544
5540
  * @param visited - Internal — set of already-visited doctype slugs for cycle detection
5545
- * @returns A new schema array with nested links resolved
5541
+ * @returns A resolved schema array ready for AForm
5546
5542
  *
5547
5543
  * @public
5548
5544
  */
5549
5545
  resolveSchema(t, r) {
5550
5546
  const n = r ?? /* @__PURE__ */ new Set(), i = t.slug;
5551
5547
  if (n.has(i))
5552
- return t.schema ? Array.isArray(t.schema) ? t.schema : Array.from(t.schema) : [];
5548
+ return (t.schema ? t.schema.toArray() : []).filter((c) => c.kind === "field").map(({ cardinality: c, ...f }) => f);
5553
5549
  n.add(i);
5554
- const o = t.schema ? Array.isArray(t.schema) ? t.schema : Array.from(t.schema) : [], s = /* @__PURE__ */ new Map();
5550
+ const o = t.schema ? t.schema.toArray() : [], s = /* @__PURE__ */ new Map();
5555
5551
  if (t.links)
5556
- for (const [u, c] of Object.entries(t.links)) {
5557
- const f = c.fieldname ?? u;
5558
- s.set(f, c);
5559
- }
5560
- const a = [];
5561
- for (const u of o)
5562
- if ("fieldtype" in u && u.fieldtype === "Link") {
5563
- const c = s.get(u.fieldname);
5564
- if (!c) {
5565
- const m = typeof u.options == "string" ? u.options : void 0;
5566
- m === void 0 && console.warn(
5567
- `[Stonecrop] Link field "${u.fieldname}" has no \`options\` or corresponding \`links\` declaration. AFormLink will be created without a \`doctype\` prop, so navigation will not work. Add \`"options": "<doctype-slug>"\` to the field definition.`
5568
- );
5569
- const { doctype: E, ...O } = u;
5570
- a.push({
5571
- ...O,
5572
- component: O.component || "AFormLink",
5573
- ...m !== void 0 ? { doctype: m } : {}
5574
- });
5575
- continue;
5576
- }
5577
- const f = this.registry[c.target];
5578
- if (!f) {
5579
- a.push({ ...u });
5580
- continue;
5581
- }
5582
- const h = this.resolveSchema(f, n), {
5583
- fieldtype: l,
5584
- options: g,
5585
- cardinality: p,
5586
- ...d
5587
- } = u;
5588
- c.cardinality === "noneOrMany" || c.cardinality === "atLeastOne" ? a.push(
5589
- this.buildTableConfig(
5590
- { ...d, label: d.label || u.fieldname },
5591
- h,
5592
- c.component
5593
- )
5594
- ) : a.push({
5595
- ...d,
5596
- label: d.label || u.fieldname,
5597
- component: c.component || d.component || "AForm",
5598
- schema: h
5599
- });
5600
- } else if ("schema" in u && Array.isArray(u.schema)) {
5601
- const c = this.resolveFields(u.schema, s, n);
5602
- a.push({ ...u, schema: c });
5603
- } else
5604
- a.push({ ...u });
5552
+ for (const [u, c] of Object.entries(t.links))
5553
+ s.set(c.fieldname ?? u, c);
5554
+ const a = this.resolveFields(o, s, n);
5605
5555
  return n.delete(i), a;
5606
5556
  }
5607
5557
  /**
5608
- * Recursively resolve a flat fields array using the provided link context.
5609
- * Used by resolveSchema to handle fieldset children.
5558
+ * Recursively resolve a `DoctypeField[]` using the provided link context.
5559
+ * Called by `resolveSchema` and recursively for fieldset children.
5610
5560
  * @internal
5611
5561
  */
5612
5562
  resolveFields(t, r, n) {
5613
5563
  const i = [];
5614
5564
  for (const o of t)
5615
- if ("fieldtype" in o && o.fieldtype === "Link") {
5565
+ if (o.kind === "field" && o.fieldtype === "Link") {
5616
5566
  const s = r.get(o.fieldname);
5617
5567
  if (!s) {
5618
- i.push({ ...o });
5568
+ const p = typeof o.options == "string" ? o.options : void 0;
5569
+ p === void 0 && console.warn(
5570
+ `[Stonecrop] Link field "${o.fieldname}" has no \`options\` or corresponding \`links\` declaration. AFormLink will be created without a \`doctype\` prop, so navigation will not work. Add \`"options": "<doctype-slug>"\` to the field definition.`
5571
+ );
5572
+ const { cardinality: _, ...m } = o;
5573
+ i.push({
5574
+ ...m,
5575
+ component: m.component || "AFormLink",
5576
+ ...p !== void 0 ? { doctype: p } : {}
5577
+ });
5619
5578
  continue;
5620
5579
  }
5621
5580
  const a = this.registry[s.target];
5622
5581
  if (!a) {
5623
- i.push({ ...o });
5582
+ const { cardinality: p, ..._ } = o;
5583
+ i.push({ ..._ });
5624
5584
  continue;
5625
5585
  }
5626
- const u = this.resolveSchema(a, new Set(n)), {
5627
- fieldtype: c,
5628
- options: f,
5629
- cardinality: h,
5630
- ...l
5631
- } = o;
5632
- s.cardinality === "noneOrMany" || s.cardinality === "atLeastOne" ? i.push(
5633
- this.buildTableConfig(
5634
- { ...l, label: l.label || o.fieldname },
5635
- u,
5636
- s.component
5637
- )
5638
- ) : i.push({
5639
- ...l,
5640
- label: l.label || o.fieldname,
5641
- component: s.component || l.component || "AForm",
5642
- schema: u
5643
- });
5644
- } else "schema" in o && Array.isArray(o.schema) ? i.push({ ...o, schema: this.resolveFields(o.schema, r, n) }) : i.push({ ...o });
5586
+ const u = this.resolveSchema(a, new Set(n)), { fieldtype: c, options: f, cardinality: h, kind: l, ...d } = o;
5587
+ if (s.cardinality === "noneOrMany" || s.cardinality === "atLeastOne")
5588
+ i.push(this.buildTableConfig(o, u, s.component));
5589
+ else {
5590
+ const p = {
5591
+ ...d,
5592
+ kind: "link",
5593
+ label: d.label || o.fieldname,
5594
+ component: s.component || d.component || "AForm",
5595
+ schema: u
5596
+ };
5597
+ i.push(p);
5598
+ }
5599
+ } else if (o.kind === "fieldset") {
5600
+ const s = this.resolveFields(o.schema, r, n), { schema: a, ...u } = o, c = {
5601
+ ...u,
5602
+ schema: s
5603
+ };
5604
+ i.push(c);
5605
+ } else if (o.kind === "table") {
5606
+ const { columns: s, config: a, ...u } = o, c = {
5607
+ ...u,
5608
+ kind: "table",
5609
+ component: u.component || "ATable",
5610
+ schema: s,
5611
+ config: a ?? { view: "list" }
5612
+ };
5613
+ i.push(c);
5614
+ } else {
5615
+ const { cardinality: s, ...a } = o;
5616
+ i.push({ ...a });
5617
+ }
5645
5618
  return i;
5646
5619
  }
5647
5620
  /**
5648
- * Build an ATable configuration from a field and child schema.
5649
- * Data-model properties from the source field are preserved via the spread `field` argument.
5621
+ * Build a `ResolvedTable` from a resolved Link field with many cardinality.
5622
+ * Extracts scalar column definitions from the child schema.
5650
5623
  * @internal
5651
5624
  */
5652
5625
  buildTableConfig(t, r, n) {
5653
- const i = {
5654
- ...t,
5655
- fieldname: t.fieldname,
5656
- component: n || t.component || "ATable",
5626
+ const i = r.filter((f) => f.kind === "field").map(({ kind: f, ...h }) => h), o = t.config ?? { view: "list" }, { fieldtype: s, options: a, cardinality: u, ...c } = t;
5627
+ return {
5628
+ ...c,
5657
5629
  kind: "table",
5658
- schema: r,
5659
- config: t.config
5630
+ label: c.label || t.fieldname,
5631
+ component: n || c.component || "ATable",
5632
+ schema: i,
5633
+ config: o
5660
5634
  };
5661
- return i.config || (i.config = { view: "list" }), i;
5662
5635
  }
5663
5636
  /**
5664
- * Initialize a new record with default values based on a schema.
5637
+ * Initialize a new record with default values based on a resolved schema.
5638
+ * Narrows by `kind` discriminator for precise branch selection.
5665
5639
  *
5666
- * @remarks
5667
- * Creates a plain object with keys from the schema's fieldnames and default values
5668
- * derived from each field's `fieldtype`:
5669
- * - Data, Text → `''`
5670
- * - Check → `false`
5671
- * - Int, Float, Decimal, Currency, Quantity → `0`
5672
- * - JSON → `{}`
5673
- * - Doctype with `cardinality: 'noneOrMany'` or `'atLeastOne'` → `[]`
5674
- * - Doctype without `cardinality` or `cardinality: 'one'` → recursively initializes nested record
5675
- * - All others → `null`
5640
+ * - `kind: 'table'` or `kind: 'link'` → `[]` or `{}`
5641
+ * - `kind: 'fieldset'` recursively initializes children as `{}`
5642
+ * - `kind: 'field'` → derives default from `fieldtype`; falls back to `null`
5676
5643
  *
5677
- * For Doctype fields with a resolved `schema` array (cardinality: 'one'), recursively
5678
- * initializes the nested record.
5679
- *
5680
- * @param schema - The schema array to derive defaults from
5644
+ * @param schema - The resolved schema array to derive defaults from
5681
5645
  * @returns A plain object with default values for each field
5682
- *
5683
- * @example
5684
- * ```ts
5685
- * const defaults = registry.initializeRecord(addressSchema)
5686
- * // { street: '', city: '', state: '', zip_code: '' }
5687
- * ```
5688
- *
5689
5646
  * @public
5690
5647
  */
5691
5648
  initializeRecord(t) {
5692
5649
  const r = {};
5693
- return t.forEach((n) => {
5694
- const i = "fieldtype" in n ? n.fieldtype : "Data", o = "cardinality" in n ? n.cardinality : void 0;
5695
- if (o === "noneOrMany" || o === "atLeastOne") {
5696
- r[n.fieldname] = [];
5697
- return;
5698
- }
5699
- if ("kind" in n && n.kind === "table") {
5650
+ for (const n of t)
5651
+ if (n.kind === "table")
5700
5652
  r[n.fieldname] = [];
5701
- return;
5702
- }
5703
- if ("schema" in n && Array.isArray(n.schema)) {
5653
+ else if (n.kind === "link")
5704
5654
  r[n.fieldname] = this.initializeRecord(n.schema);
5705
- return;
5706
- }
5707
- switch (i) {
5708
- case "Data":
5709
- case "Text":
5710
- case "Code":
5711
- r[n.fieldname] = "";
5712
- break;
5713
- case "Check":
5714
- r[n.fieldname] = !1;
5715
- break;
5716
- case "Int":
5717
- case "Float":
5718
- case "Decimal":
5719
- case "Currency":
5720
- case "Quantity":
5721
- r[n.fieldname] = 0;
5722
- break;
5723
- case "JSON":
5724
- r[n.fieldname] = {};
5725
- break;
5726
- default:
5727
- r[n.fieldname] = null;
5655
+ else if (n.kind === "fieldset")
5656
+ r[n.fieldname] = this.initializeRecord(n.schema);
5657
+ else {
5658
+ const i = n.default;
5659
+ if (i !== void 0)
5660
+ r[n.fieldname] = i;
5661
+ else
5662
+ switch (n.fieldtype) {
5663
+ case "Data":
5664
+ case "Text":
5665
+ case "Code":
5666
+ r[n.fieldname] = "";
5667
+ break;
5668
+ case "Check":
5669
+ r[n.fieldname] = !1;
5670
+ break;
5671
+ case "Int":
5672
+ case "Float":
5673
+ case "Decimal":
5674
+ case "Currency":
5675
+ case "Quantity":
5676
+ r[n.fieldname] = 0;
5677
+ break;
5678
+ case "JSON":
5679
+ r[n.fieldname] = {};
5680
+ break;
5681
+ default:
5682
+ r[n.fieldname] = null;
5683
+ }
5728
5684
  }
5729
- }), r;
5685
+ return r;
5730
5686
  }
5731
5687
  /**
5732
5688
  * Get a registered doctype by slug
@@ -5907,16 +5863,13 @@ class ns {
5907
5863
  });
5908
5864
  continue;
5909
5865
  }
5910
- if (!i.component && !("fieldtype" in i) && n.push({
5866
+ i.kind === "field" && !i.component && !i.fieldtype && n.push({
5911
5867
  severity: x.ERROR,
5912
5868
  rule: "required-component-or-fieldtype",
5913
5869
  message: `Field "${i.fieldname}" must have either component or fieldtype property`,
5914
5870
  doctype: t,
5915
5871
  fieldname: i.fieldname
5916
- }), "schema" in i) {
5917
- const o = i.schema, s = Array.isArray(o) ? o : o.toArray?.() || [];
5918
- n.push(...this.validateRequiredProperties(t, s));
5919
- }
5872
+ }), i.kind === "fieldset" && n.push(...this.validateRequiredProperties(t, i.schema));
5920
5873
  }
5921
5874
  return n;
5922
5875
  }
@@ -5927,9 +5880,9 @@ class ns {
5927
5880
  validateLinkFields(t, r, n) {
5928
5881
  const i = [];
5929
5882
  for (const o of r) {
5930
- if (("fieldtype" in o ? o.fieldtype : void 0) === "Link") {
5931
- const a = "options" in o ? o.options : void 0;
5932
- if (!a) {
5883
+ if (o.kind === "field" && o.fieldtype === "Link") {
5884
+ const s = o.options;
5885
+ if (!s) {
5933
5886
  i.push({
5934
5887
  severity: x.ERROR,
5935
5888
  rule: "link-missing-options",
@@ -5939,8 +5892,8 @@ class ns {
5939
5892
  });
5940
5893
  continue;
5941
5894
  }
5942
- const u = typeof a == "string" ? a : "";
5943
- if (!u) {
5895
+ const a = typeof s == "string" ? s : "";
5896
+ if (!a) {
5944
5897
  i.push({
5945
5898
  severity: x.ERROR,
5946
5899
  rule: "link-invalid-options",
@@ -5950,19 +5903,16 @@ class ns {
5950
5903
  });
5951
5904
  continue;
5952
5905
  }
5953
- n.registry[u] || n.registry[u.toLowerCase()] || i.push({
5906
+ n.registry[a] || n.registry[a.toLowerCase()] || i.push({
5954
5907
  severity: x.ERROR,
5955
5908
  rule: "link-invalid-target",
5956
- message: `Link field "${o.fieldname}" references non-existent doctype: "${u}"`,
5909
+ message: `Link field "${o.fieldname}" references non-existent doctype: "${a}"`,
5957
5910
  doctype: t,
5958
5911
  fieldname: o.fieldname,
5959
- context: { targetDoctype: u }
5912
+ context: { targetDoctype: a }
5960
5913
  });
5961
5914
  }
5962
- if ("schema" in o) {
5963
- const a = o.schema, u = Array.isArray(a) ? a : a.toArray?.() || [];
5964
- i.push(...this.validateLinkFields(t, u, n));
5965
- }
5915
+ o.kind === "fieldset" && i.push(...this.validateLinkFields(t, o.schema, n));
5966
5916
  }
5967
5917
  return i;
5968
5918
  }
@@ -5973,7 +5923,7 @@ class ns {
5973
5923
  validateLinkDeclarations(t, r, n, i) {
5974
5924
  const o = [], s = /* @__PURE__ */ new Map();
5975
5925
  for (const a of n)
5976
- "fieldtype" in a && a.fieldtype === "Link" && s.set(a.fieldname, a);
5926
+ a.kind === "field" && a.fieldtype === "Link" && s.set(a.fieldname, a);
5977
5927
  for (const [a, u] of Object.entries(r)) {
5978
5928
  const c = i.registry[u.target];
5979
5929
  if (!c) {
@@ -6014,15 +5964,15 @@ class ns {
6014
5964
  }
6015
5965
  if (u.fieldname) {
6016
5966
  const f = s.get(u.fieldname);
6017
- if (f) {
6018
- const h = "options" in f ? f.options : void 0, l = typeof h == "string" ? h : void 0;
6019
- l && l !== u.target && o.push({
5967
+ if (f && f.kind === "field") {
5968
+ const h = typeof f.options == "string" ? f.options : void 0;
5969
+ h && h !== u.target && o.push({
6020
5970
  severity: x.ERROR,
6021
5971
  rule: "link-field-target-mismatch",
6022
- message: `Link field "${u.fieldname}" targets "${l}" but link declaration targets "${u.target}"`,
5972
+ message: `Link field "${u.fieldname}" targets "${h}" but link declaration targets "${u.target}"`,
6023
5973
  doctype: t,
6024
5974
  fieldname: u.fieldname,
6025
- context: { linkFieldTarget: l, linkTarget: u.target }
5975
+ context: { linkFieldTarget: h, linkTarget: u.target }
6026
5976
  });
6027
5977
  }
6028
5978
  }
@@ -6129,8 +6079,8 @@ function ys(e, t, r, n, i) {
6129
6079
  return is(r).validate(e, t, n, i);
6130
6080
  }
6131
6081
  export {
6132
- ki as Doctype,
6133
- _e as FieldTriggerEngine,
6082
+ Ai as Doctype,
6083
+ ge as FieldTriggerEngine,
6134
6084
  Vt as HST,
6135
6085
  me as Registry,
6136
6086
  ns as SchemaValidator,
@@ -6150,8 +6100,8 @@ export {
6150
6100
  qn as useOperationLog,
6151
6101
  Ie as useOperationLogStore,
6152
6102
  ds as useStonecrop,
6153
- gs as useUndoRedoShortcuts,
6103
+ _s as useUndoRedoShortcuts,
6154
6104
  ys as validateSchema,
6155
- _s as withBatch
6105
+ gs as withBatch
6156
6106
  };
6157
6107
  //# sourceMappingURL=stonecrop.js.map