@tenphi/tasty 0.0.0-snapshot.b49ed29 → 0.0.0-snapshot.b4e384c

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.
Files changed (76) hide show
  1. package/README.md +403 -380
  2. package/dist/{babel-types-DpUCD2L_.d.ts → babel-types-Dc5zghyE.d.ts} +2 -2
  3. package/dist/chunks/{build-config-DQHNt7oV.js → build-config-D9Iq8QQm.js} +5 -5
  4. package/dist/chunks/{build-config-DQHNt7oV.js.map → build-config-D9Iq8QQm.js.map} +1 -1
  5. package/dist/chunks/{collector-CLJMa9_d.js → collector-Cb8ah2JF.js} +4 -4
  6. package/dist/chunks/{collector-CLJMa9_d.js.map → collector-Cb8ah2JF.js.map} +1 -1
  7. package/dist/chunks/{config-engine-DQTnjS4S.js → config-engine-CMYFZYQh.js} +5 -5
  8. package/dist/chunks/config-engine-CMYFZYQh.js.map +1 -0
  9. package/dist/chunks/{css-definitions-gzJPklRN.js → css-definitions-B4aWBkH3.js} +88 -78
  10. package/dist/chunks/css-definitions-B4aWBkH3.js.map +1 -0
  11. package/dist/chunks/{debug-XlLKYbjU.js → debug-D2Pu7Xhy.js} +4 -4
  12. package/dist/chunks/{debug-XlLKYbjU.js.map → debug-D2Pu7Xhy.js.map} +1 -1
  13. package/dist/chunks/{dsl-DRhFWQzo.js → dsl-CsFl9LGn.js} +132 -52
  14. package/dist/chunks/dsl-CsFl9LGn.js.map +1 -0
  15. package/dist/chunks/{react-runtime-CxMPs43X.js → react-runtime-DHiopXCu.js} +8 -6
  16. package/dist/chunks/react-runtime-DHiopXCu.js.map +1 -0
  17. package/dist/chunks/{runtime-engine-8qIHnb-B.js → runtime-engine-NGCofNXy.js} +11 -7
  18. package/dist/chunks/runtime-engine-NGCofNXy.js.map +1 -0
  19. package/dist/chunks/{runtime-state-BaSL1KZU.js → runtime-state-lZjMbvwV.js} +14 -3
  20. package/dist/chunks/runtime-state-lZjMbvwV.js.map +1 -0
  21. package/dist/chunks/{style-engine-DgP6pNeS.js → style-engine-DnkV_4Jg.js} +256 -95
  22. package/dist/chunks/style-engine-DnkV_4Jg.js.map +1 -0
  23. package/dist/chunks/{zero-engine-DvCd7ZUf.js → zero-engine-DcwaCvFs.js} +6 -6
  24. package/dist/chunks/zero-engine-DcwaCvFs.js.map +1 -0
  25. package/dist/{collector-D4POJ53X.d.ts → collector-D2OT6I2G.d.ts} +2 -2
  26. package/dist/{config-DvPUj4cw.d.ts → config-C4ftFxgI.d.ts} +13 -10
  27. package/dist/core/index.d.ts +4 -4
  28. package/dist/core/index.js +7 -7
  29. package/dist/{index-DC4q-xDq.d.ts → index-DxQNRj50.d.ts} +34 -16
  30. package/dist/index.d.ts +5 -5
  31. package/dist/index.js +8 -8
  32. package/dist/{merge-styles-Jb5iZ-Jf.d.ts → merge-styles-D39qBtox.d.ts} +2 -2
  33. package/dist/ssr/astro.js +2 -2
  34. package/dist/ssr/index.d.ts +1 -1
  35. package/dist/ssr/index.js +2 -2
  36. package/dist/ssr/next-config.d.ts +1 -1
  37. package/dist/ssr/next-config.js +3 -3
  38. package/dist/ssr/next.d.ts +1 -1
  39. package/dist/ssr/next.js +3 -3
  40. package/dist/static/index.d.ts +2 -2
  41. package/dist/{types-ZbF2_6LV.d.ts → types-CYQIhUg1.d.ts} +9 -7
  42. package/dist/zero/babel.d.ts +9 -3
  43. package/dist/zero/babel.js +8 -8
  44. package/dist/zero/babel.js.map +1 -1
  45. package/dist/zero/index.d.ts +25 -6
  46. package/dist/zero/index.js +5 -4
  47. package/dist/zero/index.js.map +1 -1
  48. package/dist/zero/next.d.ts +1 -1
  49. package/docs/README.md +4 -1
  50. package/docs/adoption.md +25 -17
  51. package/docs/ai-agents.md +43 -34
  52. package/docs/comparison.md +9 -8
  53. package/docs/configuration.md +186 -68
  54. package/docs/debug.md +3 -2
  55. package/docs/design-system.md +117 -15
  56. package/docs/dsl.md +258 -116
  57. package/docs/getting-started.md +81 -24
  58. package/docs/injector.md +41 -40
  59. package/docs/methodology.md +46 -21
  60. package/docs/migration-v3.md +3 -3
  61. package/docs/pipeline.md +19 -16
  62. package/docs/plugins.md +21 -41
  63. package/docs/react-api.md +70 -14
  64. package/docs/runtime-benchmarks.md +4 -4
  65. package/docs/ssr.md +92 -66
  66. package/docs/styles.md +82 -16
  67. package/docs/tasty-static.md +143 -58
  68. package/package.json +32 -33
  69. package/dist/chunks/config-engine-DQTnjS4S.js.map +0 -1
  70. package/dist/chunks/css-definitions-gzJPklRN.js.map +0 -1
  71. package/dist/chunks/dsl-DRhFWQzo.js.map +0 -1
  72. package/dist/chunks/react-runtime-CxMPs43X.js.map +0 -1
  73. package/dist/chunks/runtime-engine-8qIHnb-B.js.map +0 -1
  74. package/dist/chunks/runtime-state-BaSL1KZU.js.map +0 -1
  75. package/dist/chunks/style-engine-DgP6pNeS.js.map +0 -1
  76. package/dist/chunks/zero-engine-DvCd7ZUf.js.map +0 -1
@@ -1,6 +1,5 @@
1
- import { M as toSnakeCase, N as CSS_WIDE_KEYWORDS, T as makeEmptyDetails, _ as stringifyStyles, d as parseColor, f as parseStyle, h as resolveCustomProperties, i as DIRECTIONS, j as normalizeDslName, u as normalizeColorTokenValue, w as Lru } from "./dsl-DRhFWQzo.js";
1
+ import { D as isTransparent, E as makeEmptyDetails, F as normalizeDslName, I as toSnakeCase, L as CSS_WIDE_KEYWORDS, N as isColorKeyword, O as parseAlphaMix, T as Lru, c as getGlobalParser, d as normalizeColorTokenValue, f as parseColor, g as resolveCustomProperties, i as DIRECTIONS, p as parseStyle, u as isDroppedValue, v as stringifyStyles } from "./dsl-CsFl9LGn.js";
2
2
  import { a as warnOnceDev, i as warn, n as isSelector, o as isDevEnv } from "./shared-utils-y-HjvPN4.js";
3
- import { B as DEFAULT_TRANSITION } from "./css-definitions-gzJPklRN.js";
4
3
  //#region src/config-state.ts
5
4
  let stylesGenerated = false;
6
5
  let globalPolyfills = null;
