@gridkitjs/forms-core 0.0.0-dev-20261206092422 → 0.0.0-dev-20261206150419

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -38,6 +38,171 @@ function booleanParser(words) {
38
38
  };
39
39
  }
40
40
 
41
+ // src/choice/multi.ts
42
+ function valueKeys(value) {
43
+ return value ?? [];
44
+ }
45
+ function toKeyList(keys) {
46
+ return keys.length === 0 ? null : keys;
47
+ }
48
+ function hasKey(value, key) {
49
+ return valueKeys(value).some((held) => Object.is(held, key));
50
+ }
51
+ function sameKeys(a, b) {
52
+ const left = valueKeys(a);
53
+ const right = valueKeys(b);
54
+ return left.length === right.length && left.every((key, index) => Object.is(key, right[index]));
55
+ }
56
+ function canAddKey(value, maxCount) {
57
+ return maxCount === null || valueKeys(value).length < maxCount;
58
+ }
59
+ function addKeys(value, keys, maxCount = null) {
60
+ const next2 = [...valueKeys(value)];
61
+ for (const key of keys) {
62
+ if (!canAddKey(next2, maxCount)) {
63
+ break;
64
+ }
65
+ if (!next2.some((held) => Object.is(held, key))) {
66
+ next2.push(key);
67
+ }
68
+ }
69
+ return next2.length === valueKeys(value).length ? value : next2;
70
+ }
71
+ function removeKeys(value, keys) {
72
+ const held = valueKeys(value);
73
+ const next2 = held.filter((key) => !keys.some((gone) => Object.is(gone, key)));
74
+ return next2.length === held.length ? value : toKeyList(next2);
75
+ }
76
+ function toggleKey(value, key, maxCount = null) {
77
+ return hasKey(value, key) ? removeKeys(value, [key]) : addKeys(value, [key], maxCount);
78
+ }
79
+ function rangeKeys(rows, from, to) {
80
+ const keys = [];
81
+ for (let index = Math.min(from, to); index <= Math.max(from, to); index++) {
82
+ const row = rows[index];
83
+ if (row?.kind === "option" && row.option.disabled !== true) {
84
+ keys.push(row.option.value);
85
+ }
86
+ }
87
+ return keys;
88
+ }
89
+ function enabledKeys(scope) {
90
+ return scope.filter((option) => option.disabled !== true).map((option) => option.value);
91
+ }
92
+ function scopeState(value, scope) {
93
+ const keys = enabledKeys(scope);
94
+ const chosen2 = keys.filter((key) => hasKey(value, key)).length;
95
+ if (chosen2 === 0) {
96
+ return "none";
97
+ }
98
+ return chosen2 === keys.length ? "all" : "some";
99
+ }
100
+ function canSelectAll(value, scope, maxCount) {
101
+ if (maxCount === null) {
102
+ return true;
103
+ }
104
+ const missing = enabledKeys(scope).filter((key) => !hasKey(value, key));
105
+ return valueKeys(value).length + missing.length <= maxCount;
106
+ }
107
+ function selectAll(value, scope, maxCount = null) {
108
+ const keys = enabledKeys(scope);
109
+ if (scopeState(value, scope) === "all") {
110
+ return removeKeys(value, keys);
111
+ }
112
+ return canSelectAll(value, scope, maxCount) ? addKeys(value, keys) : value;
113
+ }
114
+ function clearKeys(value, locked) {
115
+ return removeKeys(
116
+ value,
117
+ valueKeys(value).filter((key) => !locked(key))
118
+ );
119
+ }
120
+ function keyChanges(previous, next2) {
121
+ return {
122
+ added: valueKeys(next2).filter((key) => !hasKey(previous, key)),
123
+ removed: valueKeys(previous).filter((key) => !hasKey(next2, key))
124
+ };
125
+ }
126
+
127
+ // src/choice/options.ts
128
+ function sameKey(a, b) {
129
+ return Object.is(a, b);
130
+ }
131
+ function keyText(key) {
132
+ return String(key);
133
+ }
134
+ function standInOption(key) {
135
+ return { value: key, label: keyText(key) };
136
+ }
137
+ function findDuplicateKeys(options) {
138
+ const seen = /* @__PURE__ */ new Set();
139
+ const duplicates = /* @__PURE__ */ new Set();
140
+ for (const option of options) {
141
+ const text = keyText(option.value);
142
+ if (seen.has(text)) {
143
+ duplicates.add(text);
144
+ } else {
145
+ seen.add(text);
146
+ }
147
+ }
148
+ return [...duplicates];
149
+ }
150
+ function flattenOptions(options, actions = {}) {
151
+ const groups2 = /* @__PURE__ */ new Map();
152
+ for (const option of options) {
153
+ const group = option.group ?? null;
154
+ const members = groups2.get(group);
155
+ if (members === void 0) {
156
+ groups2.set(group, [option]);
157
+ } else {
158
+ members.push(option);
159
+ }
160
+ }
161
+ const rows = (actions.start ?? []).map(actionRow);
162
+ let position = 0;
163
+ for (const [group, members] of groups2) {
164
+ if (group !== null) {
165
+ rows.push({ kind: "header", label: group, size: members.length });
166
+ }
167
+ for (const option of members) {
168
+ rows.push({ kind: "option", option, group, position });
169
+ position += 1;
170
+ }
171
+ }
172
+ rows.push(...(actions.end ?? []).map(actionRow));
173
+ return rows;
174
+ }
175
+ function actionRow(action) {
176
+ return { kind: "action", action };
177
+ }
178
+
179
+ // src/choice/details.ts
180
+ function choiceDetails(value, previous, optionOf, query) {
181
+ const known = (key) => optionOf(key) ?? standInOption(key);
182
+ const { added, removed } = keyChanges(previous, value);
183
+ return {
184
+ options: valueKeys(value).map(known),
185
+ previousOptions: valueKeys(previous).map(known),
186
+ added: added.map(known),
187
+ removed: removed.map(known),
188
+ unknownKeys: valueKeys(value).filter((key) => optionOf(key) === null),
189
+ query
190
+ };
191
+ }
192
+ function singleChoiceDetails(value, previous, optionOf, query) {
193
+ const details = choiceDetails(
194
+ value === null ? null : [value],
195
+ previous === null ? null : [previous],
196
+ optionOf,
197
+ query
198
+ );
199
+ return {
200
+ ...details,
201
+ option: details.options[0] ?? null,
202
+ previousOption: details.previousOptions[0] ?? null
203
+ };
204
+ }
205
+
41
206
  // src/localeKey.ts
