transform-to-unocss-core 0.0.46 → 0.0.48

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/index.cjs ADDED
@@ -0,0 +1,1147 @@
1
+ "use strict";
2
+
3
+ //#region src/utils.ts
4
+ const flag = ".__unocss_transfer__";
5
+ const cssMathFnRE = /^(?:calc|clamp|min|max)\s*\(.*\)/;
6
+ const numberWithUnitRE = /^-?[0-9.]+(px|rem|em|%|vw|vh|vmin|vmax|deg)$/;
7
+ function isNot(s) {
8
+ return /\[&:not\(/.test(s);
9
+ }
10
+ function isCalc(s) {
11
+ return cssMathFnRE.test(s);
12
+ }
13
+ function getFirstName(s) {
14
+ return s.split("-")[0];
15
+ }
16
+ function getLastName(s) {
17
+ const all = s.split("-");
18
+ return all[all.length - 1];
19
+ }
20
+ function isUrl(s) {
21
+ return s.startsWith("url(");
22
+ }
23
+ function isPercent(s) {
24
+ return s.endsWith("%") && !s.includes(" ");
25
+ }
26
+ function isHex(hex) {
27
+ return /^#[0-9A-F]{2,}$/i.test(hex);
28
+ }
29
+ function isRgb(s) {
30
+ return s.startsWith("rgb");
31
+ }
32
+ function isHsl(s) {
33
+ return s.startsWith("hsl");
34
+ }
35
+ function isCubicBezier(s) {
36
+ return s.startsWith("cubic-bezier");
37
+ }
38
+ function getVal(val, transform$1, inClass, prefix = "") {
39
+ if (isCalc(val) || isUrl(val) || isHex(val) || isRgb(val) || isHsl(val) || isPercent(val) || isVar(val) || isCubicBezier(val)) return inClass ? `-[${prefix}${trim(val, "all").replace(/['"]/g, "")}]` : `="[${prefix}${trim(val, "all").replace(/['"]/g, "")}]"`;
40
+ return prefix ? `-[${prefix}${transform$1 ? transform$1(val) : val}]` : `-${transform$1 ? transform$1(val) : val}`;
41
+ }
42
+ function getHundred(n) {
43
+ if (typeof n === "string" && n.endsWith("%")) return n.slice(0, -1);
44
+ return +n * 100;
45
+ }
46
+ function joinWithLine(s) {
47
+ return s.replace(/\s+/, " ").split(" ").join("-");
48
+ }
49
+ function joinWithUnderLine(s) {
50
+ return s.replace(/\s+/, " ").split(" ").join("_");
51
+ }
52
+ const positionMap = [
53
+ "top",
54
+ "right",
55
+ "bottom",
56
+ "left",
57
+ "center"
58
+ ];
59
+ /**
60
+ * 删除空格
61
+ * @param { string } s 字符串
62
+ * @param { TrimType } type 所有 | 前置 | 前后 | 后置 'all' | 'pre' | 'around' | 'post'
63
+ * @returns string
64
+ */
65
+ function trim(s, type = "around") {
66
+ if (type === "pre") return s.replace(/(^\s*)/g, "");
67
+ if (type === "post") return s.replace(/(\s*$)/g, "");
68
+ if (type === "all") return s.replace(/\s+/g, "");
69
+ if (type === "around") return s.replace(/(^\s*)|(\s*$)/g, "");
70
+ return s;
71
+ }
72
+ function transformImportant(v) {
73
+ v = v.replace(/\s+/, " ").replace(/\s*,\s*/g, ",").replace(/\s*\/\s*/, "/");
74
+ if (/rgb/.test(v)) v = v.replace(/rgba?\(([^)]+)\)/g, (all, k) => {
75
+ const _k = k.trim().split(" ");
76
+ return all.replace(k, _k.map((i, index) => i.endsWith(",") ? i : i + (_k.length - 1 === index ? "" : ",")).join(""));
77
+ });
78
+ if (/hsl/.test(v)) v = v.replace(/hsla?\(([^)]+)\)/g, (all, k) => {
79
+ const _k = k.trim().split(" ");
80
+ return all.replace(k, _k.map((i, index) => i.endsWith(",") ? i : i + (_k.length - 1 === index ? "" : ",")).join(""));
81
+ });
82
+ if (/var\([^)]+\)/.test(v)) v = v.replace(/var\(([^)]+)\)/g, (all, k) => {
83
+ const _k = k.trim().split(" ");
84
+ return all.replace(k, _k.map((i, index) => i.endsWith(",") ? i : i + (_k.length - 1 === index ? "" : ",")).join(""));
85
+ });
86
+ if (v.endsWith("!important")) return [v.replace(/\s*!important/, "").trim(), "!"];
87
+ return [v.trim(), ""];
88
+ }
89
+ function diffTemplateStyle(before, after) {
90
+ const s1 = before.match(/<style scoped>.*<\/style>/s);
91
+ const s2 = after.match(/<style scoped>.*<\/style>/s);
92
+ return s1[0] === s2[0];
93
+ }
94
+ function isEmptyStyle(code) {
95
+ return /<style scoped>\s*<\/style>/.test(code);
96
+ }
97
+ function getStyleScoped(code) {
98
+ const match = code.match(/<style scoped>(.*)<\/style>/s);
99
+ if (!match) return "";
100
+ return match[1];
101
+ }
102
+ function joinEmpty(str) {
103
+ return str.replace(/\(\s*/g, "(").replace(/\s*\)/g, ")").replace(/\s*,\s*/g, ",");
104
+ }
105
+ function isVar(s) {
106
+ return s.startsWith("var(--");
107
+ }
108
+ function isSize(s) {
109
+ return cssMathFnRE.test(s) || numberWithUnitRE.test(s) || positionMap.includes(s);
110
+ }
111
+ function isColor(s) {
112
+ return isHex(s) || isRgb(s) || isHsl(s);
113
+ }
114
+ const browserReg = /-webkit-|-moz-|-ms-|-o-/g;
115
+ const linearGradientReg = /linear-gradient\(\s*to([\w\s]+),?([\-\w()#%\s.]+)?,([\-\w()#%\s.]+)?,?([\-\w#%\s.]+)?\)$/;
116
+ const linearGradientReg1 = /linear-gradient\(\s*([^,]*),?([\-\w()#%\s.]+)?,([\-\w()#%\s.]+)?,?([\-\w#%\s.]+)?\)$/;
117
+ const otherGradientReg = /(radial|conic)-gradient\(([\-\w()#%\s.]+)?,([\-\w()#%\s.]+)?,?([\-\w#%\s.]+)?\)$/;
118
+ const commaReplacer = "__comma__";
119
+ function getGradient(s) {
120
+ return s.startsWith("linear-gradient") ? "linear" : s.startsWith("radial-gradient") ? "radial" : s.startsWith("conic-gradient") ? "conic" : "";
121
+ }
122
+
123
+ //#endregion
124
+ //#region src/align.ts
125
+ function align(key, val) {
126
+ const [value, important] = transformImportant(val);
127
+ return `${getLastName(key)}-${getLastName(value)}${important}`;
128
+ }
129
+
130
+ //#endregion
131
+ //#region src/animation.ts
132
+ function animation(key, val) {
133
+ const [value, important] = transformImportant(val);
134
+ if (key === "animation-delay") return `animate-delay${getVal(value)}${important}`;
135
+ if (key === "animation-duration") return `animate-duration${getVal(value)}${important}`;
136
+ if (key === "animation-name") return `animate-[${value}]${important}`;
137
+ if (key === "animation-timing-function") return `animate-ease-[${value}]${important}`;
138
+ if (key === "animation-iteration-count") return `animate-count${getVal(value)}${important}`;
139
+ if (key === "animation-direction") return `animate-direction-${value}${important}`;
140
+ if (key === "animation-fill-mode") return `animate-fill-${value}${important}`;
141
+ const playStates = {
142
+ running: "running",
143
+ paused: "paused"
144
+ };
145
+ if (key === "animation-play-state") {
146
+ if (value in playStates) return `animate-${playStates[value]}${important}`;
147
+ return `animate-[${value}]${important}`;
148
+ }
149
+ if (key === "animation") {
150
+ const parts = value.split(" ");
151
+ const result = [];
152
+ let timeValuesFound = 0;
153
+ for (let i = 0; i < parts.length; i++) {
154
+ const part = parts[i];
155
+ if (/^\d+(?:\.\d+)?s?$/.test(part)) {
156
+ if (timeValuesFound === 0) result.push(`animate-duration${getVal(part)}`);
157
+ else if (timeValuesFound === 1) result.push(`animate-delay${getVal(part)}`);
158
+ else result.push(`animate-[${part}]`);
159
+ timeValuesFound++;
160
+ } else if (/^(?:linear|ease|ease-in|ease-out|ease-in-out|step-start|step-end)$/.test(part)) result.push(`animate-ease-[${part}]`);
161
+ else if (part.startsWith("cubic-bezier") || part.startsWith("steps")) result.push(`animate-ease-[${part}]`);
162
+ else if ([
163
+ "alternate",
164
+ "alternate-reverse",
165
+ "normal",
166
+ "reverse"
167
+ ].includes(part)) result.push(`animate-direction-${part}`);
168
+ else if ([
169
+ "forwards",
170
+ "backwards",
171
+ "both",
172
+ "none"
173
+ ].includes(part)) result.push(`animate-fill-${part}`);
174
+ else if (playStates[part]) result.push(`animate-${playStates[part]}`);
175
+ else if (part === "infinite" || /^\d+$/.test(part)) result.push(`animate-count${getVal(part)}`);
176
+ else if (part !== "normal") result.push(`animate-[${part}]`);
177
+ else result.push(`animate-[${part}]`);
178
+ }
179
+ return result.length > 0 ? result.join(" ") + important : "";
180
+ }
181
+ return `animate-[${value}]${important}`;
182
+ }
183
+
184
+ //#endregion
185
+ //#region src/aspect.ts
186
+ function aspect(key, val) {
187
+ const [value, important] = transformImportant(val);
188
+ if (value === "auto") return `${getFirstName(key)}-${value}${important}`;
189
+ return `${getFirstName(key)}="[${value}]${important}"`;
190
+ }
191
+
192
+ //#endregion
193
+ //#region src/box.ts
194
+ const validKey = ["box-shadow", "drop-shadow"];
195
+ function box(key, val) {
196
+ let [value, important] = transformImportant(val);
197
+ if (key.startsWith("box-decoration")) return `box-decoration-${value}${important}`;
198
+ if (key === "box-sizing") return `box-${getFirstName(value)}${important}`;
199
+ if (validKey.includes(key)) return `shadow="[${value.split(" ").join("_")}]${important}"`;
200
+ }
201
+
202
+ //#endregion
203
+ //#region src/filter.ts
204
+ const hundred = [
205
+ "contrast",
206
+ "brightness",
207
+ "saturate"
208
+ ];
209
+ const percent = [
210
+ "grayscale",
211
+ "invert",
212
+ "sepia"
213
+ ];
214
+ function filter(key, val) {
215
+ const [v, important] = transformImportant(val);
216
+ const [_, name, value] = v.match(/([\w-]+)\((.*)\)/);
217
+ if (hundred.includes(name)) return `${name}-${getHundred(value)}${important}`;
218
+ if (name === "drop-shadow") return `drop-${box(name, value)}${important}`;
219
+ if (percent.includes(name)) return `${name}-${value.endsWith("%") ? value.slice(0, -1) : getHundred(value)}${important}`;
220
+ if (name === "hue-rotate") return `${name}-${value.slice(0, -3)}${important}`;
221
+ return `${name}-${value}${important}`;
222
+ }
223
+
224
+ //#endregion
225
+ //#region src/backdrop.ts
226
+ function backdrop(key, val) {
227
+ const [value, important] = transformImportant(val);
228
+ return `backdrop-${filter(key, value)}${important}`;
229
+ }
230
+
231
+ //#endregion
232
+ //#region src/background.ts
233
+ const backgroundMap = [
234
+ "background-color",
235
+ "background-attachment",
236
+ "background-position"
237
+ ];
238
+ function background(key, val) {
239
+ const [value, important] = transformImportant(val);
240
+ if (key === "background-size") return `bg${getVal(value, /\d/.test(value) ? transformSpaceToUnderLine : transformSpaceToLine, false, "length:")}${important}`;
241
+ if (backgroundMap.includes(key)) return `bg${getVal(value, transformSpaceToLine)}${important}`;
242
+ if (["background", "background-image"].includes(key)) {
243
+ if (isSize(value)) return `bg${getVal(value, transformSpaceToLine, false, "position:")}${important}`;
244
+ const temp = value.replace(/rgba?\([^)]+\)/g, "temp");
245
+ if (/\)\s*,/.test(temp)) return `bg="[${matchMultipleBgAttrs(value)}]"`;
246
+ if (value.startsWith("linear-gradient")) {
247
+ const newValue = value.replace(/rgba?\(([^)]+)\)/g, (all, v) => all.replace(v, v.replace(/\s*,\s*/g, commaReplacer)));
248
+ const matcher = newValue.match(linearGradientReg);
249
+ if (matcher) {
250
+ let [direction, from, via, to] = matcher.slice(1);
251
+ direction = direction.split(" ").map((item) => item[0]).join("");
252
+ return direction ? `bg-gradient-to-${direction}${getLinearGradientPosition$1(from, via, to)}` : getLinearGradientPosition$1(from, via, to);
253
+ }
254
+ const matcher1 = newValue.match(linearGradientReg1);
255
+ if (!matcher1) return;
256
+ return `bg-gradient-linear bg-gradient-[${matcher1[1]},${matcher1[2].replace(/\s+/, "_").replaceAll(commaReplacer, ",")},${matcher1[3].replace(/\s+/, "_").replaceAll(commaReplacer, ",")}]`;
257
+ } else if (/^(?:radial|conic)-gradient/.test(value)) {
258
+ const newValue = value.replace(/rgba?\(([^)]+)\)/g, (all, v) => all.replace(v, v.replace(/\s*,\s*/g, commaReplacer)));
259
+ const matcher = newValue.match(otherGradientReg);
260
+ if (!matcher) return;
261
+ const name = matcher[1];
262
+ const [from, via, to] = matcher.slice(2);
263
+ return `bg-gradient-${name}${getLinearGradientPosition$1(from, via, to)}`;
264
+ }
265
+ const match = value.match(/^rgba?\([^)]+\)$/);
266
+ if (match) {
267
+ const rgb = match[0];
268
+ return `bg="${value.replace(rgb, `[${rgb}]`)}${important}"`;
269
+ }
270
+ const urlMatch = value.match(/^url\(["'\s.\-\w/@]*\)$/);
271
+ if (urlMatch) return `bg="${value.replace(urlMatch[0], `[${urlMatch[0].replace(/['"]/g, "")}]${important}`)}"`;
272
+ if (value.includes(" ")) {
273
+ let r = value.split(" ").map((v) => background(key, `${v}${important ? " !important" : ""}`)).join(" ");
274
+ const bgPositionReg = /bg-\[position:([^\]]*)\]/g;
275
+ const bgPosition = r.match(bgPositionReg);
276
+ if (bgPosition && bgPosition.length > 1) {
277
+ const t = `bg-[position:${bgPosition.map((item) => item.replace(bgPositionReg, "$1")).join("_")}]`;
278
+ r = `${r.replace(bgPositionReg, "").replace(/\s+/g, " ").split(" ").filter(Boolean).concat([t]).join(" ")}`;
279
+ }
280
+ return r;
281
+ }
282
+ return `bg${getVal(value, transformSpaceToLine)}${important}`;
283
+ }
284
+ if (key === "background-blend-mode") return `bg-blend-${value}${important}`;
285
+ return `${replaceBackground(key, value)}-${transformBox(value)}${important}`;
286
+ }
287
+ function replaceBackground(s, val) {
288
+ if (val.endsWith("repeat")) return "bg";
289
+ return s.replace("background", "bg");
290
+ }
291
+ function transformBox(s) {
292
+ const reg = /border|content|padding-box/;
293
+ if (reg.test(s)) return s.replace("-box", "");
294
+ if (s.startsWith("repeat-")) return s.replace("repeat-", "");
295
+ return transformSpaceToLine(s);
296
+ }
297
+ function transformSpaceToLine(s) {
298
+ return s.replace(/\s+/, " ").replace(" ", "-");
299
+ }
300
+ function transformSpaceToUnderLine(s) {
301
+ return s.replace(/\s+/, " ").replace(" ", "_");
302
+ }
303
+ function getLinearGradientPosition$1(from, via, to) {
304
+ let result = "";
305
+ if (via && !to) {
306
+ to = via;
307
+ via = "";
308
+ }
309
+ if (from) {
310
+ from = from.replaceAll(commaReplacer, ",");
311
+ const [fromColor, fromPosition] = from.split(" ");
312
+ if (fromPosition) result += ` from="${isRgb(fromColor) ? `[${fromColor}]` : fromColor} ${fromPosition}"`;
313
+ else if (fromColor) result += ` from="${isRgb(fromColor) ? `[${fromColor}]` : fromColor}"`;
314
+ }
315
+ if (via) {
316
+ via = via.replaceAll(commaReplacer, ",");
317
+ const [viaColor, viaPosition] = via.split(" ");
318
+ if (viaPosition) result += ` via="${isRgb(viaColor) ? `[${viaColor}]` : viaColor} ${viaPosition}"`;
319
+ else if (viaColor) result += ` via="${isRgb(viaColor) ? `[${viaColor}]` : viaColor}"`;
320
+ }
321
+ if (to) {
322
+ to = to.replaceAll(commaReplacer, ",");
323
+ const [toColor, toPosition] = to.split(" ");
324
+ if (toPosition) result += ` to="${isRgb(toColor) ? `[${toColor}]` : toColor} ${toPosition}"`;
325
+ else if (toColor) result += ` to="${isRgb(toColor) ? `[${toColor}]` : toColor}"`;
326
+ }
327
+ return result;
328
+ }
329
+ const CONSTANTFLAG = "__transform_to_unocss__";
330
+ function matchMultipleBgAttrs(value) {
331
+ const map$2 = {};
332
+ let i = 0;
333
+ value = value.replace(/(rgba?|hsla?|lab|lch|hwb|color)\(\)*\)/, (_) => {
334
+ map$2[i++] = _;
335
+ return `${CONSTANTFLAG}${i}}`;
336
+ });
337
+ value = value.split(/\)\s*,/).map((item) => `${item.replace(/\s*,\s*/g, ",").replace(/\s+/g, "_")}`).join("),");
338
+ Object.keys(map$2).forEach((key) => {
339
+ value = value.replace(`${CONSTANTFLAG}${key}}`, map$2[key]);
340
+ });
341
+ return value;
342
+ }
343
+
344
+ //#endregion
345
+ //#region src/border.ts
346
+ const borderSize = [
347
+ "border-top",
348
+ "border-right",
349
+ "border-bottom",
350
+ "border-left"
351
+ ];
352
+ function border(key, val) {
353
+ let [value, important] = transformImportant(val);
354
+ if (key === "border-spacing") return `${key}="[${joinWithUnderLine(value)}]${important}"`;
355
+ if (key === "border-color") {
356
+ if (value.includes(" ")) {
357
+ const len = value.split(" ").length;
358
+ const vs = value.split(" ").map((s) => isHex(s) || isRgb(s) || isHsl(s) ? `-[${s}]` : `-${s}`);
359
+ const [top$1, right, bottom, left] = vs;
360
+ switch (len) {
361
+ case 2: return `border-y${top$1}${important} border-x${right}${important}`;
362
+ case 3: return `border-t${top$1}${important} border-b${bottom}${important} border-x${right}${important}`;
363
+ case 4: return `border-t${top$1}${important} border-b${bottom}${important} border-r${right}${important} border-l${left}${important}`;
364
+ }
365
+ }
366
+ return `border${getVal(value)}${important}`;
367
+ }
368
+ if (key === "border-radius") return isCalc(value) || !value.includes(" ") ? `border-rd${getVal(value)}${important}` : `border-rd="[${joinWithUnderLine(value)}]${important}"`;
369
+ if (borderSize.some((b) => key.startsWith(b))) return value.split(" ").map((v) => `border-${key.split("-")[1][0]}${getVal(v)}${important}`).join(" ");
370
+ if (key === "border-inline-end-width") return `border-e${getVal(value)}${important}`;
371
+ if (key === "border-inline-start-width") return `border-s${getVal(value)}${important}`;
372
+ if (key.startsWith("border-image")) return "";
373
+ if (key === "border-width" && value.includes(" ")) return value.split(" ").map((v, i) => `border-${borderSize[i].split("-")[1][0]}${getVal(v)}${important}`).join(" ");
374
+ if (/^\d[%|(px)rem]$/.test(value) || key === "border-collapse") return `border-${value}${important}`;
375
+ if (key === "border-width" || key === "border-style") return `border${getVal(value)}${important}`;
376
+ if (key === "border-color") {
377
+ if (value === "currentColor") return `border-current${important}`;
378
+ return `border${getVal(value)}${important}`;
379
+ }
380
+ return value.split(" ").map((v) => {
381
+ if (value === "currentColor") return `border-current${important}`;
382
+ return `border${getVal(v)}${important}`;
383
+ }).join(" ");
384
+ }
385
+
386
+ //#endregion
387
+ //#region src/color.ts
388
+ function color(key, val) {
389
+ const [value, important] = transformImportant(val);
390
+ return `text${getVal(value)}${important}`;
391
+ }
392
+
393
+ //#endregion
394
+ //#region src/column.ts
395
+ function column(key, val) {
396
+ const [value, important] = transformImportant(val);
397
+ if (key === "column-gap") return `gap-x-${value}${important}`;
398
+ return `${key}-${value}${important}`;
399
+ }
400
+
401
+ //#endregion
402
+ //#region src/content.ts
403
+ function content(key, val) {
404
+ const [value, important] = transformImportant(val);
405
+ return value === "\" \"" || value === "' '" ? `content-['_']${important}` : `content-[${value.replace(/"/g, "'")}]${important}`;
406
+ }
407
+
408
+ //#endregion
409
+ //#region src/cursor.ts
410
+ function cursor(key, val) {
411
+ const [value, important] = transformImportant(val);
412
+ return `${key}${getVal(value)}${important}`;
413
+ }
414
+
415
+ //#endregion
416
+ //#region src/display.ts
417
+ function display(key, val) {
418
+ const [value, important] = transformImportant(val);
419
+ if (value === "none") return `hidden${important}`;
420
+ if (value === "hidden") return `invisible${important}`;
421
+ return `${value}${important}`;
422
+ }
423
+
424
+ //#endregion
425
+ //#region src/empty.ts
426
+ const emptyMap = {
427
+ show: "visible",
428
+ hide: "hidden"
429
+ };
430
+ function empty(key, val) {
431
+ const [value, important] = transformImportant(val);
432
+ return `table-empty-cells-${emptyMap[value] ?? value}${important}`;
433
+ }
434
+
435
+ //#endregion
436
+ //#region src/flex.ts
437
+ const lastMaps = [
438
+ "flex-basis",
439
+ "flex-grow",
440
+ "flex-shrink"
441
+ ];
442
+ function flex(key, val) {
443
+ const [value, important] = transformImportant(val);
444
+ if (lastMaps.includes(key)) return `${getLastName(key)}${getVal(value)}${important}`;
445
+ if (value === "1") return `flex-1${important}`;
446
+ const firstVal = value[0];
447
+ if (key === "flex" && (firstVal === "0" || firstVal === "1")) return `flex="[${joinWithUnderLine(value)}]${important}"`;
448
+ return `${getFirstName(key)}-${value.replace("column", "col")}${important}`;
449
+ }
450
+
451
+ //#endregion
452
+ //#region src/float.ts
453
+ function float(key, val) {
454
+ const [value, important] = transformImportant(val);
455
+ return `${key}-${value}${important}`;
456
+ }
457
+
458
+ //#endregion
459
+ //#region src/font.ts
460
+ function font(key, val) {
461
+ const [value, important] = transformImportant(val);
462
+ if (key === "font-size") return `text-${value}${important}`;
463
+ if (key === "font-weight") return `font-${value}${important}`;
464
+ if (key === "font-family") {
465
+ const match = value.match(/ui-(\w{0,4})/);
466
+ if (!match) return `font-[${joinWithUnderLine(val)}]${important}`;
467
+ const [_, family] = match;
468
+ return `font-${family}${important}`;
469
+ }
470
+ if (key === "font-style") {
471
+ if (value === "normal") return `font-not-italic${important}`;
472
+ return `font-${value}${important}`;
473
+ }
474
+ if (key === "font-variant-numeric") {
475
+ if (value === "normal") return `normal-nums${important}`;
476
+ return `${value}${important}`;
477
+ }
478
+ return `font="${transformFont(value)}${important}"`;
479
+ }
480
+ function transformFont(v) {
481
+ return v.split(" ").map((item) => /^\d/.test(item) ? `text-${item}` : item).join(" ");
482
+ }
483
+
484
+ //#endregion
485
+ //#region src/grid.ts
486
+ function grid(key, val) {
487
+ const [value, important] = transformImportant(val);
488
+ if (key.startsWith("grid-template")) {
489
+ const matcher$1 = value.match(/repeat\s*\(\s*(\d+)/);
490
+ if (matcher$1) return `grid-${getLastName(key) === "rows" ? "rows" : "cols"}-${matcher$1[1]}${important}`;
491
+ return `grid-${getLastName(key) === "rows" ? "rows" : "cols"}-${value.includes(" ") ? `[${joinWithUnderLine(value)}]` : value}${important}`;
492
+ }
493
+ if (key === "grid-auto-flow") return `grid-flow-${joinWithLine(value).replace("column", "col")}${important}`;
494
+ if (key.startsWith("grid-auto")) {
495
+ const matcher$1 = value.match(/minmax\s*\(\s*0\s*,\s*1fr/);
496
+ return `auto-${getLastName(key) === "rows" ? "rows" : "cols"}-${matcher$1 ? "fr" : getFirstName(value)}${important}`;
497
+ }
498
+ const matcher = value.match(/span\s+(\d)/);
499
+ if (matcher) return `${key.slice(5).replace("column", "col")}-span-${matcher[1]}${important}`;
500
+ if (value === "1/-1") return `${key.slice(5).replace("column", "col")}-span-full${important}`;
501
+ return `${key.slice(5).replace("column", "col")}-${value}${important}`;
502
+ }
503
+
504
+ //#endregion
505
+ //#region src/inset.ts
506
+ function inset(key, val) {
507
+ const [value, important] = transformImportant(val);
508
+ if (key === "inset-inline-start") return `start${getVal(value)}${important}`;
509
+ if (key === "inset-inline-end") return `end${getVal(value)}${important}`;
510
+ return void 0;
511
+ }
512
+
513
+ //#endregion
514
+ //#region src/isolation.ts
515
+ function isolation(key, val) {
516
+ const [value, important] = transformImportant(val);
517
+ if (val === "isolate") return `${value}${important}`;
518
+ return `${key}-${value}${important}`;
519
+ }
520
+
521
+ //#endregion
522
+ //#region src/justify.ts
523
+ function justify(key, val) {
524
+ const [value, important] = transformImportant(val);
525
+ if (key === "justify-content") return `justify-${getLastName(value)}${important}`;
526
+ return `${key}-${getLastName(value)}${important}`;
527
+ }
528
+
529
+ //#endregion
530
+ //#region src/letter.ts
531
+ function letter(key, val) {
532
+ const [value, important] = transformImportant(val);
533
+ return `tracking-${value}${important}`;
534
+ }
535
+
536
+ //#endregion
537
+ //#region src/line.ts
538
+ const lineMap = {
539
+ 1: "none",
540
+ 1.25: "tight",
541
+ 1.375: "snug",
542
+ 1.5: "normal",
543
+ 1.625: "relaxed",
544
+ 2: "loose"
545
+ };
546
+ function line(key, val) {
547
+ const [value, important] = transformImportant(val);
548
+ if (value in lineMap) return `lh-${lineMap[value]}${important}`;
549
+ return `lh${getVal(value, (v) => /\d$/.test(v) ? `[${v}]` : v)}${important}`;
550
+ }
551
+
552
+ //#endregion
553
+ //#region src/list.ts
554
+ function list(key, val) {
555
+ const [value, important] = transformImportant(val);
556
+ return `${getFirstName(key)}${getVal(value)}${important}`;
557
+ }
558
+
559
+ //#endregion
560
+ //#region src/margin.ts
561
+ const map$1 = {
562
+ "margin-left": "ml",
563
+ "margin-right": "mr",
564
+ "margin-top": "mt",
565
+ "margin-bottom": "mb",
566
+ "margin-inline-start": "ms",
567
+ "margin-inline-end": "me",
568
+ "padding-left": "pl",
569
+ "padding-right": "pr",
570
+ "padding-top": "pt",
571
+ "padding-bottom": "pb",
572
+ "padding-inline-start": "ps",
573
+ "padding-inline-end": "pe"
574
+ };
575
+ function transformMargin(key, val) {
576
+ const [value, important] = transformImportant(val);
577
+ const specail = map$1[key];
578
+ if (specail) return `${specail}${getVal(value)}${important}`;
579
+ const values = value.split(" ");
580
+ const len = values.length;
581
+ if (len === 1) return `${key[0]}${getVal(values[0])}${important}`;
582
+ if (len === 2) return `${key[0]}x${getVal(values[1])}${important} ${key[0]}y${getVal(values[0])}${important}`;
583
+ if (len === 3) return `${key[0]}x${getVal(values[1])}${important} ${key[0]}t${getVal(values[0])}${important} ${key[0]}b${getVal(values[2])}${important}`;
584
+ return `${key[0]}t${getVal(values[0])}${important} ${key[0]}b${getVal(values[2])}${important} ${key[0]}l${getVal(values[3])}${important} ${key[0]}r${getVal(values[1])}${important}`;
585
+ }
586
+
587
+ //#endregion
588
+ //#region src/mask.ts
589
+ function mask(key, val) {
590
+ const [value, important] = transformImportant(val);
591
+ if ([
592
+ "mask-clip",
593
+ "mask-origin",
594
+ "mask-type"
595
+ ].includes(key)) return `${important}${key}-${getFirstName(value)}`;
596
+ if (["mask-mode", "mask-composite"].includes(key)) return `${important}${getFirstName(key)}-${getFirstName(value)}`;
597
+ if (["mask-position", "mask-size"].includes(key)) {
598
+ if (isCalc(value) || isUrl(value) || isHex(value) || isRgb(value) || isHsl(value) || isPercent(value) || isVar(value) || isCubicBezier(value)) return `${important}${key}${getVal(value)}`;
599
+ return `${important}${getFirstName(key)}-${joinWithLine(value)}`;
600
+ }
601
+ if (key === "mask-repeat") return `${important}${key}-${value}`;
602
+ if (key === "mask-image") {
603
+ const type = getGradient(value);
604
+ if (type) {
605
+ const newValue = value.replace(/rgba?\(([^)]+)\)/g, (all, v) => all.replace(v, v.replace(/\s*,\s*/g, commaReplacer)));
606
+ const matcher = newValue.match(linearGradientReg);
607
+ if (!matcher) return;
608
+ let [direction, from, via, to] = matcher.slice(1);
609
+ direction = direction.split(" ").map((item) => item[0]).join("");
610
+ return direction ? `${getLinearGradientPosition(`mask-${direction}`, from, via, to).trim()}` : getLinearGradientPosition(`mask-${type}`, from, via, to).trim();
611
+ }
612
+ return `${important}mask${getVal(value)}`;
613
+ }
614
+ return `${important}${key}${getVal(value)}`;
615
+ }
616
+ function getLinearGradientPosition(prefix, from, via, to) {
617
+ let result = "";
618
+ if (via && !to) {
619
+ to = via;
620
+ via = "";
621
+ }
622
+ if (from) {
623
+ from = from.replaceAll(commaReplacer, ",");
624
+ const [fromColor, fromPosition] = from.split(" ");
625
+ if (fromPosition) result += ` ${prefix}-from="${isRgb(fromColor) ? `[${fromColor}]` : fromColor} ${fromPosition}"`;
626
+ else if (fromColor) result += ` ${prefix}-from-${isRgb(fromColor) ? `[${fromColor}]` : fromColor}`;
627
+ }
628
+ if (via) {
629
+ via = via.replaceAll(commaReplacer, ",");
630
+ const [viaColor, viaPosition] = via.split(" ");
631
+ if (viaPosition) result += ` ${prefix}-via="${isRgb(viaColor) ? `[${viaColor}]` : viaColor} ${viaPosition}"`;
632
+ else if (viaColor) result += ` ${prefix}-via${isRgb(viaColor) ? `[${viaColor}]` : viaColor}`;
633
+ }
634
+ if (to) {
635
+ to = to.replaceAll(commaReplacer, ",");
636
+ const [toColor, toPosition] = to.split(" ");
637
+ if (toPosition) result += ` ${prefix}-to="${isRgb(toColor) ? `[${toColor}]` : toColor} ${toPosition}"`;
638
+ else if (toColor) result += ` ${prefix}-to-${isRgb(toColor) ? `[${toColor}]` : toColor}`;
639
+ }
640
+ return result;
641
+ }
642
+
643
+ //#endregion
644
+ //#region src/max.ts
645
+ function max(key, val) {
646
+ const [value, important] = transformImportant(val);
647
+ const all = key.split("-");
648
+ const attributeValue = isCalc(value) || isVar(value) ? getVal(value) : getVal(getFirstName(value));
649
+ return `${all[0]}-${all[1][0]}${attributeValue}${important}`;
650
+ }
651
+
652
+ //#endregion
653
+ //#region src/mix.ts
654
+ function mix(key, val) {
655
+ const [value, important] = transformImportant(val);
656
+ return `mix-blend-${value}${important}`;
657
+ }
658
+
659
+ //#endregion
660
+ //#region src/object.ts
661
+ function object(key, val) {
662
+ const [value, important] = transformImportant(val);
663
+ if (key === "object-position") return `${getFirstName(key)}-${joinWithLine(value)}${important}`;
664
+ return `${getFirstName(key)}-${value}${important}`;
665
+ }
666
+
667
+ //#endregion
668
+ //#region src/opacity.ts
669
+ function opacity(key, val) {
670
+ const [value, important] = transformImportant(val);
671
+ if (isPercent(val)) return `op-${value.replace("%", "")}${important}`;
672
+ return `op-${+value * 100}${important}`;
673
+ }
674
+
675
+ //#endregion
676
+ //#region src/outline.ts
677
+ function outline(key, val) {
678
+ const [value, important] = transformImportant(val);
679
+ if (key === "outline-offset") return `${key}-${value}${important}`;
680
+ return `${getFirstName(key)}-${value}${important}`;
681
+ }
682
+
683
+ //#endregion
684
+ //#region src/word.ts
685
+ function word(key, val) {
686
+ const [value, important] = transformImportant(val);
687
+ if (key.startsWith("word-spacing")) return `word-spacing${getVal(val)}${important}`;
688
+ if (value === "keep-all") return `break-keep${important}`;
689
+ if (value === "break-word") return `break-words${important}`;
690
+ return `break-${getLastName(value)}${important}`;
691
+ }
692
+
693
+ //#endregion
694
+ //#region src/overflow.ts.ts
695
+ function overflow(key, val) {
696
+ const [value, important] = transformImportant(val);
697
+ if (key === "overflow-wrap") return word(key, val);
698
+ return `${key}-${value}${important}`;
699
+ }
700
+
701
+ //#endregion
702
+ //#region src/overscroll.ts
703
+ function overscroll(key, val) {
704
+ const [value, important] = transformImportant(val);
705
+ const [prefix, _, suffix] = key.split("-");
706
+ if (suffix) return `${prefix}-${suffix}-${value}${important}`;
707
+ return `${prefix}-${value}${important}`;
708
+ }
709
+
710
+ //#endregion
711
+ //#region src/place.ts
712
+ function place(key, val) {
713
+ const [value, important] = transformImportant(val);
714
+ return `${key}-${getLastName(value)}${important}`;
715
+ }
716
+
717
+ //#endregion
718
+ //#region src/resize.ts
719
+ const map = {
720
+ vertical: "y",
721
+ horizontal: "x"
722
+ };
723
+ function resize(key, val) {
724
+ const [value, important] = transformImportant(val);
725
+ if (value === "both") return `${key}${important}`;
726
+ return `${key}-${map[value] || value}${important}`;
727
+ }
728
+
729
+ //#endregion
730
+ //#region src/rotate.ts
731
+ function rotate(key, val) {
732
+ const [value, important] = transformImportant(val);
733
+ if (value.includes(" ")) return `rotate-[${joinWithUnderLine(value)}]${important}`;
734
+ return `rotate${getVal(value)}${important}`;
735
+ }
736
+
737
+ //#endregion
738
+ //#region src/row.ts
739
+ function row(key, val) {
740
+ const [value, important] = transformImportant(val);
741
+ return `gap-y-${value}${important}`;
742
+ }
743
+
744
+ //#endregion
745
+ //#region src/scroll.ts
746
+ function scroll(key, val) {
747
+ const [value, important] = transformImportant(val);
748
+ if (key.startsWith("scroll-snap")) return `snap-${value}${important}`;
749
+ if (key === "scroll-behavior") return `scroll-${value}${important}`;
750
+ const [_, prefix, suffix, way] = key.match(/scroll-(margin|padding)-?(\w+)?-?(\w+)?/);
751
+ if (suffix === "inline" && way) return `scroll-${prefix[0]}${way[0]}${getVal(value)}${important}`;
752
+ if (suffix) return `scroll-${prefix[0]}${suffix[0]}${getVal(value)}${important}`;
753
+ return `scroll-${prefix[0]}-${value}${important}`;
754
+ }
755
+
756
+ //#endregion
757
+ //#region src/size.ts
758
+ function size(key, val) {
759
+ const [value, important] = transformImportant(val);
760
+ if (value.startsWith("-")) return `-${key[0]}${getVal(value.slice(1), getFirstName)}${important}`;
761
+ return `${key[0]}${getVal(value, getFirstName)}${important}`;
762
+ }
763
+
764
+ //#endregion
765
+ //#region src/text.ts
766
+ function text(key, val) {
767
+ const [value, important] = transformImportant(val);
768
+ if (key === "text-decoration-line") {
769
+ if (value === "none") return `no-underline${important}`;
770
+ return `${value}${important}`;
771
+ }
772
+ if (key === "text-transform") {
773
+ if (value === "none") return `normal-case${important}`;
774
+ return `${value}${important}`;
775
+ }
776
+ if (key.startsWith("text-decoration") || key === "text-indent") return `${key.split("-")[1]}${getVal(value)}${important}`;
777
+ if (key === "text-underline-offset") return `underline-offset-${value}${important}`;
778
+ return `text-${value}${important}`;
779
+ }
780
+
781
+ //#endregion
782
+ //#region src/top.ts
783
+ function top(key, val) {
784
+ const [value, important] = transformImportant(val);
785
+ return `${key}${getVal(value)}${important}`;
786
+ }
787
+
788
+ //#endregion
789
+ //#region src/transform.ts
790
+ function transform(key, val) {
791
+ const [v, important] = transformImportant(val);
792
+ if (key === "transform-origin") return `origin-${/\d/.test(v) && v.includes(" ") ? `[${joinWithUnderLine(v)}]` : joinWithLine(v)}${important}`;
793
+ if (key === "transform-style") return `transform-${v}${important}`;
794
+ if (val === "none") return `${key}-none${important}`;
795
+ return joinEmpty(v).split(" ").map((v$1) => {
796
+ const matcher = v$1.match(/([a-z]+)(3d)?([A-Z])?\((.*)\)/);
797
+ if (!matcher) return void 0;
798
+ const [_, namePrefix, is3d, nameSuffix, value] = matcher;
799
+ if (nameSuffix) {
800
+ const values = value.replace(/,(?![^()]*\))/g, " ").split(" ");
801
+ if (values.length > 1) return `${namePrefix}-${nameSuffix.toLowerCase()}="${values.map((v$2) => isVar(v$2) ? `[${v$2}]` : namePrefix === "scale" ? getHundred(v$2) : transformVal(v$2)).join(" ")}${important}"`;
802
+ return `${namePrefix}="${nameSuffix.toLowerCase()}-${isVar(values[0]) ? `[${values[0]}]` : namePrefix === "scale" ? getHundred(values[0]) : transformVal(values[0])}${important}"`;
803
+ } else {
804
+ const values = value.replace(/,(?![^()]*\))/g, " ").split(" ");
805
+ if (values.length > 1) {
806
+ if (namePrefix === "translate") return `${namePrefix}="[${values.join(",")}]"`;
807
+ return `${namePrefix}="${values.map((v$2) => isVar(v$2) ? `[${v$2}]` : namePrefix === "scale" ? getHundred(v$2) : transformVal(v$2)).join(" ")}${important}"`;
808
+ }
809
+ return `${namePrefix}="${isVar(values[0]) ? `[${values[0]}]` : namePrefix === "scale" ? getHundred(values[0]) : transformVal(values[0])}${important}"`;
810
+ }
811
+ }).filter(Boolean).join(" ");
812
+ }
813
+ function transformVal(val) {
814
+ if (val.endsWith("deg")) return val.slice(0, -3);
815
+ return val;
816
+ }
817
+
818
+ //#endregion
819
+ //#region src/transition.ts
820
+ const times = ["transition-delay", "transition-duration"];
821
+ function transition(key, val) {
822
+ const [value, important] = transformImportant(val);
823
+ if (key === "transition-timing-function") {
824
+ if (value === "linear") return `ease-${value}${important}`;
825
+ return `ease="[${value}]${important}"`;
826
+ }
827
+ if (key === "transition") return `transition="${transformTransition(value, important)}"`;
828
+ if (key === "transition-property") {
829
+ if (value.includes("color")) return `transition-color${important}`;
830
+ if (value === "box-shadow") return `transition-shadow${important}`;
831
+ return `transition-${value}${important}`;
832
+ }
833
+ if (times.includes(key)) return `${key.split("-")[1]}-${value.slice(0, -2)}${important}`;
834
+ }
835
+ function transformTransition(v, important) {
836
+ let hasDuration = false;
837
+ return v.split(" ").map((item) => {
838
+ if (/^\d/.test(item) || /^\.\d/.test(item)) {
839
+ if (hasDuration) return `delay${getVal(item, void 0, true)}${important}`;
840
+ hasDuration = true;
841
+ return `duration${getVal(item, void 0, true)}${important}`;
842
+ }
843
+ if (item === "background-color") return "colors";
844
+ return item;
845
+ }).join(" ");
846
+ }
847
+
848
+ //#endregion
849
+ //#region src/user.ts
850
+ function user(key, val) {
851
+ const [value, important] = transformImportant(val);
852
+ return `${getLastName(key)}-${value}${important}`;
853
+ }
854
+
855
+ //#endregion
856
+ //#region src/vertical.ts
857
+ function vertical(key, val) {
858
+ const [value, important] = transformImportant(val);
859
+ return `v-${value}${important}`;
860
+ }
861
+
862
+ //#endregion
863
+ //#region src/white.ts
864
+ function white(key, val) {
865
+ const [value, important] = transformImportant(val);
866
+ return `whitespace-${value}${important}`;
867
+ }
868
+
869
+ //#endregion
870
+ //#region src/will.ts
871
+ function will(key, val) {
872
+ const [value, important] = transformImportant(val);
873
+ return `${key}-${getFirstName(value)}${important}`;
874
+ }
875
+
876
+ //#endregion
877
+ //#region src/writing.ts
878
+ function writing(key, val) {
879
+ const [value, important] = transformImportant(val);
880
+ if (val === "horizontal-tb") return `write-normal${important}`;
881
+ return `write-${value.replace("-rl", "-right").replace("-lr", "-left")}${important}`;
882
+ }
883
+
884
+ //#endregion
885
+ //#region src/toUnocss.ts
886
+ const typeMap = {
887
+ animation,
888
+ aspect,
889
+ backface: list,
890
+ caption: list,
891
+ column,
892
+ columns: float,
893
+ break: float,
894
+ empty,
895
+ box,
896
+ writing,
897
+ display,
898
+ float,
899
+ clear: float,
900
+ isolation,
901
+ object,
902
+ overflow,
903
+ overscroll,
904
+ position: display,
905
+ top,
906
+ left: top,
907
+ right: top,
908
+ bottom: top,
909
+ visibility: display,
910
+ z: size,
911
+ flex,
912
+ order: float,
913
+ grid,
914
+ gap: top,
915
+ justify,
916
+ align,
917
+ place,
918
+ padding: transformMargin,
919
+ perspective: float,
920
+ margin: transformMargin,
921
+ width: size,
922
+ min: max,
923
+ max,
924
+ height: size,
925
+ font,
926
+ letter,
927
+ line,
928
+ list,
929
+ text,
930
+ mask,
931
+ hyphens: top,
932
+ vertical,
933
+ white,
934
+ word,
935
+ content,
936
+ background,
937
+ rotate,
938
+ border,
939
+ outline,
940
+ opacity,
941
+ mix,
942
+ filter,
943
+ backdrop,
944
+ table: list,
945
+ transition,
946
+ transform,
947
+ accent: list,
948
+ appearance: list,
949
+ cursor,
950
+ caret: list,
951
+ pointer: float,
952
+ resize,
953
+ scroll,
954
+ inset,
955
+ touch: list,
956
+ user,
957
+ will,
958
+ fill: float,
959
+ stroke: list,
960
+ color,
961
+ row
962
+ };
963
+ const splitReg = /([\w-]+)\s*:\s*([^;]+)/;
964
+ function toUnocss(css, isRem = false) {
965
+ var _typeMap$first;
966
+ css = css.replace(browserReg, "");
967
+ const match = css.match(splitReg);
968
+ if (!match) return;
969
+ const [_, key, val] = match;
970
+ const first = getFirstName(key);
971
+ const result = (_typeMap$first = typeMap[first]) === null || _typeMap$first === void 0 ? void 0 : _typeMap$first.call(typeMap, key, val);
972
+ if (result && isRem) return result.replace(/-([0-9.]+)px/, (_$1, v) => `-${+v / 4}`).replace(/\[[^\]]+\]/g, (match$1) => match$1.replace(/([0-9.]+)px/g, (_$1, v) => `${+v / 16}rem`));
973
+ return result;
974
+ }
975
+
976
+ //#endregion
977
+ //#region src/transformer.ts
978
+ function createRuleProcessor(config) {
979
+ return (v) => {
980
+ const anyMatch = config.anyMatch || [];
981
+ const priority = config.priority || [];
982
+ let matchedAnyRule = null;
983
+ if (anyMatch.length > 0) {
984
+ matchedAnyRule = anyMatch.find((rule) => v[rule.key] && (rule.pattern instanceof RegExp ? rule.pattern.test(v[rule.key]) : v[rule.key] === rule.pattern));
985
+ if (!matchedAnyRule) return {
986
+ transformedResult: "",
987
+ deleteKeys: []
988
+ };
989
+ }
990
+ let valueToUse = "";
991
+ if (anyMatch.length > 0 && priority.length > 0) for (const key of priority) {
992
+ const rule = anyMatch.find((r) => r.key === key);
993
+ if (rule && v[key] && (rule.pattern instanceof RegExp ? rule.pattern.test(v[key]) : v[key] === rule.pattern)) {
994
+ valueToUse = v[key];
995
+ break;
996
+ }
997
+ }
998
+ const allMatchRules = { ...config.allMatch };
999
+ const allMatchKeys = Object.keys(allMatchRules);
1000
+ for (const key of allMatchKeys) {
1001
+ const expectedValue = allMatchRules[key];
1002
+ if (!(expectedValue instanceof RegExp ? expectedValue.test(v[key]) : v[key] === expectedValue)) return {
1003
+ transformedResult: "",
1004
+ deleteKeys: []
1005
+ };
1006
+ }
1007
+ const deleteKeys = [...allMatchKeys, ...anyMatch.map((rule) => rule.key)];
1008
+ const transformedResult = typeof config.outputTemplate === "function" ? config.outputTemplate(valueToUse) : config.outputTemplate.replace("${value}", valueToUse);
1009
+ return {
1010
+ transformedResult,
1011
+ deleteKeys
1012
+ };
1013
+ };
1014
+ }
1015
+ const transformer = {
1016
+ "line-clamp-${number}": createRuleProcessor({
1017
+ allMatch: {
1018
+ "overflow": "hidden",
1019
+ "display": "-webkit-box",
1020
+ "-webkit-box-orient": "vertical"
1021
+ },
1022
+ anyMatch: [{
1023
+ key: "-webkit-line-clamp",
1024
+ pattern: /\d/
1025
+ }, {
1026
+ key: "line-clamp",
1027
+ pattern: /\d/
1028
+ }],
1029
+ priority: ["line-clamp", "-webkit-line-clamp"],
1030
+ outputTemplate: (value) => `line-clamp-${value}`
1031
+ }),
1032
+ "line-clamp-${prop}": createRuleProcessor({
1033
+ allMatch: {
1034
+ "overflow": "visible",
1035
+ "display": "block",
1036
+ "-webkit-box-orient": "horizontal"
1037
+ },
1038
+ anyMatch: [{
1039
+ key: "-webkit-line-clamp",
1040
+ pattern: /inherit|initial|revert|unset/
1041
+ }, {
1042
+ key: "line-clamp",
1043
+ pattern: /inherit|initial|revert|unset/
1044
+ }],
1045
+ priority: ["line-clamp", "-webkit-line-clamp"],
1046
+ outputTemplate: (value) => `line-clamp-${value}`
1047
+ }),
1048
+ "truncate": createRuleProcessor({
1049
+ allMatch: {
1050
+ "overflow": "hidden",
1051
+ "text-overflow": "ellipsis",
1052
+ "white-space": "nowrap"
1053
+ },
1054
+ outputTemplate: () => "truncate"
1055
+ })
1056
+ };
1057
+ function transformStyleToUnocssPre(styles) {
1058
+ const preTransformedList = [];
1059
+ const styleToObj = styles.split(";").reduce((r, item) => {
1060
+ const [key, value] = item.split(":");
1061
+ if (key.trim() && value.trim()) r[key.trim()] = value.trim();
1062
+ return r;
1063
+ }, {});
1064
+ for (const key in transformer) {
1065
+ const { transformedResult, deleteKeys } = transformer[key](styleToObj);
1066
+ if (transformedResult && deleteKeys.length) {
1067
+ preTransformedList.push(transformedResult);
1068
+ deleteKeys.forEach((deleteKey) => {
1069
+ delete styleToObj[deleteKey];
1070
+ });
1071
+ }
1072
+ }
1073
+ return {
1074
+ transformedResult: preTransformedList.join(" "),
1075
+ newStyle: Object.entries(styleToObj).map(([key, value]) => `${key}: ${value}`).join("; ")
1076
+ };
1077
+ }
1078
+
1079
+ //#endregion
1080
+ //#region src/transformStyleToUnocss.ts
1081
+ function transformStyleToUnocss(styles, isRem) {
1082
+ const noTransfer = [];
1083
+ const cache = new Set();
1084
+ const { newStyle, transformedResult } = transformStyleToUnocssPre(styles);
1085
+ if (transformedResult) return [[transformedResult, newStyle.split(";").filter(Boolean).reduce((result, cur) => {
1086
+ const key = cur.replaceAll(browserReg, "").trim();
1087
+ if (cache.has(key)) return result;
1088
+ cache.add(key);
1089
+ const val = toUnocss(cur, isRem) || "";
1090
+ if (!val) noTransfer.push(cur);
1091
+ return result += `${val} `;
1092
+ }, "").trim().replace(/\s+/g, " ")].filter(Boolean).join(" "), noTransfer];
1093
+ return [styles.split(";").filter(Boolean).reduce((result, cur) => {
1094
+ const key = cur.replaceAll(browserReg, "").trim();
1095
+ if (cache.has(key)) return result;
1096
+ cache.add(key);
1097
+ const val = toUnocss(cur, isRem) || "";
1098
+ if (!val) noTransfer.push(cur);
1099
+ return result += `${val} `;
1100
+ }, "").trim().replace(/\s+/g, " "), noTransfer];
1101
+ }
1102
+
1103
+ //#endregion
1104
+ //#region src/toUnocssClass.ts
1105
+ function toUnocssClass(css, isRem = false) {
1106
+ const [transferred, noTransferred] = transformStyleToUnocss(css, isRem);
1107
+ return [transferred ? transferred.replace(/([^\s=]+)="([^"]+)"/g, (_, v1, v2) => v2.split(" ").map((v) => `${v1}-${v}`).join(" ")) : "", noTransferred];
1108
+ }
1109
+
1110
+ //#endregion
1111
+ exports.browserReg = browserReg
1112
+ exports.commaReplacer = commaReplacer
1113
+ exports.cssMathFnRE = cssMathFnRE
1114
+ exports.diffTemplateStyle = diffTemplateStyle
1115
+ exports.flag = flag
1116
+ exports.getFirstName = getFirstName
1117
+ exports.getGradient = getGradient
1118
+ exports.getHundred = getHundred
1119
+ exports.getLastName = getLastName
1120
+ exports.getStyleScoped = getStyleScoped
1121
+ exports.getVal = getVal
1122
+ exports.isCalc = isCalc
1123
+ exports.isColor = isColor
1124
+ exports.isCubicBezier = isCubicBezier
1125
+ exports.isEmptyStyle = isEmptyStyle
1126
+ exports.isHex = isHex
1127
+ exports.isHsl = isHsl
1128
+ exports.isNot = isNot
1129
+ exports.isPercent = isPercent
1130
+ exports.isRgb = isRgb
1131
+ exports.isSize = isSize
1132
+ exports.isUrl = isUrl
1133
+ exports.isVar = isVar
1134
+ exports.joinEmpty = joinEmpty
1135
+ exports.joinWithLine = joinWithLine
1136
+ exports.joinWithUnderLine = joinWithUnderLine
1137
+ exports.linearGradientReg = linearGradientReg
1138
+ exports.linearGradientReg1 = linearGradientReg1
1139
+ exports.numberWithUnitRE = numberWithUnitRE
1140
+ exports.otherGradientReg = otherGradientReg
1141
+ exports.positionMap = positionMap
1142
+ exports.toUnocss = toUnocss
1143
+ exports.toUnocssClass = toUnocssClass
1144
+ exports.transformImportant = transformImportant
1145
+ exports.transformStyleToUnocss = transformStyleToUnocss
1146
+ exports.transformStyleToUnocssPre = transformStyleToUnocssPre
1147
+ exports.trim = trim