@@ -135,8 +134,16 @@ function resolvePredefinedState(stateKey, ctx) {
135
134
  function expandDimensionShorthands(condition) {
136
135
  return condition.replace(/\b(?:w|h|is|bs)\b/g, (dimension) => dimension === "w" ? "width" : dimension === "h" ? "height" : dimension === "is" ? "inline-size" : "block-size");
137
136
  }
137
+ const RE_QUERY_UNIT_NUMBER = /(?<![\w.-])(?:\d*\.\d+|\d+)([a-z][a-z0-9]*)\b/g;
138
138
  function expandTastyUnits(value) {
139
- return value.replace(/(\d+(?:\.\d+)?)\s*x\b/g, (_, num) => `calc(var(--gap) * ${num})`);
139
+ const units = getGlobalParser().getUnits();
140
+ if (!units) return value;
141
+ return value.replace(RE_QUERY_UNIT_NUMBER, (token, unit) => {
142
+ if (!Object.prototype.hasOwnProperty.call(units, unit)) return token;
143
+ const resolved = parseStyle(token).groups[0]?.values[0] ?? token;
144
+ if (resolved.includes("var(")) warnOnce(`query-unit-var:${unit}`, `[Tasty] Unit '${unit}' resolves to '${resolved}', which @media and @container conditions cannot read: custom properties are not available there. Write '${token}' as a px, em, or rem length.`);
145
+ return resolved;
146
+ });
140
147
  }
141
148
  const RE_LENGTH_FEATURE = /^(?:min-|max-)?(?:width|height|inline-size|block-size)$/;
142
149
  const RE_QUERY_OPERATOR = /<=|>=|<|>|=/;
@@ -192,6 +199,16 @@ const CHUNK_NAMES = {
192
199
  };
193
200
  const APPEARANCE_CHUNK_STYLES = [
194
201
  "fill",
202
+ "backgroundColor",
203
+ "image",
204
+ "backgroundImage",
205
+ "backgroundPosition",
206
+ "backgroundSize",
207
+ "backgroundRepeat",
208
+ "backgroundAttachment",
209
+ "backgroundOrigin",
210
+ "backgroundClip",
211
+ "background",
195
212
  "color",
196
213
  "opacity",
197
214
  "border",
@@ -438,10 +455,16 @@ const BORDER_STYLES = [
438
455
  ];
439
456
  //#endregion
440
457
  //#region src/styles/shared.ts
458
+ function resolveDefaultValue(value) {
459
+ return parseStyle(value).groups[0]?.values[0] ?? value;
460
+ }
441
461
  function extractCSSWideKeyword(group) {
442
462
  if (group.values.length !== 1 || group.colors.length > 0) return null;
443
463
  return CSS_WIDE_KEYWORDS.has(group.values[0]) ? group.values[0] : null;
444
464
  }
465
+ function isUnset(value) {
466
+ return value == null || value === false;
467
+ }
445
468
  const RE_VAR_REFERENCE = /^var\(/;
446
469
  function assignLineSlots(values, styleKeyword, colorToken) {
447
470
  if (styleKeyword && colorToken) return {
@@ -477,9 +500,9 @@ function processGroup$1(group) {
477
500
  else if (mod === "longhand") modFlags |= 16;
478
501
  else if (lineStyle === void 0 && BORDER_STYLES.includes(mod)) lineStyle = mod;
479
502
  const slots = assignLineSlots(values, lineStyle, colors[0]);
480
- const width = values[0] || "var(--border-width)";
503
+ const width = values[0] || resolveDefaultValue("1bw");
481
504
  const style = slots.style || "solid";
482
- const color = slots.color || "var(--border-color, currentColor)";
505
+ const color = slots.color || "var(--border-color)";
483
506
  return {
484
507
  modFlags,
485
508
  width,
@@ -562,7 +585,7 @@ function borderStyle({ border }) {
562
585
  }
563
586
  const result = {};
564
587
  const fallbackStyle = allDirectionsValue?.style || "solid";
565
- const fallbackColor = allDirectionsValue?.color || "var(--border-color, currentColor)";
588
+ const fallbackColor = allDirectionsValue?.color || "var(--border-color)";
566
589
  for (const dir of DIRECTIONS) {
567
590
  const value = directionMap[dir];
568
591
  if (value) result[`border-${dir}`] = formatBorderValue(value);
@@ -573,10 +596,15 @@ function borderStyle({ border }) {
573
596
  borderStyle.__lookupStyles = ["border"];
574
597
  //#endregion
575
598
  //#region src/styles/dimension.ts
576
- const DEFAULT_MIN_SIZE = "var(--gap)";
599
+ const DEFAULT_MIN_SIZE = "1x";
577
600
  const DEFAULT_MAX_SIZE = "100%";
601
+ const STRETCH_FALLBACKS = [
602
+ "-webkit-fill-available",
603
+ "-moz-available",
604
+ "stretch"
605
+ ];
578
606
  function parseDimensionValue(val) {
579
- if (val == null) return null;
607
+ if (isUnset(val)) return null;
580
608
  if (typeof val === "number") return `${val}px`;
581
609
  if (val === true) return "initial";
582
610
  return parseStyle(String(val)).groups[0]?.values[0] || null;
@@ -585,8 +613,8 @@ function dimensionStyle(name) {
585
613
  const minStyle = `min-${name}`;
586
614
  const maxStyle = `max-${name}`;
587
615
  return ({ value, min, max }) => {
588
- if (value == null && min == null && max == null) return null;
589
- if (value != null && typeof value === "string" && CSS_WIDE_KEYWORDS.has(value)) {
616
+ if (isUnset(value) && isUnset(min) && isUnset(max)) return null;
617
+ if (typeof value === "string" && CSS_WIDE_KEYWORDS.has(value)) {
590
618
  const styles = {
591
619
  [name]: value,
592
620
  [minStyle]: value,
@@ -615,7 +643,7 @@ function dimensionStyle(name) {
615
643
  [minStyle]: "initial",
616
644
  [maxStyle]: "initial"
617
645
  };
618
- if (value != null) {
646
+ if (!isUnset(value)) {
619
647
  let val = value;
620
648
  if (typeof val === "number") val = `${val}px`;
621
649
  val = String(val);
@@ -623,7 +651,7 @@ function dimensionStyle(name) {
623
651
  let flag = false;
624
652
  for (const mod of mods) switch (mod) {
625
653
  case "min":
626
- styles[minStyle] = values[0] || DEFAULT_MIN_SIZE;
654
+ styles[minStyle] = values[0] || resolveDefaultValue(DEFAULT_MIN_SIZE);
627
655
  flag = true;
628
656
  break;
629
657
  case "max":
@@ -649,14 +677,7 @@ function dimensionStyle(name) {
649
677
  styles[maxStyle] = values[2];
650
678
  } else styles[name] = values[0] || "auto";
651
679
  }
652
- if (styles[name] === "stretch") {
653
- if (name === "width") styles[name] = [
654
- "stretch",
655
- "-webkit-fill-available",
656
- "-moz-available"
657
- ];
658
- else styles[name] = "auto";
659
- }
680
+ if (styles[name] === "stretch") styles[name] = STRETCH_FALLBACKS;
660
681
  }
661
682
  const minVal = parseDimensionValue(min);
662
683
  const maxVal = parseDimensionValue(max);
@@ -678,11 +699,14 @@ function blockSizeStyle({ blockSize, minBlockSize, maxBlockSize }) {
678
699
  blockSizeStyle.__lookupStyles = [...BLOCK_SIZE_STYLES];
679
700
  //#endregion
680
701
  //#region src/styles/color.ts
702
+ const RE_HEX_LITERAL = /^#[0-9a-f]+$/i;
681
703
  const RE_READS_CURRENT = /var\(--current-color[,)]|currentcolor/i;
682
704
  function colorStyle({ color }) {
683
705
  if (!color) return null;
684
706
  if (color === true) color = "currentColor";
685
- color = parseColor(color, true).color || resolveCustomProperties(color);
707
+ const resolved = RE_HEX_LITERAL.test(color) ? parseStyle(color).groups[0]?.colors[0] : parseColor(color, true).color;
708
+ if (!resolved && isDroppedValue(color)) return null;
709
+ color = resolved || resolveCustomProperties(color);
686
710
  const styles = { color };
687
711
  if (!RE_READS_CURRENT.test(color)) styles["--current-color"] = color;
688
712
  return styles;
@@ -750,7 +774,7 @@ function processGroup(group, isOnlyGroup, gradients) {
750
774
  const { input, values, mods, colors } = group;
751
775
  const transparentColor = colors[0] || DEFAULT_TRANSPARENT_COLOR;
752
776
  const opaqueColor = colors[1] || DEFAULT_OPAQUE_COLOR;
753
- const firstSize = values.length ? values[0] : "calc(2 * var(--gap))";
777
+ const firstSize = values.length ? values[0] : resolveDefaultValue("2x");
754
778
  let namedCount = 0;
755
779
  for (const mod of mods) {
756
780
  const directionIndex = DIRECTIONS.indexOf(mod);
@@ -784,16 +808,39 @@ function fadeStyle({ fade }) {
784
808
  fadeStyle.__lookupStyles = ["fade"];
785
809
  //#endregion
786
810
  //#region src/styles/fill.ts
811
+ function mixFillColors(property, value, groups) {
812
+ warnOnceDev(`fill-mix:${property}:${value}`, `${property}="${value}": mixing colors with a comma is deprecated. Layer the colors as a compound color instead: "#dark 4%, #surface" is "#surface+#dark.04". For any other mix, write color-mix() itself, such as "color-mix(in srgb, #dark $weight, #surface)".` + (groups.length > 2 ? " A mix takes two colors; the rest are ignored." : ""));
813
+ const [first, second] = groups;
814
+ return `color-mix(in srgb, ${first.output}, ${second.output})`;
815
+ }
787
816
  function fillStyle({ fill, backgroundColor, image, backgroundImage, backgroundPosition, backgroundSize, backgroundRepeat, backgroundAttachment, backgroundOrigin, backgroundClip, background }) {
788
817
  if (background) return { background: parseStyle(background).output || background };
789
818
  const result = {};
790
- const colorValue = backgroundColor ?? fill;
819
+ if (fill === true) warnOnceDev("fill-true", "fill: true has no default color and is ignored. Write a color (fill: '#surface'), or false for no fill.");
820
+ const colorProperty = backgroundColor != null ? "backgroundColor" : "fill";
821
+ const colorValue = backgroundColor ?? (typeof fill === "string" ? fill : void 0);
791
822
  if (colorValue) {
792
- const parsed = parseStyle(colorValue);
793
- const firstColor = parsed.groups[0]?.colors[0];
794
- const secondColor = parsed.groups[0]?.colors[1];
795
- result["background-color"] = firstColor || resolveCustomProperties(colorValue);
796
- if (secondColor) result["--tasty-second-fill-color"] = secondColor;
823
+ const { groups } = parseStyle(colorValue);
824
+ if (groups.length > 1) result["background-color"] = mixFillColors(colorProperty, colorValue, groups);
825
+ else {
826
+ const firstColor = groups[0]?.colors[0];
827
+ const secondColor = groups[0]?.colors[1];
828
+ if (firstColor || !isDroppedValue(colorValue)) result["background-color"] = firstColor || resolveCustomProperties(colorValue);
829
+ if (secondColor) {
830
+ const tokens = colorValue.trim().split(/\s+/);
831
+ const [base, overlay] = tokens;
832
+ const join = (compound) => `Join them with a plus instead: "${compound}" paints the second color over the first as one background color.`;
833
+ const makeOpaque = `make it opaque and give it an opacity: "${base}+${overlay}.04".`;
834
+ let fix;
835
+ if (tokens.length !== 2 || base[0] !== "#" || overlay[0] !== "#") fix = join("#surface+#dark.04");
836
+ else if (isTransparent(secondColor)) fix = `"${overlay}" paints nothing, so use the first color alone: "${base}".`;
837
+ else if (overlay.includes(".")) fix = join(`${base}+${overlay}`);
838
+ else if (parseAlphaMix(secondColor) || secondColor.includes("/")) fix = `"${overlay}" is translucent, which would leave a compound see-through, so ${makeOpaque}`;
839
+ else fix = `If "${overlay}" is opaque, it covers the first color, so use it alone: "${overlay}". If it is translucent, ${makeOpaque}`;
840
+ warnOnceDev(`fill-two-colors:${colorProperty}:${colorValue}`, `${colorProperty}="${colorValue}": two colors separated by a space are deprecated. The second one is painted as a background-image layer, which contrast checkers such as axe cannot read. ${fix}`);
841
+ result["--tasty-second-fill-color"] = secondColor;
842
+ }
843
+ }
797
844
  }
798
845
  const gradientLayer = result["--tasty-second-fill-color"] ? "linear-gradient(var(--tasty-second-fill-color), var(--tasty-second-fill-color))" : null;
799
846
  const imageValue = backgroundImage ?? image;
@@ -825,7 +872,9 @@ fillStyle.__lookupStyles = [
825
872
  ];
826
873
  function svgFillStyle({ svgFill }) {
827
874
  if (!svgFill) return null;
828
- svgFill = parseStyle(svgFill).groups[0]?.colors[0] || resolveCustomProperties(svgFill);
875
+ const processed = parseStyle(svgFill);
876
+ if (!processed.groups[0]?.colors[0] && isDroppedValue(svgFill)) return null;
877
+ svgFill = processed.groups[0]?.colors[0] || resolveCustomProperties(svgFill);
829
878
  return { fill: svgFill };
830
879
  }
831
880
  svgFillStyle.__lookupStyles = ["svgFill"];
@@ -902,7 +951,7 @@ function parseSingleValue(val, defaultValue, trueValue) {
902
951
  const strVal = String(val);
903
952
  if (CSS_WIDE_KEYWORDS.has(strVal)) return strVal;
904
953
  const { values } = parseStyle(strVal).groups[0] ?? { values: [] };
905
- return values[0] || defaultValue;
954
+ return values[0] || resolveDefaultValue(defaultValue);
906
955
  }
907
956
  function directionModFlags(mods, spanModifiers) {
908
957
  let flags = 0;
@@ -920,7 +969,7 @@ function directionModFlags(mods, spanModifiers) {
920
969
  return flags;
921
970
  }
922
971
  function applyGroup(dirs, group, modFlags, property, defaultValue) {
923
- const values = group.values.length ? group.values : [defaultValue];
972
+ const values = group.values.length ? group.values : [resolveDefaultValue(defaultValue)];
924
973
  const directions = modFlags & DIRECTION_MASK;
925
974
  const span = modFlags & DIRECTION_SPAN;
926
975
  if (directions && values.length > (span ? 2 : 1)) warnExtraGroupValues(property, group.input, span ? 2 : 1);
@@ -952,11 +1001,11 @@ function optimizeShorthand(property, dirs) {
952
1001
  }
953
1002
  function processDirectionalStyle(config, props) {
954
1003
  const { main, top, right, bottom, left } = props;
955
- if (main == null && top == null && right == null && bottom == null && left == null) return null;
1004
+ if (isUnset(main) && isUnset(top) && isUnset(right) && isUnset(bottom) && isUnset(left)) return null;
956
1005
  const { property, defaultValue, trueValue, defaultInit, individualOnly, directionProperty, spanModifiers } = config;
957
1006
  const dirProp = directionProperty ?? ((dir) => `${property}-${dir}`);
958
1007
  if (individualOnly) {
959
- if (main == null) {
1008
+ if (isUnset(main)) {
960
1009
  const result = {};
961
1010
  if (top != null) {
962
1011
  const val = parseSingleValue(top, defaultValue, trueValue);
@@ -984,7 +1033,7 @@ function processDirectionalStyle(config, props) {
984
1033
  left: defaultInit
985
1034
  };
986
1035
  let useLonghand = false;
987
- if (main != null) {
1036
+ if (!isUnset(main)) {
988
1037
  if (typeof main === "number") dirs.top = dirs.right = dirs.bottom = dirs.left = `${main}px`;
989
1038
  else {
990
1039
  const strMain = main === true ? trueValue : String(main);
@@ -1106,7 +1155,7 @@ function logicalAxisStyle({ styleName, cssProperty, defaultValue, trueValue, def
1106
1155
  const modFlags = logicalModFlags(group.mods);
1107
1156
  const hasDirection = modFlags & 3;
1108
1157
  const keyword = extractCSSWideKeyword(group);
1109
- const values = keyword ? [keyword] : group.values.length ? group.values : [defaultValue];
1158
+ const values = keyword ? [keyword] : group.values.length ? group.values : [resolveDefaultValue(defaultValue)];
1110
1159
  if (hasDirection && values.length > 1) warnExtraGroupValues(styleName, group.input, 1, LOGICAL_DIRECTIONS);
1111
1160
  else if (!hasDirection && values.length > 2) warnOnceDev(`extra-logical-axis-values:${styleName}:${group.input}`, `${styleName}="${group.input}": a logical axis takes at most two values in start/end order. The extra values are ignored.`);
1112
1161
  if (modFlags & LOGICAL_LONGHAND) useLonghand = true;
@@ -1129,7 +1178,7 @@ function logicalAxisStyle({ styleName, cssProperty, defaultValue, trueValue, def
1129
1178
  }
1130
1179
  function zeroBorderValue(value) {
1131
1180
  const firstSpace = value.indexOf(" ");
1132
- return firstSpace === -1 ? "0 solid var(--border-color, currentColor)" : `0${value.slice(firstSpace)}`;
1181
+ return firstSpace === -1 ? "0 solid var(--border-color)" : `0${value.slice(firstSpace)}`;
1133
1182
  }
1134
1183
  function logicalBorderStyle(styleName, cssProperty) {
1135
1184
  const handler = ((styles) => {
@@ -1143,7 +1192,7 @@ function logicalBorderStyle(styleName, cssProperty) {
1143
1192
  start: null,
1144
1193
  end: null
1145
1194
  };
1146
- let fallback = "0 solid var(--border-color, currentColor)";
1195
+ let fallback = "0 solid var(--border-color)";
1147
1196
  let useLonghand = false;
1148
1197
  for (const group of groups) {
1149
1198
  const borderValue = parseBorderValue(group.input);
@@ -1184,8 +1233,8 @@ function logicalBorderStyles(styleNames) {
1184
1233
  return Object.fromEntries(styleNames.map((styleName, index) => [styleName, logicalBorderStyle(styleName, `border-${index ? "inline" : "block"}`)]));
1185
1234
  }
1186
1235
  const logicalStyleHandlers = {
1187
- ...logicalAxisStyles(LOGICAL_PADDING_STYLES, "padding", "var(--gap)", "1x", "0"),
1188
- ...logicalAxisStyles(LOGICAL_MARGIN_STYLES, "margin", "var(--gap)", "1x", "0"),
1236
+ ...logicalAxisStyles(LOGICAL_PADDING_STYLES, "padding", "1x", "1x", "0"),
1237
+ ...logicalAxisStyles(LOGICAL_MARGIN_STYLES, "margin", "1x", "1x", "0"),
1189
1238
  ...logicalAxisStyles(LOGICAL_INSET_STYLES, "inset", "0", "0", "auto"),
1190
1239
  ...logicalAxisStyles(LOGICAL_SCROLL_MARGIN_STYLES, "scroll-margin", "0", "1x", "0"),
1191
1240
  ...logicalAxisStyles(LOGICAL_SCROLL_PADDING_STYLES, "scroll-padding", "0", "1x", "0"),
@@ -1195,7 +1244,7 @@ const logicalStyleHandlers = {
1195
1244
  //#region src/styles/margin.ts
1196
1245
  const MARGIN_CONFIG = {
1197
1246
  property: "margin",
1198
- defaultValue: "var(--gap)",
1247
+ defaultValue: "1x",
1199
1248
  trueValue: "1x",
1200
1249
  defaultInit: "0"
1201
1250
  };
@@ -1240,12 +1289,12 @@ function outlineStyle({ outline, outlineOffset }) {
1240
1289
  break;
1241
1290
  }
1242
1291
  const slots = assignLineSlots(outlinePart.values, lineStyle, outlinePart.colors[0]);
1243
- result.outline = `${outlinePart.values[0] || "var(--outline-width)"} ${slots.style || "solid"} ${slots.color || "var(--outline-color)"}`;
1292
+ result.outline = `${outlinePart.values[0] || resolveDefaultValue("1ow")} ${slots.style || "solid"} ${slots.color || "var(--outline-color)"}`;
1244
1293
  if (offsetPart?.values[0]) result["outline-offset"] = offsetPart.values[0];
1245
1294
  }
1246
1295
  }
1247
1296
  }
1248
- if (outlineOffset != null && result["outline-offset"] === void 0) {
1297
+ if (outlineOffset != null && typeof outlineOffset !== "boolean" && result["outline-offset"] === void 0) {
1249
1298
  const offsetValue = typeof outlineOffset === "number" ? `${outlineOffset}px` : outlineOffset;
1250
1299
  result["outline-offset"] = parseStyle(offsetValue).groups[0]?.values[0] || resolveCustomProperties(offsetValue);
1251
1300
  }
@@ -1256,7 +1305,7 @@ outlineStyle.__lookupStyles = ["outline", "outlineOffset"];
1256
1305
  //#region src/styles/padding.ts
1257
1306
  const PADDING_CONFIG = {
1258
1307
  property: "padding",
1259
- defaultValue: "var(--gap)",
1308
+ defaultValue: "1x",
1260
1309
  trueValue: "1x",
1261
1310
  defaultInit: "0"
1262
1311
  };
@@ -1349,8 +1398,8 @@ const PRESET_MODIFIERS = /* @__PURE__ */ new Set([
1349
1398
  "tight",
1350
1399
  "normal"
1351
1400
  ]);
1352
- const SANS_FONT = "var(--font-sans, var(--font-sans-fallback, system-ui, sans-serif))";
1353
- const MONO_FONT = "var(--font-mono, var(--font-mono-fallback, ui-monospace, monospace))";
1401
+ const SANS_FONT = "var(--font-sans, var(--font-sans-fallback))";
1402
+ const MONO_FONT = "var(--font-mono, var(--font-mono-fallback))";
1354
1403
  function toCSS(value, isNumeric) {
1355
1404
  if (value == null) return null;
1356
1405
  if (typeof value === "number") return isNumeric ? `${value}px` : String(value);
@@ -1382,7 +1431,8 @@ function presetStyle({ preset, fontSize, lineHeight, textTransform, letterSpacin
1382
1431
  const modPart = parts[1];
1383
1432
  const nameTokens = namePart?.all ?? [];
1384
1433
  const isModOnly = nameTokens.length > 0 && nameTokens.every((t) => PRESET_MODIFIERS.has(t));
1385
- const nameToken = namePart?.mods[0] ?? namePart?.values[0] ?? "";
1434
+ const nameMods = namePart?.mods ?? [];
1435
+ const nameToken = nameTokens.find((token) => nameMods.includes(token) || isColorKeyword(token)) ?? namePart?.values[0] ?? "";
1386
1436
  const name = isModOnly || isTokenNameReference("preset", nameToken) ? "inherit" : nameToken || "inherit";
1387
1437
  const modTokens = isModOnly ? nameTokens : modPart?.all ?? [];
1388
1438
  const isStrong = modTokens.includes("strong") || modTokens.includes("bold");
@@ -1399,7 +1449,7 @@ function presetStyle({ preset, fontSize, lineHeight, textTransform, letterSpacin
1399
1449
  if (fontFamily == null && font == null) setCSSValue(styles, "font-family", name, "css");
1400
1450
  setCSSValue(styles, "bold-font-weight", name, "var");
1401
1451
  setCSSValue(styles, "icon-size", name, "var");
1402
- if (isStrong) styles["font-weight"] = `var(--bold-font-weight, 700)`;
1452
+ if (isStrong) styles["font-weight"] = "var(--bold-font-weight)";
1403
1453
  if (isItalic) styles["font-style"] = "italic";
1404
1454
  if (isIcon) {
1405
1455
  styles["font-size"] = "var(--icon-size)";
@@ -1439,7 +1489,7 @@ presetStyle.__lookupStyles = [
1439
1489
  ];
1440
1490
  //#endregion
1441
1491
  //#region src/styles/radius.ts
1442
- const PROP = "var(--radius)";
1492
+ const DEFAULT_RADIUS = "1r";
1443
1493
  const SHARP = "var(--sharp-radius)";
1444
1494
  const RADIUS_LONGHANDS = [
1445
1495
  "border-top-left-radius",
@@ -1484,19 +1534,20 @@ function radiusStyle({ radius }) {
1484
1534
  for (const i of corners) result[RADIUS_LONGHANDS[i]] = keyword;
1485
1535
  return result;
1486
1536
  }
1537
+ const defaultRadius = resolveDefaultValue(DEFAULT_RADIUS);
1487
1538
  if (mods.includes("round")) values = ["9999rem"];
1488
1539
  else if (mods.includes("ellipse")) values = ["50%"];
1489
- else if (!values.length) values = [PROP];
1540
+ else if (!values.length) values = [defaultRadius];
1490
1541
  if (mods.includes("leaf")) values = [
1491
1542
  values[1] || SHARP,
1492
- values[0] || PROP,
1543
+ values[0] || defaultRadius,
1493
1544
  values[1] || SHARP,
1494
- values[0] || PROP
1545
+ values[0] || defaultRadius
1495
1546
  ];
1496
1547
  else if (mods.includes("backleaf")) values = [
1497
- values[0] || PROP,
1548
+ values[0] || defaultRadius,
1498
1549
  values[1] || SHARP,
1499
- values[0] || PROP,
1550
+ values[0] || defaultRadius,
1500
1551
  values[1] || SHARP
1501
1552
  ];
1502
1553
  else if (mods.length) {
@@ -1508,7 +1559,7 @@ function radiusStyle({ radius }) {
1508
1559
  "0",
1509
1560
  "0"
1510
1561
  ];
1511
- for (const i of corners) arr[i] = values[0] || PROP;
1562
+ for (const i of corners) arr[i] = values[0] || defaultRadius;
1512
1563
  values = arr;
1513
1564
  }
1514
1565
  }
@@ -1700,7 +1751,6 @@ const MAP = {
1700
1751
  "height"
1701
1752
  ],
1702
1753
  gap: ["gap", "margin"],
1703
- zIndex: ["z-index"],
1704
1754
  inset: [
1705
1755
  "inset",
1706
1756
  "top",
@@ -1709,24 +1759,27 @@ const MAP = {
1709
1759
  "left"
1710
1760
  ]
1711
1761
  };
1762
+ const NAME_ALIASES = { zindex: "z-index" };
1712
1763
  const DEFAULT_EASING = "linear";
1713
1764
  const EASING_KEYWORDS = new Set("ease ease-in ease-out ease-in-out linear step-start step-end".split(" "));
1714
1765
  function isEasing(token) {
1715
1766
  return EASING_KEYWORDS.has(token) || token.startsWith("cubic-bezier(") || token.startsWith("steps(") || token.startsWith("linear(");
1716
1767
  }
1717
1768
  function getTiming(name) {
1718
- return `var(${name.startsWith("--") ? `${name}-transition` : `--${name}-transition`}, var(--transition, ${DEFAULT_TRANSITION}))`;
1769
+ return `var(${name.startsWith("--") ? `${name}-transition` : `--${name}-transition`}, var(--transition))`;
1719
1770
  }
1720
1771
  function transitionStyle({ transition }) {
1721
1772
  if (!transition) return null;
1722
- if (CSS_WIDE_KEYWORDS.has(transition)) return { transition };
1773
+ const keyword = String(transition).trim().toLowerCase();
1774
+ if (keyword === "none" || CSS_WIDE_KEYWORDS.has(keyword)) return { transition: keyword };
1723
1775
  const processed = parseStyle(transition);
1724
1776
  const map = {};
1725
1777
  const named = /* @__PURE__ */ new Set();
1726
1778
  for (const group of processed.groups) {
1727
1779
  const tokens = group.all;
1728
- const name = tokens[0];
1780
+ let name = tokens[0];
1729
1781
  if (!name || isTokenNameReference("transition", name)) continue;
1782
+ name = NAME_ALIASES[name] ?? name;
1730
1783
  let timing;
1731
1784
  let easing;
1732
1785
  let delay;
@@ -2022,6 +2075,48 @@ function rootStateIndex(selector) {
2022
2075
  if (!isRoot) return -1;
2023
2076
  return pseudoElementAt === -1 ? selector.length : pseudoElementAt;
2024
2077
  }
2078
+ function pseudoElementIndex(selector) {
2079
+ let pseudoElementAt = -1;
2080
+ let newCompound = false;
2081
+ let squareDepth = 0;
2082
+ let parenDepth = 0;
2083
+ let quote = "";
2084
+ for (let i = 0; i < selector.length; i++) {
2085
+ const char = selector[i];
2086
+ if (quote) {
2087
+ if (char === "\\") i++;
2088
+ else if (char === quote) quote = "";
2089
+ continue;
2090
+ }
2091
+ if (char === "/" && selector[i + 1] === "*") {
2092
+ const end = selector.indexOf("*/", i + 2);
2093
+ if (end === -1) break;
2094
+ i = end + 1;
2095
+ continue;
2096
+ }
2097
+ if (squareDepth === 0 && parenDepth === 0) {
2098
+ if (/[\s>+~,]/.test(char)) {
2099
+ newCompound = true;
2100
+ continue;
2101
+ }
2102
+ if (newCompound) {
2103
+ pseudoElementAt = -1;
2104
+ newCompound = false;
2105
+ }
2106
+ if (pseudoElementAt === -1 && char === ":") {
2107
+ const name = /^:[\w-]+/.exec(selector.slice(i))?.[0] ?? "";
2108
+ if (selector[i + 1] === ":" || LEGACY_PSEUDO_ELEMENT_RE.test(name)) pseudoElementAt = i;
2109
+ }
2110
+ }
2111
+ if (char === "\\") i++;
2112
+ else if (char === "\"" || char === "'") quote = char;
2113
+ else if (char === "[") squareDepth++;
2114
+ else if (char === "]") squareDepth = Math.max(0, squareDepth - 1);
2115
+ else if (char === "(") parenDepth++;
2116
+ else if (char === ")") parenDepth = Math.max(0, parenDepth - 1);
2117
+ }
2118
+ return pseudoElementAt === -1 ? selector.length : pseudoElementAt;
2119
+ }
2025
2120
  function splitSelectorsSafely(selectorList) {
2026
2121
  if (!selectorList.includes(",")) {
2027
2122
  const selector = selectorList.trim();
@@ -4539,7 +4634,7 @@ var Parser = class {
4539
4634
  let expandedCondition = expandDimensionShorthands(condition);
4540
4635
  expandedCondition = expandQueryUnits(expandedCondition);
4541
4636
  const { dimension, lowerBound, upperBound } = this.parseDimensionCondition(expandedCondition);
4542
- if (!dimension) return createPseudoCondition(raw, false, raw);
4637
+ if (!dimension) return createContainerRawCondition(`(${expandedCondition.trim()})`, containerName, false, raw);
4543
4638
  return createContainerDimensionCondition(dimension, lowerBound, upperBound, containerName, false, raw);
4544
4639
  }
4545
4640
  parsePredefinedState(raw) {
@@ -4593,6 +4688,35 @@ function clearParseCache() {
4593
4688
  parseCache.clear();
4594
4689
  }
4595
4690
  //#endregion
4691
+ //#region src/pipeline/pseudo-element-states.ts
4692
+ const QUOTED_RE = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g;
4693
+ const STRUCTURAL_PSEUDO_RE = /:(?:root|empty|scope|has|(?:first|last|only)-(?:child|of-type)|nth-(?:last-)?(?:child|of-type))(?![\w-])/i;
4694
+ function leafMismatch(node) {
4695
+ if (node.kind !== "state") return null;
4696
+ if (node.type === "modifier") return "modifiers";
4697
+ if (node.type !== "pseudo") return null;
4698
+ const selector = node.pseudo.replace(QUOTED_RE, "\"\"");
4699
+ if (STRUCTURAL_PSEUDO_RE.test(selector)) return "position in the DOM tree";
4700
+ if (selector.includes("[")) return "attributes";
4701
+ if (selector.includes(".") || selector.includes("#")) return "classes or ids";
4702
+ return null;
4703
+ }
4704
+ function pseudoElementMismatch(condition, target) {
4705
+ const walk = (node, describesTarget) => {
4706
+ if (node.kind === "compound") {
4707
+ for (const child of node.children) {
4708
+ const found = walk(child, describesTarget);
4709
+ if (found) return found;
4710
+ }
4711
+ return null;
4712
+ }
4713
+ if (node.kind !== "state") return null;
4714
+ if (node.type === "own") return target.own || target.root ? walk(node.innerCondition, true) : null;
4715
+ return describesTarget ? leafMismatch(node) : null;
4716
+ };
4717
+ return walk(condition, target.root);
4718
+ }
4719
+ //#endregion
4596
4720
  //#region src/pipeline/index.ts
4597
4721
  const RE_UPPER_CASE = /[A-Z]/;
4598
4722
  const pipelineCache = new Lru(5e3);
@@ -4602,9 +4726,9 @@ function hasPipelineCacheEntry(cacheKey) {
4602
4726
  function clearPipelineCache() {
4603
4727
  pipelineCache.clear();
4604
4728
  }
4605
- function runPipeline(styles, parserContext) {
4729
+ function runPipeline(styles, parserContext, pseudoElementRoot = false) {
4606
4730
  const allRules = [];
4607
- processStyles(styles, "", parserContext, allRules);
4731
+ processStyles(styles, "", parserContext, allRules, pseudoElementRoot);
4608
4732
  const seen = /* @__PURE__ */ new Set();
4609
4733
  const normal = [];
4610
4734
  const starting = [];
@@ -4620,7 +4744,7 @@ function stableSortByOrder(rules) {
4620
4744
  if (rules.length <= 1) return rules;
4621
4745
  return [...rules].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
4622
4746
  }
4623
- function processStyles(styles, selectorSuffix, parserContext, allRules) {
4747
+ function processStyles(styles, selectorSuffix, parserContext, allRules, pseudoElementRoot) {
4624
4748
  const keys = Object.keys(styles);
4625
4749
  const selectorKeys = [];
4626
4750
  const styleKeys = [];
@@ -4636,10 +4760,10 @@ function processStyles(styles, selectorSuffix, parserContext, allRules) {
4636
4760
  }
4637
4761
  styleKeys.push(key);
4638
4762
  }
4639
- processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules);
4640
- processHandlerQueue(buildHandlerQueue(styleKeys, styles), selectorSuffix, parserContext, allRules);
4763
+ processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules, pseudoElementRoot);
4764
+ processHandlerQueue(buildHandlerQueue(styleKeys, styles), selectorSuffix, parserContext, allRules, pseudoElementRoot);
4641
4765
  }
4642
- function processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules) {
4766
+ function processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules, pseudoElementRoot) {
4643
4767
  for (const key of selectorKeys) {
4644
4768
  const nestedStyles = styles[key];
4645
4769
  if (!nestedStyles || typeof nestedStyles !== "object") continue;
@@ -4656,30 +4780,34 @@ function processNestedSelectors(styles, selectorKeys, selectorSuffix, parserCont
4656
4780
  ...subLocalStates
4657
4781
  } : parserContext.localPredefinedStates
4658
4782
  };
4659
- for (const suffix of suffixes) processStyles(cleanedStyles, selectorSuffix + suffix, subContext, allRules);
4783
+ for (const suffix of suffixes) processStyles(cleanedStyles, selectorSuffix + suffix, subContext, allRules, pseudoElementRoot);
4660
4784
  }
4661
4785
  }
4662
- function processHandlerQueue(handlerQueue, selectorSuffix, parserContext, allRules) {
4786
+ function processHandlerQueue(handlerQueue, selectorSuffix, parserContext, allRules, pseudoElementRoot) {
4787
+ const target = {
4788
+ own: pseudoElementIndex(selectorSuffix) < selectorSuffix.length,
4789
+ root: pseudoElementRoot
4790
+ };
4663
4791
  for (const { handler, styleMap, hasStateMap } of handlerQueue) {
4664
4792
  const lookupStyles = handler.__lookupStyles;
4665
- const mergedRules = mergeByValue(invokeHandler(handler, hasStateMap ? computeStateCombinations(buildExclusivesForHandler(lookupStyles, styleMap, parserContext), lookupStyles) : [{
4793
+ const mergedRules = mergeByValue(invokeHandler(handler, hasStateMap ? computeStateCombinations(buildExclusivesForHandler(lookupStyles, styleMap, parserContext, target), lookupStyles) : [{
4666
4794
  condition: trueCondition(),
4667
4795
  values: styleMap,
4668
4796
  order: 0
4669
4797
  }], selectorSuffix));
4670
4798
  for (const rule of mergedRules) {
4671
- const cssRules = materializeComputedRule(rule);
4799
+ const cssRules = materializeComputedRule(rule, pseudoElementRoot);
4672
4800
  allRules.push(...cssRules);
4673
4801
  }
4674
4802
  }
4675
4803
  }
4676
- function buildExclusivesForHandler(lookupStyles, styleMap, parserContext) {
4804
+ function buildExclusivesForHandler(lookupStyles, styleMap, parserContext, target) {
4677
4805
  const exclusiveByStyle = /* @__PURE__ */ new Map();
4678
4806
  for (const styleName of lookupStyles) {
4679
4807
  const value = styleMap[styleName];
4680
4808
  if (value === void 0) continue;
4681
4809
  if (isValueMapping(value)) {
4682
- const fullyExpanded = expandExclusiveOrs(buildExclusiveConditions(expandOrConditions(mergeEntriesByValue(parseStyleEntries(styleName, extractCompoundStates(value), (stateKey) => parseStateKey(stateKey, { context: parserContext }))))));
4810
+ const fullyExpanded = expandExclusiveOrs(buildExclusiveConditions(expandOrConditions(mergeEntriesByValue(parseStyleEntries(styleName, extractCompoundStates(target.own || target.root ? dropPseudoElementMismatches(styleName, value, parserContext, target) : value), (stateKey) => parseStateKey(stateKey, { context: parserContext }))))));
4683
4811
  exclusiveByStyle.set(styleName, fullyExpanded);
4684
4812
  } else exclusiveByStyle.set(styleName, [{
4685
4813
  styleKey: styleName,
@@ -4692,6 +4820,18 @@ function buildExclusivesForHandler(lookupStyles, styleMap, parserContext) {
4692
4820
  }
4693
4821
  return exclusiveByStyle;
4694
4822
  }
4823
+ function dropPseudoElementMismatches(styleName, valueMap, parserContext, target) {
4824
+ let kept;
4825
+ for (const stateKey of Object.keys(valueMap)) {
4826
+ if (stateKey === "" || stateKey === "_" || isMisusedFallbackKey(stateKey)) continue;
4827
+ const mismatch = pseudoElementMismatch(parseStateKey(stateKey, { context: parserContext }), target);
4828
+ if (!mismatch) continue;
4829
+ emitWarning("PSEUDO_ELEMENT_STATE_IGNORED", `State "${stateKey}" (in "${styleName}") applies to a pseudo-element, which has no ${mismatch}, so it can never match. The state has been ignored. To condition on the element the pseudo-element belongs to, write it in the selector before the pseudo-element.`);
4830
+ kept ??= { ...valueMap };
4831
+ delete kept[stateKey];
4832
+ }
4833
+ return kept ?? valueMap;
4834
+ }
4695
4835
  function invokeHandler(handler, stateSnapshots, selectorSuffix) {
4696
4836
  const computedRules = [];
4697
4837
  for (const snapshot of stateSnapshots) {
@@ -4704,7 +4844,10 @@ function invokeHandler(handler, stateSnapshots, selectorSuffix) {
4704
4844
  const declarations = {};
4705
4845
  for (const [prop, val] of Object.entries(styleProps)) {
4706
4846
  if (RE_UPPER_CASE.test(prop) && !prop.startsWith("--") && isDevEnv()) emitWarning("HANDLER_CAMEL_CASE_KEY", `A style handler returned "${prop}". CSS property names must be kebab-case ("${toSnakeCase(prop)}"). The declaration was emitted verbatim and the browser will ignore it.`);
4707
- if (val != null && val !== "") declarations[prop] = String(val);
4847
+ if (Array.isArray(val)) {
4848
+ const chain = val.filter((v) => v != null && v !== "").map((v) => String(v));
4849
+ if (chain.length) declarations[prop] = chain.length === 1 ? chain[0] : chain;
4850
+ } else if (val != null && val !== "") declarations[prop] = String(val);
4708
4851
  }
4709
4852
  if (Object.keys(declarations).length === 0) continue;
4710
4853
  const suffixes = $ ? (Array.isArray($) ? $ : [$]).map((s) => selectorSuffix + normalizeSelectorSuffix(String(s))) : [selectorSuffix];
@@ -5019,23 +5162,26 @@ function mergeByValue(rules) {
5019
5162
  }
5020
5163
  return merged;
5021
5164
  }
5022
- function buildSelectorFromVariant(variant, selectorSuffix) {
5023
- let selector = "";
5165
+ function buildSelectorFromVariant(variant, selectorSuffix, pseudoElementRoot) {
5024
5166
  let rootSegment = branchToCSS([...variant.modifierConditions, ...variant.pseudoConditions]);
5025
5167
  for (const group of variant.selectorGroups) rootSegment += selectorGroupToCSS(group);
5026
- selector += wrapWhere(rootSegment);
5027
- if (variant.parentGroups.length > 0) selector += parentGroupsToCSS(variant.parentGroups);
5168
+ const parents = variant.parentGroups.length > 0 ? parentGroupsToCSS(variant.parentGroups) : "";
5169
+ const pseudoElementAt = pseudoElementRoot ? parents.length : 0;
5170
+ let selector = pseudoElementRoot ? parents + wrapWhere(rootSegment) : wrapWhere(rootSegment) + parents;
5028
5171
  selector += selectorSuffix;
5029
5172
  const ownOptimized = optimizeGroups(variant.ownGroups);
5030
5173
  let ownSegment = "";
5031
5174
  for (const group of ownOptimized) ownSegment += selectorGroupToCSS(group);
5032
5175
  selector += wrapWhere(ownSegment);
5033
- return selector;
5176
+ return {
5177
+ selector,
5178
+ pseudoElementAt
5179
+ };
5034
5180
  }
5035
- function materializeComputedRule(rule) {
5181
+ function materializeComputedRule(rule, pseudoElementRoot) {
5036
5182
  const components = conditionToCSS(rule.condition);
5037
5183
  if (components.isImpossible || components.variants.length === 0) return [];
5038
- const declarations = Object.entries(rule.declarations).map(([prop, value]) => `${prop}: ${value};`).join(" ");
5184
+ const declarations = Object.entries(rule.declarations).map(([prop, value]) => Array.isArray(value) ? value.map((v) => `${prop}: ${v};`).join(" ") : `${prop}: ${value};`).join(" ");
5039
5185
  const byAtRules = /* @__PURE__ */ new Map();
5040
5186
  for (const variant of components.variants) {
5041
5187
  const atRules = buildAtRulesFromVariant(variant);
@@ -5055,12 +5201,13 @@ function materializeComputedRule(rule) {
5055
5201
  }
5056
5202
  const rules = [];
5057
5203
  for (const [, group] of byAtRules) {
5058
- const selectorFragments = mergeVariantsIntoSelectorGroups(group.variants).map((v) => buildSelectorFromVariant(v, rule.selectorSuffix));
5204
+ const built = mergeVariantsIntoSelectorGroups(group.variants).map((v) => buildSelectorFromVariant(v, rule.selectorSuffix, pseudoElementRoot));
5059
5205
  const cssRule = {
5060
- selector: selectorFragments.length === 1 ? selectorFragments[0] : selectorFragments,
5206
+ selector: built.length === 1 ? built[0].selector : built.map((b) => b.selector),
5061
5207
  declarations,
5062
5208
  order: rule.order
5063
5209
  };
5210
+ if (pseudoElementRoot) cssRule.pseudoElementAt = built.map((b) => b.pseudoElementAt);
5064
5211
  if (group.atRules.length > 0) cssRule.atRules = group.atRules;
5065
5212
  if (group.rootPrefix) {
5066
5213
  cssRule.rootPrefix = group.rootPrefix;
@@ -5088,23 +5235,33 @@ function renderStyles(styles, classNameOrSelector, options, pipelineCacheKey) {
5088
5235
  if (pipelineCacheKey) rules = pipelineCache.get(pipelineCacheKey);
5089
5236
  if (!rules && !styles) return directSelector ? [] : { rules: [] };
5090
5237
  const cacheKey = pipelineCacheKey || stringifyStyles(styles);
5091
- if (!rules) rules = pipelineCache.get(cacheKey);
5092
- if (!rules) {
5093
- rules = runPipeline(styles, createStateParserContext(styles));
5094
- pipelineCache.set(cacheKey, rules);
5095
- }
5238
+ const rulesFor = (pseudoElementRoot) => {
5239
+ const key = pseudoElementRoot ? `${cacheKey}\0::` : cacheKey;
5240
+ let cached = pipelineCache.get(key);
5241
+ if (!cached) {
5242
+ cached = runPipeline(styles, createStateParserContext(styles), pseudoElementRoot);
5243
+ pipelineCache.set(key, cached);
5244
+ }
5245
+ return cached;
5246
+ };
5096
5247
  if (directSelector) {
5097
5248
  const shouldDouble = options?.doubleSelector ?? false;
5098
5249
  const items = splitSelectorsSafely(classNameOrSelector);
5099
- const bases = (items.length > 0 ? items : [classNameOrSelector]).map((base) => ({
5100
- base,
5101
- rootAt: rootStateIndex(base)
5102
- }));
5103
- return mergeStyleResults(rules.map((rule) => {
5250
+ const bases = (items.length > 0 ? items : [classNameOrSelector]).map((base) => {
5251
+ const at = pseudoElementIndex(base);
5252
+ return {
5253
+ head: base.slice(0, at),
5254
+ pseudoElement: base.slice(at),
5255
+ rootAt: rootStateIndex(base)
5256
+ };
5257
+ });
5258
+ const toResults = (groupRules, group) => groupRules.map((rule) => {
5104
5259
  const result = {
5105
- selector: (Array.isArray(rule.selector) ? rule.selector : rule.selector ? [rule.selector] : [""]).flatMap((part) => bases.map(({ base, rootAt }) => {
5260
+ selector: (Array.isArray(rule.selector) ? rule.selector : rule.selector ? [rule.selector] : [""]).flatMap((part, index) => group.map(({ head, pseudoElement, rootAt }) => {
5106
5261
  const joinsRoot = rule.rootState !== void 0 && rootAt !== -1;
5107
- let sel = joinsRoot ? `${base.slice(0, rootAt)}${wrapWhere(rule.rootState)}${base.slice(rootAt)}${part}` : `${base}${part}`;
5262
+ const base = joinsRoot ? `${head.slice(0, rootAt)}${wrapWhere(rule.rootState)}${head.slice(rootAt)}` : head;
5263
+ const at = rule.pseudoElementAt?.[index] ?? 0;
5264
+ let sel = pseudoElement ? `${base}${part.slice(0, at)}${pseudoElement}${part.slice(at)}` : `${base}${part}`;
5108
5265
  if (shouldDouble && sel.startsWith(".")) {
5109
5266
  const classMatch = sel.match(/^\.[a-zA-Z_-][a-zA-Z0-9_-]*/);
5110
5267
  if (classMatch) sel = classMatch[0] + sel;
@@ -5117,8 +5274,12 @@ function renderStyles(styles, classNameOrSelector, options, pipelineCacheKey) {
5117
5274
  if (rule.atRules && rule.atRules.length > 0) result.atRules = rule.atRules;
5118
5275
  if (rule.startingStyle) result.startingStyle = true;
5119
5276
  return result;
5120
- }));
5277
+ });
5278
+ const plain = bases.filter((base) => !base.pseudoElement);
5279
+ const pseudo = bases.filter((base) => base.pseudoElement);
5280
+ return mergeStyleResults([...plain.length > 0 ? toResults(rulesFor(false), plain) : [], ...pseudo.length > 0 ? toResults(rulesFor(true), pseudo) : []]);
5121
5281
  }
5282
+ rules ??= rulesFor(false);
5122
5283
  return { rules: rules.map((r) => ({
5123
5284
  selector: Array.isArray(r.selector) ? r.selector.join("|||") : r.selector,
5124
5285
  declarations: r.declarations,
@@ -5438,4 +5599,4 @@ function renderStylesForChunk(styles, chunkName, styleKeys, pipelineCacheKey) {
5438
5599
  //#endregion
5439
5600
  export { styleHandlers as A, STYLE_TO_CHUNK as B, camelToKebab as C, normalizeHandlerDefinition as D, defineHandler as E, DIMENSION_CHUNK_STYLES as F, setGlobalPredefinedStates as G, clearGlobalPredefinedStates as H, DISPLAY_CHUNK_STYLES as I, markStylesGeneratedState as J, hasStylesGenerated as K, FONT_CHUNK_STYLES as L, createStyle as M, APPEARANCE_CHUNK_STYLES as N, registerHandler as O, CHUNK_NAMES as P, LAYOUT_CHUNK_STYLES as R, parseStateKey as S, STYLE_HANDLER_MAP as T, createStateParserContext as U, resetStyleChunks as V, getGlobalPredefinedStates as W, resetStylesGeneratedState as X, resetGlobalPolyfillsState as Y, setGlobalPolyfillsState as Z, POSITION_STYLES as _, registerBaseStyleProps as a, renderStyles as b, BLOCK_INNER_STYLES as c, COLOR_STYLES as d, CONTAINER_STYLES as f, OUTER_STYLES as g, INNER_STYLES as h, baseStylePropsRegistry as i, scanAnimationNames as j, resetHandlers as k, BLOCK_OUTER_STYLES as l, FLOW_STYLES as m, generateChunkCacheKey as n, resetBaseStyleProps as o, DIMENSION_STYLES as p, isFunctionsPolyfillEnabled as q, categorizeStyleKeys as r, BASE_STYLES as s, renderStylesForChunk as t, BLOCK_STYLES as u, TEXT_STYLES as v, splitSelectorsSafely as w, clearParseCache as x, clearPipelineCache as y, POSITION_CHUNK_STYLES as z };
5440
5601
 
5441
- //# sourceMappingURL=style-engine-DgP6pNeS.js.map
5602
+ //# sourceMappingURL=style-engine-DnkV_4Jg.js.map