praxis-kit 4.0.1 → 4.1.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,8 +1,16 @@
1
- // ../../lib/primitive/src/tag/resolve-tag.ts
2
- function makeResolveTag(defaultTag) {
3
- return function tag(as) {
4
- return as ?? defaultTag;
5
- };
1
+ // ../../lib/adapter-utils/src/runtime/define-component.ts
2
+ function defineContractComponent(options) {
3
+ return (factory) => factory(options);
4
+ }
5
+
6
+ // ../../lib/primitive/src/guards/foundational/is-defined.ts
7
+ function isUndefined(value) {
8
+ return value === void 0;
9
+ }
10
+
11
+ // ../../lib/primitive/src/guards/foundational/is-null.ts
12
+ function isNull(value) {
13
+ return value === null;
6
14
  }
7
15
 
8
16
  // ../../lib/primitive/src/utils/is-object.ts
@@ -17,195 +25,6 @@ function isNumber(value) {
17
25
  return typeof value === "number";
18
26
  }
19
27
 
20
- // ../../lib/primitive/src/utils/assert-never.ts
21
- function assertNever(value) {
22
- throw new Error(`Unexpected value: ${String(value)}`);
23
- }
24
-
25
- // ../../lib/primitive/src/utils/cn.ts
26
- import { clsx } from "clsx";
27
- function cn(...inputs) {
28
- return clsx(...inputs);
29
- }
30
-
31
- // ../../lib/primitive/src/utils/iterate.ts
32
- function find(iterable, callback) {
33
- for (const value of iterable) {
34
- const result = callback(value);
35
- if (result != null) {
36
- return result;
37
- }
38
- }
39
- return null;
40
- }
41
- function some(iterable, predicate) {
42
- for (const value of iterable) {
43
- if (predicate(value)) return true;
44
- }
45
- return false;
46
- }
47
- function every(iterable, predicate) {
48
- let index = 0;
49
- for (const value of iterable) {
50
- if (!predicate(value, index++)) {
51
- return false;
52
- }
53
- }
54
- return true;
55
- }
56
- function* filter(iterable, predicate) {
57
- let index = 0;
58
- for (const value of iterable) {
59
- if (predicate(value, index++)) {
60
- yield value;
61
- }
62
- }
63
- }
64
- function* map(iterable, callback) {
65
- let index = 0;
66
- for (const value of iterable) {
67
- yield callback(value, index++);
68
- }
69
- }
70
- function forEach(iterable, callback) {
71
- let index = 0;
72
- for (const value of iterable) {
73
- callback(value, index++);
74
- }
75
- }
76
- function reduce(iterable, initial, callback) {
77
- let accumulator = initial;
78
- let index = 0;
79
- for (const value of iterable) {
80
- accumulator = callback(accumulator, value, index++);
81
- }
82
- return accumulator;
83
- }
84
- function collect(iterable, callback) {
85
- const result = {};
86
- let index = 0;
87
- for (const value of iterable) {
88
- const entry = callback(value, index++);
89
- if (entry === null) {
90
- return null;
91
- }
92
- result[entry[0]] = entry[1];
93
- }
94
- return result;
95
- }
96
- function findLast(value, callback) {
97
- for (let index = value.length - 1; index >= 0; index--) {
98
- const result = callback(value[index], index);
99
- if (result != null) {
100
- return result;
101
- }
102
- }
103
- return null;
104
- }
105
- function* items(collection) {
106
- for (let i = 0; i < collection.length; i++) {
107
- const item = collection.item(i);
108
- if (item !== null) {
109
- yield item;
110
- }
111
- }
112
- }
113
- function nodeList(list) {
114
- return {
115
- *[Symbol.iterator]() {
116
- for (let i = 0; i < list.length; i++) {
117
- const node = list.item(i);
118
- if (node !== null) {
119
- yield node;
120
- }
121
- }
122
- }
123
- };
124
- }
125
- function mapEntries(m) {
126
- return m.entries();
127
- }
128
- function set(s) {
129
- return s.values();
130
- }
131
- function hasOwn(object, key) {
132
- return Object.hasOwn(object, key);
133
- }
134
- function* entries(object) {
135
- for (const key in object) {
136
- if (!hasOwn(object, key)) continue;
137
- yield [key, object[key]];
138
- }
139
- }
140
- function* keys(object) {
141
- for (const [key] of entries(object)) {
142
- yield key;
143
- }
144
- }
145
- function* values(object) {
146
- for (const [, value] of entries(object)) {
147
- yield value;
148
- }
149
- }
150
- function mapValues(object, callback) {
151
- const result = {};
152
- for (const [key, value] of entries(object)) {
153
- result[key] = callback(value, key);
154
- }
155
- return result;
156
- }
157
- function forEachEntry(object, callback) {
158
- for (const [key, value] of entries(object)) {
159
- callback(key, value);
160
- }
161
- }
162
- function forEachKey(object, callback) {
163
- for (const key of keys(object)) {
164
- callback(key);
165
- }
166
- }
167
- function forEachValue(object, callback) {
168
- for (const value of values(object)) {
169
- callback(value);
170
- }
171
- }
172
- function forEachSet(s, callback) {
173
- for (const value of s) {
174
- callback(value);
175
- }
176
- }
177
- var iterate = Object.freeze({
178
- entries,
179
- filter,
180
- find,
181
- findLast,
182
- forEach,
183
- forEachEntry,
184
- forEachKey,
185
- forEachSet,
186
- forEachValue,
187
- items,
188
- keys,
189
- map,
190
- mapEntries,
191
- mapValues,
192
- nodeList,
193
- reduce,
194
- collect,
195
- set,
196
- some,
197
- every,
198
- values
199
- });
200
-
201
- // ../../lib/primitive/src/utils/merge-props.ts
202
- function mergeProps(defaultProps, props) {
203
- return {
204
- ...defaultProps ?? {},
205
- ...props
206
- };
207
- }
208
-
209
28
  // ../../lib/primitive/src/constants/aria/global-aria-attributes.ts
210
29
  var GLOBAL_ARIA_ATTRIBUTES = /* @__PURE__ */ new Set([
211
30
  "aria-atomic",
@@ -228,7 +47,7 @@ var GLOBAL_ARIA_ATTRIBUTES = /* @__PURE__ */ new Set([
228
47
  ]);
229
48
 
230
49
  // ../../lib/primitive/src/constants/aria/implicit-role-record.ts
231
- var IMPLICIT_ROLE_RECORD = {
50
+ var IMPLICIT_ROLE_RECORD = Object.freeze({
232
51
  // Landmarks
233
52
  article: "article",
234
53
  aside: "complementary",
@@ -264,8 +83,8 @@ var IMPLICIT_ROLE_RECORD = {
264
83
  meter: "meter",
265
84
  output: "status",
266
85
  progress: "progressbar"
267
- };
268
- var INPUT_TYPE_ROLE_MAP = {
86
+ });
87
+ var INPUT_TYPE_ROLE_MAP = Object.freeze({
269
88
  checkbox: "checkbox",
270
89
  radio: "radio",
271
90
  range: "slider",
@@ -279,15 +98,17 @@ var INPUT_TYPE_ROLE_MAP = {
279
98
  submit: "button",
280
99
  reset: "button",
281
100
  image: "button"
282
- };
283
- var STRONG_ROLES = [
101
+ });
102
+ var STRONG_ROLES = Object.freeze([
284
103
  "main",
285
104
  "navigation",
286
105
  "complementary",
287
106
  "contentinfo",
288
107
  "banner"
289
- ];
290
- var STANDALONE_ROLES = ["article"];
108
+ ]);
109
+ var STANDALONE_ROLES = Object.freeze([
110
+ "article"
111
+ ]);
291
112
  var STRONG_ROLES_SET = new Set(STRONG_ROLES);
292
113
  var STANDALONE_ROLES_SET = new Set(STANDALONE_ROLES);
293
114
 
@@ -442,58 +263,280 @@ var ROLE_RESTRICTED_ATTRIBUTES = /* @__PURE__ */ new Map([
442
263
  ]
443
264
  ]);
444
265
 
445
- // ../../lib/primitive/src/guards/foundational/is-defined.ts
446
- function isUndefined(value) {
447
- return value === void 0;
266
+ // ../../lib/primitive/src/guards/aria/is-aria-attribute.ts
267
+ function isGlobalAriaAttribute(attr) {
268
+ return GLOBAL_ARIA_ATTRIBUTES.has(attr);
269
+ }
270
+ function isAriaAttributeValidForRole(attr, role) {
271
+ const allowedRoles = ROLE_RESTRICTED_ATTRIBUTES.get(attr);
272
+ if (isUndefined(allowedRoles)) return true;
273
+ if (isUndefined(role)) return false;
274
+ return allowedRoles.has(role);
275
+ }
276
+
277
+ // ../../lib/primitive/src/guards/aria/is-aria-role.ts
278
+ function isStrongImplicitRole(tag) {
279
+ if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
280
+ return STRONG_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
281
+ }
282
+ function isStandaloneTag(tag) {
283
+ if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
284
+ return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
285
+ }
286
+ function getInputImplicitRole(type) {
287
+ if (!isString(type) || !(type in INPUT_TYPE_ROLE_MAP)) return void 0;
288
+ return INPUT_TYPE_ROLE_MAP[type];
289
+ }
290
+ function getConditionalImplicitRole(tag, ariaLabel, ariaLabelledBy) {
291
+ const isNamed = isString(ariaLabel) || isString(ariaLabelledBy);
292
+ if (!isNamed) return void 0;
293
+ if (tag === "section") return "region";
294
+ if (tag === "form") return "form";
295
+ return void 0;
296
+ }
297
+
298
+ // ../../lib/contract/src/aria/aria-role-policy.ts
299
+ function getImplicitRole(tag, props) {
300
+ if (tag in IMPLICIT_ROLE_RECORD) return IMPLICIT_ROLE_RECORD[tag];
301
+ if (tag === "input") return getInputImplicitRole(props?.type);
302
+ if (tag === "img") return props?.alt === "" ? "none" : "img";
303
+ if (tag === "section" || tag === "form") {
304
+ return getConditionalImplicitRole(tag, props?.["aria-label"], props?.["aria-labelledby"]);
305
+ }
306
+ return void 0;
307
+ }
308
+
309
+ // ../../lib/primitive/src/tag/resolve-tag.ts
310
+ function makeResolveTag(defaultTag) {
311
+ return function tag(as) {
312
+ return as ?? defaultTag;
313
+ };
314
+ }
315
+
316
+ // ../../lib/primitive/src/utils/assert-never.ts
317
+ function assertNever(value) {
318
+ throw new Error(`Unexpected value: ${String(value)}`);
319
+ }
320
+
321
+ // ../../lib/primitive/src/utils/cn.ts
322
+ import { clsx } from "clsx";
323
+ function cn(...inputs) {
324
+ return clsx(...inputs);
325
+ }
326
+
327
+ // ../../lib/primitive/src/utils/iterate.ts
328
+ function find(iterable, callback) {
329
+ for (const value of iterable) {
330
+ const result = callback(value);
331
+ if (result != null) {
332
+ return result;
333
+ }
334
+ }
335
+ return null;
336
+ }
337
+ function some(iterable, predicate) {
338
+ for (const value of iterable) {
339
+ if (predicate(value)) return true;
340
+ }
341
+ return false;
342
+ }
343
+ function every(iterable, predicate) {
344
+ let index = 0;
345
+ for (const value of iterable) {
346
+ if (!predicate(value, index++)) {
347
+ return false;
348
+ }
349
+ }
350
+ return true;
351
+ }
352
+ function* filter(iterable, predicate) {
353
+ let index = 0;
354
+ for (const value of iterable) {
355
+ if (predicate(value, index++)) {
356
+ yield value;
357
+ }
358
+ }
359
+ }
360
+ function* map(iterable, callback) {
361
+ let index = 0;
362
+ for (const value of iterable) {
363
+ yield callback(value, index++);
364
+ }
365
+ }
366
+ function forEach(iterable, callback) {
367
+ let index = 0;
368
+ for (const value of iterable) {
369
+ callback(value, index++);
370
+ }
371
+ }
372
+ function reduce(iterable, initial, callback) {
373
+ let accumulator = initial;
374
+ let index = 0;
375
+ for (const value of iterable) {
376
+ accumulator = callback(accumulator, value, index++);
377
+ }
378
+ return accumulator;
379
+ }
380
+ function collect(iterable, callback) {
381
+ const result = {};
382
+ let index = 0;
383
+ for (const value of iterable) {
384
+ const entry = callback(value, index++);
385
+ if (entry === null) {
386
+ return null;
387
+ }
388
+ result[entry[0]] = entry[1];
389
+ }
390
+ return result;
448
391
  }
449
-
450
- // ../../lib/primitive/src/guards/foundational/is-null.ts
451
- function isNull(value) {
452
- return value === null;
392
+ function findLast(value, callback) {
393
+ for (let index = value.length - 1; index >= 0; index--) {
394
+ const result = callback(value[index], index);
395
+ if (result != null) {
396
+ return result;
397
+ }
398
+ }
399
+ return null;
453
400
  }
454
-
455
- // ../../lib/primitive/src/guards/aria/is-aria-attribute.ts
456
- function isGlobalAriaAttribute(attr) {
457
- return GLOBAL_ARIA_ATTRIBUTES.has(attr);
401
+ function* items(collection) {
402
+ for (let i = 0; i < collection.length; i++) {
403
+ const item = collection.item(i);
404
+ if (item !== null) {
405
+ yield item;
406
+ }
407
+ }
458
408
  }
459
- function isAriaAttributeValidForRole(attr, role) {
460
- const allowedRoles = ROLE_RESTRICTED_ATTRIBUTES.get(attr);
461
- if (isUndefined(allowedRoles)) return true;
462
- if (isUndefined(role)) return false;
463
- return allowedRoles.has(role);
409
+ function nodeList(list) {
410
+ return {
411
+ *[Symbol.iterator]() {
412
+ for (let i = 0; i < list.length; i++) {
413
+ const node = list.item(i);
414
+ if (node !== null) {
415
+ yield node;
416
+ }
417
+ }
418
+ }
419
+ };
464
420
  }
465
-
466
- // ../../lib/primitive/src/guards/aria/is-aria-role.ts
467
- function isStrongImplicitRole(tag) {
468
- if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
469
- return STRONG_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
421
+ function mapEntries(m) {
422
+ return m.entries();
470
423
  }
471
- function isStandaloneTag(tag) {
472
- if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
473
- return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
424
+ function set(s) {
425
+ return s.values();
474
426
  }
475
- function getInputImplicitRole(type) {
476
- if (type == null || !(type in INPUT_TYPE_ROLE_MAP)) return void 0;
477
- return INPUT_TYPE_ROLE_MAP[type];
427
+ function hasOwn(object, key) {
428
+ return Object.hasOwn(object, key);
478
429
  }
479
- function getConditionalImplicitRole(tag, ariaLabel, ariaLabelledBy) {
480
- const isNamed = typeof ariaLabel === "string" || typeof ariaLabelledBy === "string";
481
- if (!isNamed) return void 0;
482
- if (tag === "section") return "region";
483
- if (tag === "form") return "form";
484
- return void 0;
430
+ function* entries(object) {
431
+ for (const key in object) {
432
+ if (!hasOwn(object, key)) continue;
433
+ yield [key, object[key]];
434
+ }
435
+ }
436
+ function* keys(object) {
437
+ for (const [key] of entries(object)) {
438
+ yield key;
439
+ }
440
+ }
441
+ function* values(object) {
442
+ for (const [, value] of entries(object)) {
443
+ yield value;
444
+ }
445
+ }
446
+ function mapValues(object, callback) {
447
+ const result = {};
448
+ for (const [key, value] of entries(object)) {
449
+ result[key] = callback(value, key);
450
+ }
451
+ return result;
452
+ }
453
+ function forEachEntry(object, callback) {
454
+ for (const [key, value] of entries(object)) {
455
+ callback(key, value);
456
+ }
457
+ }
458
+ function forEachKey(object, callback) {
459
+ for (const key of keys(object)) {
460
+ callback(key);
461
+ }
462
+ }
463
+ function forEachValue(object, callback) {
464
+ for (const value of values(object)) {
465
+ callback(value);
466
+ }
467
+ }
468
+ function forEachSet(s, callback) {
469
+ for (const value of s) {
470
+ callback(value);
471
+ }
472
+ }
473
+ var iterate = Object.freeze({
474
+ entries,
475
+ filter,
476
+ find,
477
+ findLast,
478
+ forEach,
479
+ forEachEntry,
480
+ forEachKey,
481
+ forEachSet,
482
+ forEachValue,
483
+ items,
484
+ keys,
485
+ map,
486
+ mapEntries,
487
+ mapValues,
488
+ nodeList,
489
+ reduce,
490
+ collect,
491
+ set,
492
+ some,
493
+ every,
494
+ values
495
+ });
496
+
497
+ // ../../lib/primitive/src/utils/merge-props.ts
498
+ function mergeProps(defaultProps, props) {
499
+ return {
500
+ ...defaultProps ?? {},
501
+ ...props
502
+ };
485
503
  }
486
504
 
487
- // ../../lib/contract/src/aria/aria-role-policy.ts
488
- function getImplicitRole(tag, props) {
489
- if (tag in IMPLICIT_ROLE_RECORD) return IMPLICIT_ROLE_RECORD[tag];
490
- if (tag === "input") return getInputImplicitRole(props?.type);
491
- if (tag === "img") return props?.alt === "" ? "none" : "img";
492
- if (tag === "section" || tag === "form") {
493
- return getConditionalImplicitRole(tag, props?.["aria-label"], props?.["aria-labelledby"]);
505
+ // ../../lib/primitive/src/guards/children/component-id.ts
506
+ var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol.for("praxis.component-default-tag");
507
+
508
+ // ../../lib/primitive/src/guards/children/is-tag.ts
509
+ function getAsProp(child) {
510
+ if (!isObject(child) || !("props" in child)) return void 0;
511
+ const props = child.props;
512
+ if (!isObject(props)) return void 0;
513
+ const as = props.as;
514
+ return isString(as) && as !== "" ? as : void 0;
515
+ }
516
+ function getTag(child) {
517
+ if (!isObject(child) || !("type" in child)) return void 0;
518
+ const t = child.type;
519
+ if (isString(t)) return t;
520
+ if (typeof t === "function" || isObject(t)) {
521
+ const defaultTag = t[COMPONENT_DEFAULT_TAG];
522
+ if (!isString(defaultTag)) return void 0;
523
+ return getAsProp(child) ?? defaultTag;
494
524
  }
495
525
  return void 0;
496
526
  }
527
+ function isTag(...args) {
528
+ if (isString(args[0])) {
529
+ const set3 = new Set(args);
530
+ return (child2) => {
531
+ const tag2 = getTag(child2);
532
+ return tag2 !== void 0 && set3.has(tag2);
533
+ };
534
+ }
535
+ const [child, ...tags] = args;
536
+ const set2 = new Set(tags);
537
+ const tag = getTag(child);
538
+ return tag !== void 0 && set2.has(tag);
539
+ }
497
540
 
498
541
  // ../../lib/contract/src/strict/invariant-base.ts
499
542
  var InvariantBase = class {
@@ -517,159 +560,21 @@ var InvariantBase = class {
517
560
  }
518
561
  };
519
562
 
520
- // ../../lib/diagnostics/src/category.ts
521
- var DiagnosticCategory = /* @__PURE__ */ ((DiagnosticCategory2) => {
522
- DiagnosticCategory2[DiagnosticCategory2["Contract"] = 0] = "Contract";
523
- DiagnosticCategory2[DiagnosticCategory2["HTML"] = 1] = "HTML";
524
- DiagnosticCategory2[DiagnosticCategory2["ARIA"] = 2] = "ARIA";
525
- DiagnosticCategory2[DiagnosticCategory2["Composition"] = 3] = "Composition";
526
- DiagnosticCategory2[DiagnosticCategory2["Rendering"] = 4] = "Rendering";
527
- DiagnosticCategory2[DiagnosticCategory2["Accessibility"] = 5] = "Accessibility";
528
- DiagnosticCategory2[DiagnosticCategory2["Performance"] = 6] = "Performance";
529
- DiagnosticCategory2[DiagnosticCategory2["Internal"] = 7] = "Internal";
530
- DiagnosticCategory2[DiagnosticCategory2["Deprecation"] = 8] = "Deprecation";
531
- DiagnosticCategory2[DiagnosticCategory2["Lint"] = 9] = "Lint";
532
- return DiagnosticCategory2;
533
- })(DiagnosticCategory || {});
534
-
535
- // ../../lib/diagnostics/src/error.ts
536
- var PraxisError = class extends Error {
537
- diagnostic;
538
- constructor(diagnostic) {
539
- super(diagnostic.message);
540
- this.name = "PraxisError";
541
- this.diagnostic = diagnostic;
542
- }
543
- };
544
-
545
- // ../../lib/diagnostics/src/severity.ts
546
- var Severity = /* @__PURE__ */ ((Severity2) => {
547
- Severity2[Severity2["Debug"] = 0] = "Debug";
548
- Severity2[Severity2["Info"] = 1] = "Info";
549
- Severity2[Severity2["Warning"] = 2] = "Warning";
550
- Severity2[Severity2["Error"] = 3] = "Error";
551
- Severity2[Severity2["Fatal"] = 4] = "Fatal";
552
- return Severity2;
553
- })(Severity || {});
554
-
555
- // ../../lib/diagnostics/src/policy.ts
556
- var DefaultPolicy = class {
557
- reportThreshold;
558
- throwThreshold;
559
- constructor({
560
- reportThreshold = 1 /* Info */,
561
- throwThreshold = 4 /* Fatal */
562
- } = {}) {
563
- this.reportThreshold = reportThreshold;
564
- this.throwThreshold = throwThreshold;
565
- }
566
- resolve(diagnostic) {
567
- if (diagnostic.severity >= this.throwThreshold) return 2 /* Throw */;
568
- if (diagnostic.severity >= this.reportThreshold) return 1 /* Report */;
569
- return 0 /* Ignore */;
570
- }
571
- };
572
-
573
- // ../../lib/diagnostics/src/diagnostics.ts
574
- var Diagnostics = class {
575
- reporter;
576
- policy;
577
- // Pre-computed at construction time: true if Warning-level diagnostics are not ignored.
578
- active;
579
- constructor(reporter, policy = new DefaultPolicy()) {
580
- this.reporter = reporter;
581
- this.policy = policy;
582
- this.active = policy.resolve({ severity: 2 /* Warning */ }) !== 0 /* Ignore */;
583
- }
584
- report(diagnostic) {
585
- const enforcement = this.policy.resolve(diagnostic);
586
- if (enforcement === 0 /* Ignore */) return diagnostic;
587
- if (enforcement === 2 /* Throw */) throw new PraxisError(diagnostic);
588
- this.reporter.report(diagnostic);
589
- return diagnostic;
590
- }
591
- warn(input) {
592
- return this.report({ ...input, severity: 2 /* Warning */ });
593
- }
594
- error(input) {
595
- return this.report({ ...input, severity: 3 /* Error */ });
596
- }
597
- info(input) {
598
- return this.report({ ...input, severity: 1 /* Info */ });
599
- }
600
- };
601
-
602
- // ../../lib/diagnostics/src/formatter.ts
603
- function formatDiagnostic(diagnostic) {
604
- const level = Severity[diagnostic.severity];
605
- const category = DiagnosticCategory[diagnostic.category];
606
- const prefix = category !== void 0 ? `[${category}] ` : "";
607
- return `${level} ${diagnostic.code}: ${prefix}${diagnostic.message}`;
608
- }
609
-
610
- // ../../lib/diagnostics/src/console-reporter.ts
611
- var ConsoleReporter = class {
612
- report(diagnostic) {
613
- const message = formatDiagnostic(diagnostic);
614
- switch (diagnostic.severity) {
615
- case 0 /* Debug */:
616
- console.debug(message);
617
- break;
618
- case 1 /* Info */:
619
- console.info(message);
620
- break;
621
- case 2 /* Warning */:
622
- console.warn(message);
623
- break;
624
- case 3 /* Error */:
625
- case 4 /* Fatal */:
626
- console.error(message);
627
- break;
628
- }
629
- }
630
- };
631
-
632
- // ../../lib/diagnostics/src/null-reporter.ts
633
- var nullReporter = {
634
- report() {
635
- }
636
- };
637
-
638
- // ../../lib/diagnostics/src/presets.ts
639
- var ignoreAllPolicy = {
640
- resolve(_) {
641
- return 0 /* Ignore */;
642
- }
643
- };
644
- var warnOnlyReporter = {
645
- report(diagnostic) {
646
- console.warn(formatDiagnostic(diagnostic));
647
- }
648
- };
649
- var silentDiagnostics = new Diagnostics(nullReporter, ignoreAllPolicy);
650
- var warnDiagnostics = new Diagnostics(
651
- warnOnlyReporter,
652
- new DefaultPolicy({ reportThreshold: 2 /* Warning */, throwThreshold: 4 /* Fatal */ })
653
- );
654
- var throwDiagnostics = new Diagnostics(
655
- new ConsoleReporter(),
656
- new DefaultPolicy({ reportThreshold: 2 /* Warning */, throwThreshold: 3 /* Error */ })
657
- );
658
-
659
563
  // ../../lib/contract/src/diagnostics/aria.ts
564
+ import { DiagnosticCategory, DiagnosticCode } from "../_shared/diagnostics.js";
660
565
  var AriaDiagnostics = {
661
566
  /** Generic bridge for violations produced by external AriaRule functions. */
662
567
  fromViolation(v) {
663
568
  return {
664
- code: "ARIA2002" /* AriaViolation */,
665
- category: 2 /* ARIA */,
569
+ code: DiagnosticCode.AriaViolation,
570
+ category: DiagnosticCategory.ARIA,
666
571
  message: v.message
667
572
  };
668
573
  },
669
574
  attributeInvalid(key, role) {
670
575
  return {
671
- code: "ARIA2003" /* AriaAttributeInvalid */,
672
- category: 2 /* ARIA */,
576
+ code: DiagnosticCode.AriaAttributeInvalid,
577
+ category: DiagnosticCategory.ARIA,
673
578
  message: `"${key}" is not valid on role="${role}". It will be removed.`,
674
579
  rationale: "Invalid ARIA attributes are ignored by assistive technology and may trigger accessibility-tree warnings in browser devtools.",
675
580
  suggestions: [
@@ -682,8 +587,8 @@ var AriaDiagnostics = {
682
587
  },
683
588
  missingLiveRegion(role, impliedLive) {
684
589
  return {
685
- code: "ARIA2004" /* AriaMissingLiveRegion */,
686
- category: 2 /* ARIA */,
590
+ code: DiagnosticCode.AriaMissingLiveRegion,
591
+ category: DiagnosticCategory.ARIA,
687
592
  message: `role="${role}" implies aria-live="${impliedLive}" but it is missing. It has been injected.`,
688
593
  rationale: "Live-region roles announce dynamic content changes to screen readers. Without aria-live the politeness level is unspecified and announcements may be silent.",
689
594
  suggestions: [
@@ -697,8 +602,8 @@ var AriaDiagnostics = {
697
602
  },
698
603
  missingAtomic(role) {
699
604
  return {
700
- code: "ARIA2005" /* AriaMissingAtomic */,
701
- category: 2 /* ARIA */,
605
+ code: DiagnosticCode.AriaMissingAtomic,
606
+ category: DiagnosticCategory.ARIA,
702
607
  message: `role="${role}" is a live region. Consider setting aria-atomic="true" if the full region should be announced as a unit, or aria-atomic="false" if only changed nodes should be read.`,
703
608
  rationale: "aria-atomic controls whether assistive technology announces the entire live region or only the changed nodes. Omitting it leaves the behaviour browser-defined."
704
609
  };
@@ -706,8 +611,8 @@ var AriaDiagnostics = {
706
611
  relevantInvalidTokens(invalid) {
707
612
  const quoted = invalid.map((t) => `"${t}"`).join(", ");
708
613
  return {
709
- code: "ARIA2006" /* AriaRelevantInvalidToken */,
710
- category: 2 /* ARIA */,
614
+ code: DiagnosticCode.AriaRelevantInvalidToken,
615
+ category: DiagnosticCategory.ARIA,
711
616
  message: `aria-relevant contains invalid token(s): ${quoted}. Valid tokens are: additions, removals, text, all.`,
712
617
  rationale: "aria-relevant accepts a space-separated list of change types. Unrecognised tokens are silently ignored by assistive technology, making the attribute ineffective.",
713
618
  suggestions: [
@@ -720,8 +625,8 @@ var AriaDiagnostics = {
720
625
  },
721
626
  relevantSuperseded() {
722
627
  return {
723
- code: "ARIA2007" /* AriaRelevantSuperseded */,
724
- category: 2 /* ARIA */,
628
+ code: DiagnosticCode.AriaRelevantSuperseded,
629
+ category: DiagnosticCategory.ARIA,
725
630
  message: 'aria-relevant includes "all" alongside other tokens. "all" supersedes additions, removals, and text \u2014 use aria-relevant="all" alone.',
726
631
  rationale: '"all" is equivalent to "additions removals text". Combining it with other tokens is redundant and may confuse readers of the markup.',
727
632
  suggestions: [
@@ -734,8 +639,8 @@ var AriaDiagnostics = {
734
639
  },
735
640
  missingAccessibleName(tag) {
736
641
  return {
737
- code: "ARIA2009" /* AriaMissingAccessibleName */,
738
- category: 2 /* ARIA */,
642
+ code: DiagnosticCode.AriaMissingAccessibleName,
643
+ category: DiagnosticCategory.ARIA,
739
644
  message: `<${tag}> has no accessible name. Add aria-label or aria-labelledby.`,
740
645
  rationale: "Elements with a landmark or interactive role must have an accessible name so that assistive technology can identify them when presenting the page outline.",
741
646
  suggestions: [
@@ -752,8 +657,8 @@ var AriaDiagnostics = {
752
657
  },
753
658
  attributeOnPresentational(attr, tag) {
754
659
  return {
755
- code: "ARIA2010" /* AriaAttributeOnPresentational */,
756
- category: 2 /* ARIA */,
660
+ code: DiagnosticCode.AriaAttributeOnPresentational,
661
+ category: DiagnosticCategory.ARIA,
757
662
  message: `"${attr}" is not allowed on a presentational <${tag}>. Presentational elements are invisible to assistive technology.`,
758
663
  rationale: 'role="none" and role="presentation" (including <img alt="">) remove an element from the accessibility tree. ARIA attributes on such elements are ignored by assistive technology.',
759
664
  suggestions: [
@@ -766,8 +671,8 @@ var AriaDiagnostics = {
766
671
  },
767
672
  ariaHiddenOnFocusable(tag) {
768
673
  return {
769
- code: "ARIA2011" /* AriaHiddenOnFocusable */,
770
- category: 2 /* ARIA */,
674
+ code: DiagnosticCode.AriaHiddenOnFocusable,
675
+ category: DiagnosticCategory.ARIA,
771
676
  message: `aria-hidden="true" must not be used on focusable <${tag}> elements. Screen reader users who navigate by keyboard will encounter the element but receive no information about it.`,
772
677
  rationale: 'aria-hidden removes an element from the accessibility tree while leaving it keyboard-reachable. This creates a "ghost" \u2014 a focusable element assistive technology cannot describe.',
773
678
  suggestions: [
@@ -785,8 +690,8 @@ var AriaDiagnostics = {
785
690
  invalidAttributeValue(attr, value, expected) {
786
691
  const got = value === null ? "null" : value === void 0 ? "undefined" : typeof value === "string" ? `"${value}"` : String(value);
787
692
  return {
788
- code: "ARIA2013" /* AriaInvalidAttributeValue */,
789
- category: 2 /* ARIA */,
693
+ code: DiagnosticCode.AriaInvalidAttributeValue,
694
+ category: DiagnosticCategory.ARIA,
790
695
  message: `"${attr}" has an invalid value (${got}). Expected: ${expected}.`,
791
696
  rationale: "ARIA attributes with invalid values are silently ignored by assistive technology, making the markup semantically inert.",
792
697
  suggestions: [
@@ -799,8 +704,8 @@ var AriaDiagnostics = {
799
704
  },
800
705
  redundantAriaLevel(tag, level) {
801
706
  return {
802
- code: "ARIA2014" /* AriaRedundantLevelAttribute */,
803
- category: 2 /* ARIA */,
707
+ code: DiagnosticCode.AriaRedundantLevelAttribute,
708
+ category: DiagnosticCategory.ARIA,
804
709
  message: `aria-level="${level}" is redundant on <${tag}>: the element already has an implicit heading level of ${level}. Remove the attribute.`,
805
710
  rationale: 'Restating the implicit aria-level adds noise without semantic value. Use aria-level only to override the native heading level (e.g. aria-level="3" on <h2>).',
806
711
  suggestions: [
@@ -813,8 +718,8 @@ var AriaDiagnostics = {
813
718
  },
814
719
  requiredProperty(attr, role) {
815
720
  return {
816
- code: "ARIA2012" /* AriaRequiredProperty */,
817
- category: 2 /* ARIA */,
721
+ code: DiagnosticCode.AriaRequiredProperty,
722
+ category: DiagnosticCategory.ARIA,
818
723
  message: `"${attr}" is required for role="${role}" but is missing.`,
819
724
  rationale: `WAI-ARIA 1.2 specifies required states and properties for certain roles. Without "${attr}", assistive technology cannot correctly communicate the element's state to users.`,
820
725
  suggestions: [
@@ -827,8 +732,8 @@ var AriaDiagnostics = {
827
732
  },
828
733
  invalidRole(role, tag) {
829
734
  return {
830
- code: "ARIA2008" /* AriaInvalidRole */,
831
- category: 2 /* ARIA */,
735
+ code: DiagnosticCode.AriaInvalidRole,
736
+ category: DiagnosticCategory.ARIA,
832
737
  message: `Invalid role "${role ?? ""}" on <${tag}>.`,
833
738
  rationale: "An unrecognised or misapplied ARIA role is ignored by assistive technology and may degrade the accessibility of the element."
834
739
  };
@@ -836,11 +741,12 @@ var AriaDiagnostics = {
836
741
  };
837
742
 
838
743
  // ../../lib/contract/src/diagnostics/contract.ts
744
+ import { DiagnosticCategory as DiagnosticCategory2, DiagnosticCode as DiagnosticCode2 } from "../_shared/diagnostics.js";
839
745
  var ContractDiagnostics = {
840
746
  unexpectedChild(typeName, index, context) {
841
747
  return {
842
- code: "COMP1004" /* UnexpectedChild */,
843
- category: 0 /* Contract */,
748
+ code: DiagnosticCode2.UnexpectedChild,
749
+ category: DiagnosticCategory2.Contract,
844
750
  component: context,
845
751
  message: `${context}: unexpected child "${typeName}" at index ${index}.`
846
752
  };
@@ -848,69 +754,69 @@ var ContractDiagnostics = {
848
754
  ambiguousChild(typeName, index, ruleNames, context) {
849
755
  const quoted = ruleNames.map((n) => `"${n}"`).join(" and ");
850
756
  return {
851
- code: "COMP1005" /* AmbiguousChild */,
852
- category: 0 /* Contract */,
757
+ code: DiagnosticCode2.AmbiguousChild,
758
+ category: DiagnosticCategory2.Contract,
853
759
  component: context,
854
760
  message: `${context}: child "${typeName}" at index ${index} matches multiple child rules: ${quoted}.`
855
761
  };
856
762
  },
857
763
  cardinalityMin(ruleName, min, context) {
858
764
  return {
859
- code: "COMP1006" /* CardinalityMin */,
860
- category: 0 /* Contract */,
765
+ code: DiagnosticCode2.CardinalityMin,
766
+ category: DiagnosticCategory2.Contract,
861
767
  component: context,
862
768
  message: `${context}: "${ruleName}" requires at least ${min}.`
863
769
  };
864
770
  },
865
771
  cardinalityMax(ruleName, max, context) {
866
772
  return {
867
- code: "COMP1007" /* CardinalityMax */,
868
- category: 0 /* Contract */,
773
+ code: DiagnosticCode2.CardinalityMax,
774
+ category: DiagnosticCategory2.Contract,
869
775
  component: context,
870
776
  message: `${context}: "${ruleName}" allows at most ${max}.`
871
777
  };
872
778
  },
873
779
  positionViolation(ruleName, position, index, context) {
874
780
  return {
875
- code: "COMP1008" /* PositionViolation */,
876
- category: 0 /* Contract */,
781
+ code: DiagnosticCode2.PositionViolation,
782
+ category: DiagnosticCategory2.Contract,
877
783
  component: context,
878
784
  message: `${context}: "${ruleName}" must be ${position}, got index ${index}`
879
785
  };
880
786
  },
881
787
  unknownVariantDim(component, label2, dim) {
882
788
  return {
883
- code: "COMP1010" /* ContractUnknownVariantDim */,
884
- category: 0 /* Contract */,
789
+ code: DiagnosticCode2.ContractUnknownVariantDim,
790
+ category: DiagnosticCategory2.Contract,
885
791
  message: `${component}: ${label2} references unknown variant "${dim}".`
886
792
  };
887
793
  },
888
794
  unknownVariantValue(component, label2, dim, value, valid) {
889
795
  return {
890
- code: "COMP1011" /* ContractUnknownVariantValue */,
891
- category: 0 /* Contract */,
796
+ code: DiagnosticCode2.ContractUnknownVariantValue,
797
+ category: DiagnosticCategory2.Contract,
892
798
  message: `${component}: ${label2} sets "${dim}" to unknown value "${value}" (valid: ${valid.join(", ")}).`
893
799
  };
894
800
  },
895
801
  unknownRecipeKey(component, key) {
896
802
  return {
897
- code: "COMP1012" /* ContractUnknownRecipeKey */,
898
- category: 0 /* Contract */,
803
+ code: DiagnosticCode2.ContractUnknownRecipeKey,
804
+ category: DiagnosticCategory2.Contract,
899
805
  message: `${component} Unknown recipeKey "${key}" \u2014 no preset with that name exists.`
900
806
  };
901
807
  },
902
808
  invalidVariantValue(component, key, value) {
903
809
  return {
904
- code: "COMP1013" /* ContractInvalidVariantValue */,
905
- category: 0 /* Contract */,
810
+ code: DiagnosticCode2.ContractInvalidVariantValue,
811
+ category: DiagnosticCategory2.Contract,
906
812
  message: `${component} Variant "${key}=${value}" is not a defined value for the "${key}" dimension.`
907
813
  };
908
814
  },
909
815
  allowedAsViolation(tag, allowedAs, component) {
910
816
  const allowed = allowedAs.map((t) => `"${String(t)}"`).join(", ");
911
817
  return {
912
- code: "COMP1009" /* AllowedAsViolation */,
913
- category: 0 /* Contract */,
818
+ code: DiagnosticCode2.AllowedAsViolation,
819
+ category: DiagnosticCategory2.Contract,
914
820
  component,
915
821
  message: `<${component}>: "as" prop received "${tag}" but only [${allowed}] are allowed.`
916
822
  };
@@ -918,73 +824,75 @@ var ContractDiagnostics = {
918
824
  };
919
825
 
920
826
  // ../../lib/contract/src/diagnostics/html.ts
827
+ import { DiagnosticCategory as DiagnosticCategory3, DiagnosticCode as DiagnosticCode3 } from "../_shared/diagnostics.js";
921
828
  var HtmlDiagnostics = {
922
829
  emptyRole(tag) {
923
830
  return {
924
- code: "HTML3002" /* HtmlEmptyRole */,
925
- category: 1 /* HTML */,
831
+ code: DiagnosticCode3.HtmlEmptyRole,
832
+ category: DiagnosticCategory3.HTML,
926
833
  message: `<${tag}> has an explicit empty role="". Omit the attribute instead.`
927
834
  };
928
835
  },
929
836
  implicitRoleRedundant(tag, implicitRole) {
930
837
  return {
931
- code: "HTML3003" /* HtmlImplicitRoleRedundant */,
932
- category: 1 /* HTML */,
838
+ code: DiagnosticCode3.HtmlImplicitRoleRedundant,
839
+ category: DiagnosticCategory3.HTML,
933
840
  message: `<${tag}> already has implicit role="${implicitRole}". Avoid redundant role assignment.`
934
841
  };
935
842
  },
936
843
  implicitRoleOverride(tag, implicitRole, role) {
937
844
  return {
938
- code: "HTML3004" /* HtmlImplicitRoleOverride */,
939
- category: 1 /* HTML */,
845
+ code: DiagnosticCode3.HtmlImplicitRoleOverride,
846
+ category: DiagnosticCategory3.HTML,
940
847
  message: `<${tag}> should not override its implicit role="${implicitRole}" with role="${role}".`
941
848
  };
942
849
  },
943
850
  standaloneRegionOverride(tag, implicitRole) {
944
851
  return {
945
- code: "HTML3005" /* HtmlStandaloneRegionOverride */,
946
- category: 1 /* HTML */,
852
+ code: DiagnosticCode3.HtmlStandaloneRegionOverride,
853
+ category: DiagnosticCategory3.HTML,
947
854
  message: `<${tag}> is a self-contained element with implicit role="${implicitRole}". Assigning role="region" has been removed.`
948
855
  };
949
856
  },
950
857
  landmarkRoleOverride(tag, implicitRole, role) {
951
858
  return {
952
- code: "HTML3006" /* HtmlLandmarkRoleOverride */,
953
- category: 1 /* HTML */,
859
+ code: DiagnosticCode3.HtmlLandmarkRoleOverride,
860
+ category: DiagnosticCategory3.HTML,
954
861
  message: `<${tag}> has a fixed landmark role="${implicitRole}". role="${role}" overrides it and confuses assistive technology. The override has been removed.`
955
862
  };
956
863
  },
957
864
  invalidChild(child, parent, allowed) {
958
865
  return {
959
- code: "HTML3007" /* HtmlInvalidChild */,
960
- category: 1 /* HTML */,
866
+ code: DiagnosticCode3.HtmlInvalidChild,
867
+ category: DiagnosticCategory3.HTML,
961
868
  message: `<${child}> is not a valid direct child of <${parent}>. Allowed: ${allowed}.`
962
869
  };
963
870
  }
964
871
  };
965
872
 
966
873
  // ../../lib/contract/src/diagnostics/slot.ts
874
+ import { DiagnosticCategory as DiagnosticCategory4, DiagnosticCode as DiagnosticCode4 } from "../_shared/diagnostics.js";
967
875
  var SlotDiagnostics = {
968
876
  exclusive(name) {
969
877
  return {
970
- code: "SLOT1001" /* SlotExclusive */,
971
- category: 0 /* Contract */,
878
+ code: DiagnosticCode4.SlotExclusive,
879
+ category: DiagnosticCategory4.Contract,
972
880
  component: name,
973
881
  message: `${name}: "as" and "asChild" are mutually exclusive`
974
882
  };
975
883
  },
976
884
  singleChildRequired(name, elementTerm) {
977
885
  return {
978
- code: "SLOT1002" /* SlotSingleChild */,
979
- category: 0 /* Contract */,
886
+ code: DiagnosticCode4.SlotSingleChild,
887
+ category: DiagnosticCategory4.Contract,
980
888
  component: name,
981
889
  message: `${name}: asChild requires a ${elementTerm} child`
982
890
  };
983
891
  },
984
892
  singleChildExceeded(name, elementTerm, count) {
985
893
  return {
986
- code: "SLOT1002" /* SlotSingleChild */,
987
- category: 0 /* Contract */,
894
+ code: DiagnosticCode4.SlotSingleChild,
895
+ category: DiagnosticCategory4.Contract,
988
896
  component: name,
989
897
  message: `${name}: asChild requires exactly one ${elementTerm} child, got ${count}`
990
898
  };
@@ -992,16 +900,16 @@ var SlotDiagnostics = {
992
900
  discardedChildren(name, elementTerm, count) {
993
901
  const suffix = count === 1 ? "" : "ren";
994
902
  return {
995
- code: "SLOT1003" /* SlotDiscardedChildren */,
996
- category: 0 /* Contract */,
903
+ code: DiagnosticCode4.SlotDiscardedChildren,
904
+ category: DiagnosticCategory4.Contract,
997
905
  component: name,
998
906
  message: `${name}: asChild discarded ${count} non-element child${suffix} \u2014 only ${elementTerm}s are valid asChild children.`
999
907
  };
1000
908
  },
1001
909
  renderFnRequired(name, received) {
1002
910
  return {
1003
- code: "SLOT1004" /* SlotRenderFn */,
1004
- category: 0 /* Contract */,
911
+ code: DiagnosticCode4.SlotRenderFn,
912
+ category: DiagnosticCategory4.Contract,
1005
913
  component: name,
1006
914
  message: `${name}: asChild requires a render function as children, got ${received}`
1007
915
  };
@@ -1685,7 +1593,7 @@ function getTypeName(value) {
1685
1593
  return primitive;
1686
1594
  }
1687
1595
  const name = value.constructor?.name;
1688
- return typeof name === "string" && name !== "Object" ? name : "object";
1596
+ return isString(name) && name !== "Object" ? name : "object";
1689
1597
  }
1690
1598
 
1691
1599
  // ../../lib/contract/src/children/normalize-child-rule.ts
@@ -1936,6 +1844,9 @@ var readonlyProps = ({
1936
1844
  };
1937
1845
  };
1938
1846
 
1847
+ // ../core/src/html/evaluators.ts
1848
+ import { warnDiagnostics as warnDiagnostics2 } from "../_shared/diagnostics.js";
1849
+
1939
1850
  // ../core/src/html/aria-rules.ts
1940
1851
  var LANDMARK_TAG_SET = /* @__PURE__ */ new Set(["article", "aside", "footer", "header", "main", "nav"]);
1941
1852
  var removeLandmarkRoleOverride = {
@@ -1978,6 +1889,167 @@ function landmarkNameAdvisory(ctx) {
1978
1889
  }
1979
1890
  var HTML_ARIA_RULES = [landmarkRoleRule, landmarkNameAdvisory];
1980
1891
 
1892
+ // ../core/src/html/contracts.ts
1893
+ import { warnDiagnostics } from "../_shared/diagnostics.js";
1894
+ function isOpenContent(...blockedTags) {
1895
+ const set2 = new Set(blockedTags);
1896
+ return (child) => isObject(child) && "type" in child && (!isString(child.type) || !set2.has(child.type));
1897
+ }
1898
+ var METADATA_TAGS = ["script", "template"];
1899
+ var metadataMatch = isTag(...METADATA_TAGS);
1900
+ function metadata(name = "metadata") {
1901
+ return { name, match: metadataMatch };
1902
+ }
1903
+ function firstOptional(name, tag) {
1904
+ return { name, match: isTag(tag), cardinality: { max: 1 }, position: "first" };
1905
+ }
1906
+ function contract(children) {
1907
+ return { diagnostics: warnDiagnostics, children };
1908
+ }
1909
+ function ariaContract(aria) {
1910
+ return { diagnostics: warnDiagnostics, aria };
1911
+ }
1912
+ function firstChildContract(name, tag) {
1913
+ return contract([firstOptional(name, tag), { name: "content", match: isOpenContent(tag) }]);
1914
+ }
1915
+ var VOID_TAGS = [
1916
+ "area",
1917
+ "base",
1918
+ "br",
1919
+ "col",
1920
+ "embed",
1921
+ "hr",
1922
+ "img",
1923
+ "input",
1924
+ "link",
1925
+ "meta",
1926
+ "param",
1927
+ "source",
1928
+ "track",
1929
+ "wbr"
1930
+ ];
1931
+ var TEXT_ONLY_TAGS = ["option", "script", "style", "textarea", "title"];
1932
+ var LANDMARK_TAGS = ["article", "aside", "footer", "header", "main", "nav"];
1933
+ var listContract = contract([{ name: "list-item", match: isTag("li", ...METADATA_TAGS) }]);
1934
+ var tableContract = contract([
1935
+ firstOptional("caption", "caption"),
1936
+ { name: "colgroup", match: isTag("colgroup") },
1937
+ { name: "thead", match: isTag("thead"), cardinality: { max: 1 } },
1938
+ { name: "tbody", match: isTag("tbody") },
1939
+ { name: "tfoot", match: isTag("tfoot"), cardinality: { max: 1 } },
1940
+ { name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
1941
+ ]);
1942
+ var tableBodyContract = contract([
1943
+ { name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
1944
+ ]);
1945
+ var tableRowContract = contract([
1946
+ { name: "table-cell", match: isTag("td", "th", ...METADATA_TAGS) }
1947
+ ]);
1948
+ var colgroupContract = contract([{ name: "column", match: isTag("col", "template") }]);
1949
+ var dlContract = contract([
1950
+ { name: "term", match: isTag("dt") },
1951
+ { name: "description", match: isTag("dd") },
1952
+ { name: "group", match: isTag("div") },
1953
+ metadata()
1954
+ ]);
1955
+ var selectContract = contract([
1956
+ { name: "option", match: isTag("option", "optgroup", "hr", ...METADATA_TAGS) }
1957
+ ]);
1958
+ var optgroupContract = contract([
1959
+ { name: "option", match: isTag("option", ...METADATA_TAGS) }
1960
+ ]);
1961
+ var datalistContract = contract([
1962
+ { name: "option", match: isTag("option", ...METADATA_TAGS) }
1963
+ ]);
1964
+ var pictureContract = contract([
1965
+ { name: "source", match: isTag("source", ...METADATA_TAGS) },
1966
+ { name: "image", match: isTag("img"), cardinality: { min: 1, max: 1 }, position: "last" }
1967
+ ]);
1968
+ var figureContract = contract([
1969
+ { name: "caption", match: isTag("figcaption"), cardinality: { max: 1 } },
1970
+ { name: "content", match: isOpenContent("figcaption") }
1971
+ ]);
1972
+ var detailsContract = firstChildContract("summary", "summary");
1973
+ var fieldsetContract = firstChildContract("legend", "legend");
1974
+ var mediaContract = contract([
1975
+ { name: "source", match: isTag("source") },
1976
+ { name: "track", match: isTag("track") },
1977
+ metadata(),
1978
+ { name: "content", match: isOpenContent("source", "track", ...METADATA_TAGS) }
1979
+ ]);
1980
+ var headContract = contract([
1981
+ {
1982
+ name: "metadata",
1983
+ match: isTag("base", "link", "meta", "noscript", "script", "style", "template", "title")
1984
+ }
1985
+ ]);
1986
+ var htmlContract = contract([
1987
+ { name: "head", match: isTag("head"), cardinality: { min: 1, max: 1 }, position: "first" },
1988
+ { name: "body", match: isTag("body"), cardinality: { min: 1, max: 1 } }
1989
+ ]);
1990
+ var voidContract = contract([]);
1991
+ var textOnlyContract = contract([
1992
+ {
1993
+ name: "text",
1994
+ match: (child) => isString(child) || isNumber(child)
1995
+ }
1996
+ ]);
1997
+ var landmarkContract = ariaContract([landmarkRoleRule, landmarkNameAdvisory]);
1998
+ var dialogContract = ariaContract([requireAccessibleName]);
1999
+ var menuContract = ariaContract([requireAccessibleName]);
2000
+ var menubarContract = ariaContract([requireAccessibleName]);
2001
+ var treeContract = ariaContract([requireAccessibleName]);
2002
+ var gridContract = ariaContract([requireAccessibleName]);
2003
+ var listboxContract = ariaContract([requireAccessibleName]);
2004
+ var tablistContract = ariaContract([requireAccessibleName]);
2005
+ var radiogroupContract = ariaContract([requireAccessibleName]);
2006
+ var CONTRACT_GROUPS = [
2007
+ [VOID_TAGS, voidContract],
2008
+ [TEXT_ONLY_TAGS, textOnlyContract],
2009
+ [LANDMARK_TAGS, landmarkContract],
2010
+ [["ul", "ol", "menu"], listContract],
2011
+ [["audio", "video"], mediaContract],
2012
+ [["thead", "tbody", "tfoot"], tableBodyContract]
2013
+ ];
2014
+ function contractMap(groups) {
2015
+ return Object.fromEntries(
2016
+ groups.flatMap(([tags, enforcement]) => tags.map((tag) => [tag, enforcement]))
2017
+ );
2018
+ }
2019
+ var htmlContracts = {
2020
+ ...contractMap(CONTRACT_GROUPS),
2021
+ table: tableContract,
2022
+ tr: tableRowContract,
2023
+ colgroup: colgroupContract,
2024
+ dl: dlContract,
2025
+ select: selectContract,
2026
+ optgroup: optgroupContract,
2027
+ datalist: datalistContract,
2028
+ picture: pictureContract,
2029
+ figure: figureContract,
2030
+ details: detailsContract,
2031
+ fieldset: fieldsetContract,
2032
+ dialog: dialogContract,
2033
+ head: headContract,
2034
+ html: htmlContract
2035
+ };
2036
+
2037
+ // ../core/src/html/evaluators.ts
2038
+ var htmlDiagnostics = warnDiagnostics2;
2039
+ function buildEvaluatorMap() {
2040
+ const map2 = /* @__PURE__ */ new Map();
2041
+ iterate.forEachEntry(htmlContracts, (tag, { children }) => {
2042
+ if (children?.length) {
2043
+ map2.set(tag, new ChildrenEvaluator(children, htmlDiagnostics, `<${tag}>`));
2044
+ }
2045
+ });
2046
+ return map2;
2047
+ }
2048
+ var HTML_EVALUATORS = buildEvaluatorMap();
2049
+ function getHtmlChildrenEvaluator(tag) {
2050
+ return typeof tag === "string" ? HTML_EVALUATORS.get(tag) : void 0;
2051
+ }
2052
+
1981
2053
  // ../core/src/html/prop-normalizers.ts
1982
2054
  var HTML_FORM_NORMALIZERS = /* @__PURE__ */ new Map([
1983
2055
  ["button", [disabledProps]],
@@ -2165,7 +2237,21 @@ function createClassPipeline(resolved) {
2165
2237
  };
2166
2238
  }
2167
2239
 
2240
+ // ../../lib/pipeline-kit/src/factory/define-pipeline.ts
2241
+ function definePipeline(factory) {
2242
+ const cache = /* @__PURE__ */ new WeakMap();
2243
+ return (resolved) => {
2244
+ let pipeline = cache.get(resolved);
2245
+ if (!pipeline) {
2246
+ pipeline = factory(resolved);
2247
+ cache.set(resolved, pipeline);
2248
+ }
2249
+ return pipeline;
2250
+ };
2251
+ }
2252
+
2168
2253
  // ../core/src/options/resolve-factory-options.ts
2254
+ import { silentDiagnostics } from "../_shared/diagnostics.js";
2169
2255
  var EMPTY_VARIANT_KEYS = /* @__PURE__ */ new Set();
2170
2256
  function composeNormalizers(normalizers, fn) {
2171
2257
  if (!normalizers?.length) return fn;
@@ -2257,21 +2343,25 @@ function validateRenderProps(diagnostics, options, props, recipeKey) {
2257
2343
  }
2258
2344
  }
2259
2345
 
2346
+ // ../core/src/factory/plugin-invariants.ts
2347
+ import { throwDiagnostics } from "../_shared/diagnostics.js";
2348
+
2260
2349
  // ../core/src/factory/plugin-diagnostics.ts
2350
+ import { DiagnosticCategory as DiagnosticCategory5, DiagnosticCode as DiagnosticCode5 } from "../_shared/diagnostics.js";
2261
2351
  var PluginDiagnostics = {
2262
2352
  invalidShape(received) {
2263
2353
  const got = received === null ? "null" : typeof received;
2264
2354
  return {
2265
- code: "PLUGIN7001" /* PluginInvalidShape */,
2266
- category: 7 /* Internal */,
2355
+ code: DiagnosticCode5.PluginInvalidShape,
2356
+ category: DiagnosticCategory5.Internal,
2267
2357
  message: `[praxis-kit] Plugin factory must return an object with a 'pipeline' function. Got: ${got}.`
2268
2358
  };
2269
2359
  },
2270
2360
  pipelineReturnType(received) {
2271
2361
  const got = received === null ? "null" : Array.isArray(received) ? "array" : typeof received;
2272
2362
  return {
2273
- code: "PLUGIN7002" /* PluginPipelineReturnType */,
2274
- category: 7 /* Internal */,
2363
+ code: DiagnosticCode5.PluginPipelineReturnType,
2364
+ category: DiagnosticCategory5.Internal,
2275
2365
  message: `[praxis-kit] Plugin pipeline must return a string. Got: ${got}.`
2276
2366
  };
2277
2367
  }
@@ -2295,89 +2385,73 @@ function guardPipeline(pipeline) {
2295
2385
  };
2296
2386
  }
2297
2387
 
2298
- // ../core/src/factory/create-polymorphic.ts
2299
- var NOOP_CLASS_PIPELINE = (_tag, _props, className) => Array.isArray(className) ? className.join(" ") : className ?? "";
2300
- function resolveClassPipeline(options, resolved, diagnostics, capabilities) {
2301
- const factory = options.styling?.plugin;
2302
- if (!factory) {
2303
- const createClassPipeline2 = capabilities?.createClassPipeline;
2304
- const classPipeline2 = createClassPipeline2 ? createClassPipeline2(resolved) : NOOP_CLASS_PIPELINE;
2305
- return { pluginResult: void 0, classPipeline: classPipeline2 };
2306
- }
2388
+ // ../core/src/factory/create-polymorphic2.ts
2389
+ var createTagPipeline = (resolved) => makeResolveTag(resolved.defaultTag);
2390
+ var createPropsPipeline = (resolved) => (props) => mergeProps(resolved.defaultProps, props);
2391
+ var createHtmlPropNormalizersPipeline = () => getHtmlPropNormalizers;
2392
+ var createHtmlChildrenEvaluatorPipeline = () => getHtmlChildrenEvaluator;
2393
+ var createStylingClassPipeline = (resolved) => createClassPipeline(resolved);
2394
+ function resolveAriaRules(resolved) {
2395
+ return [.../* @__PURE__ */ new Set([...HTML_ARIA_RULES, ...resolved.ariaRules ?? []])];
2396
+ }
2397
+ var createAriaPipeline = (resolved) => {
2398
+ const rules = resolveAriaRules(resolved);
2399
+ const engine = new AriaPolicyEngine(resolved.diagnostics, rules.length ? { rules } : void 0);
2400
+ return (tag, props) => engine.validate(tag, props);
2401
+ };
2402
+ var memoizedTagPipeline = definePipeline(createTagPipeline);
2403
+ var memoizedPropsPipeline = definePipeline(createPropsPipeline);
2404
+ var memoizedHtmlPropNormalizersPipeline = definePipeline(createHtmlPropNormalizersPipeline);
2405
+ var memoizedHtmlChildrenEvaluatorPipeline = definePipeline(createHtmlChildrenEvaluatorPipeline);
2406
+ var memoizedClassPipeline = definePipeline(createStylingClassPipeline);
2407
+ var memoizedAriaPipeline = definePipeline(createAriaPipeline);
2408
+ function resolveAriaPassthrough(_tag, props) {
2409
+ return { props };
2410
+ }
2411
+ function resolveClassPlugin(factory, resolved, diagnostics) {
2412
+ if (!factory) return { pluginResult: void 0, classPipeline: memoizedClassPipeline(resolved) };
2307
2413
  const pluginResult = factory(resolved, diagnostics);
2308
2414
  assertPluginShape(pluginResult);
2309
- const classPipeline = guardPipeline(pluginResult.pipeline);
2310
- return { pluginResult, classPipeline };
2415
+ return { pluginResult, classPipeline: guardPipeline(pluginResult.pipeline) };
2311
2416
  }
2312
- function createRuntimeMethods(resolved, classPipeline, engine, renderDiagnostics) {
2313
- return {
2314
- resolveTag: makeResolveTag(resolved.defaultTag),
2315
- resolveProps(props) {
2316
- return mergeProps(resolved.defaultProps, props);
2317
- },
2417
+ function createPolymorphic2(options = {}) {
2418
+ const baseResolved = resolveFactoryOptions(options);
2419
+ const anyBaseResolved = baseResolved;
2420
+ const resolved = Object.freeze({
2421
+ ...baseResolved,
2422
+ htmlPropNormalizersFn: memoizedHtmlPropNormalizersPipeline(anyBaseResolved),
2423
+ htmlChildrenEvaluatorFn: memoizedHtmlChildrenEvaluatorPipeline(anyBaseResolved)
2424
+ });
2425
+ const anyResolved = resolved;
2426
+ if (process.env.NODE_ENV !== "production") {
2427
+ validateFactoryOptions(resolved, resolved.diagnostics);
2428
+ }
2429
+ const { pluginResult, classPipeline } = resolveClassPlugin(
2430
+ options.styling?.plugin,
2431
+ anyResolved,
2432
+ resolved.diagnostics
2433
+ );
2434
+ const resolveTag2 = memoizedTagPipeline(anyResolved);
2435
+ const resolveProps = memoizedPropsPipeline(anyResolved);
2436
+ const resolveAriaFn = options.enforcement !== void 0 ? memoizedAriaPipeline(anyResolved) : resolveAriaPassthrough;
2437
+ const methods = {
2438
+ resolveTag: resolveTag2,
2439
+ resolveProps,
2318
2440
  resolveClasses(tag, props, className, recipe) {
2319
2441
  if (process.env.NODE_ENV !== "production") {
2320
- validateRenderProps(renderDiagnostics, resolved, props, recipe);
2442
+ validateRenderProps(resolved.diagnostics, resolved, props, recipe);
2321
2443
  }
2322
2444
  return classPipeline(tag, props, className, recipe);
2323
2445
  },
2324
2446
  resolveAria(tag, props) {
2325
- if (!engine) return { props };
2326
- const result = engine.validate(tag, props);
2327
- return { props: result.props };
2447
+ return resolveAriaFn(tag, props);
2328
2448
  }
2329
2449
  };
2330
- }
2331
- function createRuntimeObject(methods, resolved, pluginResult) {
2332
- return pluginResult ? { ...methods, options: resolved, hasStyling: true, classPlugin: pluginResult } : { ...methods, options: resolved };
2333
- }
2334
- function createPolymorphic(options = {}, capabilities) {
2335
- const baseResolved = resolveFactoryOptions(options);
2336
- const resolved = capabilities?.htmlPropNormalizersFn !== void 0 ? Object.freeze({
2337
- ...baseResolved,
2338
- htmlPropNormalizersFn: capabilities.htmlPropNormalizersFn
2339
- }) : baseResolved;
2340
- if (process.env.NODE_ENV !== "production") {
2341
- validateFactoryOptions(resolved, resolved.diagnostics);
2342
- }
2343
- const { pluginResult, classPipeline } = resolveClassPipeline(
2344
- options,
2345
- resolved,
2346
- resolved.diagnostics,
2347
- capabilities
2348
- );
2349
- const allAriaRules = [
2350
- .../* @__PURE__ */ new Set([...capabilities?.htmlAriaRules ?? [], ...resolved.ariaRules ?? []])
2351
- ];
2352
- const engine = options.enforcement !== void 0 && capabilities?.AriaEngine ? new capabilities.AriaEngine(
2353
- resolved.diagnostics,
2354
- allAriaRules.length ? { rules: allAriaRules } : void 0
2355
- ) : null;
2356
- const methods = createRuntimeMethods(resolved, classPipeline, engine, resolved.diagnostics);
2357
- return createRuntimeObject(
2358
- methods,
2359
- resolved,
2360
- pluginResult
2361
- );
2362
- }
2363
-
2364
- // ../core/src/factory/create-polymorphic-full.ts
2365
- var FULL_CAPABILITIES = {
2366
- createClassPipeline,
2367
- AriaEngine: AriaPolicyEngine,
2368
- htmlAriaRules: HTML_ARIA_RULES,
2369
- htmlPropNormalizersFn: getHtmlPropNormalizers
2370
- };
2371
- function createPolymorphic2(options = {}) {
2372
- return createPolymorphic(options, FULL_CAPABILITIES);
2450
+ const runtimeObject = pluginResult ? { ...methods, options: resolved, hasStyling: true, classPlugin: pluginResult } : { ...methods, options: resolved };
2451
+ return runtimeObject;
2373
2452
  }
2374
2453
 
2375
- // ../../lib/adapter-utils/src/define-component.ts
2376
- function defineContractComponent(options) {
2377
- return (factory) => factory(options);
2378
- }
2379
-
2380
- // ../../lib/adapter-utils/src/build-core-runtime.ts
2454
+ // ../../lib/adapter-utils/src/runtime/build-core-runtime.ts
2381
2455
  var EMPTY_SET = /* @__PURE__ */ new Set();
2382
2456
  function buildCoreRuntime(normalized) {
2383
2457
  const runtime = createPolymorphic2(normalized);
@@ -2385,12 +2459,21 @@ function buildCoreRuntime(normalized) {
2385
2459
  return { runtime, ownedKeys };
2386
2460
  }
2387
2461
 
2388
- // ../../lib/adapter-utils/src/build-engines.ts
2462
+ // ../../lib/adapter-utils/src/runtime/build-engines.ts
2389
2463
  function buildEngines(diagnostics, childRules, context) {
2390
2464
  return childRules?.length ? { childrenEvaluator: new ChildrenEvaluator(childRules, diagnostics, context) } : {};
2391
2465
  }
2392
2466
 
2393
- // ../../lib/adapter-utils/src/compose-filter.ts
2467
+ // ../../lib/adapter-utils/src/runtime/resolve-adapter-common-options.ts
2468
+ import { throwDiagnostics as throwDiagnostics2, silentDiagnostics as silentDiagnostics2 } from "../_shared/diagnostics.js";
2469
+ function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics2) {
2470
+ return {
2471
+ name: options.name ?? defaultName,
2472
+ diagnostics: options.enforcement?.diagnostics ?? defaultDiagnostics
2473
+ };
2474
+ }
2475
+
2476
+ // ../../lib/adapter-utils/src/props/compose-filter.ts
2394
2477
  function composeFilter(ownedKeys, filterProps) {
2395
2478
  const defaultFilter = (key, variantKeys) => variantKeys.has(key) || ownedKeys.has(key);
2396
2479
  if (!filterProps) {
@@ -2399,15 +2482,7 @@ function composeFilter(ownedKeys, filterProps) {
2399
2482
  return (key, variantKeys) => defaultFilter(key, variantKeys) || filterProps(key, variantKeys);
2400
2483
  }
2401
2484
 
2402
- // ../../lib/adapter-utils/src/resolve-adapter-common-options.ts
2403
- function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics) {
2404
- return {
2405
- name: options.name ?? defaultName,
2406
- diagnostics: options.enforcement?.diagnostics ?? defaultDiagnostics
2407
- };
2408
- }
2409
-
2410
- // ../../lib/adapter-utils/src/slot-validator.ts
2485
+ // ../../lib/adapter-utils/src/slot/slot-validator.ts
2411
2486
  var SlotValidator = class extends InvariantBase {
2412
2487
  #name;
2413
2488
  #elementTerm;