42
207
  function localeKey(locale) {
43
208
  if (locale === void 0) {
@@ -46,6 +211,1030 @@ function localeKey(locale) {
46
211
  return typeof locale === "string" || locale instanceof Intl.Locale ? String(locale) : locale.map(String).join(",");
47
212
  }
48
213
 
214
+ // src/choice/match.ts
215
+ var DEFAULT_MATCH_FIELDS = ["label", "keywords"];
216
+ var MARKS = /\p{Mn}/gu;
217
+ var FOLDED_MARK_BASE = /^[\p{Script=Latin}\p{Script=Greek}\p{Script=Cyrillic}\p{Script=Hebrew}\p{Script=Arabic}]/u;
218
+ var WHITESPACE = /\s+/u;
219
+ var segmenters = /* @__PURE__ */ new Map();
220
+ function segmenter(locale, granularity) {
221
+ const key = `${granularity}|${localeKey(locale)}`;
222
+ let found = segmenters.get(key);
223
+ if (found === void 0) {
224
+ found = new Intl.Segmenter(locale, { granularity });
225
+ segmenters.set(key, found);
226
+ }
227
+ return found;
228
+ }
229
+ var dotlessILocales = /* @__PURE__ */ new Map();
230
+ function keepsDotlessI(locale) {
231
+ const key = localeKey(locale);
232
+ let keeps = dotlessILocales.get(key);
233
+ if (keeps === void 0) {
234
+ const language = segmenter(locale, "grapheme").resolvedOptions().locale.split("-")[0];
235
+ keeps = language === "tr" || language === "az";
236
+ dotlessILocales.set(key, keeps);
237
+ }
238
+ return keeps;
239
+ }
240
+ var PLAIN_ASCII = /^[\x20-\x7e]*$/;
241
+ var SINGLE_UNIT_GRAPHEMES = /^[\x20-\x7e\xa0-\u02ff]*$/;
242
+ function graphemes(text, locale) {
243
+ return SINGLE_UNIT_GRAPHEMES.test(text) ? Array.from(text, (segment, index) => ({ segment, index })) : segmenter(locale, "grapheme").segment(text);
244
+ }
245
+ function lowerAscii(text, dotlessI) {
246
+ return (dotlessI ? text.replaceAll("I", "\u0131") : text).toLowerCase();
247
+ }
248
+ function foldGrapheme(grapheme, locale, dotlessI) {
249
+ if (PLAIN_ASCII.test(grapheme)) {
250
+ return lowerAscii(grapheme, dotlessI);
251
+ }
252
+ let folded = grapheme.normalize("NFC").toLocaleLowerCase(locale).normalize("NFKD");
253
+ if (FOLDED_MARK_BASE.test(folded)) {
254
+ folded = folded.replace(MARKS, "");
255
+ }
256
+ if (!dotlessI) {
257
+ folded = folded.replaceAll("\u0131", "i");
258
+ }
259
+ return folded.replaceAll("\u03C2", "\u03C3");
260
+ }
261
+ function foldText(text, locale) {
262
+ const folded = fold(text, locale);
263
+ if (folded.starts !== null) {
264
+ return folded;
265
+ }
266
+ const starts = Array.from({ length: text.length }, (_, unit) => unit);
267
+ return {
268
+ text: folded.text,
269
+ starts,
270
+ ends: starts.map((unit) => unit + 1)
271
+ };
272
+ }
273
+ function fold(text, locale) {
274
+ const dotlessI = keepsDotlessI(locale);
275
+ if (PLAIN_ASCII.test(text)) {
276
+ return { text: lowerAscii(text, dotlessI), starts: null, ends: null };
277
+ }
278
+ let folded = "";
279
+ const starts = [];
280
+ const ends = [];
281
+ for (const { segment, index } of graphemes(text, locale)) {
282
+ const part = foldGrapheme(segment, locale, dotlessI);
283
+ folded += part;
284
+ const end = index + segment.length;
285
+ for (let unit = 0; unit < part.length; unit++) {
286
+ starts.push(index);
287
+ ends.push(end);
288
+ }
289
+ }
290
+ return { text: folded, starts, ends };
291
+ }
292
+ function foldField(text, locale) {
293
+ return { original: text, folded: fold(text, locale), wordStarts: null };
294
+ }
295
+ function startOf(folded, unit) {
296
+ return folded.starts === null ? unit : folded.starts[unit] ?? 0;
297
+ }
298
+ function endOf(folded, unit) {
299
+ return folded.ends === null ? unit + 1 : folded.ends[unit] ?? 0;
300
+ }
301
+ function wordStartsOf(field, locale) {
302
+ if (field.wordStarts !== null) {
303
+ return field.wordStarts;
304
+ }
305
+ const { folded } = field;
306
+ const length = folded.text.length;
307
+ const found = [];
308
+ let unit = 0;
309
+ for (const { index, isWordLike } of segmenter(locale, "word").segment(
310
+ field.original
311
+ )) {
312
+ while (unit < length && startOf(folded, unit) < index) {
313
+ unit += 1;
314
+ }
315
+ if (isWordLike === true && unit < length) {
316
+ found.push(unit);
317
+ }
318
+ }
319
+ field.wordStarts = found;
320
+ return found;
321
+ }
322
+ function originalRange(folded, start, length) {
323
+ return [startOf(folded, start), endOf(folded, start + length - 1)];
324
+ }
325
+ function findIn(field, query, mode, locale) {
326
+ const { folded } = field;
327
+ let start;
328
+ switch (mode) {
329
+ case "contains":
330
+ start = folded.text.indexOf(query);
331
+ break;
332
+ case "startsWith":
333
+ start = folded.text.startsWith(query) ? 0 : -1;
334
+ break;
335
+ case "words":
336
+ start = wordStartsOf(field, locale).find(
337
+ (at) => folded.text.startsWith(query, at)
338
+ ) ?? -1;
339
+ break;
340
+ }
341
+ return start === -1 ? null : originalRange(folded, start, query.length);
342
+ }
343
+ function joinRanges(ranges) {
344
+ const sorted = [...ranges].sort((a, b) => a[0] - b[0] || a[1] - b[1]);
345
+ const joined = [];
346
+ for (const [start, end] of sorted) {
347
+ const last = joined.at(-1);
348
+ if (last !== void 0 && start <= last[1]) {
349
+ last[1] = Math.max(last[1], end);
350
+ } else {
351
+ joined.push([start, end]);
352
+ }
353
+ }
354
+ return joined;
355
+ }
356
+ function queryParts(query, mode, locale) {
357
+ const folded = foldText(query.trim(), locale).text;
358
+ if (folded === "") {
359
+ return [];
360
+ }
361
+ return mode === "words" ? folded.split(WHITESPACE).filter((word) => word !== "") : [folded];
362
+ }
363
+ function matchParts(field, parts, mode, locale) {
364
+ const ranges = [];
365
+ for (const part of parts) {
366
+ const range = findIn(field, part, mode, locale);
367
+ if (range === null) {
368
+ return null;
369
+ }
370
+ ranges.push(range);
371
+ }
372
+ return joinRanges(ranges);
373
+ }
374
+ function matchText(text, query, mode, locale) {
375
+ const parts = queryParts(query, mode, locale);
376
+ if (parts.length === 0) {
377
+ return [];
378
+ }
379
+ return matchParts(foldField(text, locale), parts, mode, locale);
380
+ }
381
+ function fieldTexts(option, field) {
382
+ switch (field) {
383
+ case "label":
384
+ return [option.label];
385
+ case "description":
386
+ return option.description === void 0 ? [] : [option.description];
387
+ case "keywords":
388
+ return option.keywords ?? [];
389
+ default: {
390
+ const text = option.columns?.[field];
391
+ return text === void 0 ? [] : [text];
392
+ }
393
+ }
394
+ }
395
+ function foldOption(option, fields, locale) {
396
+ return fields.map((field) => ({
397
+ field,
398
+ texts: fieldTexts(option, field).map((text) => foldField(text, locale))
399
+ }));
400
+ }
401
+ function rangesFor(field, ranges) {
402
+ return field === "keywords" ? [] : ranges;
403
+ }
404
+ function matchFolded(option, parts, mode, locale) {
405
+ if (parts.length === 0) {
406
+ return { fields: {} };
407
+ }
408
+ if (mode !== "words") {
409
+ const fields2 = {};
410
+ for (const { field, texts } of option) {
411
+ for (const text of texts) {
412
+ const ranges = matchParts(text, parts, mode, locale);
413
+ if (ranges !== null) {
414
+ fields2[field] = rangesFor(field, ranges);
415
+ break;
416
+ }
417
+ }
418
+ }
419
+ return Object.keys(fields2).length === 0 ? null : { fields: fields2 };
420
+ }
421
+ const found = /* @__PURE__ */ new Map();
422
+ for (const part of parts) {
423
+ let matched = false;
424
+ for (const { field, texts } of option) {
425
+ for (const text of texts) {
426
+ const range = findIn(text, part, mode, locale);
427
+ if (range !== null) {
428
+ const ranges = found.get(field) ?? [];
429
+ ranges.push(range);
430
+ found.set(field, ranges);
431
+ matched = true;
432
+ }
433
+ }
434
+ }
435
+ if (!matched) {
436
+ return null;
437
+ }
438
+ }
439
+ const fields = {};
440
+ for (const [field, ranges] of found) {
441
+ fields[field] = rangesFor(field, joinRanges(ranges));
442
+ }
443
+ return { fields };
444
+ }
445
+ function matchOption(option, query, context) {
446
+ const { mode, locale, fields } = context;
447
+ return matchFolded(
448
+ foldOption(option, fields, locale),
449
+ queryParts(query, mode, locale),
450
+ mode,
451
+ locale
452
+ );
453
+ }
454
+ function createOptionIndex(options, fields, locale) {
455
+ const folded = /* @__PURE__ */ new Map();
456
+ const indexOf = /* @__PURE__ */ new Map();
457
+ options.forEach((option, index) => {
458
+ if (!indexOf.has(option)) {
459
+ indexOf.set(option, index);
460
+ }
461
+ });
462
+ const foldedAt = (index, option) => {
463
+ let found = folded.get(index);
464
+ if (found === void 0) {
465
+ found = foldOption(option, fields, locale);
466
+ folded.set(index, found);
467
+ }
468
+ return found;
469
+ };
470
+ const matchAt = (index, query, mode) => {
471
+ const option = options[index];
472
+ return option === void 0 ? null : matchFolded(
473
+ foldedAt(index, option),
474
+ queryParts(query, mode, locale),
475
+ mode,
476
+ locale
477
+ );
478
+ };
479
+ const search = (query, mode, matcher) => {
480
+ const parts = queryParts(query, mode, locale);
481
+ const defaultMatch = (option, asked) => {
482
+ const index = indexOf.get(option);
483
+ if (index === void 0) {
484
+ return matchOption(option, asked, { mode, locale, fields });
485
+ }
486
+ return asked === query ? matchFolded(foldedAt(index, option), parts, mode, locale) : matchAt(index, asked, mode);
487
+ };
488
+ const context = { mode, locale, fields, defaultMatch };
489
+ const hits = [];
490
+ options.forEach((option, index) => {
491
+ const match = matcher === void 0 ? matchFolded(foldedAt(index, option), parts, mode, locale) : matcherResult(matcher(option, query, context));
492
+ if (match !== null) {
493
+ hits.push({ option, index, match });
494
+ }
495
+ });
496
+ return hits;
497
+ };
498
+ return { options, matchAt, search };
499
+ }
500
+ function matcherResult(result) {
501
+ if (result === true) {
502
+ return { fields: {} };
503
+ }
504
+ return result === false ? null : result;
505
+ }
506
+
507
+ // src/typeahead.ts
508
+ function typeaheadIndex(labels, from, query) {
509
+ const typed = query.toLowerCase();
510
+ const firstCodePoint = typed.codePointAt(0);
511
+ if (firstCodePoint === void 0) {
512
+ return -1;
513
+ }
514
+ const first = String.fromCodePoint(firstCodePoint);
515
+ const repeated = typed.replaceAll(first, "") === "";
516
+ const prefix = repeated ? first : typed;
517
+ const start = repeated ? from + 1 : Math.max(from, 0);
518
+ for (let offset2 = 0; offset2 < labels.length; offset2++) {
519
+ const index = (start + offset2) % labels.length;
520
+ if (labels[index]?.toLowerCase().startsWith(prefix) === true) {
521
+ return index;
522
+ }
523
+ }
524
+ return -1;
525
+ }
526
+
527
+ // src/choice/moveActive.ts
528
+ function isLandingRow(row, disabledOptions) {
529
+ return row.kind !== "header" && (!row.disabled || disabledOptions === "focus");
530
+ }
531
+ function findLanding(rows, start, step2, stop, disabledOptions) {
532
+ for (let index = start; index !== stop; index += step2) {
533
+ const row = rows[index];
534
+ if (row !== void 0 && isLandingRow(row, disabledOptions)) {
535
+ return index;
536
+ }
537
+ }
538
+ return null;
539
+ }
540
+ function moveActive(rows, from, move, disabledOptions = "skip") {
541
+ const count = rows.length;
542
+ const first = findLanding(rows, 0, 1, count, disabledOptions);
543
+ if (first === null) {
544
+ return null;
545
+ }
546
+ const last = findLanding(rows, count - 1, -1, -1, disabledOptions) ?? first;
547
+ if (from === null || from < 0 || from >= count) {
548
+ return move.kind === "previous" || move.kind === "last" ? last : first;
549
+ }
550
+ switch (move.kind) {
551
+ case "first":
552
+ return first;
553
+ case "last":
554
+ return last;
555
+ case "next":
556
+ return findLanding(rows, from + 1, 1, count, disabledOptions) ?? from;
557
+ case "previous":
558
+ return findLanding(rows, from - 1, -1, -1, disabledOptions) ?? from;
559
+ case "pageDown": {
560
+ const target = Math.min(from + Math.max(move.rows, 1), count - 1);
561
+ return findLanding(rows, target, 1, count, disabledOptions) ?? findLanding(rows, target - 1, -1, from, disabledOptions) ?? from;
562
+ }
563
+ case "pageUp": {
564
+ const target = Math.max(from - Math.max(move.rows, 1), 0);
565
+ return findLanding(rows, target, -1, -1, disabledOptions) ?? findLanding(rows, target + 1, 1, from, disabledOptions) ?? from;
566
+ }
567
+ }
568
+ }
569
+ function typeaheadRow(rows, from, buffer, locale, disabledOptions = "skip") {
570
+ const labels = rows.map(
571
+ (row) => isLandingRow(row, disabledOptions) ? row.typeahead : ""
572
+ );
573
+ const index = typeaheadIndex(
574
+ labels,
575
+ from ?? -1,
576
+ foldText(buffer, locale).text
577
+ );
578
+ return index === -1 ? null : index;
579
+ }
580
+
581
+ // src/choice/source.ts
582
+ var DEFAULT_SOURCE_DEBOUNCE = 250;
583
+ var DEFAULT_SOURCE_PAGE_SIZE = 50;
584
+ function toOptionPage(answer) {
585
+ return "options" in answer ? answer : { options: answer };
586
+ }
587
+ function canonical(value) {
588
+ switch (typeof value) {
589
+ case "string":
590
+ return JSON.stringify(value);
591
+ case "number":
592
+ case "boolean":
593
+ case "undefined":
594
+ return String(value);
595
+ case "bigint":
596
+ return `${String(value)}n`;
597
+ case "symbol":
598
+ case "function":
599
+ return `<${typeof value}>`;
600
+ case "object":
601
+ if (value === null) {
602
+ return "null";
603
+ }
604
+ if (value instanceof Date) {
605
+ return `Date(${String(value.getTime())})`;
606
+ }
607
+ if (Array.isArray(value)) {
608
+ return `[${value.map(canonical).join(",")}]`;
609
+ }
610
+ return `{${Object.entries(value).filter(([, member]) => member !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, member]) => `${JSON.stringify(key)}:${canonical(member)}`).join(",")}}`;
611
+ }
612
+ }
613
+ function filtersKey(filters) {
614
+ return canonical(filters);
615
+ }
616
+ function sameFilters(a, b) {
617
+ return filtersKey(a) === filtersKey(b);
618
+ }
619
+ function appendPage(shown, page) {
620
+ return {
621
+ options: shown === null ? page.options : [...shown.options, ...page.options],
622
+ next: page.next ?? null,
623
+ total: page.total ?? shown?.total ?? null
624
+ };
625
+ }
626
+ var SOURCE_IDLE = { kind: "idle" };
627
+ function shownOf(state) {
628
+ switch (state.kind) {
629
+ case "idle":
630
+ return null;
631
+ case "loaded":
632
+ return state.result;
633
+ case "waiting":
634
+ case "loading":
635
+ case "failed":
636
+ return state.shown;
637
+ }
638
+ }
639
+ function sourceReducer(state, action) {
640
+ switch (action.type) {
641
+ case "wait":
642
+ return { kind: "waiting", query: action.query, shown: shownOf(state) };
643
+ case "start":
644
+ return {
645
+ kind: "loading",
646
+ query: action.query,
647
+ request: action.request,
648
+ shown: shownOf(state),
649
+ more: action.more
650
+ };
651
+ case "page":
652
+ if (state.kind !== "loading" || state.request !== action.request) {
653
+ return state;
654
+ }
655
+ return {
656
+ kind: "loaded",
657
+ query: state.query,
658
+ result: appendPage(state.more ? state.shown : null, action.page)
659
+ };
660
+ case "fail":
661
+ if (state.kind !== "loading" || state.request !== action.request) {
662
+ return state;
663
+ }
664
+ return {
665
+ kind: "failed",
666
+ query: state.query,
667
+ request: state.request,
668
+ error: action.error,
669
+ shown: state.shown,
670
+ more: state.more
671
+ };
672
+ case "show":
673
+ return { kind: "loaded", query: action.query, result: action.result };
674
+ case "reset":
675
+ return state.kind === "idle" ? state : SOURCE_IDLE;
676
+ }
677
+ }
678
+
679
+ // src/choice/optionCache.ts
680
+ function createOptionCache(options = {}) {
681
+ const maxQueries = options.maxQueries ?? 50;
682
+ const maxAge = options.maxAge ?? 3e5;
683
+ const now = options.now ?? Date.now;
684
+ const queries = /* @__PURE__ */ new Map();
685
+ const byKey = /* @__PURE__ */ new Map();
686
+ const resolving = /* @__PURE__ */ new Set();
687
+ const missing = /* @__PURE__ */ new Set();
688
+ const pending = /* @__PURE__ */ new Map();
689
+ const listeners = /* @__PURE__ */ new Set();
690
+ let version = 0;
691
+ const notify = () => {
692
+ version += 1;
693
+ for (const listener of [...listeners]) {
694
+ listener();
695
+ }
696
+ };
697
+ const queryKey = (key) => JSON.stringify([key.filters, key.text]);
698
+ const learn = (found) => {
699
+ let learned = false;
700
+ for (const option of found) {
701
+ learned ||= !byKey.has(option.value);
702
+ byKey.set(option.value, option);
703
+ }
704
+ return learned;
705
+ };
706
+ const flush = () => {
707
+ const batches = [...pending.values()];
708
+ pending.clear();
709
+ for (const { keys, request } of batches) {
710
+ const { signal } = request.abort();
711
+ Promise.resolve().then(() => request.resolve(keys, { filters: request.filters, signal })).then(
712
+ (found) => {
713
+ learn(found);
714
+ for (const key of keys) {
715
+ resolving.delete(key);
716
+ if (!byKey.has(key)) {
717
+ missing.add(key);
718
+ }
719
+ }
720
+ notify();
721
+ },
722
+ () => {
723
+ for (const key of keys) {
724
+ resolving.delete(key);
725
+ }
726
+ notify();
727
+ }
728
+ );
729
+ }
730
+ };
731
+ return {
732
+ readPage: (key) => {
733
+ const id = queryKey(key);
734
+ const entry2 = queries.get(id);
735
+ if (entry2 === void 0) {
736
+ return null;
737
+ }
738
+ if (now() - entry2.at > maxAge) {
739
+ queries.delete(id);
740
+ return null;
741
+ }
742
+ queries.delete(id);
743
+ queries.set(id, entry2);
744
+ return entry2.pages.get(JSON.stringify(key.cursor)) ?? null;
745
+ },
746
+ storePage: (key, page) => {
747
+ const id = queryKey(key);
748
+ const existing = queries.get(id);
749
+ const entry2 = key.cursor === null || existing === void 0 ? { at: now(), pages: /* @__PURE__ */ new Map() } : existing;
750
+ entry2.pages.set(JSON.stringify(key.cursor), page);
751
+ queries.delete(id);
752
+ queries.set(id, entry2);
753
+ for (const oldest of queries.keys()) {
754
+ if (queries.size <= maxQueries) {
755
+ break;
756
+ }
757
+ queries.delete(oldest);
758
+ }
759
+ if (learn(page.options)) {
760
+ notify();
761
+ }
762
+ },
763
+ addOptions: (found) => {
764
+ learn(found);
765
+ },
766
+ lookup: (key) => {
767
+ const option = byKey.get(key);
768
+ if (option !== void 0) {
769
+ return { kind: "known", option };
770
+ }
771
+ if (resolving.has(key)) {
772
+ return { kind: "resolving" };
773
+ }
774
+ return missing.has(key) ? { kind: "missing" } : { kind: "unresolved" };
775
+ },
776
+ resolve: (keys, request) => {
777
+ const asked = [...new Set(keys)].filter(
778
+ (key) => !byKey.has(key) && !resolving.has(key) && !missing.has(key)
779
+ );
780
+ if (asked.length === 0) {
781
+ return;
782
+ }
783
+ const id = filtersKey(request.filters);
784
+ const batch = pending.get(id);
785
+ if (batch === void 0) {
786
+ if (pending.size === 0) {
787
+ void Promise.resolve().then(flush);
788
+ }
789
+ pending.set(id, {
790
+ keys: asked,
791
+ request
792
+ });
793
+ } else {
794
+ batch.keys.push(...asked.filter((key) => !batch.keys.includes(key)));
795
+ }
796
+ for (const key of asked) {
797
+ resolving.add(key);
798
+ }
799
+ },
800
+ invalidate: () => {
801
+ queries.clear();
802
+ missing.clear();
803
+ },
804
+ subscribe: (listener) => {
805
+ listeners.add(listener);
806
+ return () => {
807
+ listeners.delete(listener);
808
+ };
809
+ },
810
+ getVersion: () => version
811
+ };
812
+ }
813
+
814
+ // src/choice/sourceController.ts
815
+ function createOptionSourceController(initial) {
816
+ let options = initial;
817
+ const ownCache = createOptionCache();
818
+ let state = SOURCE_IDLE;
819
+ let lastRequest = 0;
820
+ let inFlight = null;
821
+ let cancelWait = null;
822
+ const listeners = /* @__PURE__ */ new Set();
823
+ let cacheSubscription = null;
824
+ const cache2 = () => options.cache ?? ownCache;
825
+ const emit = () => {
826
+ for (const listener of [...listeners]) {
827
+ listener();
828
+ }
829
+ };
830
+ const apply = (action) => {
831
+ state = sourceReducer(state, action);
832
+ };
833
+ const transition = (change) => {
834
+ const before = state;
835
+ change();
836
+ if (state !== before) {
837
+ emit();
838
+ }
839
+ };
840
+ const release = () => {
841
+ cancelWait?.();
842
+ cancelWait = null;
843
+ inFlight?.abort();
844
+ inFlight = null;
845
+ };
846
+ const isLocal = () => options.source.filtering === "local";
847
+ const tooShort = (text) => text.trim().length < (options.source.minQueryLength ?? 0);
848
+ const queryOf = (text) => ({
849
+ text,
850
+ filters: options.filters
851
+ });
852
+ const pageKey = (query, cursor) => ({
853
+ text: isLocal() ? "" : query.text,
854
+ filters: filtersKey(query.filters),
855
+ cursor
856
+ });
857
+ const matches = (option, text) => text.trim() === "" || options.match(option, text);
858
+ const shownResult = (query, page, more) => {
859
+ if (!isLocal()) {
860
+ return appendPage(more, page);
861
+ }
862
+ const kept = page.options.filter((option) => matches(option, query.text));
863
+ return { options: kept, next: null, total: kept.length };
864
+ };
865
+ const fetch = (query, cursor, more) => {
866
+ const key = pageKey(query, cursor);
867
+ const cached = cache2().readPage(key);
868
+ if (cached !== null) {
869
+ apply({ type: "show", query, result: shownResult(query, cached, more) });
870
+ return;
871
+ }
872
+ lastRequest += 1;
873
+ const request = lastRequest;
874
+ const { signal, abort } = options.abort();
875
+ inFlight = { request, abort };
876
+ apply({ type: "start", query, request, more: more !== null });
877
+ const { source } = options;
878
+ Promise.resolve().then(
879
+ () => source.search({
880
+ text: key.text,
881
+ filters: query.filters,
882
+ cursor,
883
+ pageSize: source.pageSize ?? DEFAULT_SOURCE_PAGE_SIZE,
884
+ signal
885
+ })
886
+ ).then(
887
+ (answer) => {
888
+ if (inFlight?.request !== request) {
889
+ return;
890
+ }
891
+ inFlight = null;
892
+ const page = toOptionPage(answer);
893
+ cache2().storePage(key, page);
894
+ transition(() => {
895
+ if (isLocal()) {
896
+ apply({
897
+ type: "show",
898
+ query,
899
+ result: shownResult(query, page, null)
900
+ });
901
+ } else {
902
+ apply({ type: "page", request, page });
903
+ }
904
+ });
905
+ },
906
+ (error) => {
907
+ if (inFlight?.request !== request) {
908
+ return;
909
+ }
910
+ inFlight = null;
911
+ transition(() => {
912
+ apply({ type: "fail", request, error });
913
+ });
914
+ options.onError?.(error, query);
915
+ }
916
+ );
917
+ };
918
+ const ask = (text) => {
919
+ release();
920
+ if (tooShort(text)) {
921
+ apply({ type: "reset" });
922
+ } else {
923
+ fetch(queryOf(text), null, null);
924
+ }
925
+ };
926
+ const subscribeCache = () => {
927
+ cacheSubscription = cache2().subscribe(emit);
928
+ };
929
+ return {
930
+ getState: () => state,
931
+ subscribe: (listener) => {
932
+ listeners.add(listener);
933
+ if (cacheSubscription === null) {
934
+ subscribeCache();
935
+ }
936
+ return () => {
937
+ listeners.delete(listener);
938
+ if (listeners.size === 0) {
939
+ cacheSubscription?.();
940
+ cacheSubscription = null;
941
+ }
942
+ };
943
+ },
944
+ setOptions: (next2) => {
945
+ const previous = options;
946
+ options = next2;
947
+ if ((previous.cache ?? ownCache) !== cache2() && cacheSubscription !== null) {
948
+ cacheSubscription();
949
+ subscribeCache();
950
+ }
951
+ if (sameFilters(previous.filters, next2.filters)) {
952
+ return;
953
+ }
954
+ const shown = state.kind === "idle" ? null : state.query.text;
955
+ release();
956
+ apply({ type: "reset" });
957
+ if (shown !== null) {
958
+ ask(shown);
959
+ }
960
+ },
961
+ query: (text) => {
962
+ transition(() => {
963
+ release();
964
+ const query = queryOf(text);
965
+ const delay = options.source.debounce ?? DEFAULT_SOURCE_DEBOUNCE;
966
+ if (tooShort(text) || isLocal() || delay <= 0 || cache2().readPage(pageKey(query, null)) !== null) {
967
+ ask(text);
968
+ return;
969
+ }
970
+ apply({ type: "wait", query });
971
+ cancelWait = options.schedule(() => {
972
+ cancelWait = null;
973
+ transition(() => {
974
+ fetch(query, null, null);
975
+ });
976
+ }, delay);
977
+ });
978
+ },
979
+ queryNow: (text) => {
980
+ transition(() => {
981
+ ask(text);
982
+ });
983
+ },
984
+ loadMore: () => {
985
+ if (state.kind !== "loaded" || state.result.next === null || isLocal()) {
986
+ return;
987
+ }
988
+ const { query, result } = state;
989
+ transition(() => {
990
+ fetch(query, result.next, result);
991
+ });
992
+ },
993
+ retry: () => {
994
+ if (state.kind !== "failed") {
995
+ return;
996
+ }
997
+ const { query, more, shown } = state;
998
+ transition(() => {
999
+ release();
1000
+ if (more && shown !== null && shown.next !== null) {
1001
+ fetch(query, shown.next, shown);
1002
+ } else {
1003
+ fetch(query, null, null);
1004
+ }
1005
+ });
1006
+ },
1007
+ invalidate: () => {
1008
+ cache2().invalidate();
1009
+ if (state.kind !== "idle") {
1010
+ const { text } = state.query;
1011
+ transition(() => {
1012
+ ask(text);
1013
+ });
1014
+ }
1015
+ },
1016
+ close: () => {
1017
+ transition(() => {
1018
+ release();
1019
+ apply({ type: "reset" });
1020
+ });
1021
+ },
1022
+ resolve: (keys) => {
1023
+ const { resolve } = options.source;
1024
+ if (resolve !== void 0) {
1025
+ cache2().resolve(keys, {
1026
+ resolve,
1027
+ filters: options.filters,
1028
+ abort: options.abort
1029
+ });
1030
+ }
1031
+ },
1032
+ lookup: (key) => cache2().lookup(key),
1033
+ getCache: cache2,
1034
+ destroy: () => {
1035
+ release();
1036
+ apply({ type: "reset" });
1037
+ }
1038
+ };
1039
+ }
1040
+
1041
+ // src/choice/tree.ts
1042
+ function createTreeIndex(nodes) {
1043
+ const byKey = /* @__PURE__ */ new Map();
1044
+ const keys = [];
1045
+ const cycles = [];
1046
+ const visit = (siblings, parent) => {
1047
+ const placed = [];
1048
+ for (const node of siblings) {
1049
+ const key = node.value;
1050
+ if (byKey.has(key)) {
1051
+ cycles.push(key);
1052
+ continue;
1053
+ }
1054
+ byKey.set(key, { parent, children: null, disabled: false });
1055
+ keys.push(key);
1056
+ placed.push(key);
1057
+ const children = node.children === void 0 ? null : visit(node.children, key);
1058
+ byKey.set(key, {
1059
+ parent,
1060
+ children: children?.length === 0 ? null : children,
1061
+ disabled: node.disabled === true
1062
+ });
1063
+ }
1064
+ return placed;
1065
+ };
1066
+ const roots = visit(nodes, null);
1067
+ return {
1068
+ roots,
1069
+ keys,
1070
+ has: (key) => byKey.has(key),
1071
+ parentOf: (key) => byKey.get(key)?.parent ?? null,
1072
+ childrenOf: (key) => byKey.get(key)?.children ?? null,
1073
+ isDisabled: (key) => byKey.get(key)?.disabled === true,
1074
+ cycles
1075
+ };
1076
+ }
1077
+ function enabledDescendants(tree, key) {
1078
+ const found = [];
1079
+ for (const child of tree.childrenOf(key) ?? []) {
1080
+ if (!tree.isDisabled(child)) {
1081
+ found.push(child, ...enabledDescendants(tree, child));
1082
+ }
1083
+ }
1084
+ return found;
1085
+ }
1086
+ function settleAncestors(tree, ticked, key) {
1087
+ for (let parent = tree.parentOf(key); parent !== null; parent = tree.parentOf(parent)) {
1088
+ if (tree.isDisabled(parent)) {
1089
+ continue;
1090
+ }
1091
+ const enabled = (tree.childrenOf(parent) ?? []).filter(
1092
+ (child) => !tree.isDisabled(child)
1093
+ );
1094
+ if (enabled.length > 0 && enabled.every((child) => ticked.has(child))) {
1095
+ ticked.add(parent);
1096
+ } else {
1097
+ ticked.delete(parent);
1098
+ }
1099
+ }
1100
+ }
1101
+ function tickNode(tree, ticked, key, tick, cascade) {
1102
+ if (tree.isDisabled(key)) {
1103
+ return ticked;
1104
+ }
1105
+ return setTick(tree, ticked, key, tick, cascade);
1106
+ }
1107
+ function setTick(tree, ticked, key, tick, cascade) {
1108
+ const next2 = new Set(ticked);
1109
+ const changed = cascade ? [key, ...enabledDescendants(tree, key)] : [key];
1110
+ for (const node of changed) {
1111
+ if (tick) {
1112
+ next2.add(node);
1113
+ } else {
1114
+ next2.delete(node);
1115
+ }
1116
+ }
1117
+ if (cascade) {
1118
+ settleAncestors(tree, next2, key);
1119
+ }
1120
+ return next2;
1121
+ }
1122
+ function tickState(tree, ticked, key) {
1123
+ const enabled = (tree.childrenOf(key) ?? []).filter(
1124
+ (child) => !tree.isDisabled(child)
1125
+ );
1126
+ if (enabled.length === 0) {
1127
+ return ticked.has(key) ? "ticked" : "unticked";
1128
+ }
1129
+ const states = new Set(
1130
+ enabled.map((child) => tickState(tree, ticked, child))
1131
+ );
1132
+ if (states.size === 1 && states.has("ticked")) {
1133
+ return "ticked";
1134
+ }
1135
+ return states.size === 1 && states.has("unticked") && !ticked.has(key) ? "unticked" : "mixed";
1136
+ }
1137
+ function inValue(tree, ticked, key, mode) {
1138
+ switch (mode) {
1139
+ case "all":
1140
+ return true;
1141
+ case "leaves":
1142
+ return tree.childrenOf(key) === null;
1143
+ case "parent": {
1144
+ const parent = tree.parentOf(key);
1145
+ return parent === null || !ticked.has(parent);
1146
+ }
1147
+ }
1148
+ }
1149
+ function treeValue(tree, ticked, mode, previous) {
1150
+ const shown = [...ticked].filter((key) => inValue(tree, ticked, key, mode));
1151
+ const kept = (previous ?? []).filter((key) => shown.includes(key));
1152
+ const value = [...kept, ...shown.filter((key) => !kept.includes(key))];
1153
+ return value.length === 0 ? null : value;
1154
+ }
1155
+ function tickedFromValue(tree, value, cascade = true) {
1156
+ let ticked = /* @__PURE__ */ new Set();
1157
+ for (const key of value ?? []) {
1158
+ ticked = setTick(tree, ticked, key, true, cascade);
1159
+ }
1160
+ return ticked;
1161
+ }
1162
+ function hasChildNodes(node) {
1163
+ return (node.children?.length ?? 0) > 0 || node.hasChildren === true;
1164
+ }
1165
+ function flattenTree(nodes, open) {
1166
+ const rows = [];
1167
+ const path = /* @__PURE__ */ new Set();
1168
+ const visit = (siblings, level, parent) => {
1169
+ const shown = siblings.filter((node) => !path.has(node.value));
1170
+ shown.forEach((node, index) => {
1171
+ const branch = hasChildNodes(node);
1172
+ const expanded = branch ? open.has(node.value) : null;
1173
+ rows.push({
1174
+ option: node,
1175
+ level,
1176
+ expanded,
1177
+ parent,
1178
+ size: shown.length,
1179
+ position: index + 1
1180
+ });
1181
+ if (expanded === true && node.children !== void 0) {
1182
+ path.add(node.value);
1183
+ visit(node.children, level + 1, rows.length - 1);
1184
+ path.delete(node.value);
1185
+ }
1186
+ });
1187
+ };
1188
+ visit(nodes, 1, null);
1189
+ return rows;
1190
+ }
1191
+ function searchTree(nodes, query, context) {
1192
+ const open = /* @__PURE__ */ new Set();
1193
+ const matches = /* @__PURE__ */ new Map();
1194
+ if (query.trim() === "") {
1195
+ return { nodes, open, matches };
1196
+ }
1197
+ const path = /* @__PURE__ */ new Set();
1198
+ const prune = (siblings) => {
1199
+ const kept = [];
1200
+ for (const node of siblings) {
1201
+ if (path.has(node.value)) {
1202
+ continue;
1203
+ }
1204
+ path.add(node.value);
1205
+ const match = matchOption(node, query, context);
1206
+ const children = prune(node.children ?? []);
1207
+ path.delete(node.value);
1208
+ if (match !== null) {
1209
+ matches.set(node.value, match);
1210
+ }
1211
+ if (children.length > 0) {
1212
+ open.add(node.value);
1213
+ }
1214
+ if (match !== null) {
1215
+ kept.push(node);
1216
+ } else if (children.length > 0) {
1217
+ kept.push({ ...node, children });
1218
+ }
1219
+ }
1220
+ return kept;
1221
+ };
1222
+ return { nodes: prune(nodes), open, matches };
1223
+ }
1224
+ var CHILDREN_UNLOADED = { kind: "unloaded" };
1225
+ function childrenLoadReducer(state, action) {
1226
+ switch (action.type) {
1227
+ case "start":
1228
+ return { kind: "loading", request: action.request };
1229
+ case "loaded":
1230
+ return state.kind === "loading" && state.request === action.request ? { kind: "loaded" } : state;
1231
+ case "fail":
1232
+ return state.kind === "loading" && state.request === action.request ? { kind: "failed", error: action.error } : state;
1233
+ case "reset":
1234
+ return CHILDREN_UNLOADED;
1235
+ }
1236
+ }
1237
+
49
1238
  // src/date/values.ts
50
1239
  var DAY_MS = 864e5;
51
1240
  var MIN_YEAR = 1;
@@ -3056,9 +4245,9 @@ function readPeriodText(text, options, layout, locale, messages) {
3056
4245
  };
3057
4246
  }
3058
4247
  }
