@weapp-tailwindcss/postcss 3.3.5 → 3.3.6

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 (107) hide show
  1. package/README.md +10 -0
  2. package/README.zh-CN.md +6 -0
  3. package/dist/compat/index.d.ts +57 -0
  4. package/dist/compat/legacy-css/source-cleanup.d.ts +2 -0
  5. package/dist/compat/mini-program-css/output-import-shell.d.ts +8 -0
  6. package/dist/compat/native/compile.d.ts +2 -0
  7. package/dist/compat/native/properties.d.ts +15 -0
  8. package/dist/compat/native/selectors.d.ts +8 -0
  9. package/dist/compat/native/types.d.ts +23 -0
  10. package/dist/compat/processed-css/cleanup.d.ts +4 -0
  11. package/dist/compat/processed-css/composition.d.ts +6 -0
  12. package/dist/compat/processed-css/entry-directives.d.ts +1 -0
  13. package/dist/compat/processed-css/imports.d.ts +8 -0
  14. package/dist/compat/scoped-css/cleanup.d.ts +4 -0
  15. package/dist/compat/scoped-css/coverage.d.ts +10 -0
  16. package/dist/compat/scoped-css/covered-rules.d.ts +4 -0
  17. package/dist/compat/scoped-css/predicates.d.ts +13 -0
  18. package/dist/compat/tailwind-directive-injection.d.ts +8 -0
  19. package/dist/compat/tailwindcss-v4/generated-output.d.ts +5 -0
  20. package/dist/compat/tailwindcss-v4/package-import-statements.d.ts +1 -0
  21. package/dist/compat/tailwindcss-v4/preflight-imports.d.ts +3 -0
  22. package/dist/compat/tailwindcss-v4/rpx-candidates.d.ts +6 -0
  23. package/dist/compat/tailwindcss-v4/theme-injection.d.ts +1 -0
  24. package/dist/compat/tailwindcss-v4/theme-source.d.ts +5 -0
  25. package/dist/compat/tailwindcss-v4/user-css/apply-only.d.ts +6 -0
  26. package/dist/compat/tailwindcss-v4/user-css/apply-reference.d.ts +4 -0
  27. package/dist/compat/tailwindcss-v4/user-css/at-rules.d.ts +3 -0
  28. package/dist/compat/tailwindcss-v4/user-css/class-selectors.d.ts +2 -0
  29. package/dist/compat/tailwindcss-v4/user-css/directives/entry-source.d.ts +9 -0
  30. package/dist/compat/tailwindcss-v4/user-css/directives/fallback.d.ts +11 -0
  31. package/dist/compat/tailwindcss-v4/user-css/directives/index.d.ts +2 -0
  32. package/dist/compat/tailwindcss-v4/user-css/directives/shared.d.ts +26 -0
  33. package/dist/compat/tailwindcss-v4/user-css/framework-composition.d.ts +2 -0
  34. package/dist/compat/tailwindcss-v4/user-css/framework-source.d.ts +1 -0
  35. package/dist/compat/tailwindcss-v4/user-css/generated-cleanup.d.ts +7 -0
  36. package/dist/compat/tailwindcss-v4/user-css/identity.d.ts +1 -0
  37. package/dist/compat/tailwindcss-v4/user-css/markers.d.ts +32 -0
  38. package/dist/compat/tailwindcss-v4/user-css/rule-deduplication.d.ts +1 -0
  39. package/dist/compat/tailwindcss-v4/user-css/scoped-rules.d.ts +4 -0
  40. package/dist/compat/tailwindcss-v4/user-css/source-fragments.d.ts +15 -0
  41. package/dist/compat/tailwindcss-v4/user-css/transform.d.ts +14 -0
  42. package/dist/compat/tailwindcss-v4/user-css/user-layer-order.d.ts +10 -0
  43. package/dist/compat/tailwindcss-v4/user-css/user-layers.d.ts +15 -0
  44. package/dist/compat/uni-app-x/apply-source.d.ts +2 -0
  45. package/dist/compat/uni-app-x/harmony-apply.d.ts +2 -0
  46. package/dist/compat/uni-app-x/reference-paths.d.ts +2 -0
  47. package/dist/compat/uni-app-x-style-value.d.ts +2 -0
  48. package/dist/compat/webpack-css/bare-selectors.d.ts +1 -0
  49. package/dist/compat/webpack-css/generated-cleanup.d.ts +4 -0
  50. package/dist/compat/webpack-css/identity.d.ts +5 -0
  51. package/dist/compat/webpack-css/preflight.d.ts +5 -0
  52. package/dist/compat/webpack-css/user-source.d.ts +6 -0
  53. package/dist/diagnostics/rpx-theme.d.ts +9 -0
  54. package/dist/directives-DTKFO5Hv.js +2630 -0
  55. package/dist/experimental/lightningcss/index.cjs +256 -0
  56. package/dist/experimental/lightningcss/index.d.ts +3 -0
  57. package/dist/experimental/lightningcss/index.js +245 -0
  58. package/dist/experimental/lightningcss/options.d.ts +3 -0
  59. package/dist/experimental/lightningcss/selector-transform.d.ts +10 -0
  60. package/dist/experimental/lightningcss/selector-utils.d.ts +10 -0
  61. package/dist/generator-plugin/config-directive.d.ts +5 -0
  62. package/dist/generator-plugin/source-files.d.ts +5 -5
  63. package/dist/generator-plugin/types.d.ts +5 -0
  64. package/dist/index.cjs +383 -9089
  65. package/dist/index.d.ts +2 -43
  66. package/dist/index.js +10 -8935
  67. package/dist/native.cjs +425 -0
  68. package/dist/native.d.ts +3 -0
  69. package/dist/native.js +419 -0
  70. package/dist/plugin-BWDgxMn5.cjs +194 -0
  71. package/dist/plugin-CpkRzMhp.js +185 -0
  72. package/dist/plugin.cjs +3 -0
  73. package/dist/plugin.d.ts +2 -0
  74. package/dist/plugin.js +2 -0
  75. package/dist/postcss-runtime-i5rHe_mj.js +2 -0
  76. package/dist/preflight-BTZL2nvC.cjs +21 -0
  77. package/dist/preflight-DVg4eehD.js +16 -0
  78. package/dist/resolve-DQiOQfoY.js +354 -0
  79. package/dist/resolve-EBh65bS8.cjs +3556 -0
  80. package/dist/rewrite-imports-CdZQE6CI.js +146 -0
  81. package/dist/shared-CELzerNo.cjs +34 -0
  82. package/dist/shared-CfQUwapA.js +23 -0
  83. package/dist/source-scan/candidates.d.ts +4 -0
  84. package/dist/source-scan/description.d.ts +15 -0
  85. package/dist/source-scan/params.d.ts +5 -0
  86. package/dist/source-scan/resolve.d.ts +30 -0
  87. package/dist/source-scan/tailwind-v4/entry-source.d.ts +16 -0
  88. package/dist/source-scan/tailwind-v4/fingerprint.d.ts +5 -0
  89. package/dist/source-scan.d.ts +3 -24
  90. package/dist/syntax/index.d.ts +1 -0
  91. package/dist/syntax/location-dependencies.d.ts +2 -0
  92. package/dist/syntax/rewrite-imports.d.ts +5 -0
  93. package/dist/syntax/runtime-signature.d.ts +2 -0
  94. package/dist/syntax/source-style.d.ts +1 -0
  95. package/dist/syntax.cjs +547 -0
  96. package/dist/syntax.d.ts +6 -0
  97. package/dist/syntax.js +3 -0
  98. package/dist/transform-Djx5HILQ.js +9239 -0
  99. package/dist/transform-Xb48e-Wk.cjs +10957 -0
  100. package/dist/transform.cjs +421 -0
  101. package/dist/transform.d.ts +40 -0
  102. package/dist/transform.js +10 -0
  103. package/dist/utils/apply-source.d.ts +11 -0
  104. package/dist/utils/css-source-trace.d.ts +6 -0
  105. package/dist/utils/custom-property-values.d.ts +4 -0
  106. package/dist/utils/generated-css-marker.d.ts +12 -0
  107. package/package.json +45 -5
