@unocss/preset-mini 66.6.6 → 66.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rules.mjs CHANGED
@@ -1,3 +1,1675 @@
1
- import { $ as flex, A as fontStyles, B as alignments, C as contains, D as displays, E as cursors, F as textWraps, G as justifies, H as flexGridJustifiesAlignments, I as userSelects, J as positions, K as orders, L as varEmpty, M as resizes, N as textOverflows, O as fieldSizing, P as textTransforms, Q as gaps, R as whitespaces, S as breaks, T as contents, U as floats, V as boxSizing, W as insets, X as overflows, Y as zIndexes, Z as grids, _ as boxShadows, a as tabSizes, at as borderStyles, b as rings, c as textStrokes, ct as appearance, d as transforms, dt as textAligns, et as textDecorations, f as svgUtilities, ft as verticalAligns, g as sizes, h as aspectRatio, i as fonts, it as opacity, j as pointerEvents, k as fontSmoothings, l as transitions, lt as outline, m as paddings, n as cssProperty, nt as bgColors, o as textIndents, ot as borders, p as margins, q as placements, r as cssVariables, rt as colorScheme, s as textShadows, st as handlerBorderStyle, t as rules, tt as containerParent, u as transformBase, ut as willChange, v as boxShadowsBase, w as contentVisibility, x as appearances, y as ringBase, z as questionMark } from "./rules-DIZf3KzB.mjs";
2
-
3
- export { alignments, appearance, appearances, aspectRatio, bgColors, borderStyles, borders, boxShadows, boxShadowsBase, boxSizing, breaks, colorScheme, containerParent, contains, contentVisibility, contents, cssProperty, cssVariables, cursors, displays, fieldSizing, flex, flexGridJustifiesAlignments, floats, fontSmoothings, fontStyles, fonts, gaps, grids, handlerBorderStyle, insets, justifies, margins, opacity, orders, outline, overflows, paddings, placements, pointerEvents, positions, questionMark, resizes, ringBase, rings, rules, sizes, svgUtilities, tabSizes, textAligns, textDecorations, textIndents, textOverflows, textShadows, textStrokes, textTransforms, textWraps, transformBase, transforms, transitions, userSelects, varEmpty, verticalAligns, whitespaces, willChange, zIndexes };
1
+ import { C as globalKeywords, S as directionMap, T as positionMap, a as colorableShadows, c as isCSSMathFn, d as parseColor, f as resolveBreakpoints, g as h, h as transformXYZ, i as colorResolver, l as isSize, m as splitShorthand, o as directionSize, s as hasParseableColor, u as makeGlobalStaticRules, w as insetMap, y as cornerMap } from "./utils-BtCNpQqm.mjs";
2
+ import { toArray } from "@unocss/core";
3
+ import { colorOpacityToString, colorToString } from "@unocss/rule-utils";
4
+ //#region src/_rules/align.ts
5
+ const verticalAlignAlias = {
6
+ "mid": "middle",
7
+ "base": "baseline",
8
+ "btm": "bottom",
9
+ "baseline": "baseline",
10
+ "top": "top",
11
+ "start": "top",
12
+ "middle": "middle",
13
+ "bottom": "bottom",
14
+ "end": "bottom",
15
+ "text-top": "text-top",
16
+ "text-bottom": "text-bottom",
17
+ "sub": "sub",
18
+ "super": "super",
19
+ ...Object.fromEntries(globalKeywords.map((x) => [x, x]))
20
+ };
21
+ const verticalAligns = [[
22
+ /^(?:vertical|align|v)-(.+)$/,
23
+ ([, v]) => ({ "vertical-align": verticalAlignAlias[v] ?? h.bracket.cssvar.numberWithUnit(v) }),
24
+ { autocomplete: [`(vertical|align|v)-(${Object.keys(verticalAlignAlias).join("|")})`, "(vertical|align|v)-<percentage>"] }
25
+ ]];
26
+ const textAlignValues = [
27
+ "center",
28
+ "left",
29
+ "right",
30
+ "justify",
31
+ "start",
32
+ "end"
33
+ ];
34
+ const textAligns = [...textAlignValues.map((v) => [`text-${v}`, { "text-align": v }]), ...[...globalKeywords, ...textAlignValues].map((v) => [`text-align-${v}`, { "text-align": v }])];
35
+ //#endregion
36
+ //#region src/_rules/behaviors.ts
37
+ const outline = [
38
+ [
39
+ /^outline-(?:width-|size-)?(.+)$/,
40
+ handleWidth$3,
41
+ { autocomplete: "outline-(width|size)-<num>" }
42
+ ],
43
+ [
44
+ /^outline-(?:color-)?(.+)$/,
45
+ handleColorOrWidth$3,
46
+ { autocomplete: "outline-$colors" }
47
+ ],
48
+ [
49
+ /^outline-offset-(.+)$/,
50
+ ([, d], { theme }) => ({ "outline-offset": theme.lineWidth?.[d] ?? h.bracket.cssvar.global.px(d) }),
51
+ { autocomplete: "outline-(offset)-<num>" }
52
+ ],
53
+ ["outline", { "outline-style": "solid" }],
54
+ ...[
55
+ "auto",
56
+ "dashed",
57
+ "dotted",
58
+ "double",
59
+ "hidden",
60
+ "solid",
61
+ "groove",
62
+ "ridge",
63
+ "inset",
64
+ "outset",
65
+ ...globalKeywords
66
+ ].map((v) => [`outline-${v}`, { "outline-style": v }]),
67
+ ["outline-none", {
68
+ "outline": "2px solid transparent",
69
+ "outline-offset": "2px"
70
+ }]
71
+ ];
72
+ function handleWidth$3([, b], { theme }) {
73
+ return { "outline-width": theme.lineWidth?.[b] ?? h.bracket.cssvar.global.px(b) };
74
+ }
75
+ function handleColorOrWidth$3(match, ctx) {
76
+ if (isCSSMathFn(h.bracket(match[1]))) return handleWidth$3(match, ctx);
77
+ return colorResolver("outline-color", "outline-color", "borderColor")(match, ctx);
78
+ }
79
+ const appearance = [["appearance-auto", {
80
+ "-webkit-appearance": "auto",
81
+ "appearance": "auto"
82
+ }], ["appearance-none", {
83
+ "-webkit-appearance": "none",
84
+ "appearance": "none"
85
+ }]];
86
+ function willChangeProperty(prop) {
87
+ return h.properties.auto.global(prop) ?? {
88
+ contents: "contents",
89
+ scroll: "scroll-position"
90
+ }[prop];
91
+ }
92
+ const willChange = [[/^will-change-(.+)/, ([, p]) => ({ "will-change": willChangeProperty(p) })]];
93
+ //#endregion
94
+ //#region src/_rules/border.ts
95
+ const borderStyles = [
96
+ "solid",
97
+ "dashed",
98
+ "dotted",
99
+ "double",
100
+ "hidden",
101
+ "none",
102
+ "groove",
103
+ "ridge",
104
+ "inset",
105
+ "outset",
106
+ ...globalKeywords
107
+ ];
108
+ const borders = [
109
+ [
110
+ /^(?:border|b)()(?:-(.+))?$/,
111
+ handlerBorderSize,
112
+ { autocomplete: "(border|b)-<directions>" }
113
+ ],
114
+ [/^(?:border|b)-([xy])(?:-(.+))?$/, handlerBorderSize],
115
+ [/^(?:border|b)-([rltbse])(?:-(.+))?$/, handlerBorderSize],
116
+ [/^(?:border|b)-(block|inline)(?:-(.+))?$/, handlerBorderSize],
117
+ [/^(?:border|b)-([bi][se])(?:-(.+))?$/, handlerBorderSize],
118
+ [
119
+ /^(?:border|b)-()(?:width|size)-(.+)$/,
120
+ handlerBorderSize,
121
+ { autocomplete: ["(border|b)-<num>", "(border|b)-<directions>-<num>"] }
122
+ ],
123
+ [/^(?:border|b)-([xy])-(?:width|size)-(.+)$/, handlerBorderSize],
124
+ [/^(?:border|b)-([rltbse])-(?:width|size)-(.+)$/, handlerBorderSize],
125
+ [/^(?:border|b)-(block|inline)-(?:width|size)-(.+)$/, handlerBorderSize],
126
+ [/^(?:border|b)-([bi][se])-(?:width|size)-(.+)$/, handlerBorderSize],
127
+ [
128
+ /^(?:border|b)-()(?:color-)?(.+)$/,
129
+ handlerBorderColorOrSize,
130
+ { autocomplete: ["(border|b)-$colors", "(border|b)-<directions>-$colors"] }
131
+ ],
132
+ [/^(?:border|b)-([xy])-(?:color-)?(.+)$/, handlerBorderColorOrSize],
133
+ [/^(?:border|b)-([rltbse])-(?:color-)?(.+)$/, handlerBorderColorOrSize],
134
+ [/^(?:border|b)-(block|inline)-(?:color-)?(.+)$/, handlerBorderColorOrSize],
135
+ [/^(?:border|b)-([bi][se])-(?:color-)?(.+)$/, handlerBorderColorOrSize],
136
+ [
137
+ /^(?:border|b)-()op(?:acity)?-?(.+)$/,
138
+ handlerBorderOpacity,
139
+ { autocomplete: "(border|b)-(op|opacity)-<percent>" }
140
+ ],
141
+ [/^(?:border|b)-([xy])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
142
+ [/^(?:border|b)-([rltbse])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
143
+ [/^(?:border|b)-(block|inline)-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
144
+ [/^(?:border|b)-([bi][se])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
145
+ [
146
+ /^(?:border-|b-)?(?:rounded|rd)()(?:-(.+))?$/,
147
+ handlerRounded,
148
+ { autocomplete: [
149
+ "(border|b)-(rounded|rd)",
150
+ "(border|b)-(rounded|rd)-$borderRadius",
151
+ "(rounded|rd)",
152
+ "(rounded|rd)-$borderRadius"
153
+ ] }
154
+ ],
155
+ [/^(?:border-|b-)?(?:rounded|rd)-([rltbse])(?:-(.+))?$/, handlerRounded],
156
+ [/^(?:border-|b-)?(?:rounded|rd)-([rltb]{2})(?:-(.+))?$/, handlerRounded],
157
+ [/^(?:border-|b-)?(?:rounded|rd)-([bise][se])(?:-(.+))?$/, handlerRounded],
158
+ [/^(?:border-|b-)?(?:rounded|rd)-([bi][se]-[bi][se])(?:-(.+))?$/, handlerRounded],
159
+ [
160
+ /^(?:border|b)-(?:style-)?()(.+)$/,
161
+ handlerBorderStyle,
162
+ { autocomplete: [
163
+ "(border|b)-style",
164
+ `(border|b)-(${borderStyles.join("|")})`,
165
+ "(border|b)-<directions>-style",
166
+ `(border|b)-<directions>-(${borderStyles.join("|")})`,
167
+ `(border|b)-<directions>-style-(${borderStyles.join("|")})`,
168
+ `(border|b)-style-(${borderStyles.join("|")})`
169
+ ] }
170
+ ],
171
+ [/^(?:border|b)-([xy])-(?:style-)?(.+)$/, handlerBorderStyle],
172
+ [/^(?:border|b)-([rltbse])-(?:style-)?(.+)$/, handlerBorderStyle],
173
+ [/^(?:border|b)-(block|inline)-(?:style-)?(.+)$/, handlerBorderStyle],
174
+ [/^(?:border|b)-([bi][se])-(?:style-)?(.+)$/, handlerBorderStyle]
175
+ ];
176
+ function transformBorderColor(color, alpha, direction) {
177
+ if (alpha != null) return { [`border${direction}-color`]: colorToString(color, alpha) };
178
+ if (direction === "") {
179
+ const object = {};
180
+ const opacityVar = `--un-border-opacity`;
181
+ const result = colorToString(color, `var(${opacityVar})`);
182
+ if (result.includes(opacityVar)) object[opacityVar] = typeof color === "string" ? 1 : colorOpacityToString(color);
183
+ object["border-color"] = result;
184
+ return object;
185
+ } else {
186
+ const object = {};
187
+ const opacityVar = "--un-border-opacity";
188
+ const opacityDirectionVar = `--un-border${direction}-opacity`;
189
+ const result = colorToString(color, `var(${opacityDirectionVar})`);
190
+ if (result.includes(opacityDirectionVar)) {
191
+ object[opacityVar] = typeof color === "string" ? 1 : colorOpacityToString(color);
192
+ object[opacityDirectionVar] = `var(${opacityVar})`;
193
+ }
194
+ object[`border${direction}-color`] = result;
195
+ return object;
196
+ }
197
+ }
198
+ function borderColorResolver(direction) {
199
+ return ([, body], theme) => {
200
+ const data = parseColor(body, theme, "borderColor");
201
+ if (!data) return;
202
+ const { alpha, color, cssColor } = data;
203
+ if (cssColor) return transformBorderColor(cssColor, alpha, direction);
204
+ else if (color) return transformBorderColor(color, alpha, direction);
205
+ };
206
+ }
207
+ function handlerBorderSize([, a = "", b], { theme }) {
208
+ const v = theme.lineWidth?.[b || "DEFAULT"] ?? h.bracket.cssvar.global.px(b || "1");
209
+ if (a in directionMap && v != null) return directionMap[a].map((i) => [`border${i}-width`, v]);
210
+ }
211
+ function handlerBorderColorOrSize([, a = "", b], ctx) {
212
+ if (a in directionMap) {
213
+ if (isCSSMathFn(h.bracket(b))) return handlerBorderSize([
214
+ "",
215
+ a,
216
+ b
217
+ ], ctx);
218
+ if (hasParseableColor(b, ctx.theme, "borderColor")) return Object.assign({}, ...directionMap[a].map((i) => borderColorResolver(i)(["", b], ctx.theme)));
219
+ }
220
+ }
221
+ function handlerBorderOpacity([, a = "", opacity]) {
222
+ const v = h.bracket.percent.cssvar(opacity);
223
+ if (a in directionMap && v != null) return directionMap[a].map((i) => [`--un-border${i}-opacity`, v]);
224
+ }
225
+ function handlerRounded([, a = "", s], { theme }) {
226
+ const v = theme.borderRadius?.[s || "DEFAULT"] || h.bracket.cssvar.global.fraction.rem(s || "1");
227
+ if (a in cornerMap && v != null) return cornerMap[a].map((i) => [`border${i}-radius`, v]);
228
+ }
229
+ function handlerBorderStyle([, a = "", s]) {
230
+ if (borderStyles.includes(s) && a in directionMap) return directionMap[a].map((i) => [`border${i}-style`, s]);
231
+ }
232
+ //#endregion
233
+ //#region src/_rules/color.ts
234
+ /**
235
+ * @example op10 op-30 opacity-100
236
+ */
237
+ const opacity = [[/^op(?:acity)?-?(.+)$/, ([, d]) => ({ opacity: h.bracket.percent.cssvar(d) })]];
238
+ const bgUrlRE = /^\[url\(.+\)\]$/;
239
+ const bgLengthRE = /^\[(?:length|size):.+\]$/;
240
+ const bgPositionRE = /^\[position:.+\]$/;
241
+ const bgGradientRE = /^\[(?:linear|conic|radial)-gradient\(.+\)\]$/;
242
+ const bgImageRE = /^\[image:.+\]$/;
243
+ const bgColors = [[
244
+ /^bg-(.+)$/,
245
+ (...args) => {
246
+ const d = args[0][1];
247
+ if (bgUrlRE.test(d)) return {
248
+ "--un-url": h.bracket(d),
249
+ "background-image": "var(--un-url)"
250
+ };
251
+ if (bgLengthRE.test(d) && h.bracketOfLength(d) != null) return { "background-size": h.bracketOfLength(d).split(" ").map((e) => h.fraction.auto.px.cssvar(e) ?? e).join(" ") };
252
+ if ((isSize(d) || bgPositionRE.test(d)) && h.bracketOfPosition(d) != null) return { "background-position": h.bracketOfPosition(d).split(" ").map((e) => h.position.fraction.auto.px.cssvar(e) ?? e).join(" ") };
253
+ if (bgGradientRE.test(d) || bgImageRE.test(d)) {
254
+ const s = h.bracket(d);
255
+ if (s) {
256
+ const url = s.startsWith("http") ? `url(${s})` : h.cssvar(s);
257
+ return { "background-image": url ?? s };
258
+ }
259
+ }
260
+ return colorResolver("background-color", "bg", "backgroundColor")(...args);
261
+ },
262
+ { autocomplete: "bg-$colors" }
263
+ ], [
264
+ /^bg-op(?:acity)?-?(.+)$/,
265
+ ([, opacity]) => ({ "--un-bg-opacity": h.bracket.percent.cssvar(opacity) }),
266
+ { autocomplete: "bg-(op|opacity)-<percent>" }
267
+ ]];
268
+ const colorScheme = [[/^color-scheme-(\w+)$/, ([, v]) => ({ "color-scheme": v })]];
269
+ //#endregion
270
+ //#region src/_rules/container.ts
271
+ const containerParent = [[/^@container(?:\/(\w+))?(?:-(normal|inline-size|size))?$/, ([, l, v]) => {
272
+ return {
273
+ "container-type": v ?? "inline-size",
274
+ "container-name": l
275
+ };
276
+ }]];
277
+ //#endregion
278
+ //#region src/_rules/decoration.ts
279
+ const decorationStyles = [
280
+ "solid",
281
+ "double",
282
+ "dotted",
283
+ "dashed",
284
+ "wavy",
285
+ ...globalKeywords
286
+ ];
287
+ const textDecorations = [
288
+ [
289
+ /^(?:decoration-)?(underline|overline|line-through)$/,
290
+ ([, s]) => ({ "text-decoration-line": s }),
291
+ { autocomplete: "decoration-(underline|overline|line-through)" }
292
+ ],
293
+ [
294
+ /^(?:underline|decoration)-(?:size-)?(.+)$/,
295
+ handleWidth$2,
296
+ { autocomplete: "(underline|decoration)-<num>" }
297
+ ],
298
+ [
299
+ /^(?:underline|decoration)-(auto|from-font)$/,
300
+ ([, s]) => ({ "text-decoration-thickness": s }),
301
+ { autocomplete: "(underline|decoration)-(auto|from-font)" }
302
+ ],
303
+ [
304
+ /^(?:underline|decoration)-(.+)$/,
305
+ handleColorOrWidth$2,
306
+ { autocomplete: "(underline|decoration)-$colors" }
307
+ ],
308
+ [
309
+ /^(?:underline|decoration)-op(?:acity)?-?(.+)$/,
310
+ ([, opacity]) => ({ "--un-line-opacity": h.bracket.percent.cssvar(opacity) }),
311
+ { autocomplete: "(underline|decoration)-(op|opacity)-<percent>" }
312
+ ],
313
+ [
314
+ /^(?:underline|decoration)-offset-(.+)$/,
315
+ ([, s], { theme }) => ({ "text-underline-offset": theme.lineWidth?.[s] ?? h.auto.bracket.cssvar.global.px(s) }),
316
+ { autocomplete: "(underline|decoration)-(offset)-<num>" }
317
+ ],
318
+ ...decorationStyles.map((v) => [`underline-${v}`, { "text-decoration-style": v }]),
319
+ ...decorationStyles.map((v) => [`decoration-${v}`, { "text-decoration-style": v }]),
320
+ ["no-underline", { "text-decoration": "none" }],
321
+ ["decoration-none", { "text-decoration": "none" }]
322
+ ];
323
+ function handleWidth$2([, b], { theme }) {
324
+ return { "text-decoration-thickness": theme.lineWidth?.[b] ?? h.bracket.cssvar.global.px(b) };
325
+ }
326
+ function handleColorOrWidth$2(match, ctx) {
327
+ if (isCSSMathFn(h.bracket(match[1]))) return handleWidth$2(match, ctx);
328
+ const result = colorResolver("text-decoration-color", "line", "borderColor")(match, ctx);
329
+ if (result) return {
330
+ "-webkit-text-decoration-color": result["text-decoration-color"],
331
+ ...result
332
+ };
333
+ }
334
+ //#endregion
335
+ //#region src/_rules/flex.ts
336
+ const flex = [
337
+ ["flex", { display: "flex" }],
338
+ ["inline-flex", { display: "inline-flex" }],
339
+ ["flex-inline", { display: "inline-flex" }],
340
+ [/^flex-(.*)$/, ([, d]) => ({ flex: h.bracket(d) != null ? h.bracket(d).split(" ").map((e) => h.cssvar.fraction(e) ?? e).join(" ") : h.cssvar.fraction(d) })],
341
+ ["flex-1", { flex: "1 1 0%" }],
342
+ ["flex-auto", { flex: "1 1 auto" }],
343
+ ["flex-initial", { flex: "0 1 auto" }],
344
+ ["flex-none", { flex: "none" }],
345
+ [
346
+ /^(?:flex-)?shrink(?:-(.*))?$/,
347
+ ([, d = ""]) => ({ "flex-shrink": h.bracket.cssvar.number(d) ?? 1 }),
348
+ { autocomplete: ["flex-shrink-<num>", "shrink-<num>"] }
349
+ ],
350
+ [
351
+ /^(?:flex-)?grow(?:-(.*))?$/,
352
+ ([, d = ""]) => ({ "flex-grow": h.bracket.cssvar.number(d) ?? 1 }),
353
+ { autocomplete: ["flex-grow-<num>", "grow-<num>"] }
354
+ ],
355
+ [
356
+ /^(?:flex-)?basis-(.+)$/,
357
+ ([, d], { theme }) => ({ "flex-basis": theme.spacing?.[d] ?? h.bracket.cssvar.auto.fraction.rem(d) }),
358
+ { autocomplete: ["flex-basis-$spacing", "basis-$spacing"] }
359
+ ],
360
+ ["flex-row", { "flex-direction": "row" }],
361
+ ["flex-row-reverse", { "flex-direction": "row-reverse" }],
362
+ ["flex-col", { "flex-direction": "column" }],
363
+ ["flex-col-reverse", { "flex-direction": "column-reverse" }],
364
+ ["flex-wrap", { "flex-wrap": "wrap" }],
365
+ ["flex-wrap-reverse", { "flex-wrap": "wrap-reverse" }],
366
+ ["flex-nowrap", { "flex-wrap": "nowrap" }]
367
+ ];
368
+ //#endregion
369
+ //#region src/_rules/gap.ts
370
+ const directions = {
371
+ "": "",
372
+ "x": "column-",
373
+ "y": "row-",
374
+ "col": "column-",
375
+ "row": "row-"
376
+ };
377
+ function handleGap([, d = "", s], { theme }) {
378
+ const v = theme.spacing?.[s] ?? h.bracket.cssvar.global.rem(s);
379
+ if (v != null) return { [`${directions[d]}gap`]: v };
380
+ }
381
+ const gaps = [
382
+ [
383
+ /^(?:flex-|grid-)?gap-?()(.+)$/,
384
+ handleGap,
385
+ { autocomplete: ["gap-$spacing", "gap-<num>"] }
386
+ ],
387
+ [
388
+ /^(?:flex-|grid-)?gap-([xy])-?(.+)$/,
389
+ handleGap,
390
+ { autocomplete: ["gap-(x|y)-$spacing", "gap-(x|y)-<num>"] }
391
+ ],
392
+ [
393
+ /^(?:flex-|grid-)?gap-(col|row)-?(.+)$/,
394
+ handleGap,
395
+ { autocomplete: ["gap-(col|row)-$spacing", "gap-(col|row)-<num>"] }
396
+ ]
397
+ ];
398
+ //#endregion
399
+ //#region src/_rules/grid.ts
400
+ function rowCol(s) {
401
+ return s.replace("col", "column");
402
+ }
403
+ function rowColTheme(s) {
404
+ return s[0] === "r" ? "Row" : "Column";
405
+ }
406
+ function autoDirection(c, theme, prop) {
407
+ const v = theme[`gridAuto${rowColTheme(c)}`]?.[prop];
408
+ if (v != null) return v;
409
+ switch (prop) {
410
+ case "min": return "min-content";
411
+ case "max": return "max-content";
412
+ case "fr": return "minmax(0,1fr)";
413
+ }
414
+ return h.bracket.cssvar.auto.rem(prop);
415
+ }
416
+ const grids = [
417
+ ["grid", { display: "grid" }],
418
+ ["inline-grid", { display: "inline-grid" }],
419
+ [/^(?:grid-)?(row|col)-(.+)$/, ([, c, v], { theme }) => ({ [`grid-${rowCol(c)}`]: theme[`grid${rowColTheme(c)}`]?.[v] ?? h.bracket.cssvar.auto(v) })],
420
+ [
421
+ /^(?:grid-)?(row|col)-span-(.+)$/,
422
+ ([, c, s]) => {
423
+ if (s === "full") return { [`grid-${rowCol(c)}`]: "1/-1" };
424
+ const v = h.bracket.number(s);
425
+ if (v != null) return { [`grid-${rowCol(c)}`]: `span ${v}/span ${v}` };
426
+ },
427
+ { autocomplete: "(grid-row|grid-col|row|col)-span-<num>" }
428
+ ],
429
+ [/^(?:grid-)?(row|col)-start-(.+)$/, ([, c, v]) => ({ [`grid-${rowCol(c)}-start`]: h.bracket.cssvar(v) ?? v })],
430
+ [
431
+ /^(?:grid-)?(row|col)-end-(.+)$/,
432
+ ([, c, v]) => ({ [`grid-${rowCol(c)}-end`]: h.bracket.cssvar(v) ?? v }),
433
+ { autocomplete: "(grid-row|grid-col|row|col)-(start|end)-<num>" }
434
+ ],
435
+ [
436
+ /^(?:grid-)?auto-(rows|cols)-(.+)$/,
437
+ ([, c, v], { theme }) => ({ [`grid-auto-${rowCol(c)}`]: autoDirection(c, theme, v) }),
438
+ { autocomplete: "(grid-auto|auto)-(rows|cols)-<num>" }
439
+ ],
440
+ [/^(?:grid-auto-flow|auto-flow|grid-flow)-(.+)$/, ([, v]) => ({ "grid-auto-flow": h.bracket.cssvar(v) })],
441
+ [
442
+ /^(?:grid-auto-flow|auto-flow|grid-flow)-(row|col|dense|row-dense|col-dense)$/,
443
+ ([, v]) => ({ "grid-auto-flow": rowCol(v).replace("-", " ") }),
444
+ { autocomplete: ["(grid-auto-flow|auto-flow|grid-flow)-(row|col|dense|row-dense|col-dense)"] }
445
+ ],
446
+ [/^(?:grid-)?(rows|cols)-(.+)$/, ([, c, v], { theme }) => ({ [`grid-template-${rowCol(c)}`]: theme[`gridTemplate${rowColTheme(c)}`]?.[v] ?? h.bracket.cssvar(v) })],
447
+ [/^(?:grid-)?(rows|cols)-minmax-([\w.-]+)$/, ([, c, d]) => ({ [`grid-template-${rowCol(c)}`]: `repeat(auto-fill,minmax(${d},1fr))` })],
448
+ [
449
+ /^(?:grid-)?(rows|cols)-(\d+)$/,
450
+ ([, c, d]) => ({ [`grid-template-${rowCol(c)}`]: `repeat(${d},minmax(0,1fr))` }),
451
+ { autocomplete: "(grid-rows|grid-cols|rows|cols)-<num>" }
452
+ ],
453
+ [/^grid-area(s)?-(.+)$/, ([, s, v]) => {
454
+ if (s != null) return { "grid-template-areas": h.cssvar(v) ?? v.split("-").map((s) => `"${h.bracket(s)}"`).join(" ") };
455
+ return { "grid-area": h.bracket.cssvar(v) };
456
+ }],
457
+ ["grid-rows-none", { "grid-template-rows": "none" }],
458
+ ["grid-cols-none", { "grid-template-columns": "none" }],
459
+ ["grid-rows-subgrid", { "grid-template-rows": "subgrid" }],
460
+ ["grid-cols-subgrid", { "grid-template-columns": "subgrid" }]
461
+ ];
462
+ //#endregion
463
+ //#region src/_rules/layout.ts
464
+ const overflowValues = [
465
+ "auto",
466
+ "hidden",
467
+ "clip",
468
+ "visible",
469
+ "scroll",
470
+ "overlay",
471
+ ...globalKeywords
472
+ ];
473
+ const overflows = [[
474
+ /^(?:overflow|of)-(.+)$/,
475
+ ([, v]) => overflowValues.includes(v) ? { overflow: v } : void 0,
476
+ { autocomplete: [`(overflow|of)-(${overflowValues.join("|")})`, `(overflow|of)-(x|y)-(${overflowValues.join("|")})`] }
477
+ ], [/^(?:overflow|of)-([xy])-(.+)$/, ([, d, v]) => overflowValues.includes(v) ? { [`overflow-${d}`]: v } : void 0]];
478
+ //#endregion
479
+ //#region src/_rules/position.ts
480
+ const positions = [
481
+ [
482
+ /^(?:position-|pos-)?(relative|absolute|fixed|sticky)$/,
483
+ ([, v]) => ({ position: v }),
484
+ { autocomplete: [
485
+ "(position|pos)-<position>",
486
+ "(position|pos)-<globalKeyword>",
487
+ "<position>"
488
+ ] }
489
+ ],
490
+ [/^(?:position-|pos-)([-\w]+)$/, ([, v]) => globalKeywords.includes(v) ? { position: v } : void 0],
491
+ [/^(?:position-|pos-)?(static)$/, ([, v]) => ({ position: v })]
492
+ ];
493
+ const justifies = [
494
+ ["justify-start", { "justify-content": "flex-start" }],
495
+ ["justify-end", { "justify-content": "flex-end" }],
496
+ ["justify-center", { "justify-content": "center" }],
497
+ ["justify-between", { "justify-content": "space-between" }],
498
+ ["justify-around", { "justify-content": "space-around" }],
499
+ ["justify-evenly", { "justify-content": "space-evenly" }],
500
+ ["justify-stretch", { "justify-content": "stretch" }],
501
+ ["justify-left", { "justify-content": "left" }],
502
+ ["justify-right", { "justify-content": "right" }],
503
+ ["justify-center-safe", { "justify-content": "safe center" }],
504
+ ["justify-end-safe", { "justify-content": "safe flex-end" }],
505
+ ["justify-normal", { "justify-content": "normal" }],
506
+ ...makeGlobalStaticRules("justify", "justify-content"),
507
+ ["justify-items-start", { "justify-items": "start" }],
508
+ ["justify-items-end", { "justify-items": "end" }],
509
+ ["justify-items-center", { "justify-items": "center" }],
510
+ ["justify-items-stretch", { "justify-items": "stretch" }],
511
+ ["justify-items-center-safe", { "justify-items": "safe center" }],
512
+ ["justify-items-end-safe", { "justify-items": "safe flex-end" }],
513
+ ...makeGlobalStaticRules("justify-items"),
514
+ ["justify-self-auto", { "justify-self": "auto" }],
515
+ ["justify-self-start", { "justify-self": "start" }],
516
+ ["justify-self-end", { "justify-self": "end" }],
517
+ ["justify-self-center", { "justify-self": "center" }],
518
+ ["justify-self-stretch", { "justify-self": "stretch" }],
519
+ ["justify-self-baseline", { "justify-self": "baseline" }],
520
+ ["justify-self-center-safe", { "justify-self": "safe center" }],
521
+ ["justify-self-end-safe", { "justify-self": "safe flex-end" }],
522
+ ...makeGlobalStaticRules("justify-self")
523
+ ];
524
+ const orders = [
525
+ [/^order-(.+)$/, ([, v]) => ({ order: h.bracket.cssvar.number(v) })],
526
+ ["order-first", { order: "-9999" }],
527
+ ["order-last", { order: "9999" }],
528
+ ["order-none", { order: "0" }]
529
+ ];
530
+ const alignments = [
531
+ ["content-center", { "align-content": "center" }],
532
+ ["content-start", { "align-content": "flex-start" }],
533
+ ["content-end", { "align-content": "flex-end" }],
534
+ ["content-between", { "align-content": "space-between" }],
535
+ ["content-around", { "align-content": "space-around" }],
536
+ ["content-evenly", { "align-content": "space-evenly" }],
537
+ ["content-baseline", { "align-content": "baseline" }],
538
+ ["content-center-safe", { "align-content": "safe center" }],
539
+ ["content-end-safe", { "align-content": "safe flex-end" }],
540
+ ["content-stretch", { "align-content": "stretch" }],
541
+ ["content-normal", { "align-content": "normal" }],
542
+ ...makeGlobalStaticRules("content", "align-content"),
543
+ ["items-start", { "align-items": "flex-start" }],
544
+ ["items-end", { "align-items": "flex-end" }],
545
+ ["items-center", { "align-items": "center" }],
546
+ ["items-baseline", { "align-items": "baseline" }],
547
+ ["items-stretch", { "align-items": "stretch" }],
548
+ ["items-baseline-last", { "align-items": "last baseline" }],
549
+ ["items-center-safe", { "align-items": "safe center" }],
550
+ ["items-end-safe", { "align-items": "safe flex-end" }],
551
+ ...makeGlobalStaticRules("items", "align-items"),
552
+ ["self-auto", { "align-self": "auto" }],
553
+ ["self-start", { "align-self": "flex-start" }],
554
+ ["self-end", { "align-self": "flex-end" }],
555
+ ["self-center", { "align-self": "center" }],
556
+ ["self-stretch", { "align-self": "stretch" }],
557
+ ["self-baseline", { "align-self": "baseline" }],
558
+ ["self-baseline-last", { "align-self": "last baseline" }],
559
+ ["self-center-safe", { "align-self": "safe center" }],
560
+ ["self-end-safe", { "align-self": "safe flex-end" }],
561
+ ...makeGlobalStaticRules("self", "align-self")
562
+ ];
563
+ const placements = [
564
+ ["place-content-center", { "place-content": "center" }],
565
+ ["place-content-start", { "place-content": "start" }],
566
+ ["place-content-end", { "place-content": "end" }],
567
+ ["place-content-between", { "place-content": "space-between" }],
568
+ ["place-content-around", { "place-content": "space-around" }],
569
+ ["place-content-evenly", { "place-content": "space-evenly" }],
570
+ ["place-content-stretch", { "place-content": "stretch" }],
571
+ ["place-content-baseline", { "place-content": "baseline" }],
572
+ ["place-content-center-safe", { "place-content": "safe center" }],
573
+ ["place-content-end-safe", { "place-content": "safe flex-end" }],
574
+ ...makeGlobalStaticRules("place-content"),
575
+ ["place-items-start", { "place-items": "start" }],
576
+ ["place-items-end", { "place-items": "end" }],
577
+ ["place-items-center", { "place-items": "center" }],
578
+ ["place-items-stretch", { "place-items": "stretch" }],
579
+ ["place-items-baseline", { "place-items": "baseline" }],
580
+ ["place-items-center-safe", { "place-items": "safe center" }],
581
+ ["place-items-end-safe", { "place-items": "safe flex-end" }],
582
+ ...makeGlobalStaticRules("place-items"),
583
+ ["place-self-auto", { "place-self": "auto" }],
584
+ ["place-self-start", { "place-self": "start" }],
585
+ ["place-self-end", { "place-self": "end" }],
586
+ ["place-self-center", { "place-self": "center" }],
587
+ ["place-self-stretch", { "place-self": "stretch" }],
588
+ ["place-self-center-safe", { "place-self": "safe center" }],
589
+ ["place-self-end-safe", { "place-self": "safe flex-end" }],
590
+ ...makeGlobalStaticRules("place-self")
591
+ ];
592
+ /**
593
+ * This is to add `flex-` and `grid-` prefix to the alignment rules,
594
+ * supporting `flex="~ items-center"` in attributify mode.
595
+ */
596
+ const flexGridJustifiesAlignments = [
597
+ ...justifies,
598
+ ...alignments,
599
+ ...placements
600
+ ].flatMap(([k, v]) => [[`flex-${k}`, v], [`grid-${k}`, v]]);
601
+ function handleInsetValue(v, { theme }) {
602
+ return theme.spacing?.[v] ?? h.bracket.cssvar.global.auto.fraction.rem(v);
603
+ }
604
+ function handleInsetValues([, d, v], ctx) {
605
+ const r = handleInsetValue(v, ctx);
606
+ if (r != null && d in insetMap) return insetMap[d].map((i) => [i.slice(1), r]);
607
+ }
608
+ const insets = [
609
+ [
610
+ /^(?:position-|pos-)?inset-(.+)$/,
611
+ ([, v], ctx) => ({ inset: handleInsetValue(v, ctx) }),
612
+ { autocomplete: [
613
+ "(position|pos)-inset-<directions>-$spacing",
614
+ "(position|pos)-inset-(block|inline)-$spacing",
615
+ "(position|pos)-inset-(bs|be|is|ie)-$spacing",
616
+ "(position|pos)-(top|left|right|bottom)-$spacing"
617
+ ] }
618
+ ],
619
+ [/^(?:position-|pos-)?(start|end)-(.+)$/, handleInsetValues],
620
+ [/^(?:position-|pos-)?inset-([xy])-(.+)$/, handleInsetValues],
621
+ [/^(?:position-|pos-)?inset-([rltbse])-(.+)$/, handleInsetValues],
622
+ [/^(?:position-|pos-)?inset-(block|inline)-(.+)$/, handleInsetValues],
623
+ [/^(?:position-|pos-)?inset-([bi][se])-(.+)$/, handleInsetValues],
624
+ [/^(?:position-|pos-)?(top|left|right|bottom)-(.+)$/, ([, d, v], ctx) => ({ [d]: handleInsetValue(v, ctx) })]
625
+ ];
626
+ const floats = [
627
+ ["float-left", { float: "left" }],
628
+ ["float-right", { float: "right" }],
629
+ ["float-start", { float: "inline-start" }],
630
+ ["float-end", { float: "inline-end" }],
631
+ ["float-none", { float: "none" }],
632
+ ...makeGlobalStaticRules("float"),
633
+ ["clear-left", { clear: "left" }],
634
+ ["clear-right", { clear: "right" }],
635
+ ["clear-both", { clear: "both" }],
636
+ ["clear-start", { clear: "inline-start" }],
637
+ ["clear-end", { clear: "inline-end" }],
638
+ ["clear-none", { clear: "none" }],
639
+ ...makeGlobalStaticRules("clear")
640
+ ];
641
+ const zIndexes = [[/^(?:position-|pos-)?z([\d.]+)$/, ([, v]) => ({ "z-index": h.number(v) })], [
642
+ /^(?:position-|pos-)?z-(.+)$/,
643
+ ([, v], { theme }) => ({ "z-index": theme.zIndex?.[v] ?? h.bracket.cssvar.global.auto.number(v) }),
644
+ { autocomplete: "z-<num>" }
645
+ ]];
646
+ const boxSizing = [
647
+ ["box-border", { "box-sizing": "border-box" }],
648
+ ["box-content", { "box-sizing": "content-box" }],
649
+ ...makeGlobalStaticRules("box", "box-sizing")
650
+ ];
651
+ //#endregion
652
+ //#region src/_rules/question-mark.ts
653
+ /**
654
+ * Used for debugging, only available in development mode.
655
+ *
656
+ * @example `?` / `where`
657
+ */
658
+ const questionMark = [[/^(where|\?)$/, (_, { constructCSS, generator }) => {
659
+ if (generator.userConfig.envMode === "dev") return `@keyframes __un_qm{0%{box-shadow:inset 4px 4px #ff1e90, inset -4px -4px #ff1e90}100%{box-shadow:inset 8px 8px #3399ff, inset -8px -8px #3399ff}} ${constructCSS({ animation: "__un_qm 0.5s ease-in-out alternate infinite" })}`;
660
+ }]];
661
+ //#endregion
662
+ //#region src/_rules/static.ts
663
+ const cursorValues = [
664
+ "auto",
665
+ "default",
666
+ "none",
667
+ "context-menu",
668
+ "help",
669
+ "pointer",
670
+ "progress",
671
+ "wait",
672
+ "cell",
673
+ "crosshair",
674
+ "text",
675
+ "vertical-text",
676
+ "alias",
677
+ "copy",
678
+ "move",
679
+ "no-drop",
680
+ "not-allowed",
681
+ "grab",
682
+ "grabbing",
683
+ "all-scroll",
684
+ "col-resize",
685
+ "row-resize",
686
+ "n-resize",
687
+ "e-resize",
688
+ "s-resize",
689
+ "w-resize",
690
+ "ne-resize",
691
+ "nw-resize",
692
+ "se-resize",
693
+ "sw-resize",
694
+ "ew-resize",
695
+ "ns-resize",
696
+ "nesw-resize",
697
+ "nwse-resize",
698
+ "zoom-in",
699
+ "zoom-out"
700
+ ];
701
+ const containValues = [
702
+ "none",
703
+ "strict",
704
+ "content",
705
+ "size",
706
+ "inline-size",
707
+ "layout",
708
+ "style",
709
+ "paint"
710
+ ];
711
+ const varEmpty = " ";
712
+ const displays = [
713
+ ["inline", { display: "inline" }],
714
+ ["block", { display: "block" }],
715
+ ["inline-block", { display: "inline-block" }],
716
+ ["contents", { display: "contents" }],
717
+ ["flow-root", { display: "flow-root" }],
718
+ ["list-item", { display: "list-item" }],
719
+ ["hidden", { display: "none" }],
720
+ [/^display-(.+)$/, ([, c]) => ({ display: h.bracket.cssvar.global(c) })]
721
+ ];
722
+ const appearances = [
723
+ ["visible", { visibility: "visible" }],
724
+ ["invisible", { visibility: "hidden" }],
725
+ ["backface-visible", { "backface-visibility": "visible" }],
726
+ ["backface-hidden", { "backface-visibility": "hidden" }],
727
+ ...makeGlobalStaticRules("backface", "backface-visibility")
728
+ ];
729
+ const cursors = [[/^cursor-(.+)$/, ([, c]) => ({ cursor: h.bracket.cssvar.global(c) })], ...cursorValues.map((v) => [`cursor-${v}`, { cursor: v }])];
730
+ const contains = [[/^contain-(.*)$/, ([, d]) => {
731
+ if (h.bracket(d) != null) return { contain: h.bracket(d).split(" ").map((e) => h.cssvar.fraction(e) ?? e).join(" ") };
732
+ return containValues.includes(d) ? { contain: d } : void 0;
733
+ }]];
734
+ const pointerEvents = [
735
+ ["pointer-events-auto", { "pointer-events": "auto" }],
736
+ ["pointer-events-none", { "pointer-events": "none" }],
737
+ ...makeGlobalStaticRules("pointer-events")
738
+ ];
739
+ const resizes = [
740
+ ["resize-x", { resize: "horizontal" }],
741
+ ["resize-y", { resize: "vertical" }],
742
+ ["resize", { resize: "both" }],
743
+ ["resize-none", { resize: "none" }],
744
+ ...makeGlobalStaticRules("resize")
745
+ ];
746
+ const userSelects = [
747
+ ["select-auto", {
748
+ "-webkit-user-select": "auto",
749
+ "user-select": "auto"
750
+ }],
751
+ ["select-all", {
752
+ "-webkit-user-select": "all",
753
+ "user-select": "all"
754
+ }],
755
+ ["select-text", {
756
+ "-webkit-user-select": "text",
757
+ "user-select": "text"
758
+ }],
759
+ ["select-none", {
760
+ "-webkit-user-select": "none",
761
+ "user-select": "none"
762
+ }],
763
+ ...makeGlobalStaticRules("select", "user-select")
764
+ ];
765
+ const whitespaces = [[
766
+ /^(?:whitespace-|ws-)([-\w]+)$/,
767
+ ([, v]) => [
768
+ "normal",
769
+ "nowrap",
770
+ "pre",
771
+ "pre-line",
772
+ "pre-wrap",
773
+ "break-spaces",
774
+ ...globalKeywords
775
+ ].includes(v) ? { "white-space": v } : void 0,
776
+ { autocomplete: "(whitespace|ws)-(normal|nowrap|pre|pre-line|pre-wrap|break-spaces)" }
777
+ ]];
778
+ const contentVisibility = [
779
+ [
780
+ /^intrinsic(?:-(block|inline|w|h))?(?:-size)?-(.+)$/,
781
+ ([, d, s]) => {
782
+ return { [`contain-intrinsic-${{
783
+ block: "block-size",
784
+ inline: "inline-size",
785
+ w: "width",
786
+ h: "height"
787
+ }[d] ?? "size"}`]: h.bracket.cssvar.global.fraction.rem(s) };
788
+ },
789
+ { autocomplete: [
790
+ "intrinsic-size-<num>",
791
+ "intrinsic-<num>",
792
+ "intrinsic-(block|inline|w|h)-<num>"
793
+ ] }
794
+ ],
795
+ ["content-visibility-visible", { "content-visibility": "visible" }],
796
+ ["content-visibility-hidden", { "content-visibility": "hidden" }],
797
+ ["content-visibility-auto", { "content-visibility": "auto" }],
798
+ ...makeGlobalStaticRules("content-visibility")
799
+ ];
800
+ const contents = [
801
+ [/^content-(.+)$/, ([, v]) => ({ content: h.bracket.cssvar(v) })],
802
+ ["content-empty", { content: "\"\"" }],
803
+ ["content-none", { content: "none" }]
804
+ ];
805
+ const breaks = [
806
+ ["break-normal", {
807
+ "overflow-wrap": "normal",
808
+ "word-break": "normal"
809
+ }],
810
+ ["break-words", { "overflow-wrap": "break-word" }],
811
+ ["break-all", { "word-break": "break-all" }],
812
+ ["break-keep", { "word-break": "keep-all" }],
813
+ ["break-anywhere", { "overflow-wrap": "anywhere" }]
814
+ ];
815
+ const textWraps = [
816
+ ["text-wrap", { "text-wrap": "wrap" }],
817
+ ["text-nowrap", { "text-wrap": "nowrap" }],
818
+ ["text-balance", { "text-wrap": "balance" }],
819
+ ["text-pretty", { "text-wrap": "pretty" }]
820
+ ];
821
+ const textOverflows = [
822
+ ["truncate", {
823
+ "overflow": "hidden",
824
+ "text-overflow": "ellipsis",
825
+ "white-space": "nowrap"
826
+ }],
827
+ ["text-truncate", {
828
+ "overflow": "hidden",
829
+ "text-overflow": "ellipsis",
830
+ "white-space": "nowrap"
831
+ }],
832
+ ["text-ellipsis", { "text-overflow": "ellipsis" }],
833
+ ["text-clip", { "text-overflow": "clip" }]
834
+ ];
835
+ const textTransforms = [
836
+ ["case-upper", { "text-transform": "uppercase" }],
837
+ ["case-lower", { "text-transform": "lowercase" }],
838
+ ["case-capital", { "text-transform": "capitalize" }],
839
+ ["case-normal", { "text-transform": "none" }],
840
+ ...makeGlobalStaticRules("case", "text-transform")
841
+ ];
842
+ const fontStyles = [
843
+ ["italic", { "font-style": "italic" }],
844
+ ["not-italic", { "font-style": "normal" }],
845
+ ["font-italic", { "font-style": "italic" }],
846
+ ["font-not-italic", { "font-style": "normal" }],
847
+ ["oblique", { "font-style": "oblique" }],
848
+ ["not-oblique", { "font-style": "normal" }],
849
+ ["font-oblique", { "font-style": "oblique" }],
850
+ ["font-not-oblique", { "font-style": "normal" }]
851
+ ];
852
+ const fontSmoothings = [["antialiased", {
853
+ "-webkit-font-smoothing": "antialiased",
854
+ "-moz-osx-font-smoothing": "grayscale"
855
+ }], ["subpixel-antialiased", {
856
+ "-webkit-font-smoothing": "auto",
857
+ "-moz-osx-font-smoothing": "auto"
858
+ }]];
859
+ const fieldSizing = [["field-sizing-fixed", { "field-sizing": "fixed" }], ["field-sizing-content", { "field-sizing": "content" }]];
860
+ //#endregion
861
+ //#region src/_rules/ring.ts
862
+ const ringBase = {
863
+ "--un-ring-inset": " ",
864
+ "--un-ring-offset-width": "0px",
865
+ "--un-ring-offset-color": "#fff",
866
+ "--un-ring-width": "0px",
867
+ "--un-ring-color": "rgb(147 197 253 / 0.5)",
868
+ "--un-shadow": "0 0 rgb(0 0 0 / 0)"
869
+ };
870
+ const rings = [
871
+ [
872
+ /^ring(?:-(.+))?$/,
873
+ ([, d], { theme }) => {
874
+ const value = theme.ringWidth?.[d || "DEFAULT"] ?? h.px(d || "1");
875
+ if (value) return {
876
+ "--un-ring-width": value,
877
+ "--un-ring-offset-shadow": "var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color)",
878
+ "--un-ring-shadow": "var(--un-ring-inset) 0 0 0 calc(var(--un-ring-width) + var(--un-ring-offset-width)) var(--un-ring-color)",
879
+ "box-shadow": "var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow)"
880
+ };
881
+ },
882
+ {
883
+ custom: { preflightKeys: Object.keys(ringBase) },
884
+ autocomplete: "ring-$ringWidth"
885
+ }
886
+ ],
887
+ [
888
+ /^ring-(?:width-|size-)(.+)$/,
889
+ handleWidth$1,
890
+ { autocomplete: "ring-(width|size)-$lineWidth" }
891
+ ],
892
+ ["ring-offset", { "--un-ring-offset-width": "1px" }],
893
+ [
894
+ /^ring-offset-(?:width-|size-)?(.+)$/,
895
+ ([, d], { theme }) => ({ "--un-ring-offset-width": theme.lineWidth?.[d] ?? h.bracket.cssvar.px(d) }),
896
+ { autocomplete: "ring-offset-(width|size)-$lineWidth" }
897
+ ],
898
+ [
899
+ /^ring-(.+)$/,
900
+ handleColorOrWidth$1,
901
+ { autocomplete: "ring-$colors" }
902
+ ],
903
+ [
904
+ /^ring-op(?:acity)?-?(.+)$/,
905
+ ([, opacity]) => ({ "--un-ring-opacity": h.bracket.percent.cssvar(opacity) }),
906
+ { autocomplete: "ring-(op|opacity)-<percent>" }
907
+ ],
908
+ [
909
+ /^ring-offset-(.+)$/,
910
+ colorResolver("--un-ring-offset-color", "ring-offset", "borderColor"),
911
+ { autocomplete: "ring-offset-$colors" }
912
+ ],
913
+ [
914
+ /^ring-offset-op(?:acity)?-?(.+)$/,
915
+ ([, opacity]) => ({ "--un-ring-offset-opacity": h.bracket.percent.cssvar(opacity) }),
916
+ { autocomplete: "ring-offset-(op|opacity)-<percent>" }
917
+ ],
918
+ ["ring-inset", { "--un-ring-inset": "inset" }]
919
+ ];
920
+ function handleWidth$1([, b], { theme }) {
921
+ return { "--un-ring-width": theme.ringWidth?.[b] ?? h.bracket.cssvar.px(b) };
922
+ }
923
+ function handleColorOrWidth$1(match, ctx) {
924
+ if (isCSSMathFn(h.bracket(match[1]))) return handleWidth$1(match, ctx);
925
+ return colorResolver("--un-ring-color", "ring", "borderColor")(match, ctx);
926
+ }
927
+ //#endregion
928
+ //#region src/_rules/shadow.ts
929
+ const boxShadowsBase = {
930
+ "--un-ring-offset-shadow": "0 0 rgb(0 0 0 / 0)",
931
+ "--un-ring-shadow": "0 0 rgb(0 0 0 / 0)",
932
+ "--un-shadow-inset": " ",
933
+ "--un-shadow": "0 0 rgb(0 0 0 / 0)"
934
+ };
935
+ const boxShadows = [
936
+ [
937
+ /^shadow(?:-(.+))?$/,
938
+ (match, context) => {
939
+ const [, d] = match;
940
+ const { theme } = context;
941
+ const v = theme.boxShadow?.[d || "DEFAULT"];
942
+ const c = d ? h.bracket.cssvar(d) : void 0;
943
+ if ((v != null || c != null) && !hasParseableColor(c, theme, "shadowColor")) return {
944
+ "--un-shadow": colorableShadows(v || c, "--un-shadow-color").join(","),
945
+ "box-shadow": "var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow)"
946
+ };
947
+ return colorResolver("--un-shadow-color", "shadow", "shadowColor")(match, context);
948
+ },
949
+ {
950
+ custom: { preflightKeys: Object.keys(boxShadowsBase) },
951
+ autocomplete: ["shadow-$colors", "shadow-$boxShadow"]
952
+ }
953
+ ],
954
+ [
955
+ /^shadow-op(?:acity)?-?(.+)$/,
956
+ ([, opacity]) => ({ "--un-shadow-opacity": h.bracket.percent.cssvar(opacity) }),
957
+ { autocomplete: "shadow-(op|opacity)-<percent>" }
958
+ ],
959
+ ["shadow-inset", { "--un-shadow-inset": "inset" }]
960
+ ];
961
+ //#endregion
962
+ //#region src/_rules/size.ts
963
+ const sizeMapping = {
964
+ h: "height",
965
+ w: "width",
966
+ inline: "inline-size",
967
+ block: "block-size"
968
+ };
969
+ function getPropName(minmax, hw) {
970
+ return `${minmax || ""}${sizeMapping[hw]}`;
971
+ }
972
+ function getSizeValue(minmax, hw, theme, prop) {
973
+ const v = theme[getPropName(minmax, hw).replace(/-(\w)/g, (_, p) => p.toUpperCase())]?.[prop];
974
+ if (v != null) return v;
975
+ switch (prop) {
976
+ case "fit":
977
+ case "max":
978
+ case "min": return `${prop}-content`;
979
+ case "stretch": return "stretch";
980
+ }
981
+ return h.bracket.cssvar.global.auto.fraction.rem(prop);
982
+ }
983
+ const sizes = [
984
+ [/^size-(min-|max-)?(.+)$/, ([, m, s], { theme }) => ({
985
+ [getPropName(m, "w")]: getSizeValue(m, "w", theme, s),
986
+ [getPropName(m, "h")]: getSizeValue(m, "h", theme, s)
987
+ })],
988
+ [/^(?:size-)?(min-|max-)?([wh])-?(.+)$/, ([, m, w, s], { theme }) => ({ [getPropName(m, w)]: getSizeValue(m, w, theme, s) })],
989
+ [
990
+ /^(?:size-)?(min-|max-)?(block|inline)-(.+)$/,
991
+ ([, m, w, s], { theme }) => ({ [getPropName(m, w)]: getSizeValue(m, w, theme, s) }),
992
+ { autocomplete: [
993
+ "(w|h)-$width|height|maxWidth|maxHeight|minWidth|minHeight|inlineSize|blockSize|maxInlineSize|maxBlockSize|minInlineSize|minBlockSize",
994
+ "(block|inline)-$width|height|maxWidth|maxHeight|minWidth|minHeight|inlineSize|blockSize|maxInlineSize|maxBlockSize|minInlineSize|minBlockSize",
995
+ "(max|min)-(w|h|block|inline)",
996
+ "(max|min)-(w|h|block|inline)-$width|height|maxWidth|maxHeight|minWidth|minHeight|inlineSize|blockSize|maxInlineSize|maxBlockSize|minInlineSize|minBlockSize",
997
+ "(w|h)-full",
998
+ "(max|min)-(w|h)-full"
999
+ ] }
1000
+ ],
1001
+ [/^(?:size-)?(min-|max-)?(h)-screen-(.+)$/, ([, m, h, p], context) => ({ [getPropName(m, h)]: handleBreakpoint(context, p, "verticalBreakpoints") })],
1002
+ [
1003
+ /^(?:size-)?(min-|max-)?(w)-screen-(.+)$/,
1004
+ ([, m, w, p], context) => ({ [getPropName(m, w)]: handleBreakpoint(context, p) }),
1005
+ { autocomplete: [
1006
+ "(w|h)-screen",
1007
+ "(min|max)-(w|h)-screen",
1008
+ "h-screen-$verticalBreakpoints",
1009
+ "(min|max)-h-screen-$verticalBreakpoints",
1010
+ "w-screen-$breakpoints",
1011
+ "(min|max)-w-screen-$breakpoints"
1012
+ ] }
1013
+ ]
1014
+ ];
1015
+ function handleBreakpoint(context, point, key = "breakpoints") {
1016
+ const bp = resolveBreakpoints(context, key);
1017
+ if (bp) return bp.find((i) => i.point === point)?.size;
1018
+ }
1019
+ function getAspectRatio(prop) {
1020
+ if (/^\d+\/\d+$/.test(prop)) return prop;
1021
+ switch (prop) {
1022
+ case "square": return "1/1";
1023
+ case "video": return "16/9";
1024
+ }
1025
+ return h.bracket.cssvar.global.auto.number(prop);
1026
+ }
1027
+ const aspectRatio = [[
1028
+ /^(?:size-)?aspect-(?:ratio-)?(.+)$/,
1029
+ ([, d]) => ({ "aspect-ratio": getAspectRatio(d) }),
1030
+ { autocomplete: ["aspect-(square|video|ratio)", "aspect-ratio-(square|video)"] }
1031
+ ]];
1032
+ //#endregion
1033
+ //#region src/_rules/spacing.ts
1034
+ const paddings = [
1035
+ [
1036
+ /^pa?()-?(.+)$/,
1037
+ directionSize("padding"),
1038
+ { autocomplete: ["(m|p)<num>", "(m|p)-<num>"] }
1039
+ ],
1040
+ [
1041
+ /^p-?xy()()$/,
1042
+ directionSize("padding"),
1043
+ { autocomplete: "(m|p)-(xy)" }
1044
+ ],
1045
+ [/^p-?([xy])(?:-?(.+))?$/, directionSize("padding")],
1046
+ [
1047
+ /^p-?([rltbse])(?:-?(.+))?$/,
1048
+ directionSize("padding"),
1049
+ { autocomplete: "(m|p)<directions>-<num>" }
1050
+ ],
1051
+ [
1052
+ /^p-(block|inline)(?:-(.+))?$/,
1053
+ directionSize("padding"),
1054
+ { autocomplete: "(m|p)-(block|inline)-<num>" }
1055
+ ],
1056
+ [
1057
+ /^p-?([bi][se])(?:-?(.+))?$/,
1058
+ directionSize("padding"),
1059
+ { autocomplete: "(m|p)-(bs|be|is|ie)-<num>" }
1060
+ ]
1061
+ ];
1062
+ const margins = [
1063
+ [/^ma?()-?(.+)$/, directionSize("margin")],
1064
+ [/^m-?xy()()$/, directionSize("margin")],
1065
+ [/^m-?([xy])(?:-?(.+))?$/, directionSize("margin")],
1066
+ [/^m-?([rltbse])(?:-?(.+))?$/, directionSize("margin")],
1067
+ [/^m-(block|inline)(?:-(.+))?$/, directionSize("margin")],
1068
+ [/^m-?([bi][se])(?:-?(.+))?$/, directionSize("margin")]
1069
+ ];
1070
+ //#endregion
1071
+ //#region src/_rules/svg.ts
1072
+ const svgUtilities = [
1073
+ [
1074
+ /^fill-(.+)$/,
1075
+ colorResolver("fill", "fill", "backgroundColor"),
1076
+ { autocomplete: "fill-$colors" }
1077
+ ],
1078
+ [
1079
+ /^fill-op(?:acity)?-?(.+)$/,
1080
+ ([, opacity]) => ({ "--un-fill-opacity": h.bracket.percent.cssvar(opacity) }),
1081
+ { autocomplete: "fill-(op|opacity)-<percent>" }
1082
+ ],
1083
+ ["fill-none", { fill: "none" }],
1084
+ [
1085
+ /^stroke-(?:width-|size-)?(.+)$/,
1086
+ handleWidth,
1087
+ { autocomplete: ["stroke-width-$lineWidth", "stroke-size-$lineWidth"] }
1088
+ ],
1089
+ [
1090
+ /^stroke-dash-(.+)$/,
1091
+ ([, s]) => ({ "stroke-dasharray": h.bracket.cssvar.number(s) }),
1092
+ { autocomplete: "stroke-dash-<num>" }
1093
+ ],
1094
+ [
1095
+ /^stroke-offset-(.+)$/,
1096
+ ([, s], { theme }) => ({ "stroke-dashoffset": theme.lineWidth?.[s] ?? h.bracket.cssvar.px.numberWithUnit(s) }),
1097
+ { autocomplete: "stroke-offset-$lineWidth" }
1098
+ ],
1099
+ [
1100
+ /^stroke-(.+)$/,
1101
+ handleColorOrWidth,
1102
+ { autocomplete: "stroke-$colors" }
1103
+ ],
1104
+ [
1105
+ /^stroke-op(?:acity)?-?(.+)$/,
1106
+ ([, opacity]) => ({ "--un-stroke-opacity": h.bracket.percent.cssvar(opacity) }),
1107
+ { autocomplete: "stroke-(op|opacity)-<percent>" }
1108
+ ],
1109
+ ["stroke-cap-square", { "stroke-linecap": "square" }],
1110
+ ["stroke-cap-round", { "stroke-linecap": "round" }],
1111
+ ["stroke-cap-auto", { "stroke-linecap": "butt" }],
1112
+ ["stroke-join-arcs", { "stroke-linejoin": "arcs" }],
1113
+ ["stroke-join-bevel", { "stroke-linejoin": "bevel" }],
1114
+ ["stroke-join-clip", { "stroke-linejoin": "miter-clip" }],
1115
+ ["stroke-join-round", { "stroke-linejoin": "round" }],
1116
+ ["stroke-join-auto", { "stroke-linejoin": "miter" }],
1117
+ ["stroke-none", { stroke: "none" }]
1118
+ ];
1119
+ function handleWidth([, b], { theme }) {
1120
+ return { "stroke-width": theme.lineWidth?.[b] ?? h.bracket.cssvar.fraction.px.number(b) };
1121
+ }
1122
+ function handleColorOrWidth(match, ctx) {
1123
+ if (isCSSMathFn(h.bracket(match[1]))) return handleWidth(match, ctx);
1124
+ return colorResolver("stroke", "stroke", "borderColor")(match, ctx);
1125
+ }
1126
+ //#endregion
1127
+ //#region src/_rules/transform.ts
1128
+ const transformValues = [
1129
+ "translate",
1130
+ "rotate",
1131
+ "scale"
1132
+ ];
1133
+ const transformCpu = [
1134
+ "translateX(var(--un-translate-x))",
1135
+ "translateY(var(--un-translate-y))",
1136
+ "rotate(var(--un-rotate))",
1137
+ "rotateZ(var(--un-rotate-z))",
1138
+ "skewX(var(--un-skew-x))",
1139
+ "skewY(var(--un-skew-y))",
1140
+ "scaleX(var(--un-scale-x))",
1141
+ "scaleY(var(--un-scale-y))"
1142
+ ].join(" ");
1143
+ const transform = [
1144
+ "translateX(var(--un-translate-x))",
1145
+ "translateY(var(--un-translate-y))",
1146
+ "translateZ(var(--un-translate-z))",
1147
+ "rotate(var(--un-rotate))",
1148
+ "rotateX(var(--un-rotate-x))",
1149
+ "rotateY(var(--un-rotate-y))",
1150
+ "rotateZ(var(--un-rotate-z))",
1151
+ "skewX(var(--un-skew-x))",
1152
+ "skewY(var(--un-skew-y))",
1153
+ "scaleX(var(--un-scale-x))",
1154
+ "scaleY(var(--un-scale-y))",
1155
+ "scaleZ(var(--un-scale-z))"
1156
+ ].join(" ");
1157
+ const transformGpu = [
1158
+ "translate3d(var(--un-translate-x), var(--un-translate-y), var(--un-translate-z))",
1159
+ "rotate(var(--un-rotate))",
1160
+ "rotateX(var(--un-rotate-x))",
1161
+ "rotateY(var(--un-rotate-y))",
1162
+ "rotateZ(var(--un-rotate-z))",
1163
+ "skewX(var(--un-skew-x))",
1164
+ "skewY(var(--un-skew-y))",
1165
+ "scaleX(var(--un-scale-x))",
1166
+ "scaleY(var(--un-scale-y))",
1167
+ "scaleZ(var(--un-scale-z))"
1168
+ ].join(" ");
1169
+ const transformBase = {
1170
+ "--un-rotate": 0,
1171
+ "--un-rotate-x": 0,
1172
+ "--un-rotate-y": 0,
1173
+ "--un-rotate-z": 0,
1174
+ "--un-scale-x": 1,
1175
+ "--un-scale-y": 1,
1176
+ "--un-scale-z": 1,
1177
+ "--un-skew-x": 0,
1178
+ "--un-skew-y": 0,
1179
+ "--un-translate-x": 0,
1180
+ "--un-translate-y": 0,
1181
+ "--un-translate-z": 0
1182
+ };
1183
+ const preflightKeys = Object.keys(transformBase);
1184
+ const transforms = [
1185
+ [
1186
+ /^(?:transform-)?origin-(.+)$/,
1187
+ ([, s]) => ({ "transform-origin": positionMap[s] ?? h.bracket.cssvar(s) }),
1188
+ { autocomplete: [`transform-origin-(${Object.keys(positionMap).join("|")})`, `origin-(${Object.keys(positionMap).join("|")})`] }
1189
+ ],
1190
+ [/^(transform-)?perspect(?:ive)?-(.+)$/, ([, t, s]) => {
1191
+ const v = h.bracket.cssvar.px.numberWithUnit(s);
1192
+ if (v != null) {
1193
+ if (t) return {
1194
+ "--un-perspective": `perspective(${v})`,
1195
+ "transform": `var(--un-perspective) ${transform}`
1196
+ };
1197
+ return {
1198
+ "-webkit-perspective": v,
1199
+ "perspective": v
1200
+ };
1201
+ }
1202
+ }],
1203
+ [/^perspect(?:ive)?-origin-(.+)$/, ([, s]) => {
1204
+ const v = h.bracket.cssvar(s) ?? (s.length >= 3 ? positionMap[s] : void 0);
1205
+ if (v != null) return {
1206
+ "-webkit-perspective-origin": v,
1207
+ "perspective-origin": v
1208
+ };
1209
+ }],
1210
+ [
1211
+ /^(?:transform-)?translate-()(.+)$/,
1212
+ handleTranslate,
1213
+ { custom: { preflightKeys } }
1214
+ ],
1215
+ [
1216
+ /^(?:transform-)?translate-([xyz])-(.+)$/,
1217
+ handleTranslate,
1218
+ { custom: { preflightKeys } }
1219
+ ],
1220
+ [
1221
+ /^(?:transform-)?rotate-()(.+)$/,
1222
+ handleRotate,
1223
+ { custom: { preflightKeys } }
1224
+ ],
1225
+ [
1226
+ /^(?:transform-)?rotate-([xyz])-(.+)$/,
1227
+ handleRotate,
1228
+ { custom: { preflightKeys } }
1229
+ ],
1230
+ [
1231
+ /^(?:transform-)?skew-()(.+)$/,
1232
+ handleSkew,
1233
+ { custom: { preflightKeys } }
1234
+ ],
1235
+ [
1236
+ /^(?:transform-)?skew-([xy])-(.+)$/,
1237
+ handleSkew,
1238
+ {
1239
+ custom: { preflightKeys },
1240
+ autocomplete: ["transform-skew-(x|y)-<percent>", "skew-(x|y)-<percent>"]
1241
+ }
1242
+ ],
1243
+ [
1244
+ /^(?:transform-)?scale-()(.+)$/,
1245
+ handleScale,
1246
+ { custom: { preflightKeys } }
1247
+ ],
1248
+ [
1249
+ /^(?:transform-)?scale-([xyz])-(.+)$/,
1250
+ handleScale,
1251
+ {
1252
+ custom: { preflightKeys },
1253
+ autocomplete: [
1254
+ `transform-(${transformValues.join("|")})-<percent>`,
1255
+ `transform-(${transformValues.join("|")})-(x|y|z)-<percent>`,
1256
+ `(${transformValues.join("|")})-<percent>`,
1257
+ `(${transformValues.join("|")})-(x|y|z)-<percent>`
1258
+ ]
1259
+ }
1260
+ ],
1261
+ [/^(?:transform-)?preserve-3d$/, () => ({ "transform-style": "preserve-3d" })],
1262
+ [/^(?:transform-)?preserve-flat$/, () => ({ "transform-style": "flat" })],
1263
+ [
1264
+ "transform",
1265
+ { transform },
1266
+ { custom: { preflightKeys } }
1267
+ ],
1268
+ [
1269
+ "transform-cpu",
1270
+ { transform: transformCpu },
1271
+ { custom: { preflightKeys: [
1272
+ "--un-translate-x",
1273
+ "--un-translate-y",
1274
+ "--un-rotate",
1275
+ "--un-rotate-z",
1276
+ "--un-skew-x",
1277
+ "--un-skew-y",
1278
+ "--un-scale-x",
1279
+ "--un-scale-y"
1280
+ ] } }
1281
+ ],
1282
+ [
1283
+ "transform-gpu",
1284
+ { transform: transformGpu },
1285
+ { custom: { preflightKeys } }
1286
+ ],
1287
+ ["transform-none", { transform: "none" }],
1288
+ ...makeGlobalStaticRules("transform")
1289
+ ];
1290
+ function handleTranslate([, d, b], { theme }) {
1291
+ const v = theme.spacing?.[b] ?? h.bracket.cssvar.fraction.rem(b);
1292
+ if (v != null) return [...transformXYZ(d, v, "translate"), ["transform", transform]];
1293
+ }
1294
+ function handleScale([, d, b]) {
1295
+ const v = h.bracket.cssvar.fraction.percent(b);
1296
+ if (v != null) return [...transformXYZ(d, v, "scale"), ["transform", transform]];
1297
+ }
1298
+ function handleRotate([, d = "", b]) {
1299
+ const v = h.bracket.cssvar.degree(b);
1300
+ if (v != null) if (d) return {
1301
+ "--un-rotate": 0,
1302
+ [`--un-rotate-${d}`]: v,
1303
+ "transform": transform
1304
+ };
1305
+ else return {
1306
+ "--un-rotate-x": 0,
1307
+ "--un-rotate-y": 0,
1308
+ "--un-rotate-z": 0,
1309
+ "--un-rotate": v,
1310
+ "transform": transform
1311
+ };
1312
+ }
1313
+ function handleSkew([, d, b]) {
1314
+ const v = h.bracket.cssvar.degree(b);
1315
+ if (v != null) return [...transformXYZ(d, v, "skew"), ["transform", transform]];
1316
+ }
1317
+ //#endregion
1318
+ //#region src/_rules/transition.ts
1319
+ function resolveTransitionProperty(prop, theme) {
1320
+ let p;
1321
+ if (h.cssvar(prop) != null) p = h.cssvar(prop);
1322
+ else {
1323
+ if (prop.startsWith("[") && prop.endsWith("]")) prop = prop.slice(1, -1);
1324
+ const props = prop.split(",").map((p) => theme.transitionProperty?.[p] ?? h.properties(p));
1325
+ if (props.every(Boolean)) p = props.join(",");
1326
+ }
1327
+ return p;
1328
+ }
1329
+ const transitions = [
1330
+ [
1331
+ /^transition(?:-(\D+?))?(?:-(\d+))?$/,
1332
+ ([, prop, d], { theme }) => {
1333
+ if (!prop && !d) return {
1334
+ "transition-property": theme.transitionProperty?.DEFAULT,
1335
+ "transition-timing-function": theme.easing?.DEFAULT,
1336
+ "transition-duration": theme.duration?.DEFAULT ?? h.time("150")
1337
+ };
1338
+ else if (prop != null) {
1339
+ const p = resolveTransitionProperty(prop, theme);
1340
+ const duration = theme.duration?.[d || "DEFAULT"] ?? h.time(d || "150");
1341
+ if (p) return {
1342
+ "transition-property": p,
1343
+ "transition-timing-function": theme.easing?.DEFAULT,
1344
+ "transition-duration": duration
1345
+ };
1346
+ } else if (d != null) return {
1347
+ "transition-property": theme.transitionProperty?.DEFAULT,
1348
+ "transition-timing-function": theme.easing?.DEFAULT,
1349
+ "transition-duration": theme.duration?.[d] ?? h.time(d)
1350
+ };
1351
+ },
1352
+ { autocomplete: "transition-$transitionProperty-$duration" }
1353
+ ],
1354
+ [
1355
+ /^(?:transition-)?duration-(.+)$/,
1356
+ ([, d], { theme }) => ({ "transition-duration": theme.duration?.[d || "DEFAULT"] ?? h.bracket.cssvar.time(d) }),
1357
+ { autocomplete: ["transition-duration-$duration", "duration-$duration"] }
1358
+ ],
1359
+ [
1360
+ /^(?:transition-)?delay-(.+)$/,
1361
+ ([, d], { theme }) => ({ "transition-delay": theme.duration?.[d || "DEFAULT"] ?? h.bracket.cssvar.time(d) }),
1362
+ { autocomplete: ["transition-delay-$duration", "delay-$duration"] }
1363
+ ],
1364
+ [
1365
+ /^(?:transition-)?ease(?:-(.+))?$/,
1366
+ ([, d], { theme }) => ({ "transition-timing-function": theme.easing?.[d || "DEFAULT"] ?? h.bracket.cssvar(d) }),
1367
+ { autocomplete: ["transition-ease-(linear|in|out|in-out|DEFAULT)", "ease-(linear|in|out|in-out|DEFAULT)"] }
1368
+ ],
1369
+ [
1370
+ /^(?:transition-)?property-(.+)$/,
1371
+ ([, v], { theme }) => {
1372
+ const p = h.global(v) || resolveTransitionProperty(v, theme);
1373
+ if (p) return { "transition-property": p };
1374
+ },
1375
+ { autocomplete: [
1376
+ `transition-property-(${[...globalKeywords].join("|")})`,
1377
+ "transition-property-$transitionProperty",
1378
+ "property-$transitionProperty"
1379
+ ] }
1380
+ ],
1381
+ ["transition-none", { transition: "none" }],
1382
+ ...makeGlobalStaticRules("transition"),
1383
+ ["transition-discrete", { "transition-behavior": "allow-discrete" }],
1384
+ ["transition-normal", { "transition-behavior": "normal" }]
1385
+ ];
1386
+ //#endregion
1387
+ //#region src/_rules/typography.ts
1388
+ const fonts = [
1389
+ [
1390
+ /^text-(.+)$/,
1391
+ handleText,
1392
+ { autocomplete: "text-$fontSize" }
1393
+ ],
1394
+ [
1395
+ /^(?:text|font)-size-(.+)$/,
1396
+ handleSize,
1397
+ { autocomplete: "text-size-$fontSize" }
1398
+ ],
1399
+ [
1400
+ /^text-(?:color-)?(.+)$/,
1401
+ handlerColorOrSize,
1402
+ { autocomplete: "text-$colors" }
1403
+ ],
1404
+ [
1405
+ /^(?:color|c)-(.+)$/,
1406
+ colorResolver("color", "text", "textColor"),
1407
+ { autocomplete: "(color|c)-$colors" }
1408
+ ],
1409
+ [
1410
+ /^(?:text|color|c)-(.+)$/,
1411
+ ([, v]) => globalKeywords.includes(v) ? { color: v } : void 0,
1412
+ { autocomplete: `(text|color|c)-(${globalKeywords.join("|")})` }
1413
+ ],
1414
+ [
1415
+ /^(?:text|color|c)-op(?:acity)?-?(.+)$/,
1416
+ ([, opacity]) => ({ "--un-text-opacity": h.bracket.percent.cssvar(opacity) }),
1417
+ { autocomplete: "(text|color|c)-(op|opacity)-<percent>" }
1418
+ ],
1419
+ [
1420
+ /^(?:font|fw)-?([^-]+)$/,
1421
+ ([, s], { theme }) => ({ "font-weight": theme.fontWeight?.[s] || h.bracket.global.number(s) }),
1422
+ { autocomplete: ["(font|fw)-(100|200|300|400|500|600|700|800|900)", "(font|fw)-$fontWeight"] }
1423
+ ],
1424
+ [
1425
+ /^(?:font-)?(?:leading|lh|line-height)-(.+)$/,
1426
+ ([, s], { theme }) => ({ "line-height": handleThemeByKey(s, theme, "lineHeight") }),
1427
+ { autocomplete: "(leading|lh|line-height)-$lineHeight" }
1428
+ ],
1429
+ ["font-synthesis-weight", { "font-synthesis": "weight" }],
1430
+ ["font-synthesis-style", { "font-synthesis": "style" }],
1431
+ ["font-synthesis-small-caps", { "font-synthesis": "small-caps" }],
1432
+ ["font-synthesis-none", { "font-synthesis": "none" }],
1433
+ [/^font-synthesis-(.+)$/, ([, s]) => ({ "font-synthesis": h.bracket.cssvar.global(s) })],
1434
+ [
1435
+ /^(?:font-)?tracking-(.+)$/,
1436
+ ([, s], { theme }) => ({ "letter-spacing": theme.letterSpacing?.[s] || h.bracket.cssvar.global.rem(s) }),
1437
+ { autocomplete: "tracking-$letterSpacing" }
1438
+ ],
1439
+ [
1440
+ /^(?:font-)?word-spacing-(.+)$/,
1441
+ ([, s], { theme }) => ({ "word-spacing": theme.wordSpacing?.[s] || h.bracket.cssvar.global.rem(s) }),
1442
+ { autocomplete: "word-spacing-$wordSpacing" }
1443
+ ],
1444
+ ["font-stretch-normal", { "font-stretch": "normal" }],
1445
+ ["font-stretch-ultra-condensed", { "font-stretch": "ultra-condensed" }],
1446
+ ["font-stretch-extra-condensed", { "font-stretch": "extra-condensed" }],
1447
+ ["font-stretch-condensed", { "font-stretch": "condensed" }],
1448
+ ["font-stretch-semi-condensed", { "font-stretch": "semi-condensed" }],
1449
+ ["font-stretch-semi-expanded", { "font-stretch": "semi-expanded" }],
1450
+ ["font-stretch-expanded", { "font-stretch": "expanded" }],
1451
+ ["font-stretch-extra-expanded", { "font-stretch": "extra-expanded" }],
1452
+ ["font-stretch-ultra-expanded", { "font-stretch": "ultra-expanded" }],
1453
+ [
1454
+ /^font-stretch-(.+)$/,
1455
+ ([, s]) => ({ "font-stretch": h.bracket.cssvar.fraction.global(s) }),
1456
+ { autocomplete: "font-stretch-<percentage>" }
1457
+ ],
1458
+ [
1459
+ /^font-(.+)$/,
1460
+ ([, d], { theme }) => ({ "font-family": theme.fontFamily?.[d] || h.bracket.cssvar.global(d) }),
1461
+ { autocomplete: "font-$fontFamily" }
1462
+ ]
1463
+ ];
1464
+ const tabSizes = [[/^tab(?:-(.+))?$/, ([, s]) => {
1465
+ const v = h.bracket.cssvar.global.number(s || "4");
1466
+ if (v != null) return {
1467
+ "-moz-tab-size": v,
1468
+ "-o-tab-size": v,
1469
+ "tab-size": v
1470
+ };
1471
+ }]];
1472
+ const textIndents = [[
1473
+ /^indent(?:-(.+))?$/,
1474
+ ([, s], { theme }) => ({ "text-indent": theme.textIndent?.[s || "DEFAULT"] || h.bracket.cssvar.global.fraction.rem(s) }),
1475
+ { autocomplete: "indent-$textIndent" }
1476
+ ]];
1477
+ const textStrokes = [
1478
+ [
1479
+ /^text-stroke(?:-(.+))?$/,
1480
+ ([, s], { theme }) => ({ "-webkit-text-stroke-width": theme.textStrokeWidth?.[s || "DEFAULT"] || h.bracket.cssvar.px(s) }),
1481
+ { autocomplete: "text-stroke-$textStrokeWidth" }
1482
+ ],
1483
+ [
1484
+ /^text-stroke-(.+)$/,
1485
+ colorResolver("-webkit-text-stroke-color", "text-stroke", "borderColor"),
1486
+ { autocomplete: "text-stroke-$colors" }
1487
+ ],
1488
+ [
1489
+ /^text-stroke-op(?:acity)?-?(.+)$/,
1490
+ ([, opacity]) => ({ "--un-text-stroke-opacity": h.bracket.percent.cssvar(opacity) }),
1491
+ { autocomplete: "text-stroke-(op|opacity)-<percent>" }
1492
+ ]
1493
+ ];
1494
+ const textShadows = [
1495
+ [
1496
+ /^text-shadow(?:-(.+))?$/,
1497
+ ([, s], { theme }) => {
1498
+ const v = theme.textShadow?.[s || "DEFAULT"];
1499
+ if (v != null) return {
1500
+ "--un-text-shadow": colorableShadows(v, "--un-text-shadow-color").join(","),
1501
+ "text-shadow": "var(--un-text-shadow)"
1502
+ };
1503
+ return { "text-shadow": h.bracket.cssvar.global(s) };
1504
+ },
1505
+ { autocomplete: "text-shadow-$textShadow" }
1506
+ ],
1507
+ [
1508
+ /^text-shadow-color-(.+)$/,
1509
+ colorResolver("--un-text-shadow-color", "text-shadow", "shadowColor"),
1510
+ { autocomplete: "text-shadow-color-$colors" }
1511
+ ],
1512
+ [
1513
+ /^text-shadow-color-op(?:acity)?-?(.+)$/,
1514
+ ([, opacity]) => ({ "--un-text-shadow-opacity": h.bracket.percent.cssvar(opacity) }),
1515
+ { autocomplete: "text-shadow-color-(op|opacity)-<percent>" }
1516
+ ]
1517
+ ];
1518
+ function handleThemeByKey(s, theme, key) {
1519
+ return theme[key]?.[s] || h.bracket.cssvar.global.rem(s);
1520
+ }
1521
+ function handleSize([, s], { theme }) {
1522
+ const size = toArray(theme.fontSize?.[s])?.[0] ?? h.bracket.cssvar.global.rem(s);
1523
+ if (size != null) return { "font-size": size };
1524
+ }
1525
+ function handlerColorOrSize(match, ctx) {
1526
+ if (isCSSMathFn(h.bracket(match[1]))) return handleSize(match, ctx);
1527
+ return colorResolver("color", "text", "textColor")(match, ctx);
1528
+ }
1529
+ function handleText([, s = "base"], { theme }) {
1530
+ const split = splitShorthand(s, "length");
1531
+ if (!split) return;
1532
+ const [size, leading] = split;
1533
+ const sizePairs = toArray(theme.fontSize?.[size]);
1534
+ const lineHeight = leading ? handleThemeByKey(leading, theme, "lineHeight") : void 0;
1535
+ if (sizePairs?.[0]) {
1536
+ const [fontSize, height, letterSpacing] = sizePairs;
1537
+ if (typeof height === "object") return {
1538
+ "font-size": fontSize,
1539
+ ...height
1540
+ };
1541
+ return {
1542
+ "font-size": fontSize,
1543
+ "line-height": lineHeight ?? height ?? "1",
1544
+ "letter-spacing": letterSpacing ? handleThemeByKey(letterSpacing, theme, "letterSpacing") : void 0
1545
+ };
1546
+ }
1547
+ const fontSize = h.bracketOfLength.rem(size);
1548
+ if (lineHeight && fontSize) return {
1549
+ "font-size": fontSize,
1550
+ "line-height": lineHeight
1551
+ };
1552
+ return { "font-size": h.bracketOfLength.rem(s) };
1553
+ }
1554
+ //#endregion
1555
+ //#region src/_rules/variables.ts
1556
+ const variablesAbbrMap = {
1557
+ backface: "backface-visibility",
1558
+ break: "word-break",
1559
+ case: "text-transform",
1560
+ content: "align-content",
1561
+ fw: "font-weight",
1562
+ items: "align-items",
1563
+ justify: "justify-content",
1564
+ select: "user-select",
1565
+ self: "align-self",
1566
+ vertical: "vertical-align",
1567
+ visible: "visibility",
1568
+ whitespace: "white-space",
1569
+ ws: "white-space"
1570
+ };
1571
+ const cssVariables = [[/^(.+?)-(\$.+)$/, ([, name, varname]) => {
1572
+ const prop = variablesAbbrMap[name];
1573
+ if (prop) return { [prop]: h.cssvar(varname) };
1574
+ }]];
1575
+ const cssProperty = [[/^\[(.*)\]$/, ([_, body]) => {
1576
+ if (!body.includes(":")) return;
1577
+ const [prop, ...rest] = body.split(":");
1578
+ const value = rest.join(":");
1579
+ if (!isURI(body) && /^[\w-]+$/.test(prop) && isValidCSSBody(value)) {
1580
+ const parsed = h.bracket(`[${value}]`);
1581
+ if (parsed) return { [prop]: parsed };
1582
+ }
1583
+ }]];
1584
+ function isValidCSSBody(body) {
1585
+ let i = 0;
1586
+ function findUntil(c) {
1587
+ while (i < body.length) {
1588
+ i += 1;
1589
+ if (body[i] === c) return true;
1590
+ }
1591
+ return false;
1592
+ }
1593
+ for (i = 0; i < body.length; i++) {
1594
+ const c = body[i];
1595
+ if ("\"`'".includes(c)) {
1596
+ if (!findUntil(c)) return false;
1597
+ } else if (c === "(") {
1598
+ if (!findUntil(")")) return false;
1599
+ } else if ("[]{}:".includes(c)) return false;
1600
+ }
1601
+ return true;
1602
+ }
1603
+ function isURI(declaration) {
1604
+ if (!declaration.includes("://")) return false;
1605
+ try {
1606
+ return new URL(declaration).host !== "";
1607
+ } catch {
1608
+ return false;
1609
+ }
1610
+ }
1611
+ //#endregion
1612
+ //#region src/_rules/default.ts
1613
+ const rules = [
1614
+ cssVariables,
1615
+ cssProperty,
1616
+ contains,
1617
+ pointerEvents,
1618
+ appearances,
1619
+ positions,
1620
+ insets,
1621
+ zIndexes,
1622
+ orders,
1623
+ grids,
1624
+ floats,
1625
+ margins,
1626
+ boxSizing,
1627
+ displays,
1628
+ aspectRatio,
1629
+ sizes,
1630
+ flex,
1631
+ transforms,
1632
+ cursors,
1633
+ userSelects,
1634
+ resizes,
1635
+ appearance,
1636
+ placements,
1637
+ alignments,
1638
+ justifies,
1639
+ gaps,
1640
+ flexGridJustifiesAlignments,
1641
+ overflows,
1642
+ textOverflows,
1643
+ whitespaces,
1644
+ breaks,
1645
+ borders,
1646
+ bgColors,
1647
+ colorScheme,
1648
+ svgUtilities,
1649
+ paddings,
1650
+ textAligns,
1651
+ textIndents,
1652
+ textWraps,
1653
+ verticalAligns,
1654
+ fonts,
1655
+ textTransforms,
1656
+ fontStyles,
1657
+ textDecorations,
1658
+ fontSmoothings,
1659
+ tabSizes,
1660
+ textStrokes,
1661
+ textShadows,
1662
+ opacity,
1663
+ boxShadows,
1664
+ outline,
1665
+ rings,
1666
+ transitions,
1667
+ willChange,
1668
+ contentVisibility,
1669
+ contents,
1670
+ containerParent,
1671
+ fieldSizing,
1672
+ questionMark
1673
+ ].flat(1);
1674
+ //#endregion
1675
+ export { alignments, appearance, appearances, aspectRatio, bgColors, borderStyles, borders, boxShadows, boxShadowsBase, boxSizing, breaks, colorScheme, containerParent, contains, contentVisibility, contents, cssProperty, cssVariables, cursors, displays, fieldSizing, flex, flexGridJustifiesAlignments, floats, fontSmoothings, fontStyles, fonts, gaps, grids, handlerBorderStyle, insets, justifies, margins, opacity, orders, outline, overflows, paddings, placements, pointerEvents, positions, questionMark, resizes, ringBase, rings, rules, sizes, svgUtilities, tabSizes, textAligns, textDecorations, textIndents, textOverflows, textShadows, textStrokes, textTransforms, textWraps, transformBase, transforms, transitions, userSelects, varEmpty, verticalAligns, whitespaces, willChange, zIndexes };