@unocss/preset-mini 0.57.7 → 0.58.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/colors.d.cts +1 -1
  2. package/dist/colors.d.mts +1 -1
  3. package/dist/colors.d.ts +1 -1
  4. package/dist/index.cjs +12 -12
  5. package/dist/index.d.cts +6 -6
  6. package/dist/index.d.mts +6 -6
  7. package/dist/index.d.ts +6 -6
  8. package/dist/index.mjs +7 -7
  9. package/dist/rules.cjs +50 -972
  10. package/dist/rules.d.cts +2 -6
  11. package/dist/rules.d.mts +2 -6
  12. package/dist/rules.d.ts +2 -6
  13. package/dist/rules.mjs +5 -931
  14. package/dist/shared/{preset-mini.MACvs-wn.cjs → preset-mini.-3Qybdh5.cjs} +49 -39
  15. package/dist/shared/{preset-mini.Stl9mkMB.mjs → preset-mini.0CcynBZx.mjs} +45 -26
  16. package/dist/shared/{preset-mini.dPVVIvNm.mjs → preset-mini.0UJFjS_1.mjs} +16 -6
  17. package/dist/shared/{preset-mini.XmVozI6N.d.mts → preset-mini.20fUBpHS.d.cts} +4 -3
  18. package/dist/shared/{preset-mini.QW22c5Df.d.ts → preset-mini.8w2rXvMk.d.ts} +4 -3
  19. package/dist/shared/preset-mini.AVP8I7_j.mjs +747 -0
  20. package/dist/shared/preset-mini.ORVb5Lu8.mjs +978 -0
  21. package/dist/shared/{preset-mini.ImRm63ih.cjs → preset-mini.UhMMbd34.cjs} +44 -26
  22. package/dist/shared/{preset-mini.4DxDu2I8.d.mts → preset-mini.YxT4AwuI.d.cts} +1 -1
  23. package/dist/shared/preset-mini.fgwIVvur.cjs +322 -0
  24. package/dist/shared/preset-mini.g6cWGZM2.cjs +1021 -0
  25. package/dist/shared/{preset-mini.5daNC9yh.d.ts → preset-mini.gVNz4b9u.d.ts} +1 -1
  26. package/dist/shared/{preset-mini.7XoWRZIl.d.mts → preset-mini.hpPpX7ws.d.cts} +1 -1
  27. package/dist/shared/{preset-mini.7XoWRZIl.d.ts → preset-mini.hpPpX7ws.d.mts} +1 -1
  28. package/dist/shared/{preset-mini.7XoWRZIl.d.cts → preset-mini.hpPpX7ws.d.ts} +1 -1
  29. package/dist/shared/preset-mini.jXC5Sr98.cjs +772 -0
  30. package/dist/shared/{preset-mini.Jpc0QYPj.d.cts → preset-mini.nzD7Hw_0.d.mts} +4 -3
  31. package/dist/shared/{preset-mini.5-XKlNyK.d.cts → preset-mini.vMrmsD3H.d.mts} +1 -1
  32. package/dist/shared/preset-mini.zC_vZg74.mjs +291 -0
  33. package/dist/theme.cjs +34 -318
  34. package/dist/theme.d.cts +3 -3
  35. package/dist/theme.d.mts +3 -3
  36. package/dist/theme.d.ts +3 -3
  37. package/dist/theme.mjs +5 -293
  38. package/dist/utils.cjs +23 -23
  39. package/dist/utils.d.cts +4 -4
  40. package/dist/utils.d.mts +4 -4
  41. package/dist/utils.d.ts +4 -4
  42. package/dist/utils.mjs +1 -1
  43. package/dist/variants.cjs +31 -739
  44. package/dist/variants.d.cts +5 -5
  45. package/dist/variants.d.mts +5 -5
  46. package/dist/variants.d.ts +5 -5
  47. package/dist/variants.mjs +4 -716
  48. package/package.json +4 -4
