clava 0.7.2 → 0.7.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # clava
2
2
 
3
+ ## 0.7.3
4
+
5
+ ### Debug attribute in development
6
+
7
+ In development, recipe results now include a `data-clava-debug` attribute. It lists the resolved variants, so you can inspect them in the browser's developer tools:
8
+
9
+ ```html
10
+ <button data-clava-debug="size='lg' intent='primary'"></button>
11
+ ```
12
+
13
+ When one recipe's output feeds another, for example through [`splitProps`](https://clava.style/docs/reference/split-props) in a wrapper component, the attribute lists the variants of every recipe. Those of the recipe that renders the element come first.
14
+
15
+ The attribute is added only when `NODE_ENV` is `"development"`, so test snapshots don't change. Use the new `debug` option of [`create`](https://clava.style/docs/reference/create) to change this. The attribute is never added in production.
16
+
17
+ ```ts
18
+ const { cv } = create({ debug: true });
19
+ ```
20
+
21
+ Clava now reads `process.env.NODE_ENV` when it's imported, not only when a recipe uses `refine` or computed defaults. Bundlers replace this expression. If you load Clava without a bundler, define `process.env.NODE_ENV` first.
22
+
3
23
  ## 0.7.2
4
24
 
5
25
  ### Computed defaults read settled values in extension chains
