praxis-kit 4.0.3 → 4.1.1

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,14 +1,16 @@
1
- // ../../lib/adapter-utils/src/define-component.ts
1
+ // ../../lib/adapter-utils/src/runtime/define-component.ts
2
2
  function defineContractComponent(options) {
3
3
  return (factory) => factory(options);
4
4
  }
5
5
 
6
- // ../../lib/adapter-utils/src/invariant.ts
7
- function panic(message) {
8
- throw new Error(message);
6
+ // ../../lib/primitive/src/guards/foundational/is-defined.ts
7
+ function isUndefined(value) {
8
+ return value === void 0;
9
9
  }
10
- function invariant(condition, message) {
11
- if (!condition) panic(message);
10
+
11
+ // ../../lib/primitive/src/guards/foundational/is-null.ts
12
+ function isNull(value) {
13
+ return value === null;
12
14
  }
13
15
 
14
16
  // ../../lib/primitive/src/utils/is-object.ts
@@ -36,197 +38,6 @@ function isPlainObject(value) {
36
38
  return proto === Object.prototype || proto === null;
37
39
  }
38
40
 
39
- // ../../lib/primitive/src/utils/assert-never.ts
40
- function assertNever(value) {
41
- throw new Error(`Unexpected value: ${String(value)}`);
42
- }
43
-
44
- // ../../lib/primitive/src/utils/iterate.ts
45
- function find(iterable, callback) {
46
- for (const value of iterable) {
47
- const result = callback(value);
48
- if (result != null) {
49
- return result;
50
- }
51
- }
52
- return null;
53
- }
54
- function some(iterable, predicate) {
55
- for (const value of iterable) {
56
- if (predicate(value)) return true;
57
- }
58
- return false;
59
- }
60
- function every(iterable, predicate) {
61
- let index = 0;
62
- for (const value of iterable) {
63
- if (!predicate(value, index++)) {
64
- return false;
65
- }
66
- }
67
- return true;
68
- }
69
- function* filter(iterable, predicate) {
70
- let index = 0;
71
- for (const value of iterable) {
72
- if (predicate(value, index++)) {
73
- yield value;
74
- }
75
- }
76
- }
77
- function* map(iterable, callback) {
78
- let index = 0;
79
- for (const value of iterable) {
80
- yield callback(value, index++);
81
- }
82
- }
83
- function forEach(iterable, callback) {
84
- let index = 0;
85
- for (const value of iterable) {
86
- callback(value, index++);
87
- }
88
- }
89
- function reduce(iterable, initial, callback) {
90
- let accumulator = initial;
91
- let index = 0;
92
- for (const value of iterable) {
93
- accumulator = callback(accumulator, value, index++);
94
- }
95
- return accumulator;
96
- }
97
- function collect(iterable, callback) {
98
- const result = {};
99
- let index = 0;
100
- for (const value of iterable) {
101
- const entry = callback(value, index++);
102
- if (entry === null) {
103
- return null;
104
- }
105
- result[entry[0]] = entry[1];
106
- }
107
- return result;
108
- }
109
- function findLast(value, callback) {
110
- for (let index = value.length - 1; index >= 0; index--) {
111
- const result = callback(value[index], index);
112
- if (result != null) {
113
- return result;
114
- }
115
- }
116
- return null;
117
- }
118
- function* items(collection) {
119
- for (let i = 0; i < collection.length; i++) {
120
- const item = collection.item(i);
121
- if (item !== null) {
122
- yield item;
123
- }
124
- }
125
- }
126
- function nodeList(list) {
127
- return {
128
- *[Symbol.iterator]() {
129
- for (let i = 0; i < list.length; i++) {
130
- const node = list.item(i);
131
- if (node !== null) {
132
- yield node;
133
- }
134
- }
135
- }
136
- };
137
- }
138
- function mapEntries(m) {
139
- return m.entries();
140
- }
141
- function set(s) {
142
- return s.values();
143
- }
144
- function hasOwn(object, key) {
145
- return Object.hasOwn(object, key);
146
- }
147
- function* entries(object) {
148
- for (const key in object) {
149
- if (!hasOwn(object, key)) continue;
150
- yield [key, object[key]];
151
- }
152
- }
153
- function* keys(object) {
154
- for (const [key] of entries(object)) {
155
- yield key;
156
- }
157
- }
158
- function* values(object) {
159
- for (const [, value] of entries(object)) {
160
- yield value;
161
- }
162
- }
163
- function mapValues(object, callback) {
164
- const result = {};
165
- for (const [key, value] of entries(object)) {
166
- result[key] = callback(value, key);
167
- }
168
- return result;
169
- }
170
- function forEachEntry(object, callback) {
171
- for (const [key, value] of entries(object)) {
172
- callback(key, value);
173
- }
174
- }
175
- function forEachKey(object, callback) {
176
- for (const key of keys(object)) {
177
- callback(key);
178
- }
179
- }
180
- function forEachValue(object, callback) {
181
- for (const value of values(object)) {
182
- callback(value);
183
- }
184
- }
185
- function forEachSet(s, callback) {
186
- for (const value of s) {
187
- callback(value);
188
- }
189
- }
190
- var iterate = Object.freeze({
191
- entries,
192
- filter,
193
- find,
194
- findLast,
195
- forEach,
196
- forEachEntry,
197
- forEachKey,
198
- forEachSet,
199
- forEachValue,
200
- items,
201
- keys,
202
- map,
203
- mapEntries,
204
- mapValues,
205
- nodeList,
206
- reduce,
207
- collect,
208
- set,
209
- some,
210
- every,
211
- values
212
- });
213
-
214
- // ../../lib/primitive/src/utils/merge-refs.ts
215
- function mergeRefsCore(...refs) {
216
- const active = refs.filter((r) => r != null);
217
- if (active.length === 0) return null;
218
- if (active.length === 1) return active[0];
219
- return (value) => {
220
- iterate.forEach(active, (ref) => {
221
- if (typeof ref === "function") {
222
- ref(value);
223
- } else {
224
- ref.current = value;
225
- }
226
- });
227
- };
228
- }
229
-
230
41
  // ../../lib/primitive/src/constants/aria/global-aria-attributes.ts
231
42
  var GLOBAL_ARIA_ATTRIBUTES = /* @__PURE__ */ new Set([
232
43
  "aria-atomic",
@@ -249,7 +60,7 @@ var GLOBAL_ARIA_ATTRIBUTES = /* @__PURE__ */ new Set([
249
60
  ]);
250
61
 
251
62
  // ../../lib/primitive/src/constants/aria/implicit-role-record.ts
252
- var IMPLICIT_ROLE_RECORD = {
63
+ var IMPLICIT_ROLE_RECORD = Object.freeze({
253
64
  // Landmarks
254
65
  article: "article",
255
66
  aside: "complementary",
@@ -285,8 +96,8 @@ var IMPLICIT_ROLE_RECORD = {
285
96
  meter: "meter",
286
97
  output: "status",
287
98
  progress: "progressbar"
288
- };
289
- var INPUT_TYPE_ROLE_MAP = {
99
+ });
100
+ var INPUT_TYPE_ROLE_MAP = Object.freeze({
290
101
  checkbox: "checkbox",
291
102
  radio: "radio",
292
103
  range: "slider",
@@ -300,18 +111,106 @@ var INPUT_TYPE_ROLE_MAP = {
300
111
  submit: "button",
301
112
  reset: "button",
302
113
  image: "button"
303
- };
304
- var STRONG_ROLES = [
114
+ });
115
+ var STRONG_ROLES = Object.freeze([
305
116
  "main",
306
117
  "navigation",
307
118
  "complementary",
308
119
  "contentinfo",
309
120
  "banner"
310
- ];
311
- var STANDALONE_ROLES = ["article"];
121
+ ]);
122
+ var STANDALONE_ROLES = Object.freeze([
123
+ "article"
124
+ ]);
312
125
  var STRONG_ROLES_SET = new Set(STRONG_ROLES);
313
126
  var STANDALONE_ROLES_SET = new Set(STANDALONE_ROLES);
314
127
 
128
+ // ../../lib/primitive/src/constants/aria/known-aria-roles.ts
129
+ var KNOWN_ARIA_ROLES = Object.freeze([
130
+ "alert",
131
+ "alertdialog",
132
+ "application",
133
+ "article",
134
+ "banner",
135
+ "blockquote",
136
+ "button",
137
+ "caption",
138
+ "cell",
139
+ "checkbox",
140
+ "code",
141
+ "columnheader",
142
+ "combobox",
143
+ "complementary",
144
+ "contentinfo",
145
+ "definition",
146
+ "deletion",
147
+ "dialog",
148
+ "document",
149
+ "emphasis",
150
+ "feed",
151
+ "figure",
152
+ "form",
153
+ "generic",
154
+ "grid",
155
+ "gridcell",
156
+ "group",
157
+ "heading",
158
+ "img",
159
+ "insertion",
160
+ "link",
161
+ "list",
162
+ "listbox",
163
+ "listitem",
164
+ "log",
165
+ "main",
166
+ "marquee",
167
+ "math",
168
+ "menu",
169
+ "menubar",
170
+ "menuitem",
171
+ "menuitemcheckbox",
172
+ "menuitemradio",
173
+ "meter",
174
+ "navigation",
175
+ "none",
176
+ "note",
177
+ "option",
178
+ "paragraph",
179
+ "presentation",
180
+ "progressbar",
181
+ "radio",
182
+ "radiogroup",
183
+ "region",
184
+ "row",
185
+ "rowgroup",
186
+ "rowheader",
187
+ "scrollbar",
188
+ "search",
189
+ "searchbox",
190
+ "separator",
191
+ "slider",
192
+ "spinbutton",
193
+ "status",
194
+ "strong",
195
+ "subscript",
196
+ "superscript",
197
+ "switch",
198
+ "tab",
199
+ "table",
200
+ "tablist",
201
+ "tabpanel",
202
+ "term",
203
+ "textbox",
204
+ "time",
205
+ "timer",
206
+ "toolbar",
207
+ "tooltip",
208
+ "tree",
209
+ "treegrid",
210
+ "treeitem"
211
+ ]);
212
+ var KNOWN_ARIA_ROLES_SET = new Set(KNOWN_ARIA_ROLES);
213
+
315
214
  // ../../lib/primitive/src/constants/aria/role-restricted-attributes.ts
316
215
  var ROLE_RESTRICTED_ATTRIBUTES = /* @__PURE__ */ new Map([
317
216
  [
@@ -463,19 +362,6 @@ var ROLE_RESTRICTED_ATTRIBUTES = /* @__PURE__ */ new Map([
463
362
  ]
464
363
  ]);
465
364
 
466
- // ../../lib/primitive/src/constants/primitive/slot-name.ts
467
- var SLOT_NAME = "Slot";
468
-
469
- // ../../lib/primitive/src/guards/foundational/is-defined.ts
470
- function isUndefined(value) {
471
- return value === void 0;
472
- }
473
-
474
- // ../../lib/primitive/src/guards/foundational/is-null.ts
475
- function isNull(value) {
476
- return value === null;
477
- }
478
-
479
365
  // ../../lib/primitive/src/guards/aria/is-aria-attribute.ts
480
366
  function isGlobalAriaAttribute(attr) {
481
367
  return GLOBAL_ARIA_ATTRIBUTES.has(attr);
@@ -487,25 +373,256 @@ function isAriaAttributeValidForRole(attr, role) {
487
373
  return allowedRoles.has(role);
488
374
  }
489
375
 
490
- // ../../lib/primitive/src/guards/aria/is-aria-role.ts
491
- function isStrongImplicitRole(tag) {
492
- if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
493
- return STRONG_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
494
- }
495
- function isStandaloneTag(tag) {
496
- if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
497
- return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
498
- }
499
- function getInputImplicitRole(type) {
500
- if (type == null || !(type in INPUT_TYPE_ROLE_MAP)) return void 0;
501
- return INPUT_TYPE_ROLE_MAP[type];
502
- }
503
- function getConditionalImplicitRole(tag, ariaLabel, ariaLabelledBy) {
504
- const isNamed = typeof ariaLabel === "string" || typeof ariaLabelledBy === "string";
505
- if (!isNamed) return void 0;
506
- if (tag === "section") return "region";
507
- if (tag === "form") return "form";
508
- return void 0;
376
+ // ../../lib/primitive/src/constants/primitive/slot-name.ts
377
+ var SLOT_NAME = "Slot";
378
+
379
+ // ../../lib/primitive/src/guards/aria/is-aria-role.ts
380
+ function isStrongImplicitRole(tag) {
381
+ if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
382
+ return STRONG_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
383
+ }
384
+ function isStandaloneTag(tag) {
385
+ if (!(tag in IMPLICIT_ROLE_RECORD)) return false;
386
+ return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
387
+ }
388
+ function getInputImplicitRole(type) {
389
+ if (!isString(type) || !(type in INPUT_TYPE_ROLE_MAP)) return void 0;
390
+ return INPUT_TYPE_ROLE_MAP[type];
391
+ }
392
+ function getConditionalImplicitRole(tag, ariaLabel, ariaLabelledBy) {
393
+ const isNamed = isString(ariaLabel) || isString(ariaLabelledBy);
394
+ if (!isNamed) return void 0;
395
+ if (tag === "section") return "region";
396
+ if (tag === "form") return "form";
397
+ return void 0;
398
+ }
399
+
400
+ // ../../lib/primitive/src/guards/aria/is-known-aria-role.ts
401
+ function isKnownAriaRole(value) {
402
+ return isString(value) && KNOWN_ARIA_ROLES_SET.has(value);
403
+ }
404
+
405
+ // ../../lib/contract/src/aria/aria-role-policy.ts
406
+ function getImplicitRole(tag, props) {
407
+ if (tag in IMPLICIT_ROLE_RECORD) return IMPLICIT_ROLE_RECORD[tag];
408
+ if (tag === "input") return getInputImplicitRole(props?.type);
409
+ if (tag === "img") return props?.alt === "" ? "none" : "img";
410
+ if (tag === "section" || tag === "form") {
411
+ return getConditionalImplicitRole(tag, props?.["aria-label"], props?.["aria-labelledby"]);
412
+ }
413
+ return void 0;
414
+ }
415
+
416
+ // ../../lib/primitive/src/tag/resolve-tag.ts
417
+ function makeResolveTag(defaultTag) {
418
+ return function tag(as) {
419
+ return as ?? defaultTag;
420
+ };
421
+ }
422
+
423
+ // ../../lib/primitive/src/utils/assert-never.ts
424
+ function assertNever(value) {
425
+ throw new Error(`Unexpected value: ${String(value)}`);
426
+ }
427
+
428
+ // ../../lib/primitive/src/utils/cn.ts
429
+ import { clsx } from "clsx";
430
+ function cn(...inputs) {
431
+ return clsx(...inputs);
432
+ }
433
+
434
+ // ../../lib/primitive/src/utils/iterate.ts
435
+ function find(iterable, callback) {
436
+ for (const value of iterable) {
437
+ const result = callback(value);
438
+ if (result != null) {
439
+ return result;
440
+ }
441
+ }
442
+ return null;
443
+ }
444
+ function some(iterable, predicate) {
445
+ for (const value of iterable) {
446
+ if (predicate(value)) return true;
447
+ }
448
+ return false;
449
+ }
450
+ function every(iterable, predicate) {
451
+ let index = 0;
452
+ for (const value of iterable) {
453
+ if (!predicate(value, index++)) {
454
+ return false;
455
+ }
456
+ }
457
+ return true;
458
+ }
459
+ function* filter(iterable, predicate) {
460
+ let index = 0;
461
+ for (const value of iterable) {
462
+ if (predicate(value, index++)) {
463
+ yield value;
464
+ }
465
+ }
466
+ }
467
+ function* map(iterable, callback) {
468
+ let index = 0;
469
+ for (const value of iterable) {
470
+ yield callback(value, index++);
471
+ }
472
+ }
473
+ function forEach(iterable, callback) {
474
+ let index = 0;
475
+ for (const value of iterable) {
476
+ callback(value, index++);
477
+ }
478
+ }
479
+ function reduce(iterable, initial, callback) {
480
+ let accumulator = initial;
481
+ let index = 0;
482
+ for (const value of iterable) {
483
+ accumulator = callback(accumulator, value, index++);
484
+ }
485
+ return accumulator;
486
+ }
487
+ function collect(iterable, callback) {
488
+ const result = {};
489
+ let index = 0;
490
+ for (const value of iterable) {
491
+ const entry = callback(value, index++);
492
+ if (entry === null) {
493
+ return null;
494
+ }
495
+ result[entry[0]] = entry[1];
496
+ }
497
+ return result;
498
+ }
499
+ function findLast(value, callback) {
500
+ for (let index = value.length - 1; index >= 0; index--) {
501
+ const result = callback(value[index], index);
502
+ if (result != null) {
503
+ return result;
504
+ }
505
+ }
506
+ return null;
507
+ }
508
+ function* items(collection) {
509
+ for (let i = 0; i < collection.length; i++) {
510
+ const item = collection.item(i);
511
+ if (item !== null) {
512
+ yield item;
513
+ }
514
+ }
515
+ }
516
+ function nodeList(list) {
517
+ return {
518
+ *[Symbol.iterator]() {
519
+ for (let i = 0; i < list.length; i++) {
520
+ const node = list.item(i);
521
+ if (node !== null) {
522
+ yield node;
523
+ }
524
+ }
525
+ }
526
+ };
527
+ }
528
+ function mapEntries(m) {
529
+ return m.entries();
530
+ }
531
+ function set(s) {
532
+ return s.values();
533
+ }
534
+ function hasOwn(object, key) {
535
+ return Object.hasOwn(object, key);
536
+ }
537
+ function* entries(object) {
538
+ for (const key in object) {
539
+ if (!hasOwn(object, key)) continue;
540
+ yield [key, object[key]];
541
+ }
542
+ }
543
+ function* keys(object) {
544
+ for (const [key] of entries(object)) {
545
+ yield key;
546
+ }
547
+ }
548
+ function* values(object) {
549
+ for (const [, value] of entries(object)) {
550
+ yield value;
551
+ }
552
+ }
553
+ function mapValues(object, callback) {
554
+ const result = {};
555
+ for (const [key, value] of entries(object)) {
556
+ result[key] = callback(value, key);
557
+ }
558
+ return result;
559
+ }
560
+ function forEachEntry(object, callback) {
561
+ for (const [key, value] of entries(object)) {
562
+ callback(key, value);
563
+ }
564
+ }
565
+ function forEachKey(object, callback) {
566
+ for (const key of keys(object)) {
567
+ callback(key);
568
+ }
569
+ }
570
+ function forEachValue(object, callback) {
571
+ for (const value of values(object)) {
572
+ callback(value);
573
+ }
574
+ }
575
+ function forEachSet(s, callback) {
576
+ for (const value of s) {
577
+ callback(value);
578
+ }
579
+ }
580
+ var iterate = Object.freeze({
581
+ entries,
582
+ filter,
583
+ find,
584
+ findLast,
585
+ forEach,
586
+ forEachEntry,
587
+ forEachKey,
588
+ forEachSet,
589
+ forEachValue,
590
+ items,
591
+ keys,
592
+ map,
593
+ mapEntries,
594
+ mapValues,
595
+ nodeList,
596
+ reduce,
597
+ collect,
598
+ set,
599
+ some,
600
+ every,
601
+ values
602
+ });
603
+
604
+ // ../../lib/primitive/src/utils/merge-refs.ts
605
+ function mergeRefsCore(...refs) {
606
+ const active = refs.filter((r) => r != null);
607
+ if (active.length === 0) return null;
608
+ if (active.length === 1) return active[0];
609
+ return (value) => {
610
+ iterate.forEach(active, (ref) => {
611
+ if (typeof ref === "function") {
612
+ ref(value);
613
+ } else {
614
+ ref.current = value;
615
+ }
616
+ });
617
+ };
618
+ }
619
+
620
+ // ../../lib/primitive/src/utils/merge-props.ts
621
+ function mergeProps(defaultProps, props) {
622
+ return {
623
+ ...defaultProps ?? {},
624
+ ...props
625
+ };
509
626
  }
510
627
 
511
628
  // ../../lib/primitive/src/guards/children/component-id.ts
@@ -545,17 +662,6 @@ function isTag(...args) {
545
662
  return tag !== void 0 && set2.has(tag);
546
663
  }
547
664
 
548
- // ../../lib/contract/src/aria/aria-role-policy.ts
549
- function getImplicitRole(tag, props) {
550
- if (tag in IMPLICIT_ROLE_RECORD) return IMPLICIT_ROLE_RECORD[tag];
551
- if (tag === "input") return getInputImplicitRole(props?.type);
552
- if (tag === "img") return props?.alt === "" ? "none" : "img";
553
- if (tag === "section" || tag === "form") {
554
- return getConditionalImplicitRole(tag, props?.["aria-label"], props?.["aria-labelledby"]);
555
- }
556
- return void 0;
557
- }
558
-
559
665
  // ../../lib/contract/src/strict/invariant-base.ts
560
666
  var InvariantBase = class {
561
667
  diagnostics;
@@ -802,18 +908,18 @@ var ContractDiagnostics = {
802
908
  message: `${context}: "${ruleName}" must be ${position}, got index ${index}`
803
909
  };
804
910
  },
805
- unknownVariantDim(component, label, dim) {
911
+ unknownVariantDim(component, label2, dim) {
806
912
  return {
807
913
  code: DiagnosticCode2.ContractUnknownVariantDim,
808
914
  category: DiagnosticCategory2.Contract,
809
- message: `${component}: ${label} references unknown variant "${dim}".`
915
+ message: `${component}: ${label2} references unknown variant "${dim}".`
810
916
  };
811
917
  },
812
- unknownVariantValue(component, label, dim, value, valid) {
918
+ unknownVariantValue(component, label2, dim, value, valid) {
813
919
  return {
814
920
  code: DiagnosticCode2.ContractUnknownVariantValue,
815
921
  category: DiagnosticCategory2.Contract,
816
- message: `${component}: ${label} sets "${dim}" to unknown value "${value}" (valid: ${valid.join(", ")}).`
922
+ message: `${component}: ${label2} sets "${dim}" to unknown value "${value}" (valid: ${valid.join(", ")}).`
817
923
  };
818
924
  },
819
925
  unknownRecipeKey(component, key) {
@@ -1611,7 +1717,7 @@ function getTypeName(value) {
1611
1717
  return primitive;
1612
1718
  }
1613
1719
  const name = value.constructor?.name;
1614
- return typeof name === "string" && name !== "Object" ? name : "object";
1720
+ return isString(name) && name !== "Object" ? name : "object";
1615
1721
  }
1616
1722
 
1617
1723
  // ../../lib/contract/src/children/normalize-child-rule.ts
@@ -1905,12 +2011,17 @@ function landmarkNameAdvisory(ctx) {
1905
2011
  if (!ctx.implicitRole || !NAMED_LANDMARK_TAGS.has(ctx.tag)) return [];
1906
2012
  return requireAccessibleName(ctx);
1907
2013
  }
2014
+ var HTML_ARIA_RULES = [landmarkRoleRule, landmarkNameAdvisory];
1908
2015
 
1909
2016
  // ../core/src/html/contracts.ts
1910
2017
  import { warnDiagnostics } from "./_shared/diagnostics.js";
1911
2018
  function isOpenContent(...blockedTags) {
1912
2019
  const set2 = new Set(blockedTags);
1913
- return (child) => isObject(child) && "type" in child && (!isString(child.type) || !set2.has(child.type));
2020
+ return (child) => {
2021
+ if (!isObject(child) || !("type" in child)) return false;
2022
+ const tag = getTag(child);
2023
+ return tag === void 0 || !set2.has(tag);
2024
+ };
1914
2025
  }
1915
2026
  var METADATA_TAGS = ["script", "template"];
1916
2027
  var metadataMatch = isTag(...METADATA_TAGS);
@@ -2080,38 +2191,396 @@ function getHtmlPropNormalizers(tag) {
2080
2191
  return typeof tag === "string" ? HTML_FORM_NORMALIZERS.get(tag) : void 0;
2081
2192
  }
2082
2193
 
2083
- // ../../lib/styling/src/variant-pass/compile-variant-lookup.ts
2084
- function buildPrecomputedKey(props) {
2085
- return Object.entries(props).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}:${v}`).join("|");
2086
- }
2194
+ // ../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.mjs
2195
+ import { clsx as clsx2 } from "clsx";
2196
+ var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
2197
+ var cx = clsx2;
2198
+ var cva = (base, config) => (props) => {
2199
+ var _config_compoundVariants;
2200
+ 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);
2201
+ const { variants, defaultVariants } = config;
2202
+ const getVariantClassNames = Object.keys(variants).map((variant) => {
2203
+ const variantProp = props === null || props === void 0 ? void 0 : props[variant];
2204
+ const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
2205
+ if (variantProp === null) return null;
2206
+ const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
2207
+ return variants[variant][variantKey];
2208
+ });
2209
+ const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param) => {
2210
+ let [key, value] = param;
2211
+ if (value === void 0) {
2212
+ return acc;
2213
+ }
2214
+ acc[key] = value;
2215
+ return acc;
2216
+ }, {});
2217
+ 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) => {
2218
+ let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;
2219
+ return Object.entries(compoundVariantOptions).every((param2) => {
2220
+ let [key, value] = param2;
2221
+ return Array.isArray(value) ? value.includes({
2222
+ ...defaultVariants,
2223
+ ...propsWithoutUndefined
2224
+ }[key]) : {
2225
+ ...defaultVariants,
2226
+ ...propsWithoutUndefined
2227
+ }[key] === value;
2228
+ }) ? [
2229
+ ...acc,
2230
+ cvClass,
2231
+ cvClassName
2232
+ ] : acc;
2233
+ }, []);
2234
+ return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
2235
+ };
2087
2236
 
2088
- // ../../lib/styling/src/variant-pass/variant-pass.ts
2089
- function createVariantPass(activeProps, config) {
2090
- return {
2091
- name: "variant",
2092
- execute() {
2093
- const preset = typeof activeProps["preset"] === "string" ? activeProps["preset"] : void 0;
2094
- const presetDefaults = preset !== void 0 && config.presets?.[preset] !== void 0 ? config.presets[preset] : {};
2095
- const resolved = {
2096
- ...config.defaults,
2097
- ...presetDefaults,
2098
- ...activeProps
2099
- };
2100
- const classes = [];
2101
- iterate.forEachEntry(config.variants, (key, valueMap) => {
2102
- const active = resolved[key];
2103
- if (typeof active === "string") {
2104
- const cls = valueMap[active];
2105
- if (cls !== void 0) classes.push(cls);
2106
- }
2237
+ // ../../lib/styling/src/cva.ts
2238
+ function cva2(base, config) {
2239
+ const fn = cva(base, config);
2240
+ return (props) => cn(fn(props));
2241
+ }
2242
+
2243
+ // ../../lib/styling/src/static-class-resolver.ts
2244
+ var StaticClassResolver = class {
2245
+ #baseClass;
2246
+ #cache = /* @__PURE__ */ new Map();
2247
+ #resolveTag;
2248
+ constructor(baseClass, tagMap) {
2249
+ this.#baseClass = Array.isArray(baseClass) ? baseClass.join(" ") : baseClass;
2250
+ this.#resolveTag = tagMap ? (tag) => {
2251
+ const extra = tagMap[tag];
2252
+ if (!extra) return this.#baseClass;
2253
+ const extraStr = Array.isArray(extra) ? extra.join(" ") : extra;
2254
+ return `${this.#baseClass} ${extraStr}`;
2255
+ } : () => this.#baseClass;
2256
+ }
2257
+ resolve(tag, skipTagMap = false) {
2258
+ if (typeof tag !== "string" || skipTagMap) return this.#baseClass;
2259
+ const cached = this.#cache.get(tag);
2260
+ if (cached !== void 0) {
2261
+ this.#cache.delete(tag);
2262
+ this.#cache.set(tag, cached);
2263
+ return cached;
2264
+ }
2265
+ const result = this.#resolveTag(tag);
2266
+ this.#cache.set(tag, result);
2267
+ if (this.#cache.size > 200) {
2268
+ const lru = this.#cache.keys().next().value;
2269
+ if (lru !== void 0) this.#cache.delete(lru);
2270
+ }
2271
+ return result;
2272
+ }
2273
+ };
2274
+
2275
+ // ../../lib/styling/src/variant-class-resolver.ts
2276
+ var VariantClassResolver = class _VariantClassResolver {
2277
+ #cvaFn;
2278
+ #recipeMap;
2279
+ #variantKeys;
2280
+ #precomputedClasses;
2281
+ #cache = /* @__PURE__ */ new Map();
2282
+ constructor(cvaFn, recipeMap, variantKeys, precomputedClasses) {
2283
+ this.#cvaFn = cvaFn ?? null;
2284
+ this.#recipeMap = Object.freeze(recipeMap ?? {});
2285
+ this.#variantKeys = variantKeys ?? null;
2286
+ this.#precomputedClasses = precomputedClasses ?? null;
2287
+ }
2288
+ resolve({ props, recipe }) {
2289
+ const normalizedKey = recipe ?? "__none__";
2290
+ const cacheKey = this.#createCacheKey(props, normalizedKey);
2291
+ if (this.#precomputedClasses !== null) {
2292
+ const precomputed = this.#precomputedClasses[cacheKey];
2293
+ if (precomputed !== void 0) return precomputed;
2294
+ }
2295
+ const cached = this.#cache.get(cacheKey);
2296
+ if (cached !== void 0) {
2297
+ this.#cache.delete(cacheKey);
2298
+ this.#cache.set(cacheKey, cached);
2299
+ return cached;
2300
+ }
2301
+ const result = this.#compute(props, recipe);
2302
+ this.#cache.set(cacheKey, result);
2303
+ if (this.#cache.size > 1e3) {
2304
+ const lru = this.#cache.keys().next().value;
2305
+ if (lru !== void 0) this.#cache.delete(lru);
2306
+ }
2307
+ return result;
2308
+ }
2309
+ #compute(props, recipe) {
2310
+ if (!this.#cvaFn) return "";
2311
+ if (!recipe) return this.#cvaFn(props);
2312
+ const preset = this.#recipeMap[recipe];
2313
+ if (!preset) return this.#cvaFn(props);
2314
+ return this.#cvaFn({ ...preset, ...props });
2315
+ }
2316
+ // When variantKeys is provided, only those keys are included in the cache key — non-variant
2317
+ // props (className, id, etc.) produce identical CVA output and must not fragment the cache.
2318
+ // Iterating #variantKeys directly (fixed Set insertion order) avoids Object.keys + filter + sort.
2319
+ // String is built incrementally to avoid a parts[] array allocation on every render.
2320
+ #createCacheKey(props, recipe) {
2321
+ if (this.#variantKeys !== null) {
2322
+ let key2 = recipe;
2323
+ iterate.forEachSet(this.#variantKeys, (k) => {
2324
+ if (k in props) key2 += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
2107
2325
  });
2108
- return { context: { classes } };
2326
+ return key2;
2327
+ }
2328
+ let key = recipe;
2329
+ iterate.forEach(Object.keys(props).sort(), (k) => {
2330
+ key += `|${k}:${_VariantClassResolver.#serializeValue(props[k])}`;
2331
+ });
2332
+ return key;
2333
+ }
2334
+ static #serializeValue(value) {
2335
+ if (value === void 0) return "u";
2336
+ if (value === null) return "n";
2337
+ if (typeof value === "boolean") return `b:${value}`;
2338
+ if (typeof value === "string") return `s:${value}`;
2339
+ return `x:${String(value)}`;
2340
+ }
2341
+ };
2342
+
2343
+ // ../../lib/styling/src/create-class-pipeline.ts
2344
+ function createClassPipeline(resolved) {
2345
+ const baseClass = resolved.baseClassName ?? "";
2346
+ const cvaFn = resolved.variants ? cva2("", {
2347
+ variants: resolved.variants,
2348
+ defaultVariants: resolved.defaultVariants,
2349
+ compoundVariants: resolved.compoundVariants
2350
+ }) : null;
2351
+ const variantKeys = resolved.variants ? new Set(Object.keys(resolved.variants)) : void 0;
2352
+ const staticResolver = new StaticClassResolver(baseClass, resolved.tagMap);
2353
+ const variantResolver = new VariantClassResolver(
2354
+ cvaFn,
2355
+ resolved.recipeMap,
2356
+ variantKeys,
2357
+ resolved.precomputedClasses
2358
+ );
2359
+ return function resolveClasses(tag, props, className, recipe) {
2360
+ const staticClasses = staticResolver.resolve(tag, recipe !== void 0);
2361
+ const variantClasses = variantResolver.resolve({ props, recipe });
2362
+ if (!className)
2363
+ return staticClasses && variantClasses ? `${staticClasses} ${variantClasses}` : staticClasses || variantClasses;
2364
+ return cn(staticClasses, variantClasses, className);
2365
+ };
2366
+ }
2367
+
2368
+ // ../../lib/pipeline-kit/src/factory/define-pipeline.ts
2369
+ function definePipeline(factory) {
2370
+ const cache = /* @__PURE__ */ new WeakMap();
2371
+ return (resolved) => {
2372
+ let pipeline = cache.get(resolved);
2373
+ if (!pipeline) {
2374
+ pipeline = factory(resolved);
2375
+ cache.set(resolved, pipeline);
2109
2376
  }
2377
+ return pipeline;
2110
2378
  };
2111
2379
  }
2112
2380
 
2113
- // ../core/src/resolver/resolver.ts
2381
+ // ../core/src/options/resolve-factory-options.ts
2114
2382
  import { silentDiagnostics } from "./_shared/diagnostics.js";
2383
+ var EMPTY_VARIANT_KEYS = /* @__PURE__ */ new Set();
2384
+ function composeNormalizers(normalizers, fn) {
2385
+ if (!normalizers?.length) return fn;
2386
+ return ((props) => {
2387
+ const patched = normalizers.reduce(
2388
+ (acc, normalizer) => ({ ...acc, ...normalizer(acc) }),
2389
+ props
2390
+ );
2391
+ return fn ? fn(patched) : patched;
2392
+ });
2393
+ }
2394
+ function whenDefined(key, value) {
2395
+ return value === void 0 ? {} : { [key]: value };
2396
+ }
2397
+ function resolveFactoryOptions(options = {}) {
2398
+ const { styling, enforcement } = options;
2399
+ const composedNormalizeFn = composeNormalizers(enforcement?.props, options.normalize);
2400
+ const variantKeys = styling?.variants === void 0 ? EMPTY_VARIANT_KEYS : new Set(Object.keys(styling.variants));
2401
+ return Object.freeze({
2402
+ defaultTag: options.tag ?? "div",
2403
+ diagnostics: enforcement?.diagnostics ?? silentDiagnostics,
2404
+ variantKeys,
2405
+ ...whenDefined("displayName", options.name),
2406
+ ...whenDefined("defaultProps", options.defaults),
2407
+ ...whenDefined("baseClassName", styling?.base),
2408
+ ...whenDefined("tagMap", styling?.tags),
2409
+ ...whenDefined("recipeMap", styling?.presets),
2410
+ ...whenDefined("variants", styling?.variants),
2411
+ ...whenDefined("defaultVariants", styling?.defaults),
2412
+ ...whenDefined("compoundVariants", styling?.compounds),
2413
+ ...whenDefined("normalizeFn", composedNormalizeFn),
2414
+ ...whenDefined("ariaRules", enforcement?.aria),
2415
+ ...whenDefined("childRules", enforcement?.children),
2416
+ ...whenDefined("allowedAs", enforcement?.allowedAs),
2417
+ ...whenDefined("precomputedClasses", styling?.precomputedClasses)
2418
+ });
2419
+ }
2420
+
2421
+ // ../core/src/options/validate-factory-options.ts
2422
+ function validateFactoryOptions(resolved, diagnostics) {
2423
+ if (!diagnostics.active) return;
2424
+ const name = resolved.displayName ?? "Component";
2425
+ const { variants } = resolved;
2426
+ const checkSelection = (label2, selection) => {
2427
+ iterate.forEachEntry(selection, (dim, value) => {
2428
+ if (value === void 0 || value === null) return;
2429
+ if (!variants || !Object.hasOwn(variants, dim)) {
2430
+ diagnostics.error(ContractDiagnostics.unknownVariantDim(name, label2, dim));
2431
+ return;
2432
+ }
2433
+ const states = variants[dim];
2434
+ const stateKey = String(value);
2435
+ if (!Object.hasOwn(states, stateKey)) {
2436
+ diagnostics.error(
2437
+ ContractDiagnostics.unknownVariantValue(name, label2, dim, stateKey, Object.keys(states))
2438
+ );
2439
+ }
2440
+ });
2441
+ };
2442
+ const { recipeMap } = resolved;
2443
+ if (recipeMap) {
2444
+ iterate.forEachEntry(recipeMap, (recipeKey, selection) => {
2445
+ checkSelection(`preset "${recipeKey}"`, selection);
2446
+ });
2447
+ }
2448
+ if (resolved.defaultVariants) checkSelection("defaults", resolved.defaultVariants);
2449
+ }
2450
+
2451
+ // ../core/src/options/validate-render-props.ts
2452
+ function label(name) {
2453
+ return name ? `[${name}]` : "[createContractComponent]";
2454
+ }
2455
+ function validateRenderProps(diagnostics, options, props, recipeKey) {
2456
+ const { recipeMap, variants, displayName } = options;
2457
+ const tag = label(displayName);
2458
+ if (recipeKey !== void 0 && (!recipeMap || !Object.hasOwn(recipeMap, recipeKey))) {
2459
+ diagnostics.error(ContractDiagnostics.unknownRecipeKey(tag, recipeKey));
2460
+ }
2461
+ if (variants) {
2462
+ iterate.forEachKey(variants, (key) => {
2463
+ if (!Object.hasOwn(props, key)) return;
2464
+ const value = props[key];
2465
+ if (value === void 0 || value === null) return;
2466
+ const dim = variants[key];
2467
+ if (dim && !Object.hasOwn(dim, String(value))) {
2468
+ diagnostics.error(ContractDiagnostics.invalidVariantValue(tag, key, String(value)));
2469
+ }
2470
+ });
2471
+ }
2472
+ }
2473
+
2474
+ // ../core/src/factory/plugin-invariants.ts
2475
+ import { throwDiagnostics } from "./_shared/diagnostics.js";
2476
+
2477
+ // ../core/src/factory/plugin-diagnostics.ts
2478
+ import { DiagnosticCategory as DiagnosticCategory5, DiagnosticCode as DiagnosticCode5 } from "./_shared/diagnostics.js";
2479
+ var PluginDiagnostics = {
2480
+ invalidShape(received) {
2481
+ const got = received === null ? "null" : typeof received;
2482
+ return {
2483
+ code: DiagnosticCode5.PluginInvalidShape,
2484
+ category: DiagnosticCategory5.Internal,
2485
+ message: `[praxis-kit] Plugin factory must return an object with a 'pipeline' function. Got: ${got}.`
2486
+ };
2487
+ },
2488
+ pipelineReturnType(received) {
2489
+ const got = received === null ? "null" : Array.isArray(received) ? "array" : typeof received;
2490
+ return {
2491
+ code: DiagnosticCode5.PluginPipelineReturnType,
2492
+ category: DiagnosticCategory5.Internal,
2493
+ message: `[praxis-kit] Plugin pipeline must return a string. Got: ${got}.`
2494
+ };
2495
+ }
2496
+ };
2497
+
2498
+ // ../core/src/factory/plugin-invariants.ts
2499
+ function assertPluginShape(result) {
2500
+ if (result === null || typeof result !== "object")
2501
+ throwDiagnostics.error(PluginDiagnostics.invalidShape(result));
2502
+ const plugin = result;
2503
+ if (typeof plugin.pipeline !== "function")
2504
+ throwDiagnostics.error(PluginDiagnostics.invalidShape(result));
2505
+ }
2506
+ function guardPipeline(pipeline) {
2507
+ if (process.env.NODE_ENV === "production") return pipeline;
2508
+ return function guardedPipeline(tag, props, className, recipe) {
2509
+ const result = pipeline(tag, props, className, recipe);
2510
+ if (typeof result !== "string")
2511
+ throwDiagnostics.error(PluginDiagnostics.pipelineReturnType(result));
2512
+ return result;
2513
+ };
2514
+ }
2515
+
2516
+ // ../core/src/factory/create-polymorphic2.ts
2517
+ var createTagPipeline = (resolved) => makeResolveTag(resolved.defaultTag);
2518
+ var createPropsPipeline = (resolved) => (props) => mergeProps(resolved.defaultProps, props);
2519
+ var createHtmlPropNormalizersPipeline = () => getHtmlPropNormalizers;
2520
+ var createHtmlChildrenEvaluatorPipeline = () => getHtmlChildrenEvaluator;
2521
+ var createStylingClassPipeline = (resolved) => createClassPipeline(resolved);
2522
+ function resolveAriaRules(resolved) {
2523
+ return [.../* @__PURE__ */ new Set([...HTML_ARIA_RULES, ...resolved.ariaRules ?? []])];
2524
+ }
2525
+ var createAriaPipeline = (resolved) => {
2526
+ const rules = resolveAriaRules(resolved);
2527
+ const engine = new AriaPolicyEngine(resolved.diagnostics, rules.length ? { rules } : void 0);
2528
+ return (tag, props) => engine.validate(tag, props);
2529
+ };
2530
+ var memoizedTagPipeline = definePipeline(createTagPipeline);
2531
+ var memoizedPropsPipeline = definePipeline(createPropsPipeline);
2532
+ var memoizedHtmlPropNormalizersPipeline = definePipeline(createHtmlPropNormalizersPipeline);
2533
+ var memoizedHtmlChildrenEvaluatorPipeline = definePipeline(createHtmlChildrenEvaluatorPipeline);
2534
+ var memoizedClassPipeline = definePipeline(createStylingClassPipeline);
2535
+ var memoizedAriaPipeline = definePipeline(createAriaPipeline);
2536
+ function resolveAriaPassthrough(_tag, props) {
2537
+ return { props };
2538
+ }
2539
+ function resolveClassPlugin(factory, resolved, diagnostics) {
2540
+ if (!factory) return { pluginResult: void 0, classPipeline: memoizedClassPipeline(resolved) };
2541
+ const pluginResult = factory(resolved, diagnostics);
2542
+ assertPluginShape(pluginResult);
2543
+ return { pluginResult, classPipeline: guardPipeline(pluginResult.pipeline) };
2544
+ }
2545
+ function createPolymorphic2(options = {}) {
2546
+ const baseResolved = resolveFactoryOptions(options);
2547
+ const anyBaseResolved = baseResolved;
2548
+ const resolved = Object.freeze({
2549
+ ...baseResolved,
2550
+ htmlPropNormalizersFn: memoizedHtmlPropNormalizersPipeline(anyBaseResolved),
2551
+ htmlChildrenEvaluatorFn: memoizedHtmlChildrenEvaluatorPipeline(anyBaseResolved)
2552
+ });
2553
+ const anyResolved = resolved;
2554
+ if (process.env.NODE_ENV !== "production") {
2555
+ validateFactoryOptions(resolved, resolved.diagnostics);
2556
+ }
2557
+ const { pluginResult, classPipeline } = resolveClassPlugin(
2558
+ options.styling?.plugin,
2559
+ anyResolved,
2560
+ resolved.diagnostics
2561
+ );
2562
+ const resolveTag2 = memoizedTagPipeline(anyResolved);
2563
+ const resolveProps = memoizedPropsPipeline(anyResolved);
2564
+ const resolveAriaFn = options.enforcement !== void 0 ? memoizedAriaPipeline(anyResolved) : resolveAriaPassthrough;
2565
+ const methods = {
2566
+ resolveTag: resolveTag2,
2567
+ resolveProps,
2568
+ resolveClasses(tag, props, className, recipe) {
2569
+ if (process.env.NODE_ENV !== "production") {
2570
+ validateRenderProps(resolved.diagnostics, resolved, props, recipe);
2571
+ }
2572
+ return classPipeline(tag, props, className, recipe);
2573
+ },
2574
+ resolveAria(tag, props) {
2575
+ return resolveAriaFn(tag, props);
2576
+ }
2577
+ };
2578
+ const runtimeObject = pluginResult ? { ...methods, options: resolved, hasStyling: true, classPlugin: pluginResult } : { ...methods, options: resolved };
2579
+ return runtimeObject;
2580
+ }
2581
+
2582
+ // ../core/src/resolver/resolver.ts
2583
+ import { silentDiagnostics as silentDiagnostics2 } from "./_shared/diagnostics.js";
2115
2584
  function enforceAllowedAs(tag, allowedAs, diagnostics, displayName) {
2116
2585
  if (allowedAs.includes(tag)) return;
2117
2586
  if (!diagnostics) return;
@@ -2119,28 +2588,57 @@ function enforceAllowedAs(tag, allowedAs, diagnostics, displayName) {
2119
2588
  diagnostics.error(ContractDiagnostics.allowedAsViolation(String(tag), allowedAs, component));
2120
2589
  }
2121
2590
 
2122
- // ../../lib/adapter-utils/src/apply-prop-normalizers.ts
2123
- function applyPropNormalizers(tag, props, additional) {
2124
- const normalizers = [...getHtmlPropNormalizers(tag) ?? [], ...additional ?? []];
2125
- if (normalizers.length === 0) return props;
2126
- return normalizers.reduce((acc, fn) => ({ ...acc, ...fn(acc) }), props);
2591
+ // ../../lib/adapter-utils/src/runtime/build-core-runtime.ts
2592
+ var EMPTY_SET = /* @__PURE__ */ new Set();
2593
+ function buildCoreRuntime(normalized) {
2594
+ const runtime = createPolymorphic2(normalized);
2595
+ const ownedKeys = "classPlugin" in runtime ? runtime.classPlugin.ownedKeys ?? EMPTY_SET : EMPTY_SET;
2596
+ return { runtime, ownedKeys };
2127
2597
  }
2128
2598
 
2129
- // ../../lib/adapter-utils/src/build-engines.ts
2599
+ // ../../lib/adapter-utils/src/runtime/build-engines.ts
2130
2600
  function buildEngines(diagnostics, childRules, context) {
2131
2601
  return childRules?.length ? { childrenEvaluator: new ChildrenEvaluator(childRules, diagnostics, context) } : {};
2132
2602
  }
2133
2603
 
2134
- // ../../lib/adapter-utils/src/resolve-adapter-common-options.ts
2135
- import { throwDiagnostics, silentDiagnostics as silentDiagnostics2 } from "./_shared/diagnostics.js";
2136
- function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics) {
2604
+ // ../../lib/adapter-utils/src/runtime/resolve-adapter-common-options.ts
2605
+ import { throwDiagnostics as throwDiagnostics2, silentDiagnostics as silentDiagnostics3 } from "./_shared/diagnostics.js";
2606
+ function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics2) {
2137
2607
  return {
2138
2608
  name: options.name ?? defaultName,
2139
2609
  diagnostics: options.enforcement?.diagnostics ?? defaultDiagnostics
2140
2610
  };
2141
2611
  }
2142
2612
 
2143
- // ../../lib/adapter-utils/src/slot-validator.ts
2613
+ // ../../lib/adapter-utils/src/invariant.ts
2614
+ function panic(message) {
2615
+ throw new Error(message);
2616
+ }
2617
+ function invariant(condition, message) {
2618
+ if (!condition) panic(message);
2619
+ }
2620
+
2621
+ // ../../lib/adapter-utils/src/props/apply-filter.ts
2622
+ function applyFilter(props, filterProps, variantKeys) {
2623
+ const out = {};
2624
+ iterate.forEachEntry(props, (k) => {
2625
+ if (!Object.hasOwn(props, k)) return;
2626
+ if (filterProps(k, variantKeys)) return;
2627
+ out[k] = props[k];
2628
+ });
2629
+ return out;
2630
+ }
2631
+
2632
+ // ../../lib/adapter-utils/src/props/compose-filter.ts
2633
+ function composeFilter(ownedKeys, filterProps) {
2634
+ const defaultFilter = (key, variantKeys) => variantKeys.has(key) || ownedKeys.has(key);
2635
+ if (!filterProps) {
2636
+ return defaultFilter;
2637
+ }
2638
+ return (key, variantKeys) => defaultFilter(key, variantKeys) || filterProps(key, variantKeys);
2639
+ }
2640
+
2641
+ // ../../lib/adapter-utils/src/slot/slot-validator.ts
2144
2642
  var SlotValidator = class extends InvariantBase {
2145
2643
  #name;
2146
2644
  #elementTerm;
@@ -2163,18 +2661,18 @@ var SlotValidator = class extends InvariantBase {
2163
2661
  };
2164
2662
 
2165
2663
  // ../../lib/adapter-utils/src/slot/policies.ts
2166
- import { clsx } from "clsx";
2664
+ import { clsx as clsx3 } from "clsx";
2167
2665
  function chainHandlers(childHandler, slotHandler) {
2168
2666
  return (...args) => {
2169
2667
  childHandler(...args);
2170
2668
  const event = args[0];
2171
- if (!(typeof event === "object" && event !== null && "defaultPrevented" in event && event.defaultPrevented)) {
2669
+ if (!(isObject(event) && "defaultPrevented" in event && event.defaultPrevented)) {
2172
2670
  slotHandler(...args);
2173
2671
  }
2174
2672
  };
2175
2673
  }
2176
2674
  function mergeClassNames(slot, child) {
2177
- return clsx(slot, child);
2675
+ return clsx3(slot, child);
2178
2676
  }
2179
2677
  function mergeStyles(slot, child) {
2180
2678
  if (!isPlainObject(slot) || !isPlainObject(child)) return child;
@@ -2206,209 +2704,6 @@ function applyMergePolicy(key, slotVal, childVal) {
2206
2704
  return policyHandlers[classifyProp(key, slotVal, childVal)](slotVal, childVal);
2207
2705
  }
2208
2706
 
2209
- // ../../lib/adapter-utils/src/build-definition.ts
2210
- function buildDefinition(name, tag) {
2211
- return {
2212
- identity: {
2213
- id: name,
2214
- name,
2215
- tag
2216
- },
2217
- capabilities: {},
2218
- metadata: {},
2219
- diagnostics: []
2220
- };
2221
- }
2222
-
2223
- // ../../lib/adapter-utils/src/build-variant-config.ts
2224
- function flattenClassName(cls) {
2225
- return Array.isArray(cls) ? cls.join(" ") : cls;
2226
- }
2227
- function mapVariantRecord(source, mapper) {
2228
- return iterate.mapValues(
2229
- source,
2230
- (inner) => iterate.mapValues(inner, mapper)
2231
- );
2232
- }
2233
- function buildVariantConfig(variants, presets, defaults, compounds) {
2234
- return {
2235
- variants: mapVariantRecord(variants ?? {}, flattenClassName),
2236
- ...presets !== void 0 && Object.keys(presets).length > 0 && { presets },
2237
- ...defaults !== void 0 && Object.keys(defaults).length > 0 && { defaults },
2238
- ...compounds !== void 0 && compounds.length > 0 && {
2239
- compounds
2240
- }
2241
- };
2242
- }
2243
-
2244
- // ../../runtime/core/src/apply-attributes.ts
2245
- function applyAttributes(nodeId, incoming, decoration, removedKeys) {
2246
- const existing = decoration[nodeId] ?? {};
2247
- const next = { ...existing.attributes };
2248
- if (removedKeys !== void 0) {
2249
- iterate.forEachSet(removedKeys, (key) => {
2250
- delete next[key];
2251
- });
2252
- }
2253
- Object.assign(next, incoming);
2254
- const { attributes: _dropped, ...rest } = existing;
2255
- const nextDecoration = Object.keys(next).length > 0 ? { ...rest, attributes: next } : rest;
2256
- return { ...decoration, [nodeId]: nextDecoration };
2257
- }
2258
-
2259
- // ../../runtime/core/src/get-active-props.ts
2260
- function getActiveProps(nodeId, decoration) {
2261
- const dec = decoration[nodeId];
2262
- return { ...dec?.attributes ?? {}, ...dec?.variants ?? {} };
2263
- }
2264
-
2265
- // ../../runtime/core/src/render-component.ts
2266
- function renderComponent(definition, tree, render, backend) {
2267
- return backend.render({ definition, tree, render });
2268
- }
2269
-
2270
- // ../../runtime/core/src/build-tree-context.ts
2271
- function buildNode(input, slotAssignments, seenIds, diagnostics) {
2272
- if (seenIds.has(input.id)) {
2273
- diagnostics.push({
2274
- code: "duplicate-node-id",
2275
- message: `Duplicate node id "${input.id}"`,
2276
- severity: "error"
2277
- });
2278
- } else {
2279
- seenIds.add(input.id);
2280
- }
2281
- if (input.slot !== void 0) {
2282
- slotAssignments.set(input.id, input.slot);
2283
- }
2284
- const children = Object.freeze(
2285
- (input.children ?? []).map((child) => buildNode(child, slotAssignments, seenIds, diagnostics))
2286
- );
2287
- if (input.kind === "native") {
2288
- return Object.freeze({ kind: "native", id: input.id, tag: input.tag, children });
2289
- }
2290
- return Object.freeze({ kind: "component", id: input.id, children });
2291
- }
2292
- function buildTreeContext(root) {
2293
- const slotAssignments = /* @__PURE__ */ new Map();
2294
- const diagnostics = [];
2295
- const rootNode = buildNode(root, slotAssignments, /* @__PURE__ */ new Set(), diagnostics);
2296
- return Object.freeze({ root: rootNode, slotAssignments, diagnostics });
2297
- }
2298
-
2299
- // ../../runtime/core/src/build-render-context.ts
2300
- function buildRenderContext(decoration = {}) {
2301
- return { decoration: new Map(Object.entries(decoration)) };
2302
- }
2303
-
2304
- // ../../lib/adapter-utils/src/resolve-compounds.ts
2305
- function matchesCompound(active, compound) {
2306
- const { class: _, ...conditions } = compound;
2307
- return Object.entries(conditions).every(([key, expected]) => {
2308
- const actual = active[key];
2309
- return Array.isArray(expected) ? expected.includes(actual) : actual === expected;
2310
- });
2311
- }
2312
- function resolveCompounds(active, compounds) {
2313
- if (!compounds?.length) return [];
2314
- const out = [];
2315
- iterate.forEach(compounds, (compound) => {
2316
- if (matchesCompound(active, compound)) {
2317
- out.push(flattenClassName(compound.class));
2318
- }
2319
- });
2320
- return out;
2321
- }
2322
-
2323
- // ../../lib/adapter-utils/src/resolve-classes.ts
2324
- function resolveClasses(decoration, variantConfig, variantDefaults, recipe, compounds, variantLookup) {
2325
- const active = getActiveProps("root", decoration);
2326
- if (variantLookup !== void 0 && recipe === void 0) {
2327
- const activeVariants = {};
2328
- iterate.forEachKey(variantConfig.variants, (key) => {
2329
- const value = active[key];
2330
- if (typeof value === "string") activeVariants[key] = value;
2331
- });
2332
- const lookupKey = buildPrecomputedKey(activeVariants);
2333
- const precomputedValue = variantLookup[lookupKey];
2334
- if (precomputedValue !== void 0) {
2335
- return {
2336
- variantClasses: precomputedValue !== "" ? [precomputedValue] : [],
2337
- compoundClasses: []
2338
- };
2339
- }
2340
- }
2341
- const passInput = recipe !== void 0 ? { ...active, preset: recipe } : active;
2342
- const { context } = createVariantPass(passInput, variantConfig).execute({ classes: [] });
2343
- const variantClasses = context.classes;
2344
- const presetOverrides = recipe !== void 0 ? variantConfig.presets?.[recipe] ?? {} : {};
2345
- const resolvedValues = {
2346
- ...variantDefaults,
2347
- ...presetOverrides,
2348
- ...active
2349
- };
2350
- const compoundClasses = resolveCompounds(resolvedValues, compounds);
2351
- return { variantClasses, compoundClasses };
2352
- }
2353
-
2354
- // ../../lib/adapter-utils/src/build-pipeline.ts
2355
- function buildStylePipeline(variants, presets, defaults, compounds, variantLookup) {
2356
- if (variants === void 0 && compounds === void 0 && presets === void 0 && variantLookup === void 0) {
2357
- return void 0;
2358
- }
2359
- const variantConfig = buildVariantConfig(variants, presets, defaults, compounds);
2360
- return {
2361
- execute(decoration, recipe) {
2362
- return resolveClasses(decoration, variantConfig, defaults, recipe, compounds, variantLookup);
2363
- }
2364
- };
2365
- }
2366
-
2367
- // ../../lib/adapter-utils/src/join-classes.ts
2368
- function joinClasses(...classes) {
2369
- return classes.filter(Boolean).join(" ");
2370
- }
2371
-
2372
- // ../../lib/adapter-utils/src/decoration-utils.ts
2373
- function withAttributes(dec, attributes) {
2374
- const { attributes: _a, ...rest } = dec;
2375
- return attributes !== void 0 ? { ...rest, attributes } : rest;
2376
- }
2377
-
2378
- // ../../lib/adapter-utils/src/apply-aria.ts
2379
- function applyAria(decoration, tag, ariaEngine) {
2380
- if (ariaEngine === void 0) return decoration;
2381
- const dec = decoration["root"];
2382
- if (dec?.attributes === void 0) return decoration;
2383
- const result = ariaEngine.validate(tag, dec.attributes);
2384
- const cleaned = result.props;
2385
- return {
2386
- ...decoration,
2387
- root: withAttributes(dec, Object.keys(cleaned).length > 0 ? cleaned : void 0)
2388
- };
2389
- }
2390
-
2391
- // ../../lib/adapter-utils/src/apply-filter-props.ts
2392
- function applyFilterProps(decoration, filterFn, variantKeys) {
2393
- if (filterFn === void 0) return decoration;
2394
- const dec = decoration["root"];
2395
- if (dec?.attributes === void 0) return decoration;
2396
- const kept = Object.fromEntries(
2397
- Object.entries(dec.attributes).filter(([k]) => !filterFn(k, variantKeys))
2398
- );
2399
- return {
2400
- ...decoration,
2401
- root: withAttributes(dec, Object.keys(kept).length > 0 ? kept : void 0)
2402
- };
2403
- }
2404
-
2405
- // ../../lib/adapter-utils/src/apply-ref.ts
2406
- function applyRef(decoration, ref) {
2407
- if (ref == null) return decoration;
2408
- const existing = decoration["root"] ?? {};
2409
- return { ...decoration, root: { ...existing, ref } };
2410
- }
2411
-
2412
2707
  // ../../adapters/react/src/shared/merge-refs.ts
2413
2708
  function mergeRefs(...refs) {
2414
2709
  return mergeRefsCore(...refs);
@@ -2421,25 +2716,52 @@ function Slottable({ children }) {
2421
2716
  return /* @__PURE__ */ jsx(Fragment, { children });
2422
2717
  }
2423
2718
 
2719
+ // ../../adapters/react/src/shared/slot/predicates.ts
2720
+ import { isValidElement } from "react";
2721
+ function isSlottableElement(value) {
2722
+ return isValidElement(value) && value.type === Slottable;
2723
+ }
2724
+
2725
+ // ../../adapters/react/src/shared/slot/compose-refs.ts
2726
+ function isReactWarningGetter(getter) {
2727
+ return isFunction(getter) && "isReactWarning" in getter;
2728
+ }
2729
+ function hasWarningGetter(obj, key) {
2730
+ return isPlainObject(obj) && isReactWarningGetter(Object.getOwnPropertyDescriptor(obj, key)?.get);
2731
+ }
2732
+ function getElementRef(element) {
2733
+ const el = element;
2734
+ return isPlainObject(el) ? el.ref ?? null : null;
2735
+ }
2736
+ function getPropsRef(element) {
2737
+ const props = element.props;
2738
+ return isPlainObject(props) ? props.ref ?? null : null;
2739
+ }
2740
+
2424
2741
  // ../../adapters/react/src/shared/slot/clone.ts
2425
2742
  import { cloneElement } from "react";
2426
2743
  function cloneWithProps(child, props, ref) {
2427
2744
  return cloneElement(child, ref !== null ? { ...props, ref } : props);
2428
2745
  }
2429
2746
 
2747
+ // ../../adapters/react/src/shared/slot/make-clone-slot-child.ts
2748
+ import { Fragment as Fragment2 } from "react";
2749
+ function makeCloneSlotChild(getChildRef) {
2750
+ return function cloneSlotChild({ child, slotProps, ref }) {
2751
+ const childProps = child.props;
2752
+ const isFragment = child.type === Fragment2;
2753
+ const childRef = isFragment ? null : getChildRef(child);
2754
+ const mergedRef = isFragment ? null : mergeRefs(ref, childRef);
2755
+ const merged = mergeSlotProps(slotProps, childProps);
2756
+ return cloneWithProps(child, merged, mergedRef);
2757
+ };
2758
+ }
2759
+
2430
2760
  // ../../adapters/react/src/shared/slot/applySlot.ts
2431
2761
  import { isValidElement as isValidElement3 } from "react";
2432
2762
 
2433
2763
  // ../../adapters/react/src/shared/slot/extractSlottable.ts
2434
- import { createElement, Fragment as Fragment2, isValidElement as isValidElement2 } from "react";
2435
-
2436
- // ../../adapters/react/src/shared/slot/predicates.ts
2437
- import { isValidElement } from "react";
2438
- function isSlottableElement(value) {
2439
- return isValidElement(value) && value.type === Slottable;
2440
- }
2441
-
2442
- // ../../adapters/react/src/shared/slot/extractSlottable.ts
2764
+ import { createElement, Fragment as Fragment3, isValidElement as isValidElement2 } from "react";
2443
2765
  function extractSlottable(children) {
2444
2766
  const childrenArray = Array.isArray(children) ? children : [children];
2445
2767
  const slottables = childrenArray.filter(isSlottableElement);
@@ -2459,14 +2781,14 @@ function extractSlottable(children) {
2459
2781
  "Slottable expects exactly one React element child, received text content"
2460
2782
  );
2461
2783
  invariant(isValidElement2(child), "Slottable expects exactly one React element child");
2462
- invariant(child.type !== Fragment2, "Slottable child cannot be a Fragment");
2784
+ invariant(child.type !== Fragment3, "Slottable child cannot be a Fragment");
2463
2785
  const index = childrenArray.indexOf(slottable);
2464
2786
  return {
2465
2787
  child,
2466
2788
  // Fragment wrapper: Slot owns no DOM node; ref composition happens only on the merge target.
2467
2789
  rebuild(merged) {
2468
2790
  const out = childrenArray.map((node, i) => i === index ? merged : node);
2469
- return createElement(Fragment2, null, ...out);
2791
+ return createElement(Fragment3, null, ...out);
2470
2792
  }
2471
2793
  };
2472
2794
  }
@@ -2482,16 +2804,6 @@ function applySlot(children, slotProps, ref, cloneSlotChild) {
2482
2804
  return cloneSlotChild({ child: children, slotProps, ref });
2483
2805
  }
2484
2806
 
2485
- // ../../adapters/react/src/shared/slot/make-render-as-child.ts
2486
- import { isValidElement as isValidElement4 } from "react";
2487
- function makeRenderAsChild(cloneSlotChild) {
2488
- return function renderAsChild(children, className, ref) {
2489
- if (!isValidElement4(children)) throw new Error("asChild requires a React element child");
2490
- const slotProps = className ? { className } : {};
2491
- return cloneSlotChild({ child: children, slotProps, ref: ref ?? null });
2492
- };
2493
- }
2494
-
2495
2807
  // ../../adapters/react/src/shared/apply-display-name.ts
2496
2808
  function applyDisplayName(component, name) {
2497
2809
  const displayName = name ?? "PolymorphicComponent";
@@ -2501,148 +2813,170 @@ function applyDisplayName(component, name) {
2501
2813
  });
2502
2814
  }
2503
2815
 
2504
- // ../../adapters/react/src/backend/extract-decoration.ts
2505
- function isStyleValue(v) {
2506
- return isString(v) || isNumber(v);
2507
- }
2508
- function isAttributeValue(v) {
2509
- return isString(v) || isNumber(v) || typeof v === "boolean";
2816
+ // ../../adapters/react/src/shared/render.ts
2817
+ import { createElement as createElement2 } from "react";
2818
+ import { jsx as jsx2 } from "react/jsx-runtime";
2819
+ function buildRenderState(tag, directives, props, className, children) {
2820
+ const state = { tag, directives, props, className };
2821
+ if (children !== void 0) state.children = children;
2822
+ return state;
2510
2823
  }
2511
- function assignIfNotEmpty(target, key, value) {
2512
- if (Object.keys(value).length > 0) {
2513
- target[key] = value;
2824
+ function prepareRenderState(runtime, props, filterProps) {
2825
+ const { as, asChild, render: _render, children, className, recipe, ...rest } = props;
2826
+ const tag = runtime.resolveTag(as);
2827
+ if (runtime.options.allowedAs !== void 0 && as !== void 0) {
2828
+ enforceAllowedAs(
2829
+ tag,
2830
+ runtime.options.allowedAs,
2831
+ runtime.options.diagnostics,
2832
+ runtime.options.displayName
2833
+ );
2514
2834
  }
2835
+ const mergedProps = runtime.resolveProps(rest);
2836
+ const htmlNormalizers = runtime.options.htmlPropNormalizersFn?.(tag);
2837
+ const baseProps = htmlNormalizers?.length ? htmlNormalizers.reduce((acc, fn) => ({ ...acc, ...fn(acc) }), mergedProps) : mergedProps;
2838
+ const normalizedProps = runtime.options.normalizeFn ? runtime.options.normalizeFn(baseProps) : baseProps;
2839
+ const resolvedClass = runtime.resolveClasses(tag, normalizedProps, className, recipe);
2840
+ const filteredProps = applyFilter(normalizedProps, filterProps, runtime.options.variantKeys);
2841
+ const directives = {
2842
+ ...as !== void 0 && { as },
2843
+ ...asChild !== void 0 && { asChild }
2844
+ };
2845
+ return buildRenderState(tag, directives, filteredProps, resolvedClass, children);
2515
2846
  }
2516
- function extractStyles(value, styles) {
2517
- if (!isObject(value)) return false;
2518
- iterate.forEachEntry(value, (k, v) => {
2519
- if (isStyleValue(v)) {
2520
- styles[k] = v;
2521
- }
2522
- });
2523
- return true;
2847
+ function warnDiscardedChildren(originalChildren, normalizedChildren, validator) {
2848
+ if (!Array.isArray(originalChildren)) return;
2849
+ const discarded = originalChildren.length - normalizedChildren.length;
2850
+ if (discarded > 0) validator.warnDiscardedChildren(discarded);
2851
+ }
2852
+ function isSingleElementArray(arr) {
2853
+ return arr.length === 1;
2524
2854
  }
2525
- function extractListener(key, value, listeners) {
2526
- if (!key.startsWith("on") || !isFunction(value)) {
2855
+ function resolveSlotChildren(children, normalized, validator) {
2856
+ warnDiscardedChildren(children, normalized, validator);
2857
+ if (isSingleElementArray(normalized)) {
2858
+ return normalized[0];
2859
+ }
2860
+ if (normalized.length > 1 && normalized.some(isSlottableElement)) {
2861
+ return normalized;
2862
+ }
2863
+ validator.assertSingleChild(normalized.length);
2864
+ return null;
2865
+ }
2866
+ function validateSlotDirectives(directives, validator) {
2867
+ const { as, asChild } = directives;
2868
+ if (!asChild) return false;
2869
+ if (as !== void 0) {
2870
+ validator.assertExclusive();
2527
2871
  return false;
2528
2872
  }
2529
- listeners[key] = value;
2530
2873
  return true;
2531
2874
  }
2532
- function extractAttributeOrVariant(key, value, attributes, variants, variantKeys) {
2533
- if (variantKeys?.has(key)) {
2534
- variants[key] = value;
2535
- } else {
2536
- attributes[key] = value;
2537
- }
2538
- }
2539
- function extractDecoration(props, variantKeys) {
2540
- const attributes = {};
2541
- const styles = {};
2542
- const listeners = {};
2543
- const variants = {};
2544
- const dec = {};
2545
- iterate.forEachEntry(props, (key, value) => {
2546
- if (key === "children" || key === "slot" || key === "ref") return;
2547
- if (key === "style" && extractStyles(value, styles)) return;
2548
- if (extractListener(key, value, listeners)) return;
2549
- if (isAttributeValue(value)) {
2550
- extractAttributeOrVariant(key, value, attributes, variants, variantKeys);
2551
- }
2875
+ function resolveSlotRender(state, getNormalized, validator) {
2876
+ if (!validateSlotDirectives(state.directives, validator)) return null;
2877
+ const child = resolveSlotChildren(state.children, getNormalized(), validator);
2878
+ if (child === null) return null;
2879
+ return { child };
2880
+ }
2881
+ function renderResolvedSlot(slotComponent, state, resolved, ref) {
2882
+ return jsx2(slotComponent, {
2883
+ ...state.props,
2884
+ className: state.className,
2885
+ ref,
2886
+ children: resolved.child
2552
2887
  });
2553
- assignIfNotEmpty(dec, "attributes", attributes);
2554
- assignIfNotEmpty(dec, "styles", styles);
2555
- assignIfNotEmpty(dec, "listeners", listeners);
2556
- assignIfNotEmpty(dec, "variants", variants);
2557
- const ref = props.ref;
2558
- if (ref !== void 0) {
2559
- dec.ref = ref;
2560
- }
2561
- return dec;
2562
2888
  }
2563
-
2564
- // ../../adapters/react/src/current/helpers/render-normally.ts
2565
- import { cloneElement as cloneElement2 } from "react";
2566
-
2567
- // ../../adapters/react/src/backend/react-backend.ts
2568
- import React from "react";
2569
-
2570
- // ../../adapters/react/src/backend/build-props.ts
2571
- function buildPropsFromDecoration(id, decoration) {
2889
+ function tryRenderAsChild(state, ref, slotComponent, getNormalized, validator) {
2890
+ const resolved = resolveSlotRender(state, getNormalized, validator);
2891
+ if (resolved === null) return null;
2892
+ return renderResolvedSlot(slotComponent, state, resolved, ref);
2893
+ }
2894
+ function buildElementProps(props, className, ref, children) {
2895
+ const { role, ...rest } = props;
2572
2896
  return {
2573
- key: id,
2574
- ...decoration?.attributes,
2575
- ...decoration?.styles !== void 0 ? { style: decoration.styles } : {},
2576
- ...decoration?.listeners,
2577
- ...decoration?.ref !== void 0 ? { ref: decoration.ref } : {}
2897
+ ...rest,
2898
+ className,
2899
+ ref,
2900
+ ...children !== void 0 && { children },
2901
+ ...isKnownAriaRole(role) && { role }
2578
2902
  };
2579
2903
  }
2580
-
2581
- // ../../adapters/react/src/backend/react-backend.ts
2582
- function renderNode(node, render) {
2583
- const children = node.children.map((child) => renderNode(child, render));
2584
- if (node.kind === "component") {
2585
- return React.createElement(React.Fragment, { key: node.id }, ...children);
2586
- }
2587
- const decoration = render.decoration.get(node.id);
2588
- const props = buildPropsFromDecoration(node.id, decoration);
2589
- return React.createElement(node.tag, props, ...children);
2590
- }
2591
- var reactBackend = {
2592
- render(context) {
2593
- return renderNode(context.tree.root, context.render);
2594
- }
2595
- };
2596
-
2597
- // ../../adapters/react/src/current/helpers/render-normally.ts
2598
- function renderNormally(definition, tag, decoration, children) {
2599
- const treeCtx = buildTreeContext({ kind: "native", tag, id: "root", children: [] });
2600
- const rendered = renderComponent(
2601
- definition,
2602
- treeCtx,
2603
- buildRenderContext(decoration),
2604
- reactBackend
2904
+ function renderIntrinsic(state, ref, runtime) {
2905
+ const elementProps = buildElementProps(state.props, state.className, ref, state.children);
2906
+ const domProps = typeof state.tag === "string" ? runtime.resolveAria(state.tag, elementProps).props : elementProps;
2907
+ return createElement2(state.tag, domProps);
2908
+ }
2909
+ function render({
2910
+ runtime,
2911
+ props,
2912
+ ref,
2913
+ slotComponent,
2914
+ normalizeChildren,
2915
+ filterProps,
2916
+ slotValidator,
2917
+ childrenEvaluator
2918
+ }) {
2919
+ const state = prepareRenderState(runtime, props, filterProps);
2920
+ let cached;
2921
+ const getNormalizedChildren = () => cached ??= normalizeChildren(state.children);
2922
+ if (process.env.NODE_ENV !== "production") {
2923
+ childrenEvaluator?.evaluate(getNormalizedChildren());
2924
+ runtime.options.htmlChildrenEvaluatorFn?.(state.tag)?.evaluate(getNormalizedChildren());
2925
+ }
2926
+ if (typeof props.render === "function") {
2927
+ return props.render({ ...state.props, className: state.className, ref });
2928
+ }
2929
+ const slotResult = tryRenderAsChild(
2930
+ state,
2931
+ ref,
2932
+ slotComponent,
2933
+ getNormalizedChildren,
2934
+ slotValidator
2605
2935
  );
2606
- return children === void 0 ? rendered : cloneElement2(rendered, {}, children);
2936
+ return slotResult ?? renderIntrinsic(state, ref, runtime);
2607
2937
  }
2608
2938
 
2609
- // ../../adapters/react/src/current/helpers/render-with-callback.ts
2610
- function renderWithCallback(render, domProps, className, ref) {
2611
- const props = { ...domProps };
2612
- if (className) props.className = className;
2613
- if (ref !== void 0) props.ref = ref;
2614
- return render(props);
2939
+ // ../../adapters/react/src/shared/build-runtime.ts
2940
+ function normalizeOptions(options, defaultSlotComponent) {
2941
+ return {
2942
+ ...options,
2943
+ ...resolveAdapterCommonOptions(options),
2944
+ slotComponent: options.slotComponent ?? defaultSlotComponent
2945
+ };
2946
+ }
2947
+ function buildRuntime(options, defaultSlotComponent, normalizeChildren) {
2948
+ const normalized = normalizeOptions(options, defaultSlotComponent);
2949
+ const { runtime, ownedKeys } = buildCoreRuntime(normalized);
2950
+ const { childrenEvaluator } = buildEngines(
2951
+ normalized.diagnostics,
2952
+ normalized.enforcement?.children,
2953
+ normalized.name
2954
+ );
2955
+ const filterProps = composeFilter(ownedKeys, normalized.filterProps);
2956
+ const slotValidator = new SlotValidator(normalized.name, normalized.diagnostics, "React element");
2957
+ return {
2958
+ runtime,
2959
+ filterProps,
2960
+ slotValidator,
2961
+ slotComponent: normalized.slotComponent,
2962
+ normalizeChildren,
2963
+ ...childrenEvaluator !== void 0 && { childrenEvaluator }
2964
+ };
2615
2965
  }
2616
2966
 
2617
2967
  export {
2618
- isFunction,
2619
- isPlainObject,
2968
+ defineContractComponent,
2969
+ isString,
2620
2970
  SLOT_NAME,
2621
2971
  COMPONENT_DEFAULT_TAG,
2622
- AriaPolicyEngine,
2623
- getHtmlChildrenEvaluator,
2624
- enforceAllowedAs,
2625
- applyPropNormalizers,
2626
- defineContractComponent,
2627
- buildEngines,
2628
- resolveAdapterCommonOptions,
2629
- SlotValidator,
2630
- mergeSlotProps,
2631
- buildDefinition,
2632
- flattenClassName,
2633
- applyAttributes,
2634
- buildStylePipeline,
2635
- joinClasses,
2636
- applyAria,
2637
- applyFilterProps,
2638
- applyRef,
2639
2972
  mergeRefs,
2640
2973
  applyDisplayName,
2641
- cloneWithProps,
2642
2974
  Slottable,
2975
+ hasWarningGetter,
2976
+ getElementRef,
2977
+ getPropsRef,
2978
+ makeCloneSlotChild,
2643
2979
  applySlot,
2644
- makeRenderAsChild,
2645
- extractDecoration,
2646
- renderNormally,
2647
- renderWithCallback
2980
+ render,
2981
+ buildRuntime
2648
2982
  };