@tenphi/tasty 0.0.0-snapshot.09c74e2

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 (243) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +539 -0
  3. package/dist/_virtual/_rolldown/runtime.js +8 -0
  4. package/dist/chunks/cacheKey.js +70 -0
  5. package/dist/chunks/cacheKey.js.map +1 -0
  6. package/dist/chunks/definitions.d.ts +37 -0
  7. package/dist/chunks/definitions.js +260 -0
  8. package/dist/chunks/definitions.js.map +1 -0
  9. package/dist/chunks/renderChunk.js +61 -0
  10. package/dist/chunks/renderChunk.js.map +1 -0
  11. package/dist/config.d.ts +280 -0
  12. package/dist/config.js +403 -0
  13. package/dist/config.js.map +1 -0
  14. package/dist/core/index.d.ts +33 -0
  15. package/dist/core/index.js +26 -0
  16. package/dist/debug.d.ts +204 -0
  17. package/dist/debug.js +733 -0
  18. package/dist/debug.js.map +1 -0
  19. package/dist/hooks/useGlobalStyles.d.ts +27 -0
  20. package/dist/hooks/useGlobalStyles.js +56 -0
  21. package/dist/hooks/useGlobalStyles.js.map +1 -0
  22. package/dist/hooks/useKeyframes.d.ts +56 -0
  23. package/dist/hooks/useKeyframes.js +54 -0
  24. package/dist/hooks/useKeyframes.js.map +1 -0
  25. package/dist/hooks/useProperty.d.ts +79 -0
  26. package/dist/hooks/useProperty.js +91 -0
  27. package/dist/hooks/useProperty.js.map +1 -0
  28. package/dist/hooks/useRawCSS.d.ts +53 -0
  29. package/dist/hooks/useRawCSS.js +28 -0
  30. package/dist/hooks/useRawCSS.js.map +1 -0
  31. package/dist/hooks/useStyles.d.ts +40 -0
  32. package/dist/hooks/useStyles.js +169 -0
  33. package/dist/hooks/useStyles.js.map +1 -0
  34. package/dist/index.d.ts +48 -0
  35. package/dist/index.js +33 -0
  36. package/dist/injector/index.d.ts +157 -0
  37. package/dist/injector/index.js +154 -0
  38. package/dist/injector/index.js.map +1 -0
  39. package/dist/injector/injector.d.ts +139 -0
  40. package/dist/injector/injector.js +404 -0
  41. package/dist/injector/injector.js.map +1 -0
  42. package/dist/injector/sheet-manager.d.ts +127 -0
  43. package/dist/injector/sheet-manager.js +714 -0
  44. package/dist/injector/sheet-manager.js.map +1 -0
  45. package/dist/injector/types.d.ts +135 -0
  46. package/dist/keyframes/index.js +206 -0
  47. package/dist/keyframes/index.js.map +1 -0
  48. package/dist/parser/classify.js +319 -0
  49. package/dist/parser/classify.js.map +1 -0
  50. package/dist/parser/const.js +33 -0
  51. package/dist/parser/const.js.map +1 -0
  52. package/dist/parser/lru.js +109 -0
  53. package/dist/parser/lru.js.map +1 -0
  54. package/dist/parser/parser.d.ts +25 -0
  55. package/dist/parser/parser.js +116 -0
  56. package/dist/parser/parser.js.map +1 -0
  57. package/dist/parser/tokenizer.js +69 -0
  58. package/dist/parser/tokenizer.js.map +1 -0
  59. package/dist/parser/types.d.ts +51 -0
  60. package/dist/parser/types.js +46 -0
  61. package/dist/parser/types.js.map +1 -0
  62. package/dist/pipeline/conditions.d.ts +134 -0
  63. package/dist/pipeline/conditions.js +406 -0
  64. package/dist/pipeline/conditions.js.map +1 -0
  65. package/dist/pipeline/exclusive.js +231 -0
  66. package/dist/pipeline/exclusive.js.map +1 -0
  67. package/dist/pipeline/index.d.ts +53 -0
  68. package/dist/pipeline/index.js +660 -0
  69. package/dist/pipeline/index.js.map +1 -0
  70. package/dist/pipeline/materialize.js +844 -0
  71. package/dist/pipeline/materialize.js.map +1 -0
  72. package/dist/pipeline/parseStateKey.d.ts +15 -0
  73. package/dist/pipeline/parseStateKey.js +438 -0
  74. package/dist/pipeline/parseStateKey.js.map +1 -0
  75. package/dist/pipeline/simplify.js +516 -0
  76. package/dist/pipeline/simplify.js.map +1 -0
  77. package/dist/pipeline/warnings.js +18 -0
  78. package/dist/pipeline/warnings.js.map +1 -0
  79. package/dist/plugins/okhsl-plugin.d.ts +35 -0
  80. package/dist/plugins/okhsl-plugin.js +371 -0
  81. package/dist/plugins/okhsl-plugin.js.map +1 -0
  82. package/dist/plugins/types.d.ts +69 -0
  83. package/dist/properties/index.js +158 -0
  84. package/dist/properties/index.js.map +1 -0
  85. package/dist/states/index.d.ts +49 -0
  86. package/dist/states/index.js +416 -0
  87. package/dist/states/index.js.map +1 -0
  88. package/dist/static/index.d.ts +5 -0
  89. package/dist/static/index.js +5 -0
  90. package/dist/static/tastyStatic.d.ts +46 -0
  91. package/dist/static/tastyStatic.js +31 -0
  92. package/dist/static/tastyStatic.js.map +1 -0
  93. package/dist/static/types.d.ts +49 -0
  94. package/dist/static/types.js +24 -0
  95. package/dist/static/types.js.map +1 -0
  96. package/dist/styles/align.d.ts +15 -0
  97. package/dist/styles/align.js +14 -0
  98. package/dist/styles/align.js.map +1 -0
  99. package/dist/styles/border.d.ts +25 -0
  100. package/dist/styles/border.js +114 -0
  101. package/dist/styles/border.js.map +1 -0
  102. package/dist/styles/color.d.ts +14 -0
  103. package/dist/styles/color.js +23 -0
  104. package/dist/styles/color.js.map +1 -0
  105. package/dist/styles/createStyle.js +77 -0
  106. package/dist/styles/createStyle.js.map +1 -0
  107. package/dist/styles/dimension.js +97 -0
  108. package/dist/styles/dimension.js.map +1 -0
  109. package/dist/styles/display.d.ts +37 -0
  110. package/dist/styles/display.js +67 -0
  111. package/dist/styles/display.js.map +1 -0
  112. package/dist/styles/fade.d.ts +15 -0
  113. package/dist/styles/fade.js +58 -0
  114. package/dist/styles/fade.js.map +1 -0
  115. package/dist/styles/fill.d.ts +42 -0
  116. package/dist/styles/fill.js +52 -0
  117. package/dist/styles/fill.js.map +1 -0
  118. package/dist/styles/flow.d.ts +16 -0
  119. package/dist/styles/flow.js +12 -0
  120. package/dist/styles/flow.js.map +1 -0
  121. package/dist/styles/gap.d.ts +31 -0
  122. package/dist/styles/gap.js +37 -0
  123. package/dist/styles/gap.js.map +1 -0
  124. package/dist/styles/height.d.ts +17 -0
  125. package/dist/styles/height.js +20 -0
  126. package/dist/styles/height.js.map +1 -0
  127. package/dist/styles/index.d.ts +2 -0
  128. package/dist/styles/index.js +9 -0
  129. package/dist/styles/index.js.map +1 -0
  130. package/dist/styles/inset.d.ts +52 -0
  131. package/dist/styles/inset.js +150 -0
  132. package/dist/styles/inset.js.map +1 -0
  133. package/dist/styles/justify.d.ts +15 -0
  134. package/dist/styles/justify.js +14 -0
  135. package/dist/styles/justify.js.map +1 -0
  136. package/dist/styles/list.d.ts +16 -0
  137. package/dist/styles/list.js +98 -0
  138. package/dist/styles/list.js.map +1 -0
  139. package/dist/styles/margin.d.ts +24 -0
  140. package/dist/styles/margin.js +104 -0
  141. package/dist/styles/margin.js.map +1 -0
  142. package/dist/styles/outline.d.ts +29 -0
  143. package/dist/styles/outline.js +65 -0
  144. package/dist/styles/outline.js.map +1 -0
  145. package/dist/styles/padding.d.ts +24 -0
  146. package/dist/styles/padding.js +104 -0
  147. package/dist/styles/padding.js.map +1 -0
  148. package/dist/styles/predefined.d.ts +73 -0
  149. package/dist/styles/predefined.js +241 -0
  150. package/dist/styles/predefined.js.map +1 -0
  151. package/dist/styles/preset.d.ts +47 -0
  152. package/dist/styles/preset.js +126 -0
  153. package/dist/styles/preset.js.map +1 -0
  154. package/dist/styles/radius.d.ts +14 -0
  155. package/dist/styles/radius.js +51 -0
  156. package/dist/styles/radius.js.map +1 -0
  157. package/dist/styles/scrollbar.d.ts +21 -0
  158. package/dist/styles/scrollbar.js +112 -0
  159. package/dist/styles/scrollbar.js.map +1 -0
  160. package/dist/styles/shadow.d.ts +14 -0
  161. package/dist/styles/shadow.js +24 -0
  162. package/dist/styles/shadow.js.map +1 -0
  163. package/dist/styles/styledScrollbar.d.ts +47 -0
  164. package/dist/styles/styledScrollbar.js +38 -0
  165. package/dist/styles/styledScrollbar.js.map +1 -0
  166. package/dist/styles/transition.d.ts +14 -0
  167. package/dist/styles/transition.js +158 -0
  168. package/dist/styles/transition.js.map +1 -0
  169. package/dist/styles/types.d.ts +498 -0
  170. package/dist/styles/width.d.ts +17 -0
  171. package/dist/styles/width.js +20 -0
  172. package/dist/styles/width.js.map +1 -0
  173. package/dist/tasty.d.ts +982 -0
  174. package/dist/tasty.js +206 -0
  175. package/dist/tasty.js.map +1 -0
  176. package/dist/tokens/typography.d.ts +19 -0
  177. package/dist/tokens/typography.js +237 -0
  178. package/dist/tokens/typography.js.map +1 -0
  179. package/dist/types.d.ts +184 -0
  180. package/dist/utils/cache-wrapper.js +26 -0
  181. package/dist/utils/cache-wrapper.js.map +1 -0
  182. package/dist/utils/case-converter.js +8 -0
  183. package/dist/utils/case-converter.js.map +1 -0
  184. package/dist/utils/colors.d.ts +5 -0
  185. package/dist/utils/colors.js +9 -0
  186. package/dist/utils/colors.js.map +1 -0
  187. package/dist/utils/css-types.d.ts +7 -0
  188. package/dist/utils/dotize.d.ts +26 -0
  189. package/dist/utils/dotize.js +122 -0
  190. package/dist/utils/dotize.js.map +1 -0
  191. package/dist/utils/filter-base-props.d.ts +15 -0
  192. package/dist/utils/filter-base-props.js +45 -0
  193. package/dist/utils/filter-base-props.js.map +1 -0
  194. package/dist/utils/get-display-name.d.ts +7 -0
  195. package/dist/utils/get-display-name.js +10 -0
  196. package/dist/utils/get-display-name.js.map +1 -0
  197. package/dist/utils/hsl-to-rgb.js +38 -0
  198. package/dist/utils/hsl-to-rgb.js.map +1 -0
  199. package/dist/utils/is-dev-env.js +19 -0
  200. package/dist/utils/is-dev-env.js.map +1 -0
  201. package/dist/utils/is-valid-element-type.js +15 -0
  202. package/dist/utils/is-valid-element-type.js.map +1 -0
  203. package/dist/utils/merge-styles.d.ts +7 -0
  204. package/dist/utils/merge-styles.js +146 -0
  205. package/dist/utils/merge-styles.js.map +1 -0
  206. package/dist/utils/mod-attrs.d.ts +8 -0
  207. package/dist/utils/mod-attrs.js +21 -0
  208. package/dist/utils/mod-attrs.js.map +1 -0
  209. package/dist/utils/okhsl-to-rgb.js +296 -0
  210. package/dist/utils/okhsl-to-rgb.js.map +1 -0
  211. package/dist/utils/process-tokens.d.ts +31 -0
  212. package/dist/utils/process-tokens.js +171 -0
  213. package/dist/utils/process-tokens.js.map +1 -0
  214. package/dist/utils/resolve-recipes.d.ts +17 -0
  215. package/dist/utils/resolve-recipes.js +147 -0
  216. package/dist/utils/resolve-recipes.js.map +1 -0
  217. package/dist/utils/string.js +8 -0
  218. package/dist/utils/string.js.map +1 -0
  219. package/dist/utils/styles.d.ts +178 -0
  220. package/dist/utils/styles.js +590 -0
  221. package/dist/utils/styles.js.map +1 -0
  222. package/dist/utils/typography.d.ts +36 -0
  223. package/dist/utils/typography.js +53 -0
  224. package/dist/utils/typography.js.map +1 -0
  225. package/dist/utils/warnings.d.ts +16 -0
  226. package/dist/utils/warnings.js +16 -0
  227. package/dist/utils/warnings.js.map +1 -0
  228. package/dist/zero/babel.d.ts +108 -0
  229. package/dist/zero/babel.js +282 -0
  230. package/dist/zero/babel.js.map +1 -0
  231. package/dist/zero/css-writer.d.ts +45 -0
  232. package/dist/zero/css-writer.js +74 -0
  233. package/dist/zero/css-writer.js.map +1 -0
  234. package/dist/zero/extractor.d.ts +24 -0
  235. package/dist/zero/extractor.js +150 -0
  236. package/dist/zero/extractor.js.map +1 -0
  237. package/dist/zero/index.d.ts +3 -0
  238. package/dist/zero/index.js +4 -0
  239. package/dist/zero/next.d.ts +60 -0
  240. package/dist/zero/next.js +78 -0
  241. package/dist/zero/next.js.map +1 -0
  242. package/package.json +189 -0
  243. package/tasty.config.ts +14 -0