3059
- const canonical = toPeriod(clean, granularity);
3060
- if (canonical !== null) {
3061
- return { kind: "period", period: canonical };
4248
+ const canonical2 = toPeriod(clean, granularity);
4249
+ if (canonical2 !== null) {
4250
+ return { kind: "period", period: canonical2 };
3062
4251
  }
3063
4252
  if (granularity === "year") {
3064
4253
  return /^\d{1,4}$/.test(clean) ? readingOf(granularity, clean, 1, today) : UNREADABLE;
@@ -3849,7 +5038,7 @@ function isTwelveHour(layout) {
3849
5038
  function hasSeconds(layout) {
3850
5039
  return layout.segments.some((segment) => segment.type === "second");
3851
5040
  }
3852
- function startOf(limits) {
5041
+ function startOf2(limits) {
3853
5042
  return timeParts(limits.min ?? "00:00");
3854
5043
  }
3855
5044
  function values(count, every = 1) {
@@ -3863,7 +5052,7 @@ function timeColumns(time, options) {
3863
5052
  const step2 = stepOf2(options.minuteStep);
3864
5053
  const twelve = isTwelveHour(layout);
3865
5054
  const limits = windowOf(options);
3866
- const current = time === null ? startOf(options) : timeParts(time);
5055
+ const current = time === null ? startOf2(options) : timeParts(time);
3867
5056
  const held = time === null ? null : current;
3868
5057
  const afternoon = current.hour >= 12 ? 12 : 0;
3869
5058
  const lastMinute = 60 - step2;
@@ -3944,7 +5133,7 @@ function clampTime(time, limits) {
3944
5133
  return time;
3945
5134
  }
3946
5135
  function setTimeColumn(time, type, value, options) {
3947
- const current = time === null ? startOf(options) : timeParts(time);
5136
+ const current = time === null ? startOf2(options) : timeParts(time);
3948
5137
  let { hour, minute, second } = current;
3949
5138
  switch (type) {
3950
5139
  case "hour":
@@ -4079,6 +5268,15 @@ function counterAnnouncement(count, max, messages) {
4079
5268
  function requiredRule() {
4080
5269
  return (value, { messages }) => value === null || typeof value === "string" && value.trim() === "" ? { text: messages.required, code: "required" } : null;
4081
5270
  }
5271
+ function requiredChoiceRule() {
5272
+ return (value, { messages }) => value === null ? { text: messages.requiredChoice, code: "required" } : null;
5273
+ }
5274
+ function maxCountRule(max) {
5275
+ return (value, { messages }) => value !== null && value.length > max ? { text: messages.tooManyChoices(max), code: "tooManyChoices" } : null;
5276
+ }
5277
+ function minCountRule(min) {
5278
+ return (value, { messages }) => value !== null && value.length < min ? { text: messages.tooFewChoices(min), code: "tooFewChoices" } : null;
5279
+ }
4082
5280
  function minLengthRule(min) {
4083
5281
  return (value, { messages }) => value !== null && countCharacters(value) < min ? { text: messages.tooShort(min), code: "tooShort" } : null;
4084
5282
  }
@@ -4785,7 +5983,10 @@ var COMMIT_SOURCES = {
4785
5983
  preset: "preset",
4786
5984
  clear: "clear",
4787
5985
  toggle: "toggle",
4788
- autofill: "autofill"
5986
+ autofill: "autofill",
5987
+ remove: "remove",
5988
+ drop: "drop",
5989
+ paste: "paste"
4789
5990
  };
4790
5991
  function formatterOf(options, purpose) {
4791
5992
  const format = options.format ?? options.defaultFormat;
@@ -6369,6 +7570,7 @@ function createDefaultFormsMessages(locale) {
6369
7570
  required: "Enter a value",
6370
7571
  requiredChecked: "Check this box to continue",
6371
7572
  requiredOn: "Turn this on to continue",
7573
+ requiredChoice: "Choose an option",
6372
7574
  tooShort: (min) => `Enter at least ${counted(n, min, characters)}`,
6373
7575
  tooLong: (max) => `Enter no more than ${counted(n, max, characters)}`,
6374
7576
  patternMismatch: "Enter a value in the expected format",
@@ -6453,6 +7655,27 @@ function createDefaultFormsMessages(locale) {
6453
7655
  optional: "optional",
6454
7656
  fieldHelp: "More information",
6455
7657
  searchPlaceholder: "Search",
7658
+ showOptions: "Show options",
7659
+ noOptions: "No options",
7660
+ resultCount: (count) => counted(n, count, ["result", "results"]),
7661
+ noMatches: (query) => `No matches for \u201C${query}\u201D`,
7662
+ selectedCount: (count) => `${n(count)} selected`,
7663
+ typeMore: (min) => `Type at least ${counted(n, min, characters)}`,
7664
+ optionsFailed: "Couldn't load the options.",
7665
+ retry: "Try again",
7666
+ moreChosen: (count) => `+${n(count)}`,
7667
+ moreChosenLabel: (count) => `and ${n(count)} more`,
7668
+ chosenList: "Chosen",
7669
+ removeChoice: (label) => `Remove ${label}`,
7670
+ choiceRemoved: (label) => `${label} removed`,
7671
+ selectAll: "Select all",
7672
+ selectAllLoaded: (count) => `Select all ${n(count)} loaded`,
7673
+ createOption: (text) => `Create \u201C${text}\u201D`,
7674
+ createFailed: (text) => `Couldn't create \u201C${text}\u201D`,
7675
+ optionMissing: (label) => `\u201C${label}\u201D is no longer available`,
7676
+ tooManyChoices: (max) => `Choose no more than ${n(max)}`,
7677
+ tooFewChoices: (min) => `Choose at least ${n(min)}`,
7678
+ maxChoicesReached: (max) => max === 1 ? "Up to 1 choice" : `Up to ${n(max)} choices`,
6456
7679
  severityLabel: (severity) => SEVERITY_LABELS[severity],
6457
7680
  severityCount: (severity, count) => counted(n, count, SEVERITY_NOUNS[severity]),
6458
7681
  messageSummaryTitle: (count) => count === 1 ? "There is 1 problem with this form" : `There are ${n(count)} problems with this form`
@@ -8052,26 +9275,6 @@ function summarizeMessages(fields, severities) {
8052
9275
  };
8053
9276
  }
8054
9277
 
8055
- // src/typeahead.ts
8056
- function typeaheadIndex(labels, from, query) {
8057
- const typed = query.toLowerCase();
8058
- const firstCodePoint = typed.codePointAt(0);
8059
- if (firstCodePoint === void 0) {
8060
- return -1;
8061
- }
8062
- const first = String.fromCodePoint(firstCodePoint);
8063
- const repeated = typed.replaceAll(first, "") === "";
8064
- const prefix = repeated ? first : typed;
8065
- const start = repeated ? from + 1 : Math.max(from, 0);
8066
- for (let offset2 = 0; offset2 < labels.length; offset2++) {
8067
- const index = (start + offset2) % labels.length;
8068
- if (labels[index]?.toLowerCase().startsWith(prefix) === true) {
8069
- return index;
8070
- }
8071
- }
8072
- return -1;
8073
- }
8074
-
8075
9278
  // src/virtualization.ts
8076
9279
  function visibleRange(heights, estimatedHeight, scrollTop, viewportHeight, overscan) {
8077
9280
  const rowCount = heights.length;
@@ -8116,14 +9319,21 @@ export {
8116
9319
  ALL_DAY,
8117
9320
  CALENDAR_FISCAL_YEAR,
8118
9321
  CHECKBOX_WORDS,
9322
+ CHILDREN_UNLOADED,
9323
+ DEFAULT_MATCH_FIELDS,
9324
+ DEFAULT_SOURCE_DEBOUNCE,
9325
+ DEFAULT_SOURCE_PAGE_SIZE,
8119
9326
  NO_TIME,
8120
9327
  POPUP_CLOSED,
9328
+ SOURCE_IDLE,
8121
9329
  SWITCH_WORDS,
8122
9330
  addDays,
8123
9331
  addDecimals,
9332
+ addKeys,
8124
9333
  addMonths,
8125
9334
  addPeriods,
8126
9335
  addYears,
9336
+ appendPage,
8127
9337
  applyMaskEdit,
8128
9338
  availableDateRule,
8129
9339
  booleanFormatter,
@@ -8133,11 +9343,16 @@ export {
8133
9343
  calendarReducer,
8134
9344
  calendarStart,
8135
9345
  calendarYears,
9346
+ canAddKey,
9347
+ canSelectAll,
8136
9348
  checkedRule,
9349
+ childrenLoadReducer,
9350
+ choiceDetails,
8137
9351
  clampCalendarDate,
8138
9352
  clampCalendarMonth,
8139
9353
  clampTime,
8140
9354
  cleanPastedNumber,
9355
+ clearKeys,
8141
9356
  commonDatePresets,
8142
9357
  compareCalendarMonths,
8143
9358
  compareDateTimes,
@@ -8154,6 +9369,10 @@ export {
8154
9369
  createDefaultFormsMessages,
8155
9370
  createFieldController,
8156
9371
  createFieldRegistry,
9372
+ createOptionCache,
9373
+ createOptionIndex,
9374
+ createOptionSourceController,
9375
+ createTreeIndex,
8157
9376
  dateDetails,
8158
9377
  dateFormatter,
8159
9378
  dateFromInstant,
@@ -8189,7 +9408,12 @@ export {
8189
9408
  fieldText,
8190
9409
  filterMaskEdit,
8191
9410
  filterNumberEdit,
9411
+ filtersKey,
9412
+ findDuplicateKeys,
8192
9413
  fixedFractionDigits,
9414
+ flattenOptions,
9415
+ flattenTree,
9416
+ foldText,
8193
9417
  formatCalendarMonth,
8194
9418
  formatCalendarYear,
8195
9419
  formatDate,
@@ -8216,6 +9440,7 @@ export {
8216
9440
  formatTimeSpan,
8217
9441
  formatWeekday,
8218
9442
  hasError,
9443
+ hasKey,
8219
9444
  ibanRule,
8220
9445
  idleSegments,
8221
9446
  inlineStep,
@@ -8232,6 +9457,7 @@ export {
8232
9457
  isCalendarMonthDisabled,
8233
9458
  isDecimalString,
8234
9459
  isInstant,
9460
+ isLandingRow,
8235
9461
  isLeapYear,
8236
9462
  isPeriod,
8237
9463
  isPlainDate,
@@ -8242,12 +9468,17 @@ export {
8242
9468
  isTimeZone,
8243
9469
  isValidMaskStart,
8244
9470
  joinSegments,
9471
+ keyChanges,
9472
+ keyText,
8245
9473
  luhnRule,
8246
9474
  maskDetails,
8247
9475
  maskFormatter,
8248
9476
  maskInputHints,
8249
9477
  maskParser,
8250
9478
  maskPresets,
9479
+ matchOption,
9480
+ matchText,
9481
+ maxCountRule,
8251
9482
  maxDateRule,
8252
9483
  maxDateTimeRule,
8253
9484
  maxDurationRule,
@@ -8257,6 +9488,7 @@ export {
8257
9488
  maxRule,
8258
9489
  maxSpanRule,
8259
9490
  maxTimeRule,
9491
+ minCountRule,
8260
9492
  minDateRule,
8261
9493
  minDateTimeRule,
8262
9494
  minDurationRule,
@@ -8270,6 +9502,7 @@ export {
8270
9502
  monthGrid,
8271
9503
  monthOfDate,
8272
9504
  mostSevere,
9505
+ moveActive,
8273
9506
  moveCalendarDate,
8274
9507
  nextCheckedValue,
8275
9508
  normalizeDecimal,
@@ -8311,6 +9544,7 @@ export {
8311
9544
  rangeEnds,
8312
9545
  rangeFlags,
8313
9546
  rangeIncludes,
9547
+ rangeKeys,
8314
9548
  rangePickPreview,
8315
9549
  rangePickReducer,
8316
9550
  rangeSpan,
@@ -8319,6 +9553,8 @@ export {
8319
9553
  readRangeEnds,
8320
9554
  readTimeText,
8321
9555
  relativePreset,
9556
+ removeKeys,
9557
+ requiredChoiceRule,
8322
9558
  requiredRule,
8323
9559
  resolveDateRange,
8324
9560
  resolveDateRule,
@@ -8327,23 +9563,32 @@ export {
8327
9563
  roundDecimal,
8328
9564
  runtimeTimeZone,
8329
9565
  sameDayIn,
9566
+ sameFilters,
9567
+ sameKey,
9568
+ sameKeys,
8330
9569
  sameRange,
8331
9570
  sameRule,
9571
+ scopeState,
9572
+ searchTree,
8332
9573
  segmentAria,
8333
9574
  segmentReducer,
8334
9575
  segmentRuns,
8335
9576
  segmentSpans,
8336
9577
  segmentValue,
8337
9578
  segmentsTime,
9579
+ selectAll,
8338
9580
  setTimeColumn,
8339
9581
  shiftDecimal,
8340
9582
  shownEnd,
8341
9583
  shownMessages,
9584
+ singleChoiceDetails,
8342
9585
  snapTime,
8343
9586
  sortFieldMessages,
9587
+ sourceReducer,
8344
9588
  spanOf,
8345
9589
  splitDateTime,
8346
9590
  splitSegments,
9591
+ standInOption,
8347
9592
  startOfDayIn,
8348
9593
  startOfMonth,
8349
9594
  startOfWeek,
@@ -8353,6 +9598,9 @@ export {
8353
9598
  subtractDecimals,
8354
9599
  summarizeMessages,
8355
9600
  textParser,
9601
+ tickNode,
9602
+ tickState,
9603
+ tickedFromValue,
8356
9604
  timeColumns,
8357
9605
  timeDetails,
8358
9606
  timeFormatter,
@@ -8361,13 +9609,19 @@ export {
8361
9609
  timeRangeKind,
8362
9610
  toFieldMessages,
8363
9611
  toInstant,
9612
+ toKeyList,
9613
+ toOptionPage,
8364
9614
  toPeriod,
8365
9615
  toPlainDate,
8366
9616
  toPlainDateTime,
8367
9617
  toPlainTime,
8368
9618
  todayIn,
9619
+ toggleKey,
9620
+ treeValue,
8369
9621
  typeaheadIndex,
9622
+ typeaheadRow,
8370
9623
  unreadable,
9624
+ valueKeys,
8371
9625
  visibleRange,
8372
9626
  wallClockOf,
8373
9627
  weekInfo,