@dynamicforms/vue-forms 0.11.0 → 0.13.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.
@@ -1,97 +1,55 @@
1
- var Gt = Object.defineProperty, Yt = Object.defineProperties;
2
- var Jt = Object.getOwnPropertyDescriptors;
3
- var q = Object.getOwnPropertySymbols;
4
- var mt = Object.prototype.hasOwnProperty, bt = Object.prototype.propertyIsEnumerable;
5
- var vt = (n) => {
6
- throw TypeError(n);
7
- };
8
- var K = (n, e, t) => e in n ? Gt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, p = (n, e) => {
9
- for (var t in e || (e = {}))
10
- mt.call(e, t) && K(n, t, e[t]);
11
- if (q)
12
- for (var t of q(e))
13
- bt.call(e, t) && K(n, t, e[t]);
14
- return n;
15
- }, x = (n, e) => Yt(n, Jt(e));
16
- var k = (n, e) => {
17
- var t = {};
18
- for (var s in n)
19
- mt.call(n, s) && e.indexOf(s) < 0 && (t[s] = n[s]);
20
- if (n != null && q)
21
- for (var s of q(n))
22
- e.indexOf(s) < 0 && bt.call(n, s) && (t[s] = n[s]);
23
- return t;
24
- };
25
- var d = (n, e, t) => K(n, typeof e != "symbol" ? e + "" : e, t), Vt = (n, e, t) => e.has(n) || vt("Cannot " + t);
26
- var l = (n, e, t) => (Vt(n, e, "read from private field"), t ? t.call(n) : e.get(n)), Z = (n, e, t) => e.has(n) ? vt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), tt = (n, e, t, s) => (Vt(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t);
27
- var wt = (n, e, t) => new Promise((s, i) => {
28
- var r = (c) => {
29
- try {
30
- o(t.next(c));
31
- } catch (u) {
32
- i(u);
33
- }
34
- }, a = (c) => {
35
- try {
36
- o(t.throw(c));
37
- } catch (u) {
38
- i(u);
39
- }
40
- }, o = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(r, a);
41
- o((t = t.apply(n, e)).next());
42
- });
43
- import { isEqual as nt, isEmpty as L, isBoolean as Kt, isString as P, truncate as Zt, isArray as Tt, isObject as Ot } from "lodash-es";
44
- import { unref as b, computed as jt, isRef as te, reactive as ee, ref as se, defineComponent as ie, resolveComponent as yt, openBlock as ne, createBlock as re, h as R } from "vue";
45
- var F = /* @__PURE__ */ ((n) => (n[n.SUPPRESS = 1] = "SUPPRESS", n[n.HIDDEN = 5] = "HIDDEN", n[n.INVISIBLE = 8] = "INVISIBLE", n[n.FULL = 10] = "FULL", n))(F || {});
46
- const Et = 10, xt = new Set(
47
- Object.values(F).filter((n) => typeof n == "number")
1
+ import { isEqual as Q, isEmpty as R, isBoolean as Lt, isString as C, truncate as Mt, isArray as vt, isObject as bt } from "lodash-es";
2
+ import { unref as h, computed as X, isRef as wt, reactive as Ut, watch as $t, ref as Wt, defineComponent as qt, resolveComponent as at, openBlock as zt, createBlock as Ht, h as F } from "vue";
3
+ var T = /* @__PURE__ */ ((n) => (n[n.SUPPRESS = 1] = "SUPPRESS", n[n.HIDDEN = 5] = "HIDDEN", n[n.INVISIBLE = 8] = "INVISIBLE", n[n.FULL = 10] = "FULL", n))(T || {});
4
+ const ot = 10, lt = new Set(
5
+ Object.values(T).filter((n) => typeof n == "number")
48
6
  );
49
7
  ((n) => {
50
- function e(i) {
51
- return i.toUpperCase() === "SUPPRESS" ? 1 : i.toUpperCase() === "HIDDEN" ? 5 : i.toUpperCase() === "INVISIBLE" ? 8 : Et;
52
- }
53
- n.fromString = e;
54
8
  function t(i) {
55
- const r = typeof i == "number" ? i : n.fromString(i);
56
- return xt.has(r) ? r : Et;
9
+ return i.toUpperCase() === "SUPPRESS" ? 1 : i.toUpperCase() === "HIDDEN" ? 5 : i.toUpperCase() === "INVISIBLE" ? 8 : ot;
10
+ }
11
+ n.fromString = t;
12
+ function e(i) {
13
+ const a = typeof i == "number" ? i : n.fromString(i);
14
+ return lt.has(a) ? a : ot;
57
15
  }
58
- n.fromAny = t;
16
+ n.fromAny = e;
59
17
  function s(i) {
60
- const r = typeof i == "number" ? i : n.fromString(i);
61
- return xt.has(r);
18
+ const a = typeof i == "number" ? i : n.fromString(i);
19
+ return lt.has(a);
62
20
  }
63
21
  n.isDefined = s;
64
- })(F || (F = {}));
65
- Object.freeze(F);
66
- const N = F;
67
- class y {
68
- constructor(e) {
69
- d(this, "executorFn");
70
- /**
71
- * What this action remembers about one of the elements it serves. An action instance is shared - a `List` row
72
- * carries the instances the item template carries - so anything an action holds about the element it last ran
73
- * over belongs to that element rather than to the action: a verdict, a sequence number, a listener it installed.
74
- * The keys are weak, so what an action remembers about a row is released with the row.
75
- */
76
- d(this, "states", /* @__PURE__ */ new WeakMap());
77
- this.executorFn = e;
78
- }
22
+ })(T || (T = {}));
23
+ Object.freeze(T);
24
+ const _ = T;
25
+ class p {
79
26
  static get classIdentifier() {
80
27
  throw new Error("classIdentifier must be declared");
81
28
  }
82
29
  get classIdentifier() {
83
30
  return this.constructor.classIdentifier;
84
31
  }
32
+ executorFn;
33
+ /**
34
+ * What this action remembers about one of the elements it serves. An action instance is shared - a `List` row
35
+ * carries the instances the item template carries - so anything an action holds about the element it last ran
36
+ * over belongs to that element rather than to the action: a verdict, a sequence number, a listener it installed.
37
+ * The keys are weak, so what an action remembers about a row is released with the row.
38
+ */
39
+ states = /* @__PURE__ */ new WeakMap();
40
+ constructor(t) {
41
+ this.executorFn = t;
42
+ }
85
43
  /**
86
44
  * This action's state for `key`, created by `init` the first time it is asked for. The key is the element the
87
45
  * action is running over, or the record that element belongs to where what is remembered is a fact about the
88
46
  * whole record.
89
47
  */
90
- state(e, t) {
91
- return this.states.has(e) || this.states.set(e, t()), this.states.get(e);
48
+ state(t, e) {
49
+ return this.states.has(t) || this.states.set(t, e()), this.states.get(t);
92
50
  }
93
- execute(e, t, ...s) {
94
- return this.executorFn(e, t, ...s);
51
+ execute(t, e, ...s) {
52
+ return this.executorFn(t, e, ...s);
95
53
  }
96
54
  get eager() {
97
55
  return !1;
@@ -102,106 +60,104 @@ class y {
102
60
  * copy as it does.
103
61
  */
104
62
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
105
- boundToBinding(e) {
63
+ boundToBinding(t) {
106
64
  }
107
65
  /**
108
- * Announces that `binding` no longer holds this action. It names one element rather than the action as a whole,
109
- * because the instance goes on serving every other element it was registered on.
66
+ * Announces that `binding` no longer holds this action, and takes back what running it left there. It names one
67
+ * element rather than the action as a whole, because the instance goes on serving every other element it was
68
+ * registered on. It runs inside the operation that drops the registration, so an operation that unwinds puts the
69
+ * registration and what this took back both back.
110
70
  */
111
71
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
112
- unregisterFrom(e) {
72
+ unregisterFrom(t) {
113
73
  }
114
74
  }
115
- class rt extends Error {
75
+ class Vt extends Error {
116
76
  }
117
- const B = /* @__PURE__ */ Symbol("ValueChangedAction");
118
- class O extends y {
119
- constructor(e) {
120
- super(e);
77
+ const yt = /* @__PURE__ */ Symbol("ValueChangedAction");
78
+ class S extends p {
79
+ constructor(t) {
80
+ super(t);
121
81
  }
122
82
  static get classIdentifier() {
123
- return B;
124
- }
125
- execute(e, t, s, i) {
126
- return super.execute(e, t, s, i);
127
- }
128
- }
129
- const z = /* @__PURE__ */ Symbol("Transaction.capture"), Pt = /* @__PURE__ */ Symbol("Transaction.restore"), Ft = /* @__PURE__ */ Symbol("Transaction.announceValue"), Nt = /* @__PURE__ */ Symbol("Transaction.settleValidity");
130
- function Ct(n) {
131
- let e = 0, t = n.parent;
132
- for (; t; )
133
- e++, t = t.parent;
134
- return e;
135
- }
136
- class ae {
137
- constructor() {
138
- d(this, "participants", /* @__PURE__ */ new Map());
139
- /** work that stands only where the transaction commits; a rollback simply never does it */
140
- d(this, "deferred", []);
141
- /** what a rollback has to put back beyond the state slots, newest last */
142
- d(this, "undo", []);
143
- /** true once the transaction has been unwound, which is what tells a run started inside it to say nothing */
144
- d(this, "unwound", !1);
145
- /** the depth the announcement in progress is working at, -1 while none is */
146
- d(this, "passDepth", -1);
147
- /** set while a pass is running and an element it has already passed the depth of gets enrolled */
148
- d(this, "restartPass", !1);
83
+ return yt;
149
84
  }
85
+ execute(t, e, s, i) {
86
+ return super.execute(t, e, s, i);
87
+ }
88
+ }
89
+ const O = /* @__PURE__ */ Symbol("Transaction.capture"), Ct = /* @__PURE__ */ Symbol("Transaction.restore"), Et = /* @__PURE__ */ Symbol("Transaction.announceValue"), xt = /* @__PURE__ */ Symbol("Transaction.settleValidity");
90
+ function ut(n) {
91
+ let t = 0, e = n.parent;
92
+ for (; e; )
93
+ t++, e = e.parent;
94
+ return t;
95
+ }
96
+ class Qt {
97
+ participants = /* @__PURE__ */ new Map();
98
+ /** what a rollback has to put back beyond the state slots, newest last */
99
+ undo = [];
100
+ /** what the commit has to do once the change stands, in the order it was handed in */
101
+ settled = [];
102
+ /** true once the transaction has been unwound, which is what tells a run started inside it to say nothing */
103
+ unwound = !1;
104
+ /** the depth the announcement in progress is working at, -1 while none is */
105
+ passDepth = -1;
106
+ /** set while a pass is running and an element it has already passed the depth of gets enrolled */
107
+ restartPass = !1;
150
108
  /** true for a transaction that was rolled back rather than committed */
151
109
  get rolledBack() {
152
110
  return this.unwound;
153
111
  }
154
- participant(e) {
155
- let t = this.participants.get(e);
156
- return t || (t = { element: e, valueDirty: !1, forceValue: !1, validityDirty: !1 }, this.participants.set(e, t)), t;
112
+ participant(t) {
113
+ let e = this.participants.get(t);
114
+ return e || (e = { element: t, valueDirty: !1, forceValue: !1, validityDirty: !1 }, this.participants.set(t, e)), e;
157
115
  }
158
116
  /**
159
117
  * Records the state of an element the first time the transaction modifies it. The whole of the mutable state
160
118
  * goes into the snapshot rather than the part being written: a rollback that restored some of it would leave
161
119
  * the element in a state the form never held.
162
120
  */
163
- touch(e) {
164
- const t = this.participant(e);
165
- t.snapshot || (t.snapshot = e[z]());
121
+ touch(t) {
122
+ const e = this.participant(t);
123
+ e.snapshot || (e.snapshot = t[O]());
166
124
  }
167
125
  /** Enrols an element as one whose value the commit has to announce. `force` skips the comparison. */
168
- markValueChanged(e, t) {
169
- const s = this.participant(e);
170
- s.valueDirty = !0, t && (s.forceValue = !0), this.noteDepth(e);
126
+ markValueChanged(t, e) {
127
+ const s = this.participant(t);
128
+ s.valueDirty = !0, e && (s.forceValue = !0), this.noteDepth(t);
171
129
  }
172
130
  /** Enrols an element as one whose verdict the commit has to re-form. */
173
- markValidityDirty(e) {
174
- this.participant(e).validityDirty = !0, this.noteDepth(e);
131
+ markValidityDirty(t) {
132
+ this.participant(t).validityDirty = !0, this.noteDepth(t);
175
133
  }
176
134
  /**
177
135
  * Queues an event that states an operation rather than a state. Added and removed items have no net over a
178
136
  * transaction, so they are neither compared nor coalesced: the commit emits them in the order they happened.
179
137
  */
180
- recordStructural(e, t) {
181
- var i;
182
- const s = this.participant(e);
183
- ((i = s.structural) != null ? i : s.structural = []).push(t), this.noteDepth(e);
138
+ recordStructural(t, e) {
139
+ const s = this.participant(t);
140
+ (s.structural ??= []).push(e), this.noteDepth(t);
184
141
  }
185
142
  /** True where the commit still owes this element a value announcement. */
186
- willAnnounceValue(e) {
187
- var t, s;
188
- return (s = (t = this.participants.get(e)) == null ? void 0 : t.valueDirty) != null ? s : !1;
189
- }
190
- /**
191
- * Registers work the commit does once everything has been announced. It is for what a rollback could not take
192
- * back: releasing a listener, dropping a registration. Held until the commit, it is simply never done where the
193
- * transaction unwinds instead.
194
- */
195
- whenCommitted(e) {
196
- this.deferred.push(e);
143
+ willAnnounceValue(t) {
144
+ return this.participants.get(t)?.valueDirty ?? !1;
197
145
  }
198
146
  /**
199
147
  * Registers what a rollback has to put back beyond the element's state slots. The snapshot covers the slots,
200
148
  * which is everything an ordinary write touches; an operation that replaces something else the element carries
201
149
  * hands its own undo in here rather than making every snapshot carry the thing.
202
150
  */
203
- whenRolledBack(e) {
204
- this.undo.push(e);
151
+ whenRolledBack(t) {
152
+ this.undo.push(t);
153
+ }
154
+ /**
155
+ * Registers work that runs once the transaction has committed, and not at all where it is rolled back. It is
156
+ * how an operation defers a step that cannot be taken back - cancelling work in flight, for one - until the
157
+ * change it belongs to actually stands.
158
+ */
159
+ whenCommitted(t) {
160
+ this.settled.push(t);
205
161
  }
206
162
  /**
207
163
  * Notes that an element at or below the depth the pass in progress is working at has been enrolled. The pass
@@ -210,8 +166,8 @@ class ae {
210
166
  * whose composed value carries that write. The depth is only measured while a pass is running - outside one
211
167
  * there is nothing the answer would change.
212
168
  */
213
- noteDepth(e) {
214
- this.passDepth < 0 || Ct(e) >= this.passDepth && (this.restartPass = !0);
169
+ noteDepth(t) {
170
+ this.passDepth < 0 || ut(t) >= this.passDepth && (this.restartPass = !0);
215
171
  }
216
172
  /**
217
173
  * Puts every element the transaction modified back as it found it. Nothing is announced: from an observer's
@@ -219,11 +175,11 @@ class ae {
219
175
  * that called a server during the transaction already did.
220
176
  */
221
177
  rollback() {
222
- this.unwound = !0, [...this.participants.values()].reverse().forEach((t) => {
223
- t.snapshot && t.element[Pt](t.snapshot);
178
+ this.unwound = !0, [...this.participants.values()].reverse().forEach((e) => {
179
+ e.snapshot && e.element[Ct](e.snapshot);
224
180
  }), this.participants.clear();
225
- for (let t = this.undo.length - 1; t >= 0; t--) this.undo[t]();
226
- this.undo.length = 0, this.deferred.length = 0;
181
+ for (let e = this.undo.length - 1; e >= 0; e--) this.undo[e]();
182
+ this.undo.length = 0, this.settled.length = 0;
227
183
  }
228
184
  /**
229
185
  * Announces what the transaction did. Values first and verdicts after, because a container's validators run
@@ -236,7 +192,8 @@ class ae {
236
192
  commit() {
237
193
  for (; !(!this.announceValues() && !this.settleValidity()); )
238
194
  ;
239
- this.deferred.splice(0).forEach((t) => t());
195
+ for (let t = 0; t < this.settled.length; t++) this.settled[t]();
196
+ this.settled.length = 0;
240
197
  }
241
198
  /**
242
199
  * The dirty participants a pass has to visit, one bucket per nesting depth; ties keep the order they were
@@ -244,14 +201,13 @@ class ae {
244
201
  * comparison sort: a whole-list assignment enrols one participant per field, and ordering those by comparison
245
202
  * would cost more than the announcement it orders.
246
203
  */
247
- buckets(e) {
248
- const t = [];
204
+ buckets(t) {
205
+ const e = [];
249
206
  return this.participants.forEach((s) => {
250
- var r;
251
- if (!e(s)) return;
252
- const i = Ct(s.element);
253
- ((r = t[i]) != null ? r : t[i] = []).push(s);
254
- }), t;
207
+ if (!t(s)) return;
208
+ const i = ut(s.element);
209
+ (e[i] ??= []).push(s);
210
+ }), e;
255
211
  }
256
212
  /**
257
213
  * Runs one pass over the dirty participants, deepest bucket first; the caller repeats it until it answers
@@ -259,18 +215,18 @@ class ae {
259
215
  * the depth being drained: that element is not in the bucket being walked, and going on would reach the
260
216
  * containers above it first. The caller's next pass takes fresh buckets and finds it at its own depth.
261
217
  */
262
- pass(e, t) {
263
- const s = this.buckets(e);
218
+ pass(t, e) {
219
+ const s = this.buckets(t);
264
220
  if (!s.length) return !1;
265
221
  for (let i = s.length - 1; i >= 0; i--) {
266
- const r = s[i];
267
- if (r) {
222
+ const a = s[i];
223
+ if (a) {
268
224
  this.passDepth = i, this.restartPass = !1;
269
225
  try {
270
- for (let a = 0; a < r.length; a++) {
226
+ for (let r = 0; r < a.length; r++) {
271
227
  if (this.restartPass) return !0;
272
- const o = r[a];
273
- e(o) && t(o);
228
+ const o = a[r];
229
+ t(o) && e(o);
274
230
  }
275
231
  } finally {
276
232
  this.passDepth = -1;
@@ -282,34 +238,32 @@ class ae {
282
238
  }
283
239
  announceValues() {
284
240
  return this.pass(
285
- (e) => e.valueDirty || e.structural !== void 0,
286
- (e) => {
287
- const { structural: t } = e, s = e.valueDirty, i = e.forceValue;
288
- e.structural = void 0, e.valueDirty = !1, e.forceValue = !1, e.element[Ft](this, s, i, t);
241
+ (t) => t.valueDirty || t.structural !== void 0,
242
+ (t) => {
243
+ const { structural: e } = t, s = t.valueDirty, i = t.forceValue;
244
+ t.structural = void 0, t.valueDirty = !1, t.forceValue = !1, t.element[Et](this, s, i, e);
289
245
  }
290
246
  );
291
247
  }
292
248
  settleValidity() {
293
249
  return this.pass(
294
- (e) => e.validityDirty,
295
- (e) => {
296
- e.validityDirty = !1, e.element[Nt](this);
250
+ (t) => t.validityDirty,
251
+ (t) => {
252
+ t.validityDirty = !1, t.element[xt](this);
297
253
  }
298
254
  );
299
255
  }
300
256
  }
301
- let _, et;
302
- function kt() {
303
- return _;
257
+ let E, q;
258
+ function St() {
259
+ return E;
304
260
  }
305
- class Rt {
261
+ class It {
306
262
  }
307
- class oe {
308
- constructor() {
309
- d(this, "open", !0);
310
- }
263
+ class Xt {
264
+ open = !0;
311
265
  rollback() {
312
- throw this.open ? new Rt() : new TypeError(
266
+ throw this.open ? new It() : new TypeError(
313
267
  "this transaction handle is spent: the transaction that handed it out has closed. A handle is only usable inside the call that received it."
314
268
  );
315
269
  }
@@ -317,60 +271,68 @@ class oe {
317
271
  this.open = !1;
318
272
  }
319
273
  }
320
- function St(n) {
274
+ function ct(n) {
321
275
  if (n != null && typeof n.then == "function")
322
276
  throw new TypeError(
323
277
  "a transaction may not be asynchronous: the callback returned a thenable. Do the awaiting outside and open a transaction for each synchronous part."
324
278
  );
325
279
  }
326
- function ot(n) {
327
- if (_) {
328
- const s = n(et);
329
- return St(s), s;
280
+ function Y(n) {
281
+ if (E) {
282
+ const s = n(q);
283
+ return ct(s), s;
330
284
  }
331
- const e = new ae(), t = new oe();
332
- _ = e, et = t;
285
+ const t = new Qt(), e = new Xt();
286
+ E = t, q = e;
333
287
  try {
334
- const s = n(t);
335
- return St(s), e.commit(), s;
288
+ const s = n(e);
289
+ return ct(s), t.commit(), s;
336
290
  } catch (s) {
337
- if (e.rollback(), s instanceof Rt) return;
291
+ if (t.rollback(), s instanceof It) return;
338
292
  throw s;
339
293
  } finally {
340
- _ = void 0, et = void 0, t.close();
294
+ E = void 0, q = void 0, e.close();
341
295
  }
342
296
  }
343
- function g(n) {
344
- return _ ? n(_) : ot(() => n(_));
297
+ function u(n) {
298
+ return E ? n(E) : Y(() => n(E));
345
299
  }
346
- const Dt = { useMarkdownInValidators: !0 };
347
- function le() {
348
- return Dt;
300
+ const At = { useMarkdownInValidators: !0 };
301
+ function Kt() {
302
+ return At;
349
303
  }
350
- function ce(n) {
351
- Object.assign(Dt, n);
304
+ function Yt(n) {
305
+ Object.assign(At, n);
352
306
  }
353
- const Ye = {
354
- install(n, e) {
355
- e && ce(e);
307
+ const De = {
308
+ install(n, t) {
309
+ t && Yt(t);
356
310
  }
357
311
  };
358
- class U extends String {
359
- constructor(t, s, i) {
360
- super(t);
361
- d(this, "plugins");
362
- d(this, "options");
363
- this.plugins = i, this.options = s;
312
+ class P extends String {
313
+ plugins;
314
+ options;
315
+ constructor(t, e, s) {
316
+ super(t), this.plugins = s, this.options = e;
364
317
  }
365
318
  }
366
- function lt(n) {
367
- const e = b(n);
368
- return typeof e == "object" && "componentName" in e;
319
+ function J(n) {
320
+ const t = h(n);
321
+ return typeof t == "object" && "componentName" in t;
369
322
  }
370
- function H(n) {
371
- return typeof b(n) == "function";
323
+ function B(n) {
324
+ return typeof h(n) == "function";
372
325
  }
373
- class ct {
326
+ class Z {
327
+ /**
328
+ * Machine-readable identifier of what failed, in kebab-case. Every validator this library ships states one, so
329
+ * code that reacts to a particular failure does not have to match the message text, which is translated and
330
+ * configurable. It is optional: an error built by hand carries whatever its author gives it, or nothing.
331
+ */
332
+ constructor(t) {
333
+ this.code = t;
334
+ }
335
+ code;
374
336
  get componentName() {
375
337
  return "Comment";
376
338
  }
@@ -384,13 +346,12 @@ class ct {
384
346
  return "";
385
347
  }
386
348
  }
387
- class ue extends ct {
388
- constructor(t, s = "") {
389
- super();
390
- d(this, "text");
391
- d(this, "classes");
392
- this.text = t, this.classes = s;
349
+ class Jt extends Z {
350
+ constructor(t, e = "", s) {
351
+ super(s), this.text = t, this.classes = e;
393
352
  }
353
+ text;
354
+ classes;
394
355
  get componentName() {
395
356
  return "template";
396
357
  }
@@ -401,24 +362,23 @@ class ue extends ct {
401
362
  return this.classes;
402
363
  }
403
364
  }
404
- class V extends ct {
405
- constructor(t, s = "") {
406
- super();
407
- d(this, "classes");
408
- d(this, "text");
409
- d(this, "textType");
410
- this.classes = s, this.text = t, this.textType = jt(() => this.getTextType);
365
+ class f extends Z {
366
+ constructor(t, e = "", s) {
367
+ super(s), this.classes = e, this.text = t, this.textType = X(() => this.getTextType);
411
368
  }
369
+ classes;
370
+ text;
371
+ textType;
412
372
  get resolvedText() {
413
- const t = b(this.text);
414
- return H(t) ? t() : t;
373
+ const t = h(this.text);
374
+ return B(t) ? t() : t;
415
375
  }
416
376
  get getTextType() {
417
377
  const t = this.resolvedText;
418
- return t ? t instanceof U ? "md" : lt(t) ? "component" : "string" : "string";
378
+ return t ? t instanceof P ? "md" : J(t) ? "component" : "string" : "string";
419
379
  }
420
380
  get componentName() {
421
- switch (b(this.textType)) {
381
+ switch (h(this.textType)) {
422
382
  case "string":
423
383
  return "template";
424
384
  case "md":
@@ -430,7 +390,7 @@ class V extends ct {
430
390
  }
431
391
  }
432
392
  get componentBindings() {
433
- switch (b(this.textType)) {
393
+ switch (h(this.textType)) {
434
394
  case "string":
435
395
  return {};
436
396
  case "md": {
@@ -444,7 +404,7 @@ class V extends ct {
444
404
  }
445
405
  }
446
406
  get componentBody() {
447
- switch (b(this.textType)) {
407
+ switch (h(this.textType)) {
448
408
  case "string":
449
409
  return this.resolvedText;
450
410
  case "component":
@@ -457,43 +417,50 @@ class V extends ct {
457
417
  return this.classes;
458
418
  }
459
419
  }
460
- class he extends V {
420
+ class Zt extends f {
461
421
  }
462
- function E(n) {
463
- return le().useMarkdownInValidators ? new U(n) : n.replace(/[*_~`]/g, "").replace(/!\[(.*?)\]\(.*?\)/g, "$1").replace(/\[(.*?)\]\((.*?)\)/g, "$1").replace(/#+\s?/g, "").replace(/>\s?/g, "").replace(/(\*|-|\d+\.)\s+/g, "").replace(/`{3}[\s\S]*?`{3}/g, "").replace(/`([^`]+)`/g, "$1").replace(/\n{2,}/g, `
422
+ function m(n) {
423
+ return Kt().useMarkdownInValidators ? new P(n) : n.replace(/[*_~`]/g, "").replace(/!\[(.*?)\]\(.*?\)/g, "$1").replace(/\[(.*?)\]\((.*?)\)/g, "$1").replace(/#+\s?/g, "").replace(/>\s?/g, "").replace(/(\*|-|\d+\.)\s+/g, "").replace(/`{3}[\s\S]*?`{3}/g, "").replace(/`([^`]+)`/g, "$1").replace(/\n{2,}/g, `
464
424
  `);
465
425
  }
466
- const de = /* @__PURE__ */ Symbol("Validator"), ge = () => E("Validation could not be completed");
467
- class v extends O {
426
+ const Gt = /* @__PURE__ */ Symbol("Validator"), te = () => m("Validation could not be completed");
427
+ class g extends S {
428
+ source;
468
429
  /**
469
430
  * Creates a new validator
470
431
  * @param validationFn Function that validates the field value and returns errors or null
471
432
  */
472
433
  constructor(t) {
473
- super((i, r, a, o) => {
474
- const c = this.bindingState(i), u = ++c.run, C = i.validationEpoch, G = kt(), dt = () => c.run === u && i.validationEpoch === C && !(G != null && G.rolledBack), Y = t(a, o, i) || [], J = (S) => ot(() => {
475
- var gt;
476
- const $ = (gt = S == null ? void 0 : S.map((j) => this.claim(j))) != null ? gt : [];
477
- for (let j = i.errors.length - 1; j >= 0; j--) {
478
- const ft = i.errors[j];
479
- if (ft.source === this.source) {
480
- const pt = $.findIndex((Xt) => nt(Xt, ft));
481
- pt >= 0 ? $.splice(pt, 1) : i.errors.splice(j, 1);
434
+ const e = (s, i, a, r) => {
435
+ const o = this.bindingState(s), l = o.abandon, w = ++o.run, b = s.validationEpoch, et = St();
436
+ let st = !1;
437
+ const U = () => !st && o.run === w && s.validationEpoch === b && !et?.rolledBack, it = new AbortController(), N = () => {
438
+ U() || (st = !0, o.abandon === N && (o.abandon = void 0), it.abort());
439
+ };
440
+ l?.();
441
+ const $ = t(a, r, s, it.signal) || [], W = (y) => Y(() => {
442
+ const k = y?.map((I) => this.claim(I)) ?? [];
443
+ for (let I = s.errors.length - 1; I >= 0; I--) {
444
+ const nt = s.errors[I];
445
+ if (nt.source === this.source) {
446
+ const rt = k.findIndex((Dt) => Q(Dt, nt));
447
+ rt >= 0 ? k.splice(rt, 1) : s.errors.splice(I, 1);
482
448
  }
483
449
  }
484
- $.length > 0 && i.errors.push(...$), i.validate();
450
+ k.length > 0 && s.errors.push(...k), s.validate();
485
451
  });
486
- return Y instanceof Promise ? (i.beginValidating(), Y.then(
487
- (S) => {
488
- dt() && J(S);
452
+ return $ instanceof Promise ? (o.abandon = N, et?.whenRolledBack(N), s.beginValidating(), $.then(
453
+ (y) => {
454
+ U() && W(y);
489
455
  },
490
- (S) => {
491
- dt() && (J([new V(ge())]), console.error("Validation failed", S));
456
+ (y) => {
457
+ U() && (W([new f(te(), "", "validation-failed")]), console.error("Validation failed", y));
492
458
  }
493
- ).finally(() => i.endValidating()).catch((S) => console.error("Validation failed", S))) : J(Y), r(i, a, o);
494
- });
495
- d(this, "source");
496
- this.source = Symbol(this.constructor.name);
459
+ ).finally(() => {
460
+ o.abandon === N && (o.abandon = void 0), s.endValidating();
461
+ }).catch((y) => console.error("Validation failed", y))) : W($), i(s, a, r);
462
+ };
463
+ super(e), this.source = Symbol(this.constructor.name);
497
464
  }
498
465
  /**
499
466
  * Returns the error instance this validator owns and may later withdraw: the argument itself when it carries no
@@ -503,20 +470,46 @@ class v extends O {
503
470
  * including the non-enumerable ones, so it renders exactly like the instance it was made from.
504
471
  */
505
472
  claim(t) {
506
- const s = t.source;
507
- if (s === this.source) return t;
508
- const i = { value: this.source, enumerable: !1, configurable: !1 };
509
- if (s === void 0)
510
- return Object.defineProperty(t, "source", i), t;
511
- const r = Object.getOwnPropertyDescriptors(t);
512
- return Object.create(Object.getPrototypeOf(t), x(p({}, r), { source: i }));
473
+ const e = t.source;
474
+ if (e === this.source) return t;
475
+ const s = { value: this.source, enumerable: !1, configurable: !1 };
476
+ if (e === void 0)
477
+ return Object.defineProperty(t, "source", s), t;
478
+ const i = Object.getOwnPropertyDescriptors(t);
479
+ return Object.create(Object.getPrototypeOf(t), { ...i, source: s });
513
480
  }
514
481
  static get classIdentifier() {
515
- return de;
482
+ return Gt;
516
483
  }
517
484
  get eager() {
518
485
  return !0;
519
486
  }
487
+ /**
488
+ * Takes this validator off `field`: the errors it put there are withdrawn and the verdict is re-formed over what
489
+ * the validators the field still holds have to say. Withdrawing them is what keeps a field from staying invalid
490
+ * on an error no validator is left to take back.
491
+ *
492
+ * A run in flight over the field is cancelled once the removal stands, and not before: a transaction that
493
+ * unwinds puts the validator and its epoch back, and the run it never cancelled goes on to reach the verdict the
494
+ * field is then owed. Cancelling it as the removal is made would leave the field reporting itself valid over a
495
+ * value nothing checked, on the strength of a transaction that never happened.
496
+ */
497
+ unregisterFrom(t) {
498
+ u((e) => {
499
+ e.whenCommitted(() => this.abandonRun(t));
500
+ for (let s = t.errors.length - 1; s >= 0; s--)
501
+ t.errors[s].source === this.source && t.errors.splice(s, 1);
502
+ t.validate();
503
+ });
504
+ }
505
+ /**
506
+ * Cancels the asynchronous run in flight over `field`, where there is one. It is called once the field has
507
+ * stopped holding this validator: the field's validation epoch has moved on by then, so the run's verdict is
508
+ * already dropped and the signal it handed its check aborts with it.
509
+ */
510
+ abandonRun(t) {
511
+ this.bindingState(t).abandon?.();
512
+ }
520
513
  /**
521
514
  * What this validator remembers about one of the fields it validates. One instance may be registered on several
522
515
  * fields - every row of a list carries the instances the item template carries - so each field has a record of
@@ -533,84 +526,84 @@ class v extends O {
533
526
  newBindingState() {
534
527
  return { run: 0 };
535
528
  }
536
- replacePlaceholdersFunction(t, s) {
529
+ replacePlaceholdersFunction(t, e) {
537
530
  return () => {
538
- let i = b(t);
539
- for (; H(i); )
540
- i = b(this.replacePlaceholders(i(), s));
541
- return i;
531
+ let s = h(t);
532
+ for (; B(s); )
533
+ s = h(this.replacePlaceholders(s(), e));
534
+ return s;
542
535
  };
543
536
  }
544
- replacePlaceholders(t, s) {
545
- if (H(t)) return this.replacePlaceholdersFunction(t, s);
546
- if (lt(t)) return t;
547
- if (te(t))
548
- return this.replacePlaceholdersFunction(() => b(t), s);
549
- let i = b(t);
550
- return Object.keys(s).forEach((r) => {
551
- i = i.replaceAll(`{${r}}`, s[r]);
552
- }), t instanceof U ? new U(i.toString(), t.options, t.plugins) : i;
553
- }
554
- }
555
- class M extends Map {
556
- constructor() {
557
- super(...arguments);
558
- d(this, "eagerActions", /* @__PURE__ */ new Set());
559
- d(this, "registeredActions", []);
560
- }
561
- register(t) {
562
- if (!(t instanceof y)) throw new Error("Invalid action type");
563
- this.registeredActions.push(t);
564
- const s = t.classIdentifier, i = this.get(s) || (() => null);
565
- function r(a, ...o) {
566
- return t.execute(a, i, ...o);
567
- }
568
- this.set(s, r), t.eager && this.eagerActions.add(t.classIdentifier);
569
- }
570
- /**
571
- * True when triggering this action would run something: a handler registered under the identifier, or - on the
572
- * value change identifier, which trigger() answers with an eager pass as well - any eager action at all. A
573
- * caller that has to build the parameters before it can trigger asks this first and skips building them when
574
- * there is nothing to receive them.
575
- */
537
+ replacePlaceholders(t, e) {
538
+ if (B(t)) return this.replacePlaceholdersFunction(t, e);
539
+ if (J(t)) return t;
540
+ if (wt(t))
541
+ return this.replacePlaceholdersFunction(() => h(t), e);
542
+ let s = h(t);
543
+ return Object.keys(e).forEach((i) => {
544
+ s = s.replaceAll(`{${i}}`, e[i]);
545
+ }), t instanceof P ? new P(s.toString(), t.options, t.plugins) : s;
546
+ }
547
+ }
548
+ class D {
549
+ /** every action registered here, in registration order across all identifiers */
550
+ registeredActions = [];
551
+ /** the actions of one identifier, in registration order */
552
+ chains = /* @__PURE__ */ new Map();
553
+ /** the eager actions of one identifier, in registration order; a subsequence of the chain under that identifier */
554
+ eagerChains = /* @__PURE__ */ new Map();
555
+ /**
556
+ * Registers `action`. It becomes the outermost handler of its identifier, or - where `before` is given and is
557
+ * registered here under the same identifier - takes that action's place in the order, so `before` wraps it and
558
+ * reaches it through `supr`. That is what lets an action be added to a chain someone else built and still sit
559
+ * inside a handler already there.
560
+ */
561
+ register(t, e) {
562
+ if (!(t instanceof p)) throw new Error("Invalid action type");
563
+ const s = t.classIdentifier;
564
+ if (e && (e.classIdentifier !== s || !this.registeredActions.includes(e)))
565
+ throw new Error("Action to register before is not registered under the same identifier");
566
+ this.registeredActions.push(t), this.insert(this.chains, s, t, e), t.eager && this.insert(this.eagerChains, s, t, e);
567
+ }
568
+ /**
569
+ * Drops `action` from this map and answers whether it was in it. The lists it stood in are replaced rather than
570
+ * written, so a run already walking one finishes on the list it started with and the removal takes effect from
571
+ * the next trigger.
572
+ */
573
+ unregister(t) {
574
+ const e = this.registeredActions.indexOf(t);
575
+ if (e < 0) return !1;
576
+ this.registeredActions.splice(e, 1);
577
+ const s = t.classIdentifier;
578
+ return this.remove(this.chains, s, t), this.remove(this.eagerChains, s, t), !0;
579
+ }
580
+ /** True where something is registered under `identifier`. */
576
581
  willTrigger(t) {
577
- return this.has(t) ? !0 : t === B && this.eagerActions.size > 0;
582
+ return this.chains.has(t);
578
583
  }
579
- trigger(t, s, ...i) {
580
- const r = t.classIdentifier;
581
- return r === B && this.triggerEager(s, ...i), this.triggerChain(r, s, ...i);
584
+ /** True where any eager action is registered, whatever identifier it stands under. */
585
+ get hasEager() {
586
+ return this.eagerChains.size > 0;
582
587
  }
583
- /**
584
- * Runs the chain registered under one identifier and nothing else. A caller that has already run the eager
585
- * pass - a transaction runs it at the write, so that the validators have decided before it commits - reaches
586
- * the handlers through here, so the eager actions are not run a second time at the announcement.
587
- */
588
- triggerChain(t, s, ...i) {
589
- const r = this.get(t);
590
- try {
591
- if (r) return r(s, ...i);
592
- } catch (a) {
593
- if (!(a instanceof rt)) throw a;
594
- }
595
- return null;
588
+ /** Runs the actions registered under `ActionClass` and answers with what the outermost of them returned. */
589
+ trigger(t, e, ...s) {
590
+ return this.run(this.chains.get(t.classIdentifier), e, s);
596
591
  }
597
- triggerEager(t, ...s) {
598
- for (const i of this.eagerActions) {
599
- const r = this.get(i);
600
- try {
601
- r && r(t, ...s);
602
- } catch (a) {
603
- if (!(a instanceof rt)) throw a;
604
- }
605
- }
592
+ /** Runs the eager actions of every identifier, each group on its own. */
593
+ triggerEager(t, ...e) {
594
+ this.eagerChains.forEach((s) => this.run(s, t, e));
595
+ }
596
+ /** Runs the eager actions registered under `identifier` and nothing else. */
597
+ triggerEagerFor(t, e, ...s) {
598
+ return this.run(this.eagerChains.get(t), e, s);
606
599
  }
607
600
  /** the validators registered in this map, in registration order */
608
601
  get validators() {
609
- return this.registeredActions.filter((t) => t instanceof v);
602
+ return this.registeredActions.filter((t) => t instanceof g);
610
603
  }
611
604
  clone() {
612
- const t = new M();
613
- return this.registeredActions.forEach((s) => t.register(s)), t;
605
+ const t = new D();
606
+ return this.registeredActions.forEach((e) => t.register(e)), t;
614
607
  }
615
608
  /**
616
609
  * Tells every action in this map that it serves `owner`. A copied map holds the instances the original holds, so
@@ -618,79 +611,95 @@ class M extends Map {
618
611
  * element it was registered on.
619
612
  */
620
613
  bindTo(t) {
621
- this.registeredActions.forEach((s) => s.boundToBinding(t));
614
+ this.registeredActions.forEach((e) => e.boundToBinding(t));
622
615
  }
623
616
  /**
624
- * A copy of this map carrying everything but the validators. It only leaves them out: releasing what a
625
- * validator installed elsewhere is the caller's to do, and only once the transaction that dropped them has
626
- * committed, because a rollback puts this map back with its validators in it.
617
+ * Walks `chain` from the end backwards, handing each action a `supr` that continues at the one before it. The
618
+ * closures exist for the length of the run and only as deep as the run actually goes, so a chain nobody walks to
619
+ * the bottom costs nothing for the part left unreached.
627
620
  */
628
- cloneWithoutValidators() {
629
- const t = new M();
630
- return this.registeredActions.forEach((s) => {
631
- s instanceof v || t.register(s);
632
- }), t;
621
+ step(t, e, s, i) {
622
+ if (e < 0) return null;
623
+ const a = (r, ...o) => this.step(t, e - 1, r, o);
624
+ return t[e].execute(s, a, ...i);
625
+ }
626
+ /** Walks a chain, answering null where there is none. An abort ends the run and is not an error to the caller. */
627
+ run(t, e, s) {
628
+ if (!t) return null;
629
+ try {
630
+ return this.step(t, t.length - 1, e, s);
631
+ } catch (i) {
632
+ if (!(i instanceof Vt)) throw i;
633
+ }
634
+ return null;
633
635
  }
636
+ insert(t, e, s, i) {
637
+ const a = t.get(e) ?? [], r = i ? a.indexOf(i) : -1;
638
+ r < 0 ? a.push(s) : a.splice(r, 0, s), t.set(e, a);
639
+ }
640
+ remove(t, e, s) {
641
+ const i = t.get(e);
642
+ if (!i?.includes(s)) return;
643
+ const a = i.filter((r) => r !== s);
644
+ a.length ? t.set(e, a) : t.delete(e);
645
+ }
646
+ }
647
+ function x(n) {
648
+ let t = n;
649
+ for (; t.fieldName !== void 0 && t.parent; ) t = t.parent;
650
+ return t;
634
651
  }
635
- function T(n) {
652
+ function ee(n) {
653
+ const t = [];
636
654
  let e = n;
637
- for (; e.fieldName !== void 0 && e.parent; ) e = e.parent;
638
- return e;
655
+ for (; e.fieldName !== void 0 && e.parent; )
656
+ t.unshift(e.fieldName), e = e.parent;
657
+ return t;
639
658
  }
640
- function fe(n) {
641
- const e = [];
642
- let t = n;
643
- for (; t.fieldName !== void 0 && t.parent; )
644
- e.unshift(t.fieldName), t = t.parent;
645
- return e;
646
- }
647
- function ut(n, e) {
648
- var s, i;
649
- let t = e;
650
- for (const r of fe(n))
651
- if (t = (i = (s = t.field) == null ? void 0 : s.call(t, r)) != null ? i : void 0, !t) break;
652
- return (t == null ? void 0 : t.declaration) === n ? t : T(n) === T(e.declaration) ? void 0 : n;
653
- }
654
- function Lt(n, e) {
655
- const t = ut(n, e);
656
- if (!t) return [];
657
- if (t !== n) return [t];
658
- const s = e.bindingsOf(n);
659
+ function G(n, t) {
660
+ let e = t;
661
+ for (const s of ee(n))
662
+ if (e = e.field?.(s) ?? void 0, !e) break;
663
+ return e?.declaration === n ? e : x(n) === x(t.declaration) ? void 0 : n;
664
+ }
665
+ function Tt(n, t) {
666
+ const e = G(n, t);
667
+ if (!e) return [];
668
+ if (e !== n) return [e];
669
+ const s = t.bindingsOf(n);
659
670
  return s.length > 0 ? s : [n];
660
671
  }
661
- function pe(n, e) {
662
- var s;
663
- let t = e.parent;
664
- for (; t; ) {
665
- const i = (s = t.field) == null ? void 0 : s.call(t, n);
666
- if (i) return i;
667
- t = t.parent;
668
- }
669
- }
670
- const me = /* @__PURE__ */ Symbol("ConditionalStatementAction");
671
- class Q extends O {
672
- constructor(t, s) {
673
- super((r, a, o, c) => (this.applyIn(T(r)) || r.markRecordIncomplete(), a(r, o, c)));
674
- d(this, "statement");
675
- d(this, "conditionalExecutor");
676
- /**
677
- * What the elements this action was registered on were declared as. It holds declarations rather than the
678
- * elements themselves, so one entry stands for every row of a list, and the element a result is applied to is
679
- * the one that declaration names within the record the change happened in.
680
- */
681
- d(this, "declarations", /* @__PURE__ */ new Set());
682
- /**
683
- * The elements this action was registered on. Registration reaches one element at a time - the rows of a list
684
- * take the action on one by one, as they are built from the item template that carries it - so this is what
685
- * says which of the elements a declaration stands for the action actually drives.
686
- */
687
- d(this, "registrations", /* @__PURE__ */ new WeakSet());
688
- this.statement = t, this.conditionalExecutor = s;
689
- const i = new O((r, a, ...o) => (this.applyFrom(r), a(r, ...o)));
690
- t.collectFields().forEach((r) => r.registerAction(i));
672
+ function se(n, t) {
673
+ let e = t.parent;
674
+ for (; e; ) {
675
+ const s = e.field?.(n);
676
+ if (s) return s;
677
+ e = e.parent;
678
+ }
679
+ }
680
+ const ie = /* @__PURE__ */ Symbol("ConditionalStatementAction");
681
+ class L extends S {
682
+ statement;
683
+ conditionalExecutor;
684
+ /**
685
+ * What the elements this action was registered on were declared as. It holds declarations rather than the
686
+ * elements themselves, so one entry stands for every row of a list, and the element a result is applied to is
687
+ * the one that declaration names within the record the change happened in.
688
+ */
689
+ declarations = /* @__PURE__ */ new Set();
690
+ /**
691
+ * The elements this action was registered on. Registration reaches one element at a time - the rows of a list
692
+ * take the action on one by one, as they are built from the item template that carries it - so this is what
693
+ * says which of the elements a declaration stands for the action actually drives.
694
+ */
695
+ registrations = /* @__PURE__ */ new WeakSet();
696
+ constructor(t, e) {
697
+ super((i, a, r, o) => (this.applyIn(x(i)) || i.markRecordIncomplete(), a(i, r, o))), this.statement = t, this.conditionalExecutor = e;
698
+ const s = new S((i, a, ...r) => (this.applyFrom(i), a(i, ...r)));
699
+ t.collectFields().forEach((i) => i.registerAction(s));
691
700
  }
692
701
  static get classIdentifier() {
693
- return me;
702
+ return ie;
694
703
  }
695
704
  get eager() {
696
705
  return !0;
@@ -698,17 +707,20 @@ class Q extends O {
698
707
  boundToBinding(t) {
699
708
  this.declarations.add(t.declaration), this.registrations.add(t);
700
709
  }
710
+ unregisterFrom(t) {
711
+ this.registrations.delete(t);
712
+ }
701
713
  /**
702
714
  * The elements of `scope` this action controls: what each declaration it serves names within that record, and of
703
715
  * those the ones that took the action on. A row of a list that never took it on is not one this action drives.
704
716
  */
705
717
  targetsIn(t) {
706
- const s = [];
718
+ const e = [];
707
719
  return this.declarations.forEach(
708
- (i) => Lt(i, t).forEach((r) => {
709
- this.registrations.has(r) && s.push(r);
720
+ (s) => Tt(s, t).forEach((i) => {
721
+ this.registrations.has(i) && e.push(i);
710
722
  })
711
- ), s;
723
+ ), e;
712
724
  }
713
725
  /**
714
726
  * Re-evaluates the statement over one record and applies the result where it changed. The result is recorded
@@ -717,12 +729,12 @@ class Q extends O {
717
729
  * this action to drive, which is how a caller learns that the record is not assembled yet.
718
730
  */
719
731
  applyIn(t) {
720
- const s = this.targetsIn(t);
721
- if (s.length === 0) return !1;
722
- const i = this.state(t, () => ({ lastResult: void 0 })), r = this.statement.evaluate(t);
723
- if (r === i.lastResult) return !0;
724
- const a = i.lastResult;
725
- return i.lastResult = r, s.forEach((o) => this.conditionalExecutor(o, r, a)), !0;
732
+ const e = this.targetsIn(t);
733
+ if (e.length === 0) return !1;
734
+ const s = this.state(t, () => ({ lastResult: void 0 })), i = this.statement.evaluate(t);
735
+ if (i === s.lastResult) return !0;
736
+ const a = s.lastResult;
737
+ return s.lastResult = i, e.forEach((r) => this.conditionalExecutor(r, i, a)), !0;
726
738
  }
727
739
  /**
728
740
  * Re-evaluates the records a change of `source` speaks for. A field of the record the targets live in speaks for
@@ -731,148 +743,134 @@ class Q extends O {
731
743
  * where the change reaches none.
732
744
  */
733
745
  applyFrom(t) {
734
- const s = /* @__PURE__ */ new Set();
735
- this.targetsIn(T(t)).forEach((i) => s.add(T(i))), s.forEach((i) => this.applyIn(i));
746
+ const e = /* @__PURE__ */ new Set();
747
+ this.targetsIn(x(t)).forEach((s) => e.add(x(s))), e.forEach((s) => this.applyIn(s));
736
748
  }
737
749
  }
738
- class be extends Q {
739
- constructor(e) {
740
- super(e, (t, s) => {
741
- t.visibility = s ? N.FULL : N.SUPPRESS;
750
+ class ne extends L {
751
+ constructor(t) {
752
+ super(t, (e, s) => {
753
+ e.visibility = s ? _.FULL : _.SUPPRESS;
742
754
  });
743
755
  }
744
756
  }
745
- class ve extends Q {
746
- constructor(e) {
747
- super(e, (t, s) => {
748
- t.enabled = s;
757
+ class re extends L {
758
+ constructor(t) {
759
+ super(t, (e, s) => {
760
+ e.enabled = s;
749
761
  });
750
762
  }
751
763
  }
752
- class Ve extends Q {
753
- constructor(e, t) {
754
- super(e, (s, i) => {
755
- i && (s.value = t);
764
+ class ae extends L {
765
+ constructor(t, e) {
766
+ super(t, (s, i) => {
767
+ i && (s.value = e);
756
768
  });
757
769
  }
758
770
  }
759
- var W = /* @__PURE__ */ ((n) => (n[n.NOT = 0] = "NOT", n[n.OR = 1] = "OR", n[n.AND = 2] = "AND", n[n.XOR = 3] = "XOR", n[n.NAND = 4] = "NAND", n[n.NOR = 5] = "NOR", n[n.EQUALS = -1] = "EQUALS", n[n.NOT_EQUALS = -2] = "NOT_EQUALS", n[n.GT = -3] = "GT", n[n.LT = -4] = "LT", n[n.GE = -5] = "GE", n[n.LE = -6] = "LE", n[n.IN = -7] = "IN", n[n.NOT_IN = -8] = "NOT_IN", n[n.INCLUDES = -9] = "INCLUDES", n[n.NOT_INCLUDES = -10] = "NOT_INCLUDES", n))(W || {});
771
+ var j = /* @__PURE__ */ ((n) => (n[n.NOT = 0] = "NOT", n[n.OR = 1] = "OR", n[n.AND = 2] = "AND", n[n.XOR = 3] = "XOR", n[n.NAND = 4] = "NAND", n[n.NOR = 5] = "NOR", n[n.EQUALS = -1] = "EQUALS", n[n.NOT_EQUALS = -2] = "NOT_EQUALS", n[n.GT = -3] = "GT", n[n.LT = -4] = "LT", n[n.GE = -5] = "GE", n[n.LE = -6] = "LE", n[n.IN = -7] = "IN", n[n.NOT_IN = -8] = "NOT_IN", n[n.INCLUDES = -9] = "INCLUDES", n[n.NOT_INCLUDES = -10] = "NOT_INCLUDES", n))(j || {});
760
772
  ((n) => {
761
- function e(r) {
762
- const a = r.toLowerCase();
763
- if (a === "not") return 0;
764
- if (a === "or") return 1;
765
- if (a === "and") return 2;
766
- if (a === "xor") return 3;
767
- if (a === "nand") return 4;
768
- if (a === "nor") return 5;
769
- if (a === "equals") return -1;
770
- if (["not_equals", "not-equals", "not equals"].includes(a)) return -2;
771
- if (a === "gt") return -3;
772
- if (a === "lt") return -4;
773
- if (a === "ge") return -5;
774
- if (a === "le") return -6;
775
- if (a === "in") return -7;
776
- if (["not_in", "not-in", "not in"].includes(a)) return -8;
777
- if (a === "includes") return -9;
778
- if (["not_includes", "not-includes", "not includes"].includes(a)) return -10;
779
- throw new Error(`Unrecognised operator ${a}`);
780
- }
781
- n.fromString = e;
782
- function t(r) {
783
- const a = typeof r == "number" ? r : n.fromString(r);
784
- if (Object.values(n).includes(a)) return a;
773
+ function t(a) {
774
+ const r = a.toLowerCase();
775
+ if (r === "not") return 0;
776
+ if (r === "or") return 1;
777
+ if (r === "and") return 2;
778
+ if (r === "xor") return 3;
779
+ if (r === "nand") return 4;
780
+ if (r === "nor") return 5;
781
+ if (r === "equals") return -1;
782
+ if (["not_equals", "not-equals", "not equals"].includes(r)) return -2;
783
+ if (r === "gt") return -3;
784
+ if (r === "lt") return -4;
785
+ if (r === "ge") return -5;
786
+ if (r === "le") return -6;
787
+ if (r === "in") return -7;
788
+ if (["not_in", "not-in", "not in"].includes(r)) return -8;
789
+ if (r === "includes") return -9;
790
+ if (["not_includes", "not-includes", "not includes"].includes(r)) return -10;
785
791
  throw new Error(`Unrecognised operator ${r}`);
786
792
  }
787
- n.fromAny = t;
788
- function s(r) {
789
- const a = typeof r == "number" ? r : n.fromString(r);
790
- return Object.values(n).includes(a);
793
+ n.fromString = t;
794
+ function e(a) {
795
+ const r = typeof a == "number" ? a : n.fromString(a);
796
+ if (Object.values(n).includes(r)) return r;
797
+ throw new Error(`Unrecognised operator ${a}`);
798
+ }
799
+ n.fromAny = e;
800
+ function s(a) {
801
+ const r = typeof a == "number" ? a : n.fromString(a);
802
+ return Object.values(n).includes(r);
791
803
  }
792
804
  n.isDefined = s;
793
- function i(r) {
794
- return r >= 0;
805
+ function i(a) {
806
+ return a >= 0;
795
807
  }
796
808
  n.isLogicOperator = i;
797
- })(W || (W = {}));
798
- Object.freeze(W);
799
- const m = W, we = /* @__PURE__ */ Symbol("EnabledChangingAction");
800
- class Bt extends y {
801
- constructor(e) {
802
- super(e);
809
+ })(j || (j = {}));
810
+ Object.freeze(j);
811
+ const c = j, oe = /* @__PURE__ */ Symbol("EnabledChangingAction");
812
+ class _t extends p {
813
+ constructor(t) {
814
+ super(t);
803
815
  }
804
816
  static get classIdentifier() {
805
- return we;
817
+ return oe;
806
818
  }
807
- execute(e, t, s, i) {
808
- return super.execute(e, t, s, i);
819
+ execute(t, e, s, i) {
820
+ return super.execute(t, e, s, i);
809
821
  }
810
822
  }
811
- const ye = /* @__PURE__ */ Symbol("EnabledChangedAction");
812
- class Ut extends y {
813
- constructor(e) {
814
- super(e);
823
+ const le = /* @__PURE__ */ Symbol("EnabledChangedAction");
824
+ class Ot extends p {
825
+ constructor(t) {
826
+ super(t);
815
827
  }
816
828
  static get classIdentifier() {
817
- return ye;
829
+ return le;
818
830
  }
819
- execute(e, t, s, i) {
820
- return super.execute(e, t, s, i);
831
+ execute(t, e, s, i) {
832
+ return super.execute(t, e, s, i);
821
833
  }
822
834
  }
823
- const Ee = /* @__PURE__ */ Symbol("ValidChangedAction");
824
- class Mt extends y {
825
- constructor(e) {
826
- super(e);
835
+ const ue = /* @__PURE__ */ Symbol("ValidChangedAction");
836
+ class Ft extends p {
837
+ constructor(t) {
838
+ super(t);
827
839
  }
828
840
  static get classIdentifier() {
829
- return Ee;
841
+ return ue;
830
842
  }
831
- execute(e, t, s, i) {
832
- return super.execute(e, t, s, i);
843
+ execute(t, e, s, i) {
844
+ return super.execute(t, e, s, i);
833
845
  }
834
846
  }
835
- const xe = /* @__PURE__ */ Symbol("VisibilityChangingAction");
836
- class Wt extends y {
837
- constructor(e) {
838
- super(e);
847
+ const ce = /* @__PURE__ */ Symbol("VisibilityChangingAction");
848
+ class Rt extends p {
849
+ constructor(t) {
850
+ super(t);
839
851
  }
840
852
  static get classIdentifier() {
841
- return xe;
853
+ return ce;
842
854
  }
843
- execute(e, t, s, i) {
844
- return super.execute(e, t, s, i);
855
+ execute(t, e, s, i) {
856
+ return super.execute(t, e, s, i);
845
857
  }
846
858
  }
847
- const Ce = /* @__PURE__ */ Symbol("VisibilityChangedAction");
848
- class $t extends y {
849
- constructor(e) {
850
- super(e);
859
+ const he = /* @__PURE__ */ Symbol("VisibilityChangedAction");
860
+ class Pt extends p {
861
+ constructor(t) {
862
+ super(t);
851
863
  }
852
864
  static get classIdentifier() {
853
- return Ce;
854
- }
855
- execute(e, t, s, i) {
856
- return super.execute(e, t, s, i);
857
- }
858
- }
859
- const It = /* @__PURE__ */ new WeakMap(), At = /* @__PURE__ */ new Set(["validators", "actions"]);
860
- let st = 0;
861
- var h, f;
862
- class A {
863
- constructor(e) {
864
- /**
865
- * The element's mutable state, in an object beside the element. `#state` is the tracked view of it: a slot read
866
- * through it inside an effect subscribes the effect to that slot, and a write to the slot re-runs the effect.
867
- * `#raw` is the same object without the proxy, for the bookkeeping nothing renders from.
868
- *
869
- * They are private class fields, so no reflection over the element reaches the state or the parent link it
870
- * carries, and a subclass reads its own slot type through the accessors below.
871
- */
872
- Z(this, h);
873
- Z(this, f);
874
- tt(this, f, e), tt(this, h, ee(e));
865
+ return he;
875
866
  }
867
+ execute(t, e, s, i) {
868
+ return super.execute(t, e, s, i);
869
+ }
870
+ }
871
+ const ht = /* @__PURE__ */ new WeakMap(), dt = /* @__PURE__ */ new WeakMap(), gt = /* @__PURE__ */ new Set(["validators", "actions"]);
872
+ let z = 0;
873
+ class V {
876
874
  /**
877
875
  * Vue's getTargetType answers INVALID for an object that carries __v_skip, so reactive() hands an element back
878
876
  * unwrapped and no element is ever behind a proxy of its own. isReactive() reads the second flag, and it stays
@@ -890,13 +888,26 @@ class A {
890
888
  get __v_isReactive() {
891
889
  return !0;
892
890
  }
891
+ /**
892
+ * The element's mutable state, in an object beside the element. `#state` is the tracked view of it: a slot read
893
+ * through it inside an effect subscribes the effect to that slot, and a write to the slot re-runs the effect.
894
+ * `#raw` is the same object without the proxy, for the bookkeeping nothing renders from.
895
+ *
896
+ * They are private class fields, so no reflection over the element reaches the state or the parent link it
897
+ * carries, and a subclass reads its own slot type through the accessors below.
898
+ */
899
+ #t;
900
+ #e;
901
+ constructor(t) {
902
+ this.#e = t, this.#t = Ut(t);
903
+ }
893
904
  /** the tracked view of this element's state; a subclass narrows the return type to its own slots */
894
905
  get state() {
895
- return l(this, h);
906
+ return this.#t;
896
907
  }
897
908
  /** the untracked view of this element's state; a subclass narrows the return type to its own slots */
898
909
  get raw() {
899
- return l(this, f);
910
+ return this.#e;
900
911
  }
901
912
  /**
902
913
  * Exchanges the data this element holds for `data`, in place. The element is the same instance afterwards - its
@@ -914,19 +925,19 @@ class A {
914
925
  * The data is measured against the element's `declaration`, so a key a record leaves out is taken from the
915
926
  * declaration rather than left as the previous record had it.
916
927
  */
917
- rebind(e) {
918
- return g((t) => {
919
- t.touch(this);
920
- const s = t.willAnnounceValue(this), i = l(this, f).announcedValue;
921
- this.resetTo(this.declaration, e), l(this, f).announcedValue = s ? i : this.value;
928
+ rebind(t) {
929
+ return u((e) => {
930
+ e.touch(this);
931
+ const s = e.willAnnounceValue(this), i = this.#e.announcedValue;
932
+ this.resetTo(this.declaration, t), this.#e.announcedValue = s ? i : this.value;
922
933
  }), this;
923
934
  }
924
935
  /** contains original field value as was provided at creation */
925
936
  get originalValue() {
926
- return l(this, h).originalValue;
937
+ return this.#t.originalValue;
927
938
  }
928
- set originalValue(e) {
929
- this.touchState(), l(this, h).originalValue = e;
939
+ set originalValue(t) {
940
+ this.touchState(), this.#t.originalValue = t;
930
941
  }
931
942
  /**
932
943
  * The extended properties this element carries: what a consumer attached to it beyond the members the class
@@ -941,14 +952,14 @@ class A {
941
952
  * and one written in place would leave a rollback with nothing to put back.
942
953
  */
943
954
  get extra() {
944
- return l(this, h).extra;
955
+ return this.#t.extra;
945
956
  }
946
957
  /**
947
958
  * Writes extended properties. The values given are merged over the ones the element carries, so a write of one
948
959
  * property leaves the others standing, and the merged set replaces the object the element held.
949
960
  */
950
- setExtendedValues(e) {
951
- this.touchState(), l(this, h).extra = Object.freeze(p(p({}, l(this, f).extra), e));
961
+ setExtendedValues(t) {
962
+ this.touchState(), this.#t.extra = Object.freeze({ ...this.#e.extra, ...t });
952
963
  }
953
964
  /**
954
965
  * The extended properties a parameter object carries: every key the element does not answer for itself. A key
@@ -960,22 +971,22 @@ class A {
960
971
  * defined on the instance after the base constructor returns, and the parameters are applied inside it. A
961
972
  * subclass that wants a parameter of its own name assigned to it declares that member as an accessor.
962
973
  */
963
- extendedOf(e) {
964
- const t = /* @__PURE__ */ Object.create(null);
965
- return Object.entries(e).forEach(([s, i]) => {
966
- At.has(s) || (!(s in this) || Object.hasOwn(Object.prototype, s)) && (t[s] = i);
967
- }), t;
974
+ extendedOf(t) {
975
+ const e = /* @__PURE__ */ Object.create(null);
976
+ return Object.entries(t).forEach(([s, i]) => {
977
+ gt.has(s) || (!(s in this) || Object.hasOwn(Object.prototype, s)) && (e[s] = i);
978
+ }), e;
968
979
  }
969
980
  /**
970
981
  * Applies a parameter object: the members the element answers for are assigned to the element and the rest
971
982
  * become its extended properties. Assigning a getter-only member throws a TypeError, which is what a caller
972
983
  * naming `valid` or `parent` past the type system gets.
973
984
  */
974
- assignParams(e) {
975
- const t = this.extendedOf(e);
976
- Object.entries(e).forEach(([s, i]) => {
977
- Object.hasOwn(t, s) || At.has(s) || (this[s] = i);
978
- }), L(t) || this.setExtendedValues(t);
985
+ assignParams(t) {
986
+ const e = this.extendedOf(t);
987
+ Object.entries(t).forEach(([s, i]) => {
988
+ Object.hasOwn(e, s) || gt.has(s) || (this[s] = i);
989
+ }), R(e) || this.setExtendedValues(e);
979
990
  }
980
991
  /**
981
992
  * Takes this element into the record of the open transaction, where one is open. A write of a single slot that
@@ -983,8 +994,7 @@ class A {
983
994
  * atomic, and inside a transaction it has to be part of what a rollback puts back.
984
995
  */
985
996
  touchState() {
986
- var e;
987
- (e = kt()) == null || e.touch(this);
997
+ St()?.touch(this);
988
998
  }
989
999
  /**
990
1000
  * Records the whole of this element's mutable state, so that a rolled-back transaction can put it back exactly
@@ -994,31 +1004,92 @@ class A {
994
1004
  * What is not in the snapshot is the action map, which no write touches: an operation that replaces it hands
995
1005
  * the transaction its own undo instead, so this stays the one shape every element captures.
996
1006
  */
997
- [z]() {
998
- return x(p({}, l(this, f)), { errors: [...l(this, f).errors] });
1007
+ [O]() {
1008
+ return { ...this.#e, errors: [...this.#e.errors] };
999
1009
  }
1000
1010
  /**
1001
1011
  * Puts a captured state back. It writes through the tracked view, so an effect that ran on the state the
1002
1012
  * transaction produced runs again on the state it is being returned to, and only for the slots that differ.
1003
1013
  *
1004
- * validatingCount is the one slot the element keeps: it counts runs that are in flight, and a rollback cannot
1005
- * un-start one. Put back, the count would no longer match the endValidating calls still to come.
1014
+ * The two validation counters are the slots the element keeps: they count runs that are in flight, and a
1015
+ * rollback cannot un-start one. Put back, the counts would no longer match the endValidating calls still to come.
1006
1016
  */
1007
- [Pt](e) {
1008
- const t = l(this, f).validatingCount;
1009
- Object.assign(l(this, h), e), l(this, h).validatingCount = t;
1017
+ [Ct](t) {
1018
+ const e = this.#e.validatingCount, s = this.#e.validatingChildren;
1019
+ Object.assign(this.#t, t), this.#t.validatingCount = e, this.#t.validatingChildren = s;
1010
1020
  }
1011
- /** true while at least one asynchronous validator is still running for this field */
1021
+ /**
1022
+ * True while an asynchronous validation is in flight on this element or on anything below it, so a form answers
1023
+ * for the whole tree it holds. The answer is a pair of counters rather than a walk: the element's own runs, and
1024
+ * how many of its children answer the same question with true. A child that starts running while it was idle,
1025
+ * or stops while it was the last one running, moves its container's tally, and a tally that changes the
1026
+ * container's own answer moves the one above it - the transition costs the nesting depth and the read costs
1027
+ * nothing.
1028
+ */
1012
1029
  get validating() {
1013
- return l(this, h).validatingCount > 0;
1030
+ return this.#t.validatingCount > 0 || this.#t.validatingChildren > 0;
1014
1031
  }
1015
1032
  /** announces the start of one asynchronous validation run; validators pair it with endValidating */
1016
1033
  beginValidating() {
1017
- l(this, h).validatingCount++;
1034
+ const t = !this.validating;
1035
+ this.#t.validatingCount++, t && this.parent?.childValidatingChanged(!0);
1018
1036
  }
1019
1037
  /** announces the end of one asynchronous validation run */
1020
1038
  endValidating() {
1021
- l(this, h).validatingCount = Math.max(0, l(this, h).validatingCount - 1);
1039
+ this.#e.validatingCount !== 0 && (this.#t.validatingCount--, this.validating || this.parent?.childValidatingChanged(!1));
1040
+ }
1041
+ /**
1042
+ * Records that a child started or stopped answering `validating` with true, and carries the transition further
1043
+ * up where it changes this element's own answer.
1044
+ */
1045
+ childValidatingChanged(t) {
1046
+ const e = this.validating;
1047
+ this.#t.validatingChildren += t ? 1 : -1, this.validating !== e && this.parent?.childValidatingChanged(t);
1048
+ }
1049
+ /**
1050
+ * True while an `Action.execute()` at or below this element has yet to settle. An `Action` answers for its own
1051
+ * runs; a container answers for the actions below it; anything else answers false, because an element that is
1052
+ * not an action has nothing to execute.
1053
+ *
1054
+ * It states one thing and `validating` states the other, so a form that gates a submit button on the tree being
1055
+ * idle reads both.
1056
+ */
1057
+ get busy() {
1058
+ return !1;
1059
+ }
1060
+ /**
1061
+ * The composed answer a container gives `busy`, memoised by Vue. An `Action` counts its executions in a counter
1062
+ * of its own, which no container is told about, so the answer is composed over the members instead of tallied;
1063
+ * the computed keeps the walk from repeating while nothing it read has moved, and a member that is itself a
1064
+ * container answers from its own computed.
1065
+ */
1066
+ get busyRead() {
1067
+ let t = dt.get(this);
1068
+ return t || (t = X(() => this.composeBusy()), dt.set(this, t)), t.value;
1069
+ }
1070
+ /** What busyRead computes. A container answers over its members; anything else executes nothing. */
1071
+ composeBusy() {
1072
+ return !1;
1073
+ }
1074
+ /**
1075
+ * Resolves once nothing at or below this element is running - no asynchronous validation, no `Action.execute()`
1076
+ * that has yet to settle. It is what a submit path awaits instead of polling `validating` and `busy`, and it
1077
+ * resolves at once where nothing is running to begin with.
1078
+ *
1079
+ * It answers for the moment it resolves and makes no promise about the one after: work started later leaves the
1080
+ * element running again, so a caller that has to act on a settled tree reads what it needs immediately after
1081
+ * awaiting rather than at its leisure.
1082
+ */
1083
+ settled() {
1084
+ return !this.validating && !this.busy ? Promise.resolve() : new Promise((t) => {
1085
+ const e = $t(
1086
+ () => this.validating || this.busy,
1087
+ (s) => {
1088
+ s || (e(), t());
1089
+ },
1090
+ { flush: "sync" }
1091
+ );
1092
+ });
1022
1093
  }
1023
1094
  /**
1024
1095
  * List of errors. The array handed out is the one the element holds, and a validator writes into it in place,
@@ -1026,10 +1097,10 @@ class A {
1026
1097
  * except the errors would leave a state the form never held.
1027
1098
  */
1028
1099
  get errors() {
1029
- return this.touchState(), l(this, h).errors;
1100
+ return this.touchState(), this.#t.errors;
1030
1101
  }
1031
- set errors(e) {
1032
- this.touchState(), l(this, h).errors = e;
1102
+ set errors(t) {
1103
+ this.touchState(), this.#t.errors = t;
1033
1104
  }
1034
1105
  /**
1035
1106
  * The container that holds this element: the Group it is a member of, or the List whose row it is, and
@@ -1038,11 +1109,11 @@ class A {
1038
1109
  * releases it.
1039
1110
  */
1040
1111
  get parent() {
1041
- return l(this, h).parent;
1112
+ return this.#t.parent;
1042
1113
  }
1043
1114
  /** when member of a Group, fieldName specifies the name of this field. Written by the group, read-only after */
1044
1115
  get fieldName() {
1045
- return l(this, h).fieldName;
1116
+ return this.#t.fieldName;
1046
1117
  }
1047
1118
  /**
1048
1119
  * The element this one was declared as: itself for an element built from parameters, and the element it was
@@ -1051,8 +1122,7 @@ class A {
1051
1122
  * answer with the same element, and an action registered on the template can tell the two apart.
1052
1123
  */
1053
1124
  get declaration() {
1054
- var e;
1055
- return (e = l(this, f).declaration) != null ? e : this;
1125
+ return this.#e.declaration ?? this;
1056
1126
  }
1057
1127
  /** The elements this one holds: a Group's members, a List's rows, none for a leaf. */
1058
1128
  get members() {
@@ -1064,9 +1134,9 @@ class A {
1064
1134
  * field that every row of a list reacts to - and it costs the subtree, so it is the path taken only when the
1065
1135
  * cheaper one, resolving within a single record, does not apply.
1066
1136
  */
1067
- bindingsOf(e) {
1068
- const t = e.declaration, s = [], i = (r) => {
1069
- r.declaration === t && s.push(r), r.members.forEach(i);
1137
+ bindingsOf(t) {
1138
+ const e = t.declaration, s = [], i = (a) => {
1139
+ a.declaration === e && s.push(a), a.members.forEach(i);
1070
1140
  };
1071
1141
  return i(this), s;
1072
1142
  }
@@ -1078,33 +1148,32 @@ class A {
1078
1148
  * nothing says so again, so the next container above answers for it.
1079
1149
  */
1080
1150
  markRecordIncomplete() {
1081
- this._recordPending || (this._recordPending = !0, st++);
1151
+ this._recordPending || (this._recordPending = !0, z++);
1082
1152
  }
1083
1153
  /**
1084
1154
  * Runs the eager passes outstanding in `element`'s subtree, now that the record it belongs to is assembled. A
1085
1155
  * container calls it where it has just made a record complete: a Group that has written its members, and a
1086
1156
  * List that has taken a row, which is what gives the row's fields the form above it.
1087
1157
  */
1088
- completeRecords(e = this) {
1089
- st !== 0 && g(() => {
1090
- const t = (s) => {
1091
- s._recordPending && (s._recordPending = !1, st--, s.rerunEagerActions()), s.members.forEach(t);
1158
+ completeRecords(t = this) {
1159
+ z !== 0 && u(() => {
1160
+ const e = (s) => {
1161
+ s._recordPending && (s._recordPending = !1, z--, s.rerunEagerActions()), s.members.forEach(e);
1092
1162
  };
1093
- t(e);
1163
+ e(t);
1094
1164
  });
1095
1165
  }
1096
1166
  /** Runs this element's eager actions over the value it holds and re-forms the verdict they reach. */
1097
1167
  rerunEagerActions() {
1098
- g((e) => {
1099
- var t;
1100
- (t = this._actions) == null || t.triggerEager(this, this.value, this.value), e.markValidityDirty(this);
1168
+ u((t) => {
1169
+ this._actions?.triggerEager(this, this.value, this.value), t.markValidityDirty(this);
1101
1170
  });
1102
1171
  }
1103
1172
  get actions() {
1104
- return this._actions || (this._actions = new M()), this._actions;
1173
+ return this._actions || (this._actions = new D()), this._actions;
1105
1174
  }
1106
- set actions(e) {
1107
- this._actions = e;
1175
+ set actions(t) {
1176
+ this._actions = t;
1108
1177
  }
1109
1178
  /**
1110
1179
  * Counts the writes that have changed the value of this element or of anything below it. A container reads it
@@ -1112,7 +1181,7 @@ class A {
1112
1181
  * cached value still re-runs when a descendant is written.
1113
1182
  */
1114
1183
  get valueVersion() {
1115
- return l(this, h).valueVersion;
1184
+ return this.#t.valueVersion;
1116
1185
  }
1117
1186
  /**
1118
1187
  * Marks the value of this element and of every ancestor as superseded. It walks the parent chain, so it costs
@@ -1121,11 +1190,11 @@ class A {
1121
1190
  * rollback puts the versions back and no reader is left holding a cache the tree no longer supports.
1122
1191
  */
1123
1192
  bumpValueVersion() {
1124
- g((e) => {
1125
- e.touch(this), l(this, h).valueVersion++;
1126
- let t = this.parent;
1127
- for (; t; )
1128
- e.touch(t), l(t, h).valueVersion++, t = t.parent;
1193
+ u((t) => {
1194
+ t.touch(this), this.#t.valueVersion++;
1195
+ let e = this.parent;
1196
+ for (; e; )
1197
+ t.touch(e), e.#t.valueVersion++, e = e.parent;
1129
1198
  });
1130
1199
  }
1131
1200
  /**
@@ -1136,10 +1205,9 @@ class A {
1136
1205
  * `force` states that the caller already knows this element's value changed - one item more or fewer is a
1137
1206
  * different list whatever the items compare as - so the commit announces it without composing a comparison.
1138
1207
  */
1139
- propagateValueChanged(e = !1) {
1140
- g((t) => {
1141
- var s;
1142
- t.markValueChanged(this, e), t.markValidityDirty(this), (s = this.parent) == null || s.notifyValueChanged();
1208
+ propagateValueChanged(t = !1) {
1209
+ u((e) => {
1210
+ e.markValueChanged(this, t), e.markValidityDirty(this), this.parent?.notifyValueChanged();
1143
1211
  });
1144
1212
  }
1145
1213
  /**
@@ -1156,7 +1224,7 @@ class A {
1156
1224
  * without a validate() call, which is the documented cost of pushing errors by hand.
1157
1225
  */
1158
1226
  get countedValid() {
1159
- return l(this, f).errors.length === 0 && l(this, f).invalidChildren === 0;
1227
+ return this.#e.errors.length === 0 && this.#e.invalidChildren === 0;
1160
1228
  }
1161
1229
  /**
1162
1230
  * Makes this element the container of `child`: it installs the back-reference, records the name a Group holds
@@ -1165,16 +1233,18 @@ class A {
1165
1233
  * released that way can be handed on. The child's state is unreachable from outside FieldBase, so a container
1166
1234
  * writes the two slots through here rather than on the child.
1167
1235
  */
1168
- takeChild(e, t) {
1169
- g((s) => {
1170
- if (e.parent) throw new TypeError("This element already belongs to a container - pass a bind() of it");
1171
- s.touch(e), l(e, h).fieldName = t, l(e, h).parent = this, this.adoptChild(e);
1236
+ takeChild(t, e) {
1237
+ u((s) => {
1238
+ if (t.parent) throw new TypeError("This element already belongs to a container - pass a bind() of it");
1239
+ s.touch(t), t.#t.fieldName = e, t.#t.parent = this, this.adoptChild(t);
1172
1240
  });
1173
1241
  }
1174
1242
  /** Takes a child into this element's invalid tally; a container calls it once the child's parent link exists. */
1175
- adoptChild(e) {
1176
- g((t) => {
1177
- t.touch(this), l(e, f).valid || l(this, f).invalidChildren++, t.markValidityDirty(this);
1243
+ adoptChild(t) {
1244
+ u((e) => {
1245
+ e.touch(this), t.#e.valid || this.#e.invalidChildren++, t.validating && this.childValidatingChanged(!0), e.whenRolledBack(() => {
1246
+ t.validating && this.childValidatingChanged(!1);
1247
+ }), e.markValidityDirty(this);
1178
1248
  });
1179
1249
  }
1180
1250
  /**
@@ -1182,9 +1252,11 @@ class A {
1182
1252
  * to a container that no longer holds it: it would go on moving that container's tally, and the link is what
1183
1253
  * stands in the way of the element being taken by another container.
1184
1254
  */
1185
- releaseChild(e) {
1186
- g((t) => {
1187
- t.touch(this), t.touch(e), l(e, f).valid || l(this, f).invalidChildren--, l(e, h).parent = void 0, t.markValidityDirty(this);
1255
+ releaseChild(t) {
1256
+ u((e) => {
1257
+ e.touch(this), e.touch(t), t.#e.valid || this.#e.invalidChildren--, t.validating && this.childValidatingChanged(!1), e.whenRolledBack(() => {
1258
+ t.validating && this.childValidatingChanged(!0);
1259
+ }), t.#t.parent = void 0, t.#t.fieldName = void 0, e.markValidityDirty(this);
1188
1260
  });
1189
1261
  }
1190
1262
  /**
@@ -1194,24 +1266,24 @@ class A {
1194
1266
  * an element at a position it already holds calls it, so the element is indistinguishable from one built for
1195
1267
  * that position.
1196
1268
  */
1197
- resetTo(e, t) {
1198
- g(() => {
1199
- const s = t === void 0 ? e.value : t, i = this.errors.length > 0;
1269
+ resetTo(t, e) {
1270
+ u(() => {
1271
+ const s = e === void 0 ? t.value : e, i = this.errors.length > 0;
1200
1272
  i && (this.errors = []), this.touched = !1;
1201
- const r = this.enabled && this.value !== s;
1202
- this.value = s, this.originalValue = this.value, this.validate(!r && i);
1273
+ const a = this.enabled && this.value !== s;
1274
+ this.value = s, this.originalValue = this.value, this.validate(!a && i);
1203
1275
  });
1204
1276
  }
1205
1277
  /** Resets a member. It is what lets a container reach the reset of a child whose class it does not know. */
1206
- resetChild(e, t, s) {
1207
- e.resetTo(t, s);
1278
+ resetChild(t, e, s) {
1279
+ t.resetTo(e, s);
1208
1280
  }
1209
1281
  /**
1210
1282
  * Records a child's new verdict in this element's tally. The child reports it as it settles, and the commit
1211
1283
  * settles the deepest element first, so the tally a container reads when its own turn comes is finished.
1212
1284
  */
1213
- childValidityChanged(e) {
1214
- l(this, f).invalidChildren += e ? -1 : 1;
1285
+ childValidityChanged(t) {
1286
+ this.#e.invalidChildren += t ? -1 : 1;
1215
1287
  }
1216
1288
  /**
1217
1289
  * The composed verdict a container answers `valid` with, memoised by Vue. The walk over the members is what
@@ -1219,35 +1291,33 @@ class A {
1219
1291
  * from repeating while nothing it read has moved.
1220
1292
  */
1221
1293
  get validRead() {
1222
- let e = It.get(this);
1223
- return e || (e = jt(() => this.composeValid()), It.set(this, e)), e.value;
1294
+ let t = ht.get(this);
1295
+ return t || (t = X(() => this.composeValid()), ht.set(this, t)), t.value;
1224
1296
  }
1225
1297
  /** What validRead computes. A leaf answers over its own errors; a container adds its members. */
1226
1298
  composeValid() {
1227
- return l(this, h).errors.length === 0;
1299
+ return this.#t.errors.length === 0;
1228
1300
  }
1229
1301
  // default property handlers
1230
1302
  get visibility() {
1231
- return l(this, h).visibility;
1303
+ return this.#t.visibility;
1232
1304
  }
1233
- set visibility(e) {
1234
- g((t) => {
1235
- var r, a;
1236
- const s = l(this, h).visibility, i = (r = this._actions) == null ? void 0 : r.trigger(Wt, this, e, s);
1237
- if (!N.isDefined(i != null ? i : e))
1305
+ set visibility(t) {
1306
+ u((e) => {
1307
+ const s = this.#t.visibility, i = this._actions?.trigger(Rt, this, t, s);
1308
+ if (!_.isDefined(i ?? t))
1238
1309
  throw new Error("visibility must be a DisplayMode constant");
1239
- t.touch(this), l(this, h).visibility = N.fromAny(i != null ? i : e), (a = this._actions) == null || a.trigger($t, this, l(this, h).visibility, s);
1310
+ e.touch(this), this.#t.visibility = _.fromAny(i ?? t), this._actions?.trigger(Pt, this, this.#t.visibility, s);
1240
1311
  });
1241
1312
  }
1242
1313
  get enabled() {
1243
- return l(this, h).enabled;
1244
- }
1245
- set enabled(e) {
1246
- g((t) => {
1247
- var r, a;
1248
- const s = l(this, h).enabled, i = (r = this._actions) == null ? void 0 : r.trigger(Bt, this, e, s);
1249
- if (!Kt(i != null ? i : e)) throw new Error("Enabled value must be boolean");
1250
- t.touch(this), l(this, h).enabled = i != null ? i : e, l(this, h).enabled !== s && this.bumpValueVersion(), (a = this._actions) == null || a.trigger(Ut, this, l(this, h).enabled, s);
1314
+ return this.#t.enabled;
1315
+ }
1316
+ set enabled(t) {
1317
+ u((e) => {
1318
+ const s = this.#t.enabled, i = this._actions?.trigger(_t, this, t, s);
1319
+ if (!Lt(i ?? t)) throw new Error("Enabled value must be boolean");
1320
+ e.touch(this), this.#t.enabled = i ?? t, this.#t.enabled !== s && this.bumpValueVersion(), this._actions?.trigger(Ot, this, this.#t.enabled, s);
1251
1321
  });
1252
1322
  }
1253
1323
  /**
@@ -1266,15 +1336,12 @@ class A {
1266
1336
  * operation states rather than an element's state - an item added, an item removed - are emitted first, in the
1267
1337
  * order the operations happened.
1268
1338
  */
1269
- [Ft](e, t, s, i) {
1270
- if (i == null || i.forEach((c) => {
1271
- var u;
1272
- return (u = this._actions) == null ? void 0 : u.trigger(c.actionClass, this, c.item, c.index);
1273
- }), !t) return;
1274
- const r = this._actions;
1275
- if (this.composesValue && !(r != null && r.willTrigger(B))) return;
1276
- const a = this.value, o = l(this, f).announcedValue;
1277
- !s && (this.composesValue ? nt(a, o) : a === o) || (e.touch(this), l(this, f).announcedValue = a, this.composesValue ? r == null || r.trigger(O, this, a, o) : r == null || r.triggerChain(B, this, a, o));
1339
+ [Et](t, e, s, i) {
1340
+ if (i?.forEach((l) => this._actions?.trigger(l.actionClass, this, l.item, l.index)), !e) return;
1341
+ const a = this._actions;
1342
+ if (this.composesValue && !(a?.willTrigger(yt) || a?.hasEager)) return;
1343
+ const r = this.value, o = this.#e.announcedValue;
1344
+ !s && (this.composesValue ? Q(r, o) : r === o) || (t.touch(this), this.#e.announcedValue = r, this.composesValue && a?.triggerEager(this, r, o), a?.trigger(S, this, r, o));
1278
1345
  }
1279
1346
  /**
1280
1347
  * Forms the verdict this element ends the transaction with and announces a transition of it. The container is
@@ -1283,28 +1350,26 @@ class A {
1283
1350
  * asynchronous validator, an error pushed in by hand - is what makes the container re-form its own. The
1284
1351
  * transaction settles the deepest element first, so a container is reached only once its members have decided.
1285
1352
  */
1286
- [Nt](e) {
1287
- var r;
1288
- const t = l(this, f).valid, s = this.countedValid;
1289
- if (s === t) return;
1290
- e.touch(this), l(this, f).valid = s;
1353
+ [xt](t) {
1354
+ const e = this.#e.valid, s = this.countedValid;
1355
+ if (s === e) return;
1356
+ t.touch(this), this.#e.valid = s;
1291
1357
  const i = this.parent;
1292
- i && (e.touch(i), i.childValidityChanged(s), e.markValidityDirty(i)), (r = this._actions) == null || r.trigger(Mt, this, s, t);
1358
+ i && (t.touch(i), i.childValidityChanged(s), t.markValidityDirty(i)), this._actions?.trigger(Ft, this, s, e);
1293
1359
  }
1294
- validate(e = !1) {
1295
- g((t) => {
1296
- var s;
1297
- e && ((s = this._actions) == null || s.triggerEager(this, this.value, this.value)), t.markValidityDirty(this);
1360
+ validate(t = !1) {
1361
+ u((e) => {
1362
+ t && this._actions?.triggerEager(this, this.value, this.value), e.markValidityDirty(this);
1298
1363
  });
1299
1364
  }
1300
1365
  get valid() {
1301
- return l(this, h).errors.length === 0;
1366
+ return this.#t.errors.length === 0;
1302
1367
  }
1303
1368
  get fullValue() {
1304
1369
  return this.value;
1305
1370
  }
1306
1371
  get isChanged() {
1307
- return !nt(this.value, this.originalValue);
1372
+ return !Q(this.value, this.originalValue);
1308
1373
  }
1309
1374
  /**
1310
1375
  * Brings a fresh element into the state a binding of `source` is in: it records what it was declared as, takes
@@ -1314,30 +1379,65 @@ class A {
1314
1379
  * actions are the very instances `source` holds - what a binding takes on is data, not behaviour - and each is
1315
1380
  * told about this element as it is taken on, so an action serving several bindings knows all of them.
1316
1381
  */
1317
- boundFrom(e, t, s, i) {
1318
- l(this, f).declaration = e.declaration;
1319
- const r = p(p({}, e.extra), i && this.extendedOf(i));
1320
- L(r) || this.setExtendedValues(r);
1321
- const a = e._actions;
1322
- a && (this._actions = a.clone(), this._actions.bindTo(this), this._actions.triggerEager(this, t, s));
1382
+ boundFrom(t, e, s, i) {
1383
+ this.#e.declaration = t.declaration;
1384
+ const a = { ...t.extra, ...i && this.extendedOf(i) };
1385
+ R(a) || this.setExtendedValues(a);
1386
+ const r = t._actions;
1387
+ r && (this._actions = r.clone(), this._actions.bindTo(this), this._actions.triggerEager(this, e, s));
1323
1388
  }
1324
1389
  /**
1325
1390
  * Registers the actions a constructor received in its parameters: registration without the eager trigger,
1326
1391
  * because a constructor ends with a single this.actions.triggerEager(...) over the finished value, and an
1327
1392
  * eager action registered here would otherwise also run once per registration, over a half-built field.
1328
1393
  */
1329
- registerInitialActions(e) {
1330
- e.forEach((t) => {
1331
- this.actions.register(t), t.boundToBinding(this);
1394
+ registerInitialActions(t) {
1395
+ t.forEach((e) => {
1396
+ this.actions.register(e), e.boundToBinding(this);
1332
1397
  });
1333
1398
  }
1334
- registerAction(e) {
1335
- return g((t) => {
1336
- t.willAnnounceValue(this) || this.refreshPreviousValue(), this.actions.register(e), e.boundToBinding(this), e.eager && this.actions.trigger(Object.getPrototypeOf(e).constructor, this, this.value, this.originalValue);
1399
+ registerAction(t) {
1400
+ return u((e) => {
1401
+ e.willAnnounceValue(this) || this.refreshPreviousValue(), this.actions.register(t), this.registered(e, t), t.eager && this.actions.triggerEagerFor(t.classIdentifier, this, this.value, this.originalValue);
1337
1402
  }), this;
1338
1403
  }
1339
- triggerAction(e, ...t) {
1340
- return this._actions ? this._actions.trigger(e, this, ...t) : null;
1404
+ /**
1405
+ * Registers `action` so that `before` wraps it: `before` reaches it through the `supr` it is handed, instead of
1406
+ * ending the run there. It is how an action is added to a chain someone else built and still sits inside a
1407
+ * handler already registered, which registration order alone cannot arrange. `before` has to be registered on
1408
+ * this element under the same identifier.
1409
+ */
1410
+ registerActionBefore(t, e) {
1411
+ return u((s) => {
1412
+ s.willAnnounceValue(this) || this.refreshPreviousValue(), this.actions.register(t, e), this.registered(s, t), t.eager && this.actions.triggerEagerFor(t.classIdentifier, this, this.value, this.originalValue);
1413
+ }), this;
1414
+ }
1415
+ /**
1416
+ * Drops `action` from this element and answers whether it held it. The instance goes on serving every other
1417
+ * element it was registered on: what is dropped is this element's registration, not the action. A validator
1418
+ * withdraws the errors it put on this element as it goes, so the verdict the element reports is the one the
1419
+ * validators it still holds reach.
1420
+ */
1421
+ unregisterAction(t) {
1422
+ let e = !1;
1423
+ return u((s) => {
1424
+ const i = this._actions;
1425
+ i && (e = i.unregister(t), e && (s.touch(this), t instanceof g && this.#t.validationEpoch++, s.whenRolledBack(() => {
1426
+ i.register(t), t.boundToBinding(this);
1427
+ }), t.unregisterFrom(this)));
1428
+ }), e;
1429
+ }
1430
+ /**
1431
+ * Records that `action` is now registered on this element, and that a rollback has to take that back. The
1432
+ * registration is not one of the state slots the snapshot covers, so it hands its own undo in.
1433
+ */
1434
+ registered(t, e) {
1435
+ e.boundToBinding(this), t.whenRolledBack(() => {
1436
+ this._actions?.unregister(e) && e.unregisterFrom(this);
1437
+ });
1438
+ }
1439
+ triggerAction(t, ...e) {
1440
+ return this._actions ? this._actions.trigger(t, this, ...e) : null;
1341
1441
  }
1342
1442
  /**
1343
1443
  * Generation counter of the validators attached to this field. A Validator reads it when a run starts and drops
@@ -1345,30 +1445,46 @@ class A {
1345
1445
  * cannot push an error onto a field that no longer has the validator that produced it.
1346
1446
  */
1347
1447
  get validationEpoch() {
1348
- return l(this, h).validationEpoch;
1448
+ return this.#t.validationEpoch;
1349
1449
  }
1350
1450
  clearValidators() {
1351
- g((e) => {
1352
- if (e.touch(this), l(this, h).validationEpoch++, this._actions) {
1353
- const t = this._actions, s = t.validators;
1354
- e.whenRolledBack(() => {
1355
- this._actions = t;
1356
- }), this.actions = t.cloneWithoutValidators(), e.whenCommitted(() => s.forEach((i) => i.unregisterFrom(this)));
1357
- }
1358
- this.errors = [], this.validate();
1451
+ u((t) => {
1452
+ t.touch(this), this.#t.validationEpoch++;
1453
+ const e = this._actions;
1454
+ e && e.validators.forEach((s) => {
1455
+ e.unregister(s), t.whenRolledBack(() => {
1456
+ e.register(s), s.boundToBinding(this);
1457
+ }), s.unregisterFrom(this);
1458
+ }), this.errors = [], this.validate();
1359
1459
  });
1360
1460
  }
1361
1461
  }
1362
- h = new WeakMap(), f = new WeakMap();
1363
- function Se(n, e) {
1364
- return n ? !e : e;
1462
+ function de(n, t) {
1463
+ return n ? !t : t;
1365
1464
  }
1366
- class I {
1367
- constructor(e, t, s) {
1368
- d(this, "operand1");
1369
- d(this, "operator");
1370
- d(this, "operand2");
1371
- this.operand1 = e, this.operator = t, this.operand2 = s;
1465
+ class v {
1466
+ operand1;
1467
+ operator;
1468
+ operand2;
1469
+ /**
1470
+ * An operand is a nested `Statement`, a `FieldBase` whose value is compared, or a literal. `undefined` and a
1471
+ * function are neither: they are what a misspelled field name and a field accessor handed over uncalled answer
1472
+ * with, and a statement built from one compares nothing and never fires. The position names which of the two
1473
+ * operands is at fault, so the error points at the place the name was written.
1474
+ */
1475
+ static validateOperand(t, e) {
1476
+ if (t === void 0)
1477
+ throw new TypeError(
1478
+ `Statement operand ${e} is undefined: an operand is a field, a nested statement or a literal, and a name resolving to nothing is none of them. Compare against null to test for an unset value.`
1479
+ );
1480
+ if (typeof t == "function")
1481
+ throw new TypeError(
1482
+ `Statement operand ${e} is a function: an operand is a field, a nested statement or a literal, and a function is none of them. An accessor states the field it answers with: group.field('name').`
1483
+ );
1484
+ }
1485
+ /** @throws TypeError where an operand the statement reads is undefined or a function. */
1486
+ constructor(t, e, s) {
1487
+ v.validateOperand(t, 1), e !== c.NOT && v.validateOperand(s, 2), this.operand1 = t, this.operator = e, this.operand2 = s;
1372
1488
  }
1373
1489
  /**
1374
1490
  * The value an operand contributes. A field operand names a field of the record the statement is evaluated in:
@@ -1376,66 +1492,65 @@ class I {
1376
1492
  * record of the statement's own - a form field above the list - is read where it stands. A record that does not
1377
1493
  * hold the field yet contributes undefined, which is what a half-built row answers with.
1378
1494
  */
1379
- static valueOf(e, t) {
1380
- if (e instanceof I) return e.evaluate(t);
1381
- if (e instanceof A) {
1382
- const s = t ? ut(e, t) : e;
1383
- return s ? b(s.value) : void 0;
1495
+ static valueOf(t, e) {
1496
+ if (t instanceof v) return t.evaluate(e);
1497
+ if (t instanceof V) {
1498
+ const s = e ? G(t, e) : t;
1499
+ return s ? h(s.value) : void 0;
1384
1500
  }
1385
- return e;
1501
+ return t;
1386
1502
  }
1387
1503
  get operand1Value() {
1388
- return I.valueOf(this.operand1);
1504
+ return v.valueOf(this.operand1);
1389
1505
  }
1390
1506
  get operand2Value() {
1391
- return I.valueOf(this.operand2);
1507
+ return v.valueOf(this.operand2);
1392
1508
  }
1393
1509
  /**
1394
1510
  * The result of the statement, over the record `scope` belongs to where one is given and over the fields the
1395
1511
  * statement was built from where it is not.
1396
1512
  */
1397
- evaluate(e) {
1398
- var i, r;
1399
- const t = I.valueOf(this.operand1, e), s = I.valueOf(this.operand2, e);
1513
+ evaluate(t) {
1514
+ const e = v.valueOf(this.operand1, t), s = v.valueOf(this.operand2, t);
1400
1515
  switch (this.operator) {
1401
1516
  // logical operators
1402
1517
  // `&&` and `||` evaluate to one of their operands, and the operands are of any type. Without the
1403
1518
  // coercion evaluate() would hand out the operand itself, so `0` or `''` would reach callers that the
1404
1519
  // signature promises a boolean, and consumers comparing results with !== would see a change where the
1405
1520
  // logical value stayed the same.
1406
- case m.AND:
1407
- return !!(t && s);
1408
- case m.OR:
1409
- return !!(t || s);
1410
- case m.NAND:
1411
- return !(t && s);
1412
- case m.NOR:
1413
- return !(t || s);
1414
- case m.XOR:
1415
- return Se(!!t, !!s);
1416
- case m.NOT:
1417
- return !t;
1521
+ case c.AND:
1522
+ return !!(e && s);
1523
+ case c.OR:
1524
+ return !!(e || s);
1525
+ case c.NAND:
1526
+ return !(e && s);
1527
+ case c.NOR:
1528
+ return !(e || s);
1529
+ case c.XOR:
1530
+ return de(!!e, !!s);
1531
+ case c.NOT:
1532
+ return !e;
1418
1533
  // comparison operators
1419
- case m.EQUALS:
1420
- return t == s;
1421
- case m.NOT_EQUALS:
1422
- return t != s;
1423
- case m.LT:
1424
- return t < s;
1425
- case m.LE:
1426
- return t <= s;
1427
- case m.GE:
1428
- return t >= s;
1429
- case m.GT:
1430
- return t > s;
1431
- case m.IN:
1432
- return !!((i = s == null ? void 0 : s.includes) != null && i.call(s, t));
1433
- case m.NOT_IN:
1434
- return !((r = s == null ? void 0 : s.includes) != null && r.call(s, t));
1435
- case m.INCLUDES:
1436
- return P(t) && P(s) && t.indexOf(s) >= 0;
1437
- case m.NOT_INCLUDES:
1438
- return !(P(t) && P(s) && t.indexOf(s) >= 0);
1534
+ case c.EQUALS:
1535
+ return e == s;
1536
+ case c.NOT_EQUALS:
1537
+ return e != s;
1538
+ case c.LT:
1539
+ return e < s;
1540
+ case c.LE:
1541
+ return e <= s;
1542
+ case c.GE:
1543
+ return e >= s;
1544
+ case c.GT:
1545
+ return e > s;
1546
+ case c.IN:
1547
+ return !!s?.includes?.(e);
1548
+ case c.NOT_IN:
1549
+ return !s?.includes?.(e);
1550
+ case c.INCLUDES:
1551
+ return C(e) && C(s) && e.indexOf(s) >= 0;
1552
+ case c.NOT_INCLUDES:
1553
+ return !(C(e) && C(s) && e.indexOf(s) >= 0);
1439
1554
  default:
1440
1555
  throw new Error(`Operator not implemented ${this.operator}`);
1441
1556
  }
@@ -1445,82 +1560,87 @@ class I {
1445
1560
  * @returns A set of all fields used in this statement
1446
1561
  */
1447
1562
  collectFields() {
1448
- const e = /* @__PURE__ */ new Set();
1449
- function t(s) {
1450
- s instanceof A ? e.add(s) : s instanceof I && s.collectFields().forEach((r) => e.add(r));
1563
+ const t = /* @__PURE__ */ new Set();
1564
+ function e(s) {
1565
+ s instanceof V ? t.add(s) : s instanceof v && s.collectFields().forEach((a) => t.add(a));
1451
1566
  }
1452
- return t(this.operand1), t(this.operand2), e;
1567
+ return e(this.operand1), e(this.operand2), t;
1453
1568
  }
1454
1569
  }
1455
- const Ie = /* @__PURE__ */ Symbol("ExecuteAction");
1456
- class qt extends y {
1457
- constructor(e) {
1458
- super(e);
1570
+ const ge = /* @__PURE__ */ Symbol("ExecuteAction");
1571
+ class jt extends p {
1572
+ constructor(t) {
1573
+ super(t);
1459
1574
  }
1460
1575
  static get classIdentifier() {
1461
- return Ie;
1576
+ return ge;
1462
1577
  }
1463
- execute(e, t, s) {
1464
- return super.execute(e, t, s);
1578
+ execute(t, e, s) {
1579
+ return super.execute(t, e, s);
1465
1580
  }
1466
1581
  }
1467
- const Ae = /* @__PURE__ */ Symbol("ListItemAddedAction");
1468
- class at extends y {
1469
- constructor(e) {
1470
- super(e);
1582
+ const fe = /* @__PURE__ */ Symbol("ListItemAddedAction");
1583
+ class K extends p {
1584
+ constructor(t) {
1585
+ super(t);
1471
1586
  }
1472
1587
  static get classIdentifier() {
1473
- return Ae;
1588
+ return fe;
1474
1589
  }
1475
- execute(e, t, s, i) {
1476
- return super.execute(e, t, s, i);
1590
+ execute(t, e, s, i) {
1591
+ return super.execute(t, e, s, i);
1477
1592
  }
1478
1593
  }
1479
- const _e = /* @__PURE__ */ Symbol("ListItemRemovedAction");
1480
- class zt extends y {
1481
- constructor(e) {
1482
- super(e);
1594
+ const pe = /* @__PURE__ */ Symbol("ListItemRemovedAction");
1595
+ class Nt extends p {
1596
+ constructor(t) {
1597
+ super(t);
1483
1598
  }
1484
1599
  static get classIdentifier() {
1485
- return _e;
1600
+ return pe;
1486
1601
  }
1487
- execute(e, t, s, i) {
1488
- return super.execute(e, t, s, i);
1602
+ execute(t, e, s, i) {
1603
+ return super.execute(t, e, s, i);
1489
1604
  }
1490
1605
  }
1491
- const Te = Object.freeze({});
1492
- function Ht() {
1606
+ const me = Object.freeze({});
1607
+ function kt() {
1493
1608
  return {
1494
1609
  originalValue: void 0,
1495
1610
  announcedValue: void 0,
1496
1611
  errors: [],
1497
- visibility: N.FULL,
1612
+ visibility: _.FULL,
1498
1613
  enabled: !0,
1499
1614
  valueVersion: 0,
1500
1615
  validatingCount: 0,
1616
+ validatingChildren: 0,
1501
1617
  parent: void 0,
1502
1618
  fieldName: void 0,
1503
1619
  validationEpoch: 0,
1504
1620
  declaration: void 0,
1505
- extra: Te,
1621
+ extra: me,
1506
1622
  valid: !0,
1507
1623
  invalidChildren: 0
1508
1624
  };
1509
1625
  }
1510
- function Oe() {
1511
- return x(p({}, Ht()), { value: void 0, touched: !1 });
1626
+ function ve() {
1627
+ return { ...kt(), value: void 0, touched: !1 };
1512
1628
  }
1513
- function Qt() {
1514
- return x(p({}, Ht()), {
1629
+ function Bt() {
1630
+ return {
1631
+ ...kt(),
1515
1632
  announcedValue: null,
1516
1633
  cachedValue: null,
1517
1634
  cachedValueVersion: -1
1518
- });
1635
+ };
1519
1636
  }
1520
- function je() {
1521
- return x(p({}, Qt()), { rows: null });
1637
+ function be() {
1638
+ return { ...Bt(), fieldNames: [] };
1522
1639
  }
1523
- class X extends A {
1640
+ function we() {
1641
+ return { ...Bt(), rows: null, rowsVersion: 0, cachedItems: null, cachedItemsVersion: -1 };
1642
+ }
1643
+ class M extends V {
1524
1644
  get state() {
1525
1645
  return super.state;
1526
1646
  }
@@ -1531,11 +1651,11 @@ class X extends A {
1531
1651
  get _value() {
1532
1652
  return this.state.value;
1533
1653
  }
1534
- set _value(e) {
1535
- this.state.value = e;
1654
+ set _value(t) {
1655
+ this.state.value = t;
1536
1656
  }
1537
- constructor(e) {
1538
- super(Oe()), this.init(e);
1657
+ constructor(t) {
1658
+ super(ve()), this.init(t);
1539
1659
  }
1540
1660
  /**
1541
1661
  * Applies the constructor parameters. It is a hook so that a subclass needing different parameter handling
@@ -1546,63 +1666,59 @@ class X extends A {
1546
1666
  * subclass initializes read as undefined inside it, and anything it writes to such a member is overwritten
1547
1667
  * the moment the initializer runs.
1548
1668
  */
1549
- init(e) {
1550
- g(() => {
1551
- var s;
1552
- if (e) {
1553
- const t = e, { value: i, validators: r, actions: a } = t, o = k(t, ["value", "validators", "actions"]);
1554
- this.registerInitialActions([...r || [], ...a || []]), this.assignParams(o), this._value = i !== void 0 ? i : this.originalValue, this.originalValue === void 0 && (this.originalValue = this._value);
1669
+ init(t) {
1670
+ u(() => {
1671
+ if (t) {
1672
+ const { value: e, validators: s, actions: i, ...a } = t;
1673
+ this.registerInitialActions([...s || [], ...i || []]), this.assignParams(a), this._value = e !== void 0 ? e : this.originalValue, this.originalValue === void 0 && (this.originalValue = this._value);
1555
1674
  }
1556
- this.raw.announcedValue = this._value, (s = this._actions) == null || s.triggerEager(this, this.value, this.originalValue), this.validate();
1675
+ this.raw.announcedValue = this._value, this._actions?.triggerEager(this, this.value, this.originalValue), this.validate();
1557
1676
  });
1558
1677
  }
1559
1678
  get value() {
1560
1679
  return this._value;
1561
1680
  }
1562
- set value(e) {
1563
- const t = this._value;
1564
- !this.enabled || t === e || g((s) => {
1565
- var i;
1566
- s.touch(this), this._value = e, this.bumpValueVersion(), (i = this._actions) == null || i.triggerEager(this, e, t), this.propagateValueChanged();
1681
+ set value(t) {
1682
+ const e = this._value;
1683
+ !this.enabled || e === t || u((s) => {
1684
+ s.touch(this), this._value = t, this.bumpValueVersion(), this._actions?.triggerEager(this, t, e), this.propagateValueChanged();
1567
1685
  });
1568
1686
  }
1569
1687
  get touched() {
1570
1688
  return this.state.touched;
1571
1689
  }
1572
- set touched(e) {
1573
- this.touchState(), this.state.touched = e;
1690
+ set touched(t) {
1691
+ this.touchState(), this.state.touched = t;
1574
1692
  }
1575
- bind(e, t) {
1576
- var r, a;
1577
- const s = this.constructor, i = new s(x(p({
1693
+ bind(t, e) {
1694
+ const s = this.constructor, i = new s({
1578
1695
  // data is what the caller supplied, and undefined is not supplied; an explicit null is, and clears
1579
- value: e !== void 0 ? e : this.value
1580
- }, t && "originalValue" in t ? { originalValue: t.originalValue } : {}), {
1581
- enabled: (r = t == null ? void 0 : t.enabled) != null ? r : this.enabled,
1582
- visibility: (a = t == null ? void 0 : t.visibility) != null ? a : this.visibility
1583
- }));
1584
- return i.boundFrom(this, i.value, i.originalValue, t), i;
1696
+ value: t !== void 0 ? t : this.value,
1697
+ ...e && "originalValue" in e ? { originalValue: e.originalValue } : {},
1698
+ enabled: e?.enabled ?? this.enabled,
1699
+ visibility: e?.visibility ?? this.visibility
1700
+ });
1701
+ return i.boundFrom(this, i.value, i.originalValue, e), i;
1585
1702
  }
1586
1703
  }
1587
- const Pe = new X({ value: "EmptyField" }).registerAction(
1588
- new O(() => {
1704
+ const Ve = new M({ value: "EmptyField" }).registerAction(
1705
+ new S(() => {
1589
1706
  console.warn("Working with EmptyField! This should not happen");
1590
1707
  })
1591
- ), _t = /* @__PURE__ */ new WeakMap();
1592
- function it(n, e) {
1593
- return (n == null ? void 0 : n.label) == null && (n == null ? void 0 : n.icon) == null ? e : n;
1594
- }
1595
- class Fe extends X {
1596
- init(e) {
1597
- g(() => {
1598
- var s;
1599
- if (this._value = { label: void 0, icon: void 0 }, e) {
1600
- const t = e, { value: i, originalValue: r, validators: a, actions: o } = t, c = k(t, ["value", "originalValue", "validators", "actions"]);
1601
- this.registerInitialActions([...a || [], ...o || []]), this.assignParams(c);
1602
- const u = it(i, this._value), C = Object.freeze({ label: r == null ? void 0 : r.label, icon: r == null ? void 0 : r.icon });
1603
- this._value = it(u, p({}, C)), this.originalValue = it(C, u);
1708
+ ), ft = /* @__PURE__ */ new WeakMap();
1709
+ function H(n, t) {
1710
+ return n?.label == null && n?.icon == null ? t : n;
1711
+ }
1712
+ class ye extends M {
1713
+ init(t) {
1714
+ u(() => {
1715
+ if (this._value = { label: void 0, icon: void 0 }, t) {
1716
+ const { value: e, originalValue: s, validators: i, actions: a, ...r } = t;
1717
+ this.registerInitialActions([...i || [], ...a || []]), this.assignParams(r);
1718
+ const o = H(e, this._value), l = Object.freeze({ label: s?.label, icon: s?.icon });
1719
+ this._value = H(o, { ...l }), this.originalValue = H(l, o);
1604
1720
  }
1605
- this.raw.announcedValue = this._value, (s = this._actions) == null || s.triggerEager(this, this.value, this.originalValue), this.validate();
1721
+ this.raw.announcedValue = this._value, this._actions?.triggerEager(this, this.value, this.originalValue), this.validate();
1606
1722
  });
1607
1723
  }
1608
1724
  /**
@@ -1611,15 +1727,15 @@ class Fe extends X {
1611
1727
  * JSON, but lodash isEqual compares own-key sets, so writing one would leave the action permanently changed
1612
1728
  * against a baseline that never carried the key.
1613
1729
  */
1614
- valueWith(e, t) {
1615
- const s = p({}, this.value);
1616
- return t === void 0 ? delete s[e] : s[e] = t, s;
1730
+ valueWith(t, e) {
1731
+ const s = { ...this.value };
1732
+ return e === void 0 ? delete s[t] : s[t] = e, s;
1617
1733
  }
1618
1734
  get icon() {
1619
1735
  return this.value.icon;
1620
1736
  }
1621
- set icon(e) {
1622
- this.value.icon !== e && (this.value = this.valueWith("icon", e));
1737
+ set icon(t) {
1738
+ this.value.icon !== t && (this.value = this.valueWith("icon", t));
1623
1739
  }
1624
1740
  get label() {
1625
1741
  return this.value.label;
@@ -1631,13 +1747,13 @@ class Fe extends X {
1631
1747
  * identity and every copy is a new object, so without the comparison here a write of the value already held
1632
1748
  * would announce a change and invalidate the value cache of every container above.
1633
1749
  */
1634
- set label(e) {
1635
- this.value.label !== e && (this.value = this.valueWith("label", e));
1750
+ set label(t) {
1751
+ this.value.label !== t && (this.value = this.valueWith("label", t));
1636
1752
  }
1637
1753
  /** the counter behind `busy`, allocated for this action the first time it is asked for */
1638
1754
  get busyRuns() {
1639
- let e = _t.get(this);
1640
- return e || (e = se(0), _t.set(this, e)), e;
1755
+ let t = ft.get(this);
1756
+ return t || (t = Wt(0), ft.set(this, t)), t;
1641
1757
  }
1642
1758
  /** true from the moment execute() is called until the handler it ran has settled, however it settles */
1643
1759
  get busy() {
@@ -1653,26 +1769,24 @@ class Fe extends X {
1653
1769
  * out of this call: a caller that does not await the answer and does not attach a catch handler leaves that
1654
1770
  * rejection unhandled.
1655
1771
  */
1656
- execute(e) {
1657
- return wt(this, null, function* () {
1658
- const t = this.busyRuns;
1659
- t.value++;
1660
- try {
1661
- return yield this.triggerAction(qt, e);
1662
- } finally {
1663
- t.value--;
1664
- }
1665
- });
1772
+ async execute(t) {
1773
+ const e = this.busyRuns;
1774
+ e.value++;
1775
+ try {
1776
+ return await this.triggerAction(jt, t);
1777
+ } finally {
1778
+ e.value--;
1779
+ }
1666
1780
  }
1667
1781
  }
1668
- const Ne = /* @__PURE__ */ ie({
1782
+ const Ce = /* @__PURE__ */ qt({
1669
1783
  __name: "messages-widget",
1670
1784
  props: {
1671
1785
  message: {},
1672
1786
  classes: {}
1673
1787
  },
1674
1788
  setup(n) {
1675
- const e = n, t = yt("vue-markdown"), s = /* @__PURE__ */ new Set([
1789
+ const t = n, e = at("vue-markdown"), s = /* @__PURE__ */ new Set([
1676
1790
  "div",
1677
1791
  "span",
1678
1792
  "p",
@@ -1729,23 +1843,23 @@ const Ne = /* @__PURE__ */ ie({
1729
1843
  "dt",
1730
1844
  "dd"
1731
1845
  ]), i = () => {
1732
- if (typeof e.message == "string") return R("span", { class: e.classes }, e.message);
1733
- const r = [];
1734
- return e.message.forEach((a) => {
1735
- switch (a.componentName) {
1846
+ if (typeof t.message == "string") return F("span", { class: t.classes }, t.message);
1847
+ const a = [];
1848
+ return t.message.forEach((r) => {
1849
+ switch (r.componentName) {
1736
1850
  case "template":
1737
- r.push(R("div", { class: [e.classes, a.extraClasses] }, a.componentBody));
1851
+ a.push(F("div", { class: [t.classes, r.extraClasses] }, r.componentBody));
1738
1852
  break;
1739
1853
  case "vue-markdown":
1740
- if (typeof t == "string")
1854
+ if (typeof e == "string")
1741
1855
  console.warn(
1742
1856
  "You are using markdown for messages-widget, but you haven't registered a vue-markdown component"
1743
- ), r.push(R("div", { class: [e.classes, a.extraClasses] }, a.componentBindings.source));
1857
+ ), a.push(F("div", { class: [t.classes, r.extraClasses] }, r.componentBindings.source));
1744
1858
  else {
1745
- const o = a.componentBindings;
1746
- r.push(
1747
- R(t, {
1748
- class: [e.classes, a.extraClasses, "df-messages-widget-markdown"],
1859
+ const o = r.componentBindings;
1860
+ a.push(
1861
+ F(e, {
1862
+ class: [t.classes, r.extraClasses, "df-messages-widget-markdown"],
1749
1863
  source: o.source,
1750
1864
  options: o.options,
1751
1865
  plugins: o.plugins
@@ -1754,88 +1868,172 @@ const Ne = /* @__PURE__ */ ie({
1754
1868
  }
1755
1869
  break;
1756
1870
  default:
1757
- r.push(
1758
- R(
1759
- s.has(a.componentName.toLowerCase()) ? a.componentName : yt(a.componentName),
1760
- p(p({
1761
- class: [e.classes, a.extraClasses]
1762
- }, a.componentBindings), a.componentBody ? { innerHTML: a.componentBody } : {})
1871
+ a.push(
1872
+ F(
1873
+ s.has(r.componentName.toLowerCase()) ? r.componentName : at(r.componentName),
1874
+ {
1875
+ class: [t.classes, r.extraClasses],
1876
+ ...r.componentBindings,
1877
+ ...r.componentBody ? { innerHTML: r.componentBody } : {}
1878
+ }
1763
1879
  )
1764
1880
  );
1765
1881
  break;
1766
1882
  }
1767
- }), r;
1883
+ }), a;
1768
1884
  };
1769
- return (r, a) => (ne(), re(i));
1885
+ return (a, r) => (zt(), Ht(i));
1770
1886
  }
1771
- });
1772
- class w extends A {
1773
- constructor(t, s) {
1774
- super(Qt());
1775
- d(this, "_fields");
1776
- if (!w.isValidFields(t)) throw new Error("Invalid fields object provided");
1777
- this._fields = /* @__PURE__ */ Object.create(null), g(() => {
1778
- var a;
1779
- if (Object.entries(t).forEach(([o, c]) => this.addField(o, c)), s) {
1780
- const r = s, { value: o, validators: c, actions: u } = r, C = k(r, ["value", "validators", "actions"]);
1781
- this.registerInitialActions([...c || [], ...u || []]), this.assignParams(C), o !== void 0 ? this.assignMembers(o) : this.originalValue !== void 0 && this.assignMembers(this.originalValue);
1782
- }
1783
- this.completeRecords();
1784
- const i = this.value;
1785
- this.originalValue === void 0 && (this.originalValue = w.baseline(i)), this.raw.announcedValue = i, (a = this._actions) == null || a.triggerEager(this, i, this.originalValue), this.validate();
1786
- });
1887
+ }), pt = /* @__PURE__ */ new WeakMap(), Ee = (n) => ({
1888
+ get(t, e, s) {
1889
+ return n(), Reflect.get(t, e, s);
1890
+ },
1891
+ has(t, e) {
1892
+ return n(), Reflect.has(t, e);
1893
+ },
1894
+ ownKeys(t) {
1895
+ return n(), Reflect.ownKeys(t);
1896
+ },
1897
+ getOwnPropertyDescriptor(t, e) {
1898
+ return n(), Reflect.getOwnPropertyDescriptor(t, e);
1899
+ },
1900
+ set(t, e) {
1901
+ throw new TypeError(`fields.${String(e)} cannot be assigned: use addField() to give the group a member`);
1902
+ },
1903
+ defineProperty(t, e) {
1904
+ throw new TypeError(`fields.${String(e)} cannot be redefined: use addField() to give the group a member`);
1905
+ },
1906
+ deleteProperty(t, e) {
1907
+ throw new TypeError(`fields.${String(e)} cannot be deleted: use removeField() to take a member out`);
1787
1908
  }
1909
+ });
1910
+ class d extends V {
1788
1911
  get state() {
1789
1912
  return super.state;
1790
1913
  }
1791
1914
  get raw() {
1792
1915
  return super.raw;
1793
1916
  }
1917
+ _fields;
1918
+ constructor(t, e) {
1919
+ if (super(be()), !d.isValidFields(t)) throw new Error("Invalid fields object provided");
1920
+ this._fields = /* @__PURE__ */ Object.create(null), u(() => {
1921
+ if (Object.entries(t).forEach(([i, a]) => this.addField(i, a)), e) {
1922
+ const { value: i, validators: a, actions: r, ...o } = e;
1923
+ this.registerInitialActions([...a || [], ...r || []]), this.assignParams(o), i !== void 0 ? this.assignMembers(i) : this.originalValue !== void 0 && this.assignMembers(this.originalValue);
1924
+ }
1925
+ this.completeRecords();
1926
+ const s = this.value;
1927
+ this.originalValue === void 0 && (this.originalValue = d.baseline(s)), this.raw.announcedValue = s, this._actions?.triggerEager(this, s, this.originalValue), this.validate();
1928
+ });
1929
+ }
1930
+ /**
1931
+ * The name array is copied as well: a rollback puts back the set of members the group held, not the array it
1932
+ * went on to hold.
1933
+ */
1934
+ [O]() {
1935
+ const t = super[O]();
1936
+ return t.fieldNames = [...this.raw.fieldNames], t;
1937
+ }
1794
1938
  /**
1795
1939
  * The copy of a built value that serves as a baseline. The value getter hands out one object per version, and
1796
1940
  * a baseline holding that same object would report every value as its own original.
1797
1941
  */
1798
1942
  static baseline(t) {
1799
- return t == null ? t : p({}, t);
1943
+ return t == null ? t : { ...t };
1944
+ }
1945
+ /**
1946
+ * Takes `field` into this group under `fieldName`. The group ends up holding it exactly as it holds a field the
1947
+ * constructor was given: the field carries the back-reference and the name, its verdict counts towards the
1948
+ * group's, and a rule of the field's that names another member of the form reaches it here.
1949
+ *
1950
+ * The change is announced through the ordinary path, so a group whose value the new field adds to says so once
1951
+ * the transaction closes, and its verdict is re-formed over the members it now holds. The baseline behind
1952
+ * `isChanged` is not rewritten: a group that gains a field holds something its original value does not carry,
1953
+ * and reports itself changed until `originalValue` is written.
1954
+ *
1955
+ * @throws Error where this group already holds a field under `fieldName`.
1956
+ * @throws TypeError where `field` already belongs to a container - pass a `bind()` of it instead.
1957
+ */
1958
+ addField(t, e) {
1959
+ return u((s) => {
1960
+ if (Object.hasOwn(this._fields, t))
1961
+ throw new Error(`Field ${t} is already in this form`);
1962
+ this.takeChild(e, t), s.touch(this), d.setEntry(this._fields, t, e), s.whenRolledBack(() => d.dropEntry(this._fields, t)), this.state.fieldNames.push(t), this.completeRecords(e), this.bumpValueVersion(), this.notifyValueChanged();
1963
+ }), this;
1964
+ }
1965
+ /**
1966
+ * Takes the field held under `fieldName` out of this group and hands it back, answering undefined where the
1967
+ * group holds no field of that name. The field is released whole: the back-reference and the name are gone, its
1968
+ * verdict and its runs in flight no longer count towards the group's, and it is free to be taken by another
1969
+ * container. What it holds - its value, its errors, the change history behind `isChanged` - is its own to report.
1970
+ *
1971
+ * The change is announced through the ordinary path, so the group's value and verdict settle over the members it
1972
+ * has left. The baseline behind `isChanged` is not rewritten, the same way it is not on `addField`.
1973
+ */
1974
+ removeField(t) {
1975
+ let e;
1976
+ return u((s) => {
1977
+ if (!Object.hasOwn(this._fields, t)) return;
1978
+ const i = this._fields[t];
1979
+ s.touch(this), this.releaseChild(i), d.dropEntry(this._fields, t), s.whenRolledBack(() => d.setEntry(this._fields, t, i)), this.state.fieldNames.splice(this.state.fieldNames.indexOf(t), 1), this.bumpValueVersion(), this.notifyValueChanged(), e = i;
1980
+ }), e;
1981
+ }
1982
+ /**
1983
+ * Writes one entry of the member map. The map is typed by the fields interface, which names the members a group
1984
+ * of that type holds and no others, so both here and in dropEntry it is reached as the plain record it is.
1985
+ */
1986
+ static setEntry(t, e, s) {
1987
+ t[e] = s;
1800
1988
  }
1801
- addField(t, s) {
1802
- if (Object.hasOwn(this._fields, t))
1803
- throw new Error(`Field ${t} is already in this form`);
1804
- this.takeChild(s, t), Object.defineProperty(this._fields, t, { get: () => s, configurable: !1, enumerable: !0 });
1989
+ /** Drops one entry out of the member map. */
1990
+ static dropEntry(t, e) {
1991
+ delete t[e];
1805
1992
  }
1806
1993
  static isValidFields(t) {
1807
- function s(i) {
1808
- return i instanceof A;
1994
+ function e(s) {
1995
+ return s instanceof V;
1809
1996
  }
1810
- return typeof t == "object" && t !== null && Object.entries(t).every(([, i]) => s(i));
1997
+ return typeof t == "object" && t !== null && Object.entries(t).every(([, s]) => e(s));
1811
1998
  }
1812
1999
  static createFromFormData(t) {
1813
- if (t instanceof A)
2000
+ if (t instanceof V)
1814
2001
  throw new Error("data is already a Form structure, should be a simple object");
1815
- return new w(
1816
- t == null ? {} : Object.fromEntries(Object.entries(t).map(([s, i]) => [s, new X({ value: i })]))
2002
+ return new d(
2003
+ t == null ? {} : Object.fromEntries(Object.entries(t).map(([e, s]) => [e, new M({ value: s })]))
1817
2004
  );
1818
2005
  }
1819
2006
  field(t) {
1820
- var s;
1821
- return (s = this._fields[t]) != null ? s : null;
2007
+ return this._fields[t] ?? null;
1822
2008
  }
2009
+ /**
2010
+ * The typed map of this group's members. What it hands out is a view over the map the group holds: reading it
2011
+ * reaches the members themselves, and every write to it is refused - addField() and removeField() are what
2012
+ * change the set. The view is built the first time something asks for it.
2013
+ *
2014
+ * Reading through it is a tracked read of the set of members, so a template rendering off `group.fields`
2015
+ * re-renders when a field is added or removed; what a member itself holds is tracked by that member.
2016
+ */
1823
2017
  get fields() {
1824
- return this._fields;
2018
+ let t = pt.get(this);
2019
+ return t || (t = new Proxy(
2020
+ this._fields,
2021
+ Ee(() => this.state.fieldNames.length)
2022
+ ), pt.set(this, t)), t;
1825
2023
  }
1826
2024
  get members() {
1827
- return Object.values(this._fields);
2025
+ return this.raw.fieldNames.map((t) => this._fields[t]);
1828
2026
  }
1829
2027
  get value() {
1830
2028
  const t = this.valueVersion;
1831
2029
  if (this.raw.cachedValueVersion === t) return this.raw.cachedValue;
1832
- const s = /* @__PURE__ */ Object.create(null);
1833
- Object.entries(this._fields).forEach(([r, a]) => {
1834
- const o = a.value;
1835
- (a.enabled || a instanceof w && !L(o)) && (s[r] = o);
2030
+ const e = /* @__PURE__ */ Object.create(null);
2031
+ Object.entries(this._fields).forEach(([i, a]) => {
2032
+ const r = a.value;
2033
+ (a.enabled || a instanceof d && !R(r)) && (e[i] = r);
1836
2034
  });
1837
- const i = L(s) ? null : Object.freeze(p({}, s));
1838
- return this.raw.cachedValue = i, this.raw.cachedValueVersion = t, i;
2035
+ const s = R(e) ? null : Object.freeze({ ...e });
2036
+ return this.raw.cachedValue = s, this.raw.cachedValueVersion = t, s;
1839
2037
  }
1840
2038
  /**
1841
2039
  * Writes the members that the given value carries. The members are written one by one and the group says
@@ -1843,15 +2041,15 @@ class w extends A {
1843
2041
  * once, over the finished set, and announces each at most once.
1844
2042
  */
1845
2043
  assignMembers(t) {
1846
- g(() => {
1847
- Object.entries(this._fields).forEach(([s, i]) => {
1848
- (t == null || Object.hasOwn(t, s)) && (i.value = t == null ? null : t[s]);
2044
+ u(() => {
2045
+ Object.entries(this._fields).forEach(([e, s]) => {
2046
+ (t == null || Object.hasOwn(t, e)) && (s.value = t == null ? null : t[e]);
1849
2047
  });
1850
2048
  });
1851
2049
  }
1852
2050
  set value(t) {
1853
- g((s) => {
1854
- this.assignMembers(t), s.markValidityDirty(this);
2051
+ u((e) => {
2052
+ this.assignMembers(t), e.markValidityDirty(this);
1855
2053
  });
1856
2054
  }
1857
2055
  /**
@@ -1859,33 +2057,32 @@ class w extends A {
1859
2057
  * value carries, while a member the value leaves out has to end up holding what the template gives it. `source`
1860
2058
  * supplies that per member, so a group reset from the template it was bound from matches a fresh binding of it.
1861
2059
  */
1862
- resetTo(t, s) {
1863
- const i = t;
1864
- g((r) => {
1865
- r.touch(this), this.errors.length && (this.errors = []), Object.entries(this._fields).forEach(([o, c]) => {
1866
- var C;
1867
- let u;
1868
- s === null ? u = null : s !== void 0 && Object.hasOwn(s, o) && (u = s[o]), this.resetChild(c, (C = i.field(o)) != null ? C : c, u);
2060
+ resetTo(t, e) {
2061
+ const s = t;
2062
+ u((i) => {
2063
+ i.touch(this), this.errors.length && (this.errors = []), Object.entries(this._fields).forEach(([r, o]) => {
2064
+ let l;
2065
+ e === null ? l = null : e !== void 0 && Object.hasOwn(e, r) && (l = e[r]), this.resetChild(o, s.field(r) ?? o, l);
1869
2066
  });
1870
2067
  const a = this.value;
1871
- this.raw.announcedValue = a, this.originalValue = w.baseline(a), super.validate(!0);
2068
+ this.raw.announcedValue = a, this.originalValue = d.baseline(a), super.validate(!0);
1872
2069
  });
1873
2070
  }
1874
2071
  get touched() {
1875
2072
  return Object.values(this._fields).some((t) => t.touched);
1876
2073
  }
1877
2074
  set touched(t) {
1878
- g(() => {
1879
- Object.values(this._fields).forEach((s) => {
1880
- s.touched = t;
2075
+ u(() => {
2076
+ Object.values(this._fields).forEach((e) => {
2077
+ e.touched = t;
1881
2078
  });
1882
2079
  });
1883
2080
  }
1884
2081
  get fullValue() {
1885
2082
  const t = /* @__PURE__ */ Object.create(null);
1886
- return Object.entries(this._fields).forEach(([s, i]) => {
1887
- t[s] = i.fullValue;
1888
- }), p({}, t);
2083
+ return Object.entries(this._fields).forEach(([e, s]) => {
2084
+ t[e] = s.fullValue;
2085
+ }), { ...t };
1889
2086
  }
1890
2087
  /**
1891
2088
  * Records that a member changed its value, so that the transaction in progress works out at commit what this
@@ -1909,27 +2106,32 @@ class w extends A {
1909
2106
  return this.validRead;
1910
2107
  }
1911
2108
  composeValid() {
1912
- return this.state.errors.length === 0 && Object.values(this._fields).every((t) => t.valid);
2109
+ return this.state.errors.length === 0 && this.state.fieldNames.every((t) => this._fields[t].valid);
2110
+ }
2111
+ get busy() {
2112
+ return this.busyRead;
2113
+ }
2114
+ composeBusy() {
2115
+ return this.state.fieldNames.some((t) => this._fields[t].busy);
1913
2116
  }
1914
2117
  validate(t = !1) {
1915
- g(() => {
1916
- t && Object.values(this._fields).forEach((s) => s.validate(!0)), super.validate(t);
2118
+ u(() => {
2119
+ t && Object.values(this._fields).forEach((e) => e.validate(!0)), super.validate(t);
1917
2120
  });
1918
2121
  }
1919
- bind(t, s) {
1920
- var a, o;
1921
- const i = /* @__PURE__ */ Object.create(null);
1922
- Object.entries(this._fields).forEach(([c, u]) => {
1923
- i[c] = u.bind();
2122
+ bind(t, e) {
2123
+ const s = /* @__PURE__ */ Object.create(null);
2124
+ Object.entries(this._fields).forEach(([a, r]) => {
2125
+ s[a] = r.bind();
1924
2126
  });
1925
- const r = new w(i, x(p({
2127
+ const i = new d(s, {
1926
2128
  // data is what the caller supplied, and undefined is not supplied; an explicit null is, and clears
1927
- value: t !== void 0 ? t : this.value
1928
- }, s && "originalValue" in s ? { originalValue: s.originalValue } : {}), {
1929
- enabled: (a = s == null ? void 0 : s.enabled) != null ? a : this.enabled,
1930
- visibility: (o = s == null ? void 0 : s.visibility) != null ? o : this.visibility
1931
- }));
1932
- return r.boundFrom(this, r.raw.announcedValue, r.originalValue, s), r;
2129
+ value: t !== void 0 ? t : this.value,
2130
+ ...e && "originalValue" in e ? { originalValue: e.originalValue } : {},
2131
+ enabled: e?.enabled ?? this.enabled,
2132
+ visibility: e?.visibility ?? this.visibility
2133
+ });
2134
+ return i.boundFrom(this, i.raw.announcedValue, i.originalValue, e), i;
1933
2135
  }
1934
2136
  /**
1935
2137
  * A record need not name every member: a key it leaves out is taken from the declaration, the same way a member
@@ -1939,28 +2141,26 @@ class w extends A {
1939
2141
  return super.rebind(t);
1940
2142
  }
1941
2143
  }
1942
- class D extends A {
1943
- constructor(t, s) {
1944
- super(je());
1945
- d(this, "_itemTemplate");
1946
- this._itemTemplate = t, g(() => {
1947
- var r;
1948
- if (s) {
1949
- const i = s, { value: a, validators: o, actions: c } = i, u = k(i, ["value", "validators", "actions"]);
1950
- this.registerInitialActions([...o || [], ...c || []]), this.assignParams(u), a != null && this.setValueInternal(a);
1951
- }
1952
- this.originalValue === void 0 && (this.originalValue = D.baseline(this.value)), this.raw.announcedValue = this.value, (r = this._actions) == null || r.triggerEager(this, this.value, this.originalValue), this.validate();
1953
- });
1954
- }
2144
+ class A extends V {
1955
2145
  get state() {
1956
2146
  return super.state;
1957
2147
  }
1958
2148
  get raw() {
1959
2149
  return super.raw;
1960
2150
  }
2151
+ _itemTemplate;
2152
+ constructor(t, e) {
2153
+ super(we()), this._itemTemplate = t, u(() => {
2154
+ if (e) {
2155
+ const { value: s, validators: i, actions: a, ...r } = e;
2156
+ this.registerInitialActions([...i || [], ...a || []]), this.assignParams(r), s != null && this.setValueInternal(s);
2157
+ }
2158
+ this.originalValue === void 0 && (this.originalValue = A.baseline(this.value)), this.raw.announcedValue = this.value, this._actions?.triggerEager(this, this.value, this.originalValue), this.validate();
2159
+ });
2160
+ }
1961
2161
  /** The row array is copied as well: a rollback puts back the set the list held, not the array it went on to hold. */
1962
- [z]() {
1963
- const t = super[z]();
2162
+ [O]() {
2163
+ const t = super[O]();
1964
2164
  return t.rows = this.raw.rows ? [...this.raw.rows] : this.raw.rows, t;
1965
2165
  }
1966
2166
  /**
@@ -1971,8 +2171,8 @@ class D extends A {
1971
2171
  return t == null ? t : [...t];
1972
2172
  }
1973
2173
  processSetValueItem(t) {
1974
- let s;
1975
- return t instanceof w ? s = t : this._itemTemplate ? s = this._itemTemplate.bind(t) : s = w.createFromFormData(t), this.takeChild(s), this.completeRecords(s), s;
2174
+ let e;
2175
+ return t instanceof d ? e = t : this._itemTemplate ? e = this._itemTemplate.bind(t) : e = d.createFromFormData(t), this.takeChild(e), this.completeRecords(e), e;
1976
2176
  }
1977
2177
  /**
1978
2178
  * Builds the item that fills a gap left by an insert beyond the end of the list: the item template bound to its
@@ -1981,32 +2181,41 @@ class D extends A {
1981
2181
  createPaddingItem() {
1982
2182
  return this.processSetValueItem(this._itemTemplate ? this._itemTemplate.bind() : null);
1983
2183
  }
2184
+ /** Records that the set of rows changed, so `items` rebuilds the frozen array it hands out at the next read. */
2185
+ rowsChanged() {
2186
+ this.state.rowsVersion++;
2187
+ }
2188
+ /** True where `next` is a different set of rows than `previous`: another count, or another row at a position. */
2189
+ static rowsDiffer(t, e) {
2190
+ const s = t ?? [], i = e ?? [];
2191
+ return s.length !== i.length || s.some((a, r) => a !== i[r]);
2192
+ }
1984
2193
  setValueInternal(t) {
1985
- g((s) => {
1986
- var i;
1987
- if (s.touch(this), t == null)
2194
+ u((e) => {
2195
+ e.touch(this);
2196
+ const s = this.raw.rows;
2197
+ if (t == null)
1988
2198
  this.releaseRows(), this.state.rows = null;
1989
2199
  else if (Array.isArray(t)) {
1990
- const r = (i = this.state.rows) != null ? i : [], a = new Array(t.length);
1991
- for (let o = 0; o < t.length; o++) {
1992
- const c = t[o], u = r[o];
1993
- u && this._itemTemplate && !(c instanceof w) ? (this.resetChild(u, this._itemTemplate, c), a[o] = u) : (u && this.releaseChild(u), a[o] = this.processSetValueItem(c));
2200
+ const i = this.state.rows ?? [], a = new Array(t.length);
2201
+ for (let r = 0; r < t.length; r++) {
2202
+ const o = t[r], l = i[r];
2203
+ l && this._itemTemplate && !(o instanceof d) ? (this.resetChild(l, this._itemTemplate, o), a[r] = l) : (l && this.releaseChild(l), a[r] = this.processSetValueItem(o));
1994
2204
  }
1995
- for (let o = t.length; o < r.length; o++) this.releaseChild(r[o]);
2205
+ for (let r = t.length; r < i.length; r++) this.releaseChild(i[r]);
1996
2206
  this.state.rows = a;
1997
2207
  }
1998
- this.bumpValueVersion();
2208
+ A.rowsDiffer(s, this.raw.rows) && this.rowsChanged(), this.bumpValueVersion();
1999
2209
  });
2000
2210
  }
2001
2211
  get value() {
2002
- var r;
2003
2212
  const t = this.valueVersion;
2004
2213
  if (this.raw.cachedValueVersion === t) return this.raw.cachedValue;
2005
- const s = (r = this.state.rows) == null ? void 0 : r.map((a) => a.value), i = L(s) ? null : Object.freeze(s);
2006
- return this.raw.cachedValue = i, this.raw.cachedValueVersion = t, i;
2214
+ const e = this.state.rows?.map((i) => i.value), s = R(e) ? null : Object.freeze(e);
2215
+ return this.raw.cachedValue = s, this.raw.cachedValueVersion = t, s;
2007
2216
  }
2008
2217
  set value(t) {
2009
- g(() => {
2218
+ u(() => {
2010
2219
  this.setValueInternal(t), this.propagateValueChanged(!0);
2011
2220
  });
2012
2221
  }
@@ -2014,35 +2223,32 @@ class D extends A {
2014
2223
  * The rows are taken from `source` where the caller supplied no value of its own, so a list nested in a row that
2015
2224
  * a whole-list assignment reuses ends up holding what the template gives it rather than what it held before.
2016
2225
  */
2017
- resetTo(t, s) {
2018
- g((i) => {
2019
- i.touch(this), this.errors.length && (this.errors = []), this.setValueInternal(s === void 0 ? t.value : s);
2020
- const r = this.value;
2021
- this.raw.announcedValue = r, this.originalValue = D.baseline(r), super.validate(!0);
2226
+ resetTo(t, e) {
2227
+ u((s) => {
2228
+ s.touch(this), this.errors.length && (this.errors = []), this.setValueInternal(e === void 0 ? t.value : e);
2229
+ const i = this.value;
2230
+ this.raw.announcedValue = i, this.originalValue = A.baseline(i), super.validate(!0);
2022
2231
  });
2023
2232
  }
2024
2233
  get touched() {
2025
- var t;
2026
- return ((t = this.state.rows) == null ? void 0 : t.some((s) => s.touched)) || !1;
2234
+ return this.state.rows?.some((t) => t.touched) || !1;
2027
2235
  }
2028
2236
  set touched(t) {
2029
- g(() => {
2030
- var s;
2031
- (s = this.state.rows) == null || s.forEach((i) => {
2032
- i.touched = t;
2237
+ u(() => {
2238
+ this.state.rows?.forEach((e) => {
2239
+ e.touched = t;
2033
2240
  });
2034
2241
  });
2035
2242
  }
2036
- bind(t, s) {
2037
- var r, a, o, c;
2038
- const i = new D((r = this._itemTemplate) == null ? void 0 : r.bind(), x(p({
2243
+ bind(t, e) {
2244
+ const s = new A(this._itemTemplate?.bind(), {
2039
2245
  // data is what the caller supplied, and undefined is not supplied; an explicit null is, and clears
2040
- value: [...(a = t !== void 0 ? t : this.value) != null ? a : []]
2041
- }, s && "originalValue" in s ? { originalValue: s.originalValue } : {}), {
2042
- enabled: (o = s == null ? void 0 : s.enabled) != null ? o : this.enabled,
2043
- visibility: (c = s == null ? void 0 : s.visibility) != null ? c : this.visibility
2044
- }));
2045
- return i.boundFrom(this, i.value, i.originalValue, s), i;
2246
+ value: [...(t !== void 0 ? t : this.value) ?? []],
2247
+ ...e && "originalValue" in e ? { originalValue: e.originalValue } : {},
2248
+ enabled: e?.enabled ?? this.enabled,
2249
+ visibility: e?.visibility ?? this.visibility
2250
+ });
2251
+ return s.boundFrom(this, s.value, s.originalValue, e), s;
2046
2252
  }
2047
2253
  /**
2048
2254
  * Records that a row changed its value, so that the transaction in progress works out at commit what this
@@ -2066,103 +2272,130 @@ class D extends A {
2066
2272
  return this.validRead;
2067
2273
  }
2068
2274
  composeValid() {
2069
- var t, s;
2070
- return this.state.errors.length === 0 && ((s = (t = this.state.rows) == null ? void 0 : t.every((i) => i.valid)) != null ? s : !0);
2275
+ return this.state.errors.length === 0 && (this.state.rows?.every((t) => t.valid) ?? !0);
2276
+ }
2277
+ get busy() {
2278
+ return this.busyRead;
2279
+ }
2280
+ composeBusy() {
2281
+ return this.state.rows?.some((t) => t.busy) ?? !1;
2071
2282
  }
2072
2283
  validate(t = !1) {
2073
- g(() => {
2074
- var s;
2075
- t && ((s = this.state.rows) == null || s.forEach((i) => i.validate(!0))), super.validate(t);
2284
+ u(() => {
2285
+ t && this.state.rows?.forEach((e) => e.validate(!0)), super.validate(t);
2076
2286
  });
2077
2287
  }
2078
2288
  get members() {
2079
- var t;
2080
- return (t = this.raw.rows) != null ? t : [];
2289
+ return this.raw.rows ?? [];
2290
+ }
2291
+ /**
2292
+ * How many rows this list holds. The read is tracked, so a template rendering off it re-renders as rows come and
2293
+ * go.
2294
+ */
2295
+ /**
2296
+ * Every row of this list, each one built from all of its fields. Where `value` states what the list serializes -
2297
+ * rows composed of the fields that are enabled, and null where the list is empty - this states what the list
2298
+ * holds: the disabled fields are in it too, and an empty list reads back as an empty array rather than as null.
2299
+ */
2300
+ get fullValue() {
2301
+ return (this.state.rows ?? []).map((t) => t.fullValue);
2302
+ }
2303
+ get length() {
2304
+ return this.state.rows?.length ?? 0;
2305
+ }
2306
+ /**
2307
+ * The rows this list holds, oldest position first. The array is a frozen copy: it states what the list held at
2308
+ * the read and nothing writes back through it - `push`, `insert`, `remove` and `clear` are what change the set -
2309
+ * so a caller may hold on to it. The rows in it are the live elements, so reading one reports what it holds now.
2310
+ *
2311
+ * The copy is built once per change of the set and handed to every reader until the next one: a write inside a
2312
+ * row changes what the list serializes without changing which rows it holds, and the array a reader took stays
2313
+ * the same one across such a write.
2314
+ */
2315
+ get items() {
2316
+ const t = this.state.rowsVersion;
2317
+ return this.raw.cachedItemsVersion !== t && (this.raw.cachedItems = Object.freeze([...this.raw.rows ?? []]), this.raw.cachedItemsVersion = t), this.raw.cachedItems;
2081
2318
  }
2082
2319
  get(t) {
2083
2320
  return this.state.rows != null ? this.state.rows[t] : void 0;
2084
2321
  }
2085
2322
  push(t) {
2086
- var s, i;
2087
- return this.insert(t, (i = (s = this.state.rows) == null ? void 0 : s.length) != null ? i : 0) + 1;
2323
+ return this.insert(t, this.state.rows?.length ?? 0) + 1;
2088
2324
  }
2089
2325
  pop() {
2090
- var t, s;
2091
- return this.remove(((s = (t = this.state.rows) == null ? void 0 : t.length) != null ? s : 0) - 1);
2326
+ return this.remove((this.state.rows?.length ?? 0) - 1);
2092
2327
  }
2093
2328
  remove(t) {
2094
- let s;
2095
- return g((i) => {
2096
- var a;
2329
+ let e;
2330
+ return u((s) => {
2097
2331
  if (this.state.rows == null || t < 0 || this.state.rows.length <= t) return;
2098
- i.touch(this);
2099
- const r = (a = this.state.rows.splice(t, 1)) == null ? void 0 : a[0];
2100
- r && (this.releaseChild(r), this.bumpValueVersion(), s = r, i.recordStructural(this, { actionClass: zt, item: s, index: t }), this.propagateValueChanged(!0));
2101
- }), s;
2102
- }
2103
- insert(t, s) {
2104
- let i = 0;
2105
- return g((r) => {
2106
- for (r.touch(this), this.state.rows == null && (this.state.rows = []), i = s < 0 ? Math.max(this.state.rows.length + s, 0) : s; this.state.rows.length < i; ) {
2107
- const o = this.createPaddingItem(), c = this.state.rows.push(o) - 1;
2108
- this.bumpValueVersion(), r.recordStructural(this, { actionClass: at, item: o, index: c });
2332
+ s.touch(this);
2333
+ const i = this.state.rows.splice(t, 1)?.[0];
2334
+ i && (this.releaseChild(i), this.rowsChanged(), this.bumpValueVersion(), e = i, s.recordStructural(this, { actionClass: Nt, item: e, index: t }), this.propagateValueChanged(!0));
2335
+ }), e;
2336
+ }
2337
+ insert(t, e) {
2338
+ let s = 0;
2339
+ return u((i) => {
2340
+ for (i.touch(this), this.state.rows == null && (this.state.rows = []), s = e < 0 ? Math.max(this.state.rows.length + e, 0) : e; this.state.rows.length < s; ) {
2341
+ const r = this.createPaddingItem(), o = this.state.rows.push(r) - 1;
2342
+ this.bumpValueVersion(), i.recordStructural(this, { actionClass: K, item: r, index: o });
2109
2343
  }
2110
2344
  const a = this.processSetValueItem(t);
2111
- this.state.rows.splice(i, 0, a), r.recordStructural(this, { actionClass: at, item: a, index: i }), this.bumpValueVersion(), this.propagateValueChanged(!0);
2112
- }), i;
2345
+ this.state.rows.splice(s, 0, a), i.recordStructural(this, { actionClass: K, item: a, index: s }), this.rowsChanged(), this.bumpValueVersion(), this.propagateValueChanged(!0);
2346
+ }), s;
2113
2347
  }
2114
2348
  /** Drops every row this list holds out of its tally, so a row that changes its verdict later is not counted. */
2115
2349
  releaseRows() {
2116
- var t;
2117
- (t = this.state.rows) == null || t.forEach((s) => this.releaseChild(s));
2350
+ this.state.rows?.forEach((t) => this.releaseChild(t));
2118
2351
  }
2119
2352
  clear() {
2120
- g((t) => {
2121
- var i, r;
2122
- const s = ((r = (i = this.state.rows) == null ? void 0 : i.length) != null ? r : 0) > 0;
2123
- t.touch(this), this.releaseRows(), this.state.rows = null, this.bumpValueVersion(), this.propagateValueChanged(s);
2353
+ u((t) => {
2354
+ const e = (this.state.rows?.length ?? 0) > 0;
2355
+ t.touch(this), this.releaseRows(), this.state.rows = null, e && this.rowsChanged(), this.bumpValueVersion(), this.propagateValueChanged(e);
2124
2356
  });
2125
2357
  }
2126
2358
  }
2127
- class ke extends v {
2128
- constructor(t, s, i) {
2129
- super((a, o, c) => {
2130
- this.comparisonState(c).oldValue = o;
2131
- const u = this.resolve(c);
2132
- return u ? (this.listenOn(u), this.isValidComparison(b(a), b(u.value)) ? null : [
2133
- new V(
2134
- this.replacePlaceholders(i, { newValue: a, oldValue: o, field: c, otherField: u })
2359
+ class xe extends g {
2360
+ constructor(t, e, s) {
2361
+ const i = (a, r, o) => {
2362
+ this.comparisonState(o).oldValue = r;
2363
+ const l = this.resolve(o);
2364
+ return l ? (this.listenOn(l), this.isValidComparison(h(a), h(l.value)) ? null : [
2365
+ new f(
2366
+ this.replacePlaceholders(s, { newValue: a, oldValue: r, field: o, otherField: l }),
2367
+ "",
2368
+ "compare-to"
2135
2369
  )
2136
- ]) : (c.markRecordIncomplete(), null);
2137
- });
2138
- d(this, "isValidComparison");
2139
- d(this, "otherField");
2140
- /**
2141
- * The fields this validator is registered on. Registration reaches one element at a time - the rows of a list
2142
- * take the validator on one by one, as they are built from the item template that carries it - so this is what
2143
- * says which of the fields a declaration stands for actually carry the rule, and a field that never took it on
2144
- * is left alone by a change of the compared field.
2145
- */
2146
- d(this, "registrations", /* @__PURE__ */ new WeakSet());
2147
- /**
2148
- * The fields this validator has installed its listener on. A binding of such a field carries the listener too -
2149
- * a binding takes on the actions of the field it was bound from - so the field it was bound from is what is
2150
- * asked about as well, and a list of a thousand rows installs one listener rather than a thousand.
2151
- */
2152
- d(this, "listening", /* @__PURE__ */ new WeakSet());
2153
- /**
2154
- * What the fields this validator was registered on were declared as. One entry stands for every binding of such a
2155
- * field, so a change of a compared field finds the fields of the record that change happened in without a list
2156
- * of a thousand rows being held here.
2157
- */
2158
- d(this, "declarations", /* @__PURE__ */ new Set());
2159
- this.isValidComparison = s, this.otherField = t;
2370
+ ]) : (o.markRecordIncomplete(), null);
2371
+ };
2372
+ super(i), this.isValidComparison = e, this.otherField = t;
2160
2373
  }
2374
+ isValidComparison;
2375
+ otherField;
2376
+ /**
2377
+ * The fields this validator is registered on. Registration reaches one element at a time - the rows of a list
2378
+ * take the validator on one by one, as they are built from the item template that carries it - so this is what
2379
+ * says which of the fields a declaration stands for actually carry the rule, and a field that never took it on
2380
+ * is left alone by a change of the compared field.
2381
+ */
2382
+ registrations = /* @__PURE__ */ new WeakSet();
2383
+ /**
2384
+ * The fields this validator has installed its listener on. A binding of such a field carries the listener too -
2385
+ * a binding takes on the actions of the field it was bound from - so the field it was bound from is what is
2386
+ * asked about as well, and a list of a thousand rows installs one listener rather than a thousand.
2387
+ */
2388
+ listening = /* @__PURE__ */ new WeakSet();
2389
+ /**
2390
+ * What the fields this validator was registered on were declared as. One entry stands for every binding of such a
2391
+ * field, so a change of a compared field finds the fields of the record that change happened in without a list
2392
+ * of a thousand rows being held here.
2393
+ */
2394
+ declarations = /* @__PURE__ */ new Set();
2161
2395
  /** The field `field` is compared against, within the record `field` belongs to. */
2162
2396
  resolve(t) {
2163
- var i;
2164
- const s = this.otherField;
2165
- return typeof s == "function" ? (i = s(t)) != null ? i : void 0 : typeof s == "string" ? pe(s, t) : ut(s, T(t));
2397
+ const e = this.otherField;
2398
+ return typeof e == "function" ? e(t) ?? void 0 : typeof e == "string" ? se(e, t) : G(e, x(t));
2166
2399
  }
2167
2400
  /**
2168
2401
  * Makes a change of `other` re-run this comparison. The listener re-runs it over the fields of the record the
@@ -2171,12 +2404,12 @@ class ke extends v {
2171
2404
  */
2172
2405
  listenOn(t) {
2173
2406
  this.listening.has(t) || this.listening.has(t.declaration) || (this.listening.add(t), t.registerAction(
2174
- new O((s, i, r, a) => {
2175
- i(s, r, a);
2176
- const o = T(s);
2407
+ new S((e, s, i, a) => {
2408
+ s(e, i, a);
2409
+ const r = x(e);
2177
2410
  this.declarations.forEach(
2178
- (c) => Lt(c, o).forEach((u) => {
2179
- this.registrations.has(u) && this.execute(u, () => null, u.value, this.comparisonState(u).oldValue);
2411
+ (o) => Tt(o, r).forEach((l) => {
2412
+ this.registrations.has(l) && this.execute(l, () => null, l.value, this.comparisonState(l).oldValue);
2180
2413
  })
2181
2414
  );
2182
2415
  })
@@ -2189,196 +2422,244 @@ class ke extends v {
2189
2422
  return this.bindingState(t);
2190
2423
  }
2191
2424
  newBindingState() {
2192
- return x(p({}, super.newBindingState()), { oldValue: void 0 });
2425
+ return { ...super.newBindingState(), oldValue: void 0 };
2193
2426
  }
2194
2427
  unregisterFrom(t) {
2195
- this.registrations.delete(t);
2196
- }
2197
- }
2198
- class Re extends v {
2199
- constructor(e, t) {
2200
- const s = t || E("Must be one of [**{allowedAsText}**]");
2201
- let i = e.join(", ");
2202
- i.length > 60 && (i = Zt(i, {
2203
- length: 40,
2204
- separator: ", ",
2205
- omission: `... (${e.length} items total)`
2206
- }));
2207
- const r = (a, o, c) => e.includes(b(a)) ? null : [
2208
- new V(
2209
- this.replacePlaceholders(s, { newValue: a, oldValue: o, field: c, allowedValues: e, allowedAsText: i })
2210
- )
2211
- ];
2428
+ super.unregisterFrom(t), this.registrations.delete(t);
2429
+ }
2430
+ }
2431
+ class Se extends g {
2432
+ constructor(t, e) {
2433
+ const s = e || m("Must be one of [**{allowedAsText}**]"), i = () => {
2434
+ const o = h(t);
2435
+ return typeof o == "function" ? o() : o;
2436
+ }, a = (o) => {
2437
+ const l = o.join(", ");
2438
+ return l.length <= 60 ? l : Mt(l, { length: 40, separator: ", ", omission: `... (${o.length} items total)` });
2439
+ }, r = (o, l, w) => {
2440
+ const b = i();
2441
+ return b.includes(h(o)) ? null : [
2442
+ new f(
2443
+ this.replacePlaceholders(s, {
2444
+ newValue: o,
2445
+ oldValue: l,
2446
+ field: w,
2447
+ allowedValues: b,
2448
+ allowedAsText: a(b)
2449
+ }),
2450
+ "",
2451
+ "in-allowed-values"
2452
+ )
2453
+ ];
2454
+ };
2212
2455
  super(r);
2213
2456
  }
2214
2457
  }
2215
- function De(n) {
2216
- return n == null ? 0 : Tt(n) || P(n) ? n.length : Ot(n) && Object.getPrototypeOf(n) === Object.prototype ? Object.keys(n).length : String(n).length;
2458
+ function Ie(n) {
2459
+ return n == null ? 0 : vt(n) || C(n) ? n.length : bt(n) && Object.getPrototypeOf(n) === Object.prototype ? Object.keys(n).length : String(n).length;
2217
2460
  }
2218
- class Le extends v {
2219
- constructor(e) {
2220
- const t = e || E("Please enter a value"), s = (i, r, a) => De(b(i)) === 0 ? [new V(this.replacePlaceholders(t, { newValue: i, oldValue: r, field: a }))] : null;
2221
- super(s);
2461
+ function mt(n) {
2462
+ return typeof n == "object" && n !== null && !wt(n) && !(n instanceof String) && !("componentName" in n);
2463
+ }
2464
+ class Ae extends g {
2465
+ constructor(t, e) {
2466
+ const s = mt(t) ? void 0 : t, i = (mt(t) ? t : e)?.trim ?? !0, a = s || m("Please enter a value"), r = (o, l, w) => {
2467
+ const b = h(o);
2468
+ return Ie(i && C(b) ? b.trim() : b) === 0 ? [
2469
+ new f(
2470
+ this.replacePlaceholders(a, { newValue: o, oldValue: l, field: w }),
2471
+ "",
2472
+ "required"
2473
+ )
2474
+ ] : null;
2475
+ };
2476
+ super(r);
2222
2477
  }
2223
2478
  }
2224
- class Be extends v {
2225
- constructor(e, t) {
2226
- const s = t || E("Value must be larger or equal to **{minValue}**"), i = (r, a, o) => r < e || r === void 0 ? [
2227
- new V(this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, minValue: e }))
2479
+ class Te extends g {
2480
+ constructor(t, e) {
2481
+ const s = e || m("Value must be larger or equal to **{minValue}**"), i = (a, r, o) => a < t || a === void 0 ? [
2482
+ new f(
2483
+ this.replacePlaceholders(s, { newValue: a, oldValue: r, field: o, minValue: t }),
2484
+ "",
2485
+ "min"
2486
+ )
2228
2487
  ] : null;
2229
2488
  super(i);
2230
2489
  }
2231
2490
  }
2232
- class Ue extends v {
2233
- constructor(e, t) {
2234
- const s = t || E("Value must be less than or equal to **{maxValue}**"), i = (r, a, o) => r > e || r === void 0 ? [
2235
- new V(this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, maxValue: e }))
2491
+ class _e extends g {
2492
+ constructor(t, e) {
2493
+ const s = e || m("Value must be less than or equal to **{maxValue}**"), i = (a, r, o) => a > t || a === void 0 ? [
2494
+ new f(
2495
+ this.replacePlaceholders(s, { newValue: a, oldValue: r, field: o, maxValue: t }),
2496
+ "",
2497
+ "max"
2498
+ )
2236
2499
  ] : null;
2237
2500
  super(i);
2238
2501
  }
2239
2502
  }
2240
- class Me extends v {
2241
- constructor(e, t, s) {
2242
- const i = s || E("Value must be between **{minValue}** and **{maxValue}**"), r = (a, o, c) => a < e || a > t || a === void 0 ? [
2243
- new V(
2244
- this.replacePlaceholders(i, { newValue: a, oldValue: o, field: c, minValue: e, maxValue: t })
2503
+ class Oe extends g {
2504
+ constructor(t, e, s) {
2505
+ const i = s || m("Value must be between **{minValue}** and **{maxValue}**"), a = (r, o, l) => r < t || r > e || r === void 0 ? [
2506
+ new f(
2507
+ this.replacePlaceholders(i, { newValue: r, oldValue: o, field: l, minValue: t, maxValue: e }),
2508
+ "",
2509
+ "range"
2245
2510
  )
2246
2511
  ] : null;
2247
- super(r);
2512
+ super(a);
2248
2513
  }
2249
2514
  }
2250
- function ht(n) {
2251
- return n == null ? 0 : Tt(n) || P(n) ? n.length : Ot(n) && Object.getPrototypeOf(n) === Object.prototype ? Object.keys(n).length : String(n).length;
2515
+ function tt(n) {
2516
+ return n == null ? 0 : vt(n) || C(n) ? n.length : bt(n) && Object.getPrototypeOf(n) === Object.prototype ? Object.keys(n).length : String(n).length;
2252
2517
  }
2253
- class We extends v {
2254
- constructor(e, t) {
2255
- const s = t || E("Length must be larger or equal to **{minLength}**"), i = (r, a, o) => ht(r) < e ? [
2256
- new V(this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, minLength: e }))
2518
+ class Fe extends g {
2519
+ constructor(t, e) {
2520
+ const s = e || m("Length must be larger or equal to **{minLength}**"), i = (a, r, o) => tt(a) < t ? [
2521
+ new f(
2522
+ this.replacePlaceholders(s, { newValue: a, oldValue: r, field: o, minLength: t }),
2523
+ "",
2524
+ "min-length"
2525
+ )
2257
2526
  ] : null;
2258
2527
  super(i);
2259
2528
  }
2260
2529
  }
2261
- class $e extends v {
2262
- constructor(e, t) {
2263
- const s = t || E("Length must be less than or equal to **{maxLength}**"), i = (r, a, o) => ht(r) > e ? [
2264
- new V(this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, maxLength: e }))
2530
+ class Re extends g {
2531
+ constructor(t, e) {
2532
+ const s = e || m("Length must be less than or equal to **{maxLength}**"), i = (a, r, o) => tt(a) > t ? [
2533
+ new f(
2534
+ this.replacePlaceholders(s, { newValue: a, oldValue: r, field: o, maxLength: t }),
2535
+ "",
2536
+ "max-length"
2537
+ )
2265
2538
  ] : null;
2266
2539
  super(i);
2267
2540
  }
2268
2541
  }
2269
- class qe extends v {
2270
- constructor(e, t, s) {
2271
- const i = s || E("Length must be between **{minLength}** and **{maxLength}**"), r = (a, o, c) => {
2272
- const u = ht(a);
2273
- return u < e || u > t ? [
2274
- new V(
2275
- this.replacePlaceholders(i, { newValue: a, oldValue: o, field: c, minLength: e, maxLength: t })
2542
+ class Pe extends g {
2543
+ constructor(t, e, s) {
2544
+ const i = s || m("Length must be between **{minLength}** and **{maxLength}**"), a = (r, o, l) => {
2545
+ const w = tt(r);
2546
+ return w < t || w > e ? [
2547
+ new f(
2548
+ this.replacePlaceholders(i, { newValue: r, oldValue: o, field: l, minLength: t, maxLength: e }),
2549
+ "",
2550
+ "range-length"
2276
2551
  )
2277
2552
  ] : null;
2278
2553
  };
2279
- super(r);
2554
+ super(a);
2280
2555
  }
2281
2556
  }
2282
- class ze extends v {
2283
- constructor(e, t) {
2284
- const s = t || E('Value must match pattern "**{pattern}**"'), i = (r, a, o) => e.test(String(b(r))) ? null : [
2285
- new V(this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, pattern: e }))
2557
+ class je extends g {
2558
+ constructor(t, e) {
2559
+ const s = e || m('Value must match pattern "**{pattern}**"'), i = (a, r, o) => t.test(String(h(a))) ? null : [
2560
+ new f(
2561
+ this.replacePlaceholders(s, { newValue: a, oldValue: r, field: o, pattern: t }),
2562
+ "",
2563
+ "pattern"
2564
+ )
2286
2565
  ];
2287
2566
  super(i);
2288
2567
  }
2289
2568
  }
2290
- const He = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2569
+ const Ne = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2291
2570
  __proto__: null,
2292
- CompareTo: ke,
2293
- InAllowedValues: Re,
2294
- LengthInRange: qe,
2295
- MaxLength: $e,
2296
- MaxValue: Ue,
2297
- MinLength: We,
2298
- MinValue: Be,
2299
- Pattern: ze,
2300
- Required: Le,
2301
- Validator: v,
2302
- ValueInRange: Me
2303
- }, Symbol.toStringTag, { value: "Module" })), Je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2571
+ CompareTo: xe,
2572
+ InAllowedValues: Se,
2573
+ LengthInRange: Pe,
2574
+ MaxLength: Re,
2575
+ MaxValue: _e,
2576
+ MinLength: Fe,
2577
+ MinValue: Te,
2578
+ Pattern: je,
2579
+ Required: Ae,
2580
+ Validator: g,
2581
+ ValueInRange: Oe
2582
+ }, Symbol.toStringTag, { value: "Module" })), Le = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2304
2583
  __proto__: null,
2305
- AbortEventHandlingException: rt,
2306
- Action: Fe,
2307
- ActionsMap: M,
2308
- ConditionalEnabledAction: ve,
2309
- ConditionalStatementAction: Q,
2310
- ConditionalValueAction: Ve,
2311
- ConditionalVisibilityAction: be,
2312
- DisplayMode: N,
2313
- EmptyField: Pe,
2314
- EnabledChangedAction: Ut,
2315
- EnabledChangingAction: Bt,
2316
- ExecuteAction: qt,
2317
- Field: X,
2318
- FieldActionBase: y,
2319
- FieldBase: A,
2320
- Group: w,
2321
- List: D,
2322
- ListItemAddedAction: at,
2323
- ListItemRemovedAction: zt,
2324
- MdString: U,
2325
- MessagesWidget: Ne,
2326
- Operator: m,
2327
- RenderableValue: he,
2328
- Statement: I,
2329
- ValidChangedAction: Mt,
2330
- ValidationError: ct,
2331
- ValidationErrorRenderContent: V,
2332
- ValidationErrorText: ue,
2333
- Validator: v,
2334
- Validators: He,
2335
- ValueChangedAction: O,
2336
- VisibilityChangedAction: $t,
2337
- VisibilityChangingAction: Wt,
2338
- buildErrorMessage: E,
2339
- isCallableFunction: H,
2340
- isSimpleComponentDef: lt,
2341
- transaction: ot
2584
+ AbortEventHandlingException: Vt,
2585
+ Action: ye,
2586
+ ActionsMap: D,
2587
+ ConditionalEnabledAction: re,
2588
+ ConditionalStatementAction: L,
2589
+ ConditionalValueAction: ae,
2590
+ ConditionalVisibilityAction: ne,
2591
+ DisplayMode: _,
2592
+ EmptyField: Ve,
2593
+ EnabledChangedAction: Ot,
2594
+ EnabledChangingAction: _t,
2595
+ ExecuteAction: jt,
2596
+ Field: M,
2597
+ FieldActionBase: p,
2598
+ FieldBase: V,
2599
+ Group: d,
2600
+ List: A,
2601
+ ListItemAddedAction: K,
2602
+ ListItemRemovedAction: Nt,
2603
+ MdString: P,
2604
+ MessagesWidget: Ce,
2605
+ Operator: c,
2606
+ RenderableValue: Zt,
2607
+ Statement: v,
2608
+ ValidChangedAction: Ft,
2609
+ ValidationError: Z,
2610
+ ValidationErrorRenderContent: f,
2611
+ ValidationErrorText: Jt,
2612
+ Validator: g,
2613
+ Validators: Ne,
2614
+ ValueChangedAction: S,
2615
+ VisibilityChangedAction: Pt,
2616
+ VisibilityChangingAction: Rt,
2617
+ buildErrorMessage: m,
2618
+ isCallableFunction: B,
2619
+ isSimpleComponentDef: J,
2620
+ transaction: Y
2342
2621
  }, Symbol.toStringTag, { value: "Module" }));
2343
2622
  export {
2344
- rt as AbortEventHandlingException,
2345
- Fe as Action,
2346
- M as ActionsMap,
2347
- ve as ConditionalEnabledAction,
2348
- Q as ConditionalStatementAction,
2349
- Ve as ConditionalValueAction,
2350
- be as ConditionalVisibilityAction,
2351
- N as DisplayMode,
2352
- Pe as EmptyField,
2353
- Ut as EnabledChangedAction,
2354
- Bt as EnabledChangingAction,
2355
- qt as ExecuteAction,
2356
- X as Field,
2357
- y as FieldActionBase,
2358
- A as FieldBase,
2359
- w as Group,
2360
- D as List,
2361
- at as ListItemAddedAction,
2362
- zt as ListItemRemovedAction,
2363
- U as MdString,
2364
- Ne as MessagesWidget,
2365
- m as Operator,
2366
- he as RenderableValue,
2367
- I as Statement,
2368
- Mt as ValidChangedAction,
2369
- ct as ValidationError,
2370
- V as ValidationErrorRenderContent,
2371
- ue as ValidationErrorText,
2372
- v as Validator,
2373
- He as Validators,
2374
- O as ValueChangedAction,
2375
- $t as VisibilityChangedAction,
2376
- Wt as VisibilityChangingAction,
2377
- E as buildErrorMessage,
2378
- Je as default,
2379
- Ye as forms,
2380
- H as isCallableFunction,
2381
- lt as isSimpleComponentDef,
2382
- ot as transaction
2623
+ Vt as AbortEventHandlingException,
2624
+ ye as Action,
2625
+ D as ActionsMap,
2626
+ re as ConditionalEnabledAction,
2627
+ L as ConditionalStatementAction,
2628
+ ae as ConditionalValueAction,
2629
+ ne as ConditionalVisibilityAction,
2630
+ _ as DisplayMode,
2631
+ Ve as EmptyField,
2632
+ Ot as EnabledChangedAction,
2633
+ _t as EnabledChangingAction,
2634
+ jt as ExecuteAction,
2635
+ M as Field,
2636
+ p as FieldActionBase,
2637
+ V as FieldBase,
2638
+ d as Group,
2639
+ A as List,
2640
+ K as ListItemAddedAction,
2641
+ Nt as ListItemRemovedAction,
2642
+ P as MdString,
2643
+ Ce as MessagesWidget,
2644
+ c as Operator,
2645
+ Zt as RenderableValue,
2646
+ v as Statement,
2647
+ Ft as ValidChangedAction,
2648
+ Z as ValidationError,
2649
+ f as ValidationErrorRenderContent,
2650
+ Jt as ValidationErrorText,
2651
+ g as Validator,
2652
+ Ne as Validators,
2653
+ S as ValueChangedAction,
2654
+ Pt as VisibilityChangedAction,
2655
+ Rt as VisibilityChangingAction,
2656
+ m as buildErrorMessage,
2657
+ Le as default,
2658
+ De as forms,
2659
+ Kt as getConfig,
2660
+ B as isCallableFunction,
2661
+ J as isSimpleComponentDef,
2662
+ Yt as setConfig,
2663
+ Y as transaction
2383
2664
  };
2384
2665
  //# sourceMappingURL=dynamicforms-vue-forms.js.map