@@ -0,0 +1,844 @@
1
+ import { Lru } from "../parser/lru.js";
2
+ import { getConditionUniqueId, not } from "./conditions.js";
3
+
4
+ //#region src/pipeline/materialize.ts
5
+ /**
6
+ * CSS Materialization
7
+ *
8
+ * Converts condition trees into CSS selectors and at-rules.
9
+ * This is the final stage that produces actual CSS output.
10
+ */
11
+ const conditionCache = new Lru(3e3);
12
+ /**
13
+ * Convert a condition tree to CSS components
14
+ */
15
+ function conditionToCSS(node) {
16
+ const key = getConditionUniqueId(node);
17
+ const cached = conditionCache.get(key);
18
+ if (cached) return cached;
19
+ const result = conditionToCSSInner(node);
20
+ conditionCache.set(key, result);
21
+ return result;
22
+ }
23
+ function emptyVariant() {
24
+ return {
25
+ modifierConditions: [],
26
+ pseudoConditions: [],
27
+ ownConditions: [],
28
+ mediaConditions: [],
29
+ containerConditions: [],
30
+ supportsConditions: [],
31
+ rootConditions: [],
32
+ parentGroups: [],
33
+ startingStyle: false
34
+ };
35
+ }
36
+ function conditionToCSSInner(node) {
37
+ if (node.kind === "true") return {
38
+ variants: [emptyVariant()],
39
+ isImpossible: false
40
+ };
41
+ if (node.kind === "false") return {
42
+ variants: [],
43
+ isImpossible: true
44
+ };
45
+ if (node.kind === "state") return stateToCSS(node);
46
+ if (node.kind === "compound") if (node.operator === "AND") return andToCSS(node.children);
47
+ else return orToCSS(node.children);
48
+ return {
49
+ variants: [emptyVariant()],
50
+ isImpossible: false
51
+ };
52
+ }
53
+ /**
54
+ * Convert a state condition to CSS
55
+ */
56
+ function stateToCSS(state) {
57
+ switch (state.type) {
58
+ case "media": return {
59
+ variants: mediaToParsed(state).map((mediaCond) => {
60
+ const v = emptyVariant();
61
+ v.mediaConditions.push(mediaCond);
62
+ return v;
63
+ }),
64
+ isImpossible: false
65
+ };
66
+ case "root": return innerConditionToVariants(state.innerCondition, state.negated ?? false, "rootConditions");
67
+ case "parent": return parentConditionToVariants(state.innerCondition, state.negated ?? false, state.direct);
68
+ case "own": return innerConditionToVariants(state.innerCondition, state.negated ?? false, "ownConditions");
69
+ case "modifier": {
70
+ const v = emptyVariant();
71
+ v.modifierConditions.push(modifierToParsed(state));
72
+ return {
73
+ variants: [v],
74
+ isImpossible: false
75
+ };
76
+ }
77
+ case "pseudo": {
78
+ const v = emptyVariant();
79
+ v.pseudoConditions.push(pseudoToParsed(state));
80
+ return {
81
+ variants: [v],
82
+ isImpossible: false
83
+ };
84
+ }
85
+ case "container": {
86
+ const v = emptyVariant();
87
+ v.containerConditions.push(containerToParsed(state));
88
+ return {
89
+ variants: [v],
90
+ isImpossible: false
91
+ };
92
+ }
93
+ case "supports": {
94
+ const v = emptyVariant();
95
+ v.supportsConditions.push(supportsToParsed(state));
96
+ return {
97
+ variants: [v],
98
+ isImpossible: false
99
+ };
100
+ }
101
+ case "starting": {
102
+ const v = emptyVariant();
103
+ v.startingStyle = !state.negated;
104
+ return {
105
+ variants: [v],
106
+ isImpossible: false
107
+ };
108
+ }
109
+ }
110
+ }
111
+ /**
112
+ * Convert modifier condition to parsed structure
113
+ */
114
+ function modifierToParsed(state) {
115
+ return {
116
+ attribute: state.attribute,
117
+ value: state.value,
118
+ operator: state.operator,
119
+ negated: state.negated ?? false
120
+ };
121
+ }
122
+ /**
123
+ * Convert parsed modifier to CSS selector string (for final output)
124
+ */
125
+ function modifierToCSS(mod) {
126
+ let selector;
127
+ if (mod.value !== void 0) {
128
+ const op = mod.operator || "=";
129
+ selector = `[${mod.attribute}${op}"${mod.value}"]`;
130
+ } else selector = `[${mod.attribute}]`;
131
+ if (mod.negated) return `:not(${selector})`;
132
+ return selector;
133
+ }
134
+ /**
135
+ * Convert pseudo condition to parsed structure
136
+ */
137
+ function pseudoToParsed(state) {
138
+ return {
139
+ pseudo: state.pseudo,
140
+ negated: state.negated ?? false
141
+ };
142
+ }
143
+ /**
144
+ * Convert parsed pseudo to CSS selector string (for final output)
145
+ */
146
+ function pseudoToCSS(pseudo) {
147
+ if (pseudo.negated) {
148
+ if (pseudo.pseudo.startsWith(":not(")) return pseudo.pseudo.slice(5, -1);
149
+ return `:not(${pseudo.pseudo})`;
150
+ }
151
+ return pseudo.pseudo;
152
+ }
153
+ /**
154
+ * Convert media condition to parsed structure(s)
155
+ * Returns an array because negated ranges produce OR branches (two separate conditions)
156
+ */
157
+ function mediaToParsed(state) {
158
+ if (state.subtype === "type") {
159
+ const mediaType = state.mediaType || "all";
160
+ return [{
161
+ subtype: "type",
162
+ negated: state.negated ?? false,
163
+ condition: mediaType,
164
+ mediaType: state.mediaType
165
+ }];
166
+ } else if (state.subtype === "feature") {
167
+ let condition;
168
+ if (state.featureValue) condition = `(${state.feature}: ${state.featureValue})`;
169
+ else condition = `(${state.feature})`;
170
+ return [{
171
+ subtype: "feature",
172
+ negated: state.negated ?? false,
173
+ condition,
174
+ feature: state.feature,
175
+ featureValue: state.featureValue
176
+ }];
177
+ } else return dimensionToMediaParsed(state.dimension || "width", state.lowerBound, state.upperBound, state.negated ?? false);
178
+ }
179
+ /**
180
+ * Convert dimension bounds to parsed media condition(s)
181
+ * Uses CSS Media Queries Level 4 `not (condition)` syntax for negation.
182
+ */
183
+ function dimensionToMediaParsed(dimension, lowerBound, upperBound, negated) {
184
+ let condition;
185
+ if (lowerBound && upperBound) {
186
+ const lowerOp = lowerBound.inclusive ? "<=" : "<";
187
+ const upperOp = upperBound.inclusive ? "<=" : "<";
188
+ condition = `(${lowerBound.value} ${lowerOp} ${dimension} ${upperOp} ${upperBound.value})`;
189
+ } else if (upperBound) condition = `(${dimension} ${upperBound.inclusive ? "<=" : "<"} ${upperBound.value})`;
190
+ else if (lowerBound) condition = `(${dimension} ${lowerBound.inclusive ? ">=" : ">"} ${lowerBound.value})`;
191
+ else condition = `(${dimension})`;
192
+ return [{
193
+ subtype: "dimension",
194
+ negated: negated ?? false,
195
+ condition,
196
+ dimension,
197
+ lowerBound,
198
+ upperBound
199
+ }];
200
+ }
201
+ /**
202
+ * Convert container condition to parsed structure
203
+ * This enables structured analysis for contradiction detection and condition combining
204
+ */
205
+ function containerToParsed(state) {
206
+ let condition;
207
+ if (state.subtype === "style") if (state.propertyValue) condition = `style(--${state.property}: ${state.propertyValue})`;
208
+ else condition = `style(--${state.property})`;
209
+ else if (state.subtype === "raw") condition = state.rawCondition;
210
+ else condition = dimensionToContainerCondition(state.dimension || "width", state.lowerBound, state.upperBound);
211
+ return {
212
+ name: state.containerName,
213
+ condition,
214
+ negated: state.negated ?? false,
215
+ subtype: state.subtype,
216
+ property: state.property,
217
+ propertyValue: state.propertyValue
218
+ };
219
+ }
220
+ /**
221
+ * Convert dimension bounds to container query condition (single string)
222
+ * Container queries support "not (condition)", so no need to invert manually
223
+ */
224
+ function dimensionToContainerCondition(dimension, lowerBound, upperBound) {
225
+ if (lowerBound && upperBound) {
226
+ const lowerOp = lowerBound.inclusive ? "<=" : "<";
227
+ const upperOp = upperBound.inclusive ? "<=" : "<";
228
+ return `(${lowerBound.value} ${lowerOp} ${dimension} ${upperOp} ${upperBound.value})`;
229
+ } else if (upperBound) return `(${dimension} ${upperBound.inclusive ? "<=" : "<"} ${upperBound.value})`;
230
+ else if (lowerBound) return `(${dimension} ${lowerBound.inclusive ? ">=" : ">"} ${lowerBound.value})`;
231
+ return "(width)";
232
+ }
233
+ /**
234
+ * Convert supports condition to parsed structure
235
+ */
236
+ function supportsToParsed(state) {
237
+ return {
238
+ subtype: state.subtype,
239
+ condition: state.condition,
240
+ negated: state.negated ?? false
241
+ };
242
+ }
243
+ /**
244
+ * Collect all modifier and pseudo conditions from a variant as a flat array.
245
+ */
246
+ function collectSelectorConditions(variant) {
247
+ return [...variant.modifierConditions, ...variant.pseudoConditions];
248
+ }
249
+ /**
250
+ * Convert an inner condition tree into SelectorVariants.
251
+ * Each inner OR branch becomes a separate variant, preserving disjunction.
252
+ * Shared by @root() and @own().
253
+ */
254
+ function innerConditionToVariants(innerCondition, negated, target) {
255
+ const innerCSS = conditionToCSS(negated ? not(innerCondition) : innerCondition);
256
+ if (innerCSS.isImpossible || innerCSS.variants.length === 0) return {
257
+ variants: [],
258
+ isImpossible: true
259
+ };
260
+ const variants = [];
261
+ for (const innerVariant of innerCSS.variants) {
262
+ const conditions = collectSelectorConditions(innerVariant);
263
+ if (conditions.length > 0) {
264
+ const v = emptyVariant();
265
+ v[target].push(...conditions);
266
+ variants.push(v);
267
+ }
268
+ }
269
+ if (variants.length === 0) return {
270
+ variants: [emptyVariant()],
271
+ isImpossible: false
272
+ };
273
+ return {
274
+ variants,
275
+ isImpossible: false
276
+ };
277
+ }
278
+ /**
279
+ * Convert a @parent() inner condition into SelectorVariants with ParentGroups.
280
+ *
281
+ * Positive: each inner OR branch becomes a separate variant with one :is() group.
282
+ * Negated: !(A | B) = !A & !B — all branches become :not() groups collected
283
+ * into a single variant so they produce :not([a] *):not([b] *) on one element.
284
+ */
285
+ function parentConditionToVariants(innerCondition, negated, direct) {
286
+ const innerCSS = conditionToCSS(innerCondition);
287
+ if (innerCSS.isImpossible || innerCSS.variants.length === 0) return {
288
+ variants: [],
289
+ isImpossible: true
290
+ };
291
+ if (negated) {
292
+ const v = emptyVariant();
293
+ for (const innerVariant of innerCSS.variants) {
294
+ const conditions = collectSelectorConditions(innerVariant);
295
+ if (conditions.length > 0) v.parentGroups.push({
296
+ conditions,
297
+ direct,
298
+ negated: true
299
+ });
300
+ }
301
+ if (v.parentGroups.length === 0) return {
302
+ variants: [emptyVariant()],
303
+ isImpossible: false
304
+ };
305
+ return {
306
+ variants: [v],
307
+ isImpossible: false
308
+ };
309
+ }
310
+ const variants = [];
311
+ for (const innerVariant of innerCSS.variants) {
312
+ const conditions = collectSelectorConditions(innerVariant);
313
+ if (conditions.length > 0) {
314
+ const v = emptyVariant();
315
+ v.parentGroups.push({
316
+ conditions,
317
+ direct,
318
+ negated: false
319
+ });
320
+ variants.push(v);
321
+ }
322
+ }
323
+ if (variants.length === 0) return {
324
+ variants: [emptyVariant()],
325
+ isImpossible: false
326
+ };
327
+ return {
328
+ variants,
329
+ isImpossible: false
330
+ };
331
+ }
332
+ /**
333
+ * Convert parsed root conditions to CSS selector prefix (for final output)
334
+ */
335
+ function rootConditionsToCSS(roots) {
336
+ if (roots.length === 0) return void 0;
337
+ let prefix = ":root";
338
+ for (const cond of roots) prefix += selectorConditionToCSS(cond);
339
+ return prefix;
340
+ }
341
+ /**
342
+ * Convert parent groups to CSS selector fragments (for final output).
343
+ * Each group produces its own :is() wrapper.
344
+ */
345
+ function parentGroupsToCSS(groups) {
346
+ let result = "";
347
+ for (const group of groups) {
348
+ const combinator = group.direct ? " > *" : " *";
349
+ let parts = "";
350
+ for (const cond of group.conditions) parts += selectorConditionToCSS(cond);
351
+ const wrapper = group.negated ? ":not" : ":is";
352
+ result += `${wrapper}(${parts}${combinator})`;
353
+ }
354
+ return result;
355
+ }
356
+ /**
357
+ * Convert a modifier or pseudo condition to a CSS selector fragment
358
+ */
359
+ function selectorConditionToCSS(cond) {
360
+ if ("attribute" in cond) return modifierToCSS(cond);
361
+ return pseudoToCSS(cond);
362
+ }
363
+ /**
364
+ * Get unique key for a modifier condition
365
+ */
366
+ function getModifierKey(mod) {
367
+ const base = mod.value ? `${mod.attribute}${mod.operator || "="}${mod.value}` : mod.attribute;
368
+ return mod.negated ? `!${base}` : base;
369
+ }
370
+ /**
371
+ * Get unique key for a pseudo condition
372
+ */
373
+ function getPseudoKey(pseudo) {
374
+ return pseudo.negated ? `!${pseudo.pseudo}` : pseudo.pseudo;
375
+ }
376
+ /**
377
+ * Get unique key for any selector condition (modifier or pseudo)
378
+ */
379
+ function getSelectorConditionKey(cond) {
380
+ return "attribute" in cond ? `mod:${getModifierKey(cond)}` : `pseudo:${getPseudoKey(cond)}`;
381
+ }
382
+ /**
383
+ * Deduplicate selector conditions (modifiers or pseudos).
384
+ * Shared by root, parent, and own conditions.
385
+ */
386
+ function dedupeSelectorConditions(conditions) {
387
+ const seen = /* @__PURE__ */ new Set();
388
+ let result = [];
389
+ for (const c of conditions) {
390
+ const key = getSelectorConditionKey(c);
391
+ if (!seen.has(key)) {
392
+ seen.add(key);
393
+ result.push(c);
394
+ }
395
+ }
396
+ const negatedBooleanAttrs = /* @__PURE__ */ new Set();
397
+ const positiveExactValuesByAttr = /* @__PURE__ */ new Map();
398
+ for (const c of result) {
399
+ if (!("attribute" in c)) continue;
400
+ if (c.negated && c.value === void 0) negatedBooleanAttrs.add(c.attribute);
401
+ const op = c.operator ?? "=";
402
+ if (!c.negated && c.value !== void 0 && op === "=") {
403
+ let values = positiveExactValuesByAttr.get(c.attribute);
404
+ if (!values) {
405
+ values = /* @__PURE__ */ new Set();
406
+ positiveExactValuesByAttr.set(c.attribute, values);
407
+ }
408
+ values.add(c.value);
409
+ }
410
+ }
411
+ result = result.filter((c) => {
412
+ if (!("attribute" in c) || !c.negated || c.value === void 0) return true;
413
+ if (negatedBooleanAttrs.has(c.attribute)) return false;
414
+ if ((c.operator ?? "=") !== "=") return true;
415
+ const positiveValues = positiveExactValuesByAttr.get(c.attribute);
416
+ if (positiveValues !== void 0 && positiveValues.size === 1 && !positiveValues.has(c.value)) return false;
417
+ return true;
418
+ });
419
+ return result;
420
+ }
421
+ /**
422
+ * Check for modifier contradiction: same attribute with opposite negation
423
+ */
424
+ function hasModifierContradiction(conditions) {
425
+ const byKey = /* @__PURE__ */ new Map();
426
+ for (const mod of conditions) {
427
+ const baseKey = mod.value ? `${mod.attribute}${mod.operator || "="}${mod.value}` : mod.attribute;
428
+ const existing = byKey.get(baseKey);
429
+ if (existing !== void 0 && existing !== !mod.negated) return true;
430
+ byKey.set(baseKey, !mod.negated);
431
+ }
432
+ return false;
433
+ }
434
+ /**
435
+ * Check for pseudo contradiction: same pseudo with opposite negation
436
+ */
437
+ function hasPseudoContradiction(conditions) {
438
+ const byKey = /* @__PURE__ */ new Map();
439
+ for (const pseudo of conditions) {
440
+ const existing = byKey.get(pseudo.pseudo);
441
+ if (existing !== void 0 && existing !== !pseudo.negated) return true;
442
+ byKey.set(pseudo.pseudo, !pseudo.negated);
443
+ }
444
+ return false;
445
+ }
446
+ /**
447
+ * Check for selector condition contradiction (modifier or pseudo with opposite negation).
448
+ * Shared by root, parent, and own conditions.
449
+ */
450
+ function hasSelectorConditionContradiction(conditions) {
451
+ const modifiers = [];
452
+ const pseudos = [];
453
+ for (const c of conditions) if ("attribute" in c) modifiers.push(c);
454
+ else pseudos.push(c);
455
+ return hasModifierContradiction(modifiers) || hasPseudoContradiction(pseudos);
456
+ }
457
+ /**
458
+ * Check for parent group contradiction: same target (direct + conditions)
459
+ * with opposite negation. E.g. :not([data-hovered] *) and :is([data-hovered] *)
460
+ * in the same variant is impossible.
461
+ */
462
+ function hasParentGroupContradiction(groups) {
463
+ const byBaseKey = /* @__PURE__ */ new Map();
464
+ for (const g of groups) {
465
+ const baseKey = `${g.direct ? ">" : ""}(${g.conditions.map(getSelectorConditionKey).sort().join(",")})`;
466
+ const existing = byBaseKey.get(baseKey);
467
+ if (existing !== void 0 && existing !== !g.negated) return true;
468
+ byBaseKey.set(baseKey, !g.negated);
469
+ }
470
+ return false;
471
+ }
472
+ /**
473
+ * Merge two selector variants (AND operation)
474
+ * Deduplicates conditions and checks for contradictions
475
+ */
476
+ function mergeVariants(a, b) {
477
+ const mergedMedia = dedupeMediaConditions([...a.mediaConditions, ...b.mediaConditions]);
478
+ if (hasMediaContradiction(mergedMedia)) return null;
479
+ const mergedRoots = dedupeSelectorConditions([...a.rootConditions, ...b.rootConditions]);
480
+ if (hasSelectorConditionContradiction(mergedRoots)) return null;
481
+ const mergedModifiers = dedupeSelectorConditions([...a.modifierConditions, ...b.modifierConditions]);
482
+ const mergedPseudos = dedupeSelectorConditions([...a.pseudoConditions, ...b.pseudoConditions]);
483
+ if (hasSelectorConditionContradiction([...mergedModifiers, ...mergedPseudos])) return null;
484
+ const mergedParentGroups = [...a.parentGroups, ...b.parentGroups];
485
+ if (hasParentGroupContradiction(mergedParentGroups)) return null;
486
+ const mergedOwn = dedupeSelectorConditions([...a.ownConditions, ...b.ownConditions]);
487
+ if (hasSelectorConditionContradiction(mergedOwn)) return null;
488
+ const mergedContainers = dedupeContainerConditions([...a.containerConditions, ...b.containerConditions]);
489
+ if (hasContainerStyleContradiction(mergedContainers)) return null;
490
+ const mergedSupports = dedupeSupportsConditions([...a.supportsConditions, ...b.supportsConditions]);
491
+ if (hasSupportsContradiction(mergedSupports)) return null;
492
+ return {
493
+ modifierConditions: mergedModifiers,
494
+ pseudoConditions: mergedPseudos,
495
+ ownConditions: mergedOwn,
496
+ mediaConditions: mergedMedia,
497
+ containerConditions: mergedContainers,
498
+ supportsConditions: mergedSupports,
499
+ rootConditions: mergedRoots,
500
+ parentGroups: mergedParentGroups,
501
+ startingStyle: a.startingStyle || b.startingStyle
502
+ };
503
+ }
504
+ /**
505
+ * Generic deduplication by a key extraction function.
506
+ * Preserves insertion order, keeping the first occurrence of each key.
507
+ */
508
+ function dedupeByKey(items, getKey) {
509
+ const seen = /* @__PURE__ */ new Set();
510
+ const result = [];
511
+ for (const item of items) {
512
+ const key = getKey(item);
513
+ if (!seen.has(key)) {
514
+ seen.add(key);
515
+ result.push(item);
516
+ }
517
+ }
518
+ return result;
519
+ }
520
+ function dedupeMediaConditions(conditions) {
521
+ return dedupeByKey(conditions, (c) => `${c.subtype}|${c.condition}|${c.negated}`);
522
+ }
523
+ function dedupeContainerConditions(conditions) {
524
+ return dedupeByKey(conditions, (c) => `${c.name ?? ""}|${c.condition}|${c.negated}`);
525
+ }
526
+ function dedupeSupportsConditions(conditions) {
527
+ return dedupeByKey(conditions, (c) => `${c.subtype}|${c.condition}|${c.negated}`);
528
+ }
529
+ /**
530
+ * Check if supports conditions contain contradictions
531
+ * e.g., @supports(display: grid) AND NOT @supports(display: grid)
532
+ */
533
+ function hasSupportsContradiction(conditions) {
534
+ const conditionMap = /* @__PURE__ */ new Map();
535
+ for (const cond of conditions) {
536
+ const key = `${cond.subtype}|${cond.condition}`;
537
+ const existing = conditionMap.get(key);
538
+ if (existing !== void 0 && existing !== !cond.negated) return true;
539
+ conditionMap.set(key, !cond.negated);
540
+ }
541
+ return false;
542
+ }
543
+ /**
544
+ * Check if a set of media conditions contains contradictions
545
+ * e.g., (prefers-color-scheme: light) AND NOT (prefers-color-scheme: light)
546
+ * or (width >= 900px) AND (width < 600px)
547
+ *
548
+ * Uses parsed media conditions for efficient analysis without regex parsing.
549
+ */
550
+ function hasMediaContradiction(conditions) {
551
+ const featureConditions = /* @__PURE__ */ new Map();
552
+ const typeConditions = /* @__PURE__ */ new Map();
553
+ const dimensionConditions = /* @__PURE__ */ new Map();
554
+ const dimensionsByDim = /* @__PURE__ */ new Map();
555
+ for (const cond of conditions) if (cond.subtype === "type") {
556
+ const key = cond.mediaType || "all";
557
+ const existing = typeConditions.get(key);
558
+ if (existing !== void 0 && existing !== !cond.negated) return true;
559
+ typeConditions.set(key, !cond.negated);
560
+ } else if (cond.subtype === "feature") {
561
+ const key = cond.condition;
562
+ const existing = featureConditions.get(key);
563
+ if (existing !== void 0 && existing !== !cond.negated) return true;
564
+ featureConditions.set(key, !cond.negated);
565
+ } else if (cond.subtype === "dimension") {
566
+ const condKey = cond.condition;
567
+ const existing = dimensionConditions.get(condKey);
568
+ if (existing !== void 0 && existing !== !cond.negated) return true;
569
+ dimensionConditions.set(condKey, !cond.negated);
570
+ if (!cond.negated) {
571
+ const dim = cond.dimension || "width";
572
+ let bounds = dimensionsByDim.get(dim);
573
+ if (!bounds) {
574
+ bounds = {
575
+ lowerBound: null,
576
+ upperBound: null
577
+ };
578
+ dimensionsByDim.set(dim, bounds);
579
+ }
580
+ if (cond.lowerBound?.valueNumeric != null) {
581
+ const value = cond.lowerBound.valueNumeric;
582
+ if (bounds.lowerBound === null || value > bounds.lowerBound) bounds.lowerBound = value;
583
+ }
584
+ if (cond.upperBound?.valueNumeric != null) {
585
+ const value = cond.upperBound.valueNumeric;
586
+ if (bounds.upperBound === null || value < bounds.upperBound) bounds.upperBound = value;
587
+ }
588
+ if (bounds.lowerBound !== null && bounds.upperBound !== null && bounds.lowerBound >= bounds.upperBound) return true;
589
+ }
590
+ }
591
+ return false;
592
+ }
593
+ /**
594
+ * Check if container conditions contain contradictions in style queries
595
+ * e.g., style(--variant: danger) and style(--variant: success) together
596
+ * Same property with different values = always false
597
+ *
598
+ * Uses parsed container conditions for efficient analysis without regex parsing.
599
+ */
600
+ function hasContainerStyleContradiction(conditions) {
601
+ const styleQueries = /* @__PURE__ */ new Map();
602
+ for (const cond of conditions) {
603
+ if (cond.subtype !== "style" || !cond.property) continue;
604
+ const property = cond.property;
605
+ const value = cond.propertyValue;
606
+ if (!styleQueries.has(property)) styleQueries.set(property, {
607
+ hasExistence: false,
608
+ values: /* @__PURE__ */ new Set(),
609
+ hasNegatedExistence: false
610
+ });
611
+ const entry = styleQueries.get(property);
612
+ if (cond.negated) {
613
+ if (value === void 0) entry.hasNegatedExistence = true;
614
+ } else if (value === void 0) entry.hasExistence = true;
615
+ else entry.values.add(value);
616
+ }
617
+ for (const [, entry] of styleQueries) {
618
+ if (entry.hasExistence && entry.hasNegatedExistence) return true;
619
+ if (entry.values.size > 1) return true;
620
+ if (entry.hasNegatedExistence && entry.values.size > 0) return true;
621
+ }
622
+ return false;
623
+ }
624
+ const variantKeyCache = /* @__PURE__ */ new WeakMap();
625
+ /**
626
+ * Get a unique key for a variant (for deduplication).
627
+ * Cached via WeakMap since variants are compared multiple times during
628
+ * deduplication and sorting.
629
+ */
630
+ function getVariantKey(v) {
631
+ const cached = variantKeyCache.get(v);
632
+ if (cached !== void 0) return cached;
633
+ const modifierKey = v.modifierConditions.map(getModifierKey).sort().join("|");
634
+ const pseudoKey = v.pseudoConditions.map(getPseudoKey).sort().join("|");
635
+ const ownKey = v.ownConditions.map(getSelectorConditionKey).sort().join("|");
636
+ const containerKey = v.containerConditions.map((c) => `${c.name ?? ""}:${c.negated ? "!" : ""}${c.condition}`).sort().join("|");
637
+ const key = [
638
+ modifierKey,
639
+ pseudoKey,
640
+ ownKey,
641
+ v.mediaConditions.map((c) => `${c.subtype}:${c.negated ? "!" : ""}${c.condition}`).sort().join("|"),
642
+ containerKey,
643
+ v.supportsConditions.map((c) => `${c.subtype}:${c.negated ? "!" : ""}${c.condition}`).sort().join("|"),
644
+ v.rootConditions.map(getSelectorConditionKey).sort().join("|"),
645
+ v.parentGroups.map(getParentGroupKey).sort().join("|"),
646
+ v.startingStyle ? "1" : "0"
647
+ ].join("###");
648
+ variantKeyCache.set(v, key);
649
+ return key;
650
+ }
651
+ /**
652
+ * Check if variant A is a superset of variant B (A is more restrictive)
653
+ *
654
+ * If A has all of B's conditions plus more, then A is redundant
655
+ * because B already covers the same cases (and more).
656
+ *
657
+ * Example:
658
+ * A: :not([size=large]):not([size=medium]):not([size=small])
659
+ * B: :not([size=large])
660
+ * A is a superset of B, so A is redundant when B exists.
661
+ */
662
+ function isVariantSuperset(a, b) {
663
+ if (a.startingStyle !== b.startingStyle) return false;
664
+ if (!isSelectorConditionsSuperset(a.rootConditions, b.rootConditions)) return false;
665
+ if (!isMediaConditionsSuperset(a.mediaConditions, b.mediaConditions)) return false;
666
+ if (!isContainerConditionsSuperset(a.containerConditions, b.containerConditions)) return false;
667
+ if (!isSupportsConditionsSuperset(a.supportsConditions, b.supportsConditions)) return false;
668
+ if (!isModifierConditionsSuperset(a.modifierConditions, b.modifierConditions)) return false;
669
+ if (!isPseudoConditionsSuperset(a.pseudoConditions, b.pseudoConditions)) return false;
670
+ if (!isSelectorConditionsSuperset(a.ownConditions, b.ownConditions)) return false;
671
+ if (!isParentGroupsSuperset(a.parentGroups, b.parentGroups)) return false;
672
+ const parentConditionCount = (groups) => groups.reduce((sum, g) => sum + g.conditions.length, 0);
673
+ return a.mediaConditions.length + a.containerConditions.length + a.supportsConditions.length + a.modifierConditions.length + a.pseudoConditions.length + a.rootConditions.length + parentConditionCount(a.parentGroups) + a.ownConditions.length > b.mediaConditions.length + b.containerConditions.length + b.supportsConditions.length + b.modifierConditions.length + b.pseudoConditions.length + b.rootConditions.length + parentConditionCount(b.parentGroups) + b.ownConditions.length;
674
+ }
675
+ /**
676
+ * Generic superset check: true if every item in B has a matching key in A.
677
+ */
678
+ function isConditionsSuperset(a, b, getKey) {
679
+ const aKeys = new Set(a.map(getKey));
680
+ return b.every((c) => aKeys.has(getKey(c)));
681
+ }
682
+ function isMediaConditionsSuperset(a, b) {
683
+ return isConditionsSuperset(a, b, (c) => `${c.subtype}|${c.condition}|${c.negated}`);
684
+ }
685
+ function isContainerConditionsSuperset(a, b) {
686
+ return isConditionsSuperset(a, b, (c) => `${c.name ?? ""}|${c.condition}|${c.negated}`);
687
+ }
688
+ function isSupportsConditionsSuperset(a, b) {
689
+ return isConditionsSuperset(a, b, (c) => `${c.subtype}|${c.condition}|${c.negated}`);
690
+ }
691
+ function isModifierConditionsSuperset(a, b) {
692
+ return isConditionsSuperset(a, b, getModifierKey);
693
+ }
694
+ function isPseudoConditionsSuperset(a, b) {
695
+ return isConditionsSuperset(a, b, getPseudoKey);
696
+ }
697
+ function isSelectorConditionsSuperset(a, b) {
698
+ return isConditionsSuperset(a, b, getSelectorConditionKey);
699
+ }
700
+ /**
701
+ * Check if parent groups A is a superset of B.
702
+ * Each group in B must have a matching group in A.
703
+ */
704
+ function isParentGroupsSuperset(a, b) {
705
+ if (a.length < b.length) return false;
706
+ return isConditionsSuperset(a, b, getParentGroupKey);
707
+ }
708
+ function getParentGroupKey(g) {
709
+ return `${g.negated ? "!" : ""}${g.direct ? ">" : ""}(${g.conditions.map(getSelectorConditionKey).sort().join(",")})`;
710
+ }
711
+ /**
712
+ * Deduplicate variants
713
+ *
714
+ * Removes:
715
+ * 1. Exact duplicates (same key)
716
+ * 2. Superset variants (more restrictive selectors that are redundant)
717
+ */
718
+ function dedupeVariants(variants) {
719
+ const seen = /* @__PURE__ */ new Set();
720
+ const result = [];
721
+ for (const v of variants) {
722
+ const key = getVariantKey(v);
723
+ if (!seen.has(key)) {
724
+ seen.add(key);
725
+ result.push(v);
726
+ }
727
+ }
728
+ const variantConditionCount = (v) => v.modifierConditions.length + v.pseudoConditions.length + v.ownConditions.length + v.mediaConditions.length + v.containerConditions.length + v.supportsConditions.length + v.rootConditions.length + v.parentGroups.reduce((sum, g) => sum + g.conditions.length, 0);
729
+ result.sort((a, b) => variantConditionCount(a) - variantConditionCount(b));
730
+ const filtered = [];
731
+ for (const candidate of result) {
732
+ let isRedundant = false;
733
+ for (const kept of filtered) if (isVariantSuperset(candidate, kept)) {
734
+ isRedundant = true;
735
+ break;
736
+ }
737
+ if (!isRedundant) filtered.push(candidate);
738
+ }
739
+ return filtered;
740
+ }
741
+ /**
742
+ * Combine AND conditions into CSS
743
+ *
744
+ * AND of conditions means cartesian product of variants:
745
+ * (A1 | A2) & (B1 | B2) = A1&B1 | A1&B2 | A2&B1 | A2&B2
746
+ *
747
+ * Variants that result in contradictions (e.g., conflicting media rules)
748
+ * are filtered out.
749
+ */
750
+ function andToCSS(children) {
751
+ let currentVariants = [emptyVariant()];
752
+ for (const child of children) {
753
+ const childCSS = conditionToCSSInner(child);
754
+ if (childCSS.isImpossible || childCSS.variants.length === 0) return {
755
+ variants: [],
756
+ isImpossible: true
757
+ };
758
+ const newVariants = [];
759
+ for (const current of currentVariants) for (const childVariant of childCSS.variants) {
760
+ const merged = mergeVariants(current, childVariant);
761
+ if (merged !== null) newVariants.push(merged);
762
+ }
763
+ if (newVariants.length === 0) return {
764
+ variants: [],
765
+ isImpossible: true
766
+ };
767
+ currentVariants = dedupeVariants(newVariants);
768
+ }
769
+ return {
770
+ variants: currentVariants,
771
+ isImpossible: false
772
+ };
773
+ }
774
+ /**
775
+ * Combine OR conditions into CSS
776
+ *
777
+ * OR in CSS means multiple selector variants (DNF).
778
+ * Each variant becomes a separate selector in the comma-separated list,
779
+ * or multiple CSS rules if they have different at-rules.
780
+ *
781
+ * Note: OR exclusivity is handled at the pipeline level (expandOrConditions),
782
+ * so here we just collect all variants. Any remaining ORs in the condition
783
+ * tree (e.g., from De Morgan expansion) are handled as simple alternatives.
784
+ */
785
+ function orToCSS(children) {
786
+ const allVariants = [];
787
+ for (const child of children) {
788
+ const childCSS = conditionToCSSInner(child);
789
+ if (childCSS.isImpossible) continue;
790
+ allVariants.push(...childCSS.variants);
791
+ }
792
+ if (allVariants.length === 0) return {
793
+ variants: [],
794
+ isImpossible: true
795
+ };
796
+ return {
797
+ variants: dedupeVariants(allVariants),
798
+ isImpossible: false
799
+ };
800
+ }
801
+ /**
802
+ * Build at-rules array from a variant
803
+ */
804
+ function buildAtRulesFromVariant(variant) {
805
+ const atRules = [];
806
+ if (variant.mediaConditions.length > 0) {
807
+ const conditionParts = variant.mediaConditions.map((c) => {
808
+ if (c.subtype === "type") return c.negated ? `not ${c.condition}` : c.condition;
809
+ else return c.negated ? `(not ${c.condition})` : c.condition;
810
+ });
811
+ atRules.push(`@media ${conditionParts.join(" and ")}`);
812
+ }
813
+ if (variant.containerConditions.length > 0) {
814
+ const byName = /* @__PURE__ */ new Map();
815
+ for (const cond of variant.containerConditions) {
816
+ const group = byName.get(cond.name) || [];
817
+ group.push(cond);
818
+ byName.set(cond.name, group);
819
+ }
820
+ for (const [name, conditions] of byName) {
821
+ const conditionParts = conditions.map((c) => c.negated ? `(not ${c.condition})` : c.condition);
822
+ const namePrefix = name ? `${name} ` : "";
823
+ atRules.push(`@container ${namePrefix}${conditionParts.join(" and ")}`);
824
+ }
825
+ }
826
+ if (variant.supportsConditions.length > 0) {
827
+ const conditionParts = variant.supportsConditions.map((c) => {
828
+ if (c.subtype === "selector") {
829
+ const selectorCond = `selector(${c.condition})`;
830
+ return c.negated ? `(not ${selectorCond})` : selectorCond;
831
+ } else {
832
+ const featureCond = `(${c.condition})`;
833
+ return c.negated ? `(not ${featureCond})` : featureCond;
834
+ }
835
+ });
836
+ atRules.push(`@supports ${conditionParts.join(" and ")}`);
837
+ }
838
+ if (variant.startingStyle) atRules.push("@starting-style");
839
+ return atRules;
840
+ }
841
+
842
+ //#endregion
843
+ export { buildAtRulesFromVariant, conditionToCSS, modifierToCSS, parentGroupsToCSS, pseudoToCSS, rootConditionsToCSS, selectorConditionToCSS };
844
+ //# sourceMappingURL=materialize.js.map