@@ -0,0 +1,747 @@
1
+ import { b as h, r as resolveBreakpoints, C as CONTROL_MINI_NO_NEGATIVE, a as cssMathFnRE } from './preset-mini.0CcynBZx.mjs';
2
+ import { variantGetParameter, variantGetBracket, variantMatcher, variantParentMatcher, getBracket, getStringComponent } from '@unocss/rule-utils';
3
+ import { warnOnce, escapeRegExp, escapeSelector } from '@unocss/core';
4
+
5
+ const variantAria = {
6
+ name: "aria",
7
+ match(matcher, ctx) {
8
+ const variant = variantGetParameter("aria-", matcher, ctx.generator.config.separators);
9
+ if (variant) {
10
+ const [match, rest] = variant;
11
+ const aria = h.bracket(match) ?? ctx.theme.aria?.[match] ?? "";
12
+ if (aria) {
13
+ return {
14
+ matcher: rest,
15
+ selector: (s) => `${s}[aria-${aria}]`
16
+ };
17
+ }
18
+ }
19
+ }
20
+ };
21
+
22
+ function calcMaxWidthBySize(size) {
23
+ const value = size.match(/^-?[0-9]+\.?[0-9]*/)?.[0] || "";
24
+ const unit = size.slice(value.length);
25
+ if (unit === "px") {
26
+ const maxWidth = Number.parseFloat(value) - 0.1;
27
+ return Number.isNaN(maxWidth) ? size : `${maxWidth}${unit}`;
28
+ }
29
+ return `calc(${size} - 0.1px)`;
30
+ }
31
+ function variantBreakpoints() {
32
+ const regexCache = {};
33
+ return {
34
+ name: "breakpoints",
35
+ match(matcher, context) {
36
+ const variantEntries = (resolveBreakpoints(context) ?? []).map(({ point, size }, idx) => [point, size, idx]);
37
+ for (const [point, size, idx] of variantEntries) {
38
+ if (!regexCache[point])
39
+ regexCache[point] = new RegExp(`^((?:([al]t-|[<~]|max-))?${point}(?:${context.generator.config.separators.join("|")}))`);
40
+ const match = matcher.match(regexCache[point]);
41
+ if (!match)
42
+ continue;
43
+ const [, pre] = match;
44
+ const m = matcher.slice(pre.length);
45
+ if (m === "container")
46
+ continue;
47
+ const isLtPrefix = pre.startsWith("lt-") || pre.startsWith("<") || pre.startsWith("max-");
48
+ const isAtPrefix = pre.startsWith("at-") || pre.startsWith("~");
49
+ let order = 1e3;
50
+ if (isLtPrefix) {
51
+ order -= idx + 1;
52
+ return {
53
+ matcher: m,
54
+ handle: (input, next) => next({
55
+ ...input,
56
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}@media (max-width: ${calcMaxWidthBySize(size)})`,
57
+ parentOrder: order
58
+ })
59
+ };
60
+ }
61
+ order += idx + 1;
62
+ if (isAtPrefix && idx < variantEntries.length - 1) {
63
+ return {
64
+ matcher: m,
65
+ handle: (input, next) => next({
66
+ ...input,
67
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}@media (min-width: ${size}) and (max-width: ${calcMaxWidthBySize(variantEntries[idx + 1][1])})`,
68
+ parentOrder: order
69
+ })
70
+ };
71
+ }
72
+ return {
73
+ matcher: m,
74
+ handle: (input, next) => next({
75
+ ...input,
76
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}@media (min-width: ${size})`,
77
+ parentOrder: order
78
+ })
79
+ };
80
+ }
81
+ },
82
+ multiPass: true,
83
+ autocomplete: "(at-|lt-|max-|)$breakpoints:"
84
+ };
85
+ }
86
+
87
+ function scopeMatcher(name, combinator) {
88
+ return {
89
+ name: `combinator:${name}`,
90
+ match(matcher, ctx) {
91
+ if (!matcher.startsWith(name))
92
+ return;
93
+ const separators = ctx.generator.config.separators;
94
+ let body = variantGetBracket(`${name}-`, matcher, separators);
95
+ if (!body) {
96
+ for (const separator of separators) {
97
+ if (matcher.startsWith(`${name}${separator}`)) {
98
+ body = ["", matcher.slice(name.length + separator.length)];
99
+ break;
100
+ }
101
+ }
102
+ if (!body)
103
+ return;
104
+ }
105
+ let bracketValue = h.bracket(body[0]) ?? "";
106
+ if (bracketValue === "")
107
+ bracketValue = "*";
108
+ return {
109
+ matcher: body[1],
110
+ selector: (s) => `${s}${combinator}${bracketValue}`
111
+ };
112
+ },
113
+ multiPass: true
114
+ };
115
+ }
116
+ const variantCombinators = [
117
+ scopeMatcher("all", " "),
118
+ scopeMatcher("children", ">"),
119
+ scopeMatcher("next", "+"),
120
+ scopeMatcher("sibling", "+"),
121
+ scopeMatcher("siblings", "~")
122
+ ];
123
+
124
+ const variantContainerQuery = {
125
+ name: "@",
126
+ match(matcher, ctx) {
127
+ if (matcher.startsWith("@container"))
128
+ return;
129
+ const variant = variantGetParameter("@", matcher, ctx.generator.config.separators);
130
+ if (variant) {
131
+ const [match, rest, label] = variant;
132
+ const unbracket = h.bracket(match);
133
+ let container;
134
+ if (unbracket) {
135
+ const minWidth = h.numberWithUnit(unbracket);
136
+ if (minWidth)
137
+ container = `(min-width: ${minWidth})`;
138
+ } else {
139
+ container = ctx.theme.containers?.[match] ?? "";
140
+ }
141
+ if (container) {
142
+ warnOnce("The container query variant is experimental and may not follow semver.");
143
+ return {
144
+ matcher: rest,
145
+ handle: (input, next) => next({
146
+ ...input,
147
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}@container${label ? ` ${label} ` : " "}${container}`
148
+ })
149
+ };
150
+ }
151
+ }
152
+ },
153
+ multiPass: true
154
+ };
155
+
156
+ function variantColorsMediaOrClass(options = {}) {
157
+ if (options?.dark === "class" || typeof options.dark === "object") {
158
+ const { dark = ".dark", light = ".light" } = typeof options.dark === "string" ? {} : options.dark;
159
+ return [
160
+ variantMatcher("dark", (input) => ({ prefix: `${dark} $$ ${input.prefix}` })),
161
+ variantMatcher("light", (input) => ({ prefix: `${light} $$ ${input.prefix}` }))
162
+ ];
163
+ }
164
+ return [
165
+ variantParentMatcher("dark", "@media (prefers-color-scheme: dark)"),
166
+ variantParentMatcher("light", "@media (prefers-color-scheme: light)")
167
+ ];
168
+ }
169
+
170
+ const variantDataAttribute = {
171
+ name: "data",
172
+ match(matcher, ctx) {
173
+ const variant = variantGetParameter("data-", matcher, ctx.generator.config.separators);
174
+ if (variant) {
175
+ const [match, rest] = variant;
176
+ const dataAttribute = h.bracket(match) ?? ctx.theme.data?.[match] ?? "";
177
+ if (dataAttribute) {
178
+ return {
179
+ matcher: rest,
180
+ selector: (s) => `${s}[data-${dataAttribute}]`
181
+ };
182
+ }
183
+ }
184
+ }
185
+ };
186
+ function taggedData(tagName) {
187
+ return {
188
+ name: `${tagName}-data`,
189
+ match(matcher, ctx) {
190
+ const variant = variantGetParameter(`${tagName}-data-`, matcher, ctx.generator.config.separators);
191
+ if (variant) {
192
+ const [match, rest] = variant;
193
+ const dataAttribute = h.bracket(match) ?? ctx.theme.data?.[match] ?? "";
194
+ if (dataAttribute) {
195
+ return {
196
+ matcher: `${tagName}-[[data-${dataAttribute}]]:${rest}`
197
+ };
198
+ }
199
+ }
200
+ }
201
+ };
202
+ }
203
+ const variantTaggedDataAttributes = [
204
+ taggedData("group"),
205
+ taggedData("peer"),
206
+ taggedData("parent"),
207
+ taggedData("previous")
208
+ ];
209
+
210
+ const variantLanguageDirections = [
211
+ variantMatcher("rtl", (input) => ({ prefix: `[dir="rtl"] $$ ${input.prefix}` })),
212
+ variantMatcher("ltr", (input) => ({ prefix: `[dir="ltr"] $$ ${input.prefix}` }))
213
+ ];
214
+
215
+ const variantSelector = {
216
+ name: "selector",
217
+ match(matcher, ctx) {
218
+ const variant = variantGetBracket("selector-", matcher, ctx.generator.config.separators);
219
+ if (variant) {
220
+ const [match, rest] = variant;
221
+ const selector = h.bracket(match);
222
+ if (selector) {
223
+ return {
224
+ matcher: rest,
225
+ selector: () => selector
226
+ };
227
+ }
228
+ }
229
+ }
230
+ };
231
+ const variantCssLayer = {
232
+ name: "layer",
233
+ match(matcher, ctx) {
234
+ const variant = variantGetParameter("layer-", matcher, ctx.generator.config.separators);
235
+ if (variant) {
236
+ const [match, rest] = variant;
237
+ const layer = h.bracket(match) ?? match;
238
+ if (layer) {
239
+ return {
240
+ matcher: rest,
241
+ handle: (input, next) => next({
242
+ ...input,
243
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}@layer ${layer}`
244
+ })
245
+ };
246
+ }
247
+ }
248
+ }
249
+ };
250
+ const variantInternalLayer = {
251
+ name: "uno-layer",
252
+ match(matcher, ctx) {
253
+ const variant = variantGetParameter("uno-layer-", matcher, ctx.generator.config.separators);
254
+ if (variant) {
255
+ const [match, rest] = variant;
256
+ const layer = h.bracket(match) ?? match;
257
+ if (layer) {
258
+ return {
259
+ matcher: rest,
260
+ layer
261
+ };
262
+ }
263
+ }
264
+ }
265
+ };
266
+ const variantScope = {
267
+ name: "scope",
268
+ match(matcher, ctx) {
269
+ const variant = variantGetBracket("scope-", matcher, ctx.generator.config.separators);
270
+ if (variant) {
271
+ const [match, rest] = variant;
272
+ const scope = h.bracket(match);
273
+ if (scope) {
274
+ return {
275
+ matcher: rest,
276
+ selector: (s) => `${scope} $$ ${s}`
277
+ };
278
+ }
279
+ }
280
+ }
281
+ };
282
+ const variantVariables = {
283
+ name: "variables",
284
+ match(matcher, ctx) {
285
+ if (!matcher.startsWith("["))
286
+ return;
287
+ const [match, rest] = getBracket(matcher, "[", "]") ?? [];
288
+ if (!(match && rest))
289
+ return;
290
+ let newMatcher;
291
+ for (const separator of ctx.generator.config.separators) {
292
+ if (rest.startsWith(separator)) {
293
+ newMatcher = rest.slice(separator.length);
294
+ break;
295
+ }
296
+ }
297
+ if (newMatcher == null)
298
+ return;
299
+ const variant = h.bracket(match) ?? "";
300
+ const useParent = variant.startsWith("@");
301
+ if (!(useParent || variant.includes("&")))
302
+ return;
303
+ return {
304
+ matcher: newMatcher,
305
+ handle(input, next) {
306
+ const updates = useParent ? {
307
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}${variant}`
308
+ } : {
309
+ selector: variant.replace(/&/g, input.selector)
310
+ };
311
+ return next({
312
+ ...input,
313
+ ...updates
314
+ });
315
+ }
316
+ };
317
+ },
318
+ multiPass: true
319
+ };
320
+
321
+ const anchoredNumberRE = /^-?[0-9.]+(?:[a-z]+|%)?$/;
322
+ const numberRE = /-?[0-9.]+(?:[a-z]+|%)?/;
323
+ const ignoreProps = [
324
+ /\b(opacity|color|flex|backdrop-filter|^filter|transform)\b/
325
+ ];
326
+ function negateMathFunction(value) {
327
+ const match = value.match(cssMathFnRE);
328
+ if (match) {
329
+ const [fnBody, rest] = getStringComponent(`(${match[2]})${match[3]}`, "(", ")", " ") ?? [];
330
+ if (fnBody)
331
+ return `calc(${match[1]}${fnBody} * -1)${rest ? ` ${rest}` : ""}`;
332
+ }
333
+ }
334
+ const negateFunctionBodyRE = /\b(hue-rotate)\s*(\(.*)/;
335
+ function negateFunctionBody(value) {
336
+ const match = value.match(negateFunctionBodyRE);
337
+ if (match) {
338
+ const [fnBody, rest] = getStringComponent(match[2], "(", ")", " ") ?? [];
339
+ if (fnBody) {
340
+ const body = anchoredNumberRE.test(fnBody.slice(1, -1)) ? fnBody.replace(numberRE, (i) => i.startsWith("-") ? i.slice(1) : `-${i}`) : `(calc(${fnBody} * -1))`;
341
+ return `${match[1]}${body}${rest ? ` ${rest}` : ""}`;
342
+ }
343
+ }
344
+ }
345
+ const variantNegative = {
346
+ name: "negative",
347
+ match(matcher) {
348
+ if (!matcher.startsWith("-"))
349
+ return;
350
+ return {
351
+ matcher: matcher.slice(1),
352
+ body: (body) => {
353
+ if (body.find((v) => v[0] === CONTROL_MINI_NO_NEGATIVE))
354
+ return;
355
+ let changed = false;
356
+ body.forEach((v) => {
357
+ const value = v[1]?.toString();
358
+ if (!value || value === "0")
359
+ return;
360
+ if (ignoreProps.some((i) => i.test(v[0])))
361
+ return;
362
+ const negatedFn = negateMathFunction(value);
363
+ if (negatedFn) {
364
+ v[1] = negatedFn;
365
+ changed = true;
366
+ return;
367
+ }
368
+ const negatedBody = negateFunctionBody(value);
369
+ if (negatedBody) {
370
+ v[1] = negatedBody;
371
+ changed = true;
372
+ return;
373
+ }
374
+ if (anchoredNumberRE.test(value)) {
375
+ v[1] = value.replace(numberRE, (i) => i.startsWith("-") ? i.slice(1) : `-${i}`);
376
+ changed = true;
377
+ }
378
+ });
379
+ if (changed)
380
+ return body;
381
+ return [];
382
+ }
383
+ };
384
+ }
385
+ };
386
+
387
+ function variantImportant() {
388
+ let re;
389
+ return {
390
+ name: "important",
391
+ match(matcher, ctx) {
392
+ if (!re)
393
+ re = new RegExp(`^(important(?:${ctx.generator.config.separators.join("|")})|!)`);
394
+ let base;
395
+ const match = matcher.match(re);
396
+ if (match)
397
+ base = matcher.slice(match[0].length);
398
+ else if (matcher.endsWith("!"))
399
+ base = matcher.slice(0, -1);
400
+ if (base) {
401
+ return {
402
+ matcher: base,
403
+ body: (body) => {
404
+ body.forEach((v) => {
405
+ if (v[1])
406
+ v[1] += " !important";
407
+ });
408
+ return body;
409
+ }
410
+ };
411
+ }
412
+ }
413
+ };
414
+ }
415
+
416
+ const variantPrint = variantParentMatcher("print", "@media print");
417
+ const variantCustomMedia = {
418
+ name: "media",
419
+ match(matcher, ctx) {
420
+ const variant = variantGetParameter("media-", matcher, ctx.generator.config.separators);
421
+ if (variant) {
422
+ const [match, rest] = variant;
423
+ let media = h.bracket(match) ?? "";
424
+ if (media === "")
425
+ media = ctx.theme.media?.[match] ?? "";
426
+ if (media) {
427
+ return {
428
+ matcher: rest,
429
+ handle: (input, next) => next({
430
+ ...input,
431
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}@media ${media}`
432
+ })
433
+ };
434
+ }
435
+ }
436
+ },
437
+ multiPass: true
438
+ };
439
+
440
+ const variantSupports = {
441
+ name: "supports",
442
+ match(matcher, ctx) {
443
+ const variant = variantGetParameter("supports-", matcher, ctx.generator.config.separators);
444
+ if (variant) {
445
+ const [match, rest] = variant;
446
+ let supports = h.bracket(match) ?? "";
447
+ if (supports === "")
448
+ supports = ctx.theme.supports?.[match] ?? "";
449
+ if (supports) {
450
+ return {
451
+ matcher: rest,
452
+ handle: (input, next) => next({
453
+ ...input,
454
+ parent: `${input.parent ? `${input.parent} $$ ` : ""}@supports ${supports}`
455
+ })
456
+ };
457
+ }
458
+ }
459
+ },
460
+ multiPass: true
461
+ };
462
+
463
+ const PseudoClasses = Object.fromEntries([
464
+ // pseudo elements part 1
465
+ ["first-letter", "::first-letter"],
466
+ ["first-line", "::first-line"],
467
+ // location
468
+ "any-link",
469
+ "link",
470
+ "visited",
471
+ "target",
472
+ ["open", "[open]"],
473
+ // forms
474
+ "default",
475
+ "checked",
476
+ "indeterminate",
477
+ "placeholder-shown",
478
+ "autofill",
479
+ "optional",
480
+ "required",
481
+ "valid",
482
+ "invalid",
483
+ "user-valid",
484
+ "user-invalid",
485
+ "in-range",
486
+ "out-of-range",
487
+ "read-only",
488
+ "read-write",
489
+ // content
490
+ "empty",
491
+ // interactions
492
+ "focus-within",
493
+ "hover",
494
+ "focus",
495
+ "focus-visible",
496
+ "active",
497
+ "enabled",
498
+ "disabled",
499
+ // tree-structural
500
+ "root",
501
+ "empty",
502
+ ["even-of-type", ":nth-of-type(even)"],
503
+ ["even", ":nth-child(even)"],
504
+ ["odd-of-type", ":nth-of-type(odd)"],
505
+ ["odd", ":nth-child(odd)"],
506
+ "first-of-type",
507
+ ["first", ":first-child"],
508
+ "last-of-type",
509
+ ["last", ":last-child"],
510
+ "only-child",
511
+ "only-of-type",
512
+ // pseudo elements part 2
513
+ ["backdrop-element", "::backdrop"],
514
+ ["placeholder", "::placeholder"],
515
+ ["before", "::before"],
516
+ ["after", "::after"],
517
+ ["selection", "::selection"],
518
+ ["marker", "::marker"],
519
+ ["file", "::file-selector-button"]
520
+ ].map((key) => Array.isArray(key) ? key : [key, `:${key}`]));
521
+ const PseudoClassesKeys = Object.keys(PseudoClasses);
522
+ const PseudoClassesColon = Object.fromEntries([
523
+ ["backdrop", "::backdrop"]
524
+ ].map((key) => Array.isArray(key) ? key : [key, `:${key}`]));
525
+ const PseudoClassesColonKeys = Object.keys(PseudoClassesColon);
526
+ const PseudoClassFunctions = [
527
+ "not",
528
+ "is",
529
+ "where",
530
+ "has"
531
+ ];
532
+ const PseudoClassesStr = Object.entries(PseudoClasses).filter(([, pseudo]) => !pseudo.startsWith("::")).map(([key]) => key).sort((a, b) => b.length - a.length).join("|");
533
+ const PseudoClassesColonStr = Object.entries(PseudoClassesColon).filter(([, pseudo]) => !pseudo.startsWith("::")).map(([key]) => key).sort((a, b) => b.length - a.length).join("|");
534
+ const PseudoClassFunctionsStr = PseudoClassFunctions.join("|");
535
+ function taggedPseudoClassMatcher(tag, parent, combinator) {
536
+ const rawRE = new RegExp(`^(${escapeRegExp(parent)}:)(\\S+)${escapeRegExp(combinator)}\\1`);
537
+ let splitRE;
538
+ let pseudoRE;
539
+ let pseudoColonRE;
540
+ let pseudoVarRE;
541
+ const matchBracket = (input) => {
542
+ const body = variantGetBracket(`${tag}-`, input, []);
543
+ if (!body)
544
+ return;
545
+ const [match, rest] = body;
546
+ const bracketValue = h.bracket(match);
547
+ if (bracketValue == null)
548
+ return;
549
+ const label = rest.split(splitRE, 1)?.[0] ?? "";
550
+ const prefix = `${parent}${escapeSelector(label)}`;
551
+ return [
552
+ label,
553
+ input.slice(input.length - (rest.length - label.length - 1)),
554
+ bracketValue.includes("&") ? bracketValue.replace(/&/g, prefix) : `${prefix}${bracketValue}`
555
+ ];
556
+ };
557
+ const matchPseudo = (input) => {
558
+ const match = input.match(pseudoRE) || input.match(pseudoColonRE);
559
+ if (!match)
560
+ return;
561
+ const [original, fn, pseudoKey] = match;
562
+ const label = match[3] ?? "";
563
+ let pseudo = PseudoClasses[pseudoKey] || PseudoClassesColon[pseudoKey] || `:${pseudoKey}`;
564
+ if (fn)
565
+ pseudo = `:${fn}(${pseudo})`;
566
+ return [
567
+ label,
568
+ input.slice(original.length),
569
+ `${parent}${escapeSelector(label)}${pseudo}`,
570
+ pseudoKey
571
+ ];
572
+ };
573
+ const matchPseudoVar = (input) => {
574
+ const match = input.match(pseudoVarRE);
575
+ if (!match)
576
+ return;
577
+ const [original, fn, pseudoValue] = match;
578
+ const label = match[3] ?? "";
579
+ const pseudo = `:${fn}(${pseudoValue})`;
580
+ return [
581
+ label,
582
+ input.slice(original.length),
583
+ `${parent}${escapeSelector(label)}${pseudo}`
584
+ ];
585
+ };
586
+ return {
587
+ name: `pseudo:${tag}`,
588
+ match(input, ctx) {
589
+ if (!(splitRE && pseudoRE && pseudoColonRE)) {
590
+ splitRE = new RegExp(`(?:${ctx.generator.config.separators.join("|")})`);
591
+ pseudoRE = new RegExp(`^${tag}-(?:(?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesStr}))(?:(/\\w+))?(?:${ctx.generator.config.separators.join("|")})`);
592
+ pseudoColonRE = new RegExp(`^${tag}-(?:(?:(${PseudoClassFunctionsStr})-)?(${PseudoClassesColonStr}))(?:(/\\w+))?(?:${ctx.generator.config.separators.filter((x) => x !== "-").join("|")})`);
593
+ pseudoVarRE = new RegExp(`^${tag}-(?:(${PseudoClassFunctionsStr})-)?\\[(.+)\\](?:(/\\w+))?(?:${ctx.generator.config.separators.filter((x) => x !== "-").join("|")})`);
594
+ }
595
+ if (!input.startsWith(tag))
596
+ return;
597
+ const result = matchBracket(input) || matchPseudo(input) || matchPseudoVar(input);
598
+ if (!result)
599
+ return;
600
+ const [label, matcher, prefix, pseudoName = ""] = result;
601
+ if (label !== "")
602
+ warnOnce("The labeled variant is experimental and may not follow semver.");
603
+ return {
604
+ matcher,
605
+ handle: (input2, next) => next({
606
+ ...input2,
607
+ prefix: `${prefix}${combinator}${input2.prefix}`.replace(rawRE, "$1$2:"),
608
+ sort: PseudoClassesKeys.indexOf(pseudoName) ?? PseudoClassesColonKeys.indexOf(pseudoName)
609
+ })
610
+ };
611
+ },
612
+ multiPass: true
613
+ };
614
+ }
615
+ const excludedPseudo = [
616
+ "::-webkit-resizer",
617
+ "::-webkit-scrollbar",
618
+ "::-webkit-scrollbar-button",
619
+ "::-webkit-scrollbar-corner",
620
+ "::-webkit-scrollbar-thumb",
621
+ "::-webkit-scrollbar-track",
622
+ "::-webkit-scrollbar-track-piece",
623
+ "::file-selector-button"
624
+ ];
625
+ const PseudoClassesAndElementsStr = Object.entries(PseudoClasses).map(([key]) => key).sort((a, b) => b.length - a.length).join("|");
626
+ const PseudoClassesAndElementsColonStr = Object.entries(PseudoClassesColon).map(([key]) => key).sort((a, b) => b.length - a.length).join("|");
627
+ function variantPseudoClassesAndElements() {
628
+ let PseudoClassesAndElementsRE;
629
+ let PseudoClassesAndElementsColonRE;
630
+ return {
631
+ name: "pseudo",
632
+ match(input, ctx) {
633
+ if (!(PseudoClassesAndElementsRE && PseudoClassesAndElementsRE)) {
634
+ PseudoClassesAndElementsRE = new RegExp(`^(${PseudoClassesAndElementsStr})(?:${ctx.generator.config.separators.join("|")})`);
635
+ PseudoClassesAndElementsColonRE = new RegExp(`^(${PseudoClassesAndElementsColonStr})(?:${ctx.generator.config.separators.filter((x) => x !== "-").join("|")})`);
636
+ }
637
+ const match = input.match(PseudoClassesAndElementsRE) || input.match(PseudoClassesAndElementsColonRE);
638
+ if (match) {
639
+ const pseudo = PseudoClasses[match[1]] || PseudoClassesColon[match[1]] || `:${match[1]}`;
640
+ let index = PseudoClassesKeys.indexOf(match[1]);
641
+ if (index === -1)
642
+ index = PseudoClassesColonKeys.indexOf(match[1]);
643
+ if (index === -1)
644
+ index = void 0;
645
+ return {
646
+ matcher: input.slice(match[0].length),
647
+ handle: (input2, next) => {
648
+ const selectors = pseudo.startsWith("::") && !excludedPseudo.includes(pseudo) ? {
649
+ pseudo: `${input2.pseudo}${pseudo}`
650
+ } : {
651
+ selector: `${input2.selector}${pseudo}`
652
+ };
653
+ return next({
654
+ ...input2,
655
+ ...selectors,
656
+ sort: index,
657
+ noMerge: true
658
+ });
659
+ }
660
+ };
661
+ }
662
+ },
663
+ multiPass: true,
664
+ autocomplete: `(${PseudoClassesAndElementsStr}|${PseudoClassesAndElementsColonStr}):`
665
+ };
666
+ }
667
+ function variantPseudoClassFunctions() {
668
+ let PseudoClassFunctionsRE;
669
+ let PseudoClassColonFunctionsRE;
670
+ let PseudoClassVarFunctionRE;
671
+ return {
672
+ match(input, ctx) {
673
+ if (!(PseudoClassFunctionsRE && PseudoClassColonFunctionsRE)) {
674
+ PseudoClassFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesStr})(?:${ctx.generator.config.separators.join("|")})`);
675
+ PseudoClassColonFunctionsRE = new RegExp(`^(${PseudoClassFunctionsStr})-(${PseudoClassesColonStr})(?:${ctx.generator.config.separators.filter((x) => x !== "-").join("|")})`);
676
+ PseudoClassVarFunctionRE = new RegExp(`^(${PseudoClassFunctionsStr})-(\\[.+\\])(?:${ctx.generator.config.separators.filter((x) => x !== "-").join("|")})`);
677
+ }
678
+ const match = input.match(PseudoClassFunctionsRE) || input.match(PseudoClassColonFunctionsRE) || input.match(PseudoClassVarFunctionRE);
679
+ if (match) {
680
+ const fn = match[1];
681
+ const fnVal = getBracket(match[2], "[", "]");
682
+ const pseudo = fnVal ? h.bracket(match[2]) : PseudoClasses[match[2]] || PseudoClassesColon[match[2]] || `:${match[2]}`;
683
+ return {
684
+ matcher: input.slice(match[0].length),
685
+ selector: (s) => `${s}:${fn}(${pseudo})`
686
+ };
687
+ }
688
+ },
689
+ multiPass: true,
690
+ autocomplete: `(${PseudoClassFunctionsStr})-(${PseudoClassesStr}|${PseudoClassesColonStr}):`
691
+ };
692
+ }
693
+ function variantTaggedPseudoClasses(options = {}) {
694
+ const attributify = !!options?.attributifyPseudo;
695
+ let firstPrefix = options?.prefix ?? "";
696
+ firstPrefix = (Array.isArray(firstPrefix) ? firstPrefix : [firstPrefix]).filter(Boolean)[0] ?? "";
697
+ const tagWithPrefix = (tag, combinator) => taggedPseudoClassMatcher(tag, attributify ? `[${firstPrefix}${tag}=""]` : `.${firstPrefix}${tag}`, combinator);
698
+ return [
699
+ tagWithPrefix("group", " "),
700
+ tagWithPrefix("peer", "~"),
701
+ tagWithPrefix("parent", ">"),
702
+ tagWithPrefix("previous", "+")
703
+ ];
704
+ }
705
+ const PartClassesRE = /(part-\[(.+)]:)(.+)/;
706
+ const variantPartClasses = {
707
+ match(input) {
708
+ const match = input.match(PartClassesRE);
709
+ if (match) {
710
+ const part = `part(${match[2]})`;
711
+ return {
712
+ matcher: input.slice(match[1].length),
713
+ selector: (s) => `${s}::${part}`
714
+ };
715
+ }
716
+ },
717
+ multiPass: true
718
+ };
719
+
720
+ function variants(options) {
721
+ return [
722
+ variantAria,
723
+ variantDataAttribute,
724
+ variantCssLayer,
725
+ variantSelector,
726
+ variantInternalLayer,
727
+ variantNegative,
728
+ variantImportant(),
729
+ variantSupports,
730
+ variantPrint,
731
+ variantCustomMedia,
732
+ variantBreakpoints(),
733
+ ...variantCombinators,
734
+ variantPseudoClassesAndElements(),
735
+ variantPseudoClassFunctions(),
736
+ ...variantTaggedPseudoClasses(options),
737
+ variantPartClasses,
738
+ ...variantColorsMediaOrClass(options),
739
+ ...variantLanguageDirections,
740
+ variantScope,
741
+ variantContainerQuery,
742
+ variantVariables,
743
+ ...variantTaggedDataAttributes
744
+ ];
745
+ }
746
+
747
+ export { variantBreakpoints as a, variantCombinators as b, calcMaxWidthBySize as c, variantContainerQuery as d, variantColorsMediaOrClass as e, variantDataAttribute as f, variantTaggedDataAttributes as g, variants as h, variantLanguageDirections as i, variantImportant as j, variantPrint as k, variantCustomMedia as l, variantSelector as m, variantCssLayer as n, variantInternalLayer as o, variantScope as p, variantVariables as q, variantNegative as r, variantPseudoClassesAndElements as s, variantPseudoClassFunctions as t, variantTaggedPseudoClasses as u, variantAria as v, variantPartClasses as w, variantSupports as x };