@@ -0,0 +1,3556 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
2
+ const require_shared = require("./shared-CELzerNo.cjs");
3
+ let _weapp_tailwindcss_postcss_calc = require("@weapp-tailwindcss/postcss-calc");
4
+ _weapp_tailwindcss_postcss_calc = require_rolldown_runtime.__toESM(_weapp_tailwindcss_postcss_calc, 1);
5
+ let postcss = require("postcss");
6
+ postcss = require_rolldown_runtime.__toESM(postcss, 1);
7
+ let postcss_value_parser = require("postcss-value-parser");
8
+ postcss_value_parser = require_rolldown_runtime.__toESM(postcss_value_parser, 1);
9
+ let postcss_selector_parser = require("postcss-selector-parser");
10
+ postcss_selector_parser = require_rolldown_runtime.__toESM(postcss_selector_parser, 1);
11
+ let _csstools_css_color_parser = require("@csstools/css-color-parser");
12
+ let _csstools_css_parser_algorithms = require("@csstools/css-parser-algorithms");
13
+ let _csstools_css_tokenizer = require("@csstools/css-tokenizer");
14
+ let node_path = require("node:path");
15
+ node_path = require_rolldown_runtime.__toESM(node_path, 1);
16
+ let postcss_preset_env = require("postcss-preset-env");
17
+ postcss_preset_env = require_rolldown_runtime.__toESM(postcss_preset_env, 1);
18
+ let _weapp_tailwindcss_engine = require("@weapp-tailwindcss/engine");
19
+ let _weapp_tailwindcss_source_scan = require("@weapp-tailwindcss/source-scan");
20
+ let node_module = require("node:module");
21
+ let tailwindcss_config = require("tailwindcss-config");
22
+ //#region src/compat/lynx-css.ts
23
+ const tailwindThemePropertyPatterns = [
24
+ /^--aspect-/,
25
+ /^--animate-/,
26
+ /^--blur-/,
27
+ /^--breakpoint-/,
28
+ /^--color-/,
29
+ /^--container-/,
30
+ /^--drop-shadow-/,
31
+ /^--ease-/,
32
+ /^--default-font-/,
33
+ /^--font-/,
34
+ /^--font-weight-/,
35
+ /^--inset-shadow-/,
36
+ /^--leading-/,
37
+ /^--perspective-/,
38
+ /^--radius-/,
39
+ /^--shadow-/,
40
+ /^--text-/,
41
+ /^--tracking-/,
42
+ /^--spacing$/
43
+ ];
44
+ function isTailwindThemeProperty(property) {
45
+ return tailwindThemePropertyPatterns.some((pattern) => pattern.test(property));
46
+ }
47
+ function isThemeScopeSelector(selector) {
48
+ return selector.split(",").some((part) => {
49
+ const normalized = part.trim();
50
+ return normalized === ":root" || normalized === ":host";
51
+ });
52
+ }
53
+ function collectTailwindThemeProperties(root) {
54
+ const values = /* @__PURE__ */ new Map();
55
+ root.walkRules((rule) => {
56
+ if (!isThemeScopeSelector(rule.selector)) return;
57
+ rule.walkDecls((decl) => {
58
+ if (isTailwindThemeProperty(decl.prop)) values.set(decl.prop, decl.value.trim());
59
+ });
60
+ });
61
+ return values;
62
+ }
63
+ function resolveThemeValue(value, properties, resolving = /* @__PURE__ */ new Set()) {
64
+ if (!value.includes("var(")) return value;
65
+ const parsed = (0, postcss_value_parser.default)(value);
66
+ parsed.walk((node) => {
67
+ if (node.type !== "function" || node.value.toLowerCase() !== "var") return;
68
+ const property = node.nodes.find((child) => child.type === "word" && child.value.startsWith("--"))?.value;
69
+ if (!property || resolving.has(property)) return;
70
+ const propertyValue = properties.get(property);
71
+ if (!propertyValue) return;
72
+ const nextResolving = new Set(resolving);
73
+ nextResolving.add(property);
74
+ const resolved = resolveThemeValue(propertyValue, properties, nextResolving);
75
+ const mutableNode = node;
76
+ mutableNode.type = "word";
77
+ mutableNode.value = resolved;
78
+ delete mutableNode.nodes;
79
+ });
80
+ return parsed.toString();
81
+ }
82
+ function removeConsumedThemeProperties(root) {
83
+ root.walkRules((rule) => {
84
+ if (!isThemeScopeSelector(rule.selector)) return;
85
+ rule.walkDecls((decl) => {
86
+ if (isTailwindThemeProperty(decl.prop)) decl.remove();
87
+ });
88
+ if (rule.nodes.length === 0) rule.remove();
89
+ });
90
+ }
91
+ /** 将 Lynx 原生无法继承的 Tailwind theme 变量静态化。 */
92
+ function transformLynxCssCompat(css) {
93
+ try {
94
+ const root = postcss.default.parse(css);
95
+ const properties = collectTailwindThemeProperties(root);
96
+ if (properties.size === 0) return css;
97
+ root.walkDecls((decl) => {
98
+ decl.value = resolveThemeValue(decl.value, properties);
99
+ });
100
+ removeConsumedThemeProperties(root);
101
+ (0, postcss.default)([(0, _weapp_tailwindcss_postcss_calc.default)()]).process(root, { from: void 0 }).sync();
102
+ return root.toString();
103
+ } catch {
104
+ return css;
105
+ }
106
+ }
107
+ //#endregion
108
+ //#region src/compat/mini-program-css/cascade-layers.ts
109
+ const LAYER_PATH_SEPARATOR = "";
110
+ const LAYER_INSERTION_ANCHOR = "__weapp_tailwindcss_layer_anchor__";
111
+ function splitLayerNames(params) {
112
+ return params.split(",").map((name) => name.trim()).filter(Boolean);
113
+ }
114
+ function splitLayerPath(name) {
115
+ return name.split(".").map((segment) => segment.trim()).filter(Boolean);
116
+ }
117
+ function createLayerPath(segments) {
118
+ return {
119
+ key: segments.join(LAYER_PATH_SEPARATOR),
120
+ segments
121
+ };
122
+ }
123
+ function isContainer(node) {
124
+ return "nodes" in node && Array.isArray(node.nodes);
125
+ }
126
+ function cloneWrapper(node, children) {
127
+ const wrapper = node.clone({ nodes: [] });
128
+ wrapper.append(...children);
129
+ return wrapper;
130
+ }
131
+ function wrapLayerNodes(atRule, nodes, root) {
132
+ let wrapped = nodes;
133
+ let parent = atRule.parent;
134
+ while (parent && parent !== root) {
135
+ if (parent.type !== "atrule" || parent.name !== "layer") {
136
+ if (isContainer(parent)) wrapped = [cloneWrapper(parent, wrapped)];
137
+ }
138
+ parent = parent.parent;
139
+ }
140
+ return wrapped;
141
+ }
142
+ function removeEmptyLayerAncestors(node, root) {
143
+ let parent = node.parent;
144
+ node.remove();
145
+ while (parent && parent !== root && parent.type === "atrule" && parent.nodes?.length === 0) {
146
+ const nextParent = parent.parent;
147
+ parent.remove();
148
+ parent = nextParent;
149
+ }
150
+ }
151
+ function isLayerDescendant(candidate, parent) {
152
+ return candidate.length > parent.length && parent.every((segment, index) => candidate[index] === segment);
153
+ }
154
+ function findParentLayerPath(atRule, paths) {
155
+ let parent = atRule.parent;
156
+ while (parent) {
157
+ if (parent.type === "atrule" && parent.name === "layer") return paths.get(parent)?.segments ?? [];
158
+ parent = parent.parent;
159
+ }
160
+ return [];
161
+ }
162
+ function createLayerInsertionAnchor(root, atRule) {
163
+ let topLevelNode = atRule;
164
+ while (topLevelNode.parent && topLevelNode.parent !== root) topLevelNode = topLevelNode.parent;
165
+ const anchor = postcss.default.comment({ text: LAYER_INSERTION_ANCHOR });
166
+ topLevelNode.before(anchor);
167
+ return anchor;
168
+ }
169
+ function insertLayeredNodes(root, anchor, nodes) {
170
+ if (!anchor.parent) {
171
+ root.append(nodes);
172
+ return;
173
+ }
174
+ if (nodes.length === 0) {
175
+ anchor.remove();
176
+ return;
177
+ }
178
+ anchor.replaceWith(nodes);
179
+ }
180
+ /**
181
+ * 按 cascade layer 声明顺序重排规则并移除 `@layer` 语法。
182
+ *
183
+ * 该转换只模拟 layer 的顺序语义,不通过提高选择器权重模拟完整 specificity 规则。
184
+ */
185
+ function consumeCascadeLayers(root) {
186
+ const layerAtRules = [];
187
+ const paths = /* @__PURE__ */ new WeakMap();
188
+ const siblingOrders = /* @__PURE__ */ new Map();
189
+ const buckets = /* @__PURE__ */ new Map();
190
+ const topLayerOccurrences = /* @__PURE__ */ new Map();
191
+ let anonymousLayerIndex = 0;
192
+ const registerPath = (segments, occurrence) => {
193
+ let parentKey = "";
194
+ for (const [index, segment] of segments.entries()) {
195
+ let siblings = siblingOrders.get(parentKey);
196
+ if (!siblings) {
197
+ siblings = /* @__PURE__ */ new Map();
198
+ siblingOrders.set(parentKey, siblings);
199
+ }
200
+ if (!siblings.has(segment)) siblings.set(segment, siblings.size);
201
+ if (index === 0 && !topLayerOccurrences.has(segment)) topLayerOccurrences.set(segment, occurrence);
202
+ parentKey = parentKey ? `${parentKey}${LAYER_PATH_SEPARATOR}${segment}` : segment;
203
+ }
204
+ const path = createLayerPath(segments);
205
+ if (!buckets.has(path.key)) buckets.set(path.key, {
206
+ ...path,
207
+ nodes: []
208
+ });
209
+ return path;
210
+ };
211
+ root.walkAtRules("layer", (atRule) => {
212
+ layerAtRules.push(atRule);
213
+ const parentLayer = findParentLayerPath(atRule, paths);
214
+ const names = splitLayerNames(atRule.params);
215
+ if (!atRule.nodes) {
216
+ for (const name of names) registerPath([...parentLayer, ...splitLayerPath(name)], atRule);
217
+ return;
218
+ }
219
+ const ownSegments = names[0] ? splitLayerPath(names[0]) : [`\u0000anonymous-${anonymousLayerIndex++}`];
220
+ paths.set(atRule, registerPath([...parentLayer, ...ownSegments], atRule));
221
+ });
222
+ if (layerAtRules.length === 0) return;
223
+ const insertionAnchors = /* @__PURE__ */ new Map();
224
+ for (const [segment, occurrence] of topLayerOccurrences) insertionAnchors.set(segment, createLayerInsertionAnchor(root, occurrence));
225
+ for (const atRule of [...layerAtRules].reverse()) {
226
+ if (!atRule.parent) continue;
227
+ const path = paths.get(atRule);
228
+ if (!path || !atRule.nodes) {
229
+ removeEmptyLayerAncestors(atRule, root);
230
+ continue;
231
+ }
232
+ const nodes = atRule.nodes.map((node) => node.clone());
233
+ if (nodes.length > 0) buckets.get(path.key)?.nodes.unshift(...wrapLayerNodes(atRule, nodes, root));
234
+ removeEmptyLayerAncestors(atRule, root);
235
+ }
236
+ const compareBuckets = (left, right) => {
237
+ if (isLayerDescendant(left.segments, right.segments)) return -1;
238
+ if (isLayerDescendant(right.segments, left.segments)) return 1;
239
+ const size = Math.min(left.segments.length, right.segments.length);
240
+ let parentKey = "";
241
+ for (let index = 0; index < size; index++) {
242
+ const leftSegment = left.segments[index];
243
+ const rightSegment = right.segments[index];
244
+ if (leftSegment !== rightSegment) {
245
+ const siblings = siblingOrders.get(parentKey);
246
+ return (siblings?.get(leftSegment) ?? 0) - (siblings?.get(rightSegment) ?? 0);
247
+ }
248
+ parentKey = parentKey ? `${parentKey}${LAYER_PATH_SEPARATOR}${leftSegment}` : leftSegment;
249
+ }
250
+ return left.segments.length - right.segments.length;
251
+ };
252
+ const bucketsByTopLayer = /* @__PURE__ */ new Map();
253
+ for (const bucket of buckets.values()) {
254
+ const topLayer = bucket.segments[0];
255
+ if (!topLayer || bucket.nodes.length === 0) continue;
256
+ const group = bucketsByTopLayer.get(topLayer) ?? [];
257
+ group.push(bucket);
258
+ bucketsByTopLayer.set(topLayer, group);
259
+ }
260
+ for (const [segment, anchor] of insertionAnchors) insertLayeredNodes(root, anchor, (bucketsByTopLayer.get(segment) ?? []).sort(compareBuckets).flatMap((bucket) => bucket.nodes));
261
+ }
262
+ //#endregion
263
+ //#region src/compat/mini-program-css/at-rules.ts
264
+ const MINI_PROGRAM_UNSUPPORTED_AT_RULES = /* @__PURE__ */ new Set(["property", "supports"]);
265
+ function removeAtRulesByScan(css, names) {
266
+ let index = 0;
267
+ let result = "";
268
+ const atRulePattern = new RegExp(`@(?:${[...names].join("|")})\\b`, "i");
269
+ while (index < css.length) {
270
+ const match = atRulePattern.exec(css.slice(index));
271
+ if (!match || match.index === void 0) {
272
+ result += css.slice(index);
273
+ break;
274
+ }
275
+ const start = index + match.index;
276
+ result += css.slice(index, start);
277
+ const blockStart = css.indexOf("{", start);
278
+ if (blockStart === -1) {
279
+ result += css.slice(start);
280
+ break;
281
+ }
282
+ let depth = 0;
283
+ let cursor = blockStart;
284
+ for (; cursor < css.length; cursor++) {
285
+ const char = css[cursor];
286
+ if (char === "{") depth++;
287
+ else if (char === "}") {
288
+ depth--;
289
+ if (depth === 0) {
290
+ cursor++;
291
+ break;
292
+ }
293
+ }
294
+ }
295
+ index = cursor;
296
+ }
297
+ return result;
298
+ }
299
+ function removeUnsupportedMiniProgramAtRules(css) {
300
+ try {
301
+ const root = postcss.default.parse(css);
302
+ root.walkAtRules((atRule) => {
303
+ if (MINI_PROGRAM_UNSUPPORTED_AT_RULES.has(atRule.name)) atRule.remove();
304
+ });
305
+ root.walkAtRules((atRule) => {
306
+ if (atRule.nodes && atRule.nodes.length === 0) atRule.remove();
307
+ });
308
+ return root.toString();
309
+ } catch {
310
+ return removeAtRulesByScan(css, MINI_PROGRAM_UNSUPPORTED_AT_RULES);
311
+ }
312
+ }
313
+ function removeUnsupportedAtSupports(css) {
314
+ return removeUnsupportedMiniProgramAtRules(css);
315
+ }
316
+ /**
317
+ * 移除小程序不支持的 cascade layer 语法,同时保留 layer 内的实际规则。
318
+ */
319
+ function removeUnsupportedCascadeLayers(root) {
320
+ consumeCascadeLayers(root);
321
+ }
322
+ function unwrapUnsupportedCascadeLayers(css) {
323
+ if (!css.includes("@layer")) return css;
324
+ try {
325
+ const root = postcss.default.parse(css);
326
+ removeUnsupportedCascadeLayers(root);
327
+ return root.toString();
328
+ } catch {
329
+ return css;
330
+ }
331
+ }
332
+ //#endregion
333
+ //#region src/compat/mini-program-css/selectors.ts
334
+ const MINI_PROGRAM_THEME_SCOPE_SELECTOR = ":host,page,.tw-root,wx-root-portal-content";
335
+ const MINI_PROGRAM_ELEMENT_SCOPE_SELECTOR = "view,text,::after,::before";
336
+ const MINI_PROGRAM_ELEMENT_SCOPE_SELECTORS = /* @__PURE__ */ new Set([
337
+ "view",
338
+ "text",
339
+ ":before",
340
+ ":after",
341
+ "::before",
342
+ "::after"
343
+ ]);
344
+ const MINI_PROGRAM_NATIVE_ELEMENT_SELECTORS = /* @__PURE__ */ new Set([
345
+ ...MINI_PROGRAM_ELEMENT_SCOPE_SELECTORS,
346
+ "button",
347
+ "input",
348
+ "textarea",
349
+ "canvas",
350
+ "video",
351
+ "audio"
352
+ ]);
353
+ const MINI_PROGRAM_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set(["*", ...MINI_PROGRAM_ELEMENT_SCOPE_SELECTORS]);
354
+ const MINI_PROGRAM_THEME_SCOPE_SELECTORS = /* @__PURE__ */ new Set([
355
+ ":host",
356
+ ":root",
357
+ "page",
358
+ ".tw-root",
359
+ "wx-root-portal-content"
360
+ ]);
361
+ function normalizeMiniProgramThemeScopeSelector(root) {
362
+ if (root === false) return ":host";
363
+ if (root === void 0) return MINI_PROGRAM_THEME_SCOPE_SELECTOR;
364
+ const selectors = Array.isArray(root) ? root.filter(Boolean) : [root];
365
+ return [.../* @__PURE__ */ new Set([":host", ...selectors])].join(",");
366
+ }
367
+ const SPECIFICITY_PLACEHOLDER_SUFFIXES = [":not(#n)", ":not(#\\#)"];
368
+ const ROOT_SPECIFICITY_PLACEHOLDER_SUFFIXES = [":not(.does-not-exist)"];
369
+ const MINI_PROGRAM_UNSUPPORTED_BROWSER_SELECTORS = /* @__PURE__ */ new Set([
370
+ ":-moz-focusring",
371
+ ":-moz-ui-invalid",
372
+ "::-webkit-calendar-picker-indicator",
373
+ "::-webkit-date-and-time-value",
374
+ "::-webkit-datetime-edit",
375
+ "::-webkit-datetime-edit-day-field",
376
+ "::-webkit-datetime-edit-fields-wrapper",
377
+ "::-webkit-datetime-edit-hour-field",
378
+ "::-webkit-datetime-edit-meridiem-field",
379
+ "::-webkit-datetime-edit-millisecond-field",
380
+ "::-webkit-datetime-edit-minute-field",
381
+ "::-webkit-datetime-edit-month-field",
382
+ "::-webkit-datetime-edit-second-field",
383
+ "::-webkit-datetime-edit-year-field",
384
+ "::-webkit-inner-spin-button",
385
+ "::-webkit-input-placeholder",
386
+ "::-webkit-outer-spin-button",
387
+ "::-webkit-search-decoration",
388
+ "::placeholder",
389
+ "[hidden]:where(:not([hidden='until-found']))"
390
+ ]);
391
+ const MINI_PROGRAM_UNSUPPORTED_BROWSER_TAG_SELECTORS = /* @__PURE__ */ new Set([
392
+ "a",
393
+ "abbr:where([title])",
394
+ "audio",
395
+ "b",
396
+ "button",
397
+ "canvas",
398
+ "code",
399
+ "embed",
400
+ "h1",
401
+ "h2",
402
+ "h3",
403
+ "h4",
404
+ "h5",
405
+ "h6",
406
+ "hr",
407
+ "html",
408
+ "iframe",
409
+ "img",
410
+ "input",
411
+ "input:where([type='button'],[type='reset'],[type='submit'])",
412
+ "kbd",
413
+ "menu",
414
+ "object",
415
+ "ol",
416
+ "optgroup",
417
+ "pre",
418
+ "progress",
419
+ "samp",
420
+ "select",
421
+ "select[multiple]optgroup",
422
+ "select[multiple]optgroupoption",
423
+ "select[size]optgroup",
424
+ "select[size]optgroupoption",
425
+ "small",
426
+ "strong",
427
+ "sub",
428
+ "summary",
429
+ "sup",
430
+ "svg",
431
+ "table",
432
+ "textarea",
433
+ "ul",
434
+ "video"
435
+ ]);
436
+ const MINI_PROGRAM_UNSUPPORTED_BROWSER_PREFLIGHT_SELECTOR_PARTS = /* @__PURE__ */ new Set([...MINI_PROGRAM_UNSUPPORTED_BROWSER_TAG_SELECTORS, "::file-selector-button"]);
437
+ function normalizeSelector(selector) {
438
+ return selector.trim().replace(/\s+/g, "");
439
+ }
440
+ function normalizePseudoElementSelector(selector) {
441
+ return normalizeSelector(selector).replace(/^:(before|after)$/, "::$1");
442
+ }
443
+ function getRuleSelectors(rule) {
444
+ return rule.selector.split(",").map(normalizePseudoElementSelector).filter(Boolean);
445
+ }
446
+ function getSortedRuleSelectorKey(rule) {
447
+ return getRuleSelectors(rule).sort().join(",");
448
+ }
449
+ function isUnsupportedBrowserSelector(selector) {
450
+ const normalized = normalizeSelector(selector);
451
+ return MINI_PROGRAM_UNSUPPORTED_BROWSER_SELECTORS.has(normalized) || MINI_PROGRAM_UNSUPPORTED_BROWSER_TAG_SELECTORS.has(normalized) && !MINI_PROGRAM_NATIVE_ELEMENT_SELECTORS.has(normalized);
452
+ }
453
+ function isUnsupportedBrowserPreflightSelector(selector) {
454
+ const normalizedParts = selector.split(",").map(normalizeSelector).filter(Boolean);
455
+ return normalizedParts.length > 1 && normalizedParts.every((part) => MINI_PROGRAM_UNSUPPORTED_BROWSER_PREFLIGHT_SELECTOR_PARTS.has(part));
456
+ }
457
+ function isMiniProgramNativeElementSelector(selector) {
458
+ return MINI_PROGRAM_NATIVE_ELEMENT_SELECTORS.has(normalizePseudoElementSelector(selector));
459
+ }
460
+ function isMiniProgramPreflightSelector(selectors) {
461
+ return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_PREFLIGHT_SELECTORS.has(selector)) && selectors.some((selector) => selector === "*" || selector === ":before" || selector === ":after" || selector === "::before" || selector === "::after");
462
+ }
463
+ function isMiniProgramThemeScopeSelector(selectors) {
464
+ return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_THEME_SCOPE_SELECTORS.has(selector));
465
+ }
466
+ //#endregion
467
+ //#region src/compat/mini-program-css/predicates.ts
468
+ const PREFLIGHT_RESET_PROPS = /* @__PURE__ */ new Set([
469
+ "box-sizing",
470
+ "border",
471
+ "border-width",
472
+ "border-style",
473
+ "border-color",
474
+ "margin",
475
+ "padding"
476
+ ]);
477
+ const PSEUDO_CONTENT_SELECTOR_RE = /^(?:::before|::after|:before|:after)(?:,(?:::before|::after|:before|:after))*$/;
478
+ const TW_CONTENT_VAR_RE$1 = /var\(\s*--tw-content\b/;
479
+ const BROWSER_PREFLIGHT_SINGLE_ELEMENT_DECLARATIONS = /* @__PURE__ */ new Map([["button", /* @__PURE__ */ new Set(["appearance:button", "-moz-appearance:button"])], ["textarea", /* @__PURE__ */ new Set(["resize:vertical"])]]);
480
+ function hasTailwindPreflightDeclaration(rule) {
481
+ let hasTailwindVar = false;
482
+ let hasResetProp = false;
483
+ rule.walkDecls((decl) => {
484
+ if (decl.prop.startsWith("--tw-")) hasTailwindVar = true;
485
+ if (PREFLIGHT_RESET_PROPS.has(decl.prop)) hasResetProp = true;
486
+ });
487
+ return hasTailwindVar || hasResetProp;
488
+ }
489
+ function hasTailwindVariableDeclaration(rule) {
490
+ let hasTailwindVar = false;
491
+ rule.walkDecls((decl) => {
492
+ if (decl.prop.startsWith("--tw-")) hasTailwindVar = true;
493
+ });
494
+ return hasTailwindVar;
495
+ }
496
+ function isCustomPropertyRule(rule) {
497
+ let hasDeclaration = false;
498
+ let allCustomProperties = true;
499
+ rule.each((node) => {
500
+ if (node.type !== "decl") return;
501
+ hasDeclaration = true;
502
+ if (!node.prop.startsWith("--")) allCustomProperties = false;
503
+ });
504
+ return hasDeclaration && allCustomProperties;
505
+ }
506
+ function isEmptyTwContentDeclaration(decl) {
507
+ return decl.prop === "--tw-content" && (decl.value === "\"\"" || decl.value === "''");
508
+ }
509
+ function isOnlyTwContentDeclarations(rule) {
510
+ let hasDeclaration = false;
511
+ let onlyContentVariable = true;
512
+ rule.walkDecls((decl) => {
513
+ hasDeclaration = true;
514
+ if (decl.prop !== "--tw-content") onlyContentVariable = false;
515
+ });
516
+ return hasDeclaration && onlyContentVariable;
517
+ }
518
+ function isPseudoContentInitRule(rule) {
519
+ const selector = rule.selector.replace(/\s+/g, "");
520
+ return PSEUDO_CONTENT_SELECTOR_RE.test(selector) && isOnlyTwContentDeclarations(rule);
521
+ }
522
+ function usesTwContentVariable(root) {
523
+ let used = false;
524
+ root.walkDecls((decl) => {
525
+ if (TW_CONTENT_VAR_RE$1.test(decl.value)) used = true;
526
+ });
527
+ return used;
528
+ }
529
+ function isMiniProgramPreflightRule(node) {
530
+ if (node.type !== "rule") return false;
531
+ const selectors = getRuleSelectors(node);
532
+ if (!isMiniProgramPreflightSelector(selectors)) return false;
533
+ if (selectors.includes("*")) return hasTailwindPreflightDeclaration(node);
534
+ if (hasTailwindVariableDeclaration(node)) return true;
535
+ return selectors.some((selector) => selector === ":before" || selector === ":after" || selector === "::before" || selector === "::after") && selectors.some((selector) => selector === "view" || selector === "text") && hasTailwindPreflightDeclaration(node);
536
+ }
537
+ function isBrowserElementPreflightRule(node) {
538
+ if (node.type !== "rule") return false;
539
+ const selectors = getRuleSelectors(node);
540
+ if (selectors.length !== 1) return false;
541
+ const declarations = BROWSER_PREFLIGHT_SINGLE_ELEMENT_DECLARATIONS.get(selectors[0]);
542
+ if (!declarations) return false;
543
+ let hasDeclaration = false;
544
+ let allBrowserPreflightDeclarations = true;
545
+ node.each((child) => {
546
+ if (child.type !== "decl") return;
547
+ hasDeclaration = true;
548
+ const key = `${child.prop.toLowerCase()}:${child.value.trim().toLowerCase()}`;
549
+ if (!declarations.has(key)) allBrowserPreflightDeclarations = false;
550
+ });
551
+ return hasDeclaration && allBrowserPreflightDeclarations;
552
+ }
553
+ function isMiniProgramThemeVariableRule(node) {
554
+ if (node.type !== "rule") return false;
555
+ return isMiniProgramThemeScopeSelector(getRuleSelectors(node)) && isCustomPropertyRule(node);
556
+ }
557
+ //#endregion
558
+ //#region src/compat/mini-program-css/directives.ts
559
+ const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
560
+ const GENERATOR_PLACEHOLDER_COMMENT_RE = /^\s*(?:!\s*)?weapp-tailwindcss generator-placeholder\s*$/i;
561
+ function isCssWhitespace$1(code) {
562
+ return code === 9 || code === 10 || code === 12 || code === 13 || code === 32;
563
+ }
564
+ function skipCssWhitespace$1(css, start) {
565
+ let index = start;
566
+ while (index < css.length && isCssWhitespace$1(css.charCodeAt(index))) index++;
567
+ return index;
568
+ }
569
+ function findClosingParenthesis(css, openingIndex) {
570
+ let depth = 0;
571
+ let quote = 0;
572
+ for (let index = openingIndex; index < css.length; index++) {
573
+ const code = css.charCodeAt(index);
574
+ if (quote !== 0) {
575
+ if (code === 92) index++;
576
+ else if (code === quote) quote = 0;
577
+ continue;
578
+ }
579
+ if (code === 34 || code === 39) {
580
+ quote = code;
581
+ continue;
582
+ }
583
+ if (code === 92) {
584
+ index++;
585
+ continue;
586
+ }
587
+ if (code === 47 && css.charCodeAt(index + 1) === 42) {
588
+ const commentEnd = css.indexOf("*/", index + 2);
589
+ if (commentEnd < 0) return -1;
590
+ index = commentEnd + 1;
591
+ continue;
592
+ }
593
+ if (code === 40) {
594
+ depth++;
595
+ continue;
596
+ }
597
+ if (code === 41) {
598
+ depth--;
599
+ if (depth === 0) return index;
600
+ }
601
+ }
602
+ return -1;
603
+ }
604
+ function isCssCodePosition(css, position) {
605
+ let quote = 0;
606
+ for (let index = 0; index < position; index++) {
607
+ const code = css.charCodeAt(index);
608
+ if (quote !== 0) {
609
+ if (code === 92) index++;
610
+ else if (code === quote) quote = 0;
611
+ continue;
612
+ }
613
+ if (code === 34 || code === 39) {
614
+ quote = code;
615
+ continue;
616
+ }
617
+ if (code === 47 && css.charCodeAt(index + 1) === 42) {
618
+ const commentEnd = css.indexOf("*/", index + 2);
619
+ if (commentEnd < 0 || commentEnd >= position) return false;
620
+ index = commentEnd + 1;
621
+ }
622
+ }
623
+ return quote === 0;
624
+ }
625
+ /**
626
+ * 严格移除文件末尾残留的 Tailwind source media 开始标记。
627
+ * 仅处理可确认属于 Tailwind 的尾部残片,其它非法 CSS 保持原样。
628
+ */
629
+ function repairTrailingUnclosedTailwindSourceMedia(css) {
630
+ const sourceMediaPattern = /(?:^|\r?\n)[\t\f ]*@media\s+source\(/g;
631
+ for (let match = sourceMediaPattern.exec(css); match !== null; match = sourceMediaPattern.exec(css)) {
632
+ const prefixLength = match[0].startsWith("\n") ? 1 : match[0].startsWith("\r\n") ? 2 : 0;
633
+ const start = match.index + prefixLength;
634
+ if (!isCssCodePosition(css, start)) continue;
635
+ const closingIndex = findClosingParenthesis(css, start + match[0].length - prefixLength - 1);
636
+ if (closingIndex < 0) continue;
637
+ const blockStart = skipCssWhitespace$1(css, closingIndex + 1);
638
+ if (css.charCodeAt(blockStart) !== 123) continue;
639
+ if (skipCssWhitespace$1(css, blockStart + 1) !== css.length) continue;
640
+ return css.slice(0, match.index);
641
+ }
642
+ return css;
643
+ }
644
+ function hasTailwindcssV4Signal(css) {
645
+ if (TAILWIND_V4_BANNER_RE.test(css)) return true;
646
+ const root = postcss.default.parse(css);
647
+ let hasProperty = false;
648
+ root.walkAtRules("property", (atRule) => {
649
+ if (atRule.params.trim().startsWith("--tw-")) {
650
+ hasProperty = true;
651
+ return false;
652
+ }
653
+ });
654
+ return hasProperty;
655
+ }
656
+ function unwrapTailwindSourceMedia(root) {
657
+ root.walkAtRules("media", (atRule) => {
658
+ if (!atRule.params.startsWith("source(")) return;
659
+ if (atRule.nodes && atRule.nodes.length > 0) atRule.replaceWith(...atRule.nodes);
660
+ else atRule.remove();
661
+ });
662
+ }
663
+ function removeTailwindGenerationDirectives(root) {
664
+ root.walkComments((comment) => {
665
+ if (GENERATOR_PLACEHOLDER_COMMENT_RE.test(comment.text)) comment.remove();
666
+ });
667
+ root.walkAtRules((atRule) => {
668
+ if (atRule.name === "config" || atRule.name === "source" || atRule.name === "tailwind" || atRule.name === "reference" || atRule.name === "plugin") atRule.remove();
669
+ });
670
+ }
671
+ const MODERN_COLOR_FUNCTION_NAMES = /* @__PURE__ */ new Set([
672
+ "oklch",
673
+ "oklab",
674
+ "lch",
675
+ "lab"
676
+ ]);
677
+ const MODERN_COLOR_SYNTAX_FUNCTION_NAMES = /* @__PURE__ */ new Set([
678
+ "rgb",
679
+ "rgba",
680
+ "hsl",
681
+ "hsla",
682
+ "hwb"
683
+ ]);
684
+ const PLACEHOLDER_PREFIX = "__weapp_tw_color_mix_";
685
+ const DYNAMIC_ALPHA_RE = /\b(?:var|env)\(|--[\w-]+\b/;
686
+ const INTERNAL_TAILWIND_ALPHA_RE = /var\(\s*--tw-[^)]+-alpha\s*\)/;
687
+ const TRANSPARENT_COLOR_RE = /^transparent$/i;
688
+ const CURRENT_COLOR_RE = /^currentcolor$/i;
689
+ const CSS_WIDE_KEYWORD_RE = /^(?:inherit|initial|unset|revert|revert-layer)$/i;
690
+ const CUSTOM_PROPERTY_RE = /^--[\w-]+$/;
691
+ //#endregion
692
+ //#region src/compat/color-mix/modern.ts
693
+ function isDisplayP3ColorFunction(colorSource) {
694
+ return /^color\(\s*display-p3\b/i.test(colorSource.trim());
695
+ }
696
+ function isModernColorSyntaxFunction(colorSource) {
697
+ const parsed = (0, postcss_value_parser.default)(colorSource.trim());
698
+ const node = parsed.nodes.length === 1 ? parsed.nodes[0] : void 0;
699
+ if (node?.type !== "function") return false;
700
+ const name = node.value.toLowerCase();
701
+ if (!MODERN_COLOR_SYNTAX_FUNCTION_NAMES.has(name)) return false;
702
+ return !node.nodes.some((child) => child.type === "div" && child.value === ",");
703
+ }
704
+ function hasUnsupportedModernColorFunction(value) {
705
+ const parsed = (0, postcss_value_parser.default)(value);
706
+ let hasUnsupported = false;
707
+ parsed.walk((node) => {
708
+ if (node.type !== "function") return;
709
+ const name = node.value.toLowerCase();
710
+ if (name === "color-mix" || MODERN_COLOR_FUNCTION_NAMES.has(name) || name === "color" && isDisplayP3ColorFunction(postcss_value_parser.default.stringify(node)) || isModernColorSyntaxFunction(postcss_value_parser.default.stringify(node))) {
711
+ hasUnsupported = true;
712
+ return false;
713
+ }
714
+ });
715
+ return hasUnsupported;
716
+ }
717
+ //#endregion
718
+ //#region src/compat/color-mix/parse.ts
719
+ function splitArguments(nodes) {
720
+ const args = [];
721
+ let current = [];
722
+ for (const node of nodes) {
723
+ if (node.type === "div" && node.value === ",") {
724
+ args.push(current);
725
+ current = [];
726
+ continue;
727
+ }
728
+ current.push(node);
729
+ }
730
+ args.push(current);
731
+ return args;
732
+ }
733
+ function splitStopSegments(nodes) {
734
+ const segments = [];
735
+ let current = [];
736
+ for (const node of nodes) {
737
+ if (node.type === "space") {
738
+ if (current.length > 0) {
739
+ segments.push(current);
740
+ current = [];
741
+ }
742
+ continue;
743
+ }
744
+ current.push(node);
745
+ }
746
+ if (current.length > 0) segments.push(current);
747
+ return segments;
748
+ }
749
+ function trimNodes(nodes) {
750
+ let start = 0;
751
+ let end = nodes.length;
752
+ while (start < end && nodes[start]?.type === "space") start += 1;
753
+ while (end > start && nodes[end - 1]?.type === "space") end -= 1;
754
+ return nodes.slice(start, end);
755
+ }
756
+ function getParsedColorData(colorSource) {
757
+ try {
758
+ const parsed = (0, _csstools_css_parser_algorithms.parseComponentValue)((0, _csstools_css_tokenizer.tokenize)({ css: colorSource }));
759
+ return (0, _csstools_css_color_parser.color)(parsed);
760
+ } catch {
761
+ return false;
762
+ }
763
+ }
764
+ function parseAlphaValue(alphaSource) {
765
+ const parsed = Number.parseFloat(alphaSource);
766
+ if (Number.isFinite(parsed)) return alphaSource.trim().endsWith("%") ? parsed / 100 : parsed;
767
+ }
768
+ function resolveVarColor(colorSource, customPropertyValues, depth = 0) {
769
+ if (depth > 5) return;
770
+ const parsed = (0, postcss_value_parser.default)(colorSource.trim());
771
+ const node = parsed.nodes.length === 1 ? parsed.nodes[0] : void 0;
772
+ if (node?.type !== "function" || node.value.toLowerCase() !== "var") return;
773
+ const args = splitArguments(node.nodes);
774
+ const propertyName = postcss_value_parser.default.stringify(trimNodes(args[0] ?? [])).trim();
775
+ if (!CUSTOM_PROPERTY_RE.test(propertyName)) return;
776
+ const resolved = customPropertyValues.get(propertyName);
777
+ if (!resolved) {
778
+ const fallback = args[1] ? postcss_value_parser.default.stringify(trimNodes(args[1])).trim() : void 0;
779
+ return fallback ? resolveColorData(fallback, customPropertyValues, depth + 1) : void 0;
780
+ }
781
+ return resolveColorData(resolved, customPropertyValues, depth + 1);
782
+ }
783
+ function resolveColorData(colorSource, customPropertyValues, depth = 0) {
784
+ if (typeof colorSource !== "string") return;
785
+ const trimmed = colorSource.trim();
786
+ if (TRANSPARENT_COLOR_RE.test(trimmed)) return getParsedColorData(trimmed) || void 0;
787
+ if (CURRENT_COLOR_RE.test(trimmed) || CSS_WIDE_KEYWORD_RE.test(trimmed)) return;
788
+ const resolvedVar = resolveVarColor(trimmed, customPropertyValues, depth);
789
+ if (resolvedVar) return resolvedVar;
790
+ return getParsedColorData(trimmed) || void 0;
791
+ }
792
+ function normalizeColorFunctionName(colorSource, alpha, customPropertyValues) {
793
+ const resolvedColor = resolveColorData(colorSource, customPropertyValues);
794
+ if (!resolvedColor) return;
795
+ resolvedColor.alpha = alpha;
796
+ return (0, _csstools_css_color_parser.serializeRGB)(resolvedColor).toString();
797
+ }
798
+ function normalizeColorFunctionWithDynamicAlpha(colorSource, alphaSource, customPropertyValues) {
799
+ const resolvedColor = resolveColorData(colorSource, customPropertyValues);
800
+ const alphaColor = getParsedColorData(`rgb(0 0 0 / ${alphaSource})`);
801
+ if (!resolvedColor || !alphaColor || typeof alphaColor.alpha === "number") return;
802
+ resolvedColor.alpha = alphaColor.alpha;
803
+ return (0, _csstools_css_color_parser.serializeRGB)(resolvedColor).toString();
804
+ }
805
+ function normalizeStandaloneColorFunction(colorSource) {
806
+ const resolvedColor = getParsedColorData(colorSource);
807
+ return resolvedColor ? (0, _csstools_css_color_parser.serializeRGB)(resolvedColor).toString() : void 0;
808
+ }
809
+ //#endregion
810
+ //#region src/compat/color-mix/resolve.ts
811
+ function createRgbaWithAlpha(colorSource, alphaSource, customPropertyValues) {
812
+ const alpha = alphaSource.trim();
813
+ return normalizeColorFunctionWithDynamicAlpha(colorSource, CUSTOM_PROPERTY_RE.test(alpha) ? `var(${alpha})` : alpha, customPropertyValues);
814
+ }
815
+ function tryResolveColorMix(node, customPropertyValues) {
816
+ const args = splitArguments(node.nodes);
817
+ if (args.length < 3) return;
818
+ const colorStopNodes = splitStopSegments(args[1] ?? []);
819
+ if (colorStopNodes.length < 2) return;
820
+ const colorNodes = trimNodes(colorStopNodes[0] ?? []);
821
+ const alphaNodes = trimNodes(colorStopNodes[1] ?? []);
822
+ const trailingNodes = trimNodes(args[2] ?? []);
823
+ if (!colorNodes.length || !alphaNodes.length || postcss_value_parser.default.stringify(trailingNodes).trim().toLowerCase() !== "transparent") return;
824
+ const colorSource = postcss_value_parser.default.stringify(colorNodes).trim();
825
+ const alphaSource = postcss_value_parser.default.stringify(alphaNodes).trim();
826
+ if (!colorSource || !alphaSource || INTERNAL_TAILWIND_ALPHA_RE.test(alphaSource)) return;
827
+ if (CURRENT_COLOR_RE.test(colorSource)) return {
828
+ value: colorSource,
829
+ deferred: false
830
+ };
831
+ if (DYNAMIC_ALPHA_RE.test(alphaSource)) {
832
+ const normalized = createRgbaWithAlpha(colorSource, alphaSource, customPropertyValues);
833
+ return normalized ? {
834
+ value: normalized,
835
+ deferred: true
836
+ } : {
837
+ value: colorSource,
838
+ deferred: true
839
+ };
840
+ }
841
+ const alpha = parseAlphaValue(alphaSource);
842
+ if (alpha === void 0) return;
843
+ const normalized = normalizeColorFunctionName(colorSource, alpha, customPropertyValues);
844
+ if (normalized) return {
845
+ value: normalized,
846
+ deferred: false
847
+ };
848
+ return {
849
+ value: colorSource,
850
+ deferred: false
851
+ };
852
+ }
853
+ //#endregion
854
+ //#region src/cssVarsV4.ts
855
+ function property(ident, initialValue, _syntax) {
856
+ return {
857
+ prop: ident,
858
+ value: initialValue || ""
859
+ };
860
+ }
861
+ const nullShadow = "0 0 #0000";
862
+ const nodes = [
863
+ property("--tw-border-spacing-x", "0", "<length>"),
864
+ property("--tw-border-spacing-y", "0", "<length>"),
865
+ property("--tw-translate-x", "0"),
866
+ property("--tw-translate-y", "0"),
867
+ property("--tw-translate-z", "0"),
868
+ property("--tw-scale-x", "1"),
869
+ property("--tw-scale-y", "1"),
870
+ property("--tw-scale-z", "1"),
871
+ property("--tw-rotate-x"),
872
+ property("--tw-rotate-y"),
873
+ property("--tw-rotate-z"),
874
+ property("--tw-skew-x"),
875
+ property("--tw-skew-y"),
876
+ property("--tw-pan-x"),
877
+ property("--tw-pan-y"),
878
+ property("--tw-pinch-zoom"),
879
+ property("--tw-scroll-snap-strictness", "proximity", "*"),
880
+ property("--tw-space-x-reverse", "0"),
881
+ property("--tw-space-y-reverse", "0"),
882
+ property("--tw-scrollbar-thumb", "#0000", "<color>"),
883
+ property("--tw-scrollbar-track", "#0000", "<color>"),
884
+ property("--tw-border-style", "solid"),
885
+ property("--tw-divide-x-reverse", "0"),
886
+ property("--tw-divide-y-reverse", "0"),
887
+ property("--tw-gradient-position", "initial"),
888
+ property("--tw-gradient-from", "#0000", "<color>"),
889
+ property("--tw-gradient-via", "#0000", "<color>"),
890
+ property("--tw-gradient-to", "#0000", "<color>"),
891
+ property("--tw-gradient-stops", "initial"),
892
+ property("--tw-gradient-via-stops", "initial"),
893
+ property("--tw-gradient-from-position", "0%", "<length-percentage>"),
894
+ property("--tw-gradient-via-position", "50%", "<length-percentage>"),
895
+ property("--tw-gradient-to-position", "100%", "<length-percentage>"),
896
+ property("--tw-mask-linear", "linear-gradient(#fff, #fff)"),
897
+ property("--tw-mask-radial", "linear-gradient(#fff, #fff)"),
898
+ property("--tw-mask-conic", "linear-gradient(#fff, #fff)"),
899
+ property("--tw-mask-left", "linear-gradient(#fff, #fff)"),
900
+ property("--tw-mask-right", "linear-gradient(#fff, #fff)"),
901
+ property("--tw-mask-bottom", "linear-gradient(#fff, #fff)"),
902
+ property("--tw-mask-top", "linear-gradient(#fff, #fff)"),
903
+ property("--tw-mask-linear-position", "0deg"),
904
+ property("--tw-mask-linear-from-position", "0%"),
905
+ property("--tw-mask-linear-to-position", "100%"),
906
+ property("--tw-mask-linear-from-color", "black"),
907
+ property("--tw-mask-linear-to-color", "transparent"),
908
+ property("--tw-mask-radial-from-position", "0%"),
909
+ property("--tw-mask-radial-to-position", "100%"),
910
+ property("--tw-mask-radial-from-color", "black"),
911
+ property("--tw-mask-radial-to-color", "transparent"),
912
+ property("--tw-mask-radial-shape", "ellipse"),
913
+ property("--tw-mask-radial-size", "farthest-corner"),
914
+ property("--tw-mask-radial-position", "center"),
915
+ property("--tw-mask-conic-position", "0deg"),
916
+ property("--tw-mask-conic-from-position", "0%"),
917
+ property("--tw-mask-conic-to-position", "100%"),
918
+ property("--tw-mask-conic-from-color", "black"),
919
+ property("--tw-mask-conic-to-color", "transparent"),
920
+ property("--tw-font-weight"),
921
+ property("--tw-blur"),
922
+ property("--tw-brightness"),
923
+ property("--tw-contrast"),
924
+ property("--tw-grayscale"),
925
+ property("--tw-hue-rotate"),
926
+ property("--tw-invert"),
927
+ property("--tw-opacity"),
928
+ property("--tw-saturate"),
929
+ property("--tw-sepia"),
930
+ property("--tw-drop-shadow"),
931
+ property("--tw-drop-shadow-color"),
932
+ property("--tw-drop-shadow-alpha", "100%", "<percentage>"),
933
+ property("--tw-drop-shadow-size"),
934
+ property("--tw-backdrop-blur"),
935
+ property("--tw-backdrop-brightness"),
936
+ property("--tw-backdrop-contrast"),
937
+ property("--tw-backdrop-grayscale"),
938
+ property("--tw-backdrop-hue-rotate"),
939
+ property("--tw-backdrop-invert"),
940
+ property("--tw-backdrop-opacity"),
941
+ property("--tw-backdrop-saturate"),
942
+ property("--tw-backdrop-sepia"),
943
+ property("--tw-duration", "initial"),
944
+ property("--tw-ease", "initial"),
945
+ property("--tw-content", "\"\""),
946
+ property("--tw-contain-size"),
947
+ property("--tw-contain-layout"),
948
+ property("--tw-contain-paint"),
949
+ property("--tw-contain-style"),
950
+ property("--tw-leading"),
951
+ property("--tw-tracking"),
952
+ property("--tw-ordinal"),
953
+ property("--tw-slashed-zero"),
954
+ property("--tw-numeric-figure"),
955
+ property("--tw-numeric-spacing"),
956
+ property("--tw-numeric-fraction"),
957
+ property("--tw-outline-style", "solid"),
958
+ property("--tw-text-shadow-color", "initial"),
959
+ property("--tw-text-shadow-alpha", "100%", "<percentage>"),
960
+ property("--tw-shadow", nullShadow),
961
+ property("--tw-shadow-color", "initial"),
962
+ property("--tw-shadow-alpha", "100%", "<percentage>"),
963
+ property("--tw-inset-shadow", nullShadow),
964
+ property("--tw-inset-shadow-color", "initial"),
965
+ property("--tw-inset-shadow-alpha", "100%", "<percentage>"),
966
+ property("--tw-ring-color"),
967
+ property("--tw-ring-shadow", nullShadow),
968
+ property("--tw-inset-ring-color"),
969
+ property("--tw-inset-ring-shadow", nullShadow),
970
+ property("--tw-ring-inset"),
971
+ property("--tw-ring-offset-width", "0px", "<length>"),
972
+ property("--tw-ring-offset-color", "#fff"),
973
+ property("--tw-ring-offset-shadow", nullShadow)
974
+ ];
975
+ for (const edge of [
976
+ "top",
977
+ "right",
978
+ "bottom",
979
+ "left"
980
+ ]) nodes.push(property(`--tw-mask-${edge}-from-position`, "0%"), property(`--tw-mask-${edge}-to-position`, "100%"), property(`--tw-mask-${edge}-from-color`, "black"), property(`--tw-mask-${edge}-to-color`, "transparent"));
981
+ //#endregion
982
+ //#region src/utils/css-vars.ts
983
+ /**
984
+ * 将 CSS 变量定义转换为可直接插入的 Declaration 节点列表。
985
+ */
986
+ function createCssVarNodes(definitions) {
987
+ return definitions.map((def) => new postcss.Declaration({
988
+ prop: def.prop,
989
+ value: def.value
990
+ }));
991
+ }
992
+ const CLAMP_PX = 9999;
993
+ const INFINITY_CALC_VALUE_REGEXP = /^calc\(\s*infinity\s*\*\s*(\d+(?:\.\d*)?|\.\d+)r?px\s*\)$/i;
994
+ const MODERN_CHECK_WEBKIT_HYPHENS_RE = /-webkit-hyphens\s*:\s*none/;
995
+ const MODERN_CHECK_MARGIN_TRIM_RE = /margin-trim\s*:\s*inline/;
996
+ const MODERN_CHECK_MOZ_ORIENT_RE = /-moz-orient\s*:\s*inline/;
997
+ const MODERN_CHECK_COLOR_RGB_RE = /color\s*:\s*rgb\(\s*from\s+red\s+r\s+g\s+b\s*\)/;
998
+ const LINEAR_GRADIENT_LAB_RE = /background-image\s*:\s*linear-gradient\(\s*in\s+lab\s*,\s*red\s*,\s*red\s*\)/;
999
+ const DISPLAY_P3_COLOR_RE = /color\s*:\s*color\(\s*display-p3\s+0\s+0\s+0%\s*\)/;
1000
+ const DISPLAY_P3_VALUE_RE$1 = /color\(\s*display-p3\b/i;
1001
+ const COLOR_GAMUT_P3_RE$1 = /\(\s*color-gamut\s*:\s*p3\s*\)/i;
1002
+ const GRADIENT_BACKGROUND_RE = /^(linear|radial|conic)-gradient\(/i;
1003
+ const GRADIENT_STOPS_VAR_RE = /^(?:linear|radial|conic)-gradient\(\s*var\(\s*--tw-gradient-stops\b/i;
1004
+ const SIMPLE_CLASS_SELECTOR_RE = /^\.([_a-z\u00A0-\uFFFF\\-][\w\u00A0-\uFFFF\\-]*)$/i;
1005
+ const COLOR_VAR_RE = /^var\(\s*(--color-[\w-]+)\s*\)$/i;
1006
+ const TAILWIND_THEME_VARIABLE_RE = /^--(?:animate|aspect|blur|breakpoint|color|container|drop-shadow|ease|font|inset-shadow|leading|perspective|radius|shadow|spacing|text|tracking)(?:-|$)/;
1007
+ const GRADIENT_DIRECTION_CLASS_RE = /^(?:-?bg-linear|bg-gradient-to-|-?bg-conic|bg-radial)/;
1008
+ const RADIUS_VALUE_RE = /\b([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)\s*(r?px)\b/gi;
1009
+ const SCIENTIFIC_NOTATION_RE = /e/i;
1010
+ const TW_VAR_FUNCTION_RE = /var\(\s*(--tw-[\w-]+)\b/g;
1011
+ const TW_CONTENT_VAR_RE = /var\(\s*--tw-content\b/;
1012
+ const TW_GRADIENT_POSITION_PROPS = /* @__PURE__ */ new Set([
1013
+ "--tw-gradient-from-position",
1014
+ "--tw-gradient-via-position",
1015
+ "--tw-gradient-to-position"
1016
+ ]);
1017
+ const UNSUPPORTED_CUSTOM_PROPERTY_DEFAULT_PROPS = /* @__PURE__ */ new Set(["--tw-gradient-via-stops"]);
1018
+ const DEFAULT_VARIABLE_SCOPE_SELECTORS = /* @__PURE__ */ new Set([
1019
+ "*",
1020
+ "view",
1021
+ "text",
1022
+ ":before",
1023
+ ":after",
1024
+ "::before",
1025
+ "::after",
1026
+ "::backdrop"
1027
+ ]);
1028
+ function isTailwindcssV4(options) {
1029
+ return options?.majorVersion === 4;
1030
+ }
1031
+ function isTailwindcssV4ThemeVariable(property) {
1032
+ return property.startsWith("--tw-") || TAILWIND_THEME_VARIABLE_RE.test(property);
1033
+ }
1034
+ function testIfRootHostForV4(node) {
1035
+ return node.type === "rule" && node.selector.includes(":root") && node.selector.includes(":host");
1036
+ }
1037
+ createCssVarNodes(nodes);
1038
+ function collectUsedTailwindcssV4Variables(root) {
1039
+ const props = /* @__PURE__ */ new Set();
1040
+ root.walkDecls((decl) => {
1041
+ if (decl.prop.startsWith("--tw-")) props.add(decl.prop);
1042
+ TW_VAR_FUNCTION_RE.lastIndex = 0;
1043
+ let match = TW_VAR_FUNCTION_RE.exec(decl.value);
1044
+ while (match !== null) {
1045
+ const prop = match[1];
1046
+ if (prop) props.add(prop);
1047
+ match = TW_VAR_FUNCTION_RE.exec(decl.value);
1048
+ }
1049
+ });
1050
+ root.walkAtRules("property", (atRule) => {
1051
+ const prop = atRule.params.trim();
1052
+ if (prop.startsWith("--tw-")) props.add(prop);
1053
+ });
1054
+ return props;
1055
+ }
1056
+ function usesTailwindcssV4ContentVariable(root) {
1057
+ let used = false;
1058
+ root.walkDecls((decl) => {
1059
+ if (TW_CONTENT_VAR_RE.test(decl.value)) used = true;
1060
+ });
1061
+ return used;
1062
+ }
1063
+ function createUsedCssVarsV4Nodes(usedProps) {
1064
+ return nodes.filter((def) => usedProps.has(def.prop) && !UNSUPPORTED_CUSTOM_PROPERTY_DEFAULT_PROPS.has(def.prop)).map((def) => new postcss.Declaration({
1065
+ prop: def.prop,
1066
+ value: def.value
1067
+ }));
1068
+ }
1069
+ function isInsideAtRule(decl, name) {
1070
+ let parent = decl.parent;
1071
+ while (parent) {
1072
+ if (parent.type === "atrule" && parent.name === name) return true;
1073
+ parent = parent.parent;
1074
+ }
1075
+ return false;
1076
+ }
1077
+ function isDefaultVariableScopeRule(rule) {
1078
+ const selectors = rule.selectors.map((selector) => selector.trim());
1079
+ if (!selectors.every((selector) => DEFAULT_VARIABLE_SCOPE_SELECTORS.has(selector))) return false;
1080
+ if (!selectors.some((selector) => selector === "*" || selector === "view" || selector === "text")) return false;
1081
+ let hasDeclaration = false;
1082
+ let onlyCustomProperties = true;
1083
+ rule.each((node) => {
1084
+ if (node.type !== "decl") return;
1085
+ hasDeclaration = true;
1086
+ if (!node.prop.startsWith("--")) onlyCustomProperties = false;
1087
+ });
1088
+ return hasDeclaration && onlyCustomProperties;
1089
+ }
1090
+ function collectScopedTailwindcssV4DefaultVariables(root) {
1091
+ const props = /* @__PURE__ */ new Set();
1092
+ root.walkDecls((decl) => {
1093
+ if (!decl.prop.startsWith("--tw-")) return;
1094
+ if (isInsideAtRule(decl, "supports")) return;
1095
+ if (decl.parent?.type === "rule" && isDefaultVariableScopeRule(decl.parent)) props.add(decl.prop);
1096
+ });
1097
+ return props;
1098
+ }
1099
+ function createMissingCssVarsV4Nodes(root, usedProps) {
1100
+ const scopedProps = collectScopedTailwindcssV4DefaultVariables(root);
1101
+ return nodes.filter((def) => usedProps.has(def.prop) && !scopedProps.has(def.prop) && !UNSUPPORTED_CUSTOM_PROPERTY_DEFAULT_PROPS.has(def.prop)).map((def) => new postcss.Declaration({
1102
+ prop: def.prop,
1103
+ value: def.value
1104
+ }));
1105
+ }
1106
+ //#endregion
1107
+ //#region src/compat/color-mix.ts
1108
+ const DYNAMIC_VAR_FALLBACK_PLACEHOLDER_PREFIX = "__weapp_tw_var_fallback_";
1109
+ function getStandaloneDynamicVarWithFallback(value) {
1110
+ const nodes = (0, postcss_value_parser.default)(value).nodes.filter((node) => node.type !== "space" && node.type !== "comment");
1111
+ const variable = nodes.length === 1 ? nodes[0] : void 0;
1112
+ const property = variable?.type === "function" ? variable.nodes.find((node) => node.type === "word" && node.value.startsWith("--")) : void 0;
1113
+ if (variable?.type !== "function" || variable.value.toLowerCase() !== "var" || property?.type !== "word" || isTailwindcssV4ThemeVariable(property.value) || !variable.nodes.some((node) => node.type === "div" && node.value === ",")) return;
1114
+ return variable;
1115
+ }
1116
+ /**
1117
+ * 保护带 fallback 的作者 CSS 变量,避免兼容插件把它错误静态化。
1118
+ */
1119
+ function protectDynamicVarFallbacks(css) {
1120
+ if (!css.includes("var(") || !css.includes(",")) return {
1121
+ css,
1122
+ restore: (value) => value
1123
+ };
1124
+ const replacements = /* @__PURE__ */ new Map();
1125
+ let root;
1126
+ try {
1127
+ root = postcss.default.parse(css);
1128
+ } catch {
1129
+ return {
1130
+ css,
1131
+ restore: (value) => value
1132
+ };
1133
+ }
1134
+ root.walkDecls((decl) => {
1135
+ if (!getStandaloneDynamicVarWithFallback(decl.value)) return;
1136
+ const placeholder = `${DYNAMIC_VAR_FALLBACK_PLACEHOLDER_PREFIX}${replacements.size}__`;
1137
+ replacements.set(placeholder, decl.value);
1138
+ decl.value = placeholder;
1139
+ });
1140
+ if (replacements.size === 0) return {
1141
+ css,
1142
+ restore: (value) => value
1143
+ };
1144
+ return {
1145
+ css: root.toString(),
1146
+ restore(value) {
1147
+ let restored = value;
1148
+ for (const [placeholder, replacement] of replacements) restored = restored.split(placeholder).join(replacement);
1149
+ return restored;
1150
+ }
1151
+ };
1152
+ }
1153
+ function normalizeModernColorValue(value, customPropertyValues = /* @__PURE__ */ new Map()) {
1154
+ if (!hasUnsupportedModernColorFunction(value)) return {
1155
+ value,
1156
+ changed: false,
1157
+ hasUnsupported: false
1158
+ };
1159
+ const parsed = (0, postcss_value_parser.default)(value);
1160
+ let changed = false;
1161
+ parsed.walk((node) => {
1162
+ if (node.type !== "function") return;
1163
+ const name = node.value.toLowerCase();
1164
+ const source = postcss_value_parser.default.stringify(node);
1165
+ let normalized;
1166
+ if (MODERN_COLOR_FUNCTION_NAMES.has(name) || name === "color" && isDisplayP3ColorFunction(source) || isModernColorSyntaxFunction(source)) normalized = normalizeStandaloneColorFunction(source);
1167
+ else if (name === "color-mix") normalized = tryResolveColorMix(node, customPropertyValues)?.value;
1168
+ if (!normalized) return;
1169
+ const mutableNode = node;
1170
+ mutableNode.type = "word";
1171
+ mutableNode.value = normalized;
1172
+ delete mutableNode.nodes;
1173
+ changed = true;
1174
+ });
1175
+ const nextValue = changed ? parsed.toString() : value;
1176
+ return {
1177
+ value: nextValue,
1178
+ changed,
1179
+ hasUnsupported: hasUnsupportedModernColorFunction(nextValue)
1180
+ };
1181
+ }
1182
+ function createPlaceholder(index) {
1183
+ return `${PLACEHOLDER_PREFIX}${index}__`;
1184
+ }
1185
+ function unwrapProtectedSupports(cssRoot) {
1186
+ cssRoot.walkAtRules("supports", (atRule) => {
1187
+ if (!atRule.nodes || !atRule.toString().includes("__weapp_tw_color_mix_")) return;
1188
+ atRule.replaceWith(atRule.nodes);
1189
+ });
1190
+ }
1191
+ function protectDynamicColorMixAlpha(css, options = {}) {
1192
+ if (!css.includes("color-mix")) return {
1193
+ css,
1194
+ restore: (value) => value
1195
+ };
1196
+ const replacements = /* @__PURE__ */ new Map();
1197
+ const root = postcss.default.parse(css);
1198
+ const customPropertyValues = new Map(options.customPropertyValues);
1199
+ let changed = false;
1200
+ root.walkDecls((decl) => {
1201
+ if (decl.prop.startsWith("--") && !decl.value.includes("color-mix")) customPropertyValues.set(decl.prop, decl.value.trim());
1202
+ });
1203
+ root.walkDecls((decl) => {
1204
+ if (!decl.value.includes("color-mix")) return;
1205
+ const parsed = (0, postcss_value_parser.default)(decl.value);
1206
+ let mutated = false;
1207
+ parsed.walk((node) => {
1208
+ if (node.type !== "function" || node.value.toLowerCase() !== "color-mix") return;
1209
+ const resolved = tryResolveColorMix(node, customPropertyValues);
1210
+ if (resolved) {
1211
+ if (resolved.deferred) {
1212
+ const placeholder = createPlaceholder(replacements.size);
1213
+ replacements.set(placeholder, resolved.value);
1214
+ const mutableNode = node;
1215
+ mutableNode.type = "word";
1216
+ mutableNode.value = placeholder;
1217
+ delete mutableNode.nodes;
1218
+ mutated = true;
1219
+ return;
1220
+ }
1221
+ const mutableNode = node;
1222
+ mutableNode.type = "word";
1223
+ mutableNode.value = resolved.value;
1224
+ delete mutableNode.nodes;
1225
+ mutated = true;
1226
+ }
1227
+ });
1228
+ if (mutated) {
1229
+ decl.value = parsed.toString();
1230
+ changed = true;
1231
+ }
1232
+ });
1233
+ if (replacements.size > 0) unwrapProtectedSupports(root);
1234
+ return {
1235
+ css: changed ? root.toString() : css,
1236
+ restore(value) {
1237
+ let restored = value;
1238
+ for (const [placeholder, replacement] of replacements) restored = restored.split(placeholder).join(replacement);
1239
+ return restored;
1240
+ }
1241
+ };
1242
+ }
1243
+ //#endregion
1244
+ //#region src/compat/mini-program-css/color-gamut.ts
1245
+ const DISPLAY_P3_VALUE_RE = /color\(\s*display-p3\b/i;
1246
+ const COLOR_GAMUT_P3_RE = /\(\s*color-gamut\s*:\s*p3\s*\)/i;
1247
+ function isDisplayP3MediaRule(atRule) {
1248
+ return atRule.name === "media" && COLOR_GAMUT_P3_RE.test(atRule.params);
1249
+ }
1250
+ function isDisplayP3Declaration(decl) {
1251
+ return DISPLAY_P3_VALUE_RE.test(decl.value);
1252
+ }
1253
+ //#endregion
1254
+ //#region src/compat/mini-program-css/root-cleanups.ts
1255
+ function removeSpecificityPlaceholders(root) {
1256
+ root.walkRules((rule) => {
1257
+ if (!rule.selectors || rule.selectors.length === 0) return;
1258
+ let changed = false;
1259
+ const selectors = rule.selectors.map((selector) => {
1260
+ let next = selector;
1261
+ for (const suffix of SPECIFICITY_PLACEHOLDER_SUFFIXES) if (next.includes(suffix)) next = next.split(suffix).join("");
1262
+ if (next !== selector) changed = true;
1263
+ return next;
1264
+ });
1265
+ if (changed) rule.selectors = selectors;
1266
+ });
1267
+ }
1268
+ function hasMiniProgramCssSpecificityPlaceholders(source) {
1269
+ return SPECIFICITY_PLACEHOLDER_SUFFIXES.some((suffix) => source.includes(suffix));
1270
+ }
1271
+ function stripMiniProgramCssSpecificityPlaceholders(source) {
1272
+ let output = source;
1273
+ for (const suffix of SPECIFICITY_PLACEHOLDER_SUFFIXES) if (output.includes(suffix)) output = output.split(suffix).join("");
1274
+ return output;
1275
+ }
1276
+ const removeSpecificityPlaceholdersFromSource = stripMiniProgramCssSpecificityPlaceholders;
1277
+ function removeRootSpecificityPlaceholders(root) {
1278
+ root.walkRules((rule) => {
1279
+ if (!rule.selectors || rule.selectors.length === 0) return;
1280
+ let changed = false;
1281
+ const selectors = rule.selectors.map((selector) => {
1282
+ let next = selector;
1283
+ for (const scopeSelector of MINI_PROGRAM_THEME_SCOPE_SELECTORS) for (const suffix of ROOT_SPECIFICITY_PLACEHOLDER_SUFFIXES) {
1284
+ const target = `${scopeSelector}${suffix}`;
1285
+ if (next.includes(target)) next = next.split(target).join(scopeSelector);
1286
+ }
1287
+ if (next !== selector) changed = true;
1288
+ return next;
1289
+ });
1290
+ if (changed) rule.selectors = selectors;
1291
+ });
1292
+ }
1293
+ function isEffectivelyEmptyContainer(container) {
1294
+ return container.nodes !== void 0 && container.nodes.every((node) => node.type === "comment");
1295
+ }
1296
+ function isKeyframeStepRule(rule) {
1297
+ return rule.parent?.type === "atrule" && rule.parent.name.toLowerCase().endsWith("keyframes");
1298
+ }
1299
+ function removeEmptyAtRules$1(root) {
1300
+ let removed = 0;
1301
+ const visit = (container) => {
1302
+ for (const node of [...container.nodes ?? []]) {
1303
+ if (!("nodes" in node) || node.nodes === void 0) continue;
1304
+ visit(node);
1305
+ if (node.type === "atrule" && node.parent && isEffectivelyEmptyContainer(node)) {
1306
+ node.remove();
1307
+ removed++;
1308
+ }
1309
+ }
1310
+ };
1311
+ visit(root);
1312
+ return removed;
1313
+ }
1314
+ function removeEmptyBlockAtRules(root) {
1315
+ let removed = 0;
1316
+ root.walkAtRules((atRule) => {
1317
+ if (atRule.nodes?.length === 0) {
1318
+ atRule.remove();
1319
+ removed++;
1320
+ }
1321
+ });
1322
+ return removed;
1323
+ }
1324
+ function removeEmptyAtRuleAncestors(parent) {
1325
+ while (parent?.type === "atrule" && isEffectivelyEmptyContainer(parent)) {
1326
+ const nextParent = parent.parent;
1327
+ parent.remove();
1328
+ parent = nextParent?.type === "atrule" ? nextParent : void 0;
1329
+ }
1330
+ }
1331
+ function removeEmptyRules(root) {
1332
+ let removed = 0;
1333
+ root.walkRules((rule) => {
1334
+ if (isKeyframeStepRule(rule) || !rule.parent || !isEffectivelyEmptyContainer(rule)) return;
1335
+ const parent = rule.parent;
1336
+ rule.remove();
1337
+ removeEmptyAtRuleAncestors(parent);
1338
+ removed++;
1339
+ });
1340
+ return removed;
1341
+ }
1342
+ function removeUnsupportedBrowserSelectors(root) {
1343
+ root.walkRules((rule) => {
1344
+ if (!rule.selectors || rule.selectors.length === 0) return;
1345
+ if (isUnsupportedBrowserPreflightSelector(rule.selector)) {
1346
+ const parent = rule.parent;
1347
+ rule.remove();
1348
+ removeEmptyAtRuleAncestors(parent);
1349
+ return;
1350
+ }
1351
+ if (isBrowserElementPreflightRule(rule)) {
1352
+ const parent = rule.parent;
1353
+ rule.remove();
1354
+ removeEmptyAtRuleAncestors(parent);
1355
+ return;
1356
+ }
1357
+ const selectors = rule.selectors.filter((selector) => !isUnsupportedBrowserSelector(selector));
1358
+ if (selectors.length === rule.selectors.length) return;
1359
+ if (selectors.length === 0) {
1360
+ const parent = rule.parent;
1361
+ rule.remove();
1362
+ removeEmptyAtRuleAncestors(parent);
1363
+ return;
1364
+ }
1365
+ rule.selectors = selectors;
1366
+ });
1367
+ }
1368
+ function removeDeclarationAndEmptyRule(decl) {
1369
+ const parent = decl.parent;
1370
+ decl.remove();
1371
+ if (parent?.type === "rule" && parent.nodes.length === 0) {
1372
+ const ruleParent = parent.parent;
1373
+ parent.remove();
1374
+ removeEmptyAtRuleAncestors(ruleParent);
1375
+ }
1376
+ }
1377
+ function removeEmptyStandardDeclarations(root) {
1378
+ root.walkDecls((decl) => {
1379
+ if (!decl.prop.startsWith("--") && decl.value.trim().length === 0 && decl.next()?.type !== "comment") removeDeclarationAndEmptyRule(decl);
1380
+ });
1381
+ }
1382
+ function removeDisplayP3Declarations(root) {
1383
+ root.walkAtRules((atRule) => {
1384
+ if (isDisplayP3MediaRule(atRule)) {
1385
+ const parent = atRule.parent;
1386
+ atRule.remove();
1387
+ removeEmptyAtRuleAncestors(parent);
1388
+ }
1389
+ });
1390
+ }
1391
+ const SIMPLE_MIN_WIDTH_MEDIA_RE = /^\(\s*min-width\s*:[^)]+\)$/i;
1392
+ const TAILWIND_GENERATED_TOKEN_COMMENT_RE = /^\s*tokens:\s*container\s*<=\s*<tailwind generated>\s*$/i;
1393
+ function isContainerMaxWidthOnlyRule(rule) {
1394
+ if (!rule.selectors || rule.selectors.length !== 1 || rule.selectors[0] !== ".container") return false;
1395
+ const declarations = rule.nodes?.filter((node) => node.type === "decl") ?? [];
1396
+ return declarations.length === 1 && declarations[0]?.prop === "max-width" && (rule.nodes ?? []).every((node) => node.type === "decl" || node.type === "comment");
1397
+ }
1398
+ function removeTailwindContainerMaxWidthMediaRules(root) {
1399
+ root.walkAtRules("media", (atRule) => {
1400
+ if (!SIMPLE_MIN_WIDTH_MEDIA_RE.test(atRule.params.trim())) return;
1401
+ atRule.walkRules((rule) => {
1402
+ if (!isContainerMaxWidthOnlyRule(rule)) return;
1403
+ const parent = rule.parent;
1404
+ rule.remove();
1405
+ removeEmptyAtRuleAncestors(parent);
1406
+ });
1407
+ });
1408
+ }
1409
+ function isContainerWidthOnlyRule(rule) {
1410
+ if (!rule.selectors || rule.selectors.length !== 1 || rule.selectors[0] !== ".container") return false;
1411
+ const declarations = rule.nodes?.filter((node) => node.type === "decl") ?? [];
1412
+ return declarations.length === 1 && declarations[0]?.prop === "width" && declarations[0].value.trim() === "100%" && (rule.nodes ?? []).every((node) => node.type === "decl" || node.type === "comment");
1413
+ }
1414
+ function isTailwindGeneratedContainerRule(rule) {
1415
+ const previous = rule.prev();
1416
+ return previous?.type === "comment" && TAILWIND_GENERATED_TOKEN_COMMENT_RE.test(previous.text);
1417
+ }
1418
+ function removeTailwindContainerWidthRules(root, options = {}) {
1419
+ root.walkRules((rule) => {
1420
+ if (!isContainerWidthOnlyRule(rule)) return;
1421
+ if (options.generatedOnly && !isTailwindGeneratedContainerRule(rule)) return;
1422
+ const parent = rule.parent;
1423
+ if (isTailwindGeneratedContainerRule(rule)) rule.prev()?.remove();
1424
+ rule.remove();
1425
+ removeEmptyAtRuleAncestors(parent);
1426
+ });
1427
+ }
1428
+ function removeUnsupportedModernColorDeclarations(root) {
1429
+ const customPropertyValues = /* @__PURE__ */ new Map();
1430
+ root.walkDecls((decl) => {
1431
+ if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
1432
+ });
1433
+ root.walkDecls((decl) => {
1434
+ const normalized = normalizeModernColorValue(decl.value, customPropertyValues);
1435
+ if (normalized.changed) {
1436
+ decl.value = normalized.value;
1437
+ if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
1438
+ }
1439
+ if (normalized.hasUnsupported) removeDeclarationAndEmptyRule(decl);
1440
+ });
1441
+ }
1442
+ //#endregion
1443
+ //#region src/compat/mini-program-prefixes.ts
1444
+ const PRESERVED_WEBKIT_DECLARATION_PROPS = /* @__PURE__ */ new Set([
1445
+ "-webkit-box-orient",
1446
+ "-webkit-line-clamp",
1447
+ "-webkit-overflow-scrolling",
1448
+ "-webkit-text-fill-color",
1449
+ "-webkit-text-stroke",
1450
+ "-webkit-text-stroke-color",
1451
+ "-webkit-text-stroke-width"
1452
+ ]);
1453
+ const PRESERVED_WEBKIT_VALUE_DECLARATIONS = /* @__PURE__ */ new Map([["display", /* @__PURE__ */ new Set(["-webkit-box"])], ["-webkit-background-clip", /* @__PURE__ */ new Set(["text"])]]);
1454
+ const TRANSITION_PROPS = /* @__PURE__ */ new Set(["transition", "transition-property"]);
1455
+ function splitTopLevelCommaList(value) {
1456
+ const parts = [];
1457
+ let start = 0;
1458
+ let depth = 0;
1459
+ let quote;
1460
+ let escaped = false;
1461
+ for (let i = 0; i < value.length; i++) {
1462
+ const char = value[i];
1463
+ if (escaped) {
1464
+ escaped = false;
1465
+ continue;
1466
+ }
1467
+ if (char === "\\") {
1468
+ escaped = true;
1469
+ continue;
1470
+ }
1471
+ if (quote) {
1472
+ if (char === quote) quote = void 0;
1473
+ continue;
1474
+ }
1475
+ if (char === "\"" || char === "'") {
1476
+ quote = char;
1477
+ continue;
1478
+ }
1479
+ if (char === "(") {
1480
+ depth++;
1481
+ continue;
1482
+ }
1483
+ if (char === ")") {
1484
+ depth = Math.max(0, depth - 1);
1485
+ continue;
1486
+ }
1487
+ if (char === "," && depth === 0) {
1488
+ parts.push(value.slice(start, i));
1489
+ start = i + 1;
1490
+ }
1491
+ }
1492
+ parts.push(value.slice(start));
1493
+ return parts;
1494
+ }
1495
+ function isPreservedWebkitDeclaration(decl) {
1496
+ const prop = decl.prop.toLowerCase();
1497
+ if (prop.startsWith("-webkit-mask")) return true;
1498
+ if (PRESERVED_WEBKIT_DECLARATION_PROPS.has(prop)) return true;
1499
+ return PRESERVED_WEBKIT_VALUE_DECLARATIONS.get(prop)?.has(decl.value.trim().toLowerCase()) ?? false;
1500
+ }
1501
+ function normalizeTransitionValue(value) {
1502
+ return splitTopLevelCommaList(value).map((part) => part.trim()).filter((part) => part.length > 0 && !part.toLowerCase().startsWith("-webkit-")).join(", ");
1503
+ }
1504
+ function hasUnsupportedWebkitKeywordValue(decl) {
1505
+ const value = decl.value.trim().toLowerCase();
1506
+ if (!value.startsWith("-webkit-")) return false;
1507
+ if (PRESERVED_WEBKIT_VALUE_DECLARATIONS.get(decl.prop.toLowerCase())?.has(value)) return false;
1508
+ return /^-webkit-[\w-]+$/.test(value);
1509
+ }
1510
+ /**
1511
+ * 收敛小程序 CSS 中的 WebKit 前缀,只保留 WXSS 里有实际价值的兼容写法。
1512
+ */
1513
+ function normalizeMiniProgramPrefixedDeclaration(decl) {
1514
+ const prop = decl.prop.toLowerCase();
1515
+ if (TRANSITION_PROPS.has(prop) && decl.value.toLowerCase().includes("-webkit-")) {
1516
+ const value = normalizeTransitionValue(decl.value);
1517
+ if (value.length === 0) {
1518
+ decl.remove();
1519
+ return;
1520
+ }
1521
+ decl.value = value;
1522
+ }
1523
+ if (prop.startsWith("-webkit-") && !isPreservedWebkitDeclaration(decl)) {
1524
+ decl.remove();
1525
+ return;
1526
+ }
1527
+ if (hasUnsupportedWebkitKeywordValue(decl)) decl.remove();
1528
+ }
1529
+ function removeUnsupportedMiniProgramPrefixedAtRule(atRule) {
1530
+ if (atRule.name.toLowerCase() === "-webkit-keyframes") atRule.remove();
1531
+ }
1532
+ //#endregion
1533
+ //#region src/compat/tailwindcss-v4/gradients.ts
1534
+ function collectTailwindcssV4ThemeVariables(root) {
1535
+ const variables = /* @__PURE__ */ new Map();
1536
+ root.walkRules((rule) => {
1537
+ if (!testIfRootHostForV4(rule) && !rule.selector.includes("page") && !rule.selector.includes(".tw-root")) return;
1538
+ rule.walkDecls((decl) => {
1539
+ if (decl.prop.startsWith("--color-")) variables.set(decl.prop, decl.value);
1540
+ });
1541
+ });
1542
+ return variables;
1543
+ }
1544
+ function resolveTailwindcssV4GradientColor(value, themeVariables) {
1545
+ const trimmed = value.trim();
1546
+ const match = COLOR_VAR_RE.exec(trimmed);
1547
+ if (!match) return trimmed;
1548
+ return themeVariables.get(match[1]) ?? trimmed;
1549
+ }
1550
+ function getSingleClassSelector(selector) {
1551
+ const match = SIMPLE_CLASS_SELECTOR_RE.exec(selector.trim());
1552
+ return match ? match[1] : void 0;
1553
+ }
1554
+ function normalizeDeclarationValue(value) {
1555
+ return value.replace(/\s+/g, " ").trim();
1556
+ }
1557
+ function normalizeTailwindcssV4GradientPosition(value) {
1558
+ return value.replace(/calc\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:deg|grad|rad|turn))\s*\*\s*-1\s*\)/gi, "-$1").replace(/^in\s+(?:oklab|oklch|hsl|srgb)(?:\s+(?:longer|shorter|increasing|decreasing)\s+hue)?$/i, "").replace(/\s+in\s+(?:oklab|oklch|hsl|srgb)(?:\s+(?:longer|shorter|increasing|decreasing)\s+hue)?\s*$/i, "").replace(/\s+(?:longer|shorter|increasing|decreasing)\s*$/i, "").trim();
1559
+ }
1560
+ function normalizeTailwindcssV4InfinityCalcValue(value) {
1561
+ return INFINITY_CALC_VALUE_REGEXP.test(value.trim()) ? `${CLAMP_PX}px` : value;
1562
+ }
1563
+ const INFINITY_CALC_CSS_RE = /calc\(\s*infinity\s*\*\s*(?:\d+(?:\.\d*)?|\.\d+)r?px\s*\)/gi;
1564
+ /** 在预处理器解析前收敛 Tailwind v4 生成的无限圆角,避免 Sass 将 infinity 当作非法表达式。 */
1565
+ function normalizeTailwindcssV4InfinityCalcCss(css) {
1566
+ return css.replace(INFINITY_CALC_CSS_RE, `${CLAMP_PX}px`);
1567
+ }
1568
+ function normalizeTailwindcssV4GradientDirectionDeclaration(rule, decl) {
1569
+ const normalized = normalizeTailwindcssV4GradientPosition(decl.value);
1570
+ if (normalized) return normalized;
1571
+ const backgroundImageDecl = rule.nodes.find((node) => {
1572
+ return node.type === "decl" && node.prop === "background-image";
1573
+ });
1574
+ if (!backgroundImageDecl) return normalized;
1575
+ if (/^radial-gradient\(/i.test(backgroundImageDecl.value)) return "at center";
1576
+ if (/^conic-gradient\(/i.test(backgroundImageDecl.value)) return "from 0deg";
1577
+ return normalized;
1578
+ }
1579
+ function appendStopPosition(color, position) {
1580
+ const normalizedPosition = position?.trim();
1581
+ return normalizedPosition ? `${color} ${normalizedPosition}` : color;
1582
+ }
1583
+ function getGradientStopsFallback(value) {
1584
+ if (!value.includes("var(") || !value.includes("--tw-gradient-stops")) return;
1585
+ const parsed = (0, postcss_value_parser.default)(value);
1586
+ let fallback;
1587
+ parsed.walk((node) => {
1588
+ if (fallback || node.type !== "function" || node.value.toLowerCase() !== "var") return;
1589
+ const firstCommaIndex = node.nodes.findIndex((child) => child.type === "div" && child.value === ",");
1590
+ const firstArg = node.nodes.find((child) => child.type !== "space");
1591
+ if (firstArg?.type !== "word" || firstArg.value !== "--tw-gradient-stops" || firstCommaIndex < 0) return;
1592
+ fallback = postcss_value_parser.default.stringify(node.nodes.slice(firstCommaIndex + 1)).trim();
1593
+ });
1594
+ return fallback;
1595
+ }
1596
+ function isTailwindcssV4GradientDirectionRule(rule) {
1597
+ const classSelector = getSingleClassSelector(rule.selector);
1598
+ if (!classSelector || !GRADIENT_DIRECTION_CLASS_RE.test(classSelector)) return false;
1599
+ return rule.nodes.some((node) => {
1600
+ return node.type === "decl" && (node.prop === "--tw-gradient-position" || node.prop === "background-image" && node.value.includes("linear-gradient("));
1601
+ });
1602
+ }
1603
+ function reorderTailwindcssV4GradientDirectionRule(rule) {
1604
+ const gradientPositionDecls = [];
1605
+ const gradientBackgroundDecls = [];
1606
+ for (const node of rule.nodes) {
1607
+ if (node.type !== "decl") continue;
1608
+ if (node.prop === "--tw-gradient-position") gradientPositionDecls.push(node);
1609
+ else if (node.prop === "background-image" && node.value.includes("linear-gradient(")) gradientBackgroundDecls.push(node);
1610
+ }
1611
+ if (gradientPositionDecls.length === 0 || gradientBackgroundDecls.length === 0) return;
1612
+ for (const decl of gradientPositionDecls) decl.value = normalizeTailwindcssV4GradientDirectionDeclaration(rule, decl);
1613
+ const anchor = rule.nodes.find((node) => {
1614
+ return node.type === "decl" && (node.prop === "--tw-gradient-position" || node.prop === "background-image" && node.value.includes("linear-gradient("));
1615
+ });
1616
+ if (!anchor) return;
1617
+ const ordered = [...gradientPositionDecls, ...gradientBackgroundDecls];
1618
+ const orderedClones = ordered.map((decl) => decl.clone());
1619
+ anchor.replaceWith(...orderedClones);
1620
+ for (const decl of ordered) if (decl.parent) decl.remove();
1621
+ }
1622
+ function mergeTailwindcssV4GradientDirectionRules(root) {
1623
+ const seen = /* @__PURE__ */ new Map();
1624
+ root.walkRules((rule) => {
1625
+ if (!isTailwindcssV4GradientDirectionRule(rule)) return;
1626
+ rule.walkDecls("--tw-gradient-position", (decl) => {
1627
+ decl.value = normalizeTailwindcssV4GradientDirectionDeclaration(rule, decl);
1628
+ });
1629
+ const selector = rule.selector.trim();
1630
+ const previous = seen.get(selector);
1631
+ if (!previous || previous.parent !== rule.parent) {
1632
+ seen.set(selector, rule);
1633
+ return;
1634
+ }
1635
+ for (const node of [...rule.nodes]) {
1636
+ if (node.type !== "decl") continue;
1637
+ if (node.prop !== "--tw-gradient-position" && node.prop !== "background-image") continue;
1638
+ previous.append(node.clone());
1639
+ }
1640
+ reorderTailwindcssV4GradientDirectionRule(previous);
1641
+ rule.remove();
1642
+ });
1643
+ }
1644
+ function createTailwindcssV4MiniProgramGradientValue(gradient, from, to, via) {
1645
+ const stops = [gradient.position, appendStopPosition(from.color, from.position)];
1646
+ if (via) stops.push(appendStopPosition(via.color, via.position));
1647
+ stops.push(appendStopPosition(to.color, to.position));
1648
+ return `${gradient.type}-gradient(${stops.filter(Boolean).join(", ")})`;
1649
+ }
1650
+ function appendTailwindcssV4MiniProgramGradientRules(root) {
1651
+ const themeVariables = collectTailwindcssV4ThemeVariables(root);
1652
+ const gradients = [];
1653
+ const fromColors = /* @__PURE__ */ new Map();
1654
+ const viaColors = /* @__PURE__ */ new Map();
1655
+ const toColors = /* @__PURE__ */ new Map();
1656
+ const fromPositions = [];
1657
+ const viaPositions = [];
1658
+ const toPositions = [];
1659
+ const directBackgroundImages = [];
1660
+ const existingBackgroundImages = /* @__PURE__ */ new Map();
1661
+ const ruleOrder = /* @__PURE__ */ new Map();
1662
+ let order = 0;
1663
+ root.walkRules((rule) => {
1664
+ const classSelector = getSingleClassSelector(rule.selector);
1665
+ const currentOrder = order++;
1666
+ if (classSelector) ruleOrder.set(classSelector, currentOrder);
1667
+ rule.walkDecls("background-image", (decl) => {
1668
+ const selector = rule.selector.trim();
1669
+ const values = existingBackgroundImages.get(selector);
1670
+ if (values) values.add(normalizeDeclarationValue(decl.value));
1671
+ else existingBackgroundImages.set(selector, /* @__PURE__ */ new Set([normalizeDeclarationValue(decl.value)]));
1672
+ });
1673
+ if (classSelector) {
1674
+ const gradientPositionDecl = rule.nodes.find((node) => {
1675
+ return node.type === "decl" && node.prop === "--tw-gradient-position";
1676
+ });
1677
+ const gradientBackgroundDecl = rule.nodes.find((node) => {
1678
+ return node.type === "decl" && node.prop === "background-image" && GRADIENT_BACKGROUND_RE.test(node.value);
1679
+ });
1680
+ if (gradientPositionDecl && gradientBackgroundDecl) {
1681
+ const gradientType = GRADIENT_BACKGROUND_RE.exec(gradientBackgroundDecl.value)?.[1];
1682
+ if (gradientType) {
1683
+ gradients.push({
1684
+ classSelector,
1685
+ order: currentOrder,
1686
+ position: normalizeTailwindcssV4GradientDirectionDeclaration(rule, gradientPositionDecl),
1687
+ type: gradientType
1688
+ });
1689
+ const fallback = GRADIENT_STOPS_VAR_RE.test(gradientBackgroundDecl.value) ? getGradientStopsFallback(gradientBackgroundDecl.value) : void 0;
1690
+ if (fallback) directBackgroundImages.push({
1691
+ selector: rule.selector.trim(),
1692
+ value: `${gradientType}-gradient(${fallback})`
1693
+ });
1694
+ }
1695
+ }
1696
+ rule.walkDecls((decl) => {
1697
+ if (decl.prop === "--tw-gradient-from") fromColors.set(classSelector, {
1698
+ classSelector,
1699
+ color: resolveTailwindcssV4GradientColor(decl.value, themeVariables),
1700
+ order: currentOrder
1701
+ });
1702
+ else if (decl.prop === "--tw-gradient-from-position") fromPositions.push({
1703
+ classSelector,
1704
+ position: decl.value
1705
+ });
1706
+ else if (decl.prop === "--tw-gradient-via") viaColors.set(classSelector, {
1707
+ classSelector,
1708
+ color: resolveTailwindcssV4GradientColor(decl.value, themeVariables),
1709
+ order: currentOrder
1710
+ });
1711
+ else if (decl.prop === "--tw-gradient-via-position") viaPositions.push({
1712
+ classSelector,
1713
+ position: decl.value
1714
+ });
1715
+ else if (decl.prop === "--tw-gradient-to") toColors.set(classSelector, {
1716
+ classSelector,
1717
+ color: resolveTailwindcssV4GradientColor(decl.value, themeVariables),
1718
+ order: currentOrder
1719
+ });
1720
+ else if (decl.prop === "--tw-gradient-to-position") toPositions.push({
1721
+ classSelector,
1722
+ position: decl.value
1723
+ });
1724
+ });
1725
+ }
1726
+ });
1727
+ const fromVariants = [];
1728
+ const viaVariants = [];
1729
+ const toVariants = [];
1730
+ const positionedFromVariants = [];
1731
+ const positionedViaVariants = [];
1732
+ const positionedToVariants = [];
1733
+ for (const color of fromColors.values()) {
1734
+ fromVariants.push(color);
1735
+ for (const position of fromPositions) positionedFromVariants.push({
1736
+ ...color,
1737
+ classSelector: `${color.classSelector}.${position.classSelector}`,
1738
+ order: Math.max(color.order, ruleOrder.get(position.classSelector) ?? color.order),
1739
+ position: position.position
1740
+ });
1741
+ }
1742
+ for (const color of viaColors.values()) {
1743
+ viaVariants.push(color);
1744
+ for (const position of viaPositions) positionedViaVariants.push({
1745
+ ...color,
1746
+ classSelector: `${color.classSelector}.${position.classSelector}`,
1747
+ order: Math.max(color.order, ruleOrder.get(position.classSelector) ?? color.order),
1748
+ position: position.position
1749
+ });
1750
+ }
1751
+ for (const color of toColors.values()) {
1752
+ toVariants.push(color);
1753
+ for (const position of toPositions) positionedToVariants.push({
1754
+ ...color,
1755
+ classSelector: `${color.classSelector}.${position.classSelector}`,
1756
+ order: Math.max(color.order, ruleOrder.get(position.classSelector) ?? color.order),
1757
+ position: position.position
1758
+ });
1759
+ }
1760
+ function appendGradientRule(selector, value) {
1761
+ const normalizedValue = normalizeDeclarationValue(value);
1762
+ if (existingBackgroundImages.get(selector)?.has(normalizedValue)) return;
1763
+ existingBackgroundImages.set(selector, /* @__PURE__ */ new Set([...existingBackgroundImages.get(selector) ?? [], normalizedValue]));
1764
+ root.append((0, postcss.rule)({
1765
+ selector,
1766
+ nodes: [new postcss.Declaration({
1767
+ prop: "background-image",
1768
+ value
1769
+ })]
1770
+ }));
1771
+ }
1772
+ for (const { selector, value } of directBackgroundImages) appendGradientRule(selector, value);
1773
+ function appendGradientCombinations(gradient, fromRules, viaRules, toRules) {
1774
+ for (const from of fromRules) for (const to of toRules) {
1775
+ appendGradientRule(`.${gradient.classSelector}.${from.classSelector}.${to.classSelector}`, createTailwindcssV4MiniProgramGradientValue(gradient, from, to));
1776
+ for (const via of viaRules) appendGradientRule(`.${gradient.classSelector}.${from.classSelector}.${via.classSelector}.${to.classSelector}`, createTailwindcssV4MiniProgramGradientValue(gradient, from, to, via));
1777
+ }
1778
+ }
1779
+ for (const gradient of gradients) {
1780
+ if (gradient.position.includes(",") || /^var\(/i.test(gradient.position)) continue;
1781
+ appendGradientCombinations(gradient, fromVariants, viaVariants, toVariants);
1782
+ appendGradientCombinations(gradient, positionedFromVariants, positionedViaVariants, positionedToVariants);
1783
+ }
1784
+ }
1785
+ //#endregion
1786
+ //#region src/compat/tailwindcss-v4/declarations.ts
1787
+ function normalizeTailwindcssV4EmptyVarFallback(value) {
1788
+ if (!value.includes("var(") || !value.includes("--tw-")) return value;
1789
+ const parsed = (0, postcss_value_parser.default)(value);
1790
+ let changed = false;
1791
+ parsed.walk((node) => {
1792
+ if (node.type !== "function" || node.value.toLowerCase() !== "var") return;
1793
+ const firstArg = node.nodes.find((child) => child.type !== "space");
1794
+ const lastArg = node.nodes.findLast((child) => child.type !== "space");
1795
+ if (firstArg?.type !== "word" || !firstArg.value.startsWith("--tw-") || lastArg?.type !== "div" || lastArg.value !== "," || node.after === " ") return;
1796
+ node.after = " ";
1797
+ changed = true;
1798
+ });
1799
+ return changed ? parsed.toString() : value;
1800
+ }
1801
+ function normalizeTailwindcssV4GradientStopsFallback(value) {
1802
+ if (!value.includes("var(") || !value.includes("--tw-gradient-via-stops")) return value;
1803
+ const parsed = (0, postcss_value_parser.default)(value);
1804
+ let changed = false;
1805
+ function normalizeNodes(nodes) {
1806
+ for (let index = 0; index < nodes.length; index++) {
1807
+ const node = nodes[index];
1808
+ if (!node) continue;
1809
+ if (node.type === "function" && node.value.toLowerCase() !== "var") {
1810
+ normalizeNodes(node.nodes);
1811
+ continue;
1812
+ }
1813
+ if (node.type !== "function") continue;
1814
+ const firstArg = node.nodes.filter((child) => child.type !== "space")[0];
1815
+ if (firstArg?.type !== "word" || firstArg.value !== "--tw-gradient-via-stops") {
1816
+ normalizeNodes(node.nodes);
1817
+ continue;
1818
+ }
1819
+ const firstCommaIndex = node.nodes.findIndex((child) => child.type === "div" && child.value === ",");
1820
+ if (firstCommaIndex < 0) continue;
1821
+ const fallbackNodes = node.nodes.slice(firstCommaIndex + 1);
1822
+ const splitIndex = fallbackNodes.findIndex((child) => child.type === "div" && child.value === ",");
1823
+ if (splitIndex < 0) continue;
1824
+ const viaFallbackNodes = fallbackNodes.slice(0, splitIndex);
1825
+ const stopNodes = fallbackNodes.slice(splitIndex);
1826
+ const nextVarNode = {
1827
+ ...node,
1828
+ nodes: [
1829
+ {
1830
+ type: "word",
1831
+ value: "--tw-gradient-via-stops"
1832
+ },
1833
+ {
1834
+ type: "div",
1835
+ value: ",",
1836
+ before: "",
1837
+ after: " "
1838
+ },
1839
+ ...viaFallbackNodes
1840
+ ],
1841
+ sourceEndIndex: void 0,
1842
+ sourceIndex: void 0
1843
+ };
1844
+ nodes.splice(index, 1, nextVarNode, ...stopNodes);
1845
+ changed = true;
1846
+ index += stopNodes.length;
1847
+ }
1848
+ }
1849
+ normalizeNodes(parsed.nodes);
1850
+ return changed ? parsed.toString() : value;
1851
+ }
1852
+ function normalizeTailwindcssV4GradientPositionFallback(value) {
1853
+ if (!value.includes("var(") || !value.includes("--tw-gradient-")) return value;
1854
+ const parsed = (0, postcss_value_parser.default)(value);
1855
+ let changed = false;
1856
+ parsed.walk((node) => {
1857
+ if (node.type !== "function" || node.value.toLowerCase() !== "var") return;
1858
+ const args = node.nodes.filter((child) => child.type !== "space");
1859
+ const firstArg = args[0];
1860
+ if (firstArg?.type !== "word" || !TW_GRADIENT_POSITION_PROPS.has(firstArg.value)) return;
1861
+ const commaIndex = args.findIndex((child) => child.type === "div" && child.value === ",");
1862
+ if (commaIndex === -1 ? void 0 : args[commaIndex]) {
1863
+ if (!args.slice(commaIndex + 1).some((child) => child.type !== "space") && node.after !== " ") {
1864
+ node.after = " ";
1865
+ changed = true;
1866
+ }
1867
+ return;
1868
+ }
1869
+ node.nodes.push({
1870
+ type: "div",
1871
+ value: ",",
1872
+ before: "",
1873
+ after: ""
1874
+ });
1875
+ node.after = " ";
1876
+ changed = true;
1877
+ });
1878
+ return changed ? parsed.toString() : value;
1879
+ }
1880
+ function normalizeTailwindcssV4Declaration(decl) {
1881
+ let changed = false;
1882
+ if (decl.prop === "--tw-gradient-via-stops" && decl.value.trim() === "initial") {
1883
+ decl.remove();
1884
+ return true;
1885
+ }
1886
+ const normalizedEmptyVarFallback = normalizeTailwindcssV4EmptyVarFallback(decl.value);
1887
+ if (normalizedEmptyVarFallback !== decl.value) {
1888
+ decl.value = normalizedEmptyVarFallback;
1889
+ changed = true;
1890
+ }
1891
+ const normalizedGradientStopsFallback = normalizeTailwindcssV4GradientStopsFallback(decl.value);
1892
+ if (normalizedGradientStopsFallback !== decl.value) {
1893
+ decl.value = normalizedGradientStopsFallback;
1894
+ changed = true;
1895
+ }
1896
+ const normalizedGradientPositionFallback = normalizeTailwindcssV4GradientPositionFallback(decl.value);
1897
+ if (normalizedGradientPositionFallback !== decl.value) {
1898
+ decl.value = normalizedGradientPositionFallback;
1899
+ changed = true;
1900
+ }
1901
+ if (decl.prop === "--tw-gradient-position") {
1902
+ const nextValue = decl.parent?.type === "rule" ? normalizeTailwindcssV4GradientDirectionDeclaration(decl.parent, decl) : normalizeTailwindcssV4GradientPosition(decl.value);
1903
+ if (nextValue !== decl.value) {
1904
+ decl.value = nextValue;
1905
+ return true;
1906
+ }
1907
+ }
1908
+ const normalizedInfinityCalcValue = normalizeTailwindcssV4InfinityCalcValue(decl.value);
1909
+ if (normalizedInfinityCalcValue !== decl.value) {
1910
+ decl.value = normalizedInfinityCalcValue;
1911
+ return true;
1912
+ }
1913
+ if (decl.prop.includes("radius")) {
1914
+ RADIUS_VALUE_RE.lastIndex = 0;
1915
+ const next = decl.value.replace(RADIUS_VALUE_RE, (m, num) => {
1916
+ const n = Number(num);
1917
+ if (!Number.isFinite(n)) return `${CLAMP_PX}px`;
1918
+ if (SCIENTIFIC_NOTATION_RE.test(String(num)) || n > 1e5) return `${CLAMP_PX}px`;
1919
+ return m;
1920
+ });
1921
+ if (next !== decl.value) {
1922
+ decl.value = next;
1923
+ return true;
1924
+ }
1925
+ }
1926
+ return changed;
1927
+ }
1928
+ //#endregion
1929
+ //#region src/syntax/css-import.ts
1930
+ function significantTokens(params) {
1931
+ return (0, _csstools_css_tokenizer.tokenize)({ css: params }).filter((token) => token[0] !== _csstools_css_tokenizer.TokenType.Whitespace && token[0] !== _csstools_css_tokenizer.TokenType.Comment);
1932
+ }
1933
+ function isCssWhitespace(char) {
1934
+ return char === " " || char === " " || char === "\n" || char === "\r" || char === "\f";
1935
+ }
1936
+ function skipCssWhitespace(params, index) {
1937
+ while (index < params.length && isCssWhitespace(params[index])) index++;
1938
+ return index;
1939
+ }
1940
+ function parseSimpleQuotedSpecifier(params, start) {
1941
+ const quote = params[start];
1942
+ if (quote !== "\"" && quote !== "'") return;
1943
+ let index = start + 1;
1944
+ while (index < params.length) {
1945
+ const char = params[index];
1946
+ if (char === "\\" || char === "\n" || char === "\r") return;
1947
+ if (char === quote) return {
1948
+ specifier: params.slice(start + 1, index),
1949
+ raw: params.slice(start, index + 1),
1950
+ quote
1951
+ };
1952
+ index++;
1953
+ }
1954
+ }
1955
+ function parseSimpleImportSpecifier(params) {
1956
+ let index = skipCssWhitespace(params, 0);
1957
+ const quoted = parseSimpleQuotedSpecifier(params, index);
1958
+ if (quoted) return quoted;
1959
+ if (params.slice(index, index + 4).toLowerCase() !== "url(") return;
1960
+ const urlStart = index;
1961
+ index = skipCssWhitespace(params, index + 4);
1962
+ const inner = parseSimpleQuotedSpecifier(params, index);
1963
+ if (!inner) return;
1964
+ index = skipCssWhitespace(params, index + inner.raw.length);
1965
+ if (params[index] !== ")") return;
1966
+ return {
1967
+ specifier: inner.specifier,
1968
+ raw: params.slice(urlStart, index + 1),
1969
+ quote: inner.quote
1970
+ };
1971
+ }
1972
+ /**
1973
+ * 解析 `@import` / `@use` / `@forward` 参数中的请求串。
1974
+ * 无 escape/注释的引号和 `url("...")` 走快路径;复杂输入才使用 CSS tokenizer。
1975
+ */
1976
+ function parseCssImportSpecifier(params) {
1977
+ const simple = parseSimpleImportSpecifier(params);
1978
+ if (simple) return simple;
1979
+ const tokens = significantTokens(params);
1980
+ const first = tokens[0];
1981
+ if (!first || first[0] === _csstools_css_tokenizer.TokenType.EOF) return;
1982
+ if (first[0] === _csstools_css_tokenizer.TokenType.String || first[0] === _csstools_css_tokenizer.TokenType.URL || first[0] === _csstools_css_tokenizer.TokenType.Ident) return {
1983
+ specifier: first[4].value,
1984
+ raw: first[1],
1985
+ quote: first[0] === _csstools_css_tokenizer.TokenType.String ? first[1][0] : void 0
1986
+ };
1987
+ if (first[0] === _csstools_css_tokenizer.TokenType.Function && first[4].value.toLowerCase() === "url" && (tokens[1]?.[0] === _csstools_css_tokenizer.TokenType.String || tokens[1]?.[0] === _csstools_css_tokenizer.TokenType.Ident) && tokens[2]?.[0] === _csstools_css_tokenizer.TokenType.CloseParen) return {
1988
+ specifier: tokens[1][4].value,
1989
+ raw: params.slice(first[2], tokens[2][3] + 1),
1990
+ quote: tokens[1][0] === _csstools_css_tokenizer.TokenType.String ? tokens[1][1][0] : void 0
1991
+ };
1992
+ }
1993
+ /** 把文件系统路径写成 CSS 请求串;缓存和读文件仍使用原始路径。 */
1994
+ function quoteCssImportSpecifier(file, quote = "\"") {
1995
+ return `${quote}${(node_path.default.sep === "\\" || /^[a-z]:[\\/]|^\\\\/i.test(file) ? file.replaceAll("\\", "/") : file).replaceAll("\\", "\\\\").replaceAll(quote, `\\${quote}`).replaceAll("\n", "\\a ").replaceAll("\r", "\\d ")}${quote}`;
1996
+ }
1997
+ /** 判断 import 参数是否指向 Tailwind CSS 包入口。 */
1998
+ function isTailwindCssImport(params) {
1999
+ const specifier = parseCssImportSpecifier(params)?.specifier;
2000
+ if (!specifier) return false;
2001
+ if (specifier === "tailwindcss" || specifier.startsWith("tailwindcss/")) return true;
2002
+ const paths = specifier.includes("\\") ? node_path.default.win32 : node_path.default.posix;
2003
+ return paths.basename(specifier) === "index.css" && paths.basename(paths.dirname(specifier)) === "tailwindcss";
2004
+ }
2005
+ /** 解析 `@import "..." source(...)` 中的 source 参数。 */
2006
+ function parseImportSourceParam(params) {
2007
+ const tokens = significantTokens(params);
2008
+ const index = tokens.findIndex((token) => token[0] === _csstools_css_tokenizer.TokenType.Function && token[4].value === "source");
2009
+ const value = tokens[index + 1];
2010
+ if (index < 0 || tokens[index + 2]?.[0] !== _csstools_css_tokenizer.TokenType.CloseParen) return;
2011
+ if (value?.[0] === _csstools_css_tokenizer.TokenType.Ident && value[4].value === "none") return {
2012
+ none: true,
2013
+ sourcePath: void 0
2014
+ };
2015
+ return value?.[0] === _csstools_css_tokenizer.TokenType.String ? {
2016
+ none: false,
2017
+ sourcePath: value[4].value
2018
+ } : void 0;
2019
+ }
2020
+ //#endregion
2021
+ //#region src/compat/mini-program-css/hoist.ts
2022
+ const HOIST_ANCHOR_COMMENT = "__weapp_tailwindcss_base_anchor__";
2023
+ function getTopDirectiveTail(root) {
2024
+ let tail;
2025
+ for (const node of root.nodes ?? []) {
2026
+ if (node.type === "atrule" && (node.name === "charset" || node.name === "import")) {
2027
+ tail = node;
2028
+ continue;
2029
+ }
2030
+ break;
2031
+ }
2032
+ return tail;
2033
+ }
2034
+ function reorderPreflightResetDeclarations(rule) {
2035
+ const declarations = (rule.nodes ?? []).filter((node) => node.type === "decl");
2036
+ if (declarations.length <= 1) return;
2037
+ const resetDeclarations = [];
2038
+ const otherDeclarations = [];
2039
+ for (const declaration of declarations) if (PREFLIGHT_RESET_PROPS.has(declaration.prop)) resetDeclarations.push(declaration);
2040
+ else otherDeclarations.push(declaration);
2041
+ if (resetDeclarations.length === 0 || otherDeclarations.length === 0) return;
2042
+ const orderedDeclarations = [...resetDeclarations, ...otherDeclarations];
2043
+ if (orderedDeclarations.every((declaration, index) => declaration === declarations[index])) return;
2044
+ for (const declaration of declarations) declaration.remove();
2045
+ rule.prepend(...orderedDeclarations);
2046
+ rule.raws.semicolon = true;
2047
+ }
2048
+ function createHoistInsertionAnchor(root) {
2049
+ for (const node of root.nodes ?? []) if (isMiniProgramPreflightRule(node) || isMiniProgramThemeVariableRule(node)) {
2050
+ const anchor = postcss.default.comment({ text: HOIST_ANCHOR_COMMENT });
2051
+ node.before(anchor);
2052
+ return anchor;
2053
+ }
2054
+ }
2055
+ function insertHoistedRules(root, rules, anchor) {
2056
+ if (anchor && !anchor.parent) anchor = void 0;
2057
+ if (rules.length === 0) {
2058
+ anchor?.remove();
2059
+ return;
2060
+ }
2061
+ const topDirectiveTail = getTopDirectiveTail(root);
2062
+ const firstRule = rules[0];
2063
+ if (!firstRule) return;
2064
+ if (anchor) {
2065
+ if (anchor.raws.before === void 0) delete firstRule.raws.before;
2066
+ else firstRule.raws.before = anchor.raws.before;
2067
+ anchor.replaceWith(rules);
2068
+ return;
2069
+ }
2070
+ firstRule.raws.before = topDirectiveTail ? "\n" : "";
2071
+ if (topDirectiveTail) topDirectiveTail.after(rules);
2072
+ else root.prepend(rules);
2073
+ }
2074
+ function mergeEquivalentHoistedRules(rules) {
2075
+ const mergedRules = [];
2076
+ const ruleBySelector = /* @__PURE__ */ new Map();
2077
+ const propsBySelector = /* @__PURE__ */ new Map();
2078
+ for (const rule of rules) {
2079
+ const key = getSortedRuleSelectorKey(rule);
2080
+ const existingRule = ruleBySelector.get(key);
2081
+ if (existingRule) {
2082
+ const existingProps = propsBySelector.get(key) ?? /* @__PURE__ */ new Set();
2083
+ const nextNodes = (rule.nodes ?? []).filter((node) => {
2084
+ if (node.type !== "decl") return true;
2085
+ if (existingProps.has(node.prop)) return false;
2086
+ existingProps.add(node.prop);
2087
+ return true;
2088
+ });
2089
+ existingRule.append(...nextNodes.map((node) => node.clone()));
2090
+ reorderPreflightResetDeclarations(existingRule);
2091
+ propsBySelector.set(key, existingProps);
2092
+ continue;
2093
+ }
2094
+ ruleBySelector.set(key, rule);
2095
+ propsBySelector.set(key, new Set((rule.nodes ?? []).flatMap((node) => node.type === "decl" ? [node.prop] : [])));
2096
+ reorderPreflightResetDeclarations(rule);
2097
+ mergedRules.push(rule);
2098
+ }
2099
+ return mergedRules;
2100
+ }
2101
+ //#endregion
2102
+ //#region src/compat/mini-program-css/preflight.ts
2103
+ const MINI_PROGRAM_PSEUDO_CONTENT_SELECTORS = /* @__PURE__ */ new Set(["::before", "::after"]);
2104
+ function applyConfiguredPreflightDeclarations(rule, cssPreflight) {
2105
+ if (!cssPreflight || typeof cssPreflight !== "object") return;
2106
+ const configuredNodes = [];
2107
+ const remainingNodes = [];
2108
+ const remainingDeclarations = /* @__PURE__ */ new Map();
2109
+ for (const node of rule.nodes ?? []) {
2110
+ if (node.type !== "decl") {
2111
+ remainingNodes.push(node);
2112
+ continue;
2113
+ }
2114
+ if (Object.hasOwn(cssPreflight, node.prop)) {
2115
+ remainingDeclarations.set(node.prop, node);
2116
+ continue;
2117
+ }
2118
+ remainingNodes.push(node);
2119
+ }
2120
+ for (const [prop, value] of Object.entries(cssPreflight)) {
2121
+ if (value === false) continue;
2122
+ const declaration = remainingDeclarations.get(prop)?.clone() ?? postcss.default.decl({
2123
+ prop,
2124
+ value: value.toString()
2125
+ });
2126
+ declaration.value = value.toString();
2127
+ configuredNodes.push(declaration);
2128
+ }
2129
+ rule.removeAll();
2130
+ rule.append([...configuredNodes, ...remainingNodes]);
2131
+ }
2132
+ function collectPreflightRules(root, options = {}) {
2133
+ const preflightNodes = [];
2134
+ for (const node of root.nodes ?? []) if (isMiniProgramPreflightRule(node)) preflightNodes.push(node);
2135
+ if (preflightNodes.length === 0) return [];
2136
+ const clonedPreflightRules = preflightNodes.map((node) => {
2137
+ const rule = node.clone();
2138
+ rule.walkDecls("--tw-content", (decl) => {
2139
+ if (isEmptyTwContentDeclaration(decl)) decl.remove();
2140
+ });
2141
+ return rule;
2142
+ });
2143
+ for (const rule of clonedPreflightRules) {
2144
+ const selectors = getRuleSelectors(rule);
2145
+ const hasElementSelector = selectors.some((selector) => selector === "view" || selector === "text");
2146
+ if (selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_PSEUDO_CONTENT_SELECTORS.has(selector))) rule.remove();
2147
+ else if (hasElementSelector && selectors.every((selector) => MINI_PROGRAM_ELEMENT_SCOPE_SELECTORS.has(selector))) {
2148
+ if (options.cssPreflight === false) {
2149
+ rule.removeAll();
2150
+ continue;
2151
+ }
2152
+ rule.selector = MINI_PROGRAM_ELEMENT_SCOPE_SELECTOR;
2153
+ applyConfiguredPreflightDeclarations(rule, options.cssPreflight);
2154
+ }
2155
+ }
2156
+ const nonEmptyPreflightRules = [...clonedPreflightRules.filter((rule) => (rule.nodes?.length ?? 0) > 0)];
2157
+ for (const node of preflightNodes) node.remove();
2158
+ return nonEmptyPreflightRules;
2159
+ }
2160
+ function createPreflightResetRule(cssPreflight) {
2161
+ if (!cssPreflight || typeof cssPreflight !== "object") return;
2162
+ const rule = postcss.default.rule({ selector: MINI_PROGRAM_ELEMENT_SCOPE_SELECTOR });
2163
+ for (const [prop, value] of Object.entries(cssPreflight)) {
2164
+ if (value === false) continue;
2165
+ rule.append({
2166
+ prop,
2167
+ value: value.toString()
2168
+ });
2169
+ }
2170
+ return rule.nodes?.length ? rule : void 0;
2171
+ }
2172
+ //#endregion
2173
+ //#region src/compat/mini-program-css/theme.ts
2174
+ function collectThemeVariableRule(root, options = {}) {
2175
+ const themeRules = [];
2176
+ const declarations = /* @__PURE__ */ new Map();
2177
+ const shouldPreserveContentInit = usesTwContentVariable(root);
2178
+ for (const node of root.nodes ?? []) {
2179
+ if (!isMiniProgramThemeVariableRule(node)) continue;
2180
+ themeRules.push(node);
2181
+ node.walkDecls((decl) => {
2182
+ if (isDisplayP3Declaration(decl)) return;
2183
+ if (decl.prop.startsWith("--tw-")) return;
2184
+ if (!shouldPreserveContentInit && isEmptyTwContentDeclaration(decl)) return;
2185
+ declarations.set(decl.prop, decl.clone());
2186
+ });
2187
+ }
2188
+ for (const rule of themeRules) rule.remove();
2189
+ if (declarations.size === 0) return;
2190
+ const rule = postcss.default.rule({ selector: normalizeMiniProgramThemeScopeSelector(options.cssSelectorReplacement?.root) });
2191
+ for (const decl of declarations.values()) rule.append(decl);
2192
+ return rule;
2193
+ }
2194
+ //#endregion
2195
+ //#region src/compat/mini-program-css/finalize.ts
2196
+ function finalizeMiniProgramCssRoot(root, options = {}) {
2197
+ const shouldInjectTailwindcssV4Defaults = options.isTailwindcssV4 === true;
2198
+ const tailwindcssV4DefaultNodes = shouldInjectTailwindcssV4Defaults ? createMissingCssVarsV4Nodes(root, collectUsedTailwindcssV4Variables(root)) : [];
2199
+ removeUnsupportedCascadeLayers(root);
2200
+ unwrapTailwindSourceMedia(root);
2201
+ removeTailwindGenerationDirectives(root);
2202
+ root.walkAtRules("property", (atRule) => {
2203
+ atRule.remove();
2204
+ });
2205
+ root.walkAtRules("supports", (atRule) => {
2206
+ atRule.remove();
2207
+ });
2208
+ removeSpecificityPlaceholders(root);
2209
+ removeRootSpecificityPlaceholders(root);
2210
+ removeUnsupportedBrowserSelectors(root);
2211
+ removeDisplayP3Declarations(root);
2212
+ removeEmptyStandardDeclarations(root);
2213
+ removeTailwindContainerMaxWidthMediaRules(root);
2214
+ removeTailwindContainerWidthRules(root, { generatedOnly: true });
2215
+ removeUnsupportedModernColorDeclarations(root);
2216
+ root.walkDecls((decl) => {
2217
+ if (shouldInjectTailwindcssV4Defaults) normalizeTailwindcssV4Declaration(decl);
2218
+ normalizeMiniProgramPrefixedDeclaration(decl);
2219
+ });
2220
+ root.walkAtRules((atRule) => {
2221
+ removeUnsupportedMiniProgramPrefixedAtRule(atRule);
2222
+ });
2223
+ if (shouldInjectTailwindcssV4Defaults) {
2224
+ mergeTailwindcssV4GradientDirectionRules(root);
2225
+ if (options.tailwindcssV4GradientFallback === true) appendTailwindcssV4MiniProgramGradientRules(root);
2226
+ }
2227
+ const hoistAnchor = createHoistInsertionAnchor(root);
2228
+ const preflightRules = collectPreflightRules(root, options);
2229
+ if (preflightRules.length === 0) {
2230
+ const resetRule = createPreflightResetRule(options.cssPreflight);
2231
+ if (resetRule) preflightRules.push(resetRule);
2232
+ }
2233
+ if (tailwindcssV4DefaultNodes.length > 0) preflightRules.push(postcss.default.rule({
2234
+ selector: MINI_PROGRAM_ELEMENT_SCOPE_SELECTOR,
2235
+ nodes: tailwindcssV4DefaultNodes
2236
+ }));
2237
+ const themeRule = collectThemeVariableRule(root, options);
2238
+ insertHoistedRules(root, mergeEquivalentHoistedRules(themeRule ? [...preflightRules, themeRule] : preflightRules), hoistAnchor);
2239
+ if (options.removeEmptyAtRuleAncestors !== false) {
2240
+ removeEmptyRules(root);
2241
+ removeEmptyAtRules$1(root);
2242
+ } else root.walkAtRules((atRule) => {
2243
+ if (atRule.nodes?.length === 0) atRule.remove();
2244
+ });
2245
+ }
2246
+ function hoistTailwindPreflightBase(css) {
2247
+ try {
2248
+ const root = postcss.default.parse(css);
2249
+ insertHoistedRules(root, collectPreflightRules(root));
2250
+ return root.toString();
2251
+ } catch {
2252
+ return css;
2253
+ }
2254
+ }
2255
+ function finalizeMiniProgramCss(css, options = {}) {
2256
+ const repairedCss = repairTrailingUnclosedTailwindSourceMedia(css);
2257
+ let isTailwindcssV4 = options.isTailwindcssV4;
2258
+ if (isTailwindcssV4 === void 0) try {
2259
+ isTailwindcssV4 = hasTailwindcssV4Signal(repairedCss);
2260
+ } catch {
2261
+ isTailwindcssV4 = TAILWIND_V4_BANNER_RE.test(repairedCss);
2262
+ }
2263
+ const cleanedCss = removeUnsupportedMiniProgramAtRules(repairedCss);
2264
+ try {
2265
+ const root = postcss.default.parse(cleanedCss);
2266
+ finalizeMiniProgramCssRoot(root, {
2267
+ ...options,
2268
+ isTailwindcssV4
2269
+ });
2270
+ return root.toString();
2271
+ } catch {
2272
+ return removeSpecificityPlaceholdersFromSource(cleanedCss);
2273
+ }
2274
+ }
2275
+ //#endregion
2276
+ //#region src/compat/web-css.ts
2277
+ const disabledFeatures = {
2278
+ theme: false,
2279
+ layer: false,
2280
+ property: false,
2281
+ nesting: false,
2282
+ oklch: false,
2283
+ colorFunctions: false,
2284
+ supports: false
2285
+ };
2286
+ const legacyWebFeatures = {
2287
+ theme: true,
2288
+ layer: true,
2289
+ property: true,
2290
+ nesting: true,
2291
+ oklch: true,
2292
+ colorFunctions: true,
2293
+ supports: true
2294
+ };
2295
+ function normalizeWebCssCompatOptionsObject(options) {
2296
+ const preset = options.preset ?? "legacy-web";
2297
+ return {
2298
+ preset,
2299
+ features: {
2300
+ ...preset === "legacy-web" ? legacyWebFeatures : disabledFeatures,
2301
+ ...options.features
2302
+ }
2303
+ };
2304
+ }
2305
+ function normalizeWebCssCompatOptions(options) {
2306
+ if (options === true) return normalizeWebCssCompatOptionsObject({ preset: "legacy-web" });
2307
+ if (!options) return {
2308
+ preset: "off",
2309
+ features: disabledFeatures
2310
+ };
2311
+ return normalizeWebCssCompatOptionsObject(options);
2312
+ }
2313
+ function isWebCssCompatEnabled(options) {
2314
+ return Object.values(options.features).some(Boolean);
2315
+ }
2316
+ function collectCustomPropertyValues(root) {
2317
+ const values = /* @__PURE__ */ new Map();
2318
+ root.walkRules((rule) => {
2319
+ if (!rule.selectors.some((selector) => selector.trim() === ":root" || selector.trim() === ":host")) return;
2320
+ rule.each((node) => {
2321
+ if (node.type === "decl" && node.prop.startsWith("--") && !node.prop.startsWith("--tw-")) {
2322
+ const decl = node;
2323
+ values.set(decl.prop, decl.value.trim());
2324
+ }
2325
+ });
2326
+ });
2327
+ return values;
2328
+ }
2329
+ function collectRegisteredCustomPropertyFallbacks(root) {
2330
+ const registeredProperties = /* @__PURE__ */ new Map();
2331
+ root.walkAtRules("property", (atRule) => {
2332
+ const propertyName = atRule.params.trim().split(/\s+/, 1)[0];
2333
+ if (propertyName?.startsWith("--")) {
2334
+ const existing = registeredProperties.get(propertyName) ?? {};
2335
+ atRule.walkDecls("initial-value", (decl) => {
2336
+ existing.initialValue = decl.value.trim();
2337
+ });
2338
+ registeredProperties.set(propertyName, existing);
2339
+ }
2340
+ atRule.remove();
2341
+ });
2342
+ return registeredProperties;
2343
+ }
2344
+ const tailwindUnregisteredInitialFallbackCustomProperties = /* @__PURE__ */ new Set([
2345
+ "--tw-gradient-position",
2346
+ "--tw-gradient-stops",
2347
+ "--tw-gradient-via-stops",
2348
+ "--tw-leading",
2349
+ "--tw-font-weight",
2350
+ "--tw-tracking"
2351
+ ]);
2352
+ function insertRegisteredCustomPropertyFallbackRule(root, registeredProperties) {
2353
+ const declarations = [];
2354
+ for (const [prop, registration] of registeredProperties) {
2355
+ if (!registration.initialValue || registration.initialValue === "initial") continue;
2356
+ declarations.push(postcss.default.decl({
2357
+ prop,
2358
+ value: registration.initialValue
2359
+ }));
2360
+ }
2361
+ if (declarations.length === 0) return;
2362
+ root.prepend(postcss.default.rule({
2363
+ selector: "*, ::before, ::after, ::backdrop",
2364
+ nodes: declarations
2365
+ }));
2366
+ }
2367
+ function removeInitialFallbackDeclarations(root, registeredProperties) {
2368
+ root.walkDecls((decl) => {
2369
+ if ((registeredProperties.has(decl.prop) && !registeredProperties.get(decl.prop)?.initialValue || tailwindUnregisteredInitialFallbackCustomProperties.has(decl.prop)) && decl.value.trim() === "initial") decl.remove();
2370
+ });
2371
+ }
2372
+ function unwrapThemeAtRules(root) {
2373
+ root.walkAtRules("theme", (atRule) => {
2374
+ if (atRule.nodes && atRule.nodes.length > 0) {
2375
+ const rootNodes = [];
2376
+ const hoistedNodes = [];
2377
+ for (const node of atRule.nodes) if (node.type === "decl" || node.type === "comment") rootNodes.push(node.clone());
2378
+ else hoistedNodes.push(node.clone());
2379
+ const replacements = [...rootNodes.length > 0 ? [postcss.default.rule({
2380
+ selector: ":root",
2381
+ nodes: rootNodes
2382
+ })] : [], ...hoistedNodes];
2383
+ atRule.replaceWith(...replacements);
2384
+ } else atRule.remove();
2385
+ });
2386
+ }
2387
+ function resolveCustomPropertyVarValue(value, customPropertyValues) {
2388
+ if (!value.includes("var(")) return value;
2389
+ const parsed = (0, postcss_value_parser.default)(value);
2390
+ let changed = false;
2391
+ parsed.walk((node) => {
2392
+ if (node.type !== "function" || node.value.toLowerCase() !== "var") return;
2393
+ const propertyNode = node.nodes.find((child) => child.type === "word" && child.value.startsWith("--"));
2394
+ if (!propertyNode) return;
2395
+ const customPropertyValue = customPropertyValues.get(propertyNode.value);
2396
+ if (!customPropertyValue) return;
2397
+ const mutableNode = node;
2398
+ mutableNode.type = "word";
2399
+ mutableNode.value = customPropertyValue;
2400
+ delete mutableNode.nodes;
2401
+ changed = true;
2402
+ });
2403
+ return changed ? parsed.toString() : value;
2404
+ }
2405
+ function usesResolvableTailwindColorVariable(value, customPropertyValues) {
2406
+ if (!value.includes("var(")) return false;
2407
+ const parsed = (0, postcss_value_parser.default)(value);
2408
+ let usesColorVariable = false;
2409
+ parsed.walk((node) => {
2410
+ if (node.type !== "function" || node.value.toLowerCase() !== "var") return;
2411
+ const propertyNode = node.nodes.find((child) => child.type === "word" && child.value.startsWith("--color-"));
2412
+ if (propertyNode && customPropertyValues.has(propertyNode.value)) usesColorVariable = true;
2413
+ });
2414
+ return usesColorVariable;
2415
+ }
2416
+ function normalizeModernColorDeclarations(root, features) {
2417
+ if (!features.oklch && !features.colorFunctions) return;
2418
+ const customPropertyValues = collectCustomPropertyValues(root);
2419
+ root.walkDecls((decl) => {
2420
+ const value = resolveCustomPropertyVarValue(decl.value, customPropertyValues);
2421
+ const normalized = normalizeModernColorValue(value, customPropertyValues);
2422
+ if (!normalized.changed) {
2423
+ if (value !== decl.value && usesResolvableTailwindColorVariable(decl.value, customPropertyValues)) decl.value = value;
2424
+ return;
2425
+ }
2426
+ if (!features.colorFunctions && !/oklch|oklab/i.test(value)) return;
2427
+ decl.value = normalized.value;
2428
+ });
2429
+ }
2430
+ function removeModernColorSupports(root) {
2431
+ root.walkAtRules("supports", (atRule) => {
2432
+ if (!/color-mix|oklch|oklab|lab|lch|display-p3/i.test(atRule.params)) return;
2433
+ if (atRule.nodes && atRule.nodes.length > 0) atRule.replaceWith(...atRule.nodes);
2434
+ else atRule.remove();
2435
+ });
2436
+ }
2437
+ function normalizeTailwindcssV4GradientPositionDeclarations(root) {
2438
+ root.walkDecls("--tw-gradient-position", (decl) => {
2439
+ const normalized = normalizeTailwindcssV4GradientPosition(decl.value);
2440
+ if (normalized) {
2441
+ decl.value = normalized;
2442
+ return;
2443
+ }
2444
+ if (normalized === decl.value.trim()) return;
2445
+ const parent = decl.parent;
2446
+ if (parent?.type !== "rule") {
2447
+ decl.value = "to bottom";
2448
+ return;
2449
+ }
2450
+ const backgroundImageDecl = parent.nodes.find((node) => {
2451
+ return node.type === "decl" && node.prop === "background-image";
2452
+ });
2453
+ if (/^radial-gradient\(/i.test(backgroundImageDecl?.value ?? "")) {
2454
+ decl.value = "at center";
2455
+ return;
2456
+ }
2457
+ if (/^conic-gradient\(/i.test(backgroundImageDecl?.value ?? "")) {
2458
+ decl.value = "from 0deg";
2459
+ return;
2460
+ }
2461
+ decl.value = "to bottom";
2462
+ });
2463
+ }
2464
+ function normalizeTailwindcssV4InfinityCalcDeclarations(root) {
2465
+ root.walkDecls((decl) => {
2466
+ const normalized = normalizeTailwindcssV4InfinityCalcValue(decl.value);
2467
+ if (normalized !== decl.value) decl.value = normalized;
2468
+ });
2469
+ }
2470
+ function removeEmptyAtRules(root) {
2471
+ root.walkAtRules((atRule) => {
2472
+ if (atRule.nodes && atRule.nodes.length === 0) atRule.remove();
2473
+ });
2474
+ }
2475
+ function insertWebkitBackgroundClipText(root) {
2476
+ root.walkDecls("background-clip", (decl) => {
2477
+ if (decl.value.trim().toLowerCase() !== "text") return;
2478
+ const parent = decl.parent;
2479
+ if (!parent || !("nodes" in parent)) return;
2480
+ if (!parent.nodes.some((node) => {
2481
+ return node.type === "decl" && node.prop.toLowerCase() === "-webkit-background-clip" && node.value.trim().toLowerCase() === "text";
2482
+ })) decl.cloneBefore({ prop: "-webkit-background-clip" });
2483
+ });
2484
+ }
2485
+ function transformCssNesting(root) {
2486
+ (0, postcss.default)([(0, postcss_preset_env.default)({
2487
+ stage: false,
2488
+ autoprefixer: false,
2489
+ features: { "nesting-rules": true }
2490
+ })]).process(root, { from: void 0 }).sync();
2491
+ }
2492
+ function transformWebCssCompat(css, options) {
2493
+ const normalized = normalizeWebCssCompatOptions(options);
2494
+ if (!isWebCssCompatEnabled(normalized) && normalized.preset !== "legacy-web") return css;
2495
+ try {
2496
+ const root = postcss.default.parse(css);
2497
+ if (normalized.features.theme) unwrapThemeAtRules(root);
2498
+ if (normalized.features.property) {
2499
+ const registeredProperties = collectRegisteredCustomPropertyFallbacks(root);
2500
+ insertRegisteredCustomPropertyFallbackRule(root, registeredProperties);
2501
+ removeInitialFallbackDeclarations(root, registeredProperties);
2502
+ }
2503
+ if (normalized.features.supports) removeModernColorSupports(root);
2504
+ if (normalized.features.nesting) transformCssNesting(root);
2505
+ normalizeTailwindcssV4GradientPositionDeclarations(root);
2506
+ normalizeTailwindcssV4InfinityCalcDeclarations(root);
2507
+ normalizeModernColorDeclarations(root, normalized.features);
2508
+ if (normalized.preset === "legacy-web") insertWebkitBackgroundClipText(root);
2509
+ if (normalized.features.layer) removeUnsupportedCascadeLayers(root);
2510
+ removeEmptyAtRules(root);
2511
+ return root.toString();
2512
+ } catch {
2513
+ return css;
2514
+ }
2515
+ }
2516
+ function transformWebCssSafeSelectors(css, options) {
2517
+ try {
2518
+ const root = postcss.default.parse(css);
2519
+ root.walkRules((rule) => {
2520
+ if (!rule.selector.includes(".")) return;
2521
+ rule.selector = (0, postcss_selector_parser.default)((selectors) => {
2522
+ selectors.walkClasses((node) => {
2523
+ node.value = require_shared.internalCssSelectorReplacer(node.value, options);
2524
+ });
2525
+ }).processSync(rule.selector);
2526
+ });
2527
+ return root.toString();
2528
+ } catch {
2529
+ return css;
2530
+ }
2531
+ }
2532
+ //#endregion
2533
+ //#region src/source-scan/params.ts
2534
+ function parseConfigParam(params) {
2535
+ const value = params.trim();
2536
+ return /^(['"])(.+)\1$/.exec(value)?.[2];
2537
+ }
2538
+ function parseSourceFileParam(params) {
2539
+ const value = params.trim();
2540
+ if (!value || value === "none" || value.startsWith("inline(")) return;
2541
+ const negated = value.startsWith("not ");
2542
+ const sourceValue = negated ? value.slice(4).trim() : value;
2543
+ if (sourceValue.startsWith("inline(")) return;
2544
+ const match = /^(['"])(.+)\1$/.exec(sourceValue);
2545
+ return match?.[2] ? {
2546
+ negated,
2547
+ sourcePath: match[2]
2548
+ } : void 0;
2549
+ }
2550
+ //#endregion
2551
+ //#region src/source-scan/inline-source.ts
2552
+ const NUMERICAL_RANGE_RE = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
2553
+ function segmentTopLevel(input, separator, options = {}) {
2554
+ const parts = [];
2555
+ const stack = [];
2556
+ let lastPos = 0;
2557
+ let quote;
2558
+ for (let index = 0; index < input.length; index++) {
2559
+ const char = input[index];
2560
+ if (char === "\\") {
2561
+ index += 1;
2562
+ continue;
2563
+ }
2564
+ if (quote) {
2565
+ if (char === quote) quote = void 0;
2566
+ continue;
2567
+ }
2568
+ if (char === "\"" || char === "'") {
2569
+ quote = char;
2570
+ continue;
2571
+ }
2572
+ if (char === "(") {
2573
+ stack.push(")");
2574
+ continue;
2575
+ }
2576
+ if (char === "[") {
2577
+ stack.push("]");
2578
+ continue;
2579
+ }
2580
+ if (char === "{") {
2581
+ stack.push("}");
2582
+ continue;
2583
+ }
2584
+ if (stack.length > 0 && char === stack[stack.length - 1]) {
2585
+ stack.pop();
2586
+ continue;
2587
+ }
2588
+ if (stack.length === 0 && char === separator) {
2589
+ const part = input.slice(lastPos, index);
2590
+ if (part || options.keepEmpty) parts.push(part);
2591
+ lastPos = index + 1;
2592
+ }
2593
+ }
2594
+ const part = input.slice(lastPos);
2595
+ if (part || options.keepEmpty) parts.push(part);
2596
+ return parts;
2597
+ }
2598
+ function isSequence(value) {
2599
+ return NUMERICAL_RANGE_RE.test(value);
2600
+ }
2601
+ function expandSequence(value) {
2602
+ const match = value.match(NUMERICAL_RANGE_RE);
2603
+ if (!match) return [value];
2604
+ const [, start, end, stepValue] = match;
2605
+ if (start === void 0 || end === void 0) return [value];
2606
+ let step = stepValue ? Number.parseInt(stepValue, 10) : void 0;
2607
+ const startNumber = Number.parseInt(start, 10);
2608
+ const endNumber = Number.parseInt(end, 10);
2609
+ const increasing = startNumber < endNumber;
2610
+ if (step === void 0) step = increasing ? 1 : -1;
2611
+ if (step === 0) return [];
2612
+ if (increasing && step < 0) step = -step;
2613
+ if (!increasing && step > 0) step = -step;
2614
+ const result = [];
2615
+ for (let value = startNumber; increasing ? value <= endNumber : value >= endNumber; value += step) result.push(String(value));
2616
+ return result;
2617
+ }
2618
+ function expandInlineSourceCandidatePattern(pattern) {
2619
+ const index = pattern.indexOf("{");
2620
+ if (index === -1) return [pattern];
2621
+ const prefix = pattern.slice(0, index);
2622
+ const rest = pattern.slice(index);
2623
+ let depth = 0;
2624
+ let endIndex = -1;
2625
+ for (let index = 0; index < rest.length; index++) {
2626
+ const char = rest[index];
2627
+ if (char === "{") depth += 1;
2628
+ else if (char === "}") {
2629
+ depth -= 1;
2630
+ if (depth === 0) {
2631
+ endIndex = index;
2632
+ break;
2633
+ }
2634
+ }
2635
+ }
2636
+ if (endIndex === -1) return [pattern];
2637
+ const inner = rest.slice(1, endIndex);
2638
+ const suffix = rest.slice(endIndex + 1);
2639
+ const parts = (isSequence(inner) ? expandSequence(inner) : segmentTopLevel(inner, ",", { keepEmpty: true })).flatMap((part) => expandInlineSourceCandidatePattern(part));
2640
+ return expandInlineSourceCandidatePattern(suffix).flatMap((suffix) => parts.map((part) => `${prefix}${part}${suffix}`));
2641
+ }
2642
+ function parseSourceInlineParam(params) {
2643
+ let value = params.trim();
2644
+ const negated = value.startsWith("not ");
2645
+ if (negated) value = value.slice(4).trim();
2646
+ if (!value.startsWith("inline(") || !value.endsWith(")")) return;
2647
+ const inlineValue = value.slice(7, -1).trim();
2648
+ const match = /^(['"])([\s\S]*)\1$/.exec(inlineValue);
2649
+ if (!match) return;
2650
+ const source = match[2];
2651
+ if (source === void 0) return;
2652
+ return {
2653
+ negated,
2654
+ source
2655
+ };
2656
+ }
2657
+ function collectCssInlineSourceCandidates(root) {
2658
+ const included = /* @__PURE__ */ new Set();
2659
+ const excluded = /* @__PURE__ */ new Set();
2660
+ root.walkAtRules("source", (rule) => {
2661
+ const parsed = parseSourceInlineParam(rule.params);
2662
+ if (!parsed) return;
2663
+ const target = parsed.negated ? excluded : included;
2664
+ for (const source of segmentTopLevel(parsed.source, " ")) {
2665
+ const trimmed = source.trim();
2666
+ if (!trimmed) continue;
2667
+ for (const candidate of expandInlineSourceCandidatePattern(trimmed)) {
2668
+ const normalized = candidate.trim();
2669
+ if (normalized) target.add(normalized);
2670
+ }
2671
+ }
2672
+ });
2673
+ for (const candidate of excluded) included.delete(candidate);
2674
+ return {
2675
+ included,
2676
+ excluded
2677
+ };
2678
+ }
2679
+ //#endregion
2680
+ //#region src/source-scan.ts
2681
+ async function resolveCssSourceEntries(root, base, defaultPattern = (0, _weapp_tailwindcss_source_scan.createSourceScanPattern)()) {
2682
+ const entries = [];
2683
+ const tasks = [];
2684
+ root.walkAtRules("source", (rule) => {
2685
+ const parsed = parseSourceFileParam(rule.params);
2686
+ if (!parsed) return;
2687
+ tasks.push((0, _weapp_tailwindcss_source_scan.resolveTailwindSourceEntry)(parsed.sourcePath, base, parsed.negated, defaultPattern));
2688
+ });
2689
+ entries.push(...await Promise.all(tasks));
2690
+ return entries;
2691
+ }
2692
+ async function expandTailwindSourceEntries(entries, options = {}) {
2693
+ return (0, _weapp_tailwindcss_source_scan.expandSourceEntries)(entries, ({ cwd, sources }) => (0, _weapp_tailwindcss_engine.resolveProjectSourceFiles)({
2694
+ cwd,
2695
+ sources,
2696
+ ...options.ignore ? { ignoredSources: options.ignore.map((pattern) => ({
2697
+ base: cwd,
2698
+ pattern: (0, _weapp_tailwindcss_source_scan.normalizeGlobPattern)(pattern),
2699
+ negated: true
2700
+ })) } : {}
2701
+ }));
2702
+ }
2703
+ //#endregion
2704
+ //#region src/utils/apply-source.ts
2705
+ function normalizeGeneratedSelector(selector) {
2706
+ return selector.replace(/:not\(#\\#\)/g, "").trim();
2707
+ }
2708
+ /** 复用调用方 AST,同时取得 apply 选择器和纯 apply 输入判定。 */
2709
+ function analyzeApplyOnlySourceRoot(root) {
2710
+ const selectors = /* @__PURE__ */ new Set();
2711
+ let hasApplyRule = false;
2712
+ let hasNonApplyRule = false;
2713
+ root.walkRules((rule) => {
2714
+ if (!rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) {
2715
+ hasNonApplyRule = true;
2716
+ return;
2717
+ }
2718
+ hasApplyRule = true;
2719
+ for (const selector of rule.selectors ?? [rule.selector]) {
2720
+ const normalized = normalizeGeneratedSelector(selector);
2721
+ if (normalized) selectors.add(normalized);
2722
+ }
2723
+ });
2724
+ return {
2725
+ selectors,
2726
+ onlyApply: hasApplyRule && !hasNonApplyRule
2727
+ };
2728
+ }
2729
+ function analyzeApplyOnlySource(source) {
2730
+ try {
2731
+ return analyzeApplyOnlySourceRoot(postcss.default.parse(source));
2732
+ } catch {
2733
+ return {
2734
+ selectors: /* @__PURE__ */ new Set(),
2735
+ onlyApply: false
2736
+ };
2737
+ }
2738
+ }
2739
+ //#endregion
2740
+ //#region src/generator-plugin/apply-only.ts
2741
+ function collectApplyOnlyCssSelectorsRoot(root) {
2742
+ return analyzeApplyOnlySourceRoot(root).selectors;
2743
+ }
2744
+ function collectApplyOnlyCssSelectors(css) {
2745
+ try {
2746
+ return collectApplyOnlyCssSelectorsRoot(postcss.default.parse(css));
2747
+ } catch {
2748
+ return /* @__PURE__ */ new Set();
2749
+ }
2750
+ }
2751
+ function ruleMatchesApplyOnlySelector(rule, selectors) {
2752
+ return (rule.selectors ?? [rule.selector]).some((selector) => selectors.has(normalizeGeneratedSelector(selector)));
2753
+ }
2754
+ function filterApplyOnlyGeneratedCssRoot(root, selectors) {
2755
+ if (selectors.size === 0) return false;
2756
+ let changed = false;
2757
+ root.walkRules((rule) => {
2758
+ if (ruleMatchesApplyOnlySelector(rule, selectors) || rule.nodes?.some((node) => node.type === "decl" && node.prop.startsWith("--"))) return;
2759
+ rule.remove();
2760
+ changed = true;
2761
+ });
2762
+ root.walkAtRules((rule) => {
2763
+ if (rule.nodes !== void 0 && rule.nodes.length === 0) {
2764
+ rule.remove();
2765
+ changed = true;
2766
+ }
2767
+ });
2768
+ return changed;
2769
+ }
2770
+ function filterApplyOnlyGeneratedCss(css, selectors) {
2771
+ if (selectors.size === 0) return css;
2772
+ try {
2773
+ const root = postcss.default.parse(css);
2774
+ return filterApplyOnlyGeneratedCssRoot(root, selectors) ? root.toString() : css;
2775
+ } catch {
2776
+ return css;
2777
+ }
2778
+ }
2779
+ //#endregion
2780
+ //#region src/generator-plugin/config-directive.ts
2781
+ function normalizeConfigDirective(css, config) {
2782
+ if (!config || !/@config\s+/.test(css)) return css;
2783
+ return css.replace(/@config\s+(["'])(.+?)\1\s*;?/, `@config "${quoteCssString(toCssPath(config))}";`);
2784
+ }
2785
+ /** 保留预处理器文本兼容;请求解析与文件定位由调用方提供。 */
2786
+ function rewriteCssConfigRequests(source, resolve) {
2787
+ return source.replace(/@config\s+(["'])(.+?)\1\s*;?/g, (full, quote, request) => {
2788
+ const resolved = resolve(request);
2789
+ return resolved === void 0 ? full : `@config ${quote}${resolved}${quote};`;
2790
+ });
2791
+ }
2792
+ /** 保留 Vite 预处理前的行级清理语义,允许尚未编译的 Sass 等源码。 */
2793
+ function stripTailwindConfigDirectives(code) {
2794
+ return code.replace(/^\s*@config\s+(?:"[^"]+"|'[^']+')[^;\n]*;\s*$/gm, "");
2795
+ }
2796
+ function quoteCssString(value) {
2797
+ return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
2798
+ }
2799
+ function toCssPath(value) {
2800
+ return value.replaceAll("\\", "/");
2801
+ }
2802
+ function prependConfigDirective(css, config) {
2803
+ if (!config || /@config\s+/.test(css)) return css;
2804
+ return `@config "${quoteCssString(toCssPath(config))}";\n${css}`;
2805
+ }
2806
+ //#endregion
2807
+ //#region src/generator-plugin/directives.ts
2808
+ const TAILWIND_ROOT_DIRECTIVE_NAMES = /* @__PURE__ */ new Set([
2809
+ "config",
2810
+ "custom-variant",
2811
+ "plugin",
2812
+ "source",
2813
+ "tailwind",
2814
+ "theme",
2815
+ "utility",
2816
+ "variant"
2817
+ ]);
2818
+ function createEmptyDirectiveAnalysis() {
2819
+ return {
2820
+ hasLocalCssImport: false,
2821
+ hasTailwindApplyDirective: false,
2822
+ hasTailwindNonRootGenerationDirectives: false,
2823
+ hasTailwindRootDirectives: false,
2824
+ hasTailwindRootImportDirectives: false,
2825
+ hasTailwindSourceDirectives: false
2826
+ };
2827
+ }
2828
+ function parseTailwindCssDirectiveRequest(params) {
2829
+ return parseCssImportSpecifier(params)?.specifier;
2830
+ }
2831
+ function parseTailwindCssConfigRequest(params) {
2832
+ return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
2833
+ }
2834
+ function isTailwindCssPackageJsonImportRequest(request) {
2835
+ return typeof request === "string" && request.startsWith("#");
2836
+ }
2837
+ function isWeappTailwindcssImportRequest(request) {
2838
+ return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/") === true;
2839
+ }
2840
+ function normalizeTailwindCssImportRequest(request, options = {}) {
2841
+ return options.importFallback && (request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/")) ? request.replace(/^weapp-tailwindcss/, "tailwindcss") : request;
2842
+ }
2843
+ function isTailwindCssImportRequest(request, options = {}) {
2844
+ const normalized = normalizeTailwindCssImportRequest(request, options);
2845
+ return normalized === "tailwindcss" || normalized === "tailwindcss4" || normalized?.startsWith("tailwindcss/") === true || normalized?.startsWith("tailwindcss4/") === true;
2846
+ }
2847
+ function isTailwindCssImportAtRule(node, options = {}) {
2848
+ if (node.name === "tailwind") return true;
2849
+ if (node.name !== "import" && node.name !== "use" && node.name !== "forward") return false;
2850
+ return isTailwindCssImportRequest(parseTailwindCssDirectiveRequest(node.params), options);
2851
+ }
2852
+ function getTailwindCssDirectiveRequest(node) {
2853
+ return node.name === "import" ? parseTailwindCssDirectiveRequest(node.params) : node.name === "config" || node.name === "plugin" || node.name === "reference" ? parseTailwindCssConfigRequest(node.params) : void 0;
2854
+ }
2855
+ function isTailwindCssGenerationDirective(node, options = {}) {
2856
+ if (node.type !== "atrule") return false;
2857
+ const atRule = node;
2858
+ const request = getTailwindCssDirectiveRequest(atRule);
2859
+ return isTailwindCssImportAtRule(atRule, options) || isTailwindCssPackageJsonImportRequest(request) || atRule.name === "apply" || !options.ignoreLayer && atRule.name === "layer" || atRule.name === "config" || atRule.name === "source";
2860
+ }
2861
+ function hasTailwindApplyDirective(css) {
2862
+ return /@apply\b/.test(css);
2863
+ }
2864
+ function analyzeTailwindCssDirectives(root, options = {}) {
2865
+ const analysis = createEmptyDirectiveAnalysis();
2866
+ root.walk((node) => {
2867
+ if (node.type !== "atrule") return;
2868
+ const atRule = node;
2869
+ if (atRule.name === "import") {
2870
+ const request = parseTailwindCssDirectiveRequest(atRule.params);
2871
+ if (request?.startsWith(".") === true || request?.startsWith("/") === true) analysis.hasLocalCssImport = true;
2872
+ }
2873
+ const isTailwindImport = isTailwindCssImportAtRule(atRule, options);
2874
+ if (isTailwindImport) {
2875
+ analysis.hasTailwindRootImportDirectives = true;
2876
+ analysis.hasTailwindRootDirectives = true;
2877
+ }
2878
+ const request = atRule.name === "import" || atRule.name === "config" || atRule.name === "plugin" ? getTailwindCssDirectiveRequest(atRule) : void 0;
2879
+ if (isTailwindImport || isTailwindCssPackageJsonImportRequest(request) || TAILWIND_ROOT_DIRECTIVE_NAMES.has(atRule.name)) analysis.hasTailwindRootDirectives = true;
2880
+ if (atRule.name === "apply") analysis.hasTailwindApplyDirective = true;
2881
+ if (isTailwindCssGenerationDirective(atRule, options)) {
2882
+ analysis.hasTailwindSourceDirectives = true;
2883
+ if (!isTailwindImport) analysis.hasTailwindNonRootGenerationDirectives = true;
2884
+ }
2885
+ });
2886
+ return analysis;
2887
+ }
2888
+ function hasTailwindRootDirectives(root, options = {}) {
2889
+ let found = false;
2890
+ root.walkAtRules((rule) => {
2891
+ if (rule.name === "import" && isTailwindCssImportRequest(parseTailwindCssDirectiveRequest(rule.params), options)) {
2892
+ found = true;
2893
+ return false;
2894
+ }
2895
+ if (TAILWIND_ROOT_DIRECTIVE_NAMES.has(rule.name)) {
2896
+ found = true;
2897
+ return false;
2898
+ }
2899
+ });
2900
+ return found;
2901
+ }
2902
+ //#endregion
2903
+ //#region src/source-scan/description.ts
2904
+ /** 只提取来源指令;默认扫描策略与配置加载由调用层决定。 */
2905
+ function describeCssSources(root, isSourceImport = isTailwindCssImport) {
2906
+ const imports = [];
2907
+ const sources = [];
2908
+ const configs = [];
2909
+ root.walkAtRules((rule) => {
2910
+ if (rule.name === "import" && isSourceImport(rule.params)) imports.push(parseImportSourceParam(rule.params) ?? {});
2911
+ else if (rule.name === "source") {
2912
+ const source = parseSourceFileParam(rule.params);
2913
+ if (source) sources.push(source);
2914
+ } else if (rule.name === "config") {
2915
+ const config = parseConfigParam(rule.params);
2916
+ if (config) configs.push(config);
2917
+ }
2918
+ });
2919
+ return {
2920
+ imports,
2921
+ sources,
2922
+ configs,
2923
+ inlineCandidates: collectCssInlineSourceCandidates(root)
2924
+ };
2925
+ }
2926
+ //#endregion
2927
+ //#region src/source-scan/resolve.ts
2928
+ /** 将 AST 描述与配置 content 合并,再交给共享扫描策略生成执行计划。 */
2929
+ async function resolveCssScanSources(definitions, policy) {
2930
+ const entries = [];
2931
+ const configEntries = [];
2932
+ const configGroups = [];
2933
+ const configPaths = /* @__PURE__ */ new Set();
2934
+ const included = /* @__PURE__ */ new Set();
2935
+ const excluded = /* @__PURE__ */ new Set();
2936
+ let automaticBase;
2937
+ let sourceNone = false;
2938
+ let hasImport = false;
2939
+ for (const { root, base } of definitions) {
2940
+ const descriptor = describeCssSources(root);
2941
+ hasImport ||= descriptor.imports.length > 0;
2942
+ sourceNone ||= descriptor.imports.some((item) => item.none);
2943
+ for (const item of descriptor.imports) if (item.sourcePath) automaticBase = (0, _weapp_tailwindcss_source_scan.sourcePathApi)(base, item.sourcePath).resolve(base, item.sourcePath);
2944
+ for (const source of descriptor.sources) entries.push(await (0, _weapp_tailwindcss_source_scan.resolveTailwindSourceEntry)(source.sourcePath, base, source.negated, policy.pattern));
2945
+ for (const value of descriptor.inlineCandidates.included) included.add(value);
2946
+ for (const value of descriptor.inlineCandidates.excluded) excluded.add(value);
2947
+ for (const request of descriptor.configs) configPaths.add(policy.configResolution === "module" ? (0, node_module.createRequire)(node_path.default.join(base, "package.json")).resolve(request) : (0, _weapp_tailwindcss_source_scan.sourcePathApi)(base, request).resolve(base, request));
2948
+ }
2949
+ if (policy.config) configPaths.add((0, _weapp_tailwindcss_source_scan.sourcePathApi)(policy.base, policy.config).resolve(policy.base, policy.config));
2950
+ for (const config of policy.loadConfigContent === false ? [] : configPaths) {
2951
+ const base = node_path.default.dirname(config);
2952
+ const loaded = await (0, tailwindcss_config.loadConfig)({
2953
+ config,
2954
+ cwd: base
2955
+ });
2956
+ const group = (0, _weapp_tailwindcss_source_scan.normalizeLegacyContentEntries)(loaded?.config.content, base, { relativeBase: base });
2957
+ configGroups.push(group);
2958
+ configEntries.push(...group);
2959
+ }
2960
+ const explicitEntries = policy.sourceEntries ?? entries;
2961
+ const combinedEntries = [...explicitEntries, ...configEntries];
2962
+ let mode = policy.automatic;
2963
+ if (mode !== "disabled") {
2964
+ if (automaticBase) mode = "auto";
2965
+ else if (sourceNone || policy.requireImport && !hasImport && combinedEntries.length === 0) mode = "disabled";
2966
+ }
2967
+ const base = automaticBase ?? (combinedEntries.length > 0 ? policy.base : policy.defaultBase ?? policy.base);
2968
+ return {
2969
+ entries: (0, _weapp_tailwindcss_source_scan.createSourceScanPlan)({
2970
+ base,
2971
+ mode,
2972
+ entries: combinedEntries,
2973
+ pattern: policy.pattern,
2974
+ ...policy.ignoredPatterns ? { ignoredPatterns: policy.ignoredPatterns } : {}
2975
+ }),
2976
+ explicitEntries,
2977
+ configEntries,
2978
+ configGroups,
2979
+ configPaths: [...configPaths],
2980
+ inlineCandidates: {
2981
+ included,
2982
+ excluded
2983
+ }
2984
+ };
2985
+ }
2986
+ //#endregion
2987
+ Object.defineProperty(exports, "CLAMP_PX", {
2988
+ enumerable: true,
2989
+ get: function() {
2990
+ return CLAMP_PX;
2991
+ }
2992
+ });
2993
+ Object.defineProperty(exports, "COLOR_GAMUT_P3_RE", {
2994
+ enumerable: true,
2995
+ get: function() {
2996
+ return COLOR_GAMUT_P3_RE$1;
2997
+ }
2998
+ });
2999
+ Object.defineProperty(exports, "DISPLAY_P3_COLOR_RE", {
3000
+ enumerable: true,
3001
+ get: function() {
3002
+ return DISPLAY_P3_COLOR_RE;
3003
+ }
3004
+ });
3005
+ Object.defineProperty(exports, "DISPLAY_P3_VALUE_RE", {
3006
+ enumerable: true,
3007
+ get: function() {
3008
+ return DISPLAY_P3_VALUE_RE$1;
3009
+ }
3010
+ });
3011
+ Object.defineProperty(exports, "INFINITY_CALC_VALUE_REGEXP", {
3012
+ enumerable: true,
3013
+ get: function() {
3014
+ return INFINITY_CALC_VALUE_REGEXP;
3015
+ }
3016
+ });
3017
+ Object.defineProperty(exports, "LINEAR_GRADIENT_LAB_RE", {
3018
+ enumerable: true,
3019
+ get: function() {
3020
+ return LINEAR_GRADIENT_LAB_RE;
3021
+ }
3022
+ });
3023
+ Object.defineProperty(exports, "MINI_PROGRAM_ELEMENT_SCOPE_SELECTOR", {
3024
+ enumerable: true,
3025
+ get: function() {
3026
+ return MINI_PROGRAM_ELEMENT_SCOPE_SELECTOR;
3027
+ }
3028
+ });
3029
+ Object.defineProperty(exports, "MINI_PROGRAM_ELEMENT_SCOPE_SELECTORS", {
3030
+ enumerable: true,
3031
+ get: function() {
3032
+ return MINI_PROGRAM_ELEMENT_SCOPE_SELECTORS;
3033
+ }
3034
+ });
3035
+ Object.defineProperty(exports, "MODERN_CHECK_COLOR_RGB_RE", {
3036
+ enumerable: true,
3037
+ get: function() {
3038
+ return MODERN_CHECK_COLOR_RGB_RE;
3039
+ }
3040
+ });
3041
+ Object.defineProperty(exports, "MODERN_CHECK_MARGIN_TRIM_RE", {
3042
+ enumerable: true,
3043
+ get: function() {
3044
+ return MODERN_CHECK_MARGIN_TRIM_RE;
3045
+ }
3046
+ });
3047
+ Object.defineProperty(exports, "MODERN_CHECK_MOZ_ORIENT_RE", {
3048
+ enumerable: true,
3049
+ get: function() {
3050
+ return MODERN_CHECK_MOZ_ORIENT_RE;
3051
+ }
3052
+ });
3053
+ Object.defineProperty(exports, "MODERN_CHECK_WEBKIT_HYPHENS_RE", {
3054
+ enumerable: true,
3055
+ get: function() {
3056
+ return MODERN_CHECK_WEBKIT_HYPHENS_RE;
3057
+ }
3058
+ });
3059
+ Object.defineProperty(exports, "analyzeApplyOnlySource", {
3060
+ enumerable: true,
3061
+ get: function() {
3062
+ return analyzeApplyOnlySource;
3063
+ }
3064
+ });
3065
+ Object.defineProperty(exports, "analyzeTailwindCssDirectives", {
3066
+ enumerable: true,
3067
+ get: function() {
3068
+ return analyzeTailwindCssDirectives;
3069
+ }
3070
+ });
3071
+ Object.defineProperty(exports, "appendTailwindcssV4MiniProgramGradientRules", {
3072
+ enumerable: true,
3073
+ get: function() {
3074
+ return appendTailwindcssV4MiniProgramGradientRules;
3075
+ }
3076
+ });
3077
+ Object.defineProperty(exports, "collectApplyOnlyCssSelectors", {
3078
+ enumerable: true,
3079
+ get: function() {
3080
+ return collectApplyOnlyCssSelectors;
3081
+ }
3082
+ });
3083
+ Object.defineProperty(exports, "collectApplyOnlyCssSelectorsRoot", {
3084
+ enumerable: true,
3085
+ get: function() {
3086
+ return collectApplyOnlyCssSelectorsRoot;
3087
+ }
3088
+ });
3089
+ Object.defineProperty(exports, "collectCssInlineSourceCandidates", {
3090
+ enumerable: true,
3091
+ get: function() {
3092
+ return collectCssInlineSourceCandidates;
3093
+ }
3094
+ });
3095
+ Object.defineProperty(exports, "collectUsedTailwindcssV4Variables", {
3096
+ enumerable: true,
3097
+ get: function() {
3098
+ return collectUsedTailwindcssV4Variables;
3099
+ }
3100
+ });
3101
+ Object.defineProperty(exports, "consumeCascadeLayers", {
3102
+ enumerable: true,
3103
+ get: function() {
3104
+ return consumeCascadeLayers;
3105
+ }
3106
+ });
3107
+ Object.defineProperty(exports, "createMissingCssVarsV4Nodes", {
3108
+ enumerable: true,
3109
+ get: function() {
3110
+ return createMissingCssVarsV4Nodes;
3111
+ }
3112
+ });
3113
+ Object.defineProperty(exports, "createUsedCssVarsV4Nodes", {
3114
+ enumerable: true,
3115
+ get: function() {
3116
+ return createUsedCssVarsV4Nodes;
3117
+ }
3118
+ });
3119
+ Object.defineProperty(exports, "describeCssSources", {
3120
+ enumerable: true,
3121
+ get: function() {
3122
+ return describeCssSources;
3123
+ }
3124
+ });
3125
+ Object.defineProperty(exports, "expandInlineSourceCandidatePattern", {
3126
+ enumerable: true,
3127
+ get: function() {
3128
+ return expandInlineSourceCandidatePattern;
3129
+ }
3130
+ });
3131
+ Object.defineProperty(exports, "expandTailwindSourceEntries", {
3132
+ enumerable: true,
3133
+ get: function() {
3134
+ return expandTailwindSourceEntries;
3135
+ }
3136
+ });
3137
+ Object.defineProperty(exports, "filterApplyOnlyGeneratedCss", {
3138
+ enumerable: true,
3139
+ get: function() {
3140
+ return filterApplyOnlyGeneratedCss;
3141
+ }
3142
+ });
3143
+ Object.defineProperty(exports, "filterApplyOnlyGeneratedCssRoot", {
3144
+ enumerable: true,
3145
+ get: function() {
3146
+ return filterApplyOnlyGeneratedCssRoot;
3147
+ }
3148
+ });
3149
+ Object.defineProperty(exports, "finalizeMiniProgramCss", {
3150
+ enumerable: true,
3151
+ get: function() {
3152
+ return finalizeMiniProgramCss;
3153
+ }
3154
+ });
3155
+ Object.defineProperty(exports, "finalizeMiniProgramCssRoot", {
3156
+ enumerable: true,
3157
+ get: function() {
3158
+ return finalizeMiniProgramCssRoot;
3159
+ }
3160
+ });
3161
+ Object.defineProperty(exports, "getRuleSelectors", {
3162
+ enumerable: true,
3163
+ get: function() {
3164
+ return getRuleSelectors;
3165
+ }
3166
+ });
3167
+ Object.defineProperty(exports, "hasMiniProgramCssSpecificityPlaceholders", {
3168
+ enumerable: true,
3169
+ get: function() {
3170
+ return hasMiniProgramCssSpecificityPlaceholders;
3171
+ }
3172
+ });
3173
+ Object.defineProperty(exports, "hasTailwindApplyDirective", {
3174
+ enumerable: true,
3175
+ get: function() {
3176
+ return hasTailwindApplyDirective;
3177
+ }
3178
+ });
3179
+ Object.defineProperty(exports, "hasTailwindRootDirectives", {
3180
+ enumerable: true,
3181
+ get: function() {
3182
+ return hasTailwindRootDirectives;
3183
+ }
3184
+ });
3185
+ Object.defineProperty(exports, "hoistTailwindPreflightBase", {
3186
+ enumerable: true,
3187
+ get: function() {
3188
+ return hoistTailwindPreflightBase;
3189
+ }
3190
+ });
3191
+ Object.defineProperty(exports, "isBrowserElementPreflightRule", {
3192
+ enumerable: true,
3193
+ get: function() {
3194
+ return isBrowserElementPreflightRule;
3195
+ }
3196
+ });
3197
+ Object.defineProperty(exports, "isCustomPropertyRule", {
3198
+ enumerable: true,
3199
+ get: function() {
3200
+ return isCustomPropertyRule;
3201
+ }
3202
+ });
3203
+ Object.defineProperty(exports, "isEmptyTwContentDeclaration", {
3204
+ enumerable: true,
3205
+ get: function() {
3206
+ return isEmptyTwContentDeclaration;
3207
+ }
3208
+ });
3209
+ Object.defineProperty(exports, "isMiniProgramNativeElementSelector", {
3210
+ enumerable: true,
3211
+ get: function() {
3212
+ return isMiniProgramNativeElementSelector;
3213
+ }
3214
+ });
3215
+ Object.defineProperty(exports, "isMiniProgramPreflightRule", {
3216
+ enumerable: true,
3217
+ get: function() {
3218
+ return isMiniProgramPreflightRule;
3219
+ }
3220
+ });
3221
+ Object.defineProperty(exports, "isMiniProgramThemeScopeSelector", {
3222
+ enumerable: true,
3223
+ get: function() {
3224
+ return isMiniProgramThemeScopeSelector;
3225
+ }
3226
+ });
3227
+ Object.defineProperty(exports, "isMiniProgramThemeVariableRule", {
3228
+ enumerable: true,
3229
+ get: function() {
3230
+ return isMiniProgramThemeVariableRule;
3231
+ }
3232
+ });
3233
+ Object.defineProperty(exports, "isPseudoContentInitRule", {
3234
+ enumerable: true,
3235
+ get: function() {
3236
+ return isPseudoContentInitRule;
3237
+ }
3238
+ });
3239
+ Object.defineProperty(exports, "isTailwindCssGenerationDirective", {
3240
+ enumerable: true,
3241
+ get: function() {
3242
+ return isTailwindCssGenerationDirective;
3243
+ }
3244
+ });
3245
+ Object.defineProperty(exports, "isTailwindCssImport", {
3246
+ enumerable: true,
3247
+ get: function() {
3248
+ return isTailwindCssImport;
3249
+ }
3250
+ });
3251
+ Object.defineProperty(exports, "isTailwindCssImportAtRule", {
3252
+ enumerable: true,
3253
+ get: function() {
3254
+ return isTailwindCssImportAtRule;
3255
+ }
3256
+ });
3257
+ Object.defineProperty(exports, "isTailwindCssImportRequest", {
3258
+ enumerable: true,
3259
+ get: function() {
3260
+ return isTailwindCssImportRequest;
3261
+ }
3262
+ });
3263
+ Object.defineProperty(exports, "isTailwindCssPackageJsonImportRequest", {
3264
+ enumerable: true,
3265
+ get: function() {
3266
+ return isTailwindCssPackageJsonImportRequest;
3267
+ }
3268
+ });
3269
+ Object.defineProperty(exports, "isTailwindcssV4", {
3270
+ enumerable: true,
3271
+ get: function() {
3272
+ return isTailwindcssV4;
3273
+ }
3274
+ });
3275
+ Object.defineProperty(exports, "isTailwindcssV4ThemeVariable", {
3276
+ enumerable: true,
3277
+ get: function() {
3278
+ return isTailwindcssV4ThemeVariable;
3279
+ }
3280
+ });
3281
+ Object.defineProperty(exports, "isUnsupportedBrowserPreflightSelector", {
3282
+ enumerable: true,
3283
+ get: function() {
3284
+ return isUnsupportedBrowserPreflightSelector;
3285
+ }
3286
+ });
3287
+ Object.defineProperty(exports, "isWeappTailwindcssImportRequest", {
3288
+ enumerable: true,
3289
+ get: function() {
3290
+ return isWeappTailwindcssImportRequest;
3291
+ }
3292
+ });
3293
+ Object.defineProperty(exports, "mergeTailwindcssV4GradientDirectionRules", {
3294
+ enumerable: true,
3295
+ get: function() {
3296
+ return mergeTailwindcssV4GradientDirectionRules;
3297
+ }
3298
+ });
3299
+ Object.defineProperty(exports, "normalizeConfigDirective", {
3300
+ enumerable: true,
3301
+ get: function() {
3302
+ return normalizeConfigDirective;
3303
+ }
3304
+ });
3305
+ Object.defineProperty(exports, "normalizeGeneratedSelector", {
3306
+ enumerable: true,
3307
+ get: function() {
3308
+ return normalizeGeneratedSelector;
3309
+ }
3310
+ });
3311
+ Object.defineProperty(exports, "normalizeMiniProgramPrefixedDeclaration", {
3312
+ enumerable: true,
3313
+ get: function() {
3314
+ return normalizeMiniProgramPrefixedDeclaration;
3315
+ }
3316
+ });
3317
+ Object.defineProperty(exports, "normalizeModernColorValue", {
3318
+ enumerable: true,
3319
+ get: function() {
3320
+ return normalizeModernColorValue;
3321
+ }
3322
+ });
3323
+ Object.defineProperty(exports, "normalizeTailwindCssImportRequest", {
3324
+ enumerable: true,
3325
+ get: function() {
3326
+ return normalizeTailwindCssImportRequest;
3327
+ }
3328
+ });
3329
+ Object.defineProperty(exports, "normalizeTailwindcssV4Declaration", {
3330
+ enumerable: true,
3331
+ get: function() {
3332
+ return normalizeTailwindcssV4Declaration;
3333
+ }
3334
+ });
3335
+ Object.defineProperty(exports, "normalizeTailwindcssV4InfinityCalcCss", {
3336
+ enumerable: true,
3337
+ get: function() {
3338
+ return normalizeTailwindcssV4InfinityCalcCss;
3339
+ }
3340
+ });
3341
+ Object.defineProperty(exports, "normalizeWebCssCompatOptions", {
3342
+ enumerable: true,
3343
+ get: function() {
3344
+ return normalizeWebCssCompatOptions;
3345
+ }
3346
+ });
3347
+ Object.defineProperty(exports, "parseConfigParam", {
3348
+ enumerable: true,
3349
+ get: function() {
3350
+ return parseConfigParam;
3351
+ }
3352
+ });
3353
+ Object.defineProperty(exports, "parseCssImportSpecifier", {
3354
+ enumerable: true,
3355
+ get: function() {
3356
+ return parseCssImportSpecifier;
3357
+ }
3358
+ });
3359
+ Object.defineProperty(exports, "parseImportSourceParam", {
3360
+ enumerable: true,
3361
+ get: function() {
3362
+ return parseImportSourceParam;
3363
+ }
3364
+ });
3365
+ Object.defineProperty(exports, "parseSourceFileParam", {
3366
+ enumerable: true,
3367
+ get: function() {
3368
+ return parseSourceFileParam;
3369
+ }
3370
+ });
3371
+ Object.defineProperty(exports, "parseTailwindCssConfigRequest", {
3372
+ enumerable: true,
3373
+ get: function() {
3374
+ return parseTailwindCssConfigRequest;
3375
+ }
3376
+ });
3377
+ Object.defineProperty(exports, "parseTailwindCssDirectiveRequest", {
3378
+ enumerable: true,
3379
+ get: function() {
3380
+ return parseTailwindCssDirectiveRequest;
3381
+ }
3382
+ });
3383
+ Object.defineProperty(exports, "prependConfigDirective", {
3384
+ enumerable: true,
3385
+ get: function() {
3386
+ return prependConfigDirective;
3387
+ }
3388
+ });
3389
+ Object.defineProperty(exports, "protectDynamicColorMixAlpha", {
3390
+ enumerable: true,
3391
+ get: function() {
3392
+ return protectDynamicColorMixAlpha;
3393
+ }
3394
+ });
3395
+ Object.defineProperty(exports, "protectDynamicVarFallbacks", {
3396
+ enumerable: true,
3397
+ get: function() {
3398
+ return protectDynamicVarFallbacks;
3399
+ }
3400
+ });
3401
+ Object.defineProperty(exports, "quoteCssImportSpecifier", {
3402
+ enumerable: true,
3403
+ get: function() {
3404
+ return quoteCssImportSpecifier;
3405
+ }
3406
+ });
3407
+ Object.defineProperty(exports, "removeEmptyAtRules", {
3408
+ enumerable: true,
3409
+ get: function() {
3410
+ return removeEmptyAtRules$1;
3411
+ }
3412
+ });
3413
+ Object.defineProperty(exports, "removeEmptyBlockAtRules", {
3414
+ enumerable: true,
3415
+ get: function() {
3416
+ return removeEmptyBlockAtRules;
3417
+ }
3418
+ });
3419
+ Object.defineProperty(exports, "removeEmptyRules", {
3420
+ enumerable: true,
3421
+ get: function() {
3422
+ return removeEmptyRules;
3423
+ }
3424
+ });
3425
+ Object.defineProperty(exports, "removeEmptyStandardDeclarations", {
3426
+ enumerable: true,
3427
+ get: function() {
3428
+ return removeEmptyStandardDeclarations;
3429
+ }
3430
+ });
3431
+ Object.defineProperty(exports, "removeSpecificityPlaceholders", {
3432
+ enumerable: true,
3433
+ get: function() {
3434
+ return removeSpecificityPlaceholders;
3435
+ }
3436
+ });
3437
+ Object.defineProperty(exports, "removeTailwindContainerMaxWidthMediaRules", {
3438
+ enumerable: true,
3439
+ get: function() {
3440
+ return removeTailwindContainerMaxWidthMediaRules;
3441
+ }
3442
+ });
3443
+ Object.defineProperty(exports, "removeTailwindContainerWidthRules", {
3444
+ enumerable: true,
3445
+ get: function() {
3446
+ return removeTailwindContainerWidthRules;
3447
+ }
3448
+ });
3449
+ Object.defineProperty(exports, "removeUnsupportedAtSupports", {
3450
+ enumerable: true,
3451
+ get: function() {
3452
+ return removeUnsupportedAtSupports;
3453
+ }
3454
+ });
3455
+ Object.defineProperty(exports, "removeUnsupportedCascadeLayers", {
3456
+ enumerable: true,
3457
+ get: function() {
3458
+ return removeUnsupportedCascadeLayers;
3459
+ }
3460
+ });
3461
+ Object.defineProperty(exports, "removeUnsupportedMiniProgramAtRules", {
3462
+ enumerable: true,
3463
+ get: function() {
3464
+ return removeUnsupportedMiniProgramAtRules;
3465
+ }
3466
+ });
3467
+ Object.defineProperty(exports, "removeUnsupportedMiniProgramPrefixedAtRule", {
3468
+ enumerable: true,
3469
+ get: function() {
3470
+ return removeUnsupportedMiniProgramPrefixedAtRule;
3471
+ }
3472
+ });
3473
+ Object.defineProperty(exports, "removeUnsupportedModernColorDeclarations", {
3474
+ enumerable: true,
3475
+ get: function() {
3476
+ return removeUnsupportedModernColorDeclarations;
3477
+ }
3478
+ });
3479
+ Object.defineProperty(exports, "repairTrailingUnclosedTailwindSourceMedia", {
3480
+ enumerable: true,
3481
+ get: function() {
3482
+ return repairTrailingUnclosedTailwindSourceMedia;
3483
+ }
3484
+ });
3485
+ Object.defineProperty(exports, "resolveCssScanSources", {
3486
+ enumerable: true,
3487
+ get: function() {
3488
+ return resolveCssScanSources;
3489
+ }
3490
+ });
3491
+ Object.defineProperty(exports, "resolveCssSourceEntries", {
3492
+ enumerable: true,
3493
+ get: function() {
3494
+ return resolveCssSourceEntries;
3495
+ }
3496
+ });
3497
+ Object.defineProperty(exports, "rewriteCssConfigRequests", {
3498
+ enumerable: true,
3499
+ get: function() {
3500
+ return rewriteCssConfigRequests;
3501
+ }
3502
+ });
3503
+ Object.defineProperty(exports, "stripMiniProgramCssSpecificityPlaceholders", {
3504
+ enumerable: true,
3505
+ get: function() {
3506
+ return stripMiniProgramCssSpecificityPlaceholders;
3507
+ }
3508
+ });
3509
+ Object.defineProperty(exports, "stripTailwindConfigDirectives", {
3510
+ enumerable: true,
3511
+ get: function() {
3512
+ return stripTailwindConfigDirectives;
3513
+ }
3514
+ });
3515
+ Object.defineProperty(exports, "testIfRootHostForV4", {
3516
+ enumerable: true,
3517
+ get: function() {
3518
+ return testIfRootHostForV4;
3519
+ }
3520
+ });
3521
+ Object.defineProperty(exports, "transformLynxCssCompat", {
3522
+ enumerable: true,
3523
+ get: function() {
3524
+ return transformLynxCssCompat;
3525
+ }
3526
+ });
3527
+ Object.defineProperty(exports, "transformWebCssCompat", {
3528
+ enumerable: true,
3529
+ get: function() {
3530
+ return transformWebCssCompat;
3531
+ }
3532
+ });
3533
+ Object.defineProperty(exports, "transformWebCssSafeSelectors", {
3534
+ enumerable: true,
3535
+ get: function() {
3536
+ return transformWebCssSafeSelectors;
3537
+ }
3538
+ });
3539
+ Object.defineProperty(exports, "unwrapUnsupportedCascadeLayers", {
3540
+ enumerable: true,
3541
+ get: function() {
3542
+ return unwrapUnsupportedCascadeLayers;
3543
+ }
3544
+ });
3545
+ Object.defineProperty(exports, "usesTailwindcssV4ContentVariable", {
3546
+ enumerable: true,
3547
+ get: function() {
3548
+ return usesTailwindcssV4ContentVariable;
3549
+ }
3550
+ });
3551
+ Object.defineProperty(exports, "usesTwContentVariable", {
3552
+ enumerable: true,
3553
+ get: function() {
3554
+ return usesTwContentVariable;
3555
+ }
3556
+ });