praxis-kit 4.0.3 → 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.
package/dist/vue/index.js CHANGED
@@ -1,18 +1,8 @@
1
1
  // ../../adapters/vue/src/create-contract-component.ts
2
- import { cloneVNode, computed, defineComponent as defineComponent2 } from "vue";
2
+ import { computed, defineComponent as defineComponent2 } from "vue";
3
3
 
4
- // ../../lib/adapter-utils/src/invariant.ts
5
- function panic(message) {
6
- throw new Error(message);
7
- }
8
- function invariant(condition, message) {
9
- if (!condition) panic(message);
10
- }
11
-
12
- // ../../lib/adapter-utils/src/apply-display-name.ts
13
- function applyDisplayName(component, name) {
14
- Object.assign(component, { displayName: name ?? "PolymorphicComponent" });
15
- }
4
+ // ../../lib/primitive/src/guards/children/component-id.ts
5
+ var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol.for("praxis.component-default-tag");
16
6
 
17
7
  // ../../lib/primitive/src/utils/is-object.ts
18
8
  function isObject(value, excludeArrays = false) {
@@ -26,185 +16,66 @@ function isNumber(value) {
26
16
  return typeof value === "number";
27
17
  }
28
18
 
29
- // ../../lib/primitive/src/merge/predicates.ts
30
- function isFunction(value) {
31
- return typeof value === "function";
19
+ // ../../lib/primitive/src/guards/foundational/is-defined.ts
20
+ function isUndefined(value) {
21
+ return value === void 0;
32
22
  }
33
23
 
34
- // ../../lib/primitive/src/utils/assert-never.ts
35
- function assertNever(value) {
36
- throw new Error(`Unexpected value: ${String(value)}`);
24
+ // ../../lib/primitive/src/guards/foundational/is-null.ts
25
+ function isNull(value) {
26
+ return value === null;
37
27
  }
38
28
 
39
- // ../../lib/primitive/src/utils/iterate.ts
40
- function find(iterable, callback) {
41
- for (const value of iterable) {
42
- const result = callback(value);
43
- if (result != null) {
44
- return result;
45
- }
46
- }
47
- return null;
48
- }
49
- function some(iterable, predicate) {
50
- for (const value of iterable) {
51
- if (predicate(value)) return true;
52
- }
53
- return false;
54
- }
55
- function every(iterable, predicate) {
56
- let index = 0;
57
- for (const value of iterable) {
58
- if (!predicate(value, index++)) {
59
- return false;
60
- }
61
- }
62
- return true;
63
- }
64
- function* filter(iterable, predicate) {
65
- let index = 0;
66
- for (const value of iterable) {
67
- if (predicate(value, index++)) {
68
- yield value;
69
- }
70
- }
71
- }
72
- function* map(iterable, callback) {
73
- let index = 0;
74
- for (const value of iterable) {
75
- yield callback(value, index++);
76
- }
77
- }
78
- function forEach(iterable, callback) {
79
- let index = 0;
80
- for (const value of iterable) {
81
- callback(value, index++);
82
- }
83
- }
84
- function reduce(iterable, initial, callback) {
85
- let accumulator = initial;
86
- let index = 0;
87
- for (const value of iterable) {
88
- accumulator = callback(accumulator, value, index++);
89
- }
90
- return accumulator;
91
- }
92
- function collect(iterable, callback) {
93
- const result = {};
94
- let index = 0;
95
- for (const value of iterable) {
96
- const entry = callback(value, index++);
97
- if (entry === null) {
98
- return null;
99
- }
100
- result[entry[0]] = entry[1];
101
- }
102
- return result;
103
- }
104
- function findLast(value, callback) {
105
- for (let index = value.length - 1; index >= 0; index--) {
106
- const result = callback(value[index], index);
107
- if (result != null) {
108
- return result;
109
- }
110
- }
111
- return null;
112
- }
113
- function* items(collection) {
114
- for (let i = 0; i < collection.length; i++) {
115
- const item = collection.item(i);
116
- if (item !== null) {
117
- yield item;
118
- }
119
- }
120
- }
121
- function nodeList(list) {
122
- return {
123
- *[Symbol.iterator]() {
124
- for (let i = 0; i < list.length; i++) {
125
- const node = list.item(i);
126
- if (node !== null) {
127
- yield node;
128
- }
129
- }
130
- }
131
- };
132
- }
133
- function mapEntries(m) {
134
- return m.entries();
135
- }
136
- function set(s) {
137
- return s.values();
138
- }
139
- function hasOwn(object, key) {
140
- return Object.hasOwn(object, key);
141
- }
142
- function* entries(object) {
143
- for (const key in object) {
144
- if (!hasOwn(object, key)) continue;
145
- yield [key, object[key]];
146
- }
147
- }
148
- function* keys(object) {
149
- for (const [key] of entries(object)) {
150
- yield key;
151
- }
29
+ // ../../lib/primitive/src/guards/children/is-tag.ts
30
+ function getAsProp(child) {
31
+ if (!isObject(child) || !("props" in child)) return void 0;
32
+ const props = child.props;
33
+ if (!isObject(props)) return void 0;
34
+ const as = props.as;
35
+ return isString(as) && as !== "" ? as : void 0;
152
36
  }
153
- function* values(object) {
154
- for (const [, value] of entries(object)) {
155
- yield value;
37
+ function getTag(child) {
38
+ if (!isObject(child) || !("type" in child)) return void 0;
39
+ const t = child.type;
40
+ if (isString(t)) return t;
41
+ if (typeof t === "function" || isObject(t)) {
42
+ const defaultTag = t[COMPONENT_DEFAULT_TAG];
43
+ if (!isString(defaultTag)) return void 0;
44
+ return getAsProp(child) ?? defaultTag;
156
45
  }
46
+ return void 0;
157
47
  }
158
- function mapValues(object, callback) {
159
- const result = {};
160
- for (const [key, value] of entries(object)) {
161
- result[key] = callback(value, key);
48
+ function isTag(...args) {
49
+ if (isString(args[0])) {
50
+ const set3 = new Set(args);
51
+ return (child2) => {
52
+ const tag2 = getTag(child2);
53
+ return tag2 !== void 0 && set3.has(tag2);
54
+ };
162
55
  }
163
- return result;
56
+ const [child, ...tags] = args;
57
+ const set2 = new Set(tags);
58
+ const tag = getTag(child);
59
+ return tag !== void 0 && set2.has(tag);
164
60
  }
165
- function forEachEntry(object, callback) {
166
- for (const [key, value] of entries(object)) {
167
- callback(key, value);
168
- }
61
+
62
+ // ../../lib/adapter-utils/src/invariant.ts
63
+ function panic(message) {
64
+ throw new Error(message);
169
65
  }
170
- function forEachKey(object, callback) {
171
- for (const key of keys(object)) {
172
- callback(key);
173
- }
66
+ function invariant(condition, message) {
67
+ if (!condition) panic(message);
174
68
  }
175
- function forEachValue(object, callback) {
176
- for (const value of values(object)) {
177
- callback(value);
178
- }
69
+
70
+ // ../../lib/adapter-utils/src/runtime/apply-display-name.ts
71
+ function applyDisplayName(component, name) {
72
+ Object.assign(component, { displayName: name ?? "PolymorphicComponent" });
179
73
  }
180
- function forEachSet(s, callback) {
181
- for (const value of s) {
182
- callback(value);
183
- }
74
+
75
+ // ../../lib/adapter-utils/src/runtime/define-component.ts
76
+ function defineContractComponent(options) {
77
+ return (factory) => factory(options);
184
78
  }
185
- var iterate = Object.freeze({
186
- entries,
187
- filter,
188
- find,
189
- findLast,
190
- forEach,
191
- forEachEntry,
192
- forEachKey,
193
- forEachSet,
194
- forEachValue,
195
- items,
196
- keys,
197
- map,
198
- mapEntries,
199
- mapValues,
200
- nodeList,
201
- reduce,
202
- collect,
203
- set,
204
- some,
205
- every,
206
- values
207
- });
208
79
 
209
80
  // ../../lib/primitive/src/constants/aria/global-aria-attributes.ts
210
81
  var GLOBAL_ARIA_ATTRIBUTES = /* @__PURE__ */ new Set([
@@ -228,7 +99,7 @@ var GLOBAL_ARIA_ATTRIBUTES = /* @__PURE__ */ new Set([
228
99
  ]);
229
100
 
230
101
  // ../../lib/primitive/src/constants/aria/implicit-role-record.ts
231
- var IMPLICIT_ROLE_RECORD = {
102
+ var IMPLICIT_ROLE_RECORD = Object.freeze({
232
103
  // Landmarks
233
104
  article: "article",
234
105
  aside: "complementary",
@@ -264,8 +135,8 @@ var IMPLICIT_ROLE_RECORD = {
264
135
  meter: "meter",
265
136
  output: "status",
266
137
  progress: "progressbar"
267
- };
268
- var INPUT_TYPE_ROLE_MAP = {
138
+ });
139
+ var INPUT_TYPE_ROLE_MAP = Object.freeze({
269
140
  checkbox: "checkbox",
270
141
  radio: "radio",
271
142
  range: "slider",
@@ -279,18 +150,106 @@ var INPUT_TYPE_ROLE_MAP = {
279
150
  submit: "button",
280
151
  reset: "button",
281
152
  image: "button"
282
- };
283
- var STRONG_ROLES = [
153
+ });
154
+ var STRONG_ROLES = Object.freeze([
284
155
  "main",
285
156
  "navigation",
286
157
  "complementary",
287
158
  "contentinfo",
288
159
  "banner"
289
- ];
290
- var STANDALONE_ROLES = ["article"];
160
+ ]);
161
+ var STANDALONE_ROLES = Object.freeze([
162
+ "article"
163
+ ]);
291
164
  var STRONG_ROLES_SET = new Set(STRONG_ROLES);
292
165
  var STANDALONE_ROLES_SET = new Set(STANDALONE_ROLES);
293
166
 
167
+ // ../../lib/primitive/src/constants/aria/known-aria-roles.ts
168
+ var KNOWN_ARIA_ROLES = Object.freeze([
169
+ "alert",
170
+ "alertdialog",
171
+ "application",
172
+ "article",
173
+ "banner",
174
+ "blockquote",
175
+ "button",
176
+ "caption",
177
+ "cell",
178
+ "checkbox",
179
+ "code",
180
+ "columnheader",
181
+ "combobox",
182
+ "complementary",
183
+ "contentinfo",
184
+ "definition",
185
+ "deletion",
186
+ "dialog",
187
+ "document",
188
+ "emphasis",
189
+ "feed",
190
+ "figure",
191
+ "form",
192
+ "generic",
193
+ "grid",
194
+ "gridcell",
195
+ "group",
196
+ "heading",
197
+ "img",
198
+ "insertion",
199
+ "link",
200
+ "list",
201
+ "listbox",
202
+ "listitem",
203
+ "log",
204
+ "main",
205
+ "marquee",
206
+ "math",
207
+ "menu",
208
+ "menubar",
209
+ "menuitem",
210
+ "menuitemcheckbox",
211
+ "menuitemradio",
212
+ "meter",
213
+ "navigation",
214
+ "none",
215
+ "note",
216
+ "option",
217
+ "paragraph",
218
+ "presentation",
219
+ "progressbar",
220
+ "radio",
221
+ "radiogroup",
222
+ "region",
223
+ "row",
224
+ "rowgroup",
225
+ "rowheader",
226
+ "scrollbar",
227
+ "search",
228
+ "searchbox",
229
+ "separator",
230
+ "slider",
231
+ "spinbutton",
232
+ "status",
233
+ "strong",
234
+ "subscript",
235
+ "superscript",
236
+ "switch",
237
+ "tab",
238
+ "table",
239
+ "tablist",
240
+ "tabpanel",
241
+ "term",
242
+ "textbox",
243
+ "time",
244
+ "timer",
245
+ "toolbar",
246
+ "tooltip",
247
+ "tree",
248
+ "treegrid",
249
+ "treeitem"
250
+ ]);
251
+ var KNOWN_ARIA_ROLES_SET = new Set(KNOWN_ARIA_ROLES);
252
+
294
253
  // ../../lib/primitive/src/constants/aria/role-restricted-attributes.ts
295
254
  var ROLE_RESTRICTED_ATTRIBUTES = /* @__PURE__ */ new Map([
296
255
  [
@@ -442,16 +401,6 @@ var ROLE_RESTRICTED_ATTRIBUTES = /* @__PURE__ */ new Map([
442
401
  ]
443
402
  ]);
444
403
 
445
- // ../../lib/primitive/src/guards/foundational/is-defined.ts
446
- function isUndefined(value) {
447
- return value === void 0;
448
- }
449
-
450
- // ../../lib/primitive/src/guards/foundational/is-null.ts
451
- function isNull(value) {
452
- return value === null;
453
- }
454
-
455
404
  // ../../lib/primitive/src/guards/aria/is-aria-attribute.ts
456
405
  function isGlobalAriaAttribute(attr) {
457
406
  return GLOBAL_ARIA_ATTRIBUTES.has(attr);
@@ -473,51 +422,20 @@ function isStandaloneTag(tag) {
473
422
  return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
474
423
  }
475
424
  function getInputImplicitRole(type) {
476
- if (type == null || !(type in INPUT_TYPE_ROLE_MAP)) return void 0;
425
+ if (!isString(type) || !(type in INPUT_TYPE_ROLE_MAP)) return void 0;
477
426
  return INPUT_TYPE_ROLE_MAP[type];
478
427
  }
479
428
  function getConditionalImplicitRole(tag, ariaLabel, ariaLabelledBy) {
480
- const isNamed = typeof ariaLabel === "string" || typeof ariaLabelledBy === "string";
429
+ const isNamed = isString(ariaLabel) || isString(ariaLabelledBy);
481
430
  if (!isNamed) return void 0;
482
431
  if (tag === "section") return "region";
483
432
  if (tag === "form") return "form";
484
433
  return void 0;
485
434
  }
486
435
 
487
- // ../../lib/primitive/src/guards/children/component-id.ts
488
- var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol.for("praxis.component-default-tag");
489
-
490
- // ../../lib/primitive/src/guards/children/is-tag.ts
491
- function getAsProp(child) {
492
- if (!isObject(child) || !("props" in child)) return void 0;
493
- const props = child.props;
494
- if (!isObject(props)) return void 0;
495
- const as = props.as;
496
- return isString(as) && as !== "" ? as : void 0;
497
- }
498
- function getTag(child) {
499
- if (!isObject(child) || !("type" in child)) return void 0;
500
- const t = child.type;
501
- if (isString(t)) return t;
502
- if (typeof t === "function" || isObject(t)) {
503
- const defaultTag = t[COMPONENT_DEFAULT_TAG];
504
- if (!isString(defaultTag)) return void 0;
505
- return getAsProp(child) ?? defaultTag;
506
- }
507
- return void 0;
508
- }
509
- function isTag(...args) {
510
- if (isString(args[0])) {
511
- const set3 = new Set(args);
512
- return (child2) => {
513
- const tag2 = getTag(child2);
514
- return tag2 !== void 0 && set3.has(tag2);
515
- };
516
- }
517
- const [child, ...tags] = args;
518
- const set2 = new Set(tags);
519
- const tag = getTag(child);
520
- return tag !== void 0 && set2.has(tag);
436
+ // ../../lib/primitive/src/guards/aria/is-known-aria-role.ts
437
+ function isKnownAriaRole(value) {
438
+ return isString(value) && KNOWN_ARIA_ROLES_SET.has(value);
521
439
  }
522
440
 
523
441
  // ../../lib/contract/src/aria/aria-role-policy.ts
@@ -528,7 +446,203 @@ function getImplicitRole(tag, props) {
528
446
  if (tag === "section" || tag === "form") {
529
447
  return getConditionalImplicitRole(tag, props?.["aria-label"], props?.["aria-labelledby"]);
530
448
  }
531
- return void 0;
449
+ return void 0;
450
+ }
451
+
452
+ // ../../lib/primitive/src/tag/resolve-tag.ts
453
+ function makeResolveTag(defaultTag) {
454
+ return function tag(as) {
455
+ return as ?? defaultTag;
456
+ };
457
+ }
458
+
459
+ // ../../lib/primitive/src/utils/assert-never.ts
460
+ function assertNever(value) {
461
+ throw new Error(`Unexpected value: ${String(value)}`);
462
+ }
463
+
464
+ // ../../lib/primitive/src/utils/cn.ts
465
+ import { clsx } from "clsx";
466
+ function cn(...inputs) {
467
+ return clsx(...inputs);
468
+ }
469
+
470
+ // ../../lib/primitive/src/utils/iterate.ts
471
+ function find(iterable, callback) {
472
+ for (const value of iterable) {
473
+ const result = callback(value);
474
+ if (result != null) {
475
+ return result;
476
+ }
477
+ }
478
+ return null;
479
+ }
480
+ function some(iterable, predicate) {
481
+ for (const value of iterable) {
482
+ if (predicate(value)) return true;
483
+ }
484
+ return false;
485
+ }
486
+ function every(iterable, predicate) {
487
+ let index = 0;
488
+ for (const value of iterable) {
489
+ if (!predicate(value, index++)) {
490
+ return false;
491
+ }
492
+ }
493
+ return true;
494
+ }
495
+ function* filter(iterable, predicate) {
496
+ let index = 0;
497
+ for (const value of iterable) {
498
+ if (predicate(value, index++)) {
499
+ yield value;
500
+ }
501
+ }
502
+ }
503
+ function* map(iterable, callback) {
504
+ let index = 0;
505
+ for (const value of iterable) {
506
+ yield callback(value, index++);
507
+ }
508
+ }
509
+ function forEach(iterable, callback) {
510
+ let index = 0;
511
+ for (const value of iterable) {
512
+ callback(value, index++);
513
+ }
514
+ }
515
+ function reduce(iterable, initial, callback) {
516
+ let accumulator = initial;
517
+ let index = 0;
518
+ for (const value of iterable) {
519
+ accumulator = callback(accumulator, value, index++);
520
+ }
521
+ return accumulator;
522
+ }
523
+ function collect(iterable, callback) {
524
+ const result = {};
525
+ let index = 0;
526
+ for (const value of iterable) {
527
+ const entry = callback(value, index++);
528
+ if (entry === null) {
529
+ return null;
530
+ }
531
+ result[entry[0]] = entry[1];
532
+ }
533
+ return result;
534
+ }
535
+ function findLast(value, callback) {
536
+ for (let index = value.length - 1; index >= 0; index--) {
537
+ const result = callback(value[index], index);
538
+ if (result != null) {
539
+ return result;
540
+ }
541
+ }
542
+ return null;
543
+ }
544
+ function* items(collection) {
545
+ for (let i = 0; i < collection.length; i++) {
546
+ const item = collection.item(i);
547
+ if (item !== null) {
548
+ yield item;
549
+ }
550
+ }
551
+ }
552
+ function nodeList(list) {
553
+ return {
554
+ *[Symbol.iterator]() {
555
+ for (let i = 0; i < list.length; i++) {
556
+ const node = list.item(i);
557
+ if (node !== null) {
558
+ yield node;
559
+ }
560
+ }
561
+ }
562
+ };
563
+ }
564
+ function mapEntries(m) {
565
+ return m.entries();
566
+ }
567
+ function set(s) {
568
+ return s.values();
569
+ }
570
+ function hasOwn(object, key) {
571
+ return Object.hasOwn(object, key);
572
+ }
573
+ function* entries(object) {
574
+ for (const key in object) {
575
+ if (!hasOwn(object, key)) continue;
576
+ yield [key, object[key]];
577
+ }
578
+ }
579
+ function* keys(object) {
580
+ for (const [key] of entries(object)) {
581
+ yield key;
582
+ }
583
+ }
584
+ function* values(object) {
585
+ for (const [, value] of entries(object)) {
586
+ yield value;
587
+ }
588
+ }
589
+ function mapValues(object, callback) {
590
+ const result = {};
591
+ for (const [key, value] of entries(object)) {
592
+ result[key] = callback(value, key);
593
+ }
594
+ return result;
595
+ }
596
+ function forEachEntry(object, callback) {
597
+ for (const [key, value] of entries(object)) {
598
+ callback(key, value);
599
+ }
600
+ }
601
+ function forEachKey(object, callback) {
602
+ for (const key of keys(object)) {
603
+ callback(key);
604
+ }
605
+ }
606
+ function forEachValue(object, callback) {
607
+ for (const value of values(object)) {
608
+ callback(value);
609
+ }
610
+ }
611
+ function forEachSet(s, callback) {
612
+ for (const value of s) {
613
+ callback(value);
614
+ }
615
+ }
616
+ var iterate = Object.freeze({
617
+ entries,
618
+ filter,
619
+ find,
620
+ findLast,
621
+ forEach,
622
+ forEachEntry,
623
+ forEachKey,
624
+ forEachSet,
625
+ forEachValue,
626
+ items,
627
+ keys,
628
+ map,
629
+ mapEntries,
630
+ mapValues,
631
+ nodeList,
632
+ reduce,
633
+ collect,
634
+ set,
635
+ some,
636
+ every,
637
+ values
638
+ });
639
+
640
+ // ../../lib/primitive/src/utils/merge-props.ts
641
+ function mergeProps(defaultProps, props) {
642
+ return {
643
+ ...defaultProps ?? {},
644
+ ...props
645
+ };
532
646
  }
533
647
 
534
648
  // ../../lib/contract/src/strict/invariant-base.ts
@@ -777,18 +891,18 @@ var ContractDiagnostics = {
777
891
  message: `${context}: "${ruleName}" must be ${position}, got index ${index}`
778
892
  };
779
893
  },
780
- unknownVariantDim(component, label, dim) {
894
+ unknownVariantDim(component, label2, dim) {
781
895
  return {
782
896
  code: DiagnosticCode2.ContractUnknownVariantDim,
783
897
  category: DiagnosticCategory2.Contract,
784
- message: `${component}: ${label} references unknown variant "${dim}".`
898
+ message: `${component}: ${label2} references unknown variant "${dim}".`
785
899
  };
786
900
  },
787
- unknownVariantValue(component, label, dim, value, valid) {
901
+ unknownVariantValue(component, label2, dim, value, valid) {
788
902
  return {
789
903
  code: DiagnosticCode2.ContractUnknownVariantValue,
790
904
  category: DiagnosticCategory2.Contract,
791
- message: `${component}: ${label} sets "${dim}" to unknown value "${value}" (valid: ${valid.join(", ")}).`
905
+ message: `${component}: ${label2} sets "${dim}" to unknown value "${value}" (valid: ${valid.join(", ")}).`
792
906
  };
793
907
  },
794
908
  unknownRecipeKey(component, key) {
@@ -1586,7 +1700,7 @@ function getTypeName(value) {
1586
1700
  return primitive;
1587
1701
  }
1588
1702
  const name = value.constructor?.name;
1589
- return typeof name === "string" && name !== "Object" ? name : "object";
1703
+ return isString(name) && name !== "Object" ? name : "object";
1590
1704
  }
1591
1705
 
1592
1706
  // ../../lib/contract/src/children/normalize-child-rule.ts
@@ -1880,6 +1994,7 @@ function landmarkNameAdvisory(ctx) {
1880
1994
  if (!ctx.implicitRole || !NAMED_LANDMARK_TAGS.has(ctx.tag)) return [];
1881
1995
  return requireAccessibleName(ctx);
1882
1996
  }
1997
+ var HTML_ARIA_RULES = [landmarkRoleRule, landmarkNameAdvisory];
1883
1998
 
1884
1999
  // ../core/src/html/contracts.ts
1885
2000
  import { warnDiagnostics } from "../_shared/diagnostics.js";
@@ -2055,404 +2170,492 @@ function getHtmlPropNormalizers(tag) {
2055
2170
  return typeof tag === "string" ? HTML_FORM_NORMALIZERS.get(tag) : void 0;
2056
2171
  }
2057
2172
 
2058
- // ../../lib/styling/src/variant-pass/compile-variant-lookup.ts
2059
- function buildPrecomputedKey(props) {
2060
- return Object.entries(props).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}:${v}`).join("|");
2061
- }
2062
-
2063
- // ../../lib/styling/src/variant-pass/variant-pass.ts
2064
- function createVariantPass(activeProps, config) {
2065
- return {
2066
- name: "variant",
2067
- execute() {
2068
- const preset = typeof activeProps["preset"] === "string" ? activeProps["preset"] : void 0;
2069
- const presetDefaults = preset !== void 0 && config.presets?.[preset] !== void 0 ? config.presets[preset] : {};
2070
- const resolved = {
2071
- ...config.defaults,
2072
- ...presetDefaults,
2073
- ...activeProps
2074
- };
2075
- const classes = [];
2076
- iterate.forEachEntry(config.variants, (key, valueMap) => {
2077
- const active = resolved[key];
2078
- if (typeof active === "string") {
2079
- const cls = valueMap[active];
2080
- if (cls !== void 0) classes.push(cls);
2081
- }
2082
- });
2083
- return { context: { classes } };
2173
+ // ../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.mjs
2174
+ import { clsx as clsx2 } from "clsx";
2175
+ var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
2176
+ var cx = clsx2;
2177
+ var cva = (base, config) => (props) => {
2178
+ var _config_compoundVariants;
2179
+ if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
2180
+ const { variants, defaultVariants } = config;
2181
+ const getVariantClassNames = Object.keys(variants).map((variant) => {
2182
+ const variantProp = props === null || props === void 0 ? void 0 : props[variant];
2183
+ const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
2184
+ if (variantProp === null) return null;
2185
+ const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
2186
+ return variants[variant][variantKey];
2187
+ });
2188
+ const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param) => {
2189
+ let [key, value] = param;
2190
+ if (value === void 0) {
2191
+ return acc;
2084
2192
  }
2085
- };
2086
- }
2087
-
2088
- // ../core/src/resolver/resolver.ts
2089
- import { silentDiagnostics } from "../_shared/diagnostics.js";
2090
- function enforceAllowedAs(tag, allowedAs, diagnostics, displayName) {
2091
- if (allowedAs.includes(tag)) return;
2092
- if (!diagnostics) return;
2093
- const component = displayName ?? String(tag);
2094
- diagnostics.error(ContractDiagnostics.allowedAsViolation(String(tag), allowedAs, component));
2095
- }
2096
-
2097
- // ../../lib/adapter-utils/src/apply-prop-normalizers.ts
2098
- function applyPropNormalizers(tag, props, additional) {
2099
- const normalizers = [...getHtmlPropNormalizers(tag) ?? [], ...additional ?? []];
2100
- if (normalizers.length === 0) return props;
2101
- return normalizers.reduce((acc, fn) => ({ ...acc, ...fn(acc) }), props);
2102
- }
2103
-
2104
- // ../../lib/adapter-utils/src/define-component.ts
2105
- function defineContractComponent(options) {
2106
- return (factory) => factory(options);
2107
- }
2108
-
2109
- // ../../lib/adapter-utils/src/build-engines.ts
2110
- function buildEngines(diagnostics, childRules, context) {
2111
- return childRules?.length ? { childrenEvaluator: new ChildrenEvaluator(childRules, diagnostics, context) } : {};
2112
- }
2113
-
2114
- // ../../lib/adapter-utils/src/resolve-adapter-common-options.ts
2115
- import { throwDiagnostics, silentDiagnostics as silentDiagnostics2 } from "../_shared/diagnostics.js";
2116
- function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics) {
2117
- return {
2118
- name: options.name ?? defaultName,
2119
- diagnostics: options.enforcement?.diagnostics ?? defaultDiagnostics
2120
- };
2121
- }
2193
+ acc[key] = value;
2194
+ return acc;
2195
+ }, {});
2196
+ const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param) => {
2197
+ let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;
2198
+ return Object.entries(compoundVariantOptions).every((param2) => {
2199
+ let [key, value] = param2;
2200
+ return Array.isArray(value) ? value.includes({
2201
+ ...defaultVariants,
2202
+ ...propsWithoutUndefined
2203
+ }[key]) : {
2204
+ ...defaultVariants,
2205
+ ...propsWithoutUndefined
2206
+ }[key] === value;
2207
+ }) ? [
2208
+ ...acc,
2209
+ cvClass,
2210
+ cvClassName
2211
+ ] : acc;
2212
+ }, []);
2213
+ return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
2214
+ };
2122
2215
 
2123
- // ../../lib/adapter-utils/src/slot-validator.ts
2124
- var SlotValidator = class extends InvariantBase {
2125
- #name;
2126
- #elementTerm;
2127
- constructor(name, diagnostics, elementTerm) {
2128
- super(diagnostics);
2129
- this.#name = name;
2130
- this.#elementTerm = elementTerm;
2216
+ // ../../lib/styling/src/cva.ts
2217
+ function cva2(base, config) {
2218
+ const fn = cva(base, config);
2219
+ return (props) => cn(fn(props));
2220
+ }
2221
+
2222
+ // ../../lib/styling/src/static-class-resolver.ts
2223
+ var StaticClassResolver = class {
2224
+ #baseClass;
2225
+ #cache = /* @__PURE__ */ new Map();
2226
+ #resolveTag;
2227
+ constructor(baseClass, tagMap) {
2228
+ this.#baseClass = Array.isArray(baseClass) ? baseClass.join(" ") : baseClass;
2229
+ this.#resolveTag = tagMap ? (tag) => {
2230
+ const extra = tagMap[tag];
2231
+ if (!extra) return this.#baseClass;
2232
+ const extraStr = Array.isArray(extra) ? extra.join(" ") : extra;
2233
+ return `${this.#baseClass} ${extraStr}`;
2234
+ } : () => this.#baseClass;
2235
+ }
2236
+ resolve(tag, skipTagMap = false) {
2237
+ if (typeof tag !== "string" || skipTagMap) return this.#baseClass;
2238
+ const cached = this.#cache.get(tag);
2239
+ if (cached !== void 0) {
2240
+ this.#cache.delete(tag);
2241
+ this.#cache.set(tag, cached);
2242
+ return cached;
2243
+ }
2244
+ const result = this.#resolveTag(tag);
2245
+ this.#cache.set(tag, result);
2246
+ if (this.#cache.size > 200) {
2247
+ const lru = this.#cache.keys().next().value;
2248
+ if (lru !== void 0) this.#cache.delete(lru);
2249
+ }
2250
+ return result;
2131
2251
  }
2132
- assertExclusive() {
2133
- this.violate(SlotDiagnostics.exclusive(this.#name));
2252
+ };
2253
+
2254
+ // ../../lib/styling/src/variant-class-resolver.ts
2255
+ var VariantClassResolver = class _VariantClassResolver {
2256
+ #cvaFn;
2257
+ #recipeMap;
2258
+ #variantKeys;
2259
+ #precomputedClasses;
2260
+ #cache = /* @__PURE__ */ new Map();
2261
+ constructor(cvaFn, recipeMap, variantKeys, precomputedClasses) {
2262
+ this.#cvaFn = cvaFn ?? null;
2263
+ this.#recipeMap = Object.freeze(recipeMap ?? {});
2264
+ this.#variantKeys = variantKeys ?? null;
2265
+ this.#precomputedClasses = precomputedClasses ?? null;
2266
+ }
2267
+ resolve({ props, recipe }) {
2268
+ const normalizedKey = recipe ?? "__none__";
2269
+ const cacheKey = this.#createCacheKey(props, normalizedKey);
2270
+ if (this.#precomputedClasses !== null) {
2271
+ const precomputed = this.#precomputedClasses[cacheKey];
2272
+ if (precomputed !== void 0) return precomputed;
2273
+ }
2274
+ const cached = this.#cache.get(cacheKey);
2275
+ if (cached !== void 0) {
2276
+ this.#cache.delete(cacheKey);
2277
+ this.#cache.set(cacheKey, cached);
2278
+ return cached;
2279
+ }
2280
+ const result = this.#compute(props, recipe);
2281
+ this.#cache.set(cacheKey, result);
2282
+ if (this.#cache.size > 1e3) {
2283
+ const lru = this.#cache.keys().next().value;
2284
+ if (lru !== void 0) this.#cache.delete(lru);
2285
+ }
2286
+ return result;
2134
2287
  }
2135
- warnDiscardedChildren(count) {
2136
- this.warn(SlotDiagnostics.discardedChildren(this.#name, this.#elementTerm, count));
2288
+ #compute(props, recipe) {
2289
+ if (!this.#cvaFn) return "";
2290
+ if (!recipe) return this.#cvaFn(props);
2291
+ const preset = this.#recipeMap[recipe];
2292
+ if (!preset) return this.#cvaFn(props);
2293
+ return this.#cvaFn({ ...preset, ...props });
2294
+ }
2295
+ // When variantKeys is provided, only those keys are included in the cache key — non-variant
2296
+ // props (className, id, etc.) produce identical CVA output and must not fragment the cache.
2297
+ // Iterating #variantKeys directly (fixed Set insertion order) avoids Object.keys + filter + sort.
2298
+ // String is built incrementally to avoid a parts[] array allocation on every render.
2299
+ #createCacheKey(props, recipe) {
2300
+ if (this.#variantKeys !== null) {
2301
+ let key2 = recipe;
2302
+ iterate.forEachSet(this.#variantKeys, (k) => {
2303
+ if (k in props) key2 += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
2304
+ });
2305
+ return key2;
2306
+ }
2307
+ let key = recipe;
2308
+ iterate.forEach(Object.keys(props).sort(), (k) => {
2309
+ key += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
2310
+ });
2311
+ return key;
2137
2312
  }
2138
- assertSingleChild(count) {
2139
- this.violate(
2140
- count === 0 ? SlotDiagnostics.singleChildRequired(this.#name, this.#elementTerm) : SlotDiagnostics.singleChildExceeded(this.#name, this.#elementTerm, count)
2141
- );
2313
+ static #serializeValue(value) {
2314
+ if (value === void 0) return "u";
2315
+ if (value === null) return "n";
2316
+ if (typeof value === "boolean") return `b:${value}`;
2317
+ if (typeof value === "string") return `s:${value}`;
2318
+ return `x:${String(value)}`;
2142
2319
  }
2143
2320
  };
2144
2321
 
2145
- // ../../lib/adapter-utils/src/build-definition.ts
2146
- function buildDefinition(name, tag) {
2147
- return {
2148
- identity: {
2149
- id: name,
2150
- name,
2151
- tag
2152
- },
2153
- capabilities: {},
2154
- metadata: {},
2155
- diagnostics: []
2322
+ // ../../lib/styling/src/create-class-pipeline.ts
2323
+ function createClassPipeline(resolved) {
2324
+ const baseClass = resolved.baseClassName ?? "";
2325
+ const cvaFn = resolved.variants ? cva2("", {
2326
+ variants: resolved.variants,
2327
+ defaultVariants: resolved.defaultVariants,
2328
+ compoundVariants: resolved.compoundVariants
2329
+ }) : null;
2330
+ const variantKeys = resolved.variants ? new Set(Object.keys(resolved.variants)) : void 0;
2331
+ const staticResolver = new StaticClassResolver(baseClass, resolved.tagMap);
2332
+ const variantResolver = new VariantClassResolver(
2333
+ cvaFn,
2334
+ resolved.recipeMap,
2335
+ variantKeys,
2336
+ resolved.precomputedClasses
2337
+ );
2338
+ return function resolveClasses(tag, props, className, recipe) {
2339
+ const staticClasses = staticResolver.resolve(tag, recipe !== void 0);
2340
+ const variantClasses = variantResolver.resolve({ props, recipe });
2341
+ if (!className)
2342
+ return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
2343
+ return cn(staticClasses, variantClasses, className);
2156
2344
  };
2157
2345
  }
2158
2346
 
2159
- // ../../lib/adapter-utils/src/build-variant-config.ts
2160
- function flattenClassName(cls) {
2161
- return Array.isArray(cls) ? cls.join(" ") : cls;
2162
- }
2163
- function mapVariantRecord(source, mapper) {
2164
- return iterate.mapValues(
2165
- source,
2166
- (inner) => iterate.mapValues(inner, mapper)
2167
- );
2168
- }
2169
- function buildVariantConfig(variants, presets, defaults, compounds) {
2170
- return {
2171
- variants: mapVariantRecord(variants ?? {}, flattenClassName),
2172
- ...presets !== void 0 && Object.keys(presets).length > 0 && { presets },
2173
- ...defaults !== void 0 && Object.keys(defaults).length > 0 && { defaults },
2174
- ...compounds !== void 0 && compounds.length > 0 && {
2175
- compounds
2347
+ // ../../lib/pipeline-kit/src/factory/define-pipeline.ts
2348
+ function definePipeline(factory) {
2349
+ const cache = /* @__PURE__ */ new WeakMap();
2350
+ return (resolved) => {
2351
+ let pipeline = cache.get(resolved);
2352
+ if (!pipeline) {
2353
+ pipeline = factory(resolved);
2354
+ cache.set(resolved, pipeline);
2176
2355
  }
2356
+ return pipeline;
2177
2357
  };
2178
2358
  }
2179
2359
 
2180
- // ../../runtime/core/src/apply-attributes.ts
2181
- function applyAttributes(nodeId, incoming, decoration, removedKeys) {
2182
- const existing = decoration[nodeId] ?? {};
2183
- const next = { ...existing.attributes };
2184
- if (removedKeys !== void 0) {
2185
- iterate.forEachSet(removedKeys, (key) => {
2186
- delete next[key];
2187
- });
2188
- }
2189
- Object.assign(next, incoming);
2190
- const { attributes: _dropped, ...rest } = existing;
2191
- const nextDecoration = Object.keys(next).length > 0 ? { ...rest, attributes: next } : rest;
2192
- return { ...decoration, [nodeId]: nextDecoration };
2193
- }
2194
-
2195
- // ../../runtime/core/src/get-active-props.ts
2196
- function getActiveProps(nodeId, decoration) {
2197
- const dec = decoration[nodeId];
2198
- return { ...dec?.attributes ?? {}, ...dec?.variants ?? {} };
2360
+ // ../core/src/options/resolve-factory-options.ts
2361
+ import { silentDiagnostics } from "../_shared/diagnostics.js";
2362
+ var EMPTY_VARIANT_KEYS = /* @__PURE__ */ new Set();
2363
+ function composeNormalizers(normalizers, fn) {
2364
+ if (!normalizers?.length) return fn;
2365
+ return ((props) => {
2366
+ const patched = normalizers.reduce(
2367
+ (acc, normalizer) => ({ ...acc, ...normalizer(acc) }),
2368
+ props
2369
+ );
2370
+ return fn ? fn(patched) : patched;
2371
+ });
2199
2372
  }
2200
-
2201
- // ../../runtime/core/src/render-component.ts
2202
- function renderComponent(definition, tree, render, backend) {
2203
- return backend.render({ definition, tree, render });
2373
+ function whenDefined(key, value) {
2374
+ return value === void 0 ? {} : { [key]: value };
2375
+ }
2376
+ function resolveFactoryOptions(options = {}) {
2377
+ const { styling, enforcement } = options;
2378
+ const composedNormalizeFn = composeNormalizers(enforcement?.props, options.normalize);
2379
+ const variantKeys = styling?.variants === void 0 ? EMPTY_VARIANT_KEYS : new Set(Object.keys(styling.variants));
2380
+ return Object.freeze({
2381
+ defaultTag: options.tag ?? "div",
2382
+ diagnostics: enforcement?.diagnostics ?? silentDiagnostics,
2383
+ variantKeys,
2384
+ ...whenDefined("displayName", options.name),
2385
+ ...whenDefined("defaultProps", options.defaults),
2386
+ ...whenDefined("baseClassName", styling?.base),
2387
+ ...whenDefined("tagMap", styling?.tags),
2388
+ ...whenDefined("recipeMap", styling?.presets),
2389
+ ...whenDefined("variants", styling?.variants),
2390
+ ...whenDefined("defaultVariants", styling?.defaults),
2391
+ ...whenDefined("compoundVariants", styling?.compounds),
2392
+ ...whenDefined("normalizeFn", composedNormalizeFn),
2393
+ ...whenDefined("ariaRules", enforcement?.aria),
2394
+ ...whenDefined("childRules", enforcement?.children),
2395
+ ...whenDefined("allowedAs", enforcement?.allowedAs),
2396
+ ...whenDefined("precomputedClasses", styling?.precomputedClasses)
2397
+ });
2204
2398
  }
2205
2399
 
2206
- // ../../runtime/core/src/build-tree-context.ts
2207
- function buildNode(input, slotAssignments, seenIds, diagnostics) {
2208
- if (seenIds.has(input.id)) {
2209
- diagnostics.push({
2210
- code: "duplicate-node-id",
2211
- message: `Duplicate node id "${input.id}"`,
2212
- severity: "error"
2400
+ // ../core/src/options/validate-factory-options.ts
2401
+ function validateFactoryOptions(resolved, diagnostics) {
2402
+ if (!diagnostics.active) return;
2403
+ const name = resolved.displayName ?? "Component";
2404
+ const { variants } = resolved;
2405
+ const checkSelection = (label2, selection) => {
2406
+ iterate.forEachEntry(selection, (dim, value) => {
2407
+ if (value === void 0 || value === null) return;
2408
+ if (!variants || !Object.hasOwn(variants, dim)) {
2409
+ diagnostics.error(ContractDiagnostics.unknownVariantDim(name, label2, dim));
2410
+ return;
2411
+ }
2412
+ const states = variants[dim];
2413
+ const stateKey = String(value);
2414
+ if (!Object.hasOwn(states, stateKey)) {
2415
+ diagnostics.error(
2416
+ ContractDiagnostics.unknownVariantValue(name, label2, dim, stateKey, Object.keys(states))
2417
+ );
2418
+ }
2419
+ });
2420
+ };
2421
+ const { recipeMap } = resolved;
2422
+ if (recipeMap) {
2423
+ iterate.forEachEntry(recipeMap, (recipeKey, selection) => {
2424
+ checkSelection(`preset "${recipeKey}"`, selection);
2213
2425
  });
2214
- } else {
2215
- seenIds.add(input.id);
2216
- }
2217
- if (input.slot !== void 0) {
2218
- slotAssignments.set(input.id, input.slot);
2219
- }
2220
- const children = Object.freeze(
2221
- (input.children ?? []).map((child) => buildNode(child, slotAssignments, seenIds, diagnostics))
2222
- );
2223
- if (input.kind === "native") {
2224
- return Object.freeze({ kind: "native", id: input.id, tag: input.tag, children });
2225
2426
  }
2226
- return Object.freeze({ kind: "component", id: input.id, children });
2227
- }
2228
- function buildTreeContext(root) {
2229
- const slotAssignments = /* @__PURE__ */ new Map();
2230
- const diagnostics = [];
2231
- const rootNode = buildNode(root, slotAssignments, /* @__PURE__ */ new Set(), diagnostics);
2232
- return Object.freeze({ root: rootNode, slotAssignments, diagnostics });
2233
- }
2234
-
2235
- // ../../runtime/core/src/build-render-context.ts
2236
- function buildRenderContext(decoration = {}) {
2237
- return { decoration: new Map(Object.entries(decoration)) };
2427
+ if (resolved.defaultVariants) checkSelection("defaults", resolved.defaultVariants);
2238
2428
  }
2239
2429
 
2240
- // ../../lib/adapter-utils/src/resolve-compounds.ts
2241
- function matchesCompound(active, compound) {
2242
- const { class: _, ...conditions } = compound;
2243
- return Object.entries(conditions).every(([key, expected]) => {
2244
- const actual = active[key];
2245
- return Array.isArray(expected) ? expected.includes(actual) : actual === expected;
2246
- });
2430
+ // ../core/src/options/validate-render-props.ts
2431
+ function label(name) {
2432
+ return name ? `[${name}]` : "[createContractComponent]";
2247
2433
  }
2248
- function resolveCompounds(active, compounds) {
2249
- if (!compounds?.length) return [];
2250
- const out = [];
2251
- iterate.forEach(compounds, (compound) => {
2252
- if (matchesCompound(active, compound)) {
2253
- out.push(flattenClassName(compound.class));
2254
- }
2255
- });
2256
- return out;
2434
+ function validateRenderProps(diagnostics, options, props, recipeKey) {
2435
+ const { recipeMap, variants, displayName } = options;
2436
+ const tag = label(displayName);
2437
+ if (recipeKey !== void 0 && (!recipeMap || !Object.hasOwn(recipeMap, recipeKey))) {
2438
+ diagnostics.error(ContractDiagnostics.unknownRecipeKey(tag, recipeKey));
2439
+ }
2440
+ if (variants) {
2441
+ iterate.forEachKey(variants, (key) => {
2442
+ if (!Object.hasOwn(props, key)) return;
2443
+ const value = props[key];
2444
+ if (value === void 0 || value === null) return;
2445
+ const dim = variants[key];
2446
+ if (dim && !Object.hasOwn(dim, String(value))) {
2447
+ diagnostics.error(ContractDiagnostics.invalidVariantValue(tag, key, String(value)));
2448
+ }
2449
+ });
2450
+ }
2257
2451
  }
2258
2452
 
2259
- // ../../lib/adapter-utils/src/resolve-classes.ts
2260
- function resolveClasses(decoration, variantConfig, variantDefaults, recipe, compounds, variantLookup) {
2261
- const active = getActiveProps("root", decoration);
2262
- if (variantLookup !== void 0 && recipe === void 0) {
2263
- const activeVariants = {};
2264
- iterate.forEachKey(variantConfig.variants, (key) => {
2265
- const value = active[key];
2266
- if (typeof value === "string") activeVariants[key] = value;
2267
- });
2268
- const lookupKey = buildPrecomputedKey(activeVariants);
2269
- const precomputedValue = variantLookup[lookupKey];
2270
- if (precomputedValue !== void 0) {
2271
- return {
2272
- variantClasses: precomputedValue !== "" ? [precomputedValue] : [],
2273
- compoundClasses: []
2274
- };
2275
- }
2453
+ // ../core/src/factory/plugin-invariants.ts
2454
+ import { throwDiagnostics } from "../_shared/diagnostics.js";
2455
+
2456
+ // ../core/src/factory/plugin-diagnostics.ts
2457
+ import { DiagnosticCategory as DiagnosticCategory5, DiagnosticCode as DiagnosticCode5 } from "../_shared/diagnostics.js";
2458
+ var PluginDiagnostics = {
2459
+ invalidShape(received) {
2460
+ const got = received === null ? "null" : typeof received;
2461
+ return {
2462
+ code: DiagnosticCode5.PluginInvalidShape,
2463
+ category: DiagnosticCategory5.Internal,
2464
+ message: `[praxis-kit] Plugin factory must return an object with a 'pipeline' function. Got: ${got}.`
2465
+ };
2466
+ },
2467
+ pipelineReturnType(received) {
2468
+ const got = received === null ? "null" : Array.isArray(received) ? "array" : typeof received;
2469
+ return {
2470
+ code: DiagnosticCode5.PluginPipelineReturnType,
2471
+ category: DiagnosticCategory5.Internal,
2472
+ message: `[praxis-kit] Plugin pipeline must return a string. Got: ${got}.`
2473
+ };
2276
2474
  }
2277
- const passInput = recipe !== void 0 ? { ...active, preset: recipe } : active;
2278
- const { context } = createVariantPass(passInput, variantConfig).execute({ classes: [] });
2279
- const variantClasses = context.classes;
2280
- const presetOverrides = recipe !== void 0 ? variantConfig.presets?.[recipe] ?? {} : {};
2281
- const resolvedValues = {
2282
- ...variantDefaults,
2283
- ...presetOverrides,
2284
- ...active
2475
+ };
2476
+
2477
+ // ../core/src/factory/plugin-invariants.ts
2478
+ function assertPluginShape(result) {
2479
+ if (result === null || typeof result !== "object")
2480
+ throwDiagnostics.error(PluginDiagnostics.invalidShape(result));
2481
+ const plugin = result;
2482
+ if (typeof plugin.pipeline !== "function")
2483
+ throwDiagnostics.error(PluginDiagnostics.invalidShape(result));
2484
+ }
2485
+ function guardPipeline(pipeline) {
2486
+ if (process.env.NODE_ENV === "production") return pipeline;
2487
+ return function guardedPipeline(tag, props, className, recipe) {
2488
+ const result = pipeline(tag, props, className, recipe);
2489
+ if (typeof result !== "string")
2490
+ throwDiagnostics.error(PluginDiagnostics.pipelineReturnType(result));
2491
+ return result;
2285
2492
  };
2286
- const compoundClasses = resolveCompounds(resolvedValues, compounds);
2287
- return { variantClasses, compoundClasses };
2288
2493
  }
2289
2494
 
2290
- // ../../lib/adapter-utils/src/build-pipeline.ts
2291
- function buildStylePipeline(variants, presets, defaults, compounds, variantLookup) {
2292
- if (variants === void 0 && compounds === void 0 && presets === void 0 && variantLookup === void 0) {
2293
- return void 0;
2495
+ // ../core/src/factory/create-polymorphic2.ts
2496
+ var createTagPipeline = (resolved) => makeResolveTag(resolved.defaultTag);
2497
+ var createPropsPipeline = (resolved) => (props) => mergeProps(resolved.defaultProps, props);
2498
+ var createHtmlPropNormalizersPipeline = () => getHtmlPropNormalizers;
2499
+ var createHtmlChildrenEvaluatorPipeline = () => getHtmlChildrenEvaluator;
2500
+ var createStylingClassPipeline = (resolved) => createClassPipeline(resolved);
2501
+ function resolveAriaRules(resolved) {
2502
+ return [.../* @__PURE__ */ new Set([...HTML_ARIA_RULES, ...resolved.ariaRules ?? []])];
2503
+ }
2504
+ var createAriaPipeline = (resolved) => {
2505
+ const rules = resolveAriaRules(resolved);
2506
+ const engine = new AriaPolicyEngine(resolved.diagnostics, rules.length ? { rules } : void 0);
2507
+ return (tag, props) => engine.validate(tag, props);
2508
+ };
2509
+ var memoizedTagPipeline = definePipeline(createTagPipeline);
2510
+ var memoizedPropsPipeline = definePipeline(createPropsPipeline);
2511
+ var memoizedHtmlPropNormalizersPipeline = definePipeline(createHtmlPropNormalizersPipeline);
2512
+ var memoizedHtmlChildrenEvaluatorPipeline = definePipeline(createHtmlChildrenEvaluatorPipeline);
2513
+ var memoizedClassPipeline = definePipeline(createStylingClassPipeline);
2514
+ var memoizedAriaPipeline = definePipeline(createAriaPipeline);
2515
+ function resolveAriaPassthrough(_tag, props) {
2516
+ return { props };
2517
+ }
2518
+ function resolveClassPlugin(factory, resolved, diagnostics) {
2519
+ if (!factory) return { pluginResult: void 0, classPipeline: memoizedClassPipeline(resolved) };
2520
+ const pluginResult = factory(resolved, diagnostics);
2521
+ assertPluginShape(pluginResult);
2522
+ return { pluginResult, classPipeline: guardPipeline(pluginResult.pipeline) };
2523
+ }
2524
+ function createPolymorphic2(options = {}) {
2525
+ const baseResolved = resolveFactoryOptions(options);
2526
+ const anyBaseResolved = baseResolved;
2527
+ const resolved = Object.freeze({
2528
+ ...baseResolved,
2529
+ htmlPropNormalizersFn: memoizedHtmlPropNormalizersPipeline(anyBaseResolved),
2530
+ htmlChildrenEvaluatorFn: memoizedHtmlChildrenEvaluatorPipeline(anyBaseResolved)
2531
+ });
2532
+ const anyResolved = resolved;
2533
+ if (process.env.NODE_ENV !== "production") {
2534
+ validateFactoryOptions(resolved, resolved.diagnostics);
2294
2535
  }
2295
- const variantConfig = buildVariantConfig(variants, presets, defaults, compounds);
2296
- return {
2297
- execute(decoration, recipe) {
2298
- return resolveClasses(decoration, variantConfig, defaults, recipe, compounds, variantLookup);
2536
+ const { pluginResult, classPipeline } = resolveClassPlugin(
2537
+ options.styling?.plugin,
2538
+ anyResolved,
2539
+ resolved.diagnostics
2540
+ );
2541
+ const resolveTag2 = memoizedTagPipeline(anyResolved);
2542
+ const resolveProps = memoizedPropsPipeline(anyResolved);
2543
+ const resolveAriaFn = options.enforcement !== void 0 ? memoizedAriaPipeline(anyResolved) : resolveAriaPassthrough;
2544
+ const methods = {
2545
+ resolveTag: resolveTag2,
2546
+ resolveProps,
2547
+ resolveClasses(tag, props, className, recipe) {
2548
+ if (process.env.NODE_ENV !== "production") {
2549
+ validateRenderProps(resolved.diagnostics, resolved, props, recipe);
2550
+ }
2551
+ return classPipeline(tag, props, className, recipe);
2552
+ },
2553
+ resolveAria(tag, props) {
2554
+ return resolveAriaFn(tag, props);
2299
2555
  }
2300
2556
  };
2557
+ const runtimeObject = pluginResult ? { ...methods, options: resolved, hasStyling: true, classPlugin: pluginResult } : { ...methods, options: resolved };
2558
+ return runtimeObject;
2301
2559
  }
2302
2560
 
2303
- // ../../lib/adapter-utils/src/join-classes.ts
2304
- function joinClasses(...classes) {
2305
- return classes.filter(Boolean).join(" ");
2561
+ // ../core/src/resolver/resolver.ts
2562
+ import { silentDiagnostics as silentDiagnostics2 } from "../_shared/diagnostics.js";
2563
+ function enforceAllowedAs(tag, allowedAs, diagnostics, displayName) {
2564
+ if (allowedAs.includes(tag)) return;
2565
+ if (!diagnostics) return;
2566
+ const component = displayName ?? String(tag);
2567
+ diagnostics.error(ContractDiagnostics.allowedAsViolation(String(tag), allowedAs, component));
2306
2568
  }
2307
2569
 
2308
- // ../../lib/adapter-utils/src/decoration-utils.ts
2309
- function withAttributes(dec, attributes) {
2310
- const { attributes: _a, ...rest } = dec;
2311
- return attributes !== void 0 ? { ...rest, attributes } : rest;
2570
+ // ../../lib/adapter-utils/src/runtime/build-core-runtime.ts
2571
+ var EMPTY_SET = /* @__PURE__ */ new Set();
2572
+ function buildCoreRuntime(normalized) {
2573
+ const runtime = createPolymorphic2(normalized);
2574
+ const ownedKeys = "classPlugin" in runtime ? runtime.classPlugin.ownedKeys ?? EMPTY_SET : EMPTY_SET;
2575
+ return { runtime, ownedKeys };
2312
2576
  }
2313
2577
 
2314
- // ../../lib/adapter-utils/src/apply-aria.ts
2315
- function applyAria(decoration, tag, ariaEngine) {
2316
- if (ariaEngine === void 0) return decoration;
2317
- const dec = decoration["root"];
2318
- if (dec?.attributes === void 0) return decoration;
2319
- const result = ariaEngine.validate(tag, dec.attributes);
2320
- const cleaned = result.props;
2321
- return {
2322
- ...decoration,
2323
- root: withAttributes(dec, Object.keys(cleaned).length > 0 ? cleaned : void 0)
2324
- };
2578
+ // ../../lib/adapter-utils/src/runtime/build-engines.ts
2579
+ function buildEngines(diagnostics, childRules, context) {
2580
+ return childRules?.length ? { childrenEvaluator: new ChildrenEvaluator(childRules, diagnostics, context) } : {};
2325
2581
  }
2326
2582
 
2327
- // ../../lib/adapter-utils/src/apply-filter-props.ts
2328
- function applyFilterProps(decoration, filterFn, variantKeys) {
2329
- if (filterFn === void 0) return decoration;
2330
- const dec = decoration["root"];
2331
- if (dec?.attributes === void 0) return decoration;
2332
- const kept = Object.fromEntries(
2333
- Object.entries(dec.attributes).filter(([k]) => !filterFn(k, variantKeys))
2334
- );
2583
+ // ../../lib/adapter-utils/src/runtime/resolve-adapter-common-options.ts
2584
+ import { throwDiagnostics as throwDiagnostics2, silentDiagnostics as silentDiagnostics3 } from "../_shared/diagnostics.js";
2585
+ function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics2) {
2335
2586
  return {
2336
- ...decoration,
2337
- root: withAttributes(dec, Object.keys(kept).length > 0 ? kept : void 0)
2587
+ name: options.name ?? defaultName,
2588
+ diagnostics: options.enforcement?.diagnostics ?? defaultDiagnostics
2338
2589
  };
2339
2590
  }
2340
2591
 
2341
- // ../../adapters/vue/src/backend/extract-decoration.ts
2342
- function isStyleValue(v) {
2343
- return isString(v) || isNumber(v);
2344
- }
2345
- function isAttributeValue(v) {
2346
- return isString(v) || isNumber(v) || typeof v === "boolean";
2347
- }
2348
- function assignIfNotEmpty(target, key, value) {
2349
- if (Object.keys(value).length > 0) {
2350
- target[key] = value;
2351
- }
2352
- }
2353
- function extractStyles(value, styles) {
2354
- if (!isObject(value)) return false;
2355
- iterate.forEachEntry(value, (k, v) => {
2356
- if (isStyleValue(v)) {
2357
- styles[k] = v;
2358
- }
2592
+ // ../../lib/adapter-utils/src/props/apply-filter.ts
2593
+ function applyFilter(props, filterProps, variantKeys) {
2594
+ const out = {};
2595
+ iterate.forEachEntry(props, (k) => {
2596
+ if (!Object.hasOwn(props, k)) return;
2597
+ if (filterProps(k, variantKeys)) return;
2598
+ out[k] = props[k];
2359
2599
  });
2360
- return true;
2361
- }
2362
- function extractListener(key, value, listeners) {
2363
- if (!key.startsWith("on") || !isFunction(value)) {
2364
- return false;
2365
- }
2366
- listeners[key] = value;
2367
- return true;
2600
+ return out;
2368
2601
  }
2369
- function extractAttributeOrVariant(key, value, attributes, variants, variantKeys) {
2370
- if (variantKeys?.has(key)) {
2371
- variants[key] = value;
2372
- } else {
2373
- attributes[key] = value;
2374
- }
2375
- }
2376
- function extractDecoration(props, variantKeys) {
2377
- const attributes = {};
2378
- const styles = {};
2379
- const listeners = {};
2380
- const variants = {};
2381
- const dec = {};
2382
- iterate.forEachEntry(props, (key, value) => {
2383
- if (key === "children" || key === "slot" || key === "ref") return;
2384
- if (key === "style" && extractStyles(value, styles)) return;
2385
- if (extractListener(key, value, listeners)) return;
2386
- if (isAttributeValue(value)) {
2387
- extractAttributeOrVariant(key, value, attributes, variants, variantKeys);
2388
- }
2389
- });
2390
- assignIfNotEmpty(dec, "attributes", attributes);
2391
- assignIfNotEmpty(dec, "styles", styles);
2392
- assignIfNotEmpty(dec, "listeners", listeners);
2393
- assignIfNotEmpty(dec, "variants", variants);
2394
- const ref = props.ref;
2395
- if (ref !== void 0) {
2396
- dec.ref = ref;
2602
+
2603
+ // ../../lib/adapter-utils/src/props/compose-filter.ts
2604
+ function composeFilter(ownedKeys, filterProps) {
2605
+ const defaultFilter = (key, variantKeys) => variantKeys.has(key) || ownedKeys.has(key);
2606
+ if (!filterProps) {
2607
+ return defaultFilter;
2397
2608
  }
2398
- return dec;
2609
+ return (key, variantKeys) => defaultFilter(key, variantKeys) || filterProps(key, variantKeys);
2399
2610
  }
2400
2611
 
2401
- // ../../adapters/vue/src/helpers/render-normally.ts
2402
- import { h as h2 } from "vue";
2403
-
2404
- // ../../adapters/vue/src/backend/vue-backend.ts
2405
- import { Fragment, h } from "vue";
2612
+ // ../../lib/adapter-utils/src/slot/slot-validator.ts
2613
+ var SlotValidator = class extends InvariantBase {
2614
+ #name;
2615
+ #elementTerm;
2616
+ constructor(name, diagnostics, elementTerm) {
2617
+ super(diagnostics);
2618
+ this.#name = name;
2619
+ this.#elementTerm = elementTerm;
2620
+ }
2621
+ assertExclusive() {
2622
+ this.violate(SlotDiagnostics.exclusive(this.#name));
2623
+ }
2624
+ warnDiscardedChildren(count) {
2625
+ this.warn(SlotDiagnostics.discardedChildren(this.#name, this.#elementTerm, count));
2626
+ }
2627
+ assertSingleChild(count) {
2628
+ this.violate(
2629
+ count === 0 ? SlotDiagnostics.singleChildRequired(this.#name, this.#elementTerm) : SlotDiagnostics.singleChildExceeded(this.#name, this.#elementTerm, count)
2630
+ );
2631
+ }
2632
+ };
2406
2633
 
2407
- // ../../adapters/vue/src/backend/build-props.ts
2408
- function buildPropsFromDecoration(id, decoration) {
2634
+ // ../../adapters/vue/src/build-runtime.ts
2635
+ function normalizeOptions(options) {
2409
2636
  return {
2410
- key: id,
2411
- ...decoration?.attributes,
2412
- ...decoration?.styles !== void 0 ? { style: decoration.styles } : {},
2413
- ...decoration?.listeners,
2414
- ...decoration?.ref !== void 0 ? { ref: decoration.ref } : {}
2637
+ ...options,
2638
+ ...resolveAdapterCommonOptions(options)
2415
2639
  };
2416
2640
  }
2417
-
2418
- // ../../adapters/vue/src/backend/vue-backend.ts
2419
- var MULTI_WORD_EVENT_RE = /^on[A-Z][a-z]+[A-Z]/;
2420
- function normalizeListenerKeys(listeners) {
2421
- const out = {};
2422
- for (const k in listeners) {
2423
- out[MULTI_WORD_EVENT_RE.test(k) ? "on" + k.slice(2).toLowerCase() : k] = listeners[k];
2424
- }
2425
- return out;
2426
- }
2427
- function renderNode(node, render, isRoot) {
2428
- const children = node.children.map((child) => renderNode(child, render, false));
2429
- if (node.kind === "component") {
2430
- return h(Fragment, isRoot ? null : { key: node.id }, children);
2431
- }
2432
- const decoration = render.decoration.get(node.id);
2433
- const base = buildPropsFromDecoration(isRoot ? "" : node.id, decoration);
2434
- const { key: _key, ...rest } = base;
2435
- const props = {
2436
- ...isRoot ? {} : { key: node.id },
2437
- ...rest,
2438
- ...decoration?.listeners !== void 0 ? normalizeListenerKeys(decoration.listeners) : {}
2641
+ function buildRuntime(options) {
2642
+ const normalized = normalizeOptions(options);
2643
+ const { runtime, ownedKeys } = buildCoreRuntime(normalized);
2644
+ const { diagnostics, enforcement, filterProps: userFilter, name } = normalized;
2645
+ const { childrenEvaluator } = buildEngines(diagnostics, enforcement?.children, name);
2646
+ const filterProps = composeFilter(ownedKeys, userFilter);
2647
+ const slotValidator = new SlotValidator(name, diagnostics, "VNode");
2648
+ const built = {
2649
+ runtime,
2650
+ filterProps,
2651
+ slotValidator,
2652
+ ...childrenEvaluator !== void 0 && { childrenEvaluator }
2439
2653
  };
2440
- return h(node.tag, props, children.length > 0 ? children : void 0);
2654
+ return built;
2441
2655
  }
2442
- var vueBackend = {
2443
- render(context) {
2444
- return renderNode(context.tree.root, context.render, true);
2445
- }
2446
- };
2447
2656
 
2448
- // ../../adapters/vue/src/helpers/render-normally.ts
2449
- function renderNormally(definition, tag, decoration, slots) {
2450
- const treeCtx = buildTreeContext({ kind: "native", tag, id: "root", children: [] });
2451
- const rendered = renderComponent(definition, treeCtx, buildRenderContext(decoration), vueBackend);
2452
- if (slots?.default === void 0) return rendered;
2453
- const { key: _key, ...props } = rendered.props ?? {};
2454
- return h2(tag, props, { default: slots.default });
2455
- }
2657
+ // ../../adapters/vue/src/render.ts
2658
+ import { cloneVNode, h as h3 } from "vue";
2456
2659
 
2457
2660
  // ../../adapters/vue/src/normalize-children.ts
2458
2661
  import { isVNode } from "vue";
@@ -2462,17 +2665,19 @@ function normalizeChildren(slots) {
2462
2665
  return { vnodes, discarded: raw.length - vnodes.length };
2463
2666
  }
2464
2667
 
2668
+ // ../../adapters/vue/src/slot/extractSlottable.ts
2669
+ import { h as h2, Fragment as Fragment2 } from "vue";
2670
+
2465
2671
  // ../../adapters/vue/src/slot/Slottable.ts
2466
- import { defineComponent, h as h3, Fragment as Fragment2 } from "vue";
2672
+ import { defineComponent, h, Fragment } from "vue";
2467
2673
  var Slottable = defineComponent({
2468
2674
  name: "Slottable",
2469
2675
  setup(_, { slots }) {
2470
- return () => h3(Fragment2, null, slots.default?.());
2676
+ return () => h(Fragment, null, slots.default?.());
2471
2677
  }
2472
2678
  });
2473
2679
 
2474
2680
  // ../../adapters/vue/src/slot/extractSlottable.ts
2475
- import { h as h4, Fragment as Fragment3 } from "vue";
2476
2681
  function isSlottableVNode(vnode) {
2477
2682
  return vnode.type === Slottable;
2478
2683
  }
@@ -2495,127 +2700,123 @@ function extractSlottable(children) {
2495
2700
  child,
2496
2701
  rebuild(merged) {
2497
2702
  const out = children.map((node, i) => i === index ? merged : node);
2498
- return h4(Fragment3, null, out);
2703
+ return h2(Fragment2, null, out);
2499
2704
  }
2500
2705
  };
2501
2706
  }
2502
2707
 
2708
+ // ../../adapters/vue/src/render.ts
2709
+ var MULTI_WORD_EVENT_RE = /^on[A-Z][a-z]+[A-Z]/;
2710
+ function normalizeListenerKeys(props) {
2711
+ const out = {};
2712
+ for (const k in props) {
2713
+ out[MULTI_WORD_EVENT_RE.test(k) ? "on" + k.slice(2).toLowerCase() : k] = props[k];
2714
+ }
2715
+ return out;
2716
+ }
2717
+ function isAttributeValue(v) {
2718
+ return isString(v) || isNumber(v) || typeof v === "boolean";
2719
+ }
2720
+ function pickAttributes(props) {
2721
+ const out = {};
2722
+ for (const k in props) {
2723
+ if (isAttributeValue(props[k])) out[k] = props[k];
2724
+ }
2725
+ return out;
2726
+ }
2727
+ function prepareRenderState(runtime, attrs, filterProps) {
2728
+ const { as, asChild, class: callerClass, recipe, ...rest } = attrs;
2729
+ const tag = typeof as === "string" ? as : runtime.options.defaultTag;
2730
+ if (runtime.options.allowedAs !== void 0) {
2731
+ enforceAllowedAs(
2732
+ tag,
2733
+ runtime.options.allowedAs,
2734
+ runtime.options.diagnostics,
2735
+ runtime.options.displayName
2736
+ );
2737
+ }
2738
+ const mergedProps = runtime.resolveProps(rest);
2739
+ const htmlNormalizers = runtime.options.htmlPropNormalizersFn?.(tag);
2740
+ const htmlNormalizedProps = htmlNormalizers?.length ? htmlNormalizers.reduce((acc, fn) => ({ ...acc, ...fn(acc) }), mergedProps) : mergedProps;
2741
+ const normalizedProps = runtime.options.normalizeFn ? runtime.options.normalizeFn(htmlNormalizedProps) : htmlNormalizedProps;
2742
+ const className = runtime.resolveClasses(tag, normalizedProps, callerClass, recipe);
2743
+ const filteredProps = applyFilter(normalizedProps, filterProps, runtime.options.variantKeys);
2744
+ return {
2745
+ tag,
2746
+ directives: {
2747
+ ...typeof as === "string" && { as },
2748
+ ...asChild !== void 0 && { asChild }
2749
+ },
2750
+ props: filteredProps,
2751
+ className
2752
+ };
2753
+ }
2754
+ function buildElementProps(props, className) {
2755
+ const { role, ...rest } = props;
2756
+ return {
2757
+ ...normalizeListenerKeys(rest),
2758
+ class: className,
2759
+ ...isKnownAriaRole(role) && { role }
2760
+ };
2761
+ }
2762
+ function renderIntrinsic(state, runtime, slots) {
2763
+ const elementProps = buildElementProps(state.props, state.className);
2764
+ const domProps = runtime.resolveAria(state.tag, elementProps).props;
2765
+ return h3(state.tag, domProps, slots.default ? { default: slots.default } : void 0);
2766
+ }
2767
+ function validateSlotDirectives(directives, validator) {
2768
+ const { as, asChild } = directives;
2769
+ if (!asChild) return false;
2770
+ if (as !== void 0) {
2771
+ validator.assertExclusive();
2772
+ return false;
2773
+ }
2774
+ return true;
2775
+ }
2776
+ function tryRenderAsChild(state, children, discarded, validator) {
2777
+ if (!validateSlotDirectives(state.directives, validator)) return null;
2778
+ if (discarded > 0) validator.warnDiscardedChildren(discarded);
2779
+ const attrs = { ...pickAttributes(state.props), class: state.className };
2780
+ const slottable = extractSlottable(children);
2781
+ if (slottable) return slottable.rebuild(cloneVNode(slottable.child, attrs));
2782
+ if (children.length === 1 && children[0] !== void 0) {
2783
+ return cloneVNode(children[0], attrs);
2784
+ }
2785
+ validator.assertSingleChild(children.length);
2786
+ return null;
2787
+ }
2788
+ function render({
2789
+ runtime,
2790
+ state,
2791
+ slots,
2792
+ slotValidator,
2793
+ childrenEvaluator
2794
+ }) {
2795
+ const { vnodes: children, discarded } = normalizeChildren(slots);
2796
+ if (process.env.NODE_ENV !== "production") {
2797
+ childrenEvaluator?.evaluate(children);
2798
+ }
2799
+ const slotResult = tryRenderAsChild(state, children, discarded, slotValidator);
2800
+ return slotResult ?? renderIntrinsic(state, runtime, slots);
2801
+ }
2802
+
2503
2803
  // ../../adapters/vue/src/create-contract-component.ts
2504
- var EMPTY_SET = /* @__PURE__ */ new Set();
2505
2804
  function createContractComponent(options) {
2506
- const resolved = resolveAdapterCommonOptions(options);
2507
- const displayName = resolved.name;
2508
- const defaultTag = options.tag ?? "div";
2509
- const definition = buildDefinition(displayName, defaultTag);
2510
- const variantKeys = new Set(Object.keys(options.styling?.variants ?? {}));
2511
- const domDefaults = options.defaults;
2512
- const stylePipeline = buildStylePipeline(
2513
- options.styling?.variants,
2514
- options.styling?.presets,
2515
- options.styling?.defaults ?? {},
2516
- options.styling?.compounds,
2517
- void 0
2518
- );
2519
- const base = options.styling?.base !== void 0 ? flattenClassName(options.styling.base) : void 0;
2520
- const filterFn = options.filterProps;
2521
- const allowedAs = options.enforcement?.allowedAs;
2522
- const normalizeFn = options.normalize;
2523
- const enforcementNormalizers = options.enforcement?.props;
2524
- const classPlugin = options.styling?.plugin !== void 0 ? options.styling.plugin(
2525
- options.styling,
2526
- resolved.diagnostics
2527
- ) : void 0;
2528
- const pluginKeys = classPlugin?.ownedKeys ?? EMPTY_SET;
2529
- const { childrenEvaluator: explicitEvaluator } = buildEngines(
2530
- resolved.diagnostics,
2531
- options.enforcement?.children,
2532
- displayName
2533
- );
2534
- const ariaEngine = options.enforcement !== void 0 ? new AriaPolicyEngine(resolved.diagnostics) : void 0;
2535
- const slotValidator = new SlotValidator(displayName, resolved.diagnostics, "VNode");
2805
+ const bundle = buildRuntime(options);
2536
2806
  const Component = defineComponent2({
2537
- name: displayName,
2807
+ // normalizeOptions always supplies `name`, so displayName is always defined here —
2808
+ // the fallback only satisfies the type, which allows it to be absent in general.
2809
+ name: bundle.runtime.options.displayName ?? "PolymorphicComponent",
2538
2810
  inheritAttrs: false,
2539
2811
  setup(_, { attrs, slots }) {
2540
- const decorationState = computed(() => {
2541
- const {
2542
- as,
2543
- asChild,
2544
- class: callerClass,
2545
- recipe,
2546
- ...ownProps
2547
- } = attrs;
2548
- const tag = typeof as === "string" ? as : defaultTag;
2549
- if (allowedAs !== void 0)
2550
- enforceAllowedAs(tag, allowedAs, resolved.diagnostics, displayName);
2551
- const rawBaseProps = domDefaults !== void 0 ? { ...domDefaults, ...ownProps } : ownProps;
2552
- const normalizedProps = applyPropNormalizers(tag, rawBaseProps, enforcementNormalizers);
2553
- const baseProps = normalizeFn !== void 0 ? normalizeFn(normalizedProps) : normalizedProps;
2554
- const pluginProps = {};
2555
- const propsForExtraction = pluginKeys.size > 0 ? Object.fromEntries(
2556
- Object.entries(baseProps).filter(([k]) => {
2557
- if (pluginKeys.has(k)) {
2558
- pluginProps[k] = baseProps[k];
2559
- return false;
2560
- }
2561
- return true;
2562
- })
2563
- ) : baseProps;
2564
- const rootDec = extractDecoration(propsForExtraction, variantKeys);
2565
- const decoration = applyAria(
2566
- Object.keys(rootDec).length > 0 ? { root: rootDec } : {},
2567
- tag,
2568
- ariaEngine
2569
- );
2570
- const recipeName = typeof recipe === "string" ? recipe : void 0;
2571
- const { variantClasses, compoundClasses } = stylePipeline ? stylePipeline.execute(decoration, recipeName) : { variantClasses: [], compoundClasses: [] };
2572
- const rawClassName = joinClasses(
2573
- base,
2574
- ...variantClasses,
2575
- ...compoundClasses,
2576
- typeof callerClass === "string" ? callerClass : void 0
2577
- );
2578
- const className = classPlugin !== void 0 ? classPlugin.pipeline(tag, pluginProps, rawClassName, recipeName) : rawClassName;
2579
- let finalDecoration = className ? applyAttributes("root", { className }, decoration, variantKeys) : decoration;
2580
- finalDecoration = applyFilterProps(finalDecoration, filterFn, variantKeys);
2581
- return { tag, asChild, as, finalDecoration, className };
2582
- });
2583
- return () => {
2584
- const { tag, asChild, as, finalDecoration, className } = decorationState.value;
2585
- const { vnodes: children, discarded } = normalizeChildren(slots);
2586
- if (process.env.NODE_ENV !== "production") {
2587
- const childEval = explicitEvaluator ?? getHtmlChildrenEvaluator(tag);
2588
- childEval?.evaluate(children);
2589
- }
2590
- if (asChild === true) {
2591
- if (typeof as === "string") {
2592
- slotValidator.assertExclusive();
2593
- } else {
2594
- if (discarded > 0) slotValidator.warnDiscardedChildren(discarded);
2595
- const extraction = extractSlottable(children);
2596
- if (extraction) {
2597
- return extraction.rebuild(
2598
- cloneVNode(extraction.child, {
2599
- ...finalDecoration["root"]?.attributes,
2600
- class: className
2601
- })
2602
- );
2603
- }
2604
- if (children.length === 1 && children[0] !== void 0) {
2605
- return cloneVNode(children[0], {
2606
- ...finalDecoration["root"]?.attributes,
2607
- class: className
2608
- });
2609
- }
2610
- slotValidator.assertSingleChild(children.length);
2611
- return null;
2612
- }
2613
- }
2614
- return renderNormally(definition, tag, finalDecoration, slots);
2615
- };
2812
+ const state = computed(
2813
+ () => prepareRenderState(bundle.runtime, attrs, bundle.filterProps)
2814
+ );
2815
+ return () => render({ ...bundle, state: state.value, slots });
2616
2816
  }
2617
2817
  });
2618
2818
  applyDisplayName(Component, options.name);
2819
+ const defaultTag = bundle.runtime.options.defaultTag;
2619
2820
  if (typeof defaultTag === "string") {
2620
2821
  Object.assign(Component, { [COMPONENT_DEFAULT_TAG]: defaultTag });
2621
2822
  }