package/README.md CHANGED
@@ -23,6 +23,7 @@ import type { Variant, VariantProps } from "clava";
23
23
  - [React](#react)
24
24
  - [Solid](#solid)
25
25
  - [`create()` And `cx()`](#create-and-cx)
26
+ - [Debugging](#debugging)
26
27
  - [Type Helpers](#type-helpers)
27
28
  - [Comparison](#comparison)
28
29
  - [API Summary](#api-summary)
@@ -612,6 +613,61 @@ title().class;
612
613
 
613
614
  When a recipe created by one factory extends a recipe created by another factory, the extended recipe's transform is preserved for its own classes and the parent transform still runs on the final joined string.
614
615
 
616
+ ## Debugging
617
+
618
+ In development, recipe results include a `data-clava-debug` attribute. It shows the resolved variants, so you can inspect them in the browser's developer tools.
619
+
620
+ ```tsx
621
+ const button = cv({
622
+ variants: {
623
+ size: { sm: "button-sm", lg: "button-lg" },
624
+ intent: { primary: "button-primary" },
625
+ },
626
+ defaultVariants: { size: "sm", intent: "primary" },
627
+ });
628
+
629
+ <button {...button.jsx({ size: "lg" })} />;
630
+ ```
631
+
632
+ ```html
633
+ <button
634
+ class="button-lg button-primary"
635
+ data-clava-debug="size='lg' intent='primary'"
636
+ ></button>
637
+ ```
638
+
639
+ The value lists the variants that [`getVariants()`](#output-modes) returns as `key=value` pairs, in variant order. These values include defaults and [`refine`](#refine) updates. Strings use single quotes. The attribute doesn't show where a recipe was created, because a source location can differ between server-rendered HTML and the browser, which would cause hydration mismatches.
640
+
641
+ When a recipe receives a `data-clava-debug` prop, it adds the incoming value after its own. [`splitProps()`](#splitting-props) sends this prop to the first recipe, together with `class`, `className`, and `style`, and also keeps it in the rest props. In a wrapper component, the element then lists the variants of the recipe that renders it first, followed by those of the outer recipes:
642
+
643
+ ```tsx
644
+ function Button(props: ButtonProps) {
645
+ const [variantProps, rest] = splitProps(props, button);
646
+ return <Clickable {...rest} {...button.jsx(variantProps)} />;
647
+ }
648
+ ```
649
+
650
+ ```html
651
+ <button
652
+ class="clickable button-lg button-primary"
653
+ data-clava-debug="disabled=false size='lg' intent='primary'"
654
+ ></button>
655
+ ```
656
+
657
+ The attribute is added only when `process.env.NODE_ENV` is `"development"`, so test snapshots don't change. Use the `debug` option of [`create()`](#create-and-cx) to change this. The attribute is never added in production, and bundlers remove the code that builds it from production builds. Don't use it to select or style elements.
658
+
659
+ ```ts
660
+ import { create } from "clava";
661
+
662
+ // Add it in tests too.
663
+ const { cv } = create({ debug: true });
664
+
665
+ // Never add it.
666
+ const { cv: quietCv } = create({ debug: false });
667
+ ```
668
+
669
+ Clava reads `process.env.NODE_ENV` when it creates a factory, including the package-level `cv` on import. Bundlers replace this expression. If you load Clava without a bundler, define `process.env.NODE_ENV` first.
670
+
615
671
  ## Type Helpers
616
672
 
617
673
  Use `RecipeLike<typeof recipe, R>` to constrain a generic component's recipe prop to a structurally compatible recipe. Use `VariantPropsWithRecipe<typeof recipe, R>` to combine the selected recipe's variant props with its `recipe` prop, or pass a third type argument for a custom prop name. See [Constraining Recipe Props](#constraining-recipe-props).
@@ -745,4 +801,4 @@ Both groups resolve one fixed prop set on every iteration, so every package with
745
801
 
746
802
  `cx(...classes)` joins class values with `clsx` and applies the factory's `transformClass`.
747
803
 
748
- `create(options?)` returns isolated `{ cv, cx }` helpers. The only option is `transformClass?: (className: string) => string`.
804
+ `create(options?)` returns isolated `{ cv, cx }` helpers. The options are `transformClass?: (className: string) => string` and `debug?: boolean`. See [Debugging](#debugging).
package/dist/index.d.ts CHANGED
@@ -437,6 +437,12 @@ export interface CVConfig<V extends Variants = {}, E extends AnyRecipe[] = []> {
437
437
  }
438
438
  interface CreateParams {
439
439
  transformClass?: (className: string) => string;
440
+ /**
441
+ * Whether recipes add a `data-clava-debug` attribute that lists their
442
+ * resolved variants. Defaults to `true` when `NODE_ENV` is
443
+ * `"development"`. The attribute is never added in production.
444
+ */
445
+ debug?: boolean;
440
446
  }
441
447
  /**
442
448
  * Splits props into multiple groups based on key sources. Each source gets its
@@ -461,5 +467,4 @@ export declare const cv: <V extends Variants = {}, const E extends AnyRecipe[] =
461
467
  * This behaves like the `cx` function returned by `create()` with no options.
462
468
  */
463
469
  export declare function cx(...classes: ClassValue$1[]): string;
464
- export type { ClassValue, HTMLCSSProperties, HTMLObjProps, HTMLProps, JSXCSSProperties, JSXProps, ModalRecipe, Recipe, RecipeLike, RecipeProps, SplitPropsFunction, StyleClassProps, StyleClassValue, StyleValue };
465
- //# sourceMappingURL=index.d.ts.map
470
+ export type { ClassValue, HTMLCSSProperties, HTMLObjProps, HTMLProps, JSXCSSProperties, JSXProps, ModalRecipe, Recipe, RecipeLike, RecipeProps, SplitPropsFunction, StyleClassProps, StyleClassValue, StyleValue };
package/dist/index.js CHANGED
@@ -224,6 +224,31 @@ function styleValueToHTMLObjStyle(style) {
224
224
  }
225
225
  return result;
226
226
  }
227
+ // src/debug.ts
228
+ const DEBUG_ATTRIBUTE = "data-clava-debug";
229
+ function isDebugEnabled(option) {
230
+ return option ?? process.env.NODE_ENV === "development";
231
+ }
232
+ function formatDebugValue(value) {
233
+ if (typeof value === "string") return `'${value.replaceAll("\\", "\\\\").replaceAll("'", "\\'")}'`;
234
+ if (typeof value === "bigint") return `${value}n`;
235
+ if (typeof value === "function") return "{...}";
236
+ if (typeof value === "object" && value != null) return "{...}";
237
+ return String(value);
238
+ }
239
+ function formatDebugAttribute({ variantKeys, variants, incoming }) {
240
+ const parts = [];
241
+ for (let i = 0; i < variantKeys.length; i++) {
242
+ const key = variantKeys[i];
243
+ if (key === void 0) continue;
244
+ if (!hasOwn(variants, key)) continue;
245
+ const value = variants[key];
246
+ if (value === void 0) continue;
247
+ parts.push(`${key}=${formatDebugValue(value)}`);
248
+ }
249
+ if (typeof incoming === "string" && incoming) parts.push(incoming);
250
+ return parts.join(" ");
251
+ }
227
252
  // src/refine-warning.ts
228
253
  function captureCreationFrame(skipFn) {
229
254
  if (process.env.NODE_ENV === "production") return void 0;
@@ -430,6 +455,7 @@ function splitPropsImpl(selfKeys, selfIsRecipe, props, sources) {
430
455
  const sourcesLength = sources.length;
431
456
  const results = [];
432
457
  let stylingClaimed = selfIsRecipe;
458
+ let stylingResult = null;
433
459
  const selfResult = {};
434
460
  const selfKeysLength = selfKeys.length;
435
461
  for (let i = 0; i < selfKeysLength; i++) {
@@ -437,6 +463,7 @@ function splitPropsImpl(selfKeys, selfIsRecipe, props, sources) {
437
463
  if (key !== void 0 && hasOwn(props, key)) selfResult[key] = props[key];
438
464
  }
439
465
  results.push(selfResult);
466
+ if (selfIsRecipe) stylingResult = selfResult;
440
467
  const effectiveKeyArrays = [selfKeys];
441
468
  for (let s = 0; s < sourcesLength; s++) {
442
469
  const source = sources[s];
@@ -455,7 +482,10 @@ function splitPropsImpl(selfKeys, selfIsRecipe, props, sources) {
455
482
  }
456
483
  results.push(sourceResult);
457
484
  effectiveKeyArrays.push(effectiveKeys);
458
- if (sourceIsRecipe && !stylingClaimed) stylingClaimed = true;
485
+ if (sourceIsRecipe && !stylingClaimed) {
486
+ stylingClaimed = true;
487
+ stylingResult = sourceResult;
488
+ }
459
489
  }
460
490
  const rest = {};
461
491
  const propKeys = Object.keys(props);
@@ -464,6 +494,7 @@ function splitPropsImpl(selfKeys, selfIsRecipe, props, sources) {
464
494
  outer: for (let i = 0; i < propKeysLength; i++) {
465
495
  const key = propKeys[i];
466
496
  if (key === void 0) continue;
497
+ if (key === "data-clava-debug" && stylingResult) stylingResult[key] = props[key];
467
498
  for (let g = 0; g < groupCount; g++) {
468
499
  const arr = effectiveKeyArrays[g];
469
500
  if (arr === void 0) continue;
@@ -506,6 +537,7 @@ function buildPrebuiltVariant(variantDef) {
506
537
  }
507
538
  function create(params = {}) {
508
539
  const transformClass = getOwn(params, "transformClass") ?? identityClass;
540
+ const debug = process.env.NODE_ENV !== "production" && isDebugEnabled(getOwn(params, "debug"));
509
541
  const transformedCx = (...classes) => {
510
542
  return transformClass(clsx(classes));
511
543
  };
@@ -1147,7 +1179,7 @@ function create(params = {}) {
1147
1179
  }
1148
1180
  const allClasses = [computedBaseClass];
1149
1181
  const style = {};
1150
- compute(resolved, userVariantProps, null, null, allClasses, style);
1182
+ const variants = compute(resolved, userVariantProps, null, null, allClasses, style);
1151
1183
  if (hasOwn(propsRecord, "class")) allClasses.push(propsRecord.class);
1152
1184
  if (hasOwn(propsRecord, "className")) allClasses.push(propsRecord.className);
1153
1185
  const psv = propsRecord.style;
@@ -1158,9 +1190,17 @@ function create(params = {}) {
1158
1190
  }
1159
1191
  return {
1160
1192
  className: transformClass(clsx(allClasses)),
1161
- style
1193
+ style,
1194
+ variants
1162
1195
  };
1163
1196
  };
1197
+ const setDebugAttribute = (result, props, variants) => {
1198
+ result[DEBUG_ATTRIBUTE] = formatDebugAttribute({
1199
+ variantKeys,
1200
+ variants,
1201
+ incoming: getOwn(props, DEBUG_ATTRIBUTE)
1202
+ });
1203
+ };
1164
1204
  const getVariants = (variants) => {
1165
1205
  const variantsRecord = variants ?? EMPTY_DEFAULTS;
1166
1206
  let variantProps = variantsRecord;
@@ -1206,21 +1246,25 @@ function create(params = {}) {
1206
1246
  return recipe;
1207
1247
  };
1208
1248
  const defaultRecipe = ((props = {}) => {
1209
- const { className, style } = computeResult(props);
1210
- return {
1249
+ const { className, style, variants } = computeResult(props);
1250
+ const result = {
1211
1251
  class: className,
1212
1252
  style
1213
1253
  };
1254
+ if (debug) setDebugAttribute(result, props, variants);
1255
+ return result;
1214
1256
  });
1215
1257
  initRecipe(defaultRecipe, inputPropsKeys, (props = {}) => {
1216
1258
  return computeResult(props).style;
1217
1259
  });
1218
1260
  const jsxRecipe = ((props = {}) => {
1219
- const { className, style } = computeResult(props);
1220
- return {
1261
+ const { className, style, variants } = computeResult(props);
1262
+ const result = {
1221
1263
  className,
1222
1264
  style
1223
1265
  };
1266
+ if (debug) setDebugAttribute(result, props, variants);
1267
+ return result;
1224
1268
  });
1225
1269
  initRecipe(jsxRecipe, [
1226
1270
  "className",
@@ -1228,11 +1272,13 @@ function create(params = {}) {
1228
1272
  ...variantKeys
1229
1273
  ], (props = {}) => computeResult(props).style);
1230
1274
  const htmlRecipe = ((props = {}) => {
1231
- const { className, style } = computeResult(props);
1232
- return {
1275
+ const { className, style, variants } = computeResult(props);
1276
+ const result = {
1233
1277
  class: className,
1234
1278
  style: styleValueToHTMLStyle(style)
1235
1279
  };
1280
+ if (debug) setDebugAttribute(result, props, variants);
1281
+ return result;
1236
1282
  });
1237
1283
  initRecipe(htmlRecipe, [
1238
1284
  "class",
@@ -1240,11 +1286,13 @@ function create(params = {}) {
1240
1286
  ...variantKeys
1241
1287
  ], (props = {}) => styleValueToHTMLStyle(computeResult(props).style));
1242
1288
  const htmlObjRecipe = ((props = {}) => {
1243
- const { className, style } = computeResult(props);
1244
- return {
1289
+ const { className, style, variants } = computeResult(props);
1290
+ const result = {
1245
1291
  class: className,
1246
1292
  style: styleValueToHTMLObjStyle(style)
1247
1293
  };
1294
+ if (debug) setDebugAttribute(result, props, variants);
1295
+ return result;
1248
1296
  });
1249
1297
  initRecipe(htmlObjRecipe, [
1250
1298
  "class",
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/utils.ts","../src/refine-warning.ts","../src/index.ts"],"sourcesContent":["import type { HTMLCSSProperties, StyleValue } from \"./types.ts\";\n\nexport const hasOwn = Object.hasOwn;\n\n/**\n * Reads a key that may be absent from a plain record. Variant, prop, and config\n * records are plain objects, so a key inherited from a polluted\n * `Object.prototype` would otherwise read back like a value the caller passed\n * or Clava itself resolved.\n */\nexport function getOwn<T extends object, K extends keyof T & string>(\n record: T,\n key: K,\n): T[K] | undefined {\n if (!hasOwn(record, key)) return undefined;\n return record[key];\n}\n\n// Keep this explicit so normalization does not depend on browser globals.\n// Vendor-prefixed variants are derived below instead of duplicating the list.\nconst unitlessNumberProperties = new Set([\n \"animationIterationCount\",\n \"aspectRatio\",\n \"borderImage\",\n \"borderImageOutset\",\n \"borderImageSlice\",\n \"borderImageWidth\",\n \"boxFlex\",\n \"boxFlexGroup\",\n \"boxOrdinalGroup\",\n \"columnCount\",\n \"columns\",\n \"fillOpacity\",\n \"flex\",\n \"flexGrow\",\n \"flexNegative\",\n \"flexOrder\",\n \"flexPositive\",\n \"flexShrink\",\n \"floodOpacity\",\n \"fontSizeAdjust\",\n \"fontWeight\",\n \"gridArea\",\n \"gridColumn\",\n \"gridColumnEnd\",\n \"gridColumnSpan\",\n \"gridColumnStart\",\n \"gridRow\",\n \"gridRowEnd\",\n \"gridRowSpan\",\n \"gridRowStart\",\n \"hyphenateLimitChars\",\n \"initialLetter\",\n \"lineClamp\",\n \"lineHeight\",\n \"maskBorder\",\n \"maskBorderOutset\",\n \"maskBorderSlice\",\n \"maskBorderWidth\",\n \"mathDepth\",\n \"maxLines\",\n \"opacity\",\n \"order\",\n \"orphans\",\n \"scale\",\n \"shapeImageThreshold\",\n \"stopOpacity\",\n \"strokeDasharray\",\n \"strokeDashoffset\",\n \"strokeMiterlimit\",\n \"strokeOpacity\",\n \"strokeWidth\",\n \"tabSize\",\n \"widows\",\n \"zIndex\",\n \"zoom\",\n]);\n\nfunction isCustomProperty(property: string) {\n return property.charCodeAt(0) === 45 && property.charCodeAt(1) === 45;\n}\n\n/**\n * Converts a hyphenated CSS property name to camelCase.\n * @example\n * hyphenToCamel(\"background-color\") // \"backgroundColor\"\n * hyphenToCamel(\"-ms-transition\") // \"msTransition\" (lowercase \"ms\" prefix)\n * hyphenToCamel(\"--custom-var\") // \"--custom-var\" (CSS variables are preserved)\n */\nexport function hyphenToCamel(str: string) {\n // CSS custom properties (variables) should not be converted\n if (isCustomProperty(str)) {\n return str;\n }\n // Fast path: no hyphen -> return as-is\n let hyphenIndex = str.indexOf(\"-\");\n if (hyphenIndex === -1) {\n return str;\n }\n\n let result = \"\";\n let lastIndex = 0;\n while (hyphenIndex !== -1) {\n result += str.slice(lastIndex, hyphenIndex);\n\n const nextIndex = hyphenIndex + 1;\n if (nextIndex >= str.length) {\n result += \"-\";\n lastIndex = nextIndex;\n break;\n }\n\n const code = str.charCodeAt(nextIndex);\n const isAsciiLetter =\n (code >= 65 && code <= 90) || (code >= 97 && code <= 122);\n if (isAsciiLetter) {\n const isMicrosoftPrefix = hyphenIndex === 0 && str.startsWith(\"ms-\", 1);\n result += isMicrosoftPrefix\n ? str[nextIndex]\n : str[nextIndex].toUpperCase();\n lastIndex = nextIndex + 1;\n } else {\n result += \"-\";\n lastIndex = nextIndex;\n }\n\n hyphenIndex = str.indexOf(\"-\", lastIndex);\n }\n\n return result + str.slice(lastIndex);\n}\n\n/**\n * Converts a camelCase CSS property name to hyphenated form.\n * @example\n * camelToHyphen(\"backgroundColor\") // \"background-color\"\n * camelToHyphen(\"msTransition\") // \"-ms-transition\" (lowercase \"ms\" prefix)\n * camelToHyphen(\"--customVar\") // \"--customVar\" (CSS variables are preserved)\n */\nexport function camelToHyphen(str: string) {\n // CSS custom properties (variables) should not be converted\n if (isCustomProperty(str)) {\n return str;\n }\n\n let result = \"\";\n let lastIndex = 0;\n for (let i = 0; i < str.length; i++) {\n const code = str.charCodeAt(i);\n if (code < 65 || code > 90) continue;\n const isMicrosoftPrefix = i === 2 && str.startsWith(\"ms\");\n if (isMicrosoftPrefix) {\n result += \"-\";\n }\n result += str.slice(lastIndex, i);\n result += \"-\";\n result += str[i].toLowerCase();\n lastIndex = i + 1;\n }\n\n if (lastIndex === 0) {\n return str;\n }\n return result + str.slice(lastIndex);\n}\n\nfunction hasVendorPrefix(property: string, prefix: string) {\n const nextCode = property.charCodeAt(prefix.length);\n if (nextCode < 65 || nextCode > 90) return false;\n return property.startsWith(prefix);\n}\n\n// \"ms\" is used in JSX, while camelizing hyphenated properties produces \"Ms\".\nconst vendorPrefixes = [\"Webkit\", \"Moz\", \"ms\", \"Ms\", \"O\"];\n\nfunction isUnitlessNumberProperty(property: string) {\n if (unitlessNumberProperties.has(property)) return true;\n\n for (const prefix of vendorPrefixes) {\n if (!hasVendorPrefix(property, prefix)) continue;\n const firstCode = property.charCodeAt(prefix.length);\n const unprefixedProperty =\n String.fromCharCode(firstCode + 32) + property.slice(prefix.length + 1);\n return unitlessNumberProperties.has(unprefixedProperty);\n }\n return false;\n}\n\nfunction normalizeStyleValue(property: string, value: string | number) {\n if (typeof value === \"string\") {\n return value;\n }\n if (isCustomProperty(property)) {\n return value;\n }\n if (isUnitlessNumberProperty(property)) {\n return value;\n }\n return `${value}px`;\n}\n\n/**\n * Parses a CSS style string into a StyleValue object.\n * @example\n * htmlStyleToStyleValue(\"background-color: red; font-size: 16px;\");\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlStyleToStyleValue(\n styleString: string,\n result: StyleValue = {},\n) {\n if (!styleString) return result;\n const len = styleString.length;\n let i = 0;\n while (i < len) {\n // Skip leading whitespace and stray semicolons\n while (i < len) {\n const c = styleString.charCodeAt(i);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13 && c !== 59) break;\n i++;\n }\n if (i >= len) break;\n // Read property name until ':' or ';'\n const propStart = i;\n while (i < len) {\n const c = styleString.charCodeAt(i);\n if (c === 58 || c === 59) break;\n i++;\n }\n if (i >= len || styleString.charCodeAt(i) === 59) {\n // No colon found - skip this declaration\n if (i < len) {\n // Skip ';'.\n i++;\n }\n continue;\n }\n let propEnd = i;\n // Trim trailing whitespace from property name\n while (propEnd > propStart) {\n const c = styleString.charCodeAt(propEnd - 1);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13) break;\n propEnd--;\n }\n if (propEnd === propStart) {\n // Empty property - skip\n while (i < len && styleString.charCodeAt(i) !== 59) {\n i++;\n }\n if (i < len) {\n i++;\n }\n continue;\n }\n const property = styleString.slice(propStart, propEnd);\n // Skip ':'.\n i++;\n // Skip whitespace before value\n while (i < len) {\n const c = styleString.charCodeAt(i);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13) break;\n i++;\n }\n const valStart = i;\n while (i < len && styleString.charCodeAt(i) !== 59) {\n i++;\n }\n let valEnd = i;\n while (valEnd > valStart) {\n const c = styleString.charCodeAt(valEnd - 1);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13) break;\n valEnd--;\n }\n if (i < len) {\n // Skip ';'.\n i++;\n }\n if (valEnd === valStart) continue;\n const value = styleString.slice(valStart, valEnd);\n // CSS property names and values are dynamic - cast required for index access\n (result as Record<string, string>)[hyphenToCamel(property)] = value;\n }\n\n return result;\n}\n\n/**\n * Converts a hyphenated style object to a camelCase StyleValue object.\n * @example\n * htmlObjStyleToStyleValue({ \"background-color\": \"red\", \"font-size\": \"16px\" });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlObjStyleToStyleValue(\n style: object,\n result: StyleValue = {},\n): StyleValue {\n for (const key in style) {\n if (!hasOwn(style, key)) continue;\n const value = (style as Record<string, unknown>)[key];\n if (value == null) continue;\n const property = hyphenToCamel(key);\n // CSS property names and values are dynamic - cast required for index access\n (result as Record<string, string | number>)[property] = normalizeStyleValue(\n property,\n value as string | number,\n );\n }\n return result;\n}\n\n/**\n * Converts a StyleValue object to a CSS style string.\n * @example\n * styleValueToHTMLStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // \"background-color: red; font-size: 16px;\"\n */\nexport function styleValueToHTMLStyle(style: StyleValue): string {\n let result = \"\";\n for (const key in style) {\n if (!hasOwn(style, key)) continue;\n const value = (style as Record<string, unknown>)[key];\n if (value == null) continue;\n if (result) {\n result += \"; \";\n }\n result += camelToHyphen(key);\n result += \": \";\n result += value as string | number;\n }\n if (!result) return \"\";\n return `${result};`;\n}\n\n/**\n * Converts a StyleValue object to a hyphenated style object.\n * @example\n * styleValueToHTMLObjStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // { \"background-color\": \"red\", \"font-size\": \"16px\" }\n */\nexport function styleValueToHTMLObjStyle(style: StyleValue) {\n const result: HTMLCSSProperties = {};\n for (const key in style) {\n if (!hasOwn(style, key)) continue;\n const value = (style as Record<string, unknown>)[key];\n if (value == null) continue;\n (result as Record<string, unknown>)[camelToHyphen(key)] = value;\n }\n return result;\n}\n","import { getOwn, hasOwn } from \"./utils.ts\";\n\nexport interface CreationFrame {\n stack?: string;\n}\n\nexport interface VariantChange {\n from: unknown;\n to: unknown;\n}\n\n// Once a refine loop is within this many iterations of the cap, start tracking\n// the latest value transition for every variant key that changes between\n// iterations so the warning can report every key that contributed to the\n// oscillation, not just the keys that happened to flip on the final step.\n// Convergent loops (the common case) exit well before this threshold and pay no\n// per-iteration tracking cost.\nexport const REFINE_UNSTABLE_TRACKING_WINDOW = 10;\n\n// Captures the call site of the function passed in `skipFn` so refine-limit\n// warnings can point developers at the originating `cv()` call. Returns\n// `undefined` in production so bundlers that replace `process.env.NODE_ENV` at\n// build time can drop the entire warning machinery. The underlying `.stack`\n// string is formatted lazily on first access in every major engine (V8,\n// SpiderMonkey, JavaScriptCore), so holding the captured frame for the\n// lifetime of the recipe is cheap when no warning fires.\nexport function captureCreationFrame(\n skipFn: Function,\n): CreationFrame | undefined {\n if (process.env.NODE_ENV === \"production\") return undefined;\n if (typeof Error.captureStackTrace === \"function\") {\n const holder: CreationFrame = {};\n Error.captureStackTrace(holder, skipFn);\n return holder;\n }\n // Engines without `Error.captureStackTrace` (SpiderMonkey, JavaScriptCore)\n // can't strip internal frames, but their `Error.stack` getter is still\n // lazy, so returning the Error instance defers the format cost. The\n // resulting trace includes extra frames from this helper, `buildRecipe`,\n // and `cv` itself.\n return new Error();\n}\n\nexport function formatCreationStack(frame: CreationFrame): string | undefined {\n let stack = frame.stack;\n if (!stack) return undefined;\n // V8 prefixes the stack with a leading \"Error\" / \"Error: message\" line that\n // isn't meaningful for a captured location — drop it.\n const newlineIdx = stack.indexOf(\"\\n\");\n if (newlineIdx > 0) {\n const firstLine = stack.slice(0, newlineIdx);\n if (firstLine === \"Error\" || firstLine.startsWith(\"Error:\")) {\n stack = stack.slice(newlineIdx + 1);\n }\n }\n const frames = stack.split(\"\\n\");\n for (let i = 0; i < frames.length; i++) {\n const line = frames[i]?.trim();\n if (!line) continue;\n if (isInternalCreationFrame(line)) continue;\n if (line.includes(\"/node_modules/\")) continue;\n if (line.includes(\"\\\\node_modules\\\\\")) continue;\n if (line.includes(\"node:internal\")) continue;\n return ` ${line}`;\n }\n return undefined;\n}\n\nfunction isInternalCreationFrame(line: string): boolean {\n if (line.includes(\"captureCreationFrame\")) return true;\n if (line.startsWith(\"at buildRecipe \")) return true;\n if (line.startsWith(\"at buildRecipe(\")) return true;\n if (line.startsWith(\"buildRecipe@\")) return true;\n if (line.startsWith(\"at cv \")) return true;\n if (line.startsWith(\"at cv(\")) return true;\n if (line.startsWith(\"cv@\")) return true;\n return false;\n}\n\nfunction formatVariantValue(value: unknown): string {\n if (typeof value === \"string\") return JSON.stringify(value);\n if (typeof value === \"number\") {\n if (Number.isNaN(value)) return \"NaN\";\n return String(value);\n }\n if (typeof value === \"bigint\") return `${value}n`;\n if (value === undefined) return \"undefined\";\n if (value === null) return \"null\";\n if (typeof value === \"boolean\") return String(value);\n if (typeof value === \"symbol\") return String(value);\n if (typeof value === \"function\") return \"[function]\";\n return \"[object]\";\n}\n\nfunction setVariantChange(\n into: Map<string, VariantChange>,\n key: string,\n from: unknown,\n to: unknown,\n): void {\n into.set(key, { from, to });\n}\n\nexport function accumulateUnstableVariantChanges(\n into: Map<string, VariantChange>,\n prev: Record<string, unknown>,\n next: Record<string, unknown>,\n): void {\n for (const key in next) {\n if (!hasOwn(next, key)) continue;\n const from = getOwn(prev, key);\n if (!Object.is(from, next[key])) {\n setVariantChange(into, key, from, next[key]);\n }\n }\n for (const key in prev) {\n if (!hasOwn(prev, key)) continue;\n if (hasOwn(next, key)) continue;\n setVariantChange(into, key, prev[key], undefined);\n }\n}\n\nfunction formatVariantChanges(changes: Map<string, VariantChange>): string {\n return Array.from(changes)\n .map(([key, { from, to }]) => {\n return `${key}: ${formatVariantValue(from)} -> ${formatVariantValue(to)}`;\n })\n .join(\", \");\n}\n\ninterface WarnRefineLimitParams {\n creationFrame: CreationFrame | undefined;\n unstableChanges: Map<string, VariantChange> | null;\n}\n\nexport function warnRefineLimit({\n creationFrame,\n unstableChanges,\n}: WarnRefineLimitParams): void {\n // Bundlers are expected to replace this branch with a production literal,\n // allowing warning-only code below to be removed from consumer bundles.\n if (process.env.NODE_ENV === \"production\") return;\n let message =\n \"Clava: Maximum refine iterations exceeded. This can happen when a \" +\n \"computed default variant or refine callback changes one of the \" +\n \"variants on every run.\";\n if (unstableChanges && unstableChanges.size > 0) {\n message += `\\nVariant(s) that did not stabilize: ${Array.from(unstableChanges.keys()).join(\", \")}.`;\n message += `\\nLatest variant changes before warning: ${formatVariantChanges(unstableChanges)}.`;\n }\n if (creationFrame) {\n const creationStack = formatCreationStack(creationFrame);\n if (creationStack) {\n message += `\\nRecipe created at:\\n${creationStack}`;\n }\n }\n console.warn(message);\n}\n","import clsx, { type ClassValue as ClsxClassValue } from \"clsx\";\nimport {\n REFINE_UNSTABLE_TRACKING_WINDOW,\n type VariantChange,\n accumulateUnstableVariantChanges,\n captureCreationFrame,\n warnRefineLimit,\n} from \"./refine-warning.ts\";\nimport type {\n AnyRecipe,\n ClassValue,\n DefaultVariants,\n ExtendableVariants,\n HTMLCSSProperties,\n HTMLObjProps,\n HTMLProps,\n InferredRecipe,\n JSXCSSProperties,\n JSXProps,\n KeySourceRecipe,\n MergeVariants,\n ModalRecipe,\n Recipe,\n RecipeLike,\n RecipeProps,\n RecipeResult,\n Refine,\n SplitPropsFunction,\n StyleClassProps,\n StyleClassValue,\n StyleValue,\n VariantValues,\n Variants,\n} from \"./types.ts\";\nimport {\n getOwn,\n hasOwn,\n htmlObjStyleToStyleValue,\n htmlStyleToStyleValue,\n styleValueToHTMLObjStyle,\n styleValueToHTMLStyle,\n} from \"./utils.ts\";\n\n// Internal compute path: pushes the variant classes contributed by this\n// recipe (and its extends chain) into `classesOut` and merges any styles\n// into `styleOut`. Base class is handled by callers via RecipeMeta.baseClass\n// to avoid string-parsing round trips. Both outputs are mutated in place to\n// avoid intermediate allocations.\ntype ComputeFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n skipKeys: Set<string> | null,\n skipValues: Record<string, Set<string>> | null,\n classesOut: ClsxClassValue[],\n styleOut: StyleValue,\n) => Record<string, unknown>;\n\ntype ComputeOnceFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n skipKeys: Set<string> | null,\n skipValues: Record<string, Set<string>> | null,\n classesOut: ClsxClassValue[],\n styleOut: StyleValue,\n protection?: RefineProtection | null,\n defaultResolved?: Record<string, unknown>,\n renderOnly?: boolean,\n pass?: RefinePass | null,\n) => Record<string, unknown>;\n\ntype ResolveRefineFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n filterOwnVariants?: boolean,\n) => Record<string, unknown>;\n\ntype ResolveRefineOnceFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n filterOwnVariants?: boolean,\n protection?: RefineProtection | null,\n defaultResolved?: Record<string, unknown>,\n pass?: RefinePass | null,\n renderOnly?: boolean,\n) => Record<string, unknown>;\n\ntype ComputedDefaultVariantFn = (\n defaultValue: unknown,\n variants: Readonly<Record<string, unknown>>,\n) => unknown;\n\n// Internal metadata stored on recipes but hidden from public types.\ninterface RecipeMeta {\n identity?: object;\n extends?: RecipeMeta[];\n rebuild?: (extensions: RecipeMeta[]) => RecipeMeta;\n baseClass: string;\n staticDefaults: Record<string, unknown>;\n // Performs a single compute pass for extending recipes, returning the\n // resolved variants while pushing classes and styles into the output values.\n compute: ComputeOnceFn;\n // Set only when this recipe's chain has computed defaults or `refine`.\n resolveRefine: ResolveRefineOnceFn | null;\n // Mirrors the variant changes of `compute` without rendering. A recipe with\n // no callbacks in its chain can still have it, because it can filter disabled\n // values that a later extend's callbacks would otherwise read. Missing when\n // the chain can't change variants, and in older Clava copies.\n resolveVariants?: ResolveRefineOnceFn;\n // Reference identity is used to detect mixed-factory `extend`. When a\n // recipe is extended by a parent from a different `create()` call, the\n // parent applies this transform to the extend's contribution before joining,\n // preserving each factory's transform boundary.\n transformClass: (className: string) => string;\n // Variant keys whose effective definition in this recipe's chain is a\n // function. An extending recipe that supplies a non-function variant for\n // the same key uses this to tell us to skip that key (matching the\n // type-level \"function variant is replaced by anything in the child\" rule).\n // Empty when no key in this chain is a function variant.\n functionVariantKeys: Set<string>;\n // Variant keys with computed defaults anywhere in this recipe's chain.\n // Child recipes use this to preserve inherited computed defaults through\n // `defaultValue` without preserving their own prior computed result.\n computedDefaultKeys: Set<string>;\n // Variant keys whose computed defaults run in this recipe's pruned chain.\n // Unlike `computedDefaultKeys`, a pruned shared ancestor doesn't add keys.\n // Older Clava copies don't expose it.\n activeComputedDefaultKeys?: Set<string>;\n // Variant keys that this recipe's chain disables entirely or partly. Older\n // Clava copies don't expose it or `isDisabledValue`.\n disabledKeys?: Set<string>;\n // Whether this recipe's chain removes the value for the key from the variants\n // it returns. A recipe that defines a value again stops its removal.\n isDisabledValue?: (key: string, value: unknown) => boolean;\n}\n\nconst META_KEY = \"__meta\";\n\ninterface RecipeWithMeta {\n [META_KEY]?: RecipeMeta;\n}\n\nconst EMPTY_DEFAULTS: Record<string, unknown> = {};\n\n// Prune shared recipes before compiling their parent's compute path. Keeping\n// the first path preserves its overrides and factory transform boundaries.\nfunction deduplicateExtensions(\n extensions: RecipeMeta[],\n seen = new Set<object>(),\n): RecipeMeta[] {\n if (extensions.length === 0) {\n return extensions;\n }\n const result: RecipeMeta[] = [];\n let changed = false;\n for (const meta of extensions) {\n const identity = getOwn(meta, \"identity\") ?? meta;\n if (seen.has(identity)) {\n changed = true;\n continue;\n }\n seen.add(identity);\n // Older Clava copies expose the compute metadata but not their graph.\n // Keep their contribution intact instead of traversing hidden ancestors.\n const inheritedExtensions = getOwn(meta, \"extends\");\n const rebuild = getOwn(meta, \"rebuild\");\n if (!inheritedExtensions || !rebuild) {\n result.push(meta);\n continue;\n }\n const children = deduplicateExtensions(inheritedExtensions, seen);\n if (children === inheritedExtensions) {\n result.push(meta);\n } else {\n result.push(rebuild(children));\n changed = true;\n }\n }\n return changed ? result : extensions;\n}\n\nconst MAX_REFINE_RUNS = 50;\n\nfunction areVariantsEqual(\n a: Record<string, unknown>,\n b: Record<string, unknown>,\n): boolean {\n // The first loop proves every own key of `a` is an own key of `b` with the\n // same value, so counting both sides is enough to prove the key sets match.\n // Counting keeps the total number of lookups the same as before the own-key\n // check was added to the first loop.\n let ownKeyDifference = 0;\n for (const key in a) {\n if (!hasOwn(a, key)) continue;\n if (!hasOwn(b, key)) return false;\n if (!Object.is(a[key], b[key])) return false;\n ownKeyDifference++;\n }\n for (const key in b) {\n if (!hasOwn(b, key)) continue;\n ownKeyDifference--;\n }\n return ownKeyDifference === 0;\n}\n\n// Variants that a `refine` callback assigned through `setVariants`. Two stages\n// read them: computed defaults skip a key that was assigned this way, and\n// `mergeProtectedIntoBase` folds them into the base each pass resolves from.\n// The record is created on the first `setVariants` call, because most callbacks\n// only read variants. The holder is shared so that a callback anywhere in the\n// chain can report its assignment back to the resolution that owns the pass.\ninterface RefineProtection {\n variants: Record<string, unknown> | null;\n}\n\nfunction mergeProtectedIntoBase(\n baseResolved: Record<string, unknown>,\n protection: RefineProtection | null,\n): Record<string, unknown> {\n const protectedVariants = protection?.variants;\n if (!protectedVariants) return baseResolved;\n return Object.assign({}, baseResolved, protectedVariants);\n}\n\n// A pass after the first one of a resolution loop. A computed default that\n// writes a key that a later computed default computes again, such as a base that\n// resets it to its static default, writes it to `chainValues` instead of the\n// working variants. Only the later computed defaults for that key read it, so\n// other callbacks keep the value that the previous pass settled on.\n// See https://github.com/ariakit/clava/issues/613\ninterface RefinePass {\n // One frame for each recipe on the current extend path.\n frames: PendingFrame[];\n // Values for keys that a later computed default still computes. The working\n // variants hold `undefined` the same way as a missing key, so it marks a\n // cleared key here too.\n chainValues: Map<string, unknown> | null;\n}\n\ninterface PendingFrame {\n // Keys that computed defaults compute after the current extend.\n keys: ReadonlySet<string> | null;\n // Whether the recipe removes a value after each extend. A computed default\n // below it writes such a value to the working variants, as before, so the\n // removal applies.\n isDisabled: ((key: string, value: unknown) => boolean) | null;\n}\n\nfunction isPendingKey(frames: PendingFrame[], key: string): boolean {\n for (let i = 0; i < frames.length; i++) {\n if (frames[i]?.keys?.has(key)) return true;\n }\n return false;\n}\n\nfunction isDisabledOnPath(\n frames: PendingFrame[],\n key: string,\n value: unknown,\n): boolean {\n for (let i = 0; i < frames.length; i++) {\n if (frames[i]?.isDisabled?.(key, value)) return true;\n }\n return false;\n}\n\n// Chains that mix in recipes from an older Clava copy aren't supported. Their\n// metadata lacks these keys, which then count as none instead of throwing.\nconst NO_KEYS: ReadonlySet<string> = new Set();\n\nfunction getActiveComputedDefaultKeys(meta: RecipeMeta): ReadonlySet<string> {\n return getOwn(meta, \"activeComputedDefaultKeys\") ?? NO_KEYS;\n}\n\n// Returns a copy of `variants` where `key` holds `value`, or is missing when\n// `value` is `undefined`.\nfunction withVariant(\n variants: Record<string, unknown>,\n key: string,\n value: unknown,\n): Record<string, unknown> {\n const copy = Object.assign({}, variants);\n if (value === undefined) {\n delete copy[key];\n } else {\n copy[key] = value;\n }\n return copy;\n}\n\nexport type {\n ClassValue,\n StyleValue,\n StyleClassProps,\n StyleClassValue,\n JSXProps,\n HTMLProps,\n HTMLObjProps,\n JSXCSSProperties,\n HTMLCSSProperties,\n ModalRecipe,\n Recipe,\n RecipeLike,\n RecipeProps,\n SplitPropsFunction,\n};\n\n/**\n * Extracts the variant props inferred for a Clava recipe. Use it to add a\n * recipe's variant props to framework component props.\n *\n * @example\n * ```ts\n * import { type VariantProps, cv } from \"clava\";\n * import type { ComponentProps } from \"react\";\n *\n * const button = cv({\n * variants: {\n * size: { sm: \"button-sm\", lg: \"button-lg\" },\n * disabled: { true: \"button-disabled\", false: \"\" },\n * },\n * });\n *\n * interface ButtonProps\n * extends ComponentProps<\"button\">,\n * VariantProps<typeof button> {}\n *\n * const props: ButtonProps = {\n * size: \"lg\",\n * disabled: true,\n * };\n * ```\n */\nexport type VariantProps<T extends Pick<AnyRecipe, \"getVariants\">> = ReturnType<\n T[\"getVariants\"]\n>;\n\n/**\n * Combines variant props with a recipe prop named `recipe` by default. The\n * prop is optional when the selected recipe is assignable to the base type,\n * and required when the selected recipe adds variants. Pass a third type\n * argument to use another prop name.\n *\n * When `R` is a union of recipes, the variant props include only the\n * variants that every member defines.\n *\n * When inferring `R`, passing `undefined` or forwarding an optional recipe\n * can fail the recipe constraint. Resolve the optional value before passing\n * it, for example with `recipe: override ?? disclosure`.\n *\n * @example\n * ```ts\n * import { type RecipeLike, type VariantPropsWithRecipe, cv } from \"clava\";\n *\n * const disclosure = cv({ variants: { $open: \"open\" } });\n *\n * type DisclosureProps<\n * R extends RecipeLike<typeof disclosure, R> = typeof disclosure,\n * > = VariantPropsWithRecipe<typeof disclosure, R>;\n *\n * type StyledDisclosureProps<\n * R extends RecipeLike<typeof disclosure, R> = typeof disclosure,\n * > = VariantPropsWithRecipe<typeof disclosure, R, \"styles\">;\n * ```\n */\nexport type VariantPropsWithRecipe<\n Base extends Recipe<any, any, any>,\n R extends RecipeLike<Base, R>,\n Name extends string = \"recipe\",\n> = VariantProps<R> &\n PartialVariantKeys<R> &\n ([R] extends [Base] ? { [Key in Name]?: R } : { [Key in Name]: R });\n\n// Blocks variants that only some union members define, because the selected\n// member may not process them. With no such keys, this is `unknown` so props\n// keep their exact shape instead of gaining an empty `{}` intersection member.\ntype PartialVariantKeys<\n R extends Pick<AnyRecipe, \"getVariants\">,\n Key extends PropertyKey = Exclude<\n UnionKeys<VariantProps<R>>,\n keyof VariantProps<R>\n >,\n> = [Key] extends [never] ? unknown : { [K in Key]?: never };\n\ntype UnionKeys<T> = T extends unknown ? keyof T : never;\n\n// Variant props expose booleans, but variant object keys are always strings.\ntype VariantKey<T> = T extends boolean ? \"true\" | \"false\" : Extract<T, string>;\n\n/**\n * Constrains a variant map to the same value keys as a variant on another\n * recipe. Boolean variants are represented with `\"true\"` and `\"false\"`\n * object keys.\n *\n * @example\n * ```ts\n * import { type Variant, cv } from \"clava\";\n *\n * const button = cv({\n * variants: {\n * size: { sm: \"button-sm\", lg: \"button-lg\" },\n * },\n * });\n *\n * const icon = cv({\n * extend: [button],\n * variants: {\n * size: {\n * sm: \"icon-sm\",\n * lg: \"icon-lg\",\n * } satisfies Variant<typeof button, \"size\">,\n * },\n * });\n * ```\n */\nexport type Variant<\n T extends Pick<AnyRecipe, \"getVariants\">,\n K extends keyof VariantProps<T>,\n> = Record<\n VariantKey<NonNullable<VariantProps<T>[K]>>,\n ClassValue | StyleClassValue\n>;\n\n/**\n * The configuration object accepted by `cv()`. It defines base class/style\n * output, variants, default variants, recipe extensions, and refinement\n * logic.\n *\n * @example\n * ```ts\n * import { type CVConfig, cv } from \"clava\";\n *\n * const config: CVConfig<{\n * tone: { info: string; danger: string };\n * }> = {\n * variants: {\n * tone: {\n * info: \"alert-info\",\n * danger: \"alert-danger\",\n * },\n * },\n * defaultVariants: {\n * tone: \"info\",\n * },\n * };\n *\n * const alert = cv(config);\n * ```\n */\nexport interface CVConfig<V extends Variants = {}, E extends AnyRecipe[] = []> {\n extend?: E;\n class?: ClassValue;\n style?: StyleValue;\n variants?: ExtendableVariants<V, E>;\n defaultVariants?: DefaultVariants<MergeVariants<V, E>>;\n refine?: Refine<MergeVariants<V, E>>;\n}\n\ninterface CreateParams {\n transformClass?: (className: string) => string;\n}\n\nfunction identityClass(className: string) {\n return className;\n}\n\nfunction isRecordObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== \"object\") return false;\n if (value == null) return false;\n if (Array.isArray(value)) return false;\n return true;\n}\n\n/**\n * Converts any style input (string, JSX object, or HTML object) to a normalized\n * StyleValue.\n */\nfunction normalizeStyle(style: unknown): StyleValue {\n if (typeof style === \"string\") {\n return htmlStyleToStyleValue(style);\n }\n if (typeof style === \"object\" && style != null) {\n return htmlObjStyleToStyleValue(style);\n }\n return {};\n}\n\n/**\n * Pre-extracts the class and (normalized) style from a variant value once at\n * recipe creation time. Returns `null` if the value contributes nothing.\n */\ninterface PrebuiltValue {\n class: ClassValue;\n style: StyleValue | null;\n}\n\nfunction extractClassAndStylePrebuilt(value: unknown): PrebuiltValue {\n if (!isRecordObject(value)) {\n return { class: value as ClassValue, style: null };\n }\n // A value that owns neither key contributes nothing, and a value that owns\n // one of them must not pick up the other from a polluted `Object.prototype`.\n // Checked inline rather than through `getOwn`: this runs for every variant\n // value at creation time, where the call is worth about 3% of `cv()`.\n const styleClassValue = value as StyleClassValue;\n const classValue = hasOwn(value, \"class\") ? styleClassValue.class : undefined;\n const styleValue = hasOwn(value, \"style\") ? styleClassValue.style : undefined;\n if (classValue === undefined && styleValue === undefined) {\n return { class: null, style: null };\n }\n const style = normalizeStyle(styleValue);\n return {\n class: classValue ?? null,\n style: Object.keys(style).length > 0 ? style : null,\n };\n}\n\nfunction getVariantValueKey(value: unknown): string | undefined {\n if (typeof value === \"string\") {\n return value;\n }\n if (typeof value === \"number\") {\n return String(value);\n }\n if (typeof value === \"boolean\") {\n return String(value);\n }\n return undefined;\n}\n\nconst EMPTY_KEYS: readonly string[] = [];\n\nfunction isRecipeKeySource(source: unknown): source is KeySourceRecipe {\n if (!source) return false;\n if (typeof source !== \"object\" && typeof source !== \"function\") {\n return false;\n }\n const typed = source as Record<string, unknown>;\n if (typeof typed.getVariants !== \"function\") return false;\n if (!Array.isArray(typed.propKeys)) return false;\n return Array.isArray(typed.variantKeys);\n}\n\n/**\n * Splits props into multiple groups based on key sources. Only the first\n * recipe claims styling props (class/className/style). Subsequent recipes\n * only receive variant props. Arrays always receive their listed keys but don't\n * claim styling props.\n */\nfunction splitPropsImpl(\n selfKeys: readonly string[],\n selfIsRecipe: boolean,\n props: Record<string, unknown>,\n sources: unknown[],\n): Record<string, unknown>[] {\n const sourcesLength = sources.length;\n const results: Record<string, unknown>[] = [];\n let stylingClaimed = selfIsRecipe;\n\n const selfResult: Record<string, unknown> = {};\n const selfKeysLength = selfKeys.length;\n for (let i = 0; i < selfKeysLength; i++) {\n const key = selfKeys[i];\n if (key !== undefined && hasOwn(props, key)) {\n selfResult[key] = props[key];\n }\n }\n results.push(selfResult);\n\n // Track effective key arrays for the rest computation — for typical inputs\n // a linear scan beats building a Set up-front.\n const effectiveKeyArrays: Array<readonly string[]> = [selfKeys];\n\n for (let s = 0; s < sourcesLength; s++) {\n const source = sources[s];\n const sourceResult: Record<string, unknown> = {};\n let sourceIsRecipe = false;\n let effectiveKeys: readonly string[];\n if (Array.isArray(source)) {\n effectiveKeys = source;\n } else if (isRecipeKeySource(source)) {\n sourceIsRecipe = true;\n effectiveKeys = stylingClaimed ? source.variantKeys : source.propKeys;\n } else {\n effectiveKeys = EMPTY_KEYS;\n }\n\n const effectiveKeysLength = effectiveKeys.length;\n for (let i = 0; i < effectiveKeysLength; i++) {\n const key = effectiveKeys[i];\n if (key !== undefined && hasOwn(props, key)) {\n sourceResult[key] = props[key];\n }\n }\n results.push(sourceResult);\n effectiveKeyArrays.push(effectiveKeys);\n\n if (sourceIsRecipe && !stylingClaimed) {\n stylingClaimed = true;\n }\n }\n\n const rest: Record<string, unknown> = {};\n const propKeys = Object.keys(props);\n const propKeysLength = propKeys.length;\n const groupCount = sourcesLength + 1;\n outer: for (let i = 0; i < propKeysLength; i++) {\n const key = propKeys[i];\n if (key === undefined) continue;\n for (let g = 0; g < groupCount; g++) {\n const arr = effectiveKeyArrays[g];\n if (arr === undefined) continue;\n const arrLength = arr.length;\n for (let j = 0; j < arrLength; j++) {\n if (arr[j] === key) continue outer;\n }\n }\n rest[key] = props[key];\n }\n results.push(rest);\n\n return results;\n}\n\n/**\n * Splits props into multiple groups based on key sources. Each source gets its\n * own result object containing all its matching keys. The first recipe\n * source claims styling props (class/className/style). Subsequent recipes\n * only receive variant props. Arrays receive their listed keys but don't claim\n * styling props. The last element is always the \"rest\" containing keys not\n * claimed by any source.\n */\nexport const splitProps: SplitPropsFunction = ((\n props: Record<string, unknown>,\n source1: unknown,\n ...sources: unknown[]\n) => {\n if (Array.isArray(source1)) {\n return splitPropsImpl(source1, false, props, sources);\n }\n if (isRecipeKeySource(source1)) {\n return splitPropsImpl(source1.propKeys, true, props, sources);\n }\n return splitPropsImpl(EMPTY_KEYS, false, props, sources);\n}) as SplitPropsFunction;\n\n/**\n * A pre-built variant. Maps variant value keys (or the literal \"true\"/\"false\"\n * strings for boolean variants) to PrebuiltValue. Includes a \"shorthand\"\n * fallback when the variant is a single class value (treated as `{ true: ... }`).\n */\ninterface PrebuiltVariant {\n // For object variants: map of value -> prebuilt class/style. A Map keeps the\n // lookup keyed by the caller's variant value out of reach of a polluted\n // `Object.prototype`.\n values: Map<string, PrebuiltValue> | null;\n // For shorthand variants: the value to use when selectedValue is true\n shorthand: PrebuiltValue | null;\n // Set of value keys that are disabled (value === null in the original variant\n // definition)\n disabledValues: Set<string> | null;\n}\n\nfunction buildPrebuiltVariant(variantDef: unknown): PrebuiltVariant {\n if (!isRecordObject(variantDef)) {\n return {\n values: null,\n shorthand: extractClassAndStylePrebuilt(variantDef),\n disabledValues: null,\n };\n }\n const values = new Map<string, PrebuiltValue>();\n let disabledValues: Set<string> | null = null;\n for (const key in variantDef) {\n if (!hasOwn(variantDef, key)) continue;\n const value = variantDef[key];\n if (value === null) {\n if (!disabledValues) {\n disabledValues = new Set<string>();\n }\n disabledValues.add(key);\n continue;\n }\n values.set(key, extractClassAndStylePrebuilt(value));\n }\n return {\n values,\n shorthand: null,\n disabledValues,\n };\n}\n\n/**\n * Creates the cv and cx functions.\n */\nexport function create(params: CreateParams = {}) {\n // Destructuring would read an inherited `transformClass`, which a polluted\n // `Object.prototype` could use to rewrite every class string this factory\n // produces, including those of the package-level `cv`.\n const transformClass = getOwn(params, \"transformClass\") ?? identityClass;\n\n // The root `cx` type lets consumers emit `typeof cx` for an exported result.\n // Otherwise, emit must name clsx's `ClassValue`, which pnpm installs hide.\n const transformedCx: typeof cx = (...classes) => {\n return transformClass(clsx(classes));\n };\n\n const buildRecipe = <\n V extends Variants = {},\n const E extends AnyRecipe[] = [],\n >(\n config: CVConfig<V, E> = {},\n ): { recipe: Recipe<V, E>; meta: RecipeMeta } => {\n type MergedVariants = MergeVariants<V, E>;\n\n // Compile caller-owned configuration once. Rebuilding a pruned branch\n // reuses these values, including references that rendering already retains.\n const extend = getOwn(config, \"extend\");\n const variants = getOwn(config, \"variants\");\n const refine = getOwn(config, \"refine\");\n const baseStyle = getOwn(config, \"style\");\n const hasBaseStyle = !!baseStyle;\n const baseClassValue = getOwn(config, \"class\");\n const variantKeySet = new Set<string>();\n const inheritedComputedDefaultKeys = new Set<string>();\n const originalExtMetas: RecipeMeta[] = [];\n if (extend) {\n for (const ext of extend) {\n const extKeys = ext.variantKeys as readonly string[];\n for (let i = 0; i < extKeys.length; i++) {\n const key = extKeys[i];\n if (key === undefined) continue;\n variantKeySet.add(key);\n }\n const meta = (ext as AnyRecipe & RecipeWithMeta)[META_KEY];\n if (!meta) continue;\n originalExtMetas.push(meta);\n // A later branch can read a computed default contributed by the first\n // path, even when that shared ancestor is pruned from this branch.\n for (const key of meta.computedDefaultKeys) {\n inheritedComputedDefaultKeys.add(key);\n }\n }\n }\n const initialExtensions =\n originalExtMetas.length > 1\n ? deduplicateExtensions(originalExtMetas)\n : originalExtMetas;\n\n // Keep own default operations separate from inherited values. An explicit\n // undefined must still clear a default when the retained extensions change.\n const ownStaticDefaults: Record<string, unknown> = {};\n const disabledVariantKeys = new Set<string>();\n let disabledValuesBuilder: Record<string, Set<string>> | null = null;\n const variantEntryNames: string[] = [];\n const variantEntryDefs: PrebuiltVariant[] = [];\n const functionVariantNames: string[] = [];\n const functionVariantFns: Array<(value: unknown) => unknown> = [];\n // Own variant definitions by name. `null` stands for a function variant.\n const ownVariantDefs = new Map<string, PrebuiltVariant | null>();\n if (variants) {\n for (const name in variants) {\n if (!hasOwn(variants, name)) continue;\n const variant = (variants as Record<string, unknown>)[name];\n if (variant === null) {\n variantKeySet.delete(name);\n disabledVariantKeys.add(name);\n continue;\n }\n variantKeySet.add(name);\n if (typeof variant === \"function\") {\n functionVariantNames.push(name);\n functionVariantFns.push(variant as (value: unknown) => unknown);\n ownVariantDefs.set(name, null);\n continue;\n }\n const prebuiltVariant = buildPrebuiltVariant(variant);\n ownVariantDefs.set(name, prebuiltVariant);\n variantEntryNames.push(name);\n variantEntryDefs.push(prebuiltVariant);\n if (prebuiltVariant.disabledValues) {\n disabledValuesBuilder ??= {};\n disabledValuesBuilder[name] = prebuiltVariant.disabledValues;\n }\n // Capture this decision before pruning can remove an inherited default.\n if (\n prebuiltVariant.values?.has(\"false\") &&\n !initialExtensions.some((meta) => hasOwn(meta.staticDefaults, name))\n ) {\n ownStaticDefaults[name] = false;\n }\n }\n }\n const definesOwnValue = (key: string, value: unknown): boolean => {\n const variant = ownVariantDefs.get(key);\n if (variant === undefined) return false;\n if (variant === null) return true;\n if (!variant.values) return typeof value === \"boolean\";\n // `false` is a valid value for a variant that only defines `true`.\n if (value === false && variant.values.has(\"true\")) return true;\n const valueKey = getVariantValueKey(value);\n return valueKey != null && variant.values.has(valueKey);\n };\n\n const variantKeys = Array.from(variantKeySet);\n const variantKeysLength = variantKeys.length;\n const variantEntryCount = variantEntryNames.length;\n const functionVariantCount = functionVariantNames.length;\n const hasDisabledVariantKeys = disabledVariantKeys.size > 0;\n const disabledVariantValues = disabledValuesBuilder;\n const hasAnyDisabled =\n hasDisabledVariantKeys || disabledVariantValues !== null;\n const inputPropsKeys = [\"class\", \"className\", \"style\", ...variantKeys];\n\n const computedDefaultNames: string[] = [];\n const computedDefaultFns: ComputedDefaultVariantFn[] = [];\n const defaultVariants = getOwn(config, \"defaultVariants\") as\n | Record<string, unknown>\n | undefined;\n if (defaultVariants) {\n for (const name in defaultVariants) {\n if (!hasOwn(defaultVariants, name)) continue;\n const value = defaultVariants[name];\n if (typeof value === \"function\") {\n computedDefaultNames.push(name);\n computedDefaultFns.push(value as ComputedDefaultVariantFn);\n } else {\n ownStaticDefaults[name] = value;\n }\n }\n }\n const computedDefaultCount = computedDefaultNames.length;\n const baseClass = clsx(baseClassValue as ClsxClassValue);\n const identity = {};\n const canTriggerRefineWarning =\n !!refine ||\n computedDefaultCount > 0 ||\n initialExtensions.some((meta) => meta.resolveRefine);\n const creationFrame =\n canTriggerRefineWarning && process.env.NODE_ENV !== \"production\"\n ? captureCreationFrame(cv)\n : undefined;\n\n // Only extension-dependent state is rebuilt. Own tables, callbacks,\n // inheritance visibility, and the creation frame stay shared and unchanged.\n const build = (\n extMetas: RecipeMeta[],\n ): {\n recipe: Recipe<V, E>;\n meta: RecipeMeta;\n } => {\n const hasExtend = extMetas.length > 0;\n const extCount = extMetas.length;\n const staticDefaults: Record<string, unknown> = {};\n const extBaseClassesArr: string[] = [];\n const extIsolated: boolean[] = [];\n let hasIsolatedExt = false;\n for (const meta of extMetas) {\n Object.assign(staticDefaults, meta.staticDefaults);\n const isolated = meta.transformClass !== transformClass;\n extIsolated.push(isolated);\n if (isolated) {\n hasIsolatedExt = true;\n extBaseClassesArr.push(meta.transformClass(meta.baseClass));\n } else {\n extBaseClassesArr.push(meta.baseClass);\n }\n }\n for (const name in ownStaticDefaults) {\n if (!hasOwn(ownStaticDefaults, name)) continue;\n const value = ownStaticDefaults[name];\n if (value === undefined) {\n delete staticDefaults[name];\n } else {\n staticDefaults[name] = value;\n }\n }\n if (hasAnyDisabled) {\n for (const key in staticDefaults) {\n if (!hasOwn(staticDefaults, key)) continue;\n if (disabledVariantKeys.has(key)) {\n delete staticDefaults[key];\n continue;\n }\n if (disabledVariantValues) {\n const valueKey = getVariantValueKey(staticDefaults[key]);\n if (\n valueKey != null &&\n getOwn(disabledVariantValues, key)?.has(valueKey)\n ) {\n delete staticDefaults[key];\n }\n }\n }\n }\n\n // Count only extends with computed default or refine work in their chain.\n // Those are the recipes that can change resolved variants across\n // fixed-point iterations.\n let extMetasWithRefineCount = 0;\n for (let i = 0; i < extCount; i++) {\n if (extMetas[i].resolveRefine) {\n extMetasWithRefineCount += 1;\n }\n }\n\n // The extends that can change variants for `getVariants`. Built once so\n // that each pass skips the others without reading their metadata.\n const extResolvers = extMetas.map(\n (meta) => getOwn(meta, \"resolveVariants\") ?? meta.resolveRefine,\n );\n const canResolveVariants =\n (hasExtend && hasAnyDisabled) ||\n !!refine ||\n computedDefaultCount > 0 ||\n extResolvers.some(Boolean);\n\n // Only a `refine` callback protects variants, through `setVariants`. This\n // over-approximates: `extMetasWithRefineCount` also counts extends that\n // only have computed defaults. Tightening it would mean tracking `refine`\n // separately in `RecipeMeta` to save one allocation. The record inside\n // the holder is created only when a callback assigns something.\n const canProtectVariants = !!refine || extMetasWithRefineCount > 0;\n\n // `userVariantProps` tells computed defaults which variants the user set\n // explicitly, and `runComputedDefaults` is its only reader anywhere in the\n // chain: a `refine` callback never receives it. `computedDefaultKeys` is\n // transitive, so an empty inherited set proves no extend runs computed\n // defaults either, and nothing reads the record. The record is then the\n // caller's own props object, which no stage may write to.\n const needsUserVariantProps =\n computedDefaultCount > 0 || inheritedComputedDefaultKeys.size > 0;\n\n // Function variant keys inherited from extends, filtered through this\n // recipe's own variants: a static (object/shorthand) variant in this\n // recipe replaces an inherited function variant for the same key.\n // The closure is exposed on `RecipeMeta` so any further extending\n // recipe can detect \"ancestor's effective variant for K is a function\"\n // and skip it when overriding K with a non-function.\n const functionVariantKeys = new Set<string>();\n for (let i = 0; i < extCount; i++) {\n const fnKeys = extMetas[i].functionVariantKeys;\n for (const k of fnKeys) {\n if (disabledVariantKeys.has(k)) continue;\n functionVariantKeys.add(k);\n }\n }\n for (let i = 0; i < functionVariantCount; i++) {\n functionVariantKeys.add(functionVariantNames[i]);\n }\n for (let i = 0; i < variantEntryCount; i++) {\n // A static variant in this recipe replaces an inherited function\n // variant for the same key; from this recipe onward, the key is no\n // longer a function variant.\n functionVariantKeys.delete(variantEntryNames[i]);\n }\n\n const computedDefaultKeys = new Set(inheritedComputedDefaultKeys);\n for (let i = 0; i < computedDefaultCount; i++) {\n computedDefaultKeys.add(computedDefaultNames[i]);\n }\n\n // Pre-compute static skip key/value sets to pass to extends. These never\n // change across calls — when caller passes no skip sets, we reuse the same\n // object and avoid Set allocation.\n let staticExtSkipKeys: Set<string> | null = null;\n if (hasDisabledVariantKeys || functionVariantCount > 0) {\n staticExtSkipKeys = new Set<string>();\n for (const k of disabledVariantKeys) {\n staticExtSkipKeys.add(k);\n }\n for (let i = 0; i < functionVariantCount; i++) {\n staticExtSkipKeys.add(functionVariantNames[i]);\n }\n }\n\n // A static variant in this recipe replaces an inherited function\n // variant, so the ancestor must skip that key.\n if (variantEntryCount > 0 && extCount > 0) {\n for (let i = 0; i < variantEntryCount; i++) {\n const name = variantEntryNames[i];\n for (let j = 0; j < extCount; j++) {\n if (extMetas[j].functionVariantKeys.has(name)) {\n staticExtSkipKeys ??= new Set<string>();\n staticExtSkipKeys.add(name);\n break;\n }\n }\n }\n }\n // Skip values are passed directly to extends. We can reuse the same object\n // when no caller-provided values need merging.\n const staticExtSkipValues = disabledVariantValues;\n\n // Callers use this only when disabled keys or values exist.\n function filterDisabledInto(\n input: Record<string, unknown>,\n out: Record<string, unknown>,\n ): void {\n for (const key in input) {\n if (!hasOwn(input, key)) continue;\n if (disabledVariantKeys.has(key)) continue;\n const value = input[key];\n if (disabledVariantValues) {\n const valueKey = getVariantValueKey(value);\n if (\n valueKey != null &&\n getOwn(disabledVariantValues, key)?.has(valueKey)\n ) {\n continue;\n }\n }\n out[key] = value;\n }\n }\n\n const isOwnDisabledValue = (key: string, value: unknown): boolean => {\n if (disabledVariantKeys.has(key)) {\n return true;\n }\n if (disabledVariantValues) {\n const valueKey = getVariantValueKey(value);\n if (\n valueKey != null &&\n getOwn(disabledVariantValues, key)?.has(valueKey)\n ) {\n return true;\n }\n }\n return false;\n };\n\n const isDisabledValue = (key: string, value: unknown): boolean => {\n if (isOwnDisabledValue(key, value)) return true;\n if (definesOwnValue(key, value)) return false;\n return extMetas.some((meta) =>\n getOwn(meta, \"isDisabledValue\")?.(key, value),\n );\n };\n\n const disabledKeys = new Set(disabledVariantKeys);\n for (const key in disabledVariantValues) {\n if (!hasOwn(disabledVariantValues, key)) continue;\n disabledKeys.add(key);\n }\n // Own keys that an extend may disable, so an extend that doesn't disable\n // anything this recipe defines adds no work to each compute pass.\n const restorableKeys: string[] = [];\n for (const meta of extMetas) {\n const extDisabledKeys = getOwn(meta, \"disabledKeys\");\n if (!extDisabledKeys) continue;\n for (const key of extDisabledKeys) {\n disabledKeys.add(key);\n if (ownVariantDefs.has(key) && !restorableKeys.includes(key)) {\n restorableKeys.push(key);\n }\n }\n }\n\n // An extend removes the values that its chain disables, but this recipe\n // defines some of them again. Its value comes back after the extend runs,\n // so the extend's own callbacks still read the variants that it declares.\n const restoreOwnValues = (\n before: Record<string, unknown>,\n after: Record<string, unknown>,\n extMeta: RecipeMeta,\n fallback: Record<string, unknown>,\n protection: RefineProtection | null | undefined,\n ): Record<string, unknown> => {\n let restored = after;\n for (const key of restorableKeys) {\n const value = getOwn(before, key);\n if (value === undefined) continue;\n if (!definesOwnValue(key, value)) continue;\n if (!getOwn(extMeta, \"isDisabledValue\")?.(key, value)) continue;\n const current = getOwn(after, key);\n // A disabling recipe without extends removes nothing.\n if (Object.is(current, value)) continue;\n // A different protected value comes from a callback, even a clear.\n const protectedVariants = protection?.variants;\n if (\n protectedVariants &&\n hasOwn(protectedVariants, key) &&\n !Object.is(protectedVariants[key], value)\n ) {\n continue;\n }\n // The extend replaces a disabled value with the fallback. Any other\n // value comes from its callbacks.\n if (\n current !== undefined &&\n !Object.is(current, getOwn(fallback, key))\n ) {\n continue;\n }\n if (restored === after) {\n restored = Object.assign({}, after);\n }\n restored[key] = value;\n }\n return restored;\n };\n\n // The frame for each extend lists the keys that computed defaults\n // compute after it runs: those of later extends and this recipe's own.\n const extPendingFrames: Array<PendingFrame | null> = [];\n const laterComputedDefaultKeys = new Set(computedDefaultNames);\n for (let i = extCount - 1; i >= 0; i--) {\n const keys =\n laterComputedDefaultKeys.size > 0\n ? new Set(laterComputedDefaultKeys)\n : null;\n extPendingFrames.unshift(\n keys || hasAnyDisabled\n ? { keys, isDisabled: hasAnyDisabled ? isOwnDisabledValue : null }\n : null,\n );\n for (const key of getActiveComputedDefaultKeys(extMetas[i])) {\n laterComputedDefaultKeys.add(key);\n }\n }\n const activeComputedDefaultKeys = laterComputedDefaultKeys;\n\n const filterOwnDisabledVariants = (\n input: Record<string, unknown>,\n fallback: Record<string, unknown>,\n ): Record<string, unknown> => {\n if (!hasAnyDisabled) {\n return input;\n }\n\n let hasOwnDisabledValue = false;\n for (const key in input) {\n if (!hasOwn(input, key)) continue;\n const value = input[key];\n if (isOwnDisabledValue(key, value)) {\n hasOwnDisabledValue = true;\n break;\n }\n }\n if (!hasOwnDisabledValue) {\n return input;\n }\n\n const filtered: Record<string, unknown> = {};\n for (const key in input) {\n if (!hasOwn(input, key)) continue;\n const value = input[key];\n if (!isOwnDisabledValue(key, value)) {\n filtered[key] = value;\n continue;\n }\n const fallbackValue = getOwn(fallback, key);\n if (\n fallbackValue !== undefined &&\n !isOwnDisabledValue(key, fallbackValue)\n ) {\n filtered[key] = fallbackValue;\n }\n }\n\n return filtered;\n };\n\n // Applies `filterOwnDisabledVariants` to the values that computed defaults\n // keep out of the working variants, so later ones read the same value.\n const filterOwnDisabledChainValues = (\n chainValues: Map<string, unknown>,\n fallback: Record<string, unknown>,\n ): void => {\n if (!hasAnyDisabled) return;\n for (const [key, value] of chainValues) {\n if (!isOwnDisabledValue(key, value)) continue;\n const fallbackValue = getOwn(fallback, key);\n chainValues.set(\n key,\n fallbackValue !== undefined &&\n !isOwnDisabledValue(key, fallbackValue)\n ? fallbackValue\n : undefined,\n );\n }\n };\n\n // Hot path: resolve variants by merging static defaults + extends'\n // static defaults + user-provided props.\n function resolveVariantsHot(\n propsVariants: Record<string, unknown>,\n ): Record<string, unknown> {\n // Start with static defaults\n const defaults = Object.assign({}, staticDefaults);\n\n // Apply propsVariants on top (filter undefined).\n for (let i = 0; i < variantKeysLength; i++) {\n const k = variantKeys[i];\n if (!hasOwn(propsVariants, k)) continue;\n const v = propsVariants[k];\n if (v === undefined) continue;\n defaults[k] = v;\n }\n\n if (!hasAnyDisabled) {\n return defaults;\n }\n\n // Filter disabled\n const result: Record<string, unknown> = {};\n filterDisabledInto(defaults, result);\n return result;\n }\n\n const runComputedDefaults = (\n resolved: Record<string, unknown>,\n defaultResolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n filterOwnVariants: boolean,\n protection: RefineProtection | null | undefined,\n pass: RefinePass | null | undefined,\n ): Record<string, unknown> => {\n const protectedVariants = protection?.variants;\n let ownVariants = filterOwnVariants ? null : resolved;\n const getOwnVariants = (): Record<string, unknown> => {\n if (ownVariants) {\n return ownVariants;\n }\n const filteredVariants: Record<string, unknown> = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (hasOwn(resolved, key)) {\n filteredVariants[key] = resolved[key];\n }\n }\n ownVariants = filteredVariants;\n return filteredVariants;\n };\n\n let updatedVariants: Record<string, unknown> | null = null;\n const ensureUpdated = (): Record<string, unknown> => {\n if (updatedVariants) {\n return updatedVariants;\n }\n const updated = Object.assign({}, resolved);\n updatedVariants = updated;\n return updated;\n };\n\n for (let i = 0; i < computedDefaultCount; i++) {\n const key = computedDefaultNames[i];\n if (hasOwn(userVariantProps, key)) {\n if (userVariantProps[key] !== undefined) continue;\n }\n if (protectedVariants && hasOwn(protectedVariants, key)) continue;\n\n const variantSnapshot = getOwnVariants();\n const currentValue = getOwn(variantSnapshot, key);\n // An earlier computed default may have kept its value for this key\n // out of the working variants. This one still reads that value as the\n // one it replaces, through `defaultValue` and through its own key.\n const chainValues = pass?.chainValues;\n const latestValue =\n chainValues && chainValues.has(key)\n ? chainValues.get(key)\n : currentValue;\n const defaultValue = inheritedComputedDefaultKeys.has(key)\n ? latestValue\n : getOwn(defaultResolved, key);\n let value = computedDefaultFns[i](\n defaultValue,\n Object.is(latestValue, currentValue)\n ? variantSnapshot\n : withVariant(variantSnapshot, key, latestValue),\n );\n if (hasAnyDisabled && isOwnDisabledValue(key, value)) {\n // The latest value stays, as if this computed default didn't run.\n // When no later one computes the key, it becomes the final value.\n if (Object.is(latestValue, currentValue)) continue;\n if (pass && isPendingKey(pass.frames, key)) continue;\n value = latestValue;\n } else if (pass) {\n if (Object.is(value, currentValue)) {\n chainValues?.delete(key);\n continue;\n }\n if (\n isPendingKey(pass.frames, key) &&\n !isDisabledOnPath(pass.frames, key, value)\n ) {\n pass.chainValues ??= new Map();\n pass.chainValues.set(key, value);\n continue;\n }\n }\n // The working variants receive this value, so a value that an\n // earlier computed default kept out of them no longer applies.\n chainValues?.delete(key);\n\n if (value === undefined) {\n if (!hasOwn(variantSnapshot, key)) continue;\n delete ensureUpdated()[key];\n continue;\n }\n if (Object.is(currentValue, value)) continue;\n ensureUpdated()[key] = value;\n }\n\n return updatedVariants ?? resolved;\n };\n\n const runRefineContext = (\n resolved: Record<string, unknown>,\n filterOwnVariants: boolean,\n collectOutput: boolean,\n applyVariantUpdates: boolean,\n protection: RefineProtection | null | undefined,\n ): {\n workingResolved: Record<string, unknown>;\n classes: ClassValue[] | null;\n style: StyleValue | null;\n } => {\n let workingResolved = resolved;\n let cClasses: ClassValue[] | null = null;\n let cStyle: StyleValue | null = null;\n\n if (refine) {\n let ownVariants = resolved;\n if (filterOwnVariants) {\n // When this recipe is being extended, `resolved` is the parent's\n // workingResolved (a superset of our variant keys). Filter to our own\n // keys for `ctx.variants` so the user's `refine` callback sees the\n // shape declared by `VariantValues<V>` and not foreign parent keys.\n const filteredVariants: Record<string, unknown> = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const k = variantKeys[i];\n if (hasOwn(resolved, k)) {\n filteredVariants[k] = resolved[k];\n }\n }\n ownVariants = filteredVariants;\n }\n // `assignedVariants`, `localCClasses` and `localCStyle` are created on\n // first use, so a callback that only inspects `variants` allocates\n // none of them. The `setVariants` bookkeeping is inlined for the same\n // reason: helper closures would be allocated on every call, including\n // the calls that never assign anything.\n // `assignedVariants` holds only the changed keys, because copying all\n // of `ownVariants` into it would repeat values `workingResolved` has.\n let assignedVariants: Record<string, unknown> | null = null;\n let localCClasses: ClassValue[] | null = null;\n let localCStyle: StyleValue | null = null;\n const ctx = {\n variants: ownVariants as VariantValues<Record<string, unknown>>,\n setVariants: (\n newVariants: VariantValues<Record<string, unknown>>,\n ) => {\n if (!applyVariantUpdates) {\n return;\n }\n for (const key in newVariants) {\n if (!hasOwn(newVariants, key)) continue;\n // `disabledVariantKeys` is empty unless this recipe disables a\n // variant, so the lookup replaces a `hasAnyDisabled` branch. The\n // key is checked before the value is read, because reading it can\n // run a caller-defined accessor.\n if (disabledVariantKeys.has(key)) continue;\n const value = (newVariants as Record<string, unknown>)[key];\n if (disabledVariantValues) {\n const valueKey = getVariantValueKey(value);\n if (\n valueKey != null &&\n getOwn(disabledVariantValues, key)?.has(valueKey)\n ) {\n continue;\n }\n }\n if (protection) {\n const protectedVariants = (protection.variants ??= {});\n protectedVariants[key] = value;\n }\n // The record holds only assigned keys, so both halves matter: a\n // key it owns can hold a clear that `??` on the value would\n // discard, and a key it does not own must fall back to\n // `ownVariants`, or a clear compares against `undefined`.\n const current =\n assignedVariants && hasOwn(assignedVariants, key)\n ? assignedVariants[key]\n : getOwn(ownVariants, key);\n if (Object.is(current, value)) {\n continue;\n }\n assignedVariants ??= {};\n assignedVariants[key] = value;\n }\n },\n addClass: (className: ClassValue) => {\n if (!collectOutput) return;\n localCClasses ??= [];\n localCClasses.push(className);\n },\n addStyle: (newStyle: StyleValue) => {\n if (!collectOutput) return;\n localCStyle ??= {};\n Object.assign(localCStyle, newStyle);\n },\n };\n const result = refine(ctx);\n if (collectOutput && result != null) {\n const r = extractClassAndStylePrebuilt(result);\n if (r.class != null) {\n localCClasses ??= [];\n localCClasses.push(r.class);\n }\n if (r.style) {\n localCStyle ??= {};\n Object.assign(localCStyle, r.style);\n }\n }\n cClasses = localCClasses;\n cStyle = localCStyle;\n if (assignedVariants) {\n // No disabled filtering here: `setVariants` drops a disabled key or\n // value before it records one, so every assigned key already passed\n // the same two checks.\n workingResolved = Object.assign(\n {},\n workingResolved,\n assignedVariants,\n );\n }\n }\n\n return {\n workingResolved,\n classes: cClasses,\n style: cStyle,\n };\n };\n\n // Core compute path. Called both for top-level rendering (via\n // `computeResult`) and recursively when this recipe is used as an\n // `extend` target by another recipe. Pushes variant classes (excluding\n // base class) into `classesOut` and merges styles into `styleOut`.\n const computeOnce: ComputeOnceFn = (\n resolved,\n userVariantProps,\n skipKeys,\n skipValues,\n classesOut,\n styleOut,\n protection,\n defaultResolved = resolved,\n renderOnly = false,\n pass,\n ) => {\n let workingResolved = resolved;\n let cClasses: ClassValue[] | null = null;\n let cStyle: StyleValue | null = null;\n\n // Run extends' contributions first (their full classes + styles) so our\n // own base style and variants apply on top, matching the original\n // ext1 → ext2 → … → current ordering.\n if (hasExtend) {\n // Build skip sets to pass to extends. Reuse precomputed values when no\n // caller-provided sets need merging.\n let extSkipKeys: Set<string> | null;\n if (skipKeys === null) {\n extSkipKeys = staticExtSkipKeys;\n } else if (staticExtSkipKeys === null) {\n extSkipKeys = skipKeys;\n } else {\n extSkipKeys = new Set(skipKeys);\n for (const k of staticExtSkipKeys) {\n extSkipKeys.add(k);\n }\n }\n\n let extSkipVals: Record<string, Set<string>> | null;\n if (skipValues === null) {\n extSkipVals = staticExtSkipValues;\n } else if (staticExtSkipValues === null) {\n extSkipVals = skipValues;\n } else {\n extSkipVals = {};\n for (const k in skipValues) {\n if (!hasOwn(skipValues, k)) continue;\n extSkipVals[k] = skipValues[k];\n }\n for (const k in staticExtSkipValues) {\n if (!hasOwn(staticExtSkipValues, k)) continue;\n const values = staticExtSkipValues[k];\n const existing = getOwn(extSkipVals, k);\n if (existing) {\n const merged = new Set<string>(existing);\n for (const v of values) {\n merged.add(v);\n }\n extSkipVals[k] = merged;\n } else {\n extSkipVals[k] = values;\n }\n }\n }\n\n for (let i = 0; i < extCount; i++) {\n const pendingFrame = pass ? extPendingFrames[i] : null;\n if (pass && pendingFrame) {\n pass.frames.push(pendingFrame);\n }\n const beforeExtend = workingResolved;\n if (hasIsolatedExt && extIsolated[i]) {\n // Isolated extend (different factory): gather its variant classes\n // into a scratch array, then push the joined string after applying\n // its own transformClass. Our outer transform applies on top.\n const extClasses: ClsxClassValue[] = [];\n workingResolved = extMetas[i].compute(\n workingResolved,\n userVariantProps,\n extSkipKeys,\n extSkipVals,\n extClasses,\n styleOut,\n protection,\n defaultResolved,\n renderOnly,\n pass,\n );\n if (extClasses.length > 0) {\n const joined = clsx(extClasses);\n if (joined.length > 0) {\n classesOut.push(extMetas[i].transformClass(joined));\n }\n }\n } else {\n workingResolved = extMetas[i].compute(\n workingResolved,\n userVariantProps,\n extSkipKeys,\n extSkipVals,\n classesOut,\n styleOut,\n protection,\n defaultResolved,\n renderOnly,\n pass,\n );\n }\n if (pass && pendingFrame) {\n pass.frames.pop();\n }\n if (restorableKeys.length > 0) {\n workingResolved = restoreOwnValues(\n beforeExtend,\n workingResolved,\n extMetas[i],\n defaultResolved,\n protection,\n );\n }\n workingResolved = filterOwnDisabledVariants(\n workingResolved,\n defaultResolved,\n );\n if (pass?.chainValues) {\n filterOwnDisabledChainValues(pass.chainValues, defaultResolved);\n }\n }\n }\n\n // Run own computed defaults after extended recipes so defaults resolve\n // from base to child. They still run before this recipe's `refine`.\n if (!renderOnly && computedDefaultCount > 0) {\n workingResolved = runComputedDefaults(\n workingResolved,\n defaultResolved,\n userVariantProps,\n true,\n protection,\n pass,\n );\n }\n\n // Run own `refine` (if any). May modify resolved variants and emit\n // classes and styles that are applied after this recipe's variants.\n if (refine) {\n const refineResult = runRefineContext(\n workingResolved,\n true,\n true,\n !renderOnly,\n protection,\n );\n workingResolved = refineResult.workingResolved;\n cClasses = refineResult.classes;\n cStyle = refineResult.style;\n }\n\n // Apply own base style (after extends' styles, matching original order).\n if (hasBaseStyle) {\n Object.assign(styleOut, baseStyle);\n }\n\n // Apply own variants. Skip keys/values come from caller (e.g., parent\n // wants its own function variant to override this variant).\n // `variantEntryNames` already excludes disabled keys (those with `null`\n // value in config) and function variants, so we don't re-check\n // `disabledVariantKeys` here.\n const ownSkipKeys = skipKeys;\n const ownSkipValues = skipValues;\n for (let i = 0; i < variantEntryCount; i++) {\n const variantName = variantEntryNames[i];\n if (ownSkipKeys && ownSkipKeys.has(variantName)) continue;\n // Read first: an inherited value that could change the output is\n // never `undefined`, so the own-property check only runs for the\n // variants that carry a value.\n const selectedValue = workingResolved[variantName];\n if (selectedValue === undefined) continue;\n if (!hasOwn(workingResolved, variantName)) continue;\n const selectedKey = getVariantValueKey(selectedValue);\n const variant = variantEntryDefs[i];\n if (\n variant.disabledValues &&\n selectedKey != null &&\n variant.disabledValues.has(selectedKey)\n ) {\n continue;\n }\n if (\n ownSkipValues &&\n selectedKey != null &&\n getOwn(ownSkipValues, variantName)?.has(selectedKey)\n ) {\n continue;\n }\n\n let value: PrebuiltValue | null | undefined;\n if (variant.values) {\n if (selectedKey == null) continue;\n value = variant.values.get(selectedKey);\n } else if (selectedValue === true) {\n value = variant.shorthand;\n }\n if (!value) continue;\n if (value.class != null) {\n classesOut.push(value.class);\n }\n if (value.style) {\n Object.assign(styleOut, value.style);\n }\n }\n\n // Apply function variants — entries in `variants` whose value is a\n // function. They run after static variants and override any same-key\n // inherited variant via `staticExtSkipKeys`.\n for (let i = 0; i < functionVariantCount; i++) {\n const variantName = functionVariantNames[i];\n if (ownSkipKeys && ownSkipKeys.has(variantName)) continue;\n const selectedValue = workingResolved[variantName];\n if (selectedValue === undefined) continue;\n if (!hasOwn(workingResolved, variantName)) continue;\n const selectedKey = getVariantValueKey(selectedValue);\n if (\n ownSkipValues &&\n selectedKey != null &&\n getOwn(ownSkipValues, variantName)?.has(selectedKey)\n ) {\n continue;\n }\n const fn = functionVariantFns[i];\n const computedResult = fn(selectedValue);\n if (computedResult == null) continue;\n const r = extractClassAndStylePrebuilt(computedResult);\n if (r.class != null) {\n classesOut.push(r.class);\n }\n if (r.style) {\n Object.assign(styleOut, r.style);\n }\n }\n\n // Apply `refine` results — must come after own variants (static and\n // function).\n if (cClasses) {\n for (let i = 0; i < cClasses.length; i++) {\n classesOut.push(cClasses[i] as ClsxClassValue);\n }\n }\n if (cStyle) {\n Object.assign(styleOut, cStyle);\n }\n\n return workingResolved;\n };\n\n const compute: ComputeFn =\n !refine && computedDefaultCount === 0 && extMetasWithRefineCount === 0\n ? computeOnce\n : (\n resolved,\n userVariantProps,\n skipKeys,\n skipValues,\n classesOut,\n styleOut,\n ) => {\n let remaining = MAX_REFINE_RUNS;\n const protection: RefineProtection | null = canProtectVariants\n ? { variants: null }\n : null;\n const incomingDefaultResolved = resolved;\n let workingResolved = resolved;\n // Latest variant changes from non-converging iterations inside the\n // tracking window. Lazy-init keeps convergent loops allocation-free.\n let unstableChanges: Map<string, VariantChange> | null = null;\n let lastClasses: ClsxClassValue[] = [];\n let lastStyle: StyleValue = {};\n let isFirstRun = true;\n let pass: RefinePass | null = null;\n\n while (remaining > 0) {\n remaining -= 1;\n const useDirectOutput = isFirstRun;\n const classCount = classesOut.length;\n const nextClasses: ClsxClassValue[] = useDirectOutput\n ? classesOut\n : [];\n const nextStyle: StyleValue = useDirectOutput ? styleOut : {};\n const defaultResolved = mergeProtectedIntoBase(\n incomingDefaultResolved,\n protection,\n );\n if (!isFirstRun) {\n pass ??= { frames: [], chainValues: null };\n pass.chainValues?.clear();\n }\n const nextResolved = computeOnce(\n workingResolved,\n userVariantProps,\n skipKeys,\n skipValues,\n nextClasses,\n nextStyle,\n protection,\n defaultResolved,\n false,\n pass,\n );\n\n // No pass has settled before the first one, so it reads the\n // latest values. It settles only when it changed nothing,\n // because a later computed default may replace a value it read.\n if (\n nextResolved === workingResolved ||\n (!isFirstRun &&\n areVariantsEqual(workingResolved, nextResolved))\n ) {\n if (nextResolved !== workingResolved) {\n computeOnce(\n nextResolved,\n userVariantProps,\n skipKeys,\n skipValues,\n classesOut,\n styleOut,\n protection,\n defaultResolved,\n true,\n );\n } else if (!useDirectOutput) {\n for (let i = 0; i < nextClasses.length; i++) {\n classesOut.push(nextClasses[i]);\n }\n Object.assign(styleOut, nextStyle);\n }\n return nextResolved;\n }\n\n // `remaining` is checked first: `process.env.NODE_ENV` is an\n // environment lookup in Node, not a property load, and only the\n // last `REFINE_UNSTABLE_TRACKING_WINDOW` passes need it. Bundlers\n // still inline it and drop the block.\n if (\n remaining < REFINE_UNSTABLE_TRACKING_WINDOW &&\n process.env.NODE_ENV !== \"production\"\n ) {\n if (!unstableChanges) {\n unstableChanges = new Map<string, VariantChange>();\n }\n accumulateUnstableVariantChanges(\n unstableChanges,\n workingResolved,\n nextResolved,\n );\n }\n\n if (useDirectOutput) {\n classesOut.length = classCount;\n for (const key in styleOut) {\n if (hasOwn(styleOut, key)) {\n Reflect.deleteProperty(styleOut, key);\n }\n }\n } else {\n lastClasses = nextClasses;\n lastStyle = nextStyle;\n }\n\n workingResolved = nextResolved;\n isFirstRun = false;\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n warnRefineLimit({\n creationFrame,\n unstableChanges,\n });\n }\n\n for (let i = 0; i < lastClasses.length; i++) {\n classesOut.push(lastClasses[i]);\n }\n Object.assign(styleOut, lastStyle);\n return workingResolved;\n };\n\n const resolveRefineOnce: ResolveRefineOnceFn = (\n resolved,\n userVariantProps,\n filterOwnVariants = true,\n protection,\n defaultResolved = resolved,\n pass,\n renderOnly = false,\n ) => {\n let workingResolved = resolved;\n\n // Visit every extend, as `computeOnce` does, so that disabled values are\n // removed at the same points. A later extend's callbacks can read them.\n for (let i = 0; i < extCount; i++) {\n const resolveExtend = extResolvers[i];\n const beforeExtend = workingResolved;\n if (resolveExtend) {\n const pendingFrame = pass ? extPendingFrames[i] : null;\n if (pass && pendingFrame) {\n pass.frames.push(pendingFrame);\n }\n workingResolved = resolveExtend(\n workingResolved,\n userVariantProps,\n true,\n protection,\n defaultResolved,\n pass,\n renderOnly,\n );\n if (pass && pendingFrame) {\n pass.frames.pop();\n }\n if (restorableKeys.length > 0) {\n workingResolved = restoreOwnValues(\n beforeExtend,\n workingResolved,\n extMetas[i],\n defaultResolved,\n protection,\n );\n }\n }\n workingResolved = filterOwnDisabledVariants(\n workingResolved,\n defaultResolved,\n );\n if (pass?.chainValues) {\n filterOwnDisabledChainValues(pass.chainValues, defaultResolved);\n }\n }\n\n if (renderOnly) return workingResolved;\n\n if (computedDefaultCount > 0) {\n workingResolved = runComputedDefaults(\n workingResolved,\n defaultResolved,\n userVariantProps,\n filterOwnVariants,\n protection,\n pass,\n );\n }\n if (refine) {\n const refineResult = runRefineContext(\n workingResolved,\n filterOwnVariants,\n false,\n true,\n protection,\n );\n workingResolved = refineResult.workingResolved;\n }\n\n return workingResolved;\n };\n\n const resolveRefine: ResolveRefineFn | null =\n refine || computedDefaultCount > 0 || extMetasWithRefineCount > 0\n ? (resolved, userVariantProps, filterOwnVariants = true) => {\n let remaining = MAX_REFINE_RUNS;\n const protection: RefineProtection | null = canProtectVariants\n ? { variants: null }\n : null;\n const incomingDefaultResolved = resolved;\n let workingResolved = resolved;\n // Latest variant changes from non-converging iterations inside the\n // tracking window. See the compute loop above for the shared\n // rationale.\n let unstableChanges: Map<string, VariantChange> | null = null;\n let pass: RefinePass | null = null;\n\n while (remaining > 0) {\n remaining -= 1;\n const defaultResolved = mergeProtectedIntoBase(\n incomingDefaultResolved,\n protection,\n );\n const nextResolved = resolveRefineOnce(\n workingResolved,\n userVariantProps,\n filterOwnVariants,\n protection,\n defaultResolved,\n pass,\n );\n\n // The first pass settles only when it changed nothing, for the\n // reason given in the compute loop above.\n if (nextResolved === workingResolved) {\n return nextResolved;\n }\n if (pass && areVariantsEqual(workingResolved, nextResolved)) {\n // Match the final pass of the compute loop above, which\n // removes a disabled value that a callback set after the\n // extend that disables it.\n return resolveRefineOnce(\n nextResolved,\n userVariantProps,\n filterOwnVariants,\n protection,\n defaultResolved,\n null,\n true,\n );\n }\n\n // `remaining` is checked first for the reason given in the\n // compute loop above.\n if (\n remaining < REFINE_UNSTABLE_TRACKING_WINDOW &&\n process.env.NODE_ENV !== \"production\"\n ) {\n if (!unstableChanges) {\n unstableChanges = new Map<string, VariantChange>();\n }\n accumulateUnstableVariantChanges(\n unstableChanges,\n workingResolved,\n nextResolved,\n );\n }\n workingResolved = nextResolved;\n pass ??= { frames: [], chainValues: null };\n pass.chainValues?.clear();\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n warnRefineLimit({\n creationFrame,\n unstableChanges,\n });\n }\n\n return workingResolved;\n }\n : null;\n\n // Top-level: resolves variants from user props, calls compute, then\n // assembles className and style with user-provided class/style overrides.\n const computeResult = (\n props: RecipeProps<MergedVariants> = EMPTY_DEFAULTS as RecipeProps<MergedVariants>,\n ): { className: string; style: StyleValue } => {\n const propsRecord = props as Record<string, unknown>;\n\n let resolved: Record<string, unknown> = {};\n Object.assign(resolved, staticDefaults);\n\n let userVariantProps: Record<string, unknown>;\n if (needsUserVariantProps) {\n const variantProps: Record<string, unknown> = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (!hasOwn(propsRecord, key)) continue;\n const value = propsRecord[key];\n variantProps[key] = value;\n if (value === undefined) continue;\n resolved[key] = value;\n }\n userVariantProps = variantProps;\n } else {\n // Fast path: walk variantKeys directly against propsRecord.\n // Own-property checks ensure a polluted Object.prototype can't add\n // values the user didn't pass.\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (!hasOwn(propsRecord, key)) continue;\n const v = propsRecord[key];\n if (v === undefined) continue;\n resolved[key] = v;\n }\n userVariantProps = propsRecord;\n }\n\n if (hasAnyDisabled) {\n const filtered: Record<string, unknown> = {};\n filterDisabledInto(resolved, filtered);\n resolved = filtered;\n }\n\n // Build allClasses directly. computedBaseClass already has all extend\n // bases joined with config.class — `compute` only adds variant classes\n // on top.\n const allClasses: ClsxClassValue[] = [computedBaseClass];\n const style: StyleValue = {};\n compute(resolved, userVariantProps, null, null, allClasses, style);\n\n // Apply user-provided class / className. Own-property checks keep these\n // consistent with the variant props read above: only what the caller\n // passed is applied, never a key inherited from Object.prototype.\n if (hasOwn(propsRecord, \"class\")) {\n allClasses.push(propsRecord.class as ClsxClassValue);\n }\n if (hasOwn(propsRecord, \"className\")) {\n allClasses.push(propsRecord.className as ClsxClassValue);\n }\n\n // Apply user-provided style, read before the own-property check for the\n // same reason as the variant loops above.\n const psv = propsRecord.style;\n if (psv != null && hasOwn(propsRecord, \"style\")) {\n if (typeof psv === \"string\") {\n if (psv.length > 0) {\n htmlStyleToStyleValue(psv, style);\n }\n } else if (typeof psv === \"object\") {\n htmlObjStyleToStyleValue(psv, style);\n }\n }\n\n return {\n className: transformClass(clsx(allClasses)),\n style,\n };\n };\n\n const getVariants = (variants?: VariantValues<MergedVariants>) => {\n const variantsRecord = variants ?? EMPTY_DEFAULTS;\n let variantProps = variantsRecord;\n // Copy to the declared variant keys, so the computed defaults that read\n // this record cannot see an undeclared key as an explicitly passed\n // variant, and cannot re-run a caller accessor once per refine pass. The\n // gate is narrower than that purpose: it misses a chain whose only\n // computed default is this recipe's own.\n // See https://github.com/ariakit/clava/issues/494\n if (variants && extMetasWithRefineCount > 0) {\n variantProps = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (hasOwn(variantsRecord, key)) {\n variantProps[key] = variantsRecord[key];\n }\n }\n }\n let resolvedVariants = resolveVariantsHot(variantProps);\n if (resolveRefine) {\n resolvedVariants = resolveRefine(\n resolvedVariants,\n variantProps,\n false,\n );\n } else if (canResolveVariants) {\n // No callback in this chain can restore a removed value, so one pass\n // reaches the state that render ends with.\n resolvedVariants = resolveRefineOnce(resolvedVariants, variantProps);\n }\n return resolvedVariants as VariantValues<MergedVariants>;\n };\n\n // Compute base class (without variants) — includes extended base classes.\n // Plain `clsx` (no `transformClass`): `meta.baseClass` flows back into\n // parent extends as `clsx` input and then through the single\n // `transformClass(clsx(allClasses))` at render time, so applying it here\n // would compound (double for own-render, triple+ for extend chains) and\n // misbehave for non-idempotent transforms.\n const computedBaseClass = hasExtend\n ? clsx(extBaseClassesArr, baseClass)\n : baseClass;\n\n // Shared closures across the default and modal recipes.\n const classFn = (props: RecipeProps<MergedVariants> = {}) => {\n return computeResult(props).className;\n };\n const meta: RecipeMeta = {\n identity,\n extends: extMetas,\n rebuild: (extensions) => build(extensions).meta,\n baseClass: computedBaseClass,\n staticDefaults,\n compute: computeOnce,\n resolveRefine: resolveRefine ? resolveRefineOnce : null,\n resolveVariants: canResolveVariants ? resolveRefineOnce : undefined,\n transformClass,\n functionVariantKeys,\n computedDefaultKeys,\n activeComputedDefaultKeys,\n disabledKeys,\n isDisabledValue,\n };\n\n const initRecipe = <\n R extends RecipeResult,\n T extends ModalRecipe<MergedVariants, R>,\n >(\n recipe: T,\n propKeys: string[],\n style: T[\"style\"],\n ): T => {\n recipe.class = classFn;\n recipe.style = style;\n recipe.getVariants = getVariants;\n recipe.variantKeys = variantKeys;\n recipe.propKeys = propKeys;\n (recipe as AnyRecipe & RecipeWithMeta)[META_KEY] = meta;\n return recipe;\n };\n\n // Default recipe\n const defaultRecipe = ((props: RecipeProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n return { class: className, style };\n }) as Recipe<V, E>;\n initRecipe(defaultRecipe, inputPropsKeys, (props = {}) => {\n return computeResult(props).style;\n });\n\n // JSX recipe\n const jsxRecipe = ((props: RecipeProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n return { className, style };\n }) as ModalRecipe<MergedVariants, JSXProps>;\n initRecipe(\n jsxRecipe,\n [\"className\", \"style\", ...variantKeys],\n (props = {}) => computeResult(props).style,\n );\n\n // HTML recipe\n const htmlRecipe = ((props: RecipeProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n return { class: className, style: styleValueToHTMLStyle(style) };\n }) as ModalRecipe<MergedVariants, HTMLProps>;\n initRecipe(htmlRecipe, [\"class\", \"style\", ...variantKeys], (props = {}) =>\n styleValueToHTMLStyle(computeResult(props).style),\n );\n\n // HTMLObj recipe\n const htmlObjRecipe = ((props: RecipeProps<MergedVariants> = {}) => {\n const { className, style } = computeResult(props);\n return { class: className, style: styleValueToHTMLObjStyle(style) };\n }) as ModalRecipe<MergedVariants, HTMLObjProps>;\n initRecipe(\n htmlObjRecipe,\n [\"class\", \"style\", ...variantKeys],\n (props = {}) => styleValueToHTMLObjStyle(computeResult(props).style),\n );\n\n defaultRecipe.jsx = jsxRecipe;\n defaultRecipe.html = htmlRecipe;\n defaultRecipe.htmlObj = htmlObjRecipe;\n\n return { recipe: defaultRecipe, meta };\n };\n return build(initialExtensions);\n };\n\n const cv = <V extends Variants = {}, const E extends AnyRecipe[] = []>(\n config: CVConfig<V, E> = {},\n ): InferredRecipe<V, E> => buildRecipe(config).recipe;\n\n return { cv, cx: transformedCx };\n}\n\nexport const cv = /* @__PURE__ */ (() => create().cv)();\n\n/**\n * Joins class values without applying a class transform.\n *\n * This behaves like the `cx` function returned by `create()` with no options.\n */\nexport function cx(...classes: ClsxClassValue[]) {\n return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qB,uBAAO,OAAO,CAAC,CAAC,GAAA,CAAI;AAOtD,SAAgB,GAAG,GAAG,SAA2B;CAC/C,OAAO,KAAK,OAAO;AACrB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/utils.ts","../src/debug.ts","../src/refine-warning.ts","../src/index.ts"],"sourcesContent":["import type { HTMLCSSProperties, StyleValue } from \"./types.ts\";\n\nexport const hasOwn = Object.hasOwn;\n\n/**\n * Reads a key that may be absent from a plain record. Variant, prop, and config\n * records are plain objects, so a key inherited from a polluted\n * `Object.prototype` would otherwise read back like a value the caller passed\n * or Clava itself resolved.\n */\nexport function getOwn<T extends object, K extends keyof T & string>(\n record: T,\n key: K,\n): T[K] | undefined {\n if (!hasOwn(record, key)) return undefined;\n return record[key];\n}\n\n// Keep this explicit so normalization does not depend on browser globals.\n// Vendor-prefixed variants are derived below instead of duplicating the list.\nconst unitlessNumberProperties = new Set([\n \"animationIterationCount\",\n \"aspectRatio\",\n \"borderImage\",\n \"borderImageOutset\",\n \"borderImageSlice\",\n \"borderImageWidth\",\n \"boxFlex\",\n \"boxFlexGroup\",\n \"boxOrdinalGroup\",\n \"columnCount\",\n \"columns\",\n \"fillOpacity\",\n \"flex\",\n \"flexGrow\",\n \"flexNegative\",\n \"flexOrder\",\n \"flexPositive\",\n \"flexShrink\",\n \"floodOpacity\",\n \"fontSizeAdjust\",\n \"fontWeight\",\n \"gridArea\",\n \"gridColumn\",\n \"gridColumnEnd\",\n \"gridColumnSpan\",\n \"gridColumnStart\",\n \"gridRow\",\n \"gridRowEnd\",\n \"gridRowSpan\",\n \"gridRowStart\",\n \"hyphenateLimitChars\",\n \"initialLetter\",\n \"lineClamp\",\n \"lineHeight\",\n \"maskBorder\",\n \"maskBorderOutset\",\n \"maskBorderSlice\",\n \"maskBorderWidth\",\n \"mathDepth\",\n \"maxLines\",\n \"opacity\",\n \"order\",\n \"orphans\",\n \"scale\",\n \"shapeImageThreshold\",\n \"stopOpacity\",\n \"strokeDasharray\",\n \"strokeDashoffset\",\n \"strokeMiterlimit\",\n \"strokeOpacity\",\n \"strokeWidth\",\n \"tabSize\",\n \"widows\",\n \"zIndex\",\n \"zoom\",\n]);\n\nfunction isCustomProperty(property: string) {\n return property.charCodeAt(0) === 45 && property.charCodeAt(1) === 45;\n}\n\n/**\n * Converts a hyphenated CSS property name to camelCase.\n * @example\n * hyphenToCamel(\"background-color\") // \"backgroundColor\"\n * hyphenToCamel(\"-ms-transition\") // \"msTransition\" (lowercase \"ms\" prefix)\n * hyphenToCamel(\"--custom-var\") // \"--custom-var\" (CSS variables are preserved)\n */\nexport function hyphenToCamel(str: string) {\n // CSS custom properties (variables) should not be converted\n if (isCustomProperty(str)) {\n return str;\n }\n // Fast path: no hyphen -> return as-is\n let hyphenIndex = str.indexOf(\"-\");\n if (hyphenIndex === -1) {\n return str;\n }\n\n let result = \"\";\n let lastIndex = 0;\n while (hyphenIndex !== -1) {\n result += str.slice(lastIndex, hyphenIndex);\n\n const nextIndex = hyphenIndex + 1;\n if (nextIndex >= str.length) {\n result += \"-\";\n lastIndex = nextIndex;\n break;\n }\n\n const code = str.charCodeAt(nextIndex);\n const isAsciiLetter =\n (code >= 65 && code <= 90) || (code >= 97 && code <= 122);\n if (isAsciiLetter) {\n const isMicrosoftPrefix = hyphenIndex === 0 && str.startsWith(\"ms-\", 1);\n result += isMicrosoftPrefix\n ? str[nextIndex]\n : str[nextIndex].toUpperCase();\n lastIndex = nextIndex + 1;\n } else {\n result += \"-\";\n lastIndex = nextIndex;\n }\n\n hyphenIndex = str.indexOf(\"-\", lastIndex);\n }\n\n return result + str.slice(lastIndex);\n}\n\n/**\n * Converts a camelCase CSS property name to hyphenated form.\n * @example\n * camelToHyphen(\"backgroundColor\") // \"background-color\"\n * camelToHyphen(\"msTransition\") // \"-ms-transition\" (lowercase \"ms\" prefix)\n * camelToHyphen(\"--customVar\") // \"--customVar\" (CSS variables are preserved)\n */\nexport function camelToHyphen(str: string) {\n // CSS custom properties (variables) should not be converted\n if (isCustomProperty(str)) {\n return str;\n }\n\n let result = \"\";\n let lastIndex = 0;\n for (let i = 0; i < str.length; i++) {\n const code = str.charCodeAt(i);\n if (code < 65 || code > 90) continue;\n const isMicrosoftPrefix = i === 2 && str.startsWith(\"ms\");\n if (isMicrosoftPrefix) {\n result += \"-\";\n }\n result += str.slice(lastIndex, i);\n result += \"-\";\n result += str[i].toLowerCase();\n lastIndex = i + 1;\n }\n\n if (lastIndex === 0) {\n return str;\n }\n return result + str.slice(lastIndex);\n}\n\nfunction hasVendorPrefix(property: string, prefix: string) {\n const nextCode = property.charCodeAt(prefix.length);\n if (nextCode < 65 || nextCode > 90) return false;\n return property.startsWith(prefix);\n}\n\n// \"ms\" is used in JSX, while camelizing hyphenated properties produces \"Ms\".\nconst vendorPrefixes = [\"Webkit\", \"Moz\", \"ms\", \"Ms\", \"O\"];\n\nfunction isUnitlessNumberProperty(property: string) {\n if (unitlessNumberProperties.has(property)) return true;\n\n for (const prefix of vendorPrefixes) {\n if (!hasVendorPrefix(property, prefix)) continue;\n const firstCode = property.charCodeAt(prefix.length);\n const unprefixedProperty =\n String.fromCharCode(firstCode + 32) + property.slice(prefix.length + 1);\n return unitlessNumberProperties.has(unprefixedProperty);\n }\n return false;\n}\n\nfunction normalizeStyleValue(property: string, value: string | number) {\n if (typeof value === \"string\") {\n return value;\n }\n if (isCustomProperty(property)) {\n return value;\n }\n if (isUnitlessNumberProperty(property)) {\n return value;\n }\n return `${value}px`;\n}\n\n/**\n * Parses a CSS style string into a StyleValue object.\n * @example\n * htmlStyleToStyleValue(\"background-color: red; font-size: 16px;\");\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlStyleToStyleValue(\n styleString: string,\n result: StyleValue = {},\n) {\n if (!styleString) return result;\n const len = styleString.length;\n let i = 0;\n while (i < len) {\n // Skip leading whitespace and stray semicolons\n while (i < len) {\n const c = styleString.charCodeAt(i);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13 && c !== 59) break;\n i++;\n }\n if (i >= len) break;\n // Read property name until ':' or ';'\n const propStart = i;\n while (i < len) {\n const c = styleString.charCodeAt(i);\n if (c === 58 || c === 59) break;\n i++;\n }\n if (i >= len || styleString.charCodeAt(i) === 59) {\n // No colon found - skip this declaration\n if (i < len) {\n // Skip ';'.\n i++;\n }\n continue;\n }\n let propEnd = i;\n // Trim trailing whitespace from property name\n while (propEnd > propStart) {\n const c = styleString.charCodeAt(propEnd - 1);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13) break;\n propEnd--;\n }\n if (propEnd === propStart) {\n // Empty property - skip\n while (i < len && styleString.charCodeAt(i) !== 59) {\n i++;\n }\n if (i < len) {\n i++;\n }\n continue;\n }\n const property = styleString.slice(propStart, propEnd);\n // Skip ':'.\n i++;\n // Skip whitespace before value\n while (i < len) {\n const c = styleString.charCodeAt(i);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13) break;\n i++;\n }\n const valStart = i;\n while (i < len && styleString.charCodeAt(i) !== 59) {\n i++;\n }\n let valEnd = i;\n while (valEnd > valStart) {\n const c = styleString.charCodeAt(valEnd - 1);\n if (c !== 32 && c !== 9 && c !== 10 && c !== 13) break;\n valEnd--;\n }\n if (i < len) {\n // Skip ';'.\n i++;\n }\n if (valEnd === valStart) continue;\n const value = styleString.slice(valStart, valEnd);\n // CSS property names and values are dynamic - cast required for index access\n (result as Record<string, string>)[hyphenToCamel(property)] = value;\n }\n\n return result;\n}\n\n/**\n * Converts a hyphenated style object to a camelCase StyleValue object.\n * @example\n * htmlObjStyleToStyleValue({ \"background-color\": \"red\", \"font-size\": \"16px\" });\n * // { backgroundColor: \"red\", fontSize: \"16px\" }\n */\nexport function htmlObjStyleToStyleValue(\n style: object,\n result: StyleValue = {},\n): StyleValue {\n for (const key in style) {\n if (!hasOwn(style, key)) continue;\n const value = (style as Record<string, unknown>)[key];\n if (value == null) continue;\n const property = hyphenToCamel(key);\n // CSS property names and values are dynamic - cast required for index access\n (result as Record<string, string | number>)[property] = normalizeStyleValue(\n property,\n value as string | number,\n );\n }\n return result;\n}\n\n/**\n * Converts a StyleValue object to a CSS style string.\n * @example\n * styleValueToHTMLStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // \"background-color: red; font-size: 16px;\"\n */\nexport function styleValueToHTMLStyle(style: StyleValue): string {\n let result = \"\";\n for (const key in style) {\n if (!hasOwn(style, key)) continue;\n const value = (style as Record<string, unknown>)[key];\n if (value == null) continue;\n if (result) {\n result += \"; \";\n }\n result += camelToHyphen(key);\n result += \": \";\n result += value as string | number;\n }\n if (!result) return \"\";\n return `${result};`;\n}\n\n/**\n * Converts a StyleValue object to a hyphenated style object.\n * @example\n * styleValueToHTMLObjStyle({ backgroundColor: \"red\", fontSize: \"16px\" });\n * // { \"background-color\": \"red\", \"font-size\": \"16px\" }\n */\nexport function styleValueToHTMLObjStyle(style: StyleValue) {\n const result: HTMLCSSProperties = {};\n for (const key in style) {\n if (!hasOwn(style, key)) continue;\n const value = (style as Record<string, unknown>)[key];\n if (value == null) continue;\n (result as Record<string, unknown>)[camelToHyphen(key)] = value;\n }\n return result;\n}\n","import { hasOwn } from \"./utils.ts\";\n\n/**\n * The attribute that recipes add in development to show the resolved variants\n * that produced an element.\n */\nexport const DEBUG_ATTRIBUTE = \"data-clava-debug\";\n\n/**\n * Returns whether recipes created by a factory outside production add the\n * debug attribute. The `debug` option wins. The default adds it only in\n * development, so test snapshots don't change.\n */\nexport function isDebugEnabled(option: boolean | undefined): boolean {\n return option ?? process.env.NODE_ENV === \"development\";\n}\n\nfunction formatDebugValue(value: unknown): string {\n if (typeof value === \"string\") {\n // Single quotes keep the value readable in HTML, where attribute values\n // are shown in double quotes.\n return `'${value.replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll(\"'\", \"\\\\'\")}'`;\n }\n if (typeof value === \"bigint\") return `${value}n`;\n if (typeof value === \"function\") return \"{...}\";\n if (typeof value === \"object\" && value != null) return \"{...}\";\n return String(value);\n}\n\ninterface FormatDebugAttributeParams {\n variantKeys: readonly string[];\n variants: Record<string, unknown>;\n incoming: unknown;\n}\n\n/**\n * Formats a recipe's resolved variants as space-separated `key=value` pairs in\n * the recipe's variant key order. A debug value that another recipe passed as\n * a prop is appended, so the variants of the recipe that renders the element\n * come first.\n *\n * The value has no source location. Server stacks can be source-mapped or\n * name other files than browser stacks, such as Turbopack chunks, and a\n * different value would cause hydration mismatches.\n */\nexport function formatDebugAttribute({\n variantKeys,\n variants,\n incoming,\n}: FormatDebugAttributeParams): string {\n const parts: string[] = [];\n for (let i = 0; i < variantKeys.length; i++) {\n const key = variantKeys[i];\n if (key === undefined) continue;\n if (!hasOwn(variants, key)) continue;\n const value = variants[key];\n if (value === undefined) continue;\n parts.push(`${key}=${formatDebugValue(value)}`);\n }\n if (typeof incoming === \"string\" && incoming) {\n parts.push(incoming);\n }\n return parts.join(\" \");\n}\n","import { getOwn, hasOwn } from \"./utils.ts\";\n\nexport interface CreationFrame {\n stack?: string;\n}\n\nexport interface VariantChange {\n from: unknown;\n to: unknown;\n}\n\n// Once a refine loop is within this many iterations of the cap, start tracking\n// the latest value transition for every variant key that changes between\n// iterations so the warning can report every key that contributed to the\n// oscillation, not just the keys that happened to flip on the final step.\n// Convergent loops (the common case) exit well before this threshold and pay no\n// per-iteration tracking cost.\nexport const REFINE_UNSTABLE_TRACKING_WINDOW = 10;\n\n// Captures the call site of the function passed in `skipFn` so refine-limit\n// warnings can point developers at the originating `cv()` call. Returns\n// `undefined` in production so bundlers that replace `process.env.NODE_ENV` at\n// build time can drop the entire warning machinery. The underlying `.stack`\n// string is formatted lazily on first access in every major engine (V8,\n// SpiderMonkey, JavaScriptCore), so holding the captured frame for the\n// lifetime of the recipe is cheap when no warning fires.\nexport function captureCreationFrame(\n skipFn: Function,\n): CreationFrame | undefined {\n if (process.env.NODE_ENV === \"production\") return undefined;\n if (typeof Error.captureStackTrace === \"function\") {\n const holder: CreationFrame = {};\n Error.captureStackTrace(holder, skipFn);\n return holder;\n }\n // Engines without `Error.captureStackTrace` (SpiderMonkey, JavaScriptCore)\n // can't strip internal frames, but their `Error.stack` getter is still\n // lazy, so returning the Error instance defers the format cost. The\n // resulting trace includes extra frames from this helper, `buildRecipe`,\n // and `cv` itself.\n return new Error();\n}\n\nexport function formatCreationStack(frame: CreationFrame): string | undefined {\n let stack = frame.stack;\n if (!stack) return undefined;\n // V8 prefixes the stack with a leading \"Error\" / \"Error: message\" line that\n // isn't meaningful for a captured location — drop it.\n const newlineIdx = stack.indexOf(\"\\n\");\n if (newlineIdx > 0) {\n const firstLine = stack.slice(0, newlineIdx);\n if (firstLine === \"Error\" || firstLine.startsWith(\"Error:\")) {\n stack = stack.slice(newlineIdx + 1);\n }\n }\n const frames = stack.split(\"\\n\");\n for (let i = 0; i < frames.length; i++) {\n const line = frames[i]?.trim();\n if (!line) continue;\n if (isInternalCreationFrame(line)) continue;\n if (line.includes(\"/node_modules/\")) continue;\n if (line.includes(\"\\\\node_modules\\\\\")) continue;\n if (line.includes(\"node:internal\")) continue;\n return ` ${line}`;\n }\n return undefined;\n}\n\nfunction isInternalCreationFrame(line: string): boolean {\n if (line.includes(\"captureCreationFrame\")) return true;\n if (line.startsWith(\"at buildRecipe \")) return true;\n if (line.startsWith(\"at buildRecipe(\")) return true;\n if (line.startsWith(\"buildRecipe@\")) return true;\n if (line.startsWith(\"at cv \")) return true;\n if (line.startsWith(\"at cv(\")) return true;\n if (line.startsWith(\"cv@\")) return true;\n return false;\n}\n\nfunction formatVariantValue(value: unknown): string {\n if (typeof value === \"string\") return JSON.stringify(value);\n if (typeof value === \"number\") {\n if (Number.isNaN(value)) return \"NaN\";\n return String(value);\n }\n if (typeof value === \"bigint\") return `${value}n`;\n if (value === undefined) return \"undefined\";\n if (value === null) return \"null\";\n if (typeof value === \"boolean\") return String(value);\n if (typeof value === \"symbol\") return String(value);\n if (typeof value === \"function\") return \"[function]\";\n return \"[object]\";\n}\n\nfunction setVariantChange(\n into: Map<string, VariantChange>,\n key: string,\n from: unknown,\n to: unknown,\n): void {\n into.set(key, { from, to });\n}\n\nexport function accumulateUnstableVariantChanges(\n into: Map<string, VariantChange>,\n prev: Record<string, unknown>,\n next: Record<string, unknown>,\n): void {\n for (const key in next) {\n if (!hasOwn(next, key)) continue;\n const from = getOwn(prev, key);\n if (!Object.is(from, next[key])) {\n setVariantChange(into, key, from, next[key]);\n }\n }\n for (const key in prev) {\n if (!hasOwn(prev, key)) continue;\n if (hasOwn(next, key)) continue;\n setVariantChange(into, key, prev[key], undefined);\n }\n}\n\nfunction formatVariantChanges(changes: Map<string, VariantChange>): string {\n return Array.from(changes)\n .map(([key, { from, to }]) => {\n return `${key}: ${formatVariantValue(from)} -> ${formatVariantValue(to)}`;\n })\n .join(\", \");\n}\n\ninterface WarnRefineLimitParams {\n creationFrame: CreationFrame | undefined;\n unstableChanges: Map<string, VariantChange> | null;\n}\n\nexport function warnRefineLimit({\n creationFrame,\n unstableChanges,\n}: WarnRefineLimitParams): void {\n // Bundlers are expected to replace this branch with a production literal,\n // allowing warning-only code below to be removed from consumer bundles.\n if (process.env.NODE_ENV === \"production\") return;\n let message =\n \"Clava: Maximum refine iterations exceeded. This can happen when a \" +\n \"computed default variant or refine callback changes one of the \" +\n \"variants on every run.\";\n if (unstableChanges && unstableChanges.size > 0) {\n message += `\\nVariant(s) that did not stabilize: ${Array.from(unstableChanges.keys()).join(\", \")}.`;\n message += `\\nLatest variant changes before warning: ${formatVariantChanges(unstableChanges)}.`;\n }\n if (creationFrame) {\n const creationStack = formatCreationStack(creationFrame);\n if (creationStack) {\n message += `\\nRecipe created at:\\n${creationStack}`;\n }\n }\n console.warn(message);\n}\n","import clsx, { type ClassValue as ClsxClassValue } from \"clsx\";\nimport {\n DEBUG_ATTRIBUTE,\n formatDebugAttribute,\n isDebugEnabled,\n} from \"./debug.ts\";\nimport {\n REFINE_UNSTABLE_TRACKING_WINDOW,\n type VariantChange,\n accumulateUnstableVariantChanges,\n captureCreationFrame,\n warnRefineLimit,\n} from \"./refine-warning.ts\";\nimport type {\n AnyRecipe,\n ClassValue,\n DefaultVariants,\n ExtendableVariants,\n HTMLCSSProperties,\n HTMLObjProps,\n HTMLProps,\n InferredRecipe,\n JSXCSSProperties,\n JSXProps,\n KeySourceRecipe,\n MergeVariants,\n ModalRecipe,\n Recipe,\n RecipeLike,\n RecipeProps,\n RecipeResult,\n Refine,\n SplitPropsFunction,\n StyleClassProps,\n StyleClassValue,\n StyleValue,\n VariantValues,\n Variants,\n} from \"./types.ts\";\nimport {\n getOwn,\n hasOwn,\n htmlObjStyleToStyleValue,\n htmlStyleToStyleValue,\n styleValueToHTMLObjStyle,\n styleValueToHTMLStyle,\n} from \"./utils.ts\";\n\n// Internal compute path: pushes the variant classes contributed by this\n// recipe (and its extends chain) into `classesOut` and merges any styles\n// into `styleOut`. Base class is handled by callers via RecipeMeta.baseClass\n// to avoid string-parsing round trips. Both outputs are mutated in place to\n// avoid intermediate allocations.\ntype ComputeFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n skipKeys: Set<string> | null,\n skipValues: Record<string, Set<string>> | null,\n classesOut: ClsxClassValue[],\n styleOut: StyleValue,\n) => Record<string, unknown>;\n\ntype ComputeOnceFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n skipKeys: Set<string> | null,\n skipValues: Record<string, Set<string>> | null,\n classesOut: ClsxClassValue[],\n styleOut: StyleValue,\n protection?: RefineProtection | null,\n defaultResolved?: Record<string, unknown>,\n renderOnly?: boolean,\n pass?: RefinePass | null,\n) => Record<string, unknown>;\n\ntype ResolveRefineFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n filterOwnVariants?: boolean,\n) => Record<string, unknown>;\n\ntype ResolveRefineOnceFn = (\n resolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n filterOwnVariants?: boolean,\n protection?: RefineProtection | null,\n defaultResolved?: Record<string, unknown>,\n pass?: RefinePass | null,\n renderOnly?: boolean,\n) => Record<string, unknown>;\n\ntype ComputedDefaultVariantFn = (\n defaultValue: unknown,\n variants: Readonly<Record<string, unknown>>,\n) => unknown;\n\n// Internal metadata stored on recipes but hidden from public types.\ninterface RecipeMeta {\n identity?: object;\n extends?: RecipeMeta[];\n rebuild?: (extensions: RecipeMeta[]) => RecipeMeta;\n baseClass: string;\n staticDefaults: Record<string, unknown>;\n // Performs a single compute pass for extending recipes, returning the\n // resolved variants while pushing classes and styles into the output values.\n compute: ComputeOnceFn;\n // Set only when this recipe's chain has computed defaults or `refine`.\n resolveRefine: ResolveRefineOnceFn | null;\n // Mirrors the variant changes of `compute` without rendering. A recipe with\n // no callbacks in its chain can still have it, because it can filter disabled\n // values that a later extend's callbacks would otherwise read. Missing when\n // the chain can't change variants, and in older Clava copies.\n resolveVariants?: ResolveRefineOnceFn;\n // Reference identity is used to detect mixed-factory `extend`. When a\n // recipe is extended by a parent from a different `create()` call, the\n // parent applies this transform to the extend's contribution before joining,\n // preserving each factory's transform boundary.\n transformClass: (className: string) => string;\n // Variant keys whose effective definition in this recipe's chain is a\n // function. An extending recipe that supplies a non-function variant for\n // the same key uses this to tell us to skip that key (matching the\n // type-level \"function variant is replaced by anything in the child\" rule).\n // Empty when no key in this chain is a function variant.\n functionVariantKeys: Set<string>;\n // Variant keys with computed defaults anywhere in this recipe's chain.\n // Child recipes use this to preserve inherited computed defaults through\n // `defaultValue` without preserving their own prior computed result.\n computedDefaultKeys: Set<string>;\n // Variant keys whose computed defaults run in this recipe's pruned chain.\n // Unlike `computedDefaultKeys`, a pruned shared ancestor doesn't add keys.\n // Older Clava copies don't expose it.\n activeComputedDefaultKeys?: Set<string>;\n // Variant keys that this recipe's chain disables entirely or partly. Older\n // Clava copies don't expose it or `isDisabledValue`.\n disabledKeys?: Set<string>;\n // Whether this recipe's chain removes the value for the key from the variants\n // it returns. A recipe that defines a value again stops its removal.\n isDisabledValue?: (key: string, value: unknown) => boolean;\n}\n\nconst META_KEY = \"__meta\";\n\ninterface RecipeWithMeta {\n [META_KEY]?: RecipeMeta;\n}\n\nconst EMPTY_DEFAULTS: Record<string, unknown> = {};\n\n// Prune shared recipes before compiling their parent's compute path. Keeping\n// the first path preserves its overrides and factory transform boundaries.\nfunction deduplicateExtensions(\n extensions: RecipeMeta[],\n seen = new Set<object>(),\n): RecipeMeta[] {\n if (extensions.length === 0) {\n return extensions;\n }\n const result: RecipeMeta[] = [];\n let changed = false;\n for (const meta of extensions) {\n const identity = getOwn(meta, \"identity\") ?? meta;\n if (seen.has(identity)) {\n changed = true;\n continue;\n }\n seen.add(identity);\n // Older Clava copies expose the compute metadata but not their graph.\n // Keep their contribution intact instead of traversing hidden ancestors.\n const inheritedExtensions = getOwn(meta, \"extends\");\n const rebuild = getOwn(meta, \"rebuild\");\n if (!inheritedExtensions || !rebuild) {\n result.push(meta);\n continue;\n }\n const children = deduplicateExtensions(inheritedExtensions, seen);\n if (children === inheritedExtensions) {\n result.push(meta);\n } else {\n result.push(rebuild(children));\n changed = true;\n }\n }\n return changed ? result : extensions;\n}\n\nconst MAX_REFINE_RUNS = 50;\n\nfunction areVariantsEqual(\n a: Record<string, unknown>,\n b: Record<string, unknown>,\n): boolean {\n // The first loop proves every own key of `a` is an own key of `b` with the\n // same value, so counting both sides is enough to prove the key sets match.\n // Counting keeps the total number of lookups the same as before the own-key\n // check was added to the first loop.\n let ownKeyDifference = 0;\n for (const key in a) {\n if (!hasOwn(a, key)) continue;\n if (!hasOwn(b, key)) return false;\n if (!Object.is(a[key], b[key])) return false;\n ownKeyDifference++;\n }\n for (const key in b) {\n if (!hasOwn(b, key)) continue;\n ownKeyDifference--;\n }\n return ownKeyDifference === 0;\n}\n\n// Variants that a `refine` callback assigned through `setVariants`. Two stages\n// read them: computed defaults skip a key that was assigned this way, and\n// `mergeProtectedIntoBase` folds them into the base each pass resolves from.\n// The record is created on the first `setVariants` call, because most callbacks\n// only read variants. The holder is shared so that a callback anywhere in the\n// chain can report its assignment back to the resolution that owns the pass.\ninterface RefineProtection {\n variants: Record<string, unknown> | null;\n}\n\nfunction mergeProtectedIntoBase(\n baseResolved: Record<string, unknown>,\n protection: RefineProtection | null,\n): Record<string, unknown> {\n const protectedVariants = protection?.variants;\n if (!protectedVariants) return baseResolved;\n return Object.assign({}, baseResolved, protectedVariants);\n}\n\n// A pass after the first one of a resolution loop. A computed default that\n// writes a key that a later computed default computes again, such as a base that\n// resets it to its static default, writes it to `chainValues` instead of the\n// working variants. Only the later computed defaults for that key read it, so\n// other callbacks keep the value that the previous pass settled on.\n// See https://github.com/ariakit/clava/issues/613\ninterface RefinePass {\n // One frame for each recipe on the current extend path.\n frames: PendingFrame[];\n // Values for keys that a later computed default still computes. The working\n // variants hold `undefined` the same way as a missing key, so it marks a\n // cleared key here too.\n chainValues: Map<string, unknown> | null;\n}\n\ninterface PendingFrame {\n // Keys that computed defaults compute after the current extend.\n keys: ReadonlySet<string> | null;\n // Whether the recipe removes a value after each extend. A computed default\n // below it writes such a value to the working variants, as before, so the\n // removal applies.\n isDisabled: ((key: string, value: unknown) => boolean) | null;\n}\n\nfunction isPendingKey(frames: PendingFrame[], key: string): boolean {\n for (let i = 0; i < frames.length; i++) {\n if (frames[i]?.keys?.has(key)) return true;\n }\n return false;\n}\n\nfunction isDisabledOnPath(\n frames: PendingFrame[],\n key: string,\n value: unknown,\n): boolean {\n for (let i = 0; i < frames.length; i++) {\n if (frames[i]?.isDisabled?.(key, value)) return true;\n }\n return false;\n}\n\n// Chains that mix in recipes from an older Clava copy aren't supported. Their\n// metadata lacks these keys, which then count as none instead of throwing.\nconst NO_KEYS: ReadonlySet<string> = new Set();\n\nfunction getActiveComputedDefaultKeys(meta: RecipeMeta): ReadonlySet<string> {\n return getOwn(meta, \"activeComputedDefaultKeys\") ?? NO_KEYS;\n}\n\n// Returns a copy of `variants` where `key` holds `value`, or is missing when\n// `value` is `undefined`.\nfunction withVariant(\n variants: Record<string, unknown>,\n key: string,\n value: unknown,\n): Record<string, unknown> {\n const copy = Object.assign({}, variants);\n if (value === undefined) {\n delete copy[key];\n } else {\n copy[key] = value;\n }\n return copy;\n}\n\nexport type {\n ClassValue,\n StyleValue,\n StyleClassProps,\n StyleClassValue,\n JSXProps,\n HTMLProps,\n HTMLObjProps,\n JSXCSSProperties,\n HTMLCSSProperties,\n ModalRecipe,\n Recipe,\n RecipeLike,\n RecipeProps,\n SplitPropsFunction,\n};\n\n/**\n * Extracts the variant props inferred for a Clava recipe. Use it to add a\n * recipe's variant props to framework component props.\n *\n * @example\n * ```ts\n * import { type VariantProps, cv } from \"clava\";\n * import type { ComponentProps } from \"react\";\n *\n * const button = cv({\n * variants: {\n * size: { sm: \"button-sm\", lg: \"button-lg\" },\n * disabled: { true: \"button-disabled\", false: \"\" },\n * },\n * });\n *\n * interface ButtonProps\n * extends ComponentProps<\"button\">,\n * VariantProps<typeof button> {}\n *\n * const props: ButtonProps = {\n * size: \"lg\",\n * disabled: true,\n * };\n * ```\n */\nexport type VariantProps<T extends Pick<AnyRecipe, \"getVariants\">> = ReturnType<\n T[\"getVariants\"]\n>;\n\n/**\n * Combines variant props with a recipe prop named `recipe` by default. The\n * prop is optional when the selected recipe is assignable to the base type,\n * and required when the selected recipe adds variants. Pass a third type\n * argument to use another prop name.\n *\n * When `R` is a union of recipes, the variant props include only the\n * variants that every member defines.\n *\n * When inferring `R`, passing `undefined` or forwarding an optional recipe\n * can fail the recipe constraint. Resolve the optional value before passing\n * it, for example with `recipe: override ?? disclosure`.\n *\n * @example\n * ```ts\n * import { type RecipeLike, type VariantPropsWithRecipe, cv } from \"clava\";\n *\n * const disclosure = cv({ variants: { $open: \"open\" } });\n *\n * type DisclosureProps<\n * R extends RecipeLike<typeof disclosure, R> = typeof disclosure,\n * > = VariantPropsWithRecipe<typeof disclosure, R>;\n *\n * type StyledDisclosureProps<\n * R extends RecipeLike<typeof disclosure, R> = typeof disclosure,\n * > = VariantPropsWithRecipe<typeof disclosure, R, \"styles\">;\n * ```\n */\nexport type VariantPropsWithRecipe<\n Base extends Recipe<any, any, any>,\n R extends RecipeLike<Base, R>,\n Name extends string = \"recipe\",\n> = VariantProps<R> &\n PartialVariantKeys<R> &\n ([R] extends [Base] ? { [Key in Name]?: R } : { [Key in Name]: R });\n\n// Blocks variants that only some union members define, because the selected\n// member may not process them. With no such keys, this is `unknown` so props\n// keep their exact shape instead of gaining an empty `{}` intersection member.\ntype PartialVariantKeys<\n R extends Pick<AnyRecipe, \"getVariants\">,\n Key extends PropertyKey = Exclude<\n UnionKeys<VariantProps<R>>,\n keyof VariantProps<R>\n >,\n> = [Key] extends [never] ? unknown : { [K in Key]?: never };\n\ntype UnionKeys<T> = T extends unknown ? keyof T : never;\n\n// Variant props expose booleans, but variant object keys are always strings.\ntype VariantKey<T> = T extends boolean ? \"true\" | \"false\" : Extract<T, string>;\n\n/**\n * Constrains a variant map to the same value keys as a variant on another\n * recipe. Boolean variants are represented with `\"true\"` and `\"false\"`\n * object keys.\n *\n * @example\n * ```ts\n * import { type Variant, cv } from \"clava\";\n *\n * const button = cv({\n * variants: {\n * size: { sm: \"button-sm\", lg: \"button-lg\" },\n * },\n * });\n *\n * const icon = cv({\n * extend: [button],\n * variants: {\n * size: {\n * sm: \"icon-sm\",\n * lg: \"icon-lg\",\n * } satisfies Variant<typeof button, \"size\">,\n * },\n * });\n * ```\n */\nexport type Variant<\n T extends Pick<AnyRecipe, \"getVariants\">,\n K extends keyof VariantProps<T>,\n> = Record<\n VariantKey<NonNullable<VariantProps<T>[K]>>,\n ClassValue | StyleClassValue\n>;\n\n/**\n * The configuration object accepted by `cv()`. It defines base class/style\n * output, variants, default variants, recipe extensions, and refinement\n * logic.\n *\n * @example\n * ```ts\n * import { type CVConfig, cv } from \"clava\";\n *\n * const config: CVConfig<{\n * tone: { info: string; danger: string };\n * }> = {\n * variants: {\n * tone: {\n * info: \"alert-info\",\n * danger: \"alert-danger\",\n * },\n * },\n * defaultVariants: {\n * tone: \"info\",\n * },\n * };\n *\n * const alert = cv(config);\n * ```\n */\nexport interface CVConfig<V extends Variants = {}, E extends AnyRecipe[] = []> {\n extend?: E;\n class?: ClassValue;\n style?: StyleValue;\n variants?: ExtendableVariants<V, E>;\n defaultVariants?: DefaultVariants<MergeVariants<V, E>>;\n refine?: Refine<MergeVariants<V, E>>;\n}\n\ninterface CreateParams {\n transformClass?: (className: string) => string;\n /**\n * Whether recipes add a `data-clava-debug` attribute that lists their\n * resolved variants. Defaults to `true` when `NODE_ENV` is\n * `\"development\"`. The attribute is never added in production.\n */\n debug?: boolean;\n}\n\nfunction identityClass(className: string) {\n return className;\n}\n\nfunction isRecordObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== \"object\") return false;\n if (value == null) return false;\n if (Array.isArray(value)) return false;\n return true;\n}\n\n/**\n * Converts any style input (string, JSX object, or HTML object) to a normalized\n * StyleValue.\n */\nfunction normalizeStyle(style: unknown): StyleValue {\n if (typeof style === \"string\") {\n return htmlStyleToStyleValue(style);\n }\n if (typeof style === \"object\" && style != null) {\n return htmlObjStyleToStyleValue(style);\n }\n return {};\n}\n\n/**\n * Pre-extracts the class and (normalized) style from a variant value once at\n * recipe creation time. Returns `null` if the value contributes nothing.\n */\ninterface PrebuiltValue {\n class: ClassValue;\n style: StyleValue | null;\n}\n\nfunction extractClassAndStylePrebuilt(value: unknown): PrebuiltValue {\n if (!isRecordObject(value)) {\n return { class: value as ClassValue, style: null };\n }\n // A value that owns neither key contributes nothing, and a value that owns\n // one of them must not pick up the other from a polluted `Object.prototype`.\n // Checked inline rather than through `getOwn`: this runs for every variant\n // value at creation time, where the call is worth about 3% of `cv()`.\n const styleClassValue = value as StyleClassValue;\n const classValue = hasOwn(value, \"class\") ? styleClassValue.class : undefined;\n const styleValue = hasOwn(value, \"style\") ? styleClassValue.style : undefined;\n if (classValue === undefined && styleValue === undefined) {\n return { class: null, style: null };\n }\n const style = normalizeStyle(styleValue);\n return {\n class: classValue ?? null,\n style: Object.keys(style).length > 0 ? style : null,\n };\n}\n\nfunction getVariantValueKey(value: unknown): string | undefined {\n if (typeof value === \"string\") {\n return value;\n }\n if (typeof value === \"number\") {\n return String(value);\n }\n if (typeof value === \"boolean\") {\n return String(value);\n }\n return undefined;\n}\n\nconst EMPTY_KEYS: readonly string[] = [];\n\nfunction isRecipeKeySource(source: unknown): source is KeySourceRecipe {\n if (!source) return false;\n if (typeof source !== \"object\" && typeof source !== \"function\") {\n return false;\n }\n const typed = source as Record<string, unknown>;\n if (typeof typed.getVariants !== \"function\") return false;\n if (!Array.isArray(typed.propKeys)) return false;\n return Array.isArray(typed.variantKeys);\n}\n\n/**\n * Splits props into multiple groups based on key sources. Only the first\n * recipe claims styling props (class/className/style). Subsequent recipes\n * only receive variant props. Arrays always receive their listed keys but don't\n * claim styling props.\n */\nfunction splitPropsImpl(\n selfKeys: readonly string[],\n selfIsRecipe: boolean,\n props: Record<string, unknown>,\n sources: unknown[],\n): Record<string, unknown>[] {\n const sourcesLength = sources.length;\n const results: Record<string, unknown>[] = [];\n let stylingClaimed = selfIsRecipe;\n // The recipe that claims styling props also receives an incoming debug\n // attribute, so it can append the value to its own. The rest props keep the\n // value too, so it still reaches the element through `.class()`.\n let stylingResult: Record<string, unknown> | null = null;\n\n const selfResult: Record<string, unknown> = {};\n const selfKeysLength = selfKeys.length;\n for (let i = 0; i < selfKeysLength; i++) {\n const key = selfKeys[i];\n if (key !== undefined && hasOwn(props, key)) {\n selfResult[key] = props[key];\n }\n }\n results.push(selfResult);\n if (selfIsRecipe) {\n stylingResult = selfResult;\n }\n\n // Track effective key arrays for the rest computation — for typical inputs\n // a linear scan beats building a Set up-front.\n const effectiveKeyArrays: Array<readonly string[]> = [selfKeys];\n\n for (let s = 0; s < sourcesLength; s++) {\n const source = sources[s];\n const sourceResult: Record<string, unknown> = {};\n let sourceIsRecipe = false;\n let effectiveKeys: readonly string[];\n if (Array.isArray(source)) {\n effectiveKeys = source;\n } else if (isRecipeKeySource(source)) {\n sourceIsRecipe = true;\n effectiveKeys = stylingClaimed ? source.variantKeys : source.propKeys;\n } else {\n effectiveKeys = EMPTY_KEYS;\n }\n\n const effectiveKeysLength = effectiveKeys.length;\n for (let i = 0; i < effectiveKeysLength; i++) {\n const key = effectiveKeys[i];\n if (key !== undefined && hasOwn(props, key)) {\n sourceResult[key] = props[key];\n }\n }\n results.push(sourceResult);\n effectiveKeyArrays.push(effectiveKeys);\n\n if (sourceIsRecipe && !stylingClaimed) {\n stylingClaimed = true;\n stylingResult = sourceResult;\n }\n }\n\n const rest: Record<string, unknown> = {};\n const propKeys = Object.keys(props);\n const propKeysLength = propKeys.length;\n const groupCount = sourcesLength + 1;\n outer: for (let i = 0; i < propKeysLength; i++) {\n const key = propKeys[i];\n if (key === undefined) continue;\n // Checked in this loop, which already visits every own enumerable key, so\n // that calls without the attribute don't pay for a separate `hasOwn`\n // lookup.\n if (key === DEBUG_ATTRIBUTE && stylingResult) {\n stylingResult[key] = props[key];\n }\n for (let g = 0; g < groupCount; g++) {\n const arr = effectiveKeyArrays[g];\n if (arr === undefined) continue;\n const arrLength = arr.length;\n for (let j = 0; j < arrLength; j++) {\n if (arr[j] === key) continue outer;\n }\n }\n rest[key] = props[key];\n }\n results.push(rest);\n\n return results;\n}\n\n/**\n * Splits props into multiple groups based on key sources. Each source gets its\n * own result object containing all its matching keys. The first recipe\n * source claims styling props (class/className/style). Subsequent recipes\n * only receive variant props. Arrays receive their listed keys but don't claim\n * styling props. The last element is always the \"rest\" containing keys not\n * claimed by any source.\n */\nexport const splitProps: SplitPropsFunction = ((\n props: Record<string, unknown>,\n source1: unknown,\n ...sources: unknown[]\n) => {\n if (Array.isArray(source1)) {\n return splitPropsImpl(source1, false, props, sources);\n }\n if (isRecipeKeySource(source1)) {\n return splitPropsImpl(source1.propKeys, true, props, sources);\n }\n return splitPropsImpl(EMPTY_KEYS, false, props, sources);\n}) as SplitPropsFunction;\n\n/**\n * A pre-built variant. Maps variant value keys (or the literal \"true\"/\"false\"\n * strings for boolean variants) to PrebuiltValue. Includes a \"shorthand\"\n * fallback when the variant is a single class value (treated as `{ true: ... }`).\n */\ninterface PrebuiltVariant {\n // For object variants: map of value -> prebuilt class/style. A Map keeps the\n // lookup keyed by the caller's variant value out of reach of a polluted\n // `Object.prototype`.\n values: Map<string, PrebuiltValue> | null;\n // For shorthand variants: the value to use when selectedValue is true\n shorthand: PrebuiltValue | null;\n // Set of value keys that are disabled (value === null in the original variant\n // definition)\n disabledValues: Set<string> | null;\n}\n\nfunction buildPrebuiltVariant(variantDef: unknown): PrebuiltVariant {\n if (!isRecordObject(variantDef)) {\n return {\n values: null,\n shorthand: extractClassAndStylePrebuilt(variantDef),\n disabledValues: null,\n };\n }\n const values = new Map<string, PrebuiltValue>();\n let disabledValues: Set<string> | null = null;\n for (const key in variantDef) {\n if (!hasOwn(variantDef, key)) continue;\n const value = variantDef[key];\n if (value === null) {\n if (!disabledValues) {\n disabledValues = new Set<string>();\n }\n disabledValues.add(key);\n continue;\n }\n values.set(key, extractClassAndStylePrebuilt(value));\n }\n return {\n values,\n shorthand: null,\n disabledValues,\n };\n}\n\n/**\n * Creates the cv and cx functions.\n */\nexport function create(params: CreateParams = {}) {\n // Destructuring would read an inherited `transformClass`, which a polluted\n // `Object.prototype` could use to rewrite every class string this factory\n // produces, including those of the package-level `cv`.\n const transformClass = getOwn(params, \"transformClass\") ?? identityClass;\n // The production check stays here, so bundlers can fold `debug` to `false`\n // and remove the debug code from production bundles.\n const debug =\n process.env.NODE_ENV !== \"production\" &&\n isDebugEnabled(getOwn(params, \"debug\"));\n\n // The root `cx` type lets consumers emit `typeof cx` for an exported result.\n // Otherwise, emit must name clsx's `ClassValue`, which pnpm installs hide.\n const transformedCx: typeof cx = (...classes) => {\n return transformClass(clsx(classes));\n };\n\n const buildRecipe = <\n V extends Variants = {},\n const E extends AnyRecipe[] = [],\n >(\n config: CVConfig<V, E> = {},\n ): { recipe: Recipe<V, E>; meta: RecipeMeta } => {\n type MergedVariants = MergeVariants<V, E>;\n\n // Compile caller-owned configuration once. Rebuilding a pruned branch\n // reuses these values, including references that rendering already retains.\n const extend = getOwn(config, \"extend\");\n const variants = getOwn(config, \"variants\");\n const refine = getOwn(config, \"refine\");\n const baseStyle = getOwn(config, \"style\");\n const hasBaseStyle = !!baseStyle;\n const baseClassValue = getOwn(config, \"class\");\n const variantKeySet = new Set<string>();\n const inheritedComputedDefaultKeys = new Set<string>();\n const originalExtMetas: RecipeMeta[] = [];\n if (extend) {\n for (const ext of extend) {\n const extKeys = ext.variantKeys as readonly string[];\n for (let i = 0; i < extKeys.length; i++) {\n const key = extKeys[i];\n if (key === undefined) continue;\n variantKeySet.add(key);\n }\n const meta = (ext as AnyRecipe & RecipeWithMeta)[META_KEY];\n if (!meta) continue;\n originalExtMetas.push(meta);\n // A later branch can read a computed default contributed by the first\n // path, even when that shared ancestor is pruned from this branch.\n for (const key of meta.computedDefaultKeys) {\n inheritedComputedDefaultKeys.add(key);\n }\n }\n }\n const initialExtensions =\n originalExtMetas.length > 1\n ? deduplicateExtensions(originalExtMetas)\n : originalExtMetas;\n\n // Keep own default operations separate from inherited values. An explicit\n // undefined must still clear a default when the retained extensions change.\n const ownStaticDefaults: Record<string, unknown> = {};\n const disabledVariantKeys = new Set<string>();\n let disabledValuesBuilder: Record<string, Set<string>> | null = null;\n const variantEntryNames: string[] = [];\n const variantEntryDefs: PrebuiltVariant[] = [];\n const functionVariantNames: string[] = [];\n const functionVariantFns: Array<(value: unknown) => unknown> = [];\n // Own variant definitions by name. `null` stands for a function variant.\n const ownVariantDefs = new Map<string, PrebuiltVariant | null>();\n if (variants) {\n for (const name in variants) {\n if (!hasOwn(variants, name)) continue;\n const variant = (variants as Record<string, unknown>)[name];\n if (variant === null) {\n variantKeySet.delete(name);\n disabledVariantKeys.add(name);\n continue;\n }\n variantKeySet.add(name);\n if (typeof variant === \"function\") {\n functionVariantNames.push(name);\n functionVariantFns.push(variant as (value: unknown) => unknown);\n ownVariantDefs.set(name, null);\n continue;\n }\n const prebuiltVariant = buildPrebuiltVariant(variant);\n ownVariantDefs.set(name, prebuiltVariant);\n variantEntryNames.push(name);\n variantEntryDefs.push(prebuiltVariant);\n if (prebuiltVariant.disabledValues) {\n disabledValuesBuilder ??= {};\n disabledValuesBuilder[name] = prebuiltVariant.disabledValues;\n }\n // Capture this decision before pruning can remove an inherited default.\n if (\n prebuiltVariant.values?.has(\"false\") &&\n !initialExtensions.some((meta) => hasOwn(meta.staticDefaults, name))\n ) {\n ownStaticDefaults[name] = false;\n }\n }\n }\n const definesOwnValue = (key: string, value: unknown): boolean => {\n const variant = ownVariantDefs.get(key);\n if (variant === undefined) return false;\n if (variant === null) return true;\n if (!variant.values) return typeof value === \"boolean\";\n // `false` is a valid value for a variant that only defines `true`.\n if (value === false && variant.values.has(\"true\")) return true;\n const valueKey = getVariantValueKey(value);\n return valueKey != null && variant.values.has(valueKey);\n };\n\n const variantKeys = Array.from(variantKeySet);\n const variantKeysLength = variantKeys.length;\n const variantEntryCount = variantEntryNames.length;\n const functionVariantCount = functionVariantNames.length;\n const hasDisabledVariantKeys = disabledVariantKeys.size > 0;\n const disabledVariantValues = disabledValuesBuilder;\n const hasAnyDisabled =\n hasDisabledVariantKeys || disabledVariantValues !== null;\n const inputPropsKeys = [\"class\", \"className\", \"style\", ...variantKeys];\n\n const computedDefaultNames: string[] = [];\n const computedDefaultFns: ComputedDefaultVariantFn[] = [];\n const defaultVariants = getOwn(config, \"defaultVariants\") as\n | Record<string, unknown>\n | undefined;\n if (defaultVariants) {\n for (const name in defaultVariants) {\n if (!hasOwn(defaultVariants, name)) continue;\n const value = defaultVariants[name];\n if (typeof value === \"function\") {\n computedDefaultNames.push(name);\n computedDefaultFns.push(value as ComputedDefaultVariantFn);\n } else {\n ownStaticDefaults[name] = value;\n }\n }\n }\n const computedDefaultCount = computedDefaultNames.length;\n const baseClass = clsx(baseClassValue as ClsxClassValue);\n const identity = {};\n const canTriggerRefineWarning =\n !!refine ||\n computedDefaultCount > 0 ||\n initialExtensions.some((meta) => meta.resolveRefine);\n const creationFrame =\n canTriggerRefineWarning && process.env.NODE_ENV !== \"production\"\n ? captureCreationFrame(cv)\n : undefined;\n\n // Only extension-dependent state is rebuilt. Own tables, callbacks,\n // inheritance visibility, and the creation frame stay shared and unchanged.\n const build = (\n extMetas: RecipeMeta[],\n ): {\n recipe: Recipe<V, E>;\n meta: RecipeMeta;\n } => {\n const hasExtend = extMetas.length > 0;\n const extCount = extMetas.length;\n const staticDefaults: Record<string, unknown> = {};\n const extBaseClassesArr: string[] = [];\n const extIsolated: boolean[] = [];\n let hasIsolatedExt = false;\n for (const meta of extMetas) {\n Object.assign(staticDefaults, meta.staticDefaults);\n const isolated = meta.transformClass !== transformClass;\n extIsolated.push(isolated);\n if (isolated) {\n hasIsolatedExt = true;\n extBaseClassesArr.push(meta.transformClass(meta.baseClass));\n } else {\n extBaseClassesArr.push(meta.baseClass);\n }\n }\n for (const name in ownStaticDefaults) {\n if (!hasOwn(ownStaticDefaults, name)) continue;\n const value = ownStaticDefaults[name];\n if (value === undefined) {\n delete staticDefaults[name];\n } else {\n staticDefaults[name] = value;\n }\n }\n if (hasAnyDisabled) {\n for (const key in staticDefaults) {\n if (!hasOwn(staticDefaults, key)) continue;\n if (disabledVariantKeys.has(key)) {\n delete staticDefaults[key];\n continue;\n }\n if (disabledVariantValues) {\n const valueKey = getVariantValueKey(staticDefaults[key]);\n if (\n valueKey != null &&\n getOwn(disabledVariantValues, key)?.has(valueKey)\n ) {\n delete staticDefaults[key];\n }\n }\n }\n }\n\n // Count only extends with computed default or refine work in their chain.\n // Those are the recipes that can change resolved variants across\n // fixed-point iterations.\n let extMetasWithRefineCount = 0;\n for (let i = 0; i < extCount; i++) {\n if (extMetas[i].resolveRefine) {\n extMetasWithRefineCount += 1;\n }\n }\n\n // The extends that can change variants for `getVariants`. Built once so\n // that each pass skips the others without reading their metadata.\n const extResolvers = extMetas.map(\n (meta) => getOwn(meta, \"resolveVariants\") ?? meta.resolveRefine,\n );\n const canResolveVariants =\n (hasExtend && hasAnyDisabled) ||\n !!refine ||\n computedDefaultCount > 0 ||\n extResolvers.some(Boolean);\n\n // Only a `refine` callback protects variants, through `setVariants`. This\n // over-approximates: `extMetasWithRefineCount` also counts extends that\n // only have computed defaults. Tightening it would mean tracking `refine`\n // separately in `RecipeMeta` to save one allocation. The record inside\n // the holder is created only when a callback assigns something.\n const canProtectVariants = !!refine || extMetasWithRefineCount > 0;\n\n // `userVariantProps` tells computed defaults which variants the user set\n // explicitly, and `runComputedDefaults` is its only reader anywhere in the\n // chain: a `refine` callback never receives it. `computedDefaultKeys` is\n // transitive, so an empty inherited set proves no extend runs computed\n // defaults either, and nothing reads the record. The record is then the\n // caller's own props object, which no stage may write to.\n const needsUserVariantProps =\n computedDefaultCount > 0 || inheritedComputedDefaultKeys.size > 0;\n\n // Function variant keys inherited from extends, filtered through this\n // recipe's own variants: a static (object/shorthand) variant in this\n // recipe replaces an inherited function variant for the same key.\n // The closure is exposed on `RecipeMeta` so any further extending\n // recipe can detect \"ancestor's effective variant for K is a function\"\n // and skip it when overriding K with a non-function.\n const functionVariantKeys = new Set<string>();\n for (let i = 0; i < extCount; i++) {\n const fnKeys = extMetas[i].functionVariantKeys;\n for (const k of fnKeys) {\n if (disabledVariantKeys.has(k)) continue;\n functionVariantKeys.add(k);\n }\n }\n for (let i = 0; i < functionVariantCount; i++) {\n functionVariantKeys.add(functionVariantNames[i]);\n }\n for (let i = 0; i < variantEntryCount; i++) {\n // A static variant in this recipe replaces an inherited function\n // variant for the same key; from this recipe onward, the key is no\n // longer a function variant.\n functionVariantKeys.delete(variantEntryNames[i]);\n }\n\n const computedDefaultKeys = new Set(inheritedComputedDefaultKeys);\n for (let i = 0; i < computedDefaultCount; i++) {\n computedDefaultKeys.add(computedDefaultNames[i]);\n }\n\n // Pre-compute static skip key/value sets to pass to extends. These never\n // change across calls — when caller passes no skip sets, we reuse the same\n // object and avoid Set allocation.\n let staticExtSkipKeys: Set<string> | null = null;\n if (hasDisabledVariantKeys || functionVariantCount > 0) {\n staticExtSkipKeys = new Set<string>();\n for (const k of disabledVariantKeys) {\n staticExtSkipKeys.add(k);\n }\n for (let i = 0; i < functionVariantCount; i++) {\n staticExtSkipKeys.add(functionVariantNames[i]);\n }\n }\n\n // A static variant in this recipe replaces an inherited function\n // variant, so the ancestor must skip that key.\n if (variantEntryCount > 0 && extCount > 0) {\n for (let i = 0; i < variantEntryCount; i++) {\n const name = variantEntryNames[i];\n for (let j = 0; j < extCount; j++) {\n if (extMetas[j].functionVariantKeys.has(name)) {\n staticExtSkipKeys ??= new Set<string>();\n staticExtSkipKeys.add(name);\n break;\n }\n }\n }\n }\n // Skip values are passed directly to extends. We can reuse the same object\n // when no caller-provided values need merging.\n const staticExtSkipValues = disabledVariantValues;\n\n // Callers use this only when disabled keys or values exist.\n function filterDisabledInto(\n input: Record<string, unknown>,\n out: Record<string, unknown>,\n ): void {\n for (const key in input) {\n if (!hasOwn(input, key)) continue;\n if (disabledVariantKeys.has(key)) continue;\n const value = input[key];\n if (disabledVariantValues) {\n const valueKey = getVariantValueKey(value);\n if (\n valueKey != null &&\n getOwn(disabledVariantValues, key)?.has(valueKey)\n ) {\n continue;\n }\n }\n out[key] = value;\n }\n }\n\n const isOwnDisabledValue = (key: string, value: unknown): boolean => {\n if (disabledVariantKeys.has(key)) {\n return true;\n }\n if (disabledVariantValues) {\n const valueKey = getVariantValueKey(value);\n if (\n valueKey != null &&\n getOwn(disabledVariantValues, key)?.has(valueKey)\n ) {\n return true;\n }\n }\n return false;\n };\n\n const isDisabledValue = (key: string, value: unknown): boolean => {\n if (isOwnDisabledValue(key, value)) return true;\n if (definesOwnValue(key, value)) return false;\n return extMetas.some((meta) =>\n getOwn(meta, \"isDisabledValue\")?.(key, value),\n );\n };\n\n const disabledKeys = new Set(disabledVariantKeys);\n for (const key in disabledVariantValues) {\n if (!hasOwn(disabledVariantValues, key)) continue;\n disabledKeys.add(key);\n }\n // Own keys that an extend may disable, so an extend that doesn't disable\n // anything this recipe defines adds no work to each compute pass.\n const restorableKeys: string[] = [];\n for (const meta of extMetas) {\n const extDisabledKeys = getOwn(meta, \"disabledKeys\");\n if (!extDisabledKeys) continue;\n for (const key of extDisabledKeys) {\n disabledKeys.add(key);\n if (ownVariantDefs.has(key) && !restorableKeys.includes(key)) {\n restorableKeys.push(key);\n }\n }\n }\n\n // An extend removes the values that its chain disables, but this recipe\n // defines some of them again. Its value comes back after the extend runs,\n // so the extend's own callbacks still read the variants that it declares.\n const restoreOwnValues = (\n before: Record<string, unknown>,\n after: Record<string, unknown>,\n extMeta: RecipeMeta,\n fallback: Record<string, unknown>,\n protection: RefineProtection | null | undefined,\n ): Record<string, unknown> => {\n let restored = after;\n for (const key of restorableKeys) {\n const value = getOwn(before, key);\n if (value === undefined) continue;\n if (!definesOwnValue(key, value)) continue;\n if (!getOwn(extMeta, \"isDisabledValue\")?.(key, value)) continue;\n const current = getOwn(after, key);\n // A disabling recipe without extends removes nothing.\n if (Object.is(current, value)) continue;\n // A different protected value comes from a callback, even a clear.\n const protectedVariants = protection?.variants;\n if (\n protectedVariants &&\n hasOwn(protectedVariants, key) &&\n !Object.is(protectedVariants[key], value)\n ) {\n continue;\n }\n // The extend replaces a disabled value with the fallback. Any other\n // value comes from its callbacks.\n if (\n current !== undefined &&\n !Object.is(current, getOwn(fallback, key))\n ) {\n continue;\n }\n if (restored === after) {\n restored = Object.assign({}, after);\n }\n restored[key] = value;\n }\n return restored;\n };\n\n // The frame for each extend lists the keys that computed defaults\n // compute after it runs: those of later extends and this recipe's own.\n const extPendingFrames: Array<PendingFrame | null> = [];\n const laterComputedDefaultKeys = new Set(computedDefaultNames);\n for (let i = extCount - 1; i >= 0; i--) {\n const keys =\n laterComputedDefaultKeys.size > 0\n ? new Set(laterComputedDefaultKeys)\n : null;\n extPendingFrames.unshift(\n keys || hasAnyDisabled\n ? { keys, isDisabled: hasAnyDisabled ? isOwnDisabledValue : null }\n : null,\n );\n for (const key of getActiveComputedDefaultKeys(extMetas[i])) {\n laterComputedDefaultKeys.add(key);\n }\n }\n const activeComputedDefaultKeys = laterComputedDefaultKeys;\n\n const filterOwnDisabledVariants = (\n input: Record<string, unknown>,\n fallback: Record<string, unknown>,\n ): Record<string, unknown> => {\n if (!hasAnyDisabled) {\n return input;\n }\n\n let hasOwnDisabledValue = false;\n for (const key in input) {\n if (!hasOwn(input, key)) continue;\n const value = input[key];\n if (isOwnDisabledValue(key, value)) {\n hasOwnDisabledValue = true;\n break;\n }\n }\n if (!hasOwnDisabledValue) {\n return input;\n }\n\n const filtered: Record<string, unknown> = {};\n for (const key in input) {\n if (!hasOwn(input, key)) continue;\n const value = input[key];\n if (!isOwnDisabledValue(key, value)) {\n filtered[key] = value;\n continue;\n }\n const fallbackValue = getOwn(fallback, key);\n if (\n fallbackValue !== undefined &&\n !isOwnDisabledValue(key, fallbackValue)\n ) {\n filtered[key] = fallbackValue;\n }\n }\n\n return filtered;\n };\n\n // Applies `filterOwnDisabledVariants` to the values that computed defaults\n // keep out of the working variants, so later ones read the same value.\n const filterOwnDisabledChainValues = (\n chainValues: Map<string, unknown>,\n fallback: Record<string, unknown>,\n ): void => {\n if (!hasAnyDisabled) return;\n for (const [key, value] of chainValues) {\n if (!isOwnDisabledValue(key, value)) continue;\n const fallbackValue = getOwn(fallback, key);\n chainValues.set(\n key,\n fallbackValue !== undefined &&\n !isOwnDisabledValue(key, fallbackValue)\n ? fallbackValue\n : undefined,\n );\n }\n };\n\n // Hot path: resolve variants by merging static defaults + extends'\n // static defaults + user-provided props.\n function resolveVariantsHot(\n propsVariants: Record<string, unknown>,\n ): Record<string, unknown> {\n // Start with static defaults\n const defaults = Object.assign({}, staticDefaults);\n\n // Apply propsVariants on top (filter undefined).\n for (let i = 0; i < variantKeysLength; i++) {\n const k = variantKeys[i];\n if (!hasOwn(propsVariants, k)) continue;\n const v = propsVariants[k];\n if (v === undefined) continue;\n defaults[k] = v;\n }\n\n if (!hasAnyDisabled) {\n return defaults;\n }\n\n // Filter disabled\n const result: Record<string, unknown> = {};\n filterDisabledInto(defaults, result);\n return result;\n }\n\n const runComputedDefaults = (\n resolved: Record<string, unknown>,\n defaultResolved: Record<string, unknown>,\n userVariantProps: Record<string, unknown>,\n filterOwnVariants: boolean,\n protection: RefineProtection | null | undefined,\n pass: RefinePass | null | undefined,\n ): Record<string, unknown> => {\n const protectedVariants = protection?.variants;\n let ownVariants = filterOwnVariants ? null : resolved;\n const getOwnVariants = (): Record<string, unknown> => {\n if (ownVariants) {\n return ownVariants;\n }\n const filteredVariants: Record<string, unknown> = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (hasOwn(resolved, key)) {\n filteredVariants[key] = resolved[key];\n }\n }\n ownVariants = filteredVariants;\n return filteredVariants;\n };\n\n let updatedVariants: Record<string, unknown> | null = null;\n const ensureUpdated = (): Record<string, unknown> => {\n if (updatedVariants) {\n return updatedVariants;\n }\n const updated = Object.assign({}, resolved);\n updatedVariants = updated;\n return updated;\n };\n\n for (let i = 0; i < computedDefaultCount; i++) {\n const key = computedDefaultNames[i];\n if (hasOwn(userVariantProps, key)) {\n if (userVariantProps[key] !== undefined) continue;\n }\n if (protectedVariants && hasOwn(protectedVariants, key)) continue;\n\n const variantSnapshot = getOwnVariants();\n const currentValue = getOwn(variantSnapshot, key);\n // An earlier computed default may have kept its value for this key\n // out of the working variants. This one still reads that value as the\n // one it replaces, through `defaultValue` and through its own key.\n const chainValues = pass?.chainValues;\n const latestValue =\n chainValues && chainValues.has(key)\n ? chainValues.get(key)\n : currentValue;\n const defaultValue = inheritedComputedDefaultKeys.has(key)\n ? latestValue\n : getOwn(defaultResolved, key);\n let value = computedDefaultFns[i](\n defaultValue,\n Object.is(latestValue, currentValue)\n ? variantSnapshot\n : withVariant(variantSnapshot, key, latestValue),\n );\n if (hasAnyDisabled && isOwnDisabledValue(key, value)) {\n // The latest value stays, as if this computed default didn't run.\n // When no later one computes the key, it becomes the final value.\n if (Object.is(latestValue, currentValue)) continue;\n if (pass && isPendingKey(pass.frames, key)) continue;\n value = latestValue;\n } else if (pass) {\n if (Object.is(value, currentValue)) {\n chainValues?.delete(key);\n continue;\n }\n if (\n isPendingKey(pass.frames, key) &&\n !isDisabledOnPath(pass.frames, key, value)\n ) {\n pass.chainValues ??= new Map();\n pass.chainValues.set(key, value);\n continue;\n }\n }\n // The working variants receive this value, so a value that an\n // earlier computed default kept out of them no longer applies.\n chainValues?.delete(key);\n\n if (value === undefined) {\n if (!hasOwn(variantSnapshot, key)) continue;\n delete ensureUpdated()[key];\n continue;\n }\n if (Object.is(currentValue, value)) continue;\n ensureUpdated()[key] = value;\n }\n\n return updatedVariants ?? resolved;\n };\n\n const runRefineContext = (\n resolved: Record<string, unknown>,\n filterOwnVariants: boolean,\n collectOutput: boolean,\n applyVariantUpdates: boolean,\n protection: RefineProtection | null | undefined,\n ): {\n workingResolved: Record<string, unknown>;\n classes: ClassValue[] | null;\n style: StyleValue | null;\n } => {\n let workingResolved = resolved;\n let cClasses: ClassValue[] | null = null;\n let cStyle: StyleValue | null = null;\n\n if (refine) {\n let ownVariants = resolved;\n if (filterOwnVariants) {\n // When this recipe is being extended, `resolved` is the parent's\n // workingResolved (a superset of our variant keys). Filter to our own\n // keys for `ctx.variants` so the user's `refine` callback sees the\n // shape declared by `VariantValues<V>` and not foreign parent keys.\n const filteredVariants: Record<string, unknown> = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const k = variantKeys[i];\n if (hasOwn(resolved, k)) {\n filteredVariants[k] = resolved[k];\n }\n }\n ownVariants = filteredVariants;\n }\n // `assignedVariants`, `localCClasses` and `localCStyle` are created on\n // first use, so a callback that only inspects `variants` allocates\n // none of them. The `setVariants` bookkeeping is inlined for the same\n // reason: helper closures would be allocated on every call, including\n // the calls that never assign anything.\n // `assignedVariants` holds only the changed keys, because copying all\n // of `ownVariants` into it would repeat values `workingResolved` has.\n let assignedVariants: Record<string, unknown> | null = null;\n let localCClasses: ClassValue[] | null = null;\n let localCStyle: StyleValue | null = null;\n const ctx = {\n variants: ownVariants as VariantValues<Record<string, unknown>>,\n setVariants: (\n newVariants: VariantValues<Record<string, unknown>>,\n ) => {\n if (!applyVariantUpdates) {\n return;\n }\n for (const key in newVariants) {\n if (!hasOwn(newVariants, key)) continue;\n // `disabledVariantKeys` is empty unless this recipe disables a\n // variant, so the lookup replaces a `hasAnyDisabled` branch. The\n // key is checked before the value is read, because reading it can\n // run a caller-defined accessor.\n if (disabledVariantKeys.has(key)) continue;\n const value = (newVariants as Record<string, unknown>)[key];\n if (disabledVariantValues) {\n const valueKey = getVariantValueKey(value);\n if (\n valueKey != null &&\n getOwn(disabledVariantValues, key)?.has(valueKey)\n ) {\n continue;\n }\n }\n if (protection) {\n const protectedVariants = (protection.variants ??= {});\n protectedVariants[key] = value;\n }\n // The record holds only assigned keys, so both halves matter: a\n // key it owns can hold a clear that `??` on the value would\n // discard, and a key it does not own must fall back to\n // `ownVariants`, or a clear compares against `undefined`.\n const current =\n assignedVariants && hasOwn(assignedVariants, key)\n ? assignedVariants[key]\n : getOwn(ownVariants, key);\n if (Object.is(current, value)) {\n continue;\n }\n assignedVariants ??= {};\n assignedVariants[key] = value;\n }\n },\n addClass: (className: ClassValue) => {\n if (!collectOutput) return;\n localCClasses ??= [];\n localCClasses.push(className);\n },\n addStyle: (newStyle: StyleValue) => {\n if (!collectOutput) return;\n localCStyle ??= {};\n Object.assign(localCStyle, newStyle);\n },\n };\n const result = refine(ctx);\n if (collectOutput && result != null) {\n const r = extractClassAndStylePrebuilt(result);\n if (r.class != null) {\n localCClasses ??= [];\n localCClasses.push(r.class);\n }\n if (r.style) {\n localCStyle ??= {};\n Object.assign(localCStyle, r.style);\n }\n }\n cClasses = localCClasses;\n cStyle = localCStyle;\n if (assignedVariants) {\n // No disabled filtering here: `setVariants` drops a disabled key or\n // value before it records one, so every assigned key already passed\n // the same two checks.\n workingResolved = Object.assign(\n {},\n workingResolved,\n assignedVariants,\n );\n }\n }\n\n return {\n workingResolved,\n classes: cClasses,\n style: cStyle,\n };\n };\n\n // Core compute path. Called both for top-level rendering (via\n // `computeResult`) and recursively when this recipe is used as an\n // `extend` target by another recipe. Pushes variant classes (excluding\n // base class) into `classesOut` and merges styles into `styleOut`.\n const computeOnce: ComputeOnceFn = (\n resolved,\n userVariantProps,\n skipKeys,\n skipValues,\n classesOut,\n styleOut,\n protection,\n defaultResolved = resolved,\n renderOnly = false,\n pass,\n ) => {\n let workingResolved = resolved;\n let cClasses: ClassValue[] | null = null;\n let cStyle: StyleValue | null = null;\n\n // Run extends' contributions first (their full classes + styles) so our\n // own base style and variants apply on top, matching the original\n // ext1 → ext2 → … → current ordering.\n if (hasExtend) {\n // Build skip sets to pass to extends. Reuse precomputed values when no\n // caller-provided sets need merging.\n let extSkipKeys: Set<string> | null;\n if (skipKeys === null) {\n extSkipKeys = staticExtSkipKeys;\n } else if (staticExtSkipKeys === null) {\n extSkipKeys = skipKeys;\n } else {\n extSkipKeys = new Set(skipKeys);\n for (const k of staticExtSkipKeys) {\n extSkipKeys.add(k);\n }\n }\n\n let extSkipVals: Record<string, Set<string>> | null;\n if (skipValues === null) {\n extSkipVals = staticExtSkipValues;\n } else if (staticExtSkipValues === null) {\n extSkipVals = skipValues;\n } else {\n extSkipVals = {};\n for (const k in skipValues) {\n if (!hasOwn(skipValues, k)) continue;\n extSkipVals[k] = skipValues[k];\n }\n for (const k in staticExtSkipValues) {\n if (!hasOwn(staticExtSkipValues, k)) continue;\n const values = staticExtSkipValues[k];\n const existing = getOwn(extSkipVals, k);\n if (existing) {\n const merged = new Set<string>(existing);\n for (const v of values) {\n merged.add(v);\n }\n extSkipVals[k] = merged;\n } else {\n extSkipVals[k] = values;\n }\n }\n }\n\n for (let i = 0; i < extCount; i++) {\n const pendingFrame = pass ? extPendingFrames[i] : null;\n if (pass && pendingFrame) {\n pass.frames.push(pendingFrame);\n }\n const beforeExtend = workingResolved;\n if (hasIsolatedExt && extIsolated[i]) {\n // Isolated extend (different factory): gather its variant classes\n // into a scratch array, then push the joined string after applying\n // its own transformClass. Our outer transform applies on top.\n const extClasses: ClsxClassValue[] = [];\n workingResolved = extMetas[i].compute(\n workingResolved,\n userVariantProps,\n extSkipKeys,\n extSkipVals,\n extClasses,\n styleOut,\n protection,\n defaultResolved,\n renderOnly,\n pass,\n );\n if (extClasses.length > 0) {\n const joined = clsx(extClasses);\n if (joined.length > 0) {\n classesOut.push(extMetas[i].transformClass(joined));\n }\n }\n } else {\n workingResolved = extMetas[i].compute(\n workingResolved,\n userVariantProps,\n extSkipKeys,\n extSkipVals,\n classesOut,\n styleOut,\n protection,\n defaultResolved,\n renderOnly,\n pass,\n );\n }\n if (pass && pendingFrame) {\n pass.frames.pop();\n }\n if (restorableKeys.length > 0) {\n workingResolved = restoreOwnValues(\n beforeExtend,\n workingResolved,\n extMetas[i],\n defaultResolved,\n protection,\n );\n }\n workingResolved = filterOwnDisabledVariants(\n workingResolved,\n defaultResolved,\n );\n if (pass?.chainValues) {\n filterOwnDisabledChainValues(pass.chainValues, defaultResolved);\n }\n }\n }\n\n // Run own computed defaults after extended recipes so defaults resolve\n // from base to child. They still run before this recipe's `refine`.\n if (!renderOnly && computedDefaultCount > 0) {\n workingResolved = runComputedDefaults(\n workingResolved,\n defaultResolved,\n userVariantProps,\n true,\n protection,\n pass,\n );\n }\n\n // Run own `refine` (if any). May modify resolved variants and emit\n // classes and styles that are applied after this recipe's variants.\n if (refine) {\n const refineResult = runRefineContext(\n workingResolved,\n true,\n true,\n !renderOnly,\n protection,\n );\n workingResolved = refineResult.workingResolved;\n cClasses = refineResult.classes;\n cStyle = refineResult.style;\n }\n\n // Apply own base style (after extends' styles, matching original order).\n if (hasBaseStyle) {\n Object.assign(styleOut, baseStyle);\n }\n\n // Apply own variants. Skip keys/values come from caller (e.g., parent\n // wants its own function variant to override this variant).\n // `variantEntryNames` already excludes disabled keys (those with `null`\n // value in config) and function variants, so we don't re-check\n // `disabledVariantKeys` here.\n const ownSkipKeys = skipKeys;\n const ownSkipValues = skipValues;\n for (let i = 0; i < variantEntryCount; i++) {\n const variantName = variantEntryNames[i];\n if (ownSkipKeys && ownSkipKeys.has(variantName)) continue;\n // Read first: an inherited value that could change the output is\n // never `undefined`, so the own-property check only runs for the\n // variants that carry a value.\n const selectedValue = workingResolved[variantName];\n if (selectedValue === undefined) continue;\n if (!hasOwn(workingResolved, variantName)) continue;\n const selectedKey = getVariantValueKey(selectedValue);\n const variant = variantEntryDefs[i];\n if (\n variant.disabledValues &&\n selectedKey != null &&\n variant.disabledValues.has(selectedKey)\n ) {\n continue;\n }\n if (\n ownSkipValues &&\n selectedKey != null &&\n getOwn(ownSkipValues, variantName)?.has(selectedKey)\n ) {\n continue;\n }\n\n let value: PrebuiltValue | null | undefined;\n if (variant.values) {\n if (selectedKey == null) continue;\n value = variant.values.get(selectedKey);\n } else if (selectedValue === true) {\n value = variant.shorthand;\n }\n if (!value) continue;\n if (value.class != null) {\n classesOut.push(value.class);\n }\n if (value.style) {\n Object.assign(styleOut, value.style);\n }\n }\n\n // Apply function variants — entries in `variants` whose value is a\n // function. They run after static variants and override any same-key\n // inherited variant via `staticExtSkipKeys`.\n for (let i = 0; i < functionVariantCount; i++) {\n const variantName = functionVariantNames[i];\n if (ownSkipKeys && ownSkipKeys.has(variantName)) continue;\n const selectedValue = workingResolved[variantName];\n if (selectedValue === undefined) continue;\n if (!hasOwn(workingResolved, variantName)) continue;\n const selectedKey = getVariantValueKey(selectedValue);\n if (\n ownSkipValues &&\n selectedKey != null &&\n getOwn(ownSkipValues, variantName)?.has(selectedKey)\n ) {\n continue;\n }\n const fn = functionVariantFns[i];\n const computedResult = fn(selectedValue);\n if (computedResult == null) continue;\n const r = extractClassAndStylePrebuilt(computedResult);\n if (r.class != null) {\n classesOut.push(r.class);\n }\n if (r.style) {\n Object.assign(styleOut, r.style);\n }\n }\n\n // Apply `refine` results — must come after own variants (static and\n // function).\n if (cClasses) {\n for (let i = 0; i < cClasses.length; i++) {\n classesOut.push(cClasses[i] as ClsxClassValue);\n }\n }\n if (cStyle) {\n Object.assign(styleOut, cStyle);\n }\n\n return workingResolved;\n };\n\n const compute: ComputeFn =\n !refine && computedDefaultCount === 0 && extMetasWithRefineCount === 0\n ? computeOnce\n : (\n resolved,\n userVariantProps,\n skipKeys,\n skipValues,\n classesOut,\n styleOut,\n ) => {\n let remaining = MAX_REFINE_RUNS;\n const protection: RefineProtection | null = canProtectVariants\n ? { variants: null }\n : null;\n const incomingDefaultResolved = resolved;\n let workingResolved = resolved;\n // Latest variant changes from non-converging iterations inside the\n // tracking window. Lazy-init keeps convergent loops allocation-free.\n let unstableChanges: Map<string, VariantChange> | null = null;\n let lastClasses: ClsxClassValue[] = [];\n let lastStyle: StyleValue = {};\n let isFirstRun = true;\n let pass: RefinePass | null = null;\n\n while (remaining > 0) {\n remaining -= 1;\n const useDirectOutput = isFirstRun;\n const classCount = classesOut.length;\n const nextClasses: ClsxClassValue[] = useDirectOutput\n ? classesOut\n : [];\n const nextStyle: StyleValue = useDirectOutput ? styleOut : {};\n const defaultResolved = mergeProtectedIntoBase(\n incomingDefaultResolved,\n protection,\n );\n if (!isFirstRun) {\n pass ??= { frames: [], chainValues: null };\n pass.chainValues?.clear();\n }\n const nextResolved = computeOnce(\n workingResolved,\n userVariantProps,\n skipKeys,\n skipValues,\n nextClasses,\n nextStyle,\n protection,\n defaultResolved,\n false,\n pass,\n );\n\n // No pass has settled before the first one, so it reads the\n // latest values. It settles only when it changed nothing,\n // because a later computed default may replace a value it read.\n if (\n nextResolved === workingResolved ||\n (!isFirstRun &&\n areVariantsEqual(workingResolved, nextResolved))\n ) {\n if (nextResolved !== workingResolved) {\n computeOnce(\n nextResolved,\n userVariantProps,\n skipKeys,\n skipValues,\n classesOut,\n styleOut,\n protection,\n defaultResolved,\n true,\n );\n } else if (!useDirectOutput) {\n for (let i = 0; i < nextClasses.length; i++) {\n classesOut.push(nextClasses[i]);\n }\n Object.assign(styleOut, nextStyle);\n }\n return nextResolved;\n }\n\n // `remaining` is checked first: `process.env.NODE_ENV` is an\n // environment lookup in Node, not a property load, and only the\n // last `REFINE_UNSTABLE_TRACKING_WINDOW` passes need it. Bundlers\n // still inline it and drop the block.\n if (\n remaining < REFINE_UNSTABLE_TRACKING_WINDOW &&\n process.env.NODE_ENV !== \"production\"\n ) {\n if (!unstableChanges) {\n unstableChanges = new Map<string, VariantChange>();\n }\n accumulateUnstableVariantChanges(\n unstableChanges,\n workingResolved,\n nextResolved,\n );\n }\n\n if (useDirectOutput) {\n classesOut.length = classCount;\n for (const key in styleOut) {\n if (hasOwn(styleOut, key)) {\n Reflect.deleteProperty(styleOut, key);\n }\n }\n } else {\n lastClasses = nextClasses;\n lastStyle = nextStyle;\n }\n\n workingResolved = nextResolved;\n isFirstRun = false;\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n warnRefineLimit({\n creationFrame,\n unstableChanges,\n });\n }\n\n for (let i = 0; i < lastClasses.length; i++) {\n classesOut.push(lastClasses[i]);\n }\n Object.assign(styleOut, lastStyle);\n return workingResolved;\n };\n\n const resolveRefineOnce: ResolveRefineOnceFn = (\n resolved,\n userVariantProps,\n filterOwnVariants = true,\n protection,\n defaultResolved = resolved,\n pass,\n renderOnly = false,\n ) => {\n let workingResolved = resolved;\n\n // Visit every extend, as `computeOnce` does, so that disabled values are\n // removed at the same points. A later extend's callbacks can read them.\n for (let i = 0; i < extCount; i++) {\n const resolveExtend = extResolvers[i];\n const beforeExtend = workingResolved;\n if (resolveExtend) {\n const pendingFrame = pass ? extPendingFrames[i] : null;\n if (pass && pendingFrame) {\n pass.frames.push(pendingFrame);\n }\n workingResolved = resolveExtend(\n workingResolved,\n userVariantProps,\n true,\n protection,\n defaultResolved,\n pass,\n renderOnly,\n );\n if (pass && pendingFrame) {\n pass.frames.pop();\n }\n if (restorableKeys.length > 0) {\n workingResolved = restoreOwnValues(\n beforeExtend,\n workingResolved,\n extMetas[i],\n defaultResolved,\n protection,\n );\n }\n }\n workingResolved = filterOwnDisabledVariants(\n workingResolved,\n defaultResolved,\n );\n if (pass?.chainValues) {\n filterOwnDisabledChainValues(pass.chainValues, defaultResolved);\n }\n }\n\n if (renderOnly) return workingResolved;\n\n if (computedDefaultCount > 0) {\n workingResolved = runComputedDefaults(\n workingResolved,\n defaultResolved,\n userVariantProps,\n filterOwnVariants,\n protection,\n pass,\n );\n }\n if (refine) {\n const refineResult = runRefineContext(\n workingResolved,\n filterOwnVariants,\n false,\n true,\n protection,\n );\n workingResolved = refineResult.workingResolved;\n }\n\n return workingResolved;\n };\n\n const resolveRefine: ResolveRefineFn | null =\n refine || computedDefaultCount > 0 || extMetasWithRefineCount > 0\n ? (resolved, userVariantProps, filterOwnVariants = true) => {\n let remaining = MAX_REFINE_RUNS;\n const protection: RefineProtection | null = canProtectVariants\n ? { variants: null }\n : null;\n const incomingDefaultResolved = resolved;\n let workingResolved = resolved;\n // Latest variant changes from non-converging iterations inside the\n // tracking window. See the compute loop above for the shared\n // rationale.\n let unstableChanges: Map<string, VariantChange> | null = null;\n let pass: RefinePass | null = null;\n\n while (remaining > 0) {\n remaining -= 1;\n const defaultResolved = mergeProtectedIntoBase(\n incomingDefaultResolved,\n protection,\n );\n const nextResolved = resolveRefineOnce(\n workingResolved,\n userVariantProps,\n filterOwnVariants,\n protection,\n defaultResolved,\n pass,\n );\n\n // The first pass settles only when it changed nothing, for the\n // reason given in the compute loop above.\n if (nextResolved === workingResolved) {\n return nextResolved;\n }\n if (pass && areVariantsEqual(workingResolved, nextResolved)) {\n // Match the final pass of the compute loop above, which\n // removes a disabled value that a callback set after the\n // extend that disables it.\n return resolveRefineOnce(\n nextResolved,\n userVariantProps,\n filterOwnVariants,\n protection,\n defaultResolved,\n null,\n true,\n );\n }\n\n // `remaining` is checked first for the reason given in the\n // compute loop above.\n if (\n remaining < REFINE_UNSTABLE_TRACKING_WINDOW &&\n process.env.NODE_ENV !== \"production\"\n ) {\n if (!unstableChanges) {\n unstableChanges = new Map<string, VariantChange>();\n }\n accumulateUnstableVariantChanges(\n unstableChanges,\n workingResolved,\n nextResolved,\n );\n }\n workingResolved = nextResolved;\n pass ??= { frames: [], chainValues: null };\n pass.chainValues?.clear();\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n warnRefineLimit({\n creationFrame,\n unstableChanges,\n });\n }\n\n return workingResolved;\n }\n : null;\n\n // Top-level: resolves variants from user props, calls compute, then\n // assembles className and style with user-provided class/style overrides.\n const computeResult = (\n props: RecipeProps<MergedVariants> = EMPTY_DEFAULTS as RecipeProps<MergedVariants>,\n ): {\n className: string;\n style: StyleValue;\n variants: Record<string, unknown>;\n } => {\n const propsRecord = props as Record<string, unknown>;\n\n let resolved: Record<string, unknown> = {};\n Object.assign(resolved, staticDefaults);\n\n let userVariantProps: Record<string, unknown>;\n if (needsUserVariantProps) {\n const variantProps: Record<string, unknown> = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (!hasOwn(propsRecord, key)) continue;\n const value = propsRecord[key];\n variantProps[key] = value;\n if (value === undefined) continue;\n resolved[key] = value;\n }\n userVariantProps = variantProps;\n } else {\n // Fast path: walk variantKeys directly against propsRecord.\n // Own-property checks ensure a polluted Object.prototype can't add\n // values the user didn't pass.\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (!hasOwn(propsRecord, key)) continue;\n const v = propsRecord[key];\n if (v === undefined) continue;\n resolved[key] = v;\n }\n userVariantProps = propsRecord;\n }\n\n if (hasAnyDisabled) {\n const filtered: Record<string, unknown> = {};\n filterDisabledInto(resolved, filtered);\n resolved = filtered;\n }\n\n // Build allClasses directly. computedBaseClass already has all extend\n // bases joined with config.class — `compute` only adds variant classes\n // on top.\n const allClasses: ClsxClassValue[] = [computedBaseClass];\n const style: StyleValue = {};\n const variants = compute(\n resolved,\n userVariantProps,\n null,\n null,\n allClasses,\n style,\n );\n\n // Apply user-provided class / className. Own-property checks keep these\n // consistent with the variant props read above: only what the caller\n // passed is applied, never a key inherited from Object.prototype.\n if (hasOwn(propsRecord, \"class\")) {\n allClasses.push(propsRecord.class as ClsxClassValue);\n }\n if (hasOwn(propsRecord, \"className\")) {\n allClasses.push(propsRecord.className as ClsxClassValue);\n }\n\n // Apply user-provided style, read before the own-property check for the\n // same reason as the variant loops above.\n const psv = propsRecord.style;\n if (psv != null && hasOwn(propsRecord, \"style\")) {\n if (typeof psv === \"string\") {\n if (psv.length > 0) {\n htmlStyleToStyleValue(psv, style);\n }\n } else if (typeof psv === \"object\") {\n htmlObjStyleToStyleValue(psv, style);\n }\n }\n\n return {\n className: transformClass(clsx(allClasses)),\n style,\n variants,\n };\n };\n\n // Adds the debug attribute to a mode result. Call only when `debug` is\n // true.\n const setDebugAttribute = (\n result: Record<string, unknown>,\n props: RecipeProps<MergedVariants>,\n variants: Record<string, unknown>,\n ) => {\n result[DEBUG_ATTRIBUTE] = formatDebugAttribute({\n variantKeys,\n variants,\n incoming: getOwn(props as Record<string, unknown>, DEBUG_ATTRIBUTE),\n });\n };\n\n const getVariants = (variants?: VariantValues<MergedVariants>) => {\n const variantsRecord = variants ?? EMPTY_DEFAULTS;\n let variantProps = variantsRecord;\n // Copy to the declared variant keys, so the computed defaults that read\n // this record cannot see an undeclared key as an explicitly passed\n // variant, and cannot re-run a caller accessor once per refine pass. The\n // gate is narrower than that purpose: it misses a chain whose only\n // computed default is this recipe's own.\n // See https://github.com/ariakit/clava/issues/494\n if (variants && extMetasWithRefineCount > 0) {\n variantProps = {};\n for (let i = 0; i < variantKeysLength; i++) {\n const key = variantKeys[i];\n if (hasOwn(variantsRecord, key)) {\n variantProps[key] = variantsRecord[key];\n }\n }\n }\n let resolvedVariants = resolveVariantsHot(variantProps);\n if (resolveRefine) {\n resolvedVariants = resolveRefine(\n resolvedVariants,\n variantProps,\n false,\n );\n } else if (canResolveVariants) {\n // No callback in this chain can restore a removed value, so one pass\n // reaches the state that render ends with.\n resolvedVariants = resolveRefineOnce(resolvedVariants, variantProps);\n }\n return resolvedVariants as VariantValues<MergedVariants>;\n };\n\n // Compute base class (without variants) — includes extended base classes.\n // Plain `clsx` (no `transformClass`): `meta.baseClass` flows back into\n // parent extends as `clsx` input and then through the single\n // `transformClass(clsx(allClasses))` at render time, so applying it here\n // would compound (double for own-render, triple+ for extend chains) and\n // misbehave for non-idempotent transforms.\n const computedBaseClass = hasExtend\n ? clsx(extBaseClassesArr, baseClass)\n : baseClass;\n\n // Shared closures across the default and modal recipes.\n const classFn = (props: RecipeProps<MergedVariants> = {}) => {\n return computeResult(props).className;\n };\n const meta: RecipeMeta = {\n identity,\n extends: extMetas,\n rebuild: (extensions) => build(extensions).meta,\n baseClass: computedBaseClass,\n staticDefaults,\n compute: computeOnce,\n resolveRefine: resolveRefine ? resolveRefineOnce : null,\n resolveVariants: canResolveVariants ? resolveRefineOnce : undefined,\n transformClass,\n functionVariantKeys,\n computedDefaultKeys,\n activeComputedDefaultKeys,\n disabledKeys,\n isDisabledValue,\n };\n\n const initRecipe = <\n R extends RecipeResult,\n T extends ModalRecipe<MergedVariants, R>,\n >(\n recipe: T,\n propKeys: string[],\n style: T[\"style\"],\n ): T => {\n recipe.class = classFn;\n recipe.style = style;\n recipe.getVariants = getVariants;\n recipe.variantKeys = variantKeys;\n recipe.propKeys = propKeys;\n (recipe as AnyRecipe & RecipeWithMeta)[META_KEY] = meta;\n return recipe;\n };\n\n // Default recipe\n const defaultRecipe = ((props: RecipeProps<MergedVariants> = {}) => {\n const { className, style, variants } = computeResult(props);\n const result = { class: className, style };\n if (debug) {\n setDebugAttribute(result, props, variants);\n }\n return result;\n }) as Recipe<V, E>;\n initRecipe(defaultRecipe, inputPropsKeys, (props = {}) => {\n return computeResult(props).style;\n });\n\n // JSX recipe\n const jsxRecipe = ((props: RecipeProps<MergedVariants> = {}) => {\n const { className, style, variants } = computeResult(props);\n const result = { className, style };\n if (debug) {\n setDebugAttribute(result, props, variants);\n }\n return result;\n }) as ModalRecipe<MergedVariants, JSXProps>;\n initRecipe(\n jsxRecipe,\n [\"className\", \"style\", ...variantKeys],\n (props = {}) => computeResult(props).style,\n );\n\n // HTML recipe\n const htmlRecipe = ((props: RecipeProps<MergedVariants> = {}) => {\n const { className, style, variants } = computeResult(props);\n const result = {\n class: className,\n style: styleValueToHTMLStyle(style),\n };\n if (debug) {\n setDebugAttribute(result, props, variants);\n }\n return result;\n }) as ModalRecipe<MergedVariants, HTMLProps>;\n initRecipe(htmlRecipe, [\"class\", \"style\", ...variantKeys], (props = {}) =>\n styleValueToHTMLStyle(computeResult(props).style),\n );\n\n // HTMLObj recipe\n const htmlObjRecipe = ((props: RecipeProps<MergedVariants> = {}) => {\n const { className, style, variants } = computeResult(props);\n const result = {\n class: className,\n style: styleValueToHTMLObjStyle(style),\n };\n if (debug) {\n setDebugAttribute(result, props, variants);\n }\n return result;\n }) as ModalRecipe<MergedVariants, HTMLObjProps>;\n initRecipe(\n htmlObjRecipe,\n [\"class\", \"style\", ...variantKeys],\n (props = {}) => styleValueToHTMLObjStyle(computeResult(props).style),\n );\n\n defaultRecipe.jsx = jsxRecipe;\n defaultRecipe.html = htmlRecipe;\n defaultRecipe.htmlObj = htmlObjRecipe;\n\n return { recipe: defaultRecipe, meta };\n };\n return build(initialExtensions);\n };\n\n const cv = <V extends Variants = {}, const E extends AnyRecipe[] = []>(\n config: CVConfig<V, E> = {},\n ): InferredRecipe<V, E> => buildRecipe(config).recipe;\n\n return { cv, cx: transformedCx };\n}\n\nexport const cv = /* @__PURE__ */ (() => create().cv)();\n\n/**\n * Joins class values without applying a class transform.\n *\n * This behaves like the `cx` function returned by `create()` with no options.\n */\nexport function cx(...classes: ClsxClassValue[]) {\n return clsx(classes);\n}\n"],"mappings":";;AAEA,MAAa,SAAS,OAAO;AAQ7B,SAAgB,OACd,QACA,KACkB;CAClB,IAAI,CAAC,OAAO,QAAQ,GAAG,GAAG,OAAO,KAAA;CACjC,OAAO,OAAO;AAChB;AAIA,MAAM,2CAA2B,IAAI,IAAI;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;C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@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clava",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Clava library",
5
5
  "keywords": [
6
6
  "class variance",
@@ -49,14 +49,14 @@
49
49
  "devDependencies": {
50
50
  "@types/node": "26.6.6",
51
51
  "@types/react": "19.3.0",
52
- "rolldown": "1.2.15",
53
- "rolldown-plugin-dts": "0.28.8",
52
+ "rolldown": "1.3.0",
53
+ "rolldown-plugin-dts": "0.30.0",
54
54
  "scripts": "0.0.0",
55
- "solid-js": "1.9.17",
55
+ "solid-js": "1.9.18",
56
56
  "test-utils": "0.0.0",
57
57
  "typescript": "npm:@typescript/typescript6@6.0.2",
58
- "vite": "8.3.5",
59
- "vitest": "5.0.5"
58
+ "vite": "8.3.6",
59
+ "vitest": "5.1.0"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "rolldown -c",
package/src/debug.ts ADDED
@@ -0,0 +1,64 @@
1
+ import { hasOwn } from "./utils.ts";
2
+
3
+ /**
4
+ * The attribute that recipes add in development to show the resolved variants
5
+ * that produced an element.
6
+ */
7
+ export const DEBUG_ATTRIBUTE = "data-clava-debug";
8
+
9
+ /**
10
+ * Returns whether recipes created by a factory outside production add the
11
+ * debug attribute. The `debug` option wins. The default adds it only in
12
+ * development, so test snapshots don't change.
13
+ */
14
+ export function isDebugEnabled(option: boolean | undefined): boolean {
15
+ return option ?? process.env.NODE_ENV === "development";
16
+ }
17
+
18
+ function formatDebugValue(value: unknown): string {
19
+ if (typeof value === "string") {
20
+ // Single quotes keep the value readable in HTML, where attribute values
21
+ // are shown in double quotes.
22
+ return `'${value.replaceAll("\\", "\\\\").replaceAll("'", "\\'")}'`;
23
+ }
24
+ if (typeof value === "bigint") return `${value}n`;
25
+ if (typeof value === "function") return "{...}";
26
+ if (typeof value === "object" && value != null) return "{...}";
27
+ return String(value);
28
+ }
29
+
30
+ interface FormatDebugAttributeParams {
31
+ variantKeys: readonly string[];
32
+ variants: Record<string, unknown>;
33
+ incoming: unknown;
34
+ }
35
+
36
+ /**
37
+ * Formats a recipe's resolved variants as space-separated `key=value` pairs in
38
+ * the recipe's variant key order. A debug value that another recipe passed as
39
+ * a prop is appended, so the variants of the recipe that renders the element
40
+ * come first.
41
+ *
42
+ * The value has no source location. Server stacks can be source-mapped or
43
+ * name other files than browser stacks, such as Turbopack chunks, and a
44
+ * different value would cause hydration mismatches.
45
+ */
46
+ export function formatDebugAttribute({
47
+ variantKeys,
48
+ variants,
49
+ incoming,
50
+ }: FormatDebugAttributeParams): string {
51
+ const parts: string[] = [];
52
+ for (let i = 0; i < variantKeys.length; i++) {
53
+ const key = variantKeys[i];
54
+ if (key === undefined) continue;
55
+ if (!hasOwn(variants, key)) continue;
56
+ const value = variants[key];
57
+ if (value === undefined) continue;
58
+ parts.push(`${key}=${formatDebugValue(value)}`);
59
+ }
60
+ if (typeof incoming === "string" && incoming) {
61
+ parts.push(incoming);
62
+ }
63
+ return parts.join(" ");
64
+ }
package/src/index.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  import clsx, { type ClassValue as ClsxClassValue } from "clsx";
2
+ import {
3
+ DEBUG_ATTRIBUTE,
4
+ formatDebugAttribute,
5
+ isDebugEnabled,
6
+ } from "./debug.ts";
2
7
  import {
3
8
  REFINE_UNSTABLE_TRACKING_WINDOW,
4
9
  type VariantChange,
@@ -457,6 +462,12 @@ export interface CVConfig<V extends Variants = {}, E extends AnyRecipe[] = []> {
457
462
 
458
463
  interface CreateParams {
459
464
  transformClass?: (className: string) => string;
465
+ /**
466
+ * Whether recipes add a `data-clava-debug` attribute that lists their
467
+ * resolved variants. Defaults to `true` when `NODE_ENV` is
468
+ * `"development"`. The attribute is never added in production.
469
+ */
470
+ debug?: boolean;
460
471
  }
461
472
 
462
473
  function identityClass(className: string) {
@@ -555,6 +566,10 @@ function splitPropsImpl(
555
566
  const sourcesLength = sources.length;
556
567
  const results: Record<string, unknown>[] = [];
557
568
  let stylingClaimed = selfIsRecipe;
569
+ // The recipe that claims styling props also receives an incoming debug
570
+ // attribute, so it can append the value to its own. The rest props keep the
571
+ // value too, so it still reaches the element through `.class()`.
572
+ let stylingResult: Record<string, unknown> | null = null;
558
573
 
559
574
  const selfResult: Record<string, unknown> = {};
560
575
  const selfKeysLength = selfKeys.length;
@@ -565,6 +580,9 @@ function splitPropsImpl(
565
580
  }
566
581
  }
567
582
  results.push(selfResult);
583
+ if (selfIsRecipe) {
584
+ stylingResult = selfResult;
585
+ }
568
586
 
569
587
  // Track effective key arrays for the rest computation — for typical inputs
570
588
  // a linear scan beats building a Set up-front.
@@ -596,6 +614,7 @@ function splitPropsImpl(
596
614
 
597
615
  if (sourceIsRecipe && !stylingClaimed) {
598
616
  stylingClaimed = true;
617
+ stylingResult = sourceResult;
599
618
  }
600
619
  }
601
620
 
@@ -606,6 +625,12 @@ function splitPropsImpl(
606
625
  outer: for (let i = 0; i < propKeysLength; i++) {
607
626
  const key = propKeys[i];
608
627
  if (key === undefined) continue;
628
+ // Checked in this loop, which already visits every own enumerable key, so
629
+ // that calls without the attribute don't pay for a separate `hasOwn`
630
+ // lookup.
631
+ if (key === DEBUG_ATTRIBUTE && stylingResult) {
632
+ stylingResult[key] = props[key];
633
+ }
609
634
  for (let g = 0; g < groupCount; g++) {
610
635
  const arr = effectiveKeyArrays[g];
611
636
  if (arr === undefined) continue;
@@ -697,6 +722,11 @@ export function create(params: CreateParams = {}) {
697
722
  // `Object.prototype` could use to rewrite every class string this factory
698
723
  // produces, including those of the package-level `cv`.
699
724
  const transformClass = getOwn(params, "transformClass") ?? identityClass;
725
+ // The production check stays here, so bundlers can fold `debug` to `false`
726
+ // and remove the debug code from production bundles.
727
+ const debug =
728
+ process.env.NODE_ENV !== "production" &&
729
+ isDebugEnabled(getOwn(params, "debug"));
700
730
 
701
731
  // The root `cx` type lets consumers emit `typeof cx` for an exported result.
702
732
  // Otherwise, emit must name clsx's `ClassValue`, which pnpm installs hide.
@@ -1983,7 +2013,11 @@ export function create(params: CreateParams = {}) {
1983
2013
  // assembles className and style with user-provided class/style overrides.
1984
2014
  const computeResult = (
1985
2015
  props: RecipeProps<MergedVariants> = EMPTY_DEFAULTS as RecipeProps<MergedVariants>,
1986
- ): { className: string; style: StyleValue } => {
2016
+ ): {
2017
+ className: string;
2018
+ style: StyleValue;
2019
+ variants: Record<string, unknown>;
2020
+ } => {
1987
2021
  const propsRecord = props as Record<string, unknown>;
1988
2022
 
1989
2023
  let resolved: Record<string, unknown> = {};
@@ -2026,7 +2060,14 @@ export function create(params: CreateParams = {}) {
2026
2060
  // on top.
2027
2061
  const allClasses: ClsxClassValue[] = [computedBaseClass];
2028
2062
  const style: StyleValue = {};
2029
- compute(resolved, userVariantProps, null, null, allClasses, style);
2063
+ const variants = compute(
2064
+ resolved,
2065
+ userVariantProps,
2066
+ null,
2067
+ null,
2068
+ allClasses,
2069
+ style,
2070
+ );
2030
2071
 
2031
2072
  // Apply user-provided class / className. Own-property checks keep these
2032
2073
  // consistent with the variant props read above: only what the caller
@@ -2054,9 +2095,24 @@ export function create(params: CreateParams = {}) {
2054
2095
  return {
2055
2096
  className: transformClass(clsx(allClasses)),
2056
2097
  style,
2098
+ variants,
2057
2099
  };
2058
2100
  };
2059
2101
 
2102
+ // Adds the debug attribute to a mode result. Call only when `debug` is
2103
+ // true.
2104
+ const setDebugAttribute = (
2105
+ result: Record<string, unknown>,
2106
+ props: RecipeProps<MergedVariants>,
2107
+ variants: Record<string, unknown>,
2108
+ ) => {
2109
+ result[DEBUG_ATTRIBUTE] = formatDebugAttribute({
2110
+ variantKeys,
2111
+ variants,
2112
+ incoming: getOwn(props as Record<string, unknown>, DEBUG_ATTRIBUTE),
2113
+ });
2114
+ };
2115
+
2060
2116
  const getVariants = (variants?: VariantValues<MergedVariants>) => {
2061
2117
  const variantsRecord = variants ?? EMPTY_DEFAULTS;
2062
2118
  let variantProps = variantsRecord;
@@ -2140,8 +2196,12 @@ export function create(params: CreateParams = {}) {
2140
2196
 
2141
2197
  // Default recipe
2142
2198
  const defaultRecipe = ((props: RecipeProps<MergedVariants> = {}) => {
2143
- const { className, style } = computeResult(props);
2144
- return { class: className, style };
2199
+ const { className, style, variants } = computeResult(props);
2200
+ const result = { class: className, style };
2201
+ if (debug) {
2202
+ setDebugAttribute(result, props, variants);
2203
+ }
2204
+ return result;
2145
2205
  }) as Recipe<V, E>;
2146
2206
  initRecipe(defaultRecipe, inputPropsKeys, (props = {}) => {
2147
2207
  return computeResult(props).style;
@@ -2149,8 +2209,12 @@ export function create(params: CreateParams = {}) {
2149
2209
 
2150
2210
  // JSX recipe
2151
2211
  const jsxRecipe = ((props: RecipeProps<MergedVariants> = {}) => {
2152
- const { className, style } = computeResult(props);
2153
- return { className, style };
2212
+ const { className, style, variants } = computeResult(props);
2213
+ const result = { className, style };
2214
+ if (debug) {
2215
+ setDebugAttribute(result, props, variants);
2216
+ }
2217
+ return result;
2154
2218
  }) as ModalRecipe<MergedVariants, JSXProps>;
2155
2219
  initRecipe(
2156
2220
  jsxRecipe,
@@ -2160,8 +2224,15 @@ export function create(params: CreateParams = {}) {
2160
2224
 
2161
2225
  // HTML recipe
2162
2226
  const htmlRecipe = ((props: RecipeProps<MergedVariants> = {}) => {
2163
- const { className, style } = computeResult(props);
2164
- return { class: className, style: styleValueToHTMLStyle(style) };
2227
+ const { className, style, variants } = computeResult(props);
2228
+ const result = {
2229
+ class: className,
2230
+ style: styleValueToHTMLStyle(style),
2231
+ };
2232
+ if (debug) {
2233
+ setDebugAttribute(result, props, variants);
2234
+ }
2235
+ return result;
2165
2236
  }) as ModalRecipe<MergedVariants, HTMLProps>;
2166
2237
  initRecipe(htmlRecipe, ["class", "style", ...variantKeys], (props = {}) =>
2167
2238
  styleValueToHTMLStyle(computeResult(props).style),
@@ -2169,8 +2240,15 @@ export function create(params: CreateParams = {}) {
2169
2240
 
2170
2241
  // HTMLObj recipe
2171
2242
  const htmlObjRecipe = ((props: RecipeProps<MergedVariants> = {}) => {
2172
- const { className, style } = computeResult(props);
2173
- return { class: className, style: styleValueToHTMLObjStyle(style) };
2243
+ const { className, style, variants } = computeResult(props);
2244
+ const result = {
2245
+ class: className,
2246
+ style: styleValueToHTMLObjStyle(style),
2247
+ };
2248
+ if (debug) {
2249
+ setDebugAttribute(result, props, variants);
2250
+ }
2251
+ return result;
2174
2252
  }) as ModalRecipe<MergedVariants, HTMLObjProps>;
2175
2253
  initRecipe(
2176
2254
  htmlObjRecipe,