@csszyx/compiler 0.1.0

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.js ADDED
@@ -0,0 +1,2820 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/compiler.ts
9
+ import { init, transform_sz, version as getWasmVersion } from "@csszyx/core";
10
+
11
+ // src/transform.ts
12
+ import * as babel from "@babel/core";
13
+ import * as t from "@babel/types";
14
+
15
+ // src/property-types.ts
16
+ var PropertyCategory = /* @__PURE__ */ ((PropertyCategory2) => {
17
+ PropertyCategory2[PropertyCategory2["SPACING"] = 0] = "SPACING";
18
+ PropertyCategory2[PropertyCategory2["COLOR"] = 1] = "COLOR";
19
+ PropertyCategory2[PropertyCategory2["FRACTION"] = 2] = "FRACTION";
20
+ PropertyCategory2[PropertyCategory2["UNITLESS"] = 3] = "UNITLESS";
21
+ PropertyCategory2[PropertyCategory2["ANGLE"] = 4] = "ANGLE";
22
+ PropertyCategory2[PropertyCategory2["DURATION"] = 5] = "DURATION";
23
+ PropertyCategory2[PropertyCategory2["ARBITRARY"] = 6] = "ARBITRARY";
24
+ PropertyCategory2[PropertyCategory2["PASSTHROUGH"] = 7] = "PASSTHROUGH";
25
+ return PropertyCategory2;
26
+ })(PropertyCategory || {});
27
+ var PROPERTY_CATEGORY_MAP = {
28
+ // ---- SPACING ----
29
+ p: 0 /* SPACING */,
30
+ pt: 0 /* SPACING */,
31
+ pr: 0 /* SPACING */,
32
+ pb: 0 /* SPACING */,
33
+ pl: 0 /* SPACING */,
34
+ px: 0 /* SPACING */,
35
+ py: 0 /* SPACING */,
36
+ ps: 0 /* SPACING */,
37
+ pe: 0 /* SPACING */,
38
+ m: 0 /* SPACING */,
39
+ mt: 0 /* SPACING */,
40
+ mr: 0 /* SPACING */,
41
+ mb: 0 /* SPACING */,
42
+ ml: 0 /* SPACING */,
43
+ mx: 0 /* SPACING */,
44
+ my: 0 /* SPACING */,
45
+ ms: 0 /* SPACING */,
46
+ me: 0 /* SPACING */,
47
+ spaceX: 0 /* SPACING */,
48
+ spaceY: 0 /* SPACING */,
49
+ gap: 0 /* SPACING */,
50
+ gapX: 0 /* SPACING */,
51
+ gapY: 0 /* SPACING */,
52
+ inset: 0 /* SPACING */,
53
+ insetX: 0 /* SPACING */,
54
+ insetY: 0 /* SPACING */,
55
+ top: 0 /* SPACING */,
56
+ right: 0 /* SPACING */,
57
+ bottom: 0 /* SPACING */,
58
+ left: 0 /* SPACING */,
59
+ start: 0 /* SPACING */,
60
+ end: 0 /* SPACING */,
61
+ w: 0 /* SPACING */,
62
+ minW: 0 /* SPACING */,
63
+ maxW: 0 /* SPACING */,
64
+ h: 0 /* SPACING */,
65
+ minH: 0 /* SPACING */,
66
+ maxH: 0 /* SPACING */,
67
+ size: 0 /* SPACING */,
68
+ basis: 0 /* SPACING */,
69
+ indent: 0 /* SPACING */,
70
+ scrollM: 0 /* SPACING */,
71
+ scrollMt: 0 /* SPACING */,
72
+ scrollMr: 0 /* SPACING */,
73
+ scrollMb: 0 /* SPACING */,
74
+ scrollMl: 0 /* SPACING */,
75
+ scrollMs: 0 /* SPACING */,
76
+ scrollMe: 0 /* SPACING */,
77
+ scrollMx: 0 /* SPACING */,
78
+ scrollMy: 0 /* SPACING */,
79
+ scrollP: 0 /* SPACING */,
80
+ scrollPt: 0 /* SPACING */,
81
+ scrollPr: 0 /* SPACING */,
82
+ scrollPb: 0 /* SPACING */,
83
+ scrollPl: 0 /* SPACING */,
84
+ scrollPs: 0 /* SPACING */,
85
+ scrollPe: 0 /* SPACING */,
86
+ scrollPx: 0 /* SPACING */,
87
+ scrollPy: 0 /* SPACING */,
88
+ translateX: 0 /* SPACING */,
89
+ translateY: 0 /* SPACING */,
90
+ borderSpacing: 0 /* SPACING */,
91
+ borderSpacingX: 0 /* SPACING */,
92
+ borderSpacingY: 0 /* SPACING */,
93
+ outlineOffset: 0 /* SPACING */,
94
+ ringOffset: 0 /* SPACING */,
95
+ underlineOffset: 0 /* SPACING */,
96
+ // ---- COLOR ----
97
+ bg: 1 /* COLOR */,
98
+ color: 1 /* COLOR */,
99
+ borderColor: 1 /* COLOR */,
100
+ divideColor: 1 /* COLOR */,
101
+ outlineColor: 1 /* COLOR */,
102
+ ringColor: 1 /* COLOR */,
103
+ ringOffsetColor: 1 /* COLOR */,
104
+ shadowColor: 1 /* COLOR */,
105
+ textShadowColor: 1 /* COLOR */,
106
+ decorationColor: 1 /* COLOR */,
107
+ accent: 1 /* COLOR */,
108
+ caret: 1 /* COLOR */,
109
+ fill: 1 /* COLOR */,
110
+ stroke: 1 /* COLOR */,
111
+ from: 1 /* COLOR */,
112
+ via: 1 /* COLOR */,
113
+ to: 1 /* COLOR */,
114
+ dropShadowColor: 1 /* COLOR */,
115
+ // ---- UNITLESS ----
116
+ opacity: 3 /* UNITLESS */,
117
+ z: 3 /* UNITLESS */,
118
+ order: 3 /* UNITLESS */,
119
+ columns: 3 /* UNITLESS */,
120
+ gridCols: 3 /* UNITLESS */,
121
+ gridRows: 3 /* UNITLESS */,
122
+ col: 3 /* UNITLESS */,
123
+ colSpan: 3 /* UNITLESS */,
124
+ colStart: 3 /* UNITLESS */,
125
+ colEnd: 3 /* UNITLESS */,
126
+ row: 3 /* UNITLESS */,
127
+ rowSpan: 3 /* UNITLESS */,
128
+ rowStart: 3 /* UNITLESS */,
129
+ rowEnd: 3 /* UNITLESS */,
130
+ lineClamp: 3 /* UNITLESS */,
131
+ grow: 3 /* UNITLESS */,
132
+ shrink: 3 /* UNITLESS */,
133
+ scale: 3 /* UNITLESS */,
134
+ scaleX: 3 /* UNITLESS */,
135
+ scaleY: 3 /* UNITLESS */,
136
+ brightness: 3 /* UNITLESS */,
137
+ contrast: 3 /* UNITLESS */,
138
+ saturate: 3 /* UNITLESS */,
139
+ hueRotate: 3 /* UNITLESS */,
140
+ backdropBrightness: 3 /* UNITLESS */,
141
+ backdropContrast: 3 /* UNITLESS */,
142
+ backdropSaturate: 3 /* UNITLESS */,
143
+ backdropHueRotate: 3 /* UNITLESS */,
144
+ backdropOpacity: 3 /* UNITLESS */,
145
+ strokeWidth: 3 /* UNITLESS */,
146
+ border: 3 /* UNITLESS */,
147
+ borderT: 3 /* UNITLESS */,
148
+ borderR: 3 /* UNITLESS */,
149
+ borderB: 3 /* UNITLESS */,
150
+ borderL: 3 /* UNITLESS */,
151
+ borderX: 3 /* UNITLESS */,
152
+ borderY: 3 /* UNITLESS */,
153
+ borderS: 3 /* UNITLESS */,
154
+ borderE: 3 /* UNITLESS */,
155
+ ring: 3 /* UNITLESS */,
156
+ outline: 3 /* UNITLESS */,
157
+ leading: 3 /* UNITLESS */,
158
+ decorationThickness: 3 /* UNITLESS */,
159
+ // ---- ANGLE ----
160
+ rotate: 4 /* ANGLE */,
161
+ skewX: 4 /* ANGLE */,
162
+ skewY: 4 /* ANGLE */,
163
+ // ---- DURATION ----
164
+ duration: 5 /* DURATION */,
165
+ delay: 5 /* DURATION */
166
+ };
167
+ function getPropertyCategory(property) {
168
+ return PROPERTY_CATEGORY_MAP[property] ?? 7 /* PASSTHROUGH */;
169
+ }
170
+ var COLOR_PROPERTIES = new Set(
171
+ Object.entries(PROPERTY_CATEGORY_MAP).filter(([, cat]) => cat === 1 /* COLOR */).map(([key]) => key)
172
+ );
173
+ function getCSSVariableName(property, variantPrefix) {
174
+ const prop = property.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
175
+ if (variantPrefix) {
176
+ return `--_sz-${variantPrefix}-${prop}`;
177
+ }
178
+ return `--_sz-${prop}`;
179
+ }
180
+
181
+ // src/transform-core.ts
182
+ var PROPERTY_MAP = {
183
+ // Background
184
+ bg: "bg",
185
+ bgAttach: "bg",
186
+ bgClip: "bg-clip",
187
+ bgImg: "bg",
188
+ bgOrigin: "bg-origin",
189
+ bgPos: "bg",
190
+ bgRepeat: "bg",
191
+ bgSize: "bg",
192
+ // Gradient color stops
193
+ from: "from",
194
+ via: "via",
195
+ to: "to",
196
+ // Border Radius
197
+ rounded: "rounded",
198
+ roundedT: "rounded-t",
199
+ roundedR: "rounded-r",
200
+ roundedB: "rounded-b",
201
+ roundedL: "rounded-l",
202
+ roundedTl: "rounded-tl",
203
+ roundedTr: "rounded-tr",
204
+ roundedBl: "rounded-bl",
205
+ roundedBr: "rounded-br",
206
+ roundedS: "rounded-s",
207
+ roundedE: "rounded-e",
208
+ roundedSs: "rounded-ss",
209
+ roundedSe: "rounded-se",
210
+ roundedEs: "rounded-es",
211
+ roundedEe: "rounded-ee",
212
+ // Border
213
+ border: "border",
214
+ borderColor: "border",
215
+ borderStyle: "border",
216
+ borderT: "border-t",
217
+ borderR: "border-r",
218
+ borderB: "border-b",
219
+ borderL: "border-l",
220
+ borderX: "border-x",
221
+ borderY: "border-y",
222
+ borderS: "border-s",
223
+ borderE: "border-e",
224
+ // Divide
225
+ divideX: "divide-x",
226
+ divideY: "divide-y",
227
+ divideColor: "divide",
228
+ divideStyle: "divide",
229
+ // Outline
230
+ outline: "outline",
231
+ outlineColor: "outline",
232
+ outlineOffset: "outline-offset",
233
+ outlineStyle: "outline",
234
+ // Ring (v3 — keep for future v3 support)
235
+ ring: "ring",
236
+ ringColor: "ring",
237
+ ringOffset: "ring-offset",
238
+ ringOffsetColor: "ring-offset",
239
+ // Spacing (canonical shorthand only)
240
+ p: "p",
241
+ pt: "pt",
242
+ pr: "pr",
243
+ pb: "pb",
244
+ pl: "pl",
245
+ px: "px",
246
+ py: "py",
247
+ ps: "ps",
248
+ pe: "pe",
249
+ m: "m",
250
+ mt: "mt",
251
+ mr: "mr",
252
+ mb: "mb",
253
+ ml: "ml",
254
+ mx: "mx",
255
+ my: "my",
256
+ ms: "ms",
257
+ me: "me",
258
+ // Space between
259
+ spaceX: "space-x",
260
+ spaceY: "space-y",
261
+ // Sizing (canonical shorthand only)
262
+ w: "w",
263
+ minW: "min-w",
264
+ maxW: "max-w",
265
+ h: "h",
266
+ minH: "min-h",
267
+ maxH: "max-h",
268
+ size: "size",
269
+ // Layout
270
+ aspect: "aspect",
271
+ columns: "columns",
272
+ breakAfter: "break-after",
273
+ breakBefore: "break-before",
274
+ breakInside: "break-inside",
275
+ boxDecoration: "box-decoration",
276
+ box: "box",
277
+ float: "float",
278
+ clear: "clear",
279
+ isolation: "isolation",
280
+ objectFit: "object",
281
+ objectPos: "object",
282
+ overflowX: "overflow-x",
283
+ overflowY: "overflow-y",
284
+ overscroll: "overscroll",
285
+ overscrollX: "overscroll-x",
286
+ overscrollY: "overscroll-y",
287
+ z: "z",
288
+ position: "position",
289
+ display: "display",
290
+ // Inset
291
+ inset: "inset",
292
+ insetX: "inset-x",
293
+ insetY: "inset-y",
294
+ top: "top",
295
+ right: "right",
296
+ bottom: "bottom",
297
+ left: "left",
298
+ start: "start",
299
+ end: "end",
300
+ // Visibility
301
+ visibility: "visibility",
302
+ // Typography
303
+ color: "text",
304
+ text: "text",
305
+ fontWeight: "font",
306
+ font: "font",
307
+ fontFamily: "font",
308
+ fontStretch: "font-stretch",
309
+ textAlign: "text",
310
+ decoration: "decoration",
311
+ decorationColor: "decoration",
312
+ decorationStyle: "decoration",
313
+ decorationThickness: "decoration",
314
+ underlineOffset: "underline-offset",
315
+ textTransform: "text",
316
+ textOverflow: "text",
317
+ textWrap: "text",
318
+ wrap: "wrap",
319
+ indent: "indent",
320
+ align: "align",
321
+ whitespace: "whitespace",
322
+ break: "break",
323
+ hyphens: "hyphens",
324
+ content: "content",
325
+ leading: "leading",
326
+ tracking: "tracking",
327
+ lineClamp: "line-clamp",
328
+ list: "list",
329
+ listPos: "list",
330
+ listImg: "list-image",
331
+ // Flex & Grid
332
+ basis: "basis",
333
+ flexDir: "flex",
334
+ flexWrap: "flex",
335
+ grow: "grow",
336
+ shrink: "shrink",
337
+ order: "order",
338
+ items: "items",
339
+ self: "self",
340
+ justify: "justify",
341
+ justifyItems: "justify-items",
342
+ justifySelf: "justify-self",
343
+ placeContent: "place-content",
344
+ placeItems: "place-items",
345
+ placeSelf: "place-self",
346
+ gap: "gap",
347
+ gapX: "gap-x",
348
+ gapY: "gap-y",
349
+ // Grid
350
+ gridCols: "grid-cols",
351
+ gridRows: "grid-rows",
352
+ col: "col",
353
+ colSpan: "col-span",
354
+ colStart: "col-start",
355
+ colEnd: "col-end",
356
+ row: "row",
357
+ rowSpan: "row-span",
358
+ rowStart: "row-start",
359
+ rowEnd: "row-end",
360
+ gridFlow: "grid-flow",
361
+ autoCols: "auto-cols",
362
+ autoRows: "auto-rows",
363
+ // Effects
364
+ shadow: "shadow",
365
+ shadowColor: "shadow",
366
+ insetShadow: "inset-shadow",
367
+ textShadow: "text-shadow",
368
+ textShadowColor: "text-shadow",
369
+ opacity: "opacity",
370
+ mixBlend: "mix-blend",
371
+ bgBlend: "bg-blend",
372
+ // Filters
373
+ blur: "blur",
374
+ brightness: "brightness",
375
+ contrast: "contrast",
376
+ dropShadow: "drop-shadow",
377
+ dropShadowColor: "drop-shadow",
378
+ grayscale: "grayscale",
379
+ hueRotate: "hue-rotate",
380
+ invert: "invert",
381
+ saturate: "saturate",
382
+ sepia: "sepia",
383
+ backdropBlur: "backdrop-blur",
384
+ backdropBrightness: "backdrop-brightness",
385
+ backdropContrast: "backdrop-contrast",
386
+ backdropGrayscale: "backdrop-grayscale",
387
+ backdropHueRotate: "backdrop-hue-rotate",
388
+ backdropInvert: "backdrop-invert",
389
+ backdropOpacity: "backdrop-opacity",
390
+ backdropSaturate: "backdrop-saturate",
391
+ backdropSepia: "backdrop-sepia",
392
+ // Transforms
393
+ scale: "scale",
394
+ scaleX: "scale-x",
395
+ scaleY: "scale-y",
396
+ rotate: "rotate",
397
+ translateX: "translate-x",
398
+ translateY: "translate-y",
399
+ skewX: "skew-x",
400
+ skewY: "skew-y",
401
+ origin: "origin",
402
+ backface: "backface",
403
+ perspective: "perspective",
404
+ perspectiveOrigin: "perspective-origin",
405
+ transformStyle: "transform",
406
+ // Transitions & Animation
407
+ transition: "transition",
408
+ transitionBehavior: "transition",
409
+ duration: "duration",
410
+ ease: "ease",
411
+ delay: "delay",
412
+ animate: "animate",
413
+ // Masks
414
+ mask: "mask",
415
+ maskSize: "mask-size",
416
+ maskPos: "mask-position",
417
+ maskRepeat: "mask-repeat",
418
+ maskShape: "mask",
419
+ // Interactivity
420
+ cursor: "cursor",
421
+ caret: "caret",
422
+ pointerEvents: "pointer-events",
423
+ resize: "resize",
424
+ scroll: "scroll",
425
+ scrollM: "scroll-m",
426
+ scrollMt: "scroll-mt",
427
+ scrollMr: "scroll-mr",
428
+ scrollMb: "scroll-mb",
429
+ scrollMl: "scroll-ml",
430
+ scrollMs: "scroll-ms",
431
+ scrollMe: "scroll-me",
432
+ scrollMx: "scroll-mx",
433
+ scrollMy: "scroll-my",
434
+ scrollP: "scroll-p",
435
+ scrollPt: "scroll-pt",
436
+ scrollPr: "scroll-pr",
437
+ scrollPb: "scroll-pb",
438
+ scrollPl: "scroll-pl",
439
+ scrollPs: "scroll-ps",
440
+ scrollPe: "scroll-pe",
441
+ scrollPx: "scroll-px",
442
+ scrollPy: "scroll-py",
443
+ snapAlign: "snap",
444
+ snapStop: "snap",
445
+ snapType: "snap",
446
+ touch: "touch",
447
+ select: "select",
448
+ willChange: "will-change",
449
+ appearance: "appearance",
450
+ accent: "accent",
451
+ forcedColorAdjust: "forced-color-adjust",
452
+ // SVG
453
+ fill: "fill",
454
+ stroke: "stroke",
455
+ strokeWidth: "stroke",
456
+ // Tables
457
+ borderCollapse: "border",
458
+ borderSpacing: "border-spacing",
459
+ borderSpacingX: "border-spacing-x",
460
+ borderSpacingY: "border-spacing-y",
461
+ tableLayout: "table",
462
+ caption: "caption",
463
+ // Overflow
464
+ overflow: "overflow"
465
+ };
466
+ var SUGGESTION_MAP = {
467
+ // Background
468
+ backgroundColor: "bg",
469
+ backgroundImage: "bgImg",
470
+ backgroundSize: "bgSize",
471
+ backgroundPosition: "bgPos",
472
+ backgroundRepeat: "bgRepeat",
473
+ bgAttachment: "bgAttach",
474
+ bgImage: "bgImg",
475
+ // Border Radius
476
+ borderRadius: "rounded",
477
+ borderTopLeftRadius: "roundedTl",
478
+ borderTopRightRadius: "roundedTr",
479
+ borderBottomLeftRadius: "roundedBl",
480
+ borderBottomRightRadius: "roundedBr",
481
+ // Border
482
+ borderWidth: "border",
483
+ // Spacing
484
+ padding: "p",
485
+ paddingTop: "pt",
486
+ paddingRight: "pr",
487
+ paddingBottom: "pb",
488
+ paddingLeft: "pl",
489
+ paddingX: "px",
490
+ paddingY: "py",
491
+ margin: "m",
492
+ marginTop: "mt",
493
+ marginRight: "mr",
494
+ marginBottom: "mb",
495
+ marginLeft: "ml",
496
+ marginX: "mx",
497
+ marginY: "my",
498
+ // Sizing
499
+ width: "w",
500
+ height: "h",
501
+ minWidth: "minW",
502
+ maxWidth: "maxW",
503
+ minHeight: "minH",
504
+ maxHeight: "maxH",
505
+ // Layout
506
+ aspectRatio: "aspect",
507
+ boxSizing: "box",
508
+ boxDecorationBreak: "boxDecoration",
509
+ objectPosition: "objectPos",
510
+ zIndex: "z",
511
+ // Typography
512
+ fontStyle: "italic/notItalic (boolean)",
513
+ weight: "fontWeight",
514
+ textDecoration: "decoration or underline/lineThrough/noUnderline (boolean)",
515
+ textDecorationColor: "decorationColor",
516
+ textDecorationStyle: "decorationStyle",
517
+ textDecorationThickness: "decorationThickness",
518
+ textUnderlineOffset: "underlineOffset",
519
+ lineHeight: "leading",
520
+ letterSpacing: "tracking",
521
+ textIndent: "indent",
522
+ verticalAlign: "align",
523
+ wordBreak: "break",
524
+ overflowWrap: "wrap",
525
+ textWrap: "textWrap",
526
+ listStyleType: "list",
527
+ listStylePosition: "listPos",
528
+ listStyleImage: "listImg",
529
+ listStyle: "list",
530
+ listPosition: "listPos",
531
+ listImage: "listImg",
532
+ // Flex & Grid
533
+ flexBasis: "basis",
534
+ flexDirection: "flexDir",
535
+ flexGrow: "grow",
536
+ flexShrink: "shrink",
537
+ alignItems: "items",
538
+ alignContent: "content",
539
+ alignSelf: "self",
540
+ justifyContent: "justify",
541
+ gridTemplateColumns: "gridCols",
542
+ gridTemplateRows: "gridRows",
543
+ gridColumn: "col",
544
+ gridRow: "row",
545
+ gridAutoFlow: "gridFlow",
546
+ gridAutoColumns: "autoCols",
547
+ gridAutoRows: "autoRows",
548
+ // Effects
549
+ boxShadow: "shadow",
550
+ mixBlendMode: "mixBlend",
551
+ backgroundBlendMode: "bgBlend",
552
+ // Transitions
553
+ transitionProperty: "transition",
554
+ transitionDuration: "duration",
555
+ transitionTimingFunction: "ease",
556
+ transitionDelay: "delay",
557
+ animation: "animate",
558
+ transformOrigin: "origin",
559
+ // Interactivity
560
+ caretColor: "caret",
561
+ accentColor: "accent",
562
+ scrollBehavior: "scroll",
563
+ scrollMargin: "scrollM",
564
+ scrollPadding: "scrollP",
565
+ scrollSnapAlign: "snapAlign",
566
+ scrollSnapStop: "snapStop",
567
+ scrollSnapType: "snapType",
568
+ touchAction: "touch",
569
+ userSelect: "select",
570
+ captionSide: "caption",
571
+ // Boolean remaps
572
+ flexWrapReverse: "flexWrap: 'wrap-reverse'",
573
+ flexNowrap: "flexWrap: 'nowrap'"
574
+ };
575
+ var VARIANT_MAP = {
576
+ // Focus variants
577
+ focusWithin: "focus-within",
578
+ focusVisible: "focus-visible",
579
+ // Structural variants
580
+ firstOfType: "first-of-type",
581
+ lastOfType: "last-of-type",
582
+ onlyOfType: "only-of-type",
583
+ onlyChild: "only",
584
+ firstChild: "first",
585
+ lastChild: "last",
586
+ // Motion variants
587
+ motionReduce: "motion-reduce",
588
+ motionSafe: "motion-safe",
589
+ // Contrast variants
590
+ contrastMore: "contrast-more",
591
+ contrastLess: "contrast-less",
592
+ // Pseudo-element variants
593
+ firstLine: "first-line",
594
+ firstLetter: "first-letter",
595
+ // Form variants
596
+ placeholderShown: "placeholder-shown",
597
+ inRange: "in-range",
598
+ outOfRange: "out-of-range",
599
+ readOnly: "read-only",
600
+ // Pointer variants
601
+ pointerFine: "pointer-fine",
602
+ pointerCoarse: "pointer-coarse",
603
+ pointerNone: "pointer-none",
604
+ // Screen orientation
605
+ screenPortrait: "portrait",
606
+ screenLandscape: "landscape",
607
+ // Container query max variants
608
+ "@maxSm": "@max-sm",
609
+ "@maxMd": "@max-md",
610
+ "@maxLg": "@max-lg",
611
+ "@maxXl": "@max-xl",
612
+ "@max2xl": "@max-2xl"
613
+ };
614
+ var KNOWN_VARIANTS = /* @__PURE__ */ new Set([
615
+ // Responsive
616
+ "sm",
617
+ "md",
618
+ "lg",
619
+ "xl",
620
+ "2xl",
621
+ // Container queries
622
+ "@sm",
623
+ "@md",
624
+ "@lg",
625
+ "@xl",
626
+ "@2xl",
627
+ // Dark mode
628
+ "dark",
629
+ "light",
630
+ // Print/Media
631
+ "print",
632
+ "portrait",
633
+ "landscape",
634
+ // Motion
635
+ "motion-reduce",
636
+ "motion-safe",
637
+ "motionReduce",
638
+ "motionSafe",
639
+ // Contrast
640
+ "contrast-more",
641
+ "contrast-less",
642
+ "contrastMore",
643
+ "contrastLess",
644
+ // States
645
+ "hover",
646
+ "focus",
647
+ "focus-within",
648
+ "focus-visible",
649
+ "focusWithin",
650
+ "focusVisible",
651
+ "active",
652
+ "visited",
653
+ "target",
654
+ "disabled",
655
+ "enabled",
656
+ "checked",
657
+ "indeterminate",
658
+ "default",
659
+ "required",
660
+ "valid",
661
+ "invalid",
662
+ "in-range",
663
+ "out-of-range",
664
+ "inRange",
665
+ "outOfRange",
666
+ "placeholder-shown",
667
+ "placeholderShown",
668
+ "autofill",
669
+ "read-only",
670
+ "readOnly",
671
+ // Structure
672
+ "first",
673
+ "last",
674
+ "only",
675
+ "odd",
676
+ "even",
677
+ "empty",
678
+ "first-of-type",
679
+ "last-of-type",
680
+ "only-of-type",
681
+ "firstOfType",
682
+ "lastOfType",
683
+ "onlyOfType",
684
+ "first-child",
685
+ "last-child",
686
+ "only-child",
687
+ "firstChild",
688
+ "lastChild",
689
+ "onlyChild",
690
+ // Pseudo-elements
691
+ "before",
692
+ "after",
693
+ "placeholder",
694
+ "file",
695
+ "marker",
696
+ "selection",
697
+ "first-line",
698
+ "first-letter",
699
+ "firstLine",
700
+ "firstLetter",
701
+ "backdrop",
702
+ // Pointer
703
+ "pointer-fine",
704
+ "pointer-coarse",
705
+ "pointer-none",
706
+ "pointerFine",
707
+ "pointerCoarse",
708
+ "pointerNone",
709
+ // Open
710
+ "open",
711
+ // RTL/LTR
712
+ "ltr",
713
+ "rtl"
714
+ ]);
715
+ var ARIA_STATES = /* @__PURE__ */ new Set([
716
+ "checked",
717
+ "disabled",
718
+ "expanded",
719
+ "hidden",
720
+ "pressed",
721
+ "readonly",
722
+ "required",
723
+ "selected",
724
+ "busy",
725
+ "current",
726
+ "invalid",
727
+ "live",
728
+ "atomic",
729
+ "modal"
730
+ ]);
731
+ var BOOLEAN_SHORTHANDS = /* @__PURE__ */ new Set([
732
+ // Display
733
+ "block",
734
+ "inline",
735
+ "inlineBlock",
736
+ "flex",
737
+ "inlineFlex",
738
+ "grid",
739
+ "inlineGrid",
740
+ "hidden",
741
+ "contents",
742
+ "table",
743
+ "tableRow",
744
+ "tableCell",
745
+ "flowRoot",
746
+ "listItem",
747
+ // Position
748
+ "static",
749
+ "fixed",
750
+ "absolute",
751
+ "relative",
752
+ "sticky",
753
+ // Visibility
754
+ "visible",
755
+ "invisible",
756
+ "collapse",
757
+ // Typography
758
+ "truncate",
759
+ "uppercase",
760
+ "lowercase",
761
+ "capitalize",
762
+ "normalCase",
763
+ "underline",
764
+ "overline",
765
+ "lineThrough",
766
+ "noUnderline",
767
+ "italic",
768
+ "notItalic",
769
+ "antialiased",
770
+ "subpixelAntialiased",
771
+ // Flexbox (grow/shrink only — flexWrap uses string values)
772
+ "grow",
773
+ "shrink",
774
+ // Filters (default values)
775
+ "blur",
776
+ "grayscale",
777
+ "invert",
778
+ "sepia",
779
+ "backdropBlur",
780
+ "backdropGrayscale",
781
+ "backdropInvert",
782
+ "backdropSepia",
783
+ // Misc
784
+ "container",
785
+ "prose",
786
+ "srOnly",
787
+ "notSrOnly",
788
+ "isolate",
789
+ "ordinal",
790
+ "slashedZero",
791
+ // Font variant numeric
792
+ "liningNums",
793
+ "oldstyleNums",
794
+ "proportionalNums",
795
+ "tabularNums",
796
+ "diagonalFractions",
797
+ "stackedFractions",
798
+ // Divide/Space reverse
799
+ "divideXReverse",
800
+ "divideYReverse",
801
+ "spaceXReverse",
802
+ "spaceYReverse",
803
+ // Ring (v3 future)
804
+ "ring",
805
+ // Outline
806
+ "outline",
807
+ // Transforms
808
+ "scale3d",
809
+ "rotate3d",
810
+ "translate3d",
811
+ "transformGpu",
812
+ "transformCpu",
813
+ "transformNone"
814
+ ]);
815
+ var BOOLEAN_TO_CLASS = {
816
+ inlineBlock: "inline-block",
817
+ inlineFlex: "inline-flex",
818
+ inlineGrid: "inline-grid",
819
+ tableRow: "table-row",
820
+ tableCell: "table-cell",
821
+ flowRoot: "flow-root",
822
+ listItem: "list-item",
823
+ normalCase: "normal-case",
824
+ lineThrough: "line-through",
825
+ noUnderline: "no-underline",
826
+ notItalic: "not-italic",
827
+ subpixelAntialiased: "subpixel-antialiased",
828
+ backdropBlur: "backdrop-blur",
829
+ backdropGrayscale: "backdrop-grayscale",
830
+ backdropInvert: "backdrop-invert",
831
+ backdropSepia: "backdrop-sepia",
832
+ srOnly: "sr-only",
833
+ notSrOnly: "not-sr-only",
834
+ divideXReverse: "divide-x-reverse",
835
+ divideYReverse: "divide-y-reverse",
836
+ spaceXReverse: "space-x-reverse",
837
+ spaceYReverse: "space-y-reverse",
838
+ // Font variant numeric
839
+ liningNums: "lining-nums",
840
+ oldstyleNums: "oldstyle-nums",
841
+ proportionalNums: "proportional-nums",
842
+ tabularNums: "tabular-nums",
843
+ diagonalFractions: "diagonal-fractions",
844
+ stackedFractions: "stacked-fractions",
845
+ // Transforms
846
+ scale3d: "scale-3d",
847
+ rotate3d: "rotate-3d",
848
+ translate3d: "translate-3d",
849
+ transformGpu: "transform-gpu",
850
+ transformCpu: "transform-cpu",
851
+ transformNone: "transform-none"
852
+ };
853
+ var SNAP_DIRECT_MAP = {
854
+ snapAlign: {
855
+ start: "snap-start",
856
+ end: "snap-end",
857
+ center: "snap-center",
858
+ none: "snap-align-none"
859
+ },
860
+ snapStop: {
861
+ normal: "snap-normal",
862
+ always: "snap-always"
863
+ },
864
+ snapType: {
865
+ none: "snap-none",
866
+ x: "snap-x",
867
+ y: "snap-y",
868
+ both: "snap-both"
869
+ },
870
+ snapStrictness: {
871
+ mandatory: "snap-mandatory",
872
+ proximity: "snap-proximity"
873
+ }
874
+ };
875
+ var NEGATIVE_ALLOWED = /* @__PURE__ */ new Set([
876
+ "m",
877
+ "mt",
878
+ "mr",
879
+ "mb",
880
+ "ml",
881
+ "mx",
882
+ "my",
883
+ "ms",
884
+ "me",
885
+ "top",
886
+ "right",
887
+ "bottom",
888
+ "left",
889
+ "inset",
890
+ "inset-x",
891
+ "inset-y",
892
+ "start",
893
+ "end",
894
+ "z",
895
+ "order",
896
+ "col",
897
+ "col-start",
898
+ "col-end",
899
+ "row",
900
+ "row-start",
901
+ "row-end",
902
+ "rotate",
903
+ "skew-x",
904
+ "skew-y",
905
+ "translate-x",
906
+ "translate-y",
907
+ "space-x",
908
+ "space-y",
909
+ "tracking",
910
+ "indent",
911
+ "scroll-m",
912
+ "scroll-mx",
913
+ "scroll-my",
914
+ "scroll-mt",
915
+ "scroll-mr",
916
+ "scroll-mb",
917
+ "scroll-ml",
918
+ "hue-rotate",
919
+ "backdrop-hue-rotate"
920
+ ]);
921
+ function handleImportant(value) {
922
+ if (typeof value === "string" && value.endsWith("!")) {
923
+ return { value: value.slice(0, -1), important: true };
924
+ }
925
+ return { value, important: false };
926
+ }
927
+ function formatOpacity(op) {
928
+ if (typeof op === "number") {
929
+ return String(op);
930
+ }
931
+ if (typeof op === "string") {
932
+ if (op.startsWith("--")) {
933
+ return `(${op})`;
934
+ }
935
+ return `[${op}]`;
936
+ }
937
+ return String(op);
938
+ }
939
+ function isArbitraryVariant(key) {
940
+ return key.startsWith("[") && key.endsWith("]");
941
+ }
942
+ function normalizeArbitraryVariant(key) {
943
+ return key.replace(/\s+/g, "");
944
+ }
945
+ function normalizeArbitraryValue(value) {
946
+ return value.trim().replace(/\s*([+*/(),:])\s*/g, "$1").replace(/\s+/g, "_");
947
+ }
948
+ var FRACTION_SUPPORTED_PROPS = /* @__PURE__ */ new Set([
949
+ // Sizing (both rawKey and resolved key forms)
950
+ "w",
951
+ "width",
952
+ "min-w",
953
+ "minW",
954
+ "minWidth",
955
+ "max-w",
956
+ "maxW",
957
+ "maxWidth",
958
+ "h",
959
+ "height",
960
+ "min-h",
961
+ "minH",
962
+ "minHeight",
963
+ "max-h",
964
+ "maxH",
965
+ "maxHeight",
966
+ "size",
967
+ // Flex
968
+ "basis",
969
+ "flexBasis",
970
+ "flex",
971
+ // Inset
972
+ "inset",
973
+ "inset-x",
974
+ "insetX",
975
+ "inset-y",
976
+ "insetY",
977
+ "top",
978
+ "right",
979
+ "bottom",
980
+ "left",
981
+ "start",
982
+ "end",
983
+ // Translate
984
+ "translate-x",
985
+ "translateX",
986
+ "translate-y",
987
+ "translateY"
988
+ ]);
989
+ function needsArbitraryBrackets(value) {
990
+ return /^\d+(\.\d+)?(px|rem|em|%|vh|vw|ch|dvh|dvw|svh|svw|lvh|lvw|cqw|cqh|deg|rad|turn|grad|ms|s|fr)$/.test(value) || // Units
991
+ /^\.\d+(px|rem|em|%|vh|vw|ch)?$/.test(value) || // Values starting with . like .25em
992
+ value.startsWith("#") || // Hex colors
993
+ value.startsWith("rgb") || // RGB colors
994
+ value.startsWith("hsl") || // HSL colors
995
+ value.includes("calc(") || // Calculations
996
+ value.includes("var(") || // CSS variables (old syntax)
997
+ value.includes("attr(") || // attr() function
998
+ value.includes("url(") || // URLs
999
+ value.includes("clamp(") || // Clamp
1000
+ value.includes("min(") || // Min
1001
+ value.includes("max(") || // Max
1002
+ value.includes(" ");
1003
+ }
1004
+ var LIST_STYLE_STANDARD = /* @__PURE__ */ new Set(["none", "disc", "decimal"]);
1005
+ var FONT_STRETCH_KEYWORDS = /* @__PURE__ */ new Set([
1006
+ "ultra-condensed",
1007
+ "extra-condensed",
1008
+ "condensed",
1009
+ "semi-condensed",
1010
+ "normal",
1011
+ "semi-expanded",
1012
+ "expanded",
1013
+ "extra-expanded",
1014
+ "ultra-expanded"
1015
+ ]);
1016
+ var NEEDS_ARBITRARY_PROPERTY = /* @__PURE__ */ new Set([
1017
+ "mask-type",
1018
+ "mask-composite",
1019
+ "mask-mode"
1020
+ ]);
1021
+ function getVariantPrefix(key) {
1022
+ if (VARIANT_MAP[key]) {
1023
+ return VARIANT_MAP[key];
1024
+ }
1025
+ return key.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1026
+ }
1027
+ function handleGroupPeer(type, nestedObj, prefix) {
1028
+ const classes = [];
1029
+ for (const [nestedKey, nestedValue] of Object.entries(nestedObj)) {
1030
+ if (nestedValue === null || nestedValue === void 0 || nestedValue === false) {
1031
+ continue;
1032
+ }
1033
+ if (nestedKey === "has" && typeof nestedValue === "object") {
1034
+ for (const [selector, selectorValue] of Object.entries(nestedValue)) {
1035
+ if (selectorValue === null || selectorValue === void 0 || selectorValue === false) {
1036
+ continue;
1037
+ }
1038
+ const variantPrefix = `${prefix}${type}-has-[${selector}]:`;
1039
+ const result = transform(selectorValue, variantPrefix);
1040
+ if (result.className) {
1041
+ classes.push(result.className);
1042
+ }
1043
+ }
1044
+ continue;
1045
+ }
1046
+ const isVariant = KNOWN_VARIANTS.has(nestedKey) || KNOWN_VARIANTS.has(getVariantPrefix(nestedKey));
1047
+ const isArbitrary = nestedKey.startsWith(".") || nestedKey.startsWith("#") || nestedKey.startsWith("[") || nestedKey.startsWith(":");
1048
+ if (isArbitrary) {
1049
+ const variantPrefix = `${prefix}${type}-[${nestedKey}]:`;
1050
+ const result = transform(nestedValue, variantPrefix);
1051
+ if (result.className) {
1052
+ classes.push(result.className);
1053
+ }
1054
+ } else if (isVariant) {
1055
+ const mappedVariant = getVariantPrefix(nestedKey);
1056
+ const variantPrefix = `${prefix}${type}-${mappedVariant}:`;
1057
+ const result = transform(nestedValue, variantPrefix);
1058
+ if (result.className) {
1059
+ classes.push(result.className);
1060
+ }
1061
+ } else if (typeof nestedValue === "object" && nestedValue !== null) {
1062
+ for (const [state, stateValue] of Object.entries(nestedValue)) {
1063
+ if (stateValue === null || stateValue === void 0 || stateValue === false) {
1064
+ continue;
1065
+ }
1066
+ const mappedState = getVariantPrefix(state);
1067
+ const variantPrefix = `${prefix}${type}-${mappedState}/${nestedKey}:`;
1068
+ const result = transform(stateValue, variantPrefix);
1069
+ if (result.className) {
1070
+ classes.push(result.className);
1071
+ }
1072
+ }
1073
+ }
1074
+ }
1075
+ return classes;
1076
+ }
1077
+ function handleHas(hasObj, prefix) {
1078
+ const classes = [];
1079
+ for (const [selector, value] of Object.entries(hasObj)) {
1080
+ if (value === null || value === void 0 || value === false) {
1081
+ continue;
1082
+ }
1083
+ let selectorStr;
1084
+ if (KNOWN_VARIANTS.has(selector) || selector.startsWith(":")) {
1085
+ selectorStr = selector.startsWith(":") ? selector : `:${selector}`;
1086
+ } else {
1087
+ selectorStr = selector;
1088
+ }
1089
+ const variantPrefix = `${prefix}has-[${selectorStr}]:`;
1090
+ const result = transform(value, variantPrefix);
1091
+ if (result.className) {
1092
+ classes.push(result.className);
1093
+ }
1094
+ }
1095
+ return classes;
1096
+ }
1097
+ function handleNot(notObj, prefix) {
1098
+ const classes = [];
1099
+ for (const [key, value] of Object.entries(notObj)) {
1100
+ if (value === null || value === void 0 || value === false) {
1101
+ continue;
1102
+ }
1103
+ if (key === "supports" && typeof value === "object") {
1104
+ for (const [condition, condValue] of Object.entries(value)) {
1105
+ const variantPrefix = `${prefix}not-supports-[${condition}]:`;
1106
+ const result = transform(condValue, variantPrefix);
1107
+ if (result.className) {
1108
+ classes.push(result.className);
1109
+ }
1110
+ }
1111
+ } else {
1112
+ const mappedVariant = getVariantPrefix(key);
1113
+ const variantPrefix = `${prefix}not-${mappedVariant}:`;
1114
+ const result = transform(value, variantPrefix);
1115
+ if (result.className) {
1116
+ classes.push(result.className);
1117
+ }
1118
+ }
1119
+ }
1120
+ return classes;
1121
+ }
1122
+ function handleData(dataObj, prefix) {
1123
+ const classes = [];
1124
+ for (const [key, value] of Object.entries(dataObj)) {
1125
+ if (value === null || value === void 0 || value === false) {
1126
+ continue;
1127
+ }
1128
+ const variantPrefix = `${prefix}data-[${key}]:`;
1129
+ const result = transform(value, variantPrefix);
1130
+ if (result.className) {
1131
+ classes.push(result.className);
1132
+ }
1133
+ }
1134
+ return classes;
1135
+ }
1136
+ function handleAria(ariaObj, prefix) {
1137
+ const classes = [];
1138
+ for (const [key, value] of Object.entries(ariaObj)) {
1139
+ if (value === null || value === void 0 || value === false) {
1140
+ continue;
1141
+ }
1142
+ let variantPrefix;
1143
+ if (ARIA_STATES.has(key)) {
1144
+ variantPrefix = `${prefix}aria-${key}:`;
1145
+ } else {
1146
+ variantPrefix = `${prefix}aria-[${key}]:`;
1147
+ }
1148
+ const result = transform(value, variantPrefix);
1149
+ if (result.className) {
1150
+ classes.push(result.className);
1151
+ }
1152
+ }
1153
+ return classes;
1154
+ }
1155
+ function handleSupports(supportsObj, prefix) {
1156
+ const classes = [];
1157
+ for (const [condition, value] of Object.entries(supportsObj)) {
1158
+ if (value === null || value === void 0 || value === false) {
1159
+ continue;
1160
+ }
1161
+ const variantPrefix = `${prefix}supports-[${condition}]:`;
1162
+ const result = transform(value, variantPrefix);
1163
+ if (result.className) {
1164
+ classes.push(result.className);
1165
+ }
1166
+ }
1167
+ return classes;
1168
+ }
1169
+ function transform(szProp, prefix = "", mangleMap) {
1170
+ if (!szProp || typeof szProp !== "object") {
1171
+ return { className: "", attributes: {} };
1172
+ }
1173
+ const classes = [];
1174
+ const attributes = {};
1175
+ for (const [rawKey, value] of Object.entries(szProp)) {
1176
+ if (value === false) {
1177
+ if (rawKey === "italic") {
1178
+ classes.push(`${prefix}not-italic`);
1179
+ } else if (rawKey === "antialiased") {
1180
+ classes.push(`${prefix}subpixel-antialiased`);
1181
+ }
1182
+ continue;
1183
+ }
1184
+ if (value === null || value === void 0) {
1185
+ continue;
1186
+ }
1187
+ if (rawKey.startsWith("@") && typeof value === "string") {
1188
+ const mappedKey = VARIANT_MAP[rawKey] || rawKey;
1189
+ classes.push(`${prefix}${mappedKey}/${value}`);
1190
+ continue;
1191
+ }
1192
+ if (rawKey === "bgImg" && typeof value === "object" && value !== null && !Array.isArray(value)) {
1193
+ const grad = value;
1194
+ const gradType = grad.gradient;
1195
+ if (!gradType) {
1196
+ continue;
1197
+ }
1198
+ let cls = "";
1199
+ if (gradType === "linear") {
1200
+ const dir = grad.dir ?? "to-r";
1201
+ if (typeof dir === "number") {
1202
+ if (dir < 0) {
1203
+ cls = `-bg-linear-${Math.abs(dir)}`;
1204
+ } else {
1205
+ cls = `bg-linear-${dir}`;
1206
+ }
1207
+ } else if (typeof dir === "string") {
1208
+ if (dir.startsWith("--")) {
1209
+ cls = `bg-linear-(${dir})`;
1210
+ } else if (dir.startsWith("to-")) {
1211
+ cls = `bg-linear-${dir}`;
1212
+ } else {
1213
+ cls = `bg-linear-[${normalizeArbitraryValue(dir)}]`;
1214
+ }
1215
+ }
1216
+ } else if (gradType === "radial") {
1217
+ const dir = grad.dir;
1218
+ if (dir === void 0 || dir === null) {
1219
+ cls = "bg-radial";
1220
+ } else if (typeof dir === "string") {
1221
+ if (dir.startsWith("--")) {
1222
+ cls = `bg-radial-(${dir})`;
1223
+ } else {
1224
+ cls = `bg-radial-[${normalizeArbitraryValue(dir)}]`;
1225
+ }
1226
+ }
1227
+ } else if (gradType === "conic") {
1228
+ const dir = grad.dir;
1229
+ if (dir === void 0 || dir === null) {
1230
+ cls = "bg-conic";
1231
+ } else if (typeof dir === "number") {
1232
+ if (dir < 0) {
1233
+ cls = `-bg-conic-${Math.abs(dir)}`;
1234
+ } else {
1235
+ cls = `bg-conic-${dir}`;
1236
+ }
1237
+ } else if (typeof dir === "string") {
1238
+ if (dir.startsWith("--")) {
1239
+ cls = `bg-conic-(${dir})`;
1240
+ } else {
1241
+ cls = `bg-conic-[${normalizeArbitraryValue(dir)}]`;
1242
+ }
1243
+ }
1244
+ }
1245
+ if (grad.in) {
1246
+ cls += `/${grad.in}`;
1247
+ }
1248
+ if (cls) {
1249
+ classes.push(`${prefix}${cls}`);
1250
+ }
1251
+ continue;
1252
+ }
1253
+ if ((rawKey === "group" || rawKey === "peer") && typeof value === "string") {
1254
+ classes.push(`${prefix}${rawKey}/${value}`);
1255
+ continue;
1256
+ }
1257
+ if (typeof value === "object" && value !== null && !Array.isArray(value) && "color" in value) {
1258
+ const colorObj = value;
1259
+ const twPrefix = PROPERTY_MAP[rawKey] || rawKey.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1260
+ const colorBase = String(colorObj.color);
1261
+ if (colorObj.op !== void 0) {
1262
+ const opStr = formatOpacity(colorObj.op);
1263
+ classes.push(`${prefix}${twPrefix}-${colorBase}/${opStr}`);
1264
+ } else {
1265
+ classes.push(`${prefix}${twPrefix}-${colorBase}`);
1266
+ }
1267
+ continue;
1268
+ }
1269
+ if (typeof value === "object" && !Array.isArray(value)) {
1270
+ if (rawKey === "group") {
1271
+ const groupClasses = handleGroupPeer("group", value, prefix);
1272
+ classes.push(...groupClasses);
1273
+ continue;
1274
+ }
1275
+ if (rawKey === "peer") {
1276
+ const peerClasses = handleGroupPeer("peer", value, prefix);
1277
+ classes.push(...peerClasses);
1278
+ continue;
1279
+ }
1280
+ if (rawKey === "has") {
1281
+ const hasClasses = handleHas(value, prefix);
1282
+ classes.push(...hasClasses);
1283
+ continue;
1284
+ }
1285
+ if (rawKey === "not") {
1286
+ const notClasses = handleNot(value, prefix);
1287
+ classes.push(...notClasses);
1288
+ continue;
1289
+ }
1290
+ if (rawKey === "data") {
1291
+ const dataClasses = handleData(value, prefix);
1292
+ classes.push(...dataClasses);
1293
+ continue;
1294
+ }
1295
+ if (rawKey === "aria") {
1296
+ const ariaClasses = handleAria(value, prefix);
1297
+ classes.push(...ariaClasses);
1298
+ continue;
1299
+ }
1300
+ if (rawKey === "supports") {
1301
+ const supportsClasses = handleSupports(value, prefix);
1302
+ classes.push(...supportsClasses);
1303
+ continue;
1304
+ }
1305
+ if (rawKey === "min" || rawKey === "max") {
1306
+ const KNOWN_BP = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
1307
+ for (const [breakpoint, breakpointValue] of Object.entries(value)) {
1308
+ if (breakpointValue === null || breakpointValue === void 0 || breakpointValue === false) {
1309
+ continue;
1310
+ }
1311
+ let bpStr;
1312
+ if (isArbitraryVariant(breakpoint)) {
1313
+ bpStr = `${rawKey}-${breakpoint}`;
1314
+ } else if (KNOWN_BP.has(breakpoint)) {
1315
+ bpStr = `${rawKey}-${breakpoint}`;
1316
+ } else {
1317
+ bpStr = `${rawKey}-[${breakpoint}]`;
1318
+ }
1319
+ const nestedPrefix2 = `${prefix}${bpStr}:`;
1320
+ const result = transform(breakpointValue, nestedPrefix2);
1321
+ if (result.className) {
1322
+ classes.push(result.className);
1323
+ }
1324
+ }
1325
+ continue;
1326
+ }
1327
+ if (rawKey.startsWith("@")) {
1328
+ const mappedKey = VARIANT_MAP[rawKey] || rawKey;
1329
+ if (typeof value === "string") {
1330
+ classes.push(`${prefix}${mappedKey}/${value}`);
1331
+ continue;
1332
+ }
1333
+ const KNOWN_BP = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
1334
+ for (const [nestedKey, nestedValue] of Object.entries(value)) {
1335
+ if (nestedValue === null || nestedValue === void 0 || nestedValue === false) {
1336
+ continue;
1337
+ }
1338
+ if (isArbitraryVariant(nestedKey)) {
1339
+ const nestedPrefix2 = `${prefix}${mappedKey}-${nestedKey}:`;
1340
+ const result = transform(nestedValue, nestedPrefix2);
1341
+ if (result.className) {
1342
+ classes.push(result.className);
1343
+ }
1344
+ } else if ((mappedKey === "@min" || mappedKey === "@max") && typeof nestedValue === "object" && nestedValue !== null && !KNOWN_BP.has(nestedKey) && !PROPERTY_MAP[nestedKey] && !BOOLEAN_SHORTHANDS.has(nestedKey)) {
1345
+ const nestedPrefix2 = `${prefix}${mappedKey}-[${nestedKey}]:`;
1346
+ const result = transform(nestedValue, nestedPrefix2);
1347
+ if (result.className) {
1348
+ classes.push(result.className);
1349
+ }
1350
+ } else if (PROPERTY_MAP[nestedKey] || BOOLEAN_SHORTHANDS.has(nestedKey) || nestedKey.startsWith("@")) {
1351
+ const nestedPrefix2 = `${prefix}${mappedKey}:`;
1352
+ const result = transform({ [nestedKey]: nestedValue }, nestedPrefix2);
1353
+ if (result.className) {
1354
+ classes.push(result.className);
1355
+ }
1356
+ } else if (typeof nestedValue === "object" && nestedValue !== null) {
1357
+ const nestedPrefix2 = `${prefix}${mappedKey}/${nestedKey}:`;
1358
+ const result = transform(nestedValue, nestedPrefix2);
1359
+ if (result.className) {
1360
+ classes.push(result.className);
1361
+ }
1362
+ } else {
1363
+ const nestedPrefix2 = `${prefix}${mappedKey}:`;
1364
+ const result = transform({ [nestedKey]: nestedValue }, nestedPrefix2);
1365
+ if (result.className) {
1366
+ classes.push(result.className);
1367
+ }
1368
+ }
1369
+ }
1370
+ continue;
1371
+ }
1372
+ if (isArbitraryVariant(rawKey)) {
1373
+ const normalizedKey = normalizeArbitraryVariant(rawKey);
1374
+ const nestedPrefix2 = `${prefix}${normalizedKey}:`;
1375
+ const nestedResult2 = transform(value, nestedPrefix2);
1376
+ if (nestedResult2.className) {
1377
+ classes.push(nestedResult2.className);
1378
+ }
1379
+ continue;
1380
+ }
1381
+ const variantName = getVariantPrefix(rawKey);
1382
+ const nestedPrefix = `${prefix}${variantName}:`;
1383
+ const nestedResult = transform(value, nestedPrefix);
1384
+ if (nestedResult.className) {
1385
+ classes.push(nestedResult.className);
1386
+ }
1387
+ continue;
1388
+ }
1389
+ if (SNAP_DIRECT_MAP[rawKey] && typeof value === "string") {
1390
+ const mapped = SNAP_DIRECT_MAP[rawKey][value];
1391
+ if (mapped) {
1392
+ classes.push(`${prefix}${mapped}`);
1393
+ continue;
1394
+ }
1395
+ }
1396
+ if (typeof value === "string" && KNOWN_VARIANTS.has(rawKey)) {
1397
+ const variantName = getVariantPrefix(rawKey);
1398
+ classes.push(`${prefix}${variantName}:${value}`);
1399
+ continue;
1400
+ }
1401
+ if (rawKey.startsWith("--")) {
1402
+ classes.push(`${prefix}[${rawKey}:${value}]`);
1403
+ continue;
1404
+ }
1405
+ if (rawKey === "container") {
1406
+ if (value === true) {
1407
+ classes.push(`${prefix}container`);
1408
+ } else if (typeof value === "string") {
1409
+ classes.push(`${prefix}@container/${value}`);
1410
+ }
1411
+ continue;
1412
+ }
1413
+ let key = rawKey;
1414
+ if (PROPERTY_MAP[key]) {
1415
+ key = PROPERTY_MAP[key];
1416
+ } else {
1417
+ key = key.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1418
+ }
1419
+ let className = prefix;
1420
+ if (rawKey === "willChange" && typeof value === "string") {
1421
+ if (value === "scroll") {
1422
+ classes.push(`${prefix}will-change-scroll-position`);
1423
+ } else if (value.startsWith("--")) {
1424
+ classes.push(`${prefix}will-change-(${value})`);
1425
+ } else {
1426
+ classes.push(`${prefix}will-change-${value}`);
1427
+ }
1428
+ continue;
1429
+ }
1430
+ if (key === "display") {
1431
+ if (typeof value === "string") {
1432
+ if (value === "none") {
1433
+ className += "hidden";
1434
+ } else {
1435
+ className += value;
1436
+ }
1437
+ classes.push(className);
1438
+ continue;
1439
+ }
1440
+ }
1441
+ if (key === "position") {
1442
+ if (typeof value === "string") {
1443
+ className += value;
1444
+ classes.push(className);
1445
+ continue;
1446
+ }
1447
+ }
1448
+ if (key === "visibility") {
1449
+ if (typeof value === "string") {
1450
+ if (value === "hidden") {
1451
+ className += "invisible";
1452
+ } else {
1453
+ className += value;
1454
+ }
1455
+ classes.push(className);
1456
+ continue;
1457
+ }
1458
+ }
1459
+ if (key === "isolation") {
1460
+ if (typeof value === "string") {
1461
+ if (value === "isolate") {
1462
+ className += "isolate";
1463
+ } else {
1464
+ className += `isolation-${value}`;
1465
+ }
1466
+ classes.push(className);
1467
+ continue;
1468
+ }
1469
+ }
1470
+ if ((rawKey === "fromPos" || rawKey === "viaPos" || rawKey === "toPos") && typeof value === "number") {
1471
+ const gradPrefix = rawKey.replace("Pos", "");
1472
+ classes.push(`${prefix}${gradPrefix}-${value}%`);
1473
+ continue;
1474
+ }
1475
+ if (typeof value === "string") {
1476
+ if (rawKey === "decoration") {
1477
+ if (["underline", "overline", "line-through", "no-underline", "none"].includes(value)) {
1478
+ className += value === "none" ? "no-underline" : value;
1479
+ classes.push(className);
1480
+ continue;
1481
+ }
1482
+ }
1483
+ if (rawKey === "textTransform") {
1484
+ if (["uppercase", "lowercase", "capitalize", "normal-case"].includes(value)) {
1485
+ className += value;
1486
+ classes.push(className);
1487
+ continue;
1488
+ }
1489
+ }
1490
+ if (rawKey === "fontVariant") {
1491
+ const FONT_VARIANT_CLASSES = /* @__PURE__ */ new Set([
1492
+ "normal-nums",
1493
+ "ordinal",
1494
+ "slashed-zero",
1495
+ "lining-nums",
1496
+ "oldstyle-nums",
1497
+ "proportional-nums",
1498
+ "tabular-nums",
1499
+ "diagonal-fractions",
1500
+ "stacked-fractions"
1501
+ ]);
1502
+ if (FONT_VARIANT_CLASSES.has(value)) {
1503
+ className += value;
1504
+ classes.push(className);
1505
+ continue;
1506
+ }
1507
+ }
1508
+ if (rawKey === "textWrap") {
1509
+ className += `text-${value}`;
1510
+ classes.push(className);
1511
+ continue;
1512
+ }
1513
+ if (rawKey === "break") {
1514
+ const wbMap = {
1515
+ "normal": "break-normal",
1516
+ "all": "break-all",
1517
+ "keep": "break-keep",
1518
+ "break-normal": "break-normal",
1519
+ "break-all": "break-all",
1520
+ "break-keep": "break-keep"
1521
+ };
1522
+ className += wbMap[value] || `break-${value}`;
1523
+ classes.push(className);
1524
+ continue;
1525
+ }
1526
+ if (rawKey === "wrap") {
1527
+ const owMap = {
1528
+ "normal": "wrap-normal",
1529
+ "break-word": "wrap-break-word",
1530
+ "anywhere": "wrap-anywhere",
1531
+ "wrap-normal": "wrap-normal",
1532
+ "wrap-break-word": "wrap-break-word",
1533
+ "wrap-anywhere": "wrap-anywhere"
1534
+ };
1535
+ className += owMap[value] || `wrap-${value}`;
1536
+ classes.push(className);
1537
+ continue;
1538
+ }
1539
+ if (rawKey === "textOverflow") {
1540
+ if (value === "ellipsis") {
1541
+ classes.push(`${prefix}truncate`);
1542
+ } else {
1543
+ classes.push(`${prefix}text-${value}`);
1544
+ }
1545
+ continue;
1546
+ }
1547
+ if (rawKey === "lineClamp") {
1548
+ const sValue = String(value);
1549
+ if (sValue.startsWith("--")) {
1550
+ className += `line-clamp-(${sValue})`;
1551
+ } else {
1552
+ const numVal = Number(sValue);
1553
+ if (!isNaN(numVal) && Number.isInteger(numVal)) {
1554
+ className += `line-clamp-${sValue}`;
1555
+ } else {
1556
+ className += `line-clamp-[${sValue}]`;
1557
+ }
1558
+ }
1559
+ classes.push(className);
1560
+ continue;
1561
+ }
1562
+ if (rawKey === "list" || rawKey === "listStyle") {
1563
+ const sValue = String(value);
1564
+ if (sValue.startsWith("--")) {
1565
+ className += `list-(${sValue})`;
1566
+ } else if (LIST_STYLE_STANDARD.has(sValue)) {
1567
+ className += `list-${sValue}`;
1568
+ } else {
1569
+ className += `list-[${sValue}]`;
1570
+ }
1571
+ classes.push(className);
1572
+ continue;
1573
+ }
1574
+ if (rawKey === "listPos") {
1575
+ className += `list-${value}`;
1576
+ classes.push(className);
1577
+ continue;
1578
+ }
1579
+ if (rawKey === "divideStyle") {
1580
+ className += `divide-${value}`;
1581
+ classes.push(className);
1582
+ continue;
1583
+ }
1584
+ if (rawKey === "decorationStyle" || rawKey === "textDecorationStyle") {
1585
+ className += `decoration-${value}`;
1586
+ classes.push(className);
1587
+ continue;
1588
+ }
1589
+ if (rawKey === "decorationColor" || rawKey === "textDecorationColor") {
1590
+ className += `decoration-${value}`;
1591
+ classes.push(className);
1592
+ continue;
1593
+ }
1594
+ if (rawKey === "decorationThickness" || rawKey === "textDecorationThickness") {
1595
+ if (needsArbitraryBrackets(value)) {
1596
+ className += `decoration-[${value}]`;
1597
+ } else if (value.startsWith("--")) {
1598
+ className += `decoration-(${value})`;
1599
+ } else {
1600
+ className += `decoration-${value}`;
1601
+ }
1602
+ classes.push(className);
1603
+ continue;
1604
+ }
1605
+ if (rawKey === "fontStretch") {
1606
+ const sValue = String(value);
1607
+ if (FONT_STRETCH_KEYWORDS.has(sValue)) {
1608
+ className += `font-${sValue}`;
1609
+ } else if (sValue.startsWith("--")) {
1610
+ className += `font-stretch-(${sValue})`;
1611
+ } else if (/^\d+%$/.test(sValue)) {
1612
+ className += `font-stretch-${sValue}`;
1613
+ } else {
1614
+ className += `font-stretch-[${sValue}]`;
1615
+ }
1616
+ classes.push(className);
1617
+ continue;
1618
+ }
1619
+ if (rawKey === "maxW" && value === "container") {
1620
+ classes.push("container");
1621
+ continue;
1622
+ }
1623
+ if (rawKey === "shadowColor") {
1624
+ if (String(value).startsWith("--")) {
1625
+ classes.push(`shadow-(color:${value})`);
1626
+ } else {
1627
+ classes.push(`shadow-${value}`);
1628
+ }
1629
+ continue;
1630
+ }
1631
+ if (rawKey === "brightness" || rawKey === "contrast" || rawKey === "saturate" || rawKey === "scale" || rawKey === "backdropBrightness" || rawKey === "backdropContrast" || rawKey === "backdropSaturate") {
1632
+ const prop = rawKey.startsWith("backdrop") ? `backdrop-${rawKey.slice(8).toLowerCase()}` : rawKey;
1633
+ const sValue = String(value);
1634
+ if (sValue.startsWith("--")) {
1635
+ classes.push(`${prop}-(${sValue})`);
1636
+ } else {
1637
+ classes.push(`${prop}-[${sValue}]`);
1638
+ }
1639
+ continue;
1640
+ }
1641
+ if (rawKey === "textShadow") {
1642
+ if (value === "none") {
1643
+ className += "text-shadow-none";
1644
+ } else if (value === "") {
1645
+ className += "text-shadow";
1646
+ } else if (needsArbitraryBrackets(value)) {
1647
+ className += `text-shadow-[${normalizeArbitraryValue(value)}]`;
1648
+ } else {
1649
+ className += `text-shadow-${value}`;
1650
+ }
1651
+ classes.push(className);
1652
+ continue;
1653
+ }
1654
+ if (rawKey === "textShadowColor") {
1655
+ className += `text-shadow-${value}`;
1656
+ classes.push(className);
1657
+ continue;
1658
+ }
1659
+ if (rawKey === "fromPos" || rawKey === "viaPos" || rawKey === "toPos") {
1660
+ const gradPrefix = rawKey.replace("Pos", "");
1661
+ const sValue = String(value);
1662
+ if (value.startsWith("--")) {
1663
+ classes.push(`${gradPrefix}-(${value})`);
1664
+ } else if (/^\d+%$/.test(sValue)) {
1665
+ classes.push(`${gradPrefix}-${sValue}`);
1666
+ } else {
1667
+ classes.push(`${gradPrefix}-[${sValue}]`);
1668
+ }
1669
+ continue;
1670
+ }
1671
+ if (rawKey === "bgImg") {
1672
+ const v = String(value).trim();
1673
+ if (v === "none") {
1674
+ classes.push("bg-none");
1675
+ continue;
1676
+ }
1677
+ const vNorm = v.startsWith("-") ? v.slice(1) : v;
1678
+ if (vNorm.startsWith("linear-") || vNorm.startsWith("radial") || vNorm.startsWith("conic") || vNorm.startsWith("gradient-to-")) {
1679
+ const vMapped = vNorm.startsWith("gradient-to-") ? vNorm.replace("gradient-to-", "linear-to-") : vNorm;
1680
+ if (v.startsWith("-")) {
1681
+ classes.push(`-bg-${vMapped}`);
1682
+ } else {
1683
+ classes.push(`bg-${vMapped}`);
1684
+ }
1685
+ continue;
1686
+ }
1687
+ if (v.startsWith("--")) {
1688
+ classes.push(`bg-(image:${v})`);
1689
+ continue;
1690
+ }
1691
+ if (v.startsWith("url(")) {
1692
+ classes.push(`bg-[${v}]`);
1693
+ continue;
1694
+ }
1695
+ classes.push(`bg-[url(${v})]`);
1696
+ continue;
1697
+ }
1698
+ if (rawKey === "bgPos") {
1699
+ const sVal = String(value);
1700
+ if (sVal.startsWith("--")) {
1701
+ classes.push(`bg-(${sVal})`);
1702
+ } else if (sVal.includes("_") || needsArbitraryBrackets(sVal)) {
1703
+ classes.push(`bg-[${normalizeArbitraryValue(sVal)}]`);
1704
+ } else {
1705
+ classes.push(`bg-${sVal}`);
1706
+ }
1707
+ continue;
1708
+ }
1709
+ if (rawKey === "maskPos") {
1710
+ className += `mask-${value}`;
1711
+ classes.push(className);
1712
+ continue;
1713
+ }
1714
+ if (rawKey === "maskRepeat") {
1715
+ if (value === "repeat") {
1716
+ className += "mask-repeat";
1717
+ } else if (value === "no-repeat") {
1718
+ className += "mask-no-repeat";
1719
+ } else {
1720
+ className += `mask-${value}`;
1721
+ }
1722
+ classes.push(className);
1723
+ continue;
1724
+ }
1725
+ if (rawKey === "maskSize") {
1726
+ className += `mask-${value}`;
1727
+ classes.push(className);
1728
+ continue;
1729
+ }
1730
+ if (rawKey === "maskShape") {
1731
+ className += `mask-${value}`;
1732
+ classes.push(className);
1733
+ continue;
1734
+ }
1735
+ if (rawKey === "maskComposite") {
1736
+ className += `mask-${value}`;
1737
+ classes.push(className);
1738
+ continue;
1739
+ }
1740
+ if (rawKey === "maskMode") {
1741
+ className += `mask-${value}`;
1742
+ classes.push(className);
1743
+ continue;
1744
+ }
1745
+ if (rawKey === "maskType") {
1746
+ className += `mask-type-${value}`;
1747
+ classes.push(className);
1748
+ continue;
1749
+ }
1750
+ if (rawKey === "content") {
1751
+ if (value.startsWith("--")) {
1752
+ className += `content-(${value})`;
1753
+ } else if (!["none", "empty"].includes(value)) {
1754
+ className += `content-[${value}]`;
1755
+ } else {
1756
+ className += `content-${value}`;
1757
+ }
1758
+ classes.push(className);
1759
+ continue;
1760
+ }
1761
+ if (rawKey === "borderTColor") {
1762
+ className += `border-t-${value}`;
1763
+ classes.push(className);
1764
+ continue;
1765
+ }
1766
+ if (rawKey === "borderRColor") {
1767
+ className += `border-r-${value}`;
1768
+ classes.push(className);
1769
+ continue;
1770
+ }
1771
+ if (rawKey === "borderBColor") {
1772
+ className += `border-b-${value}`;
1773
+ classes.push(className);
1774
+ continue;
1775
+ }
1776
+ if (rawKey === "borderLColor") {
1777
+ className += `border-l-${value}`;
1778
+ classes.push(className);
1779
+ continue;
1780
+ }
1781
+ if (rawKey === "borderXColor") {
1782
+ className += `border-x-${value}`;
1783
+ classes.push(className);
1784
+ continue;
1785
+ }
1786
+ if (rawKey === "borderYColor") {
1787
+ className += `border-y-${value}`;
1788
+ classes.push(className);
1789
+ continue;
1790
+ }
1791
+ if (rawKey === "transitionBehavior") {
1792
+ className += `transition-${value}`;
1793
+ classes.push(className);
1794
+ continue;
1795
+ }
1796
+ if (rawKey === "dropShadowColor") {
1797
+ if (value.startsWith("--")) {
1798
+ className += `drop-shadow-(color:${value})`;
1799
+ } else {
1800
+ className += `drop-shadow-${value}`;
1801
+ }
1802
+ classes.push(className);
1803
+ continue;
1804
+ }
1805
+ if (rawKey === "origin" || rawKey === "ease" || rawKey === "animate" || rawKey === "filter" || rawKey === "backdropFilter" || rawKey === "dropShadow") {
1806
+ const sVal = String(value);
1807
+ const prop = PROPERTY_MAP[rawKey] || rawKey;
1808
+ if (needsArbitraryBrackets(sVal) || sVal.includes("(") || sVal.includes("_") || sVal.includes("%")) {
1809
+ classes.push(`${prop}-[${normalizeArbitraryValue(sVal)}]`);
1810
+ continue;
1811
+ }
1812
+ }
1813
+ if (rawKey === "transformStyle") {
1814
+ if (value === "preserve-3d" || value === "3d") {
1815
+ className += "transform-3d";
1816
+ } else {
1817
+ className += `transform-${value}`;
1818
+ }
1819
+ classes.push(className);
1820
+ continue;
1821
+ }
1822
+ if (rawKey === "perspective") {
1823
+ const STANDARD_PERSPECTIVE = /* @__PURE__ */ new Set(["none", "normal", "dramatic", "midrange"]);
1824
+ if (STANDARD_PERSPECTIVE.has(value)) {
1825
+ className += `perspective-${value}`;
1826
+ } else if (value.startsWith("--")) {
1827
+ className += `perspective-(${value})`;
1828
+ } else if (needsArbitraryBrackets(value)) {
1829
+ className += `perspective-[${value}]`;
1830
+ } else {
1831
+ className += `perspective-${value}`;
1832
+ }
1833
+ classes.push(className);
1834
+ continue;
1835
+ }
1836
+ if (rawKey === "perspectiveOrigin") {
1837
+ const STANDARD_ORIGINS = /* @__PURE__ */ new Set(["center", "top", "right", "bottom", "left", "top-left", "top-right", "bottom-left", "bottom-right"]);
1838
+ if (STANDARD_ORIGINS.has(value)) {
1839
+ className += `perspective-origin-${value}`;
1840
+ } else {
1841
+ className += `perspective-origin-[${value}]`;
1842
+ }
1843
+ classes.push(className);
1844
+ continue;
1845
+ }
1846
+ if (rawKey === "backface") {
1847
+ className += `backface-${value}`;
1848
+ classes.push(className);
1849
+ continue;
1850
+ }
1851
+ }
1852
+ if (process.env.NODE_ENV !== "production" && typeof window === "undefined") {
1853
+ const isKnown = PROPERTY_MAP[rawKey] || BOOLEAN_SHORTHANDS.has(rawKey) || SNAP_DIRECT_MAP[rawKey] || NEEDS_ARBITRARY_PROPERTY.has(key) || rawKey === "fromPos" || rawKey === "viaPos" || rawKey === "toPos" || rawKey.startsWith("--") || rawKey.startsWith("[") || rawKey.startsWith("@") || // Variants that fell through (e.g. empty object)
1854
+ KNOWN_VARIANTS.has(rawKey) || // Groups/Peers
1855
+ rawKey === "group" || rawKey === "peer" || // Special variant objects
1856
+ rawKey === "has" || rawKey === "not" || rawKey === "data" || rawKey === "aria" || rawKey === "supports" || rawKey === "min" || rawKey === "max";
1857
+ if (!isKnown) {
1858
+ const suggestion = SUGGESTION_MAP[rawKey];
1859
+ if (suggestion) {
1860
+ console.warn(
1861
+ `[csszyx] Use the canonical key "${suggestion}" instead of "${rawKey}".`
1862
+ );
1863
+ } else {
1864
+ console.warn(
1865
+ `[csszyx] Unknown property "${rawKey}" in sz prop. This will be ignored. Check for typos.`
1866
+ );
1867
+ }
1868
+ }
1869
+ }
1870
+ if (value === true) {
1871
+ if (BOOLEAN_SHORTHANDS.has(rawKey)) {
1872
+ const mappedClass = BOOLEAN_TO_CLASS[rawKey] || key;
1873
+ className += mappedClass;
1874
+ } else {
1875
+ className += key;
1876
+ }
1877
+ classes.push(className);
1878
+ continue;
1879
+ }
1880
+ if (typeof value === "number") {
1881
+ if (value < 0 && NEGATIVE_ALLOWED.has(key)) {
1882
+ className += `-${key}-${Math.abs(value)}`;
1883
+ } else {
1884
+ className += `${key}-${value}`;
1885
+ }
1886
+ classes.push(className);
1887
+ continue;
1888
+ }
1889
+ if (typeof value === "string") {
1890
+ const { value: cleanValue, important } = handleImportant(value);
1891
+ let finalValue = cleanValue;
1892
+ if (NEEDS_ARBITRARY_PROPERTY.has(key)) {
1893
+ const arbitraryProp = `[${key}:${finalValue}]`;
1894
+ className += arbitraryProp;
1895
+ if (important) {
1896
+ className += "!";
1897
+ }
1898
+ classes.push(className);
1899
+ continue;
1900
+ }
1901
+ const isAspectRatio = key === "aspect" && /^\d+\/\d+$/.test(finalValue);
1902
+ if (finalValue.startsWith("--")) {
1903
+ finalValue = `(${finalValue})`;
1904
+ } else if (finalValue.startsWith("var(")) {
1905
+ finalValue = `[${normalizeArbitraryValue(finalValue)}]`;
1906
+ } else if (/^\d+\/\d+$/.test(finalValue)) {
1907
+ if (!FRACTION_SUPPORTED_PROPS.has(rawKey)) {
1908
+ finalValue = `[${finalValue}]`;
1909
+ }
1910
+ } else if (needsArbitraryBrackets(finalValue) || isAspectRatio || /^\d+\.\d+%$/.test(finalValue)) {
1911
+ finalValue = `[${normalizeArbitraryValue(finalValue)}]`;
1912
+ }
1913
+ className += `${key}-${finalValue}`;
1914
+ if (important) {
1915
+ className += "!";
1916
+ }
1917
+ classes.push(className);
1918
+ }
1919
+ }
1920
+ const finalClasses = classes.filter(Boolean);
1921
+ if (mangleMap) {
1922
+ const mangledClasses = finalClasses.map((cls) => mangleMap[cls] || cls);
1923
+ return {
1924
+ className: mangledClasses.join(" "),
1925
+ attributes
1926
+ };
1927
+ }
1928
+ return {
1929
+ className: finalClasses.join(" "),
1930
+ attributes
1931
+ };
1932
+ }
1933
+ function isValidSzProp(szProp) {
1934
+ return szProp !== null && szProp !== void 0 && typeof szProp === "object" && !Array.isArray(szProp);
1935
+ }
1936
+ function normalizeClassName(className) {
1937
+ return className.split(/\s+/).filter(Boolean).join(" ");
1938
+ }
1939
+
1940
+ // src/transform.ts
1941
+ function transformSourceCode(source) {
1942
+ let usesRuntime = false;
1943
+ let usesColorVar = false;
1944
+ let transformed = false;
1945
+ if (!source.includes("sz")) {
1946
+ return { code: source, transformed: false, usesRuntime: false, usesColorVar: false };
1947
+ }
1948
+ try {
1949
+ const result = babel.transformSync(source, {
1950
+ filename: "file.tsx",
1951
+ // Enable TS/JSX parsing
1952
+ ast: true,
1953
+ code: true,
1954
+ configFile: false,
1955
+ babelrc: false,
1956
+ parserOpts: {
1957
+ plugins: ["typescript", "jsx"]
1958
+ },
1959
+ plugins: [
1960
+ function() {
1961
+ return {
1962
+ visitor: {
1963
+ JSXAttribute(path) {
1964
+ if (path.node.name.name !== "sz") {
1965
+ return;
1966
+ }
1967
+ const value = path.node.value;
1968
+ if (t.isStringLiteral(value)) {
1969
+ path.node.name.name = "className";
1970
+ transformed = true;
1971
+ return;
1972
+ }
1973
+ if (t.isJSXExpressionContainer(value)) {
1974
+ const expression = value.expression;
1975
+ if (t.isObjectExpression(expression)) {
1976
+ const staticObject = evaluateStaticObject(expression);
1977
+ if (staticObject !== null) {
1978
+ const { className, attributes } = transform(staticObject);
1979
+ path.node.name.name = "className";
1980
+ path.node.value = t.stringLiteral(className);
1981
+ Object.entries(attributes).forEach(([key, val]) => {
1982
+ if (path.parentPath?.isJSXOpeningElement()) {
1983
+ path.parentPath.node.attributes.push(
1984
+ t.jsxAttribute(
1985
+ t.jsxIdentifier(key),
1986
+ t.stringLiteral(val)
1987
+ )
1988
+ );
1989
+ }
1990
+ });
1991
+ transformed = true;
1992
+ return;
1993
+ }
1994
+ const partial = evaluatePartialObject(expression);
1995
+ if (partial !== null && !partial.hasSpread && partial.dynamicProps.size > 0) {
1996
+ const staticClasses = [];
1997
+ if (Object.keys(partial.staticProps).length > 0) {
1998
+ const { className: sc } = transform(partial.staticProps);
1999
+ if (sc) {
2000
+ staticClasses.push(sc);
2001
+ }
2002
+ }
2003
+ const cssVarClasses = [];
2004
+ const styleProps = [];
2005
+ for (const [, info] of partial.dynamicProps) {
2006
+ if (!info.skipClass) {
2007
+ cssVarClasses.push(buildCSSVarClassName(info));
2008
+ }
2009
+ styleProps.push(
2010
+ t.objectProperty(
2011
+ t.stringLiteral(info.varName),
2012
+ generateStyleValueExpression(info)
2013
+ )
2014
+ );
2015
+ }
2016
+ const allClasses = [...staticClasses, ...partial.rawClasses, ...cssVarClasses].join(" ");
2017
+ path.node.name.name = "className";
2018
+ path.node.value = t.stringLiteral(allClasses);
2019
+ if (styleProps.length > 0 && path.parentPath?.isJSXOpeningElement()) {
2020
+ const styleAttr = t.jsxAttribute(
2021
+ t.jsxIdentifier("style"),
2022
+ t.jsxExpressionContainer(
2023
+ t.objectExpression(styleProps)
2024
+ )
2025
+ );
2026
+ path.parentPath.node.attributes.push(styleAttr);
2027
+ }
2028
+ if (partial.usesColorVar) {
2029
+ usesColorVar = true;
2030
+ }
2031
+ transformed = true;
2032
+ return;
2033
+ }
2034
+ }
2035
+ if (t.isIdentifier(expression) && !t.isJSXEmptyExpression(expression)) {
2036
+ const binding = path.scope.getBinding(expression.name);
2037
+ if (binding && binding.path.isVariableDeclarator()) {
2038
+ const init2 = binding.path.node.init;
2039
+ if (init2) {
2040
+ const resolved = tryStaticTransformNode(init2);
2041
+ if (resolved !== null) {
2042
+ path.node.name.name = "className";
2043
+ if (t.isStringLiteral(resolved)) {
2044
+ path.node.value = resolved;
2045
+ } else {
2046
+ value.expression = resolved;
2047
+ }
2048
+ transformed = true;
2049
+ return;
2050
+ }
2051
+ }
2052
+ }
2053
+ }
2054
+ if (t.isConditionalExpression(expression)) {
2055
+ const resolved = tryStaticTransformNode(expression);
2056
+ if (resolved !== null) {
2057
+ path.node.name.name = "className";
2058
+ if (t.isStringLiteral(resolved)) {
2059
+ path.node.value = resolved;
2060
+ } else {
2061
+ value.expression = resolved;
2062
+ }
2063
+ transformed = true;
2064
+ return;
2065
+ }
2066
+ }
2067
+ path.node.name.name = "className";
2068
+ const szCall = t.callExpression(
2069
+ t.identifier("_sz"),
2070
+ [expression]
2071
+ );
2072
+ value.expression = szCall;
2073
+ usesRuntime = true;
2074
+ transformed = true;
2075
+ }
2076
+ }
2077
+ }
2078
+ };
2079
+ }
2080
+ ]
2081
+ });
2082
+ return {
2083
+ code: result?.code || source,
2084
+ transformed,
2085
+ usesRuntime,
2086
+ usesColorVar
2087
+ };
2088
+ } catch (e) {
2089
+ console.warn("[csszyx] AST transform failed, falling back to original code:", e);
2090
+ return { code: source, transformed: false, usesRuntime: false, usesColorVar: false };
2091
+ }
2092
+ }
2093
+ function tryStaticTransformNode(node) {
2094
+ if (t.isObjectExpression(node)) {
2095
+ const staticObj = evaluateStaticObject(node);
2096
+ if (staticObj !== null) {
2097
+ const { className } = transform(staticObj);
2098
+ return t.stringLiteral(className);
2099
+ }
2100
+ return null;
2101
+ }
2102
+ if (t.isStringLiteral(node)) {
2103
+ return node;
2104
+ }
2105
+ if (t.isConditionalExpression(node)) {
2106
+ const consequent = tryStaticTransformNode(node.consequent);
2107
+ const alternate = tryStaticTransformNode(node.alternate);
2108
+ if (consequent !== null && alternate !== null) {
2109
+ return t.conditionalExpression(node.test, consequent, alternate);
2110
+ }
2111
+ return null;
2112
+ }
2113
+ return null;
2114
+ }
2115
+ function evaluateStaticObject(node) {
2116
+ const result = {};
2117
+ for (const prop of node.properties) {
2118
+ if (!t.isObjectProperty(prop)) {
2119
+ return null;
2120
+ }
2121
+ if (prop.computed) {
2122
+ return null;
2123
+ }
2124
+ let key;
2125
+ if (t.isIdentifier(prop.key)) {
2126
+ key = prop.key.name;
2127
+ } else if (t.isStringLiteral(prop.key)) {
2128
+ key = prop.key.value;
2129
+ } else {
2130
+ return null;
2131
+ }
2132
+ const value = prop.value;
2133
+ if (t.isStringLiteral(value)) {
2134
+ result[key] = value.value;
2135
+ } else if (t.isNumericLiteral(value)) {
2136
+ result[key] = value.value;
2137
+ } else if (t.isBooleanLiteral(value)) {
2138
+ result[key] = value.value;
2139
+ } else if (t.isUnaryExpression(value) && value.operator === "-" && t.isNumericLiteral(value.argument)) {
2140
+ result[key] = -value.argument.value;
2141
+ } else if (t.isObjectExpression(value)) {
2142
+ const nested = evaluateStaticObject(value);
2143
+ if (nested === null) {
2144
+ return null;
2145
+ }
2146
+ result[key] = nested;
2147
+ } else {
2148
+ return null;
2149
+ }
2150
+ }
2151
+ return result;
2152
+ }
2153
+ function evaluatePartialObject(node, variantChain = "") {
2154
+ const staticProps = {};
2155
+ const dynamicProps = /* @__PURE__ */ new Map();
2156
+ const rawClasses = [];
2157
+ let usesColorVar = false;
2158
+ for (const prop of node.properties) {
2159
+ if (t.isSpreadElement(prop)) {
2160
+ return null;
2161
+ }
2162
+ if (!t.isObjectProperty(prop)) {
2163
+ return null;
2164
+ }
2165
+ if (prop.computed) {
2166
+ return null;
2167
+ }
2168
+ let key;
2169
+ if (t.isIdentifier(prop.key)) {
2170
+ key = prop.key.name;
2171
+ } else if (t.isStringLiteral(prop.key)) {
2172
+ key = prop.key.value;
2173
+ } else {
2174
+ return null;
2175
+ }
2176
+ const value = prop.value;
2177
+ if (t.isStringLiteral(value)) {
2178
+ staticProps[key] = value.value;
2179
+ } else if (t.isNumericLiteral(value)) {
2180
+ staticProps[key] = value.value;
2181
+ } else if (t.isBooleanLiteral(value)) {
2182
+ staticProps[key] = value.value;
2183
+ } else if (t.isUnaryExpression(value) && value.operator === "-" && t.isNumericLiteral(value.argument)) {
2184
+ staticProps[key] = -value.argument.value;
2185
+ } else if (t.isObjectExpression(value)) {
2186
+ const nested = evaluateStaticObject(value);
2187
+ if (nested !== null) {
2188
+ staticProps[key] = nested;
2189
+ } else {
2190
+ const colorObjProps = /* @__PURE__ */ new Map();
2191
+ for (const p of value.properties) {
2192
+ if (t.isObjectProperty(p) && !p.computed && t.isIdentifier(p.key)) {
2193
+ colorObjProps.set(p.key.name, p);
2194
+ }
2195
+ }
2196
+ if (colorObjProps.has("color") && COLOR_PROPERTIES.has(key)) {
2197
+ const colorProp = colorObjProps.get("color");
2198
+ if (!colorProp) {
2199
+ continue;
2200
+ }
2201
+ const opProp = colorObjProps.get("op");
2202
+ const twPrefix = PROPERTY_MAP[key] || key.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
2203
+ let colorStr = null;
2204
+ if (t.isStringLiteral(colorProp.value)) {
2205
+ colorStr = colorProp.value.value;
2206
+ }
2207
+ if (colorStr && opProp) {
2208
+ const opVarName = getCSSVariableName(`${key}-op`, variantChain || void 0);
2209
+ const uniqueKey = variantChain ? `${variantChain}-${key}-op` : `${key}-op`;
2210
+ if (t.isStringLiteral(opProp.value) || t.isNumericLiteral(opProp.value)) {
2211
+ const opVal = t.isStringLiteral(opProp.value) ? opProp.value.value : opProp.value.value;
2212
+ staticProps[key] = { color: colorStr, op: opVal };
2213
+ } else if (t.isExpression(opProp.value)) {
2214
+ const variantPfx = variantChain ? `${variantChain}:` : "";
2215
+ rawClasses.push(`${variantPfx}${twPrefix}-${colorStr}/[var(${opVarName})]`);
2216
+ dynamicProps.set(uniqueKey, {
2217
+ expression: opProp.value,
2218
+ category: 3 /* UNITLESS */,
2219
+ varName: opVarName,
2220
+ twPrefix: `${twPrefix}-op`,
2221
+ variantChain: variantChain || "",
2222
+ skipClass: true
2223
+ });
2224
+ }
2225
+ } else if (!colorStr && opProp) {
2226
+ const varName = getCSSVariableName(key, variantChain || void 0);
2227
+ const uniqueKey = variantChain ? `${variantChain}-${key}` : key;
2228
+ usesColorVar = true;
2229
+ dynamicProps.set(uniqueKey, {
2230
+ expression: t.isExpression(colorProp.value) ? colorProp.value : t.stringLiteral(""),
2231
+ category: 1 /* COLOR */,
2232
+ varName,
2233
+ twPrefix,
2234
+ variantChain: variantChain || ""
2235
+ });
2236
+ } else if (colorStr && !opProp) {
2237
+ staticProps[key] = colorStr;
2238
+ }
2239
+ } else {
2240
+ const isVariant = KNOWN_VARIANTS.has(key) || KNOWN_VARIANTS.has(getVariantPrefix(key));
2241
+ if (isVariant) {
2242
+ const variantKey = variantChain ? `${variantChain}-${key}` : key;
2243
+ const nestedResult = evaluatePartialObject(value, variantKey);
2244
+ if (nestedResult === null) {
2245
+ return null;
2246
+ }
2247
+ if (Object.keys(nestedResult.staticProps).length > 0) {
2248
+ staticProps[key] = nestedResult.staticProps;
2249
+ }
2250
+ for (const [k, v] of nestedResult.dynamicProps) {
2251
+ dynamicProps.set(k, v);
2252
+ }
2253
+ rawClasses.push(...nestedResult.rawClasses);
2254
+ if (nestedResult.usesColorVar) {
2255
+ usesColorVar = true;
2256
+ }
2257
+ } else {
2258
+ return null;
2259
+ }
2260
+ }
2261
+ }
2262
+ } else if (t.isExpression(value)) {
2263
+ const twPrefix = PROPERTY_MAP[key] || key.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
2264
+ const category = getPropertyCategory(key);
2265
+ const varName = getCSSVariableName(key, variantChain || void 0);
2266
+ const uniqueKey = variantChain ? `${variantChain}-${key}` : key;
2267
+ if (COLOR_PROPERTIES.has(key)) {
2268
+ usesColorVar = true;
2269
+ }
2270
+ dynamicProps.set(uniqueKey, {
2271
+ expression: value,
2272
+ category,
2273
+ varName,
2274
+ twPrefix,
2275
+ variantChain: variantChain || ""
2276
+ });
2277
+ } else {
2278
+ return null;
2279
+ }
2280
+ }
2281
+ return { staticProps, dynamicProps, rawClasses, hasSpread: false, usesColorVar };
2282
+ }
2283
+ function generateStyleValueExpression(info) {
2284
+ const { expression, category } = info;
2285
+ switch (category) {
2286
+ case 0 /* SPACING */:
2287
+ return t.templateLiteral(
2288
+ [
2289
+ t.templateElement({ raw: "calc(", cooked: "calc(" }, false),
2290
+ t.templateElement({ raw: " * var(--spacing))", cooked: " * var(--spacing))" }, true)
2291
+ ],
2292
+ [expression]
2293
+ );
2294
+ case 1 /* COLOR */:
2295
+ return t.callExpression(
2296
+ t.identifier("__szColorVar"),
2297
+ [expression]
2298
+ );
2299
+ case 4 /* ANGLE */:
2300
+ return t.templateLiteral(
2301
+ [
2302
+ t.templateElement({ raw: "", cooked: "" }, false),
2303
+ t.templateElement({ raw: "deg", cooked: "deg" }, true)
2304
+ ],
2305
+ [expression]
2306
+ );
2307
+ case 5 /* DURATION */:
2308
+ return t.templateLiteral(
2309
+ [
2310
+ t.templateElement({ raw: "", cooked: "" }, false),
2311
+ t.templateElement({ raw: "ms", cooked: "ms" }, true)
2312
+ ],
2313
+ [expression]
2314
+ );
2315
+ case 3 /* UNITLESS */:
2316
+ case 7 /* PASSTHROUGH */:
2317
+ case 2 /* FRACTION */:
2318
+ case 6 /* ARBITRARY */:
2319
+ default:
2320
+ return t.templateLiteral(
2321
+ [
2322
+ t.templateElement({ raw: "", cooked: "" }, false),
2323
+ t.templateElement({ raw: "", cooked: "" }, true)
2324
+ ],
2325
+ [expression]
2326
+ );
2327
+ }
2328
+ }
2329
+ function buildCSSVarClassName(info) {
2330
+ const { twPrefix, varName, variantChain } = info;
2331
+ const variantPrefix = variantChain ? `${getVariantPrefix(variantChain)}:` : "";
2332
+ return `${variantPrefix}${twPrefix}-[var(${varName})]`;
2333
+ }
2334
+
2335
+ // src/compiler.ts
2336
+ var CsszyxCompiler = class _CsszyxCompiler {
2337
+ /**
2338
+ * Private constructor to enforce singleton pattern.
2339
+ */
2340
+ constructor() {
2341
+ this.wasmLoaded = false;
2342
+ }
2343
+ /**
2344
+ * Gets the singleton instance of the compiler.
2345
+ *
2346
+ * @returns {CsszyxCompiler} The compiler instance.
2347
+ */
2348
+ static getInstance() {
2349
+ if (!_CsszyxCompiler.instance) {
2350
+ _CsszyxCompiler.instance = new _CsszyxCompiler();
2351
+ }
2352
+ return _CsszyxCompiler.instance;
2353
+ }
2354
+ /**
2355
+ * Initializes the WASM core.
2356
+ *
2357
+ * @returns {Promise<void>} Resolves when WASM is ready.
2358
+ */
2359
+ async init() {
2360
+ if (this.wasmLoaded) {
2361
+ return;
2362
+ }
2363
+ try {
2364
+ init();
2365
+ this.wasmLoaded = true;
2366
+ console.info(`[csszyx] WASM Core initialized (v${getWasmVersion()})`);
2367
+ } catch (error) {
2368
+ console.warn(
2369
+ "[csszyx] Failed to initialize WASM core, falling back to JavaScript transformer",
2370
+ error
2371
+ );
2372
+ this.wasmLoaded = false;
2373
+ }
2374
+ }
2375
+ /**
2376
+ * Transforms an sz object into Tailwind classes.
2377
+ *
2378
+ * @param {SzObject} sz - The object to transform.
2379
+ * @returns {string} The transformed class string.
2380
+ */
2381
+ transform(sz) {
2382
+ if (this.wasmLoaded) {
2383
+ try {
2384
+ return transform_sz(sz);
2385
+ } catch (error) {
2386
+ console.warn(
2387
+ "[csszyx] WASM transformation failed, using JS fallback",
2388
+ error
2389
+ );
2390
+ return transform(sz).className;
2391
+ }
2392
+ }
2393
+ return transform(sz).className;
2394
+ }
2395
+ /**
2396
+ * Checks if the WASM core is currently active.
2397
+ *
2398
+ * @returns {boolean} True if WASM is loaded.
2399
+ */
2400
+ isWasmActive() {
2401
+ return this.wasmLoaded;
2402
+ }
2403
+ /**
2404
+ * Generates a recovery token using WASM or JS fallback.
2405
+ *
2406
+ * @param {object} metadata - Token metadata
2407
+ * @param metadata.component - Component name
2408
+ * @param metadata.filePath - File path source
2409
+ * @param metadata.line - Line number
2410
+ * @param metadata.column - Column number
2411
+ * @param metadata.mode - Build mode (dev/prod)
2412
+ * @param metadata.buildId - Unique build identifier
2413
+ * @returns {string} The generated token
2414
+ */
2415
+ generateRecoveryToken(metadata) {
2416
+ if (this.wasmLoaded) {
2417
+ try {
2418
+ const { generate_token } = __require("@csszyx/core");
2419
+ return generate_token(
2420
+ metadata.component,
2421
+ metadata.filePath,
2422
+ metadata.line,
2423
+ metadata.column,
2424
+ metadata.mode,
2425
+ metadata.buildId
2426
+ );
2427
+ } catch (error) {
2428
+ console.warn("[csszyx] WASM token generation failed", error);
2429
+ }
2430
+ }
2431
+ const str = `${metadata.component}:${metadata.filePath}:${metadata.line}:${metadata.column}:${metadata.mode}:${metadata.buildId}`;
2432
+ let hash = 0;
2433
+ for (let i = 0; i < str.length; i++) {
2434
+ hash = (hash << 5) - hash + str.charCodeAt(i) | 0;
2435
+ }
2436
+ return Math.abs(hash).toString(16).padStart(12, "0").slice(0, 12);
2437
+ }
2438
+ };
2439
+
2440
+ // src/recovery.ts
2441
+ function isValidRecoveryMode(value) {
2442
+ return value === "csr" || value === "dev-only";
2443
+ }
2444
+ function generateRecoveryToken(metadata) {
2445
+ return CsszyxCompiler.getInstance().generateRecoveryToken(metadata);
2446
+ }
2447
+ function createRecoveryToken(metadata, buildId) {
2448
+ const fullMetadata = {
2449
+ ...metadata,
2450
+ buildId
2451
+ };
2452
+ const token = generateRecoveryToken(fullMetadata);
2453
+ return {
2454
+ token,
2455
+ metadata: fullMetadata
2456
+ };
2457
+ }
2458
+ function validateSzRecover(value, componentName) {
2459
+ if (!isValidRecoveryMode(value)) {
2460
+ return {
2461
+ valid: false,
2462
+ error: `szRecover in ${componentName} must be static literal "csr" or "dev-only", got: ${JSON.stringify(value)}`
2463
+ };
2464
+ }
2465
+ return { valid: true };
2466
+ }
2467
+ function injectRecoveryToken(attributes, token) {
2468
+ return {
2469
+ ...attributes,
2470
+ "data-sz-recovery-token": token
2471
+ };
2472
+ }
2473
+
2474
+ // src/manifest.ts
2475
+ import { createHash } from "crypto";
2476
+ var ManifestBuilder = class {
2477
+ /**
2478
+ * Creates a new manifest builder.
2479
+ *
2480
+ * @param {string} buildId - Build ID (git hash or timestamp)
2481
+ *
2482
+ * @example
2483
+ * ```typescript
2484
+ * const builder = new ManifestBuilder('abc123');
2485
+ * ```
2486
+ */
2487
+ constructor(buildId) {
2488
+ this.tokens = /* @__PURE__ */ new Map();
2489
+ this.buildId = buildId;
2490
+ }
2491
+ /**
2492
+ * Adds a token to the manifest.
2493
+ *
2494
+ * @param {string} token - The recovery token
2495
+ * @param {TokenMetadata} metadata - Token metadata
2496
+ *
2497
+ * @example
2498
+ * ```typescript
2499
+ * builder.addToken('a94f1c2e8b3d', {
2500
+ * mode: 'csr',
2501
+ * component: 'Button',
2502
+ * filePath: '/app/Button.tsx',
2503
+ * line: 10,
2504
+ * column: 5,
2505
+ * buildId: 'abc123'
2506
+ * });
2507
+ * ```
2508
+ */
2509
+ addToken(token, metadata) {
2510
+ const relativePath = this.toRelativePath(metadata.filePath);
2511
+ this.tokens.set(token, {
2512
+ mode: metadata.mode,
2513
+ component: metadata.component,
2514
+ path: relativePath
2515
+ });
2516
+ }
2517
+ /**
2518
+ * Converts absolute path to relative path.
2519
+ *
2520
+ * @param {string} absolutePath - Absolute file path
2521
+ * @returns {string} Relative path
2522
+ */
2523
+ toRelativePath(absolutePath) {
2524
+ if (absolutePath.startsWith("/")) {
2525
+ const parts = absolutePath.split("/");
2526
+ const rootIndex = parts.findIndex(
2527
+ (p) => p === "src" || p === "app" || p === "components"
2528
+ );
2529
+ if (rootIndex > 0) {
2530
+ return parts.slice(rootIndex).join("/");
2531
+ }
2532
+ }
2533
+ return absolutePath;
2534
+ }
2535
+ /**
2536
+ * Computes checksum of the tokens object.
2537
+ *
2538
+ * @param {Record<string, TokenData>} tokens - Tokens object
2539
+ * @returns {string} SHA-256 checksum
2540
+ */
2541
+ computeChecksum(tokens) {
2542
+ const sortedKeys = Object.keys(tokens).sort();
2543
+ const sortedTokens = {};
2544
+ for (const key of sortedKeys) {
2545
+ sortedTokens[key] = tokens[key];
2546
+ }
2547
+ const content = JSON.stringify(sortedTokens);
2548
+ return createHash("sha256").update(content).digest("hex");
2549
+ }
2550
+ /**
2551
+ * Builds the final recovery manifest.
2552
+ *
2553
+ * @returns {RecoveryManifest} The complete recovery manifest
2554
+ *
2555
+ * @example
2556
+ * ```typescript
2557
+ * const manifest = builder.build();
2558
+ * // Returns: { buildId: 'abc123', checksum: '...', tokens: {...} }
2559
+ * ```
2560
+ */
2561
+ build() {
2562
+ const tokensObject = {};
2563
+ for (const [token, data] of this.tokens.entries()) {
2564
+ tokensObject[token] = data;
2565
+ }
2566
+ const checksum = this.computeChecksum(tokensObject);
2567
+ return {
2568
+ buildId: this.buildId,
2569
+ checksum,
2570
+ tokens: tokensObject
2571
+ };
2572
+ }
2573
+ /**
2574
+ * Gets the number of tokens in the manifest.
2575
+ *
2576
+ * @returns {number} Token count
2577
+ */
2578
+ size() {
2579
+ return this.tokens.size;
2580
+ }
2581
+ /**
2582
+ * Checks if a token exists in the manifest.
2583
+ *
2584
+ * @param {string} token - Token to check
2585
+ * @returns {boolean} True if token exists
2586
+ */
2587
+ hasToken(token) {
2588
+ return this.tokens.has(token);
2589
+ }
2590
+ /**
2591
+ * Clears all tokens from the manifest.
2592
+ */
2593
+ clear() {
2594
+ this.tokens.clear();
2595
+ }
2596
+ };
2597
+ function serializeManifest(manifest, pretty = false) {
2598
+ return JSON.stringify(manifest, null, pretty ? 2 : 0);
2599
+ }
2600
+ function parseManifest(json) {
2601
+ const parsed = JSON.parse(json);
2602
+ if (!parsed.buildId || !parsed.checksum || !parsed.tokens) {
2603
+ throw new Error("Invalid recovery manifest format");
2604
+ }
2605
+ return parsed;
2606
+ }
2607
+ function validateManifest(manifest) {
2608
+ if (!manifest || typeof manifest !== "object") {
2609
+ return { valid: false, error: "Manifest must be an object" };
2610
+ }
2611
+ const m = manifest;
2612
+ if (typeof m.buildId !== "string") {
2613
+ return { valid: false, error: "buildId must be a string" };
2614
+ }
2615
+ if (typeof m.checksum !== "string") {
2616
+ return { valid: false, error: "checksum must be a string" };
2617
+ }
2618
+ if (!m.tokens || typeof m.tokens !== "object") {
2619
+ return { valid: false, error: "tokens must be an object" };
2620
+ }
2621
+ return { valid: true };
2622
+ }
2623
+
2624
+ // src/hoisting.ts
2625
+ import * as t2 from "@babel/types";
2626
+ function findLCA(nodeA, nodeB, parentMap) {
2627
+ const ancestorsA = /* @__PURE__ */ new Set();
2628
+ let current = nodeA;
2629
+ while (current) {
2630
+ ancestorsA.add(current);
2631
+ current = parentMap.get(current);
2632
+ }
2633
+ current = nodeB;
2634
+ while (current) {
2635
+ if (ancestorsA.has(current) && t2.isJSXOpeningElement(current) && current !== nodeA && current !== nodeB) {
2636
+ return current;
2637
+ }
2638
+ current = parentMap.get(current);
2639
+ }
2640
+ return null;
2641
+ }
2642
+ function isFragment(node) {
2643
+ if (t2.isJSXIdentifier(node.name)) {
2644
+ return node.name.name === "Fragment";
2645
+ }
2646
+ if (t2.isJSXMemberExpression(node.name)) {
2647
+ return t2.isJSXIdentifier(node.name.property) && node.name.property.name === "Fragment";
2648
+ }
2649
+ return false;
2650
+ }
2651
+ function removeStyleVar(element, varName) {
2652
+ for (const attr of element.attributes) {
2653
+ if (!t2.isJSXAttribute(attr)) {
2654
+ continue;
2655
+ }
2656
+ if (!t2.isJSXIdentifier(attr.name) || attr.name.name !== "style") {
2657
+ continue;
2658
+ }
2659
+ if (!t2.isJSXExpressionContainer(attr.value)) {
2660
+ continue;
2661
+ }
2662
+ const styleObj = attr.value.expression;
2663
+ if (!t2.isObjectExpression(styleObj)) {
2664
+ continue;
2665
+ }
2666
+ styleObj.properties = styleObj.properties.filter((prop) => {
2667
+ if (!t2.isObjectProperty(prop)) {
2668
+ return true;
2669
+ }
2670
+ if (t2.isStringLiteral(prop.key)) {
2671
+ return prop.key.value !== varName;
2672
+ }
2673
+ return true;
2674
+ });
2675
+ if (styleObj.properties.length === 0) {
2676
+ const idx = element.attributes.indexOf(attr);
2677
+ if (idx !== -1) {
2678
+ element.attributes.splice(idx, 1);
2679
+ }
2680
+ }
2681
+ break;
2682
+ }
2683
+ }
2684
+ function addStyleVar(element, varName, valueExpr) {
2685
+ for (const attr of element.attributes) {
2686
+ if (!t2.isJSXAttribute(attr)) {
2687
+ continue;
2688
+ }
2689
+ if (!t2.isJSXIdentifier(attr.name) || attr.name.name !== "style") {
2690
+ continue;
2691
+ }
2692
+ if (!t2.isJSXExpressionContainer(attr.value)) {
2693
+ continue;
2694
+ }
2695
+ const styleObj = attr.value.expression;
2696
+ if (!t2.isObjectExpression(styleObj)) {
2697
+ continue;
2698
+ }
2699
+ const existing = styleObj.properties.find(
2700
+ (prop) => t2.isObjectProperty(prop) && t2.isStringLiteral(prop.key) && prop.key.value === varName
2701
+ );
2702
+ if (!existing) {
2703
+ styleObj.properties.push(
2704
+ t2.objectProperty(t2.stringLiteral(varName), valueExpr)
2705
+ );
2706
+ }
2707
+ return;
2708
+ }
2709
+ element.attributes.push(
2710
+ t2.jsxAttribute(
2711
+ t2.jsxIdentifier("style"),
2712
+ t2.jsxExpressionContainer(
2713
+ t2.objectExpression([
2714
+ t2.objectProperty(t2.stringLiteral(varName), valueExpr)
2715
+ ])
2716
+ )
2717
+ )
2718
+ );
2719
+ }
2720
+ function hoistCSSVariables(usages, parentMap) {
2721
+ if (usages.length < 2) {
2722
+ return;
2723
+ }
2724
+ const groups = /* @__PURE__ */ new Map();
2725
+ for (const usage of usages) {
2726
+ if (usage.serializedValue === null) {
2727
+ continue;
2728
+ }
2729
+ const groupKey = `${usage.varName}::${usage.serializedValue}`;
2730
+ const group = groups.get(groupKey) || [];
2731
+ group.push(usage);
2732
+ groups.set(groupKey, group);
2733
+ }
2734
+ for (const [, group] of groups) {
2735
+ if (group.length < 2) {
2736
+ continue;
2737
+ }
2738
+ let lca = group[0].element;
2739
+ for (let i = 1; i < group.length; i++) {
2740
+ const newLca = findLCA(lca, group[i].element, parentMap);
2741
+ if (newLca === null || isFragment(newLca)) {
2742
+ lca = null;
2743
+ break;
2744
+ }
2745
+ lca = newLca;
2746
+ }
2747
+ if (!lca) {
2748
+ continue;
2749
+ }
2750
+ addStyleVar(lca, group[0].varName, group[0].valueExpr);
2751
+ for (const usage of group) {
2752
+ removeStyleVar(usage.element, usage.varName);
2753
+ }
2754
+ }
2755
+ }
2756
+ function buildParentMap(ast) {
2757
+ const map = /* @__PURE__ */ new Map();
2758
+ function traverse(node, parent) {
2759
+ if (parent) {
2760
+ map.set(node, parent);
2761
+ }
2762
+ for (const key of Object.keys(node)) {
2763
+ const value = node[key];
2764
+ if (value && typeof value === "object") {
2765
+ if (Array.isArray(value)) {
2766
+ for (const item of value) {
2767
+ if (item && typeof item === "object" && "type" in item) {
2768
+ traverse(item, node);
2769
+ }
2770
+ }
2771
+ } else if ("type" in value) {
2772
+ traverse(value, node);
2773
+ }
2774
+ }
2775
+ }
2776
+ }
2777
+ traverse(ast);
2778
+ return map;
2779
+ }
2780
+
2781
+ // src/index.ts
2782
+ var VERSION = "0.0.0";
2783
+ var DEFAULT_COMPILER_OPTIONS = {
2784
+ buildId: Date.now().toString(),
2785
+ development: process.env.NODE_ENV !== "production",
2786
+ autoInjectRecovery: false,
2787
+ strictMode: false
2788
+ };
2789
+ function mergeOptions(options = {}) {
2790
+ return {
2791
+ ...DEFAULT_COMPILER_OPTIONS,
2792
+ ...options
2793
+ };
2794
+ }
2795
+ export {
2796
+ COLOR_PROPERTIES,
2797
+ CsszyxCompiler,
2798
+ DEFAULT_COMPILER_OPTIONS,
2799
+ ManifestBuilder,
2800
+ PROPERTY_CATEGORY_MAP,
2801
+ PropertyCategory,
2802
+ VERSION,
2803
+ buildParentMap,
2804
+ createRecoveryToken,
2805
+ generateRecoveryToken,
2806
+ getCSSVariableName,
2807
+ getPropertyCategory,
2808
+ hoistCSSVariables,
2809
+ injectRecoveryToken,
2810
+ isValidRecoveryMode,
2811
+ isValidSzProp,
2812
+ mergeOptions,
2813
+ normalizeClassName,
2814
+ parseManifest,
2815
+ serializeManifest,
2816
+ transform,
2817
+ transformSourceCode,
2818
+ validateManifest,
2819
+ validateSzRecover
2820
+ };