chaincss 2.0.7 → 2.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.
Files changed (159) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/CODE_OF_CONDUCT.md +21 -0
  3. package/CONTRIBUTING.md +28 -0
  4. package/README.md +455 -226
  5. package/demo/demo/node_modules/caniuse-db/fulldata-json/data-2.0.json +1 -0
  6. package/demo/index.html +16 -0
  7. package/demo/package.json +20 -0
  8. package/demo/src/App.tsx +117 -0
  9. package/demo/src/chaincss-barrel.ts +9 -0
  10. package/demo/src/main.tsx +8 -0
  11. package/demo/src/styles.chain.ts +300 -0
  12. package/demo/vite.config.ts +46 -0
  13. package/dist/cli/commands/build.d.ts +0 -1
  14. package/dist/cli/commands/cache.d.ts +1 -0
  15. package/dist/cli/commands/init.d.ts +6 -3
  16. package/dist/cli/commands/timeline.d.ts +0 -1
  17. package/dist/cli/commands/watch.d.ts +0 -1
  18. package/dist/cli/index.d.ts +0 -1
  19. package/dist/cli/index.js +3213 -5296
  20. package/dist/cli/types.d.ts +51 -20
  21. package/dist/cli/utils/config-loader.d.ts +0 -1
  22. package/dist/cli/utils/file-utils.d.ts +27 -3
  23. package/dist/cli/utils/logger.d.ts +0 -1
  24. package/dist/compiler/Chain.d.ts +215 -0
  25. package/dist/compiler/animations.d.ts +76 -0
  26. package/dist/compiler/atomic-optimizer.d.ts +47 -12
  27. package/dist/compiler/breakpoints.d.ts +46 -0
  28. package/dist/compiler/btt.d.ts +36 -60
  29. package/dist/compiler/cache-manager.d.ts +58 -4
  30. package/dist/compiler/commonProps.d.ts +0 -1
  31. package/dist/compiler/content-addressable-cache.d.ts +78 -0
  32. package/dist/compiler/helpers.d.ts +54 -0
  33. package/dist/compiler/index.d.ts +16 -9
  34. package/dist/compiler/index.js +4450 -4316
  35. package/dist/compiler/prefixer.d.ts +17 -1
  36. package/dist/compiler/shorthands.d.ts +28 -0
  37. package/dist/compiler/suggestions.d.ts +43 -0
  38. package/dist/compiler/theme-contract.d.ts +16 -27
  39. package/dist/compiler/token-resolver.d.ts +69 -0
  40. package/dist/compiler/tokens.d.ts +33 -8
  41. package/dist/core/auto-detector.d.ts +34 -0
  42. package/dist/core/common-utils.d.ts +97 -0
  43. package/dist/core/compiler.d.ts +63 -23
  44. package/dist/core/constants.d.ts +137 -36
  45. package/dist/core/smart-chain.d.ts +3 -0
  46. package/dist/core/types.d.ts +122 -15
  47. package/dist/core/utils.d.ts +134 -17
  48. package/dist/index.d.ts +52 -8
  49. package/dist/index.js +7090 -5578
  50. package/dist/plugins/vite.d.ts +7 -5
  51. package/dist/plugins/vite.js +2964 -25641
  52. package/dist/plugins/webpack.d.ts +24 -1
  53. package/dist/plugins/webpack.js +209 -72
  54. package/dist/runtime/Chain.d.ts +32 -0
  55. package/dist/runtime/auto-hooks.d.ts +11 -0
  56. package/dist/runtime/hmr.d.ts +22 -2
  57. package/dist/runtime/index.d.ts +3 -2
  58. package/dist/runtime/index.js +3648 -301
  59. package/dist/runtime/injector.d.ts +39 -72
  60. package/dist/runtime/react.d.ts +17 -12
  61. package/dist/runtime/svelte.d.ts +15 -0
  62. package/dist/runtime/types.d.ts +126 -4
  63. package/dist/runtime/utils.d.ts +0 -1
  64. package/dist/runtime/vue.d.ts +34 -14
  65. package/package.json +59 -66
  66. package/src/cli/commands/build.ts +133 -0
  67. package/src/cli/commands/cache.ts +371 -0
  68. package/src/cli/commands/init.ts +230 -0
  69. package/src/cli/commands/timeline.ts +435 -0
  70. package/src/cli/commands/watch.ts +211 -0
  71. package/src/cli/index.ts +226 -0
  72. package/src/cli/types.ts +100 -0
  73. package/src/cli/utils/config-loader.ts +174 -0
  74. package/src/cli/utils/file-utils.ts +139 -0
  75. package/src/cli/utils/logger.ts +74 -0
  76. package/src/compiler/Chain.ts +831 -0
  77. package/src/compiler/animations.ts +517 -0
  78. package/src/compiler/atomic-optimizer.ts +786 -0
  79. package/src/compiler/breakpoints.ts +347 -0
  80. package/src/compiler/btt.ts +1147 -0
  81. package/src/compiler/cache-manager.ts +446 -0
  82. package/src/compiler/commonProps.ts +18 -0
  83. package/src/compiler/content-addressable-cache.ts +478 -0
  84. package/src/compiler/helpers.ts +407 -0
  85. package/src/compiler/index.ts +72 -0
  86. package/src/compiler/prefixer.ts +724 -0
  87. package/src/compiler/shorthands.ts +558 -0
  88. package/src/compiler/suggestions.ts +436 -0
  89. package/src/compiler/theme-contract.ts +197 -0
  90. package/src/compiler/token-resolver.ts +241 -0
  91. package/src/compiler/tokens.ts +612 -0
  92. package/src/core/auto-detector.ts +187 -0
  93. package/src/core/common-utils.ts +423 -0
  94. package/src/core/compiler.ts +835 -0
  95. package/src/core/constants.ts +424 -0
  96. package/src/core/index.ts +107 -0
  97. package/src/core/smart-chain.ts +163 -0
  98. package/src/core/types.ts +257 -0
  99. package/src/core/utils.ts +598 -0
  100. package/src/index.ts +208 -0
  101. package/src/plugins/vite.d.ts +316 -0
  102. package/src/plugins/vite.ts +424 -0
  103. package/src/plugins/webpack.d.ts +289 -0
  104. package/src/plugins/webpack.ts +416 -0
  105. package/src/runtime/Chain.ts +242 -0
  106. package/src/runtime/auto-hooks.tsx +127 -0
  107. package/src/runtime/auto-vue.ts +72 -0
  108. package/src/runtime/hmr.ts +212 -0
  109. package/src/runtime/index.ts +82 -0
  110. package/src/runtime/injector.ts +273 -0
  111. package/src/runtime/react.tsx +269 -0
  112. package/src/runtime/svelte.ts +15 -0
  113. package/src/runtime/types.ts +256 -0
  114. package/src/runtime/utils.ts +128 -0
  115. package/src/runtime/vite-env.d.ts +120 -0
  116. package/src/runtime/vue.ts +231 -0
  117. package/tsconfig.build.json +41 -0
  118. package/tsconfig.json +25 -0
  119. package/tsconfig.runtimes.json +18 -0
  120. package/dist/cli/cli.cjs +0 -7
  121. package/dist/cli/commands/build.d.ts.map +0 -1
  122. package/dist/cli/commands/compile.d.ts +0 -3
  123. package/dist/cli/commands/compile.d.ts.map +0 -1
  124. package/dist/cli/commands/init.d.ts.map +0 -1
  125. package/dist/cli/commands/timeline.d.ts.map +0 -1
  126. package/dist/cli/commands/watch.d.ts.map +0 -1
  127. package/dist/cli/index.d.ts.map +0 -1
  128. package/dist/cli/types.d.ts.map +0 -1
  129. package/dist/cli/utils/config-loader.d.ts.map +0 -1
  130. package/dist/cli/utils/file-utils.d.ts.map +0 -1
  131. package/dist/cli/utils/logger.d.ts.map +0 -1
  132. package/dist/compiler/atomic-optimizer.d.ts.map +0 -1
  133. package/dist/compiler/btt.d.ts.map +0 -1
  134. package/dist/compiler/cache-manager.d.ts.map +0 -1
  135. package/dist/compiler/commonProps.d.ts.map +0 -1
  136. package/dist/compiler/index.d.ts.map +0 -1
  137. package/dist/compiler/prefixer.d.ts.map +0 -1
  138. package/dist/compiler/theme-contract.d.ts.map +0 -1
  139. package/dist/compiler/tokens.d.ts.map +0 -1
  140. package/dist/compiler/types.d.ts +0 -57
  141. package/dist/compiler/types.d.ts.map +0 -1
  142. package/dist/core/compiler.d.ts.map +0 -1
  143. package/dist/core/constants.d.ts.map +0 -1
  144. package/dist/core/index.d.ts +0 -4
  145. package/dist/core/index.d.ts.map +0 -1
  146. package/dist/core/types.d.ts.map +0 -1
  147. package/dist/core/utils.d.ts.map +0 -1
  148. package/dist/index.d.ts.map +0 -1
  149. package/dist/plugins/vite.d.ts.map +0 -1
  150. package/dist/plugins/webpack.d.ts.map +0 -1
  151. package/dist/runtime/hmr.d.ts.map +0 -1
  152. package/dist/runtime/index.d.ts.map +0 -1
  153. package/dist/runtime/injector.d.ts.map +0 -1
  154. package/dist/runtime/react.d.ts.map +0 -1
  155. package/dist/runtime/react.js +0 -324
  156. package/dist/runtime/types.d.ts.map +0 -1
  157. package/dist/runtime/utils.d.ts.map +0 -1
  158. package/dist/runtime/vue.d.ts.map +0 -1
  159. package/dist/runtime/vue.js +0 -286
@@ -1,330 +1,3482 @@
1
+ // src/compiler/suggestions.ts
2
+ var KNOWN_SHORTHANDS = [
3
+ // Spacing
4
+ "m",
5
+ "mt",
6
+ "mr",
7
+ "mb",
8
+ "ml",
9
+ "p",
10
+ "pt",
11
+ "pr",
12
+ "pb",
13
+ "pl",
14
+ "mx",
15
+ "my",
16
+ "px",
17
+ "py",
18
+ "inset",
19
+ "insetX",
20
+ "insetY",
21
+ // Sizing
22
+ "w",
23
+ "h",
24
+ "minW",
25
+ "maxW",
26
+ "minH",
27
+ "maxH",
28
+ "size",
29
+ "aspect",
30
+ // Display & Layout
31
+ "d",
32
+ "pos",
33
+ "flex",
34
+ "grid",
35
+ "inlineFlex",
36
+ "inlineGrid",
37
+ "flexDir",
38
+ "flexWrap",
39
+ "justify",
40
+ "items",
41
+ "align",
42
+ "content",
43
+ "self",
44
+ "center",
45
+ "flexCenter",
46
+ "gridCenter",
47
+ "stack",
48
+ "gridTable",
49
+ "cols",
50
+ "rows",
51
+ "gap",
52
+ "gapX",
53
+ "gapY",
54
+ "grow",
55
+ "shrink",
56
+ "basis",
57
+ "order",
58
+ // Colors & Backgrounds
59
+ "bg",
60
+ "c",
61
+ "text",
62
+ "op",
63
+ // Borders
64
+ "border",
65
+ "borderW",
66
+ "borderC",
67
+ "borderS",
68
+ "borderT",
69
+ "borderR",
70
+ "borderB",
71
+ "borderL",
72
+ "borderX",
73
+ "borderY",
74
+ "rounded",
75
+ "br",
76
+ "radius",
77
+ "roundedTL",
78
+ "roundedTR",
79
+ "roundedBR",
80
+ "roundedBL",
81
+ // Typography
82
+ "fontF",
83
+ "fs",
84
+ "fw",
85
+ "lh",
86
+ "ls",
87
+ "align",
88
+ // Effects
89
+ "shadow",
90
+ "truncate",
91
+ "hide",
92
+ "show",
93
+ "unselectable",
94
+ "scrollable",
95
+ "glass",
96
+ "glow",
97
+ "textGradient",
98
+ "meshGradient",
99
+ "noise",
100
+ // Positioning
101
+ "absolute",
102
+ "fixed",
103
+ "sticky",
104
+ "relative",
105
+ // Utilities
106
+ "pill",
107
+ "container",
108
+ "fullScreen",
109
+ "shimmer",
110
+ "bento",
111
+ "pressable",
112
+ "focusRing",
113
+ "outlineDebug",
114
+ "skeleton",
115
+ "safeArea",
116
+ "clickScale",
117
+ "onInteracting",
118
+ "children",
119
+ "dark",
120
+ "light",
121
+ "fluidText"
122
+ ];
123
+ var COMMON_CSS_PROPERTIES = [
124
+ "display",
125
+ "position",
126
+ "margin",
127
+ "margin-top",
128
+ "margin-right",
129
+ "margin-bottom",
130
+ "margin-left",
131
+ "padding",
132
+ "padding-top",
133
+ "padding-right",
134
+ "padding-bottom",
135
+ "padding-left",
136
+ "color",
137
+ "background",
138
+ "background-color",
139
+ "background-image",
140
+ "background-size",
141
+ "background-position",
142
+ "border",
143
+ "border-width",
144
+ "border-style",
145
+ "border-color",
146
+ "border-radius",
147
+ "width",
148
+ "height",
149
+ "max-width",
150
+ "max-height",
151
+ "min-width",
152
+ "min-height",
153
+ "font-size",
154
+ "font-weight",
155
+ "font-family",
156
+ "line-height",
157
+ "letter-spacing",
158
+ "text-align",
159
+ "cursor",
160
+ "opacity",
161
+ "z-index",
162
+ "overflow",
163
+ "overflow-x",
164
+ "overflow-y",
165
+ "flex",
166
+ "flex-direction",
167
+ "flex-wrap",
168
+ "justify-content",
169
+ "align-items",
170
+ "align-self",
171
+ "gap",
172
+ "grid",
173
+ "grid-template-columns",
174
+ "grid-template-rows",
175
+ "grid-column",
176
+ "grid-row",
177
+ "transition",
178
+ "transform",
179
+ "animation",
180
+ "box-shadow",
181
+ "text-shadow",
182
+ "filter",
183
+ "backdrop-filter",
184
+ "clip-path",
185
+ "mask",
186
+ "pointer-events",
187
+ "user-select",
188
+ "resize",
189
+ "appearance"
190
+ ];
191
+ var ANIMATION_PRESETS = [
192
+ "fadeIn",
193
+ "fadeOut",
194
+ "fadeInUp",
195
+ "fadeInDown",
196
+ "fadeInLeft",
197
+ "fadeInRight",
198
+ "fadeOutUp",
199
+ "fadeOutDown",
200
+ "slideInUp",
201
+ "slideInDown",
202
+ "slideInLeft",
203
+ "slideInRight",
204
+ "slideOutUp",
205
+ "slideOutDown",
206
+ "zoomIn",
207
+ "zoomOut",
208
+ "zoomInUp",
209
+ "zoomInDown",
210
+ "bounce",
211
+ "bounceIn",
212
+ "bounceOut",
213
+ "pulse",
214
+ "pulseGlow",
215
+ "shake",
216
+ "shakeX",
217
+ "shakeY",
218
+ "spin",
219
+ "spinReverse",
220
+ "wiggle",
221
+ "wobble",
222
+ "flip",
223
+ "flipX",
224
+ "blink",
225
+ "typing",
226
+ "cursor",
227
+ "shimmer",
228
+ "ripple",
229
+ "float",
230
+ "sink",
231
+ "swing",
232
+ "flash",
233
+ "textReveal",
234
+ "textGlitch"
235
+ ];
236
+ var BREAKPOINTS = [
237
+ "sm",
238
+ "md",
239
+ "lg",
240
+ "xl",
241
+ "2xl",
242
+ "mobile",
243
+ "tablet",
244
+ "desktop",
245
+ "mobile-sm",
246
+ "mobile-md",
247
+ "tablet-sm",
248
+ "tablet-lg",
249
+ "desktop-sm",
250
+ "desktop-md",
251
+ "desktop-lg",
252
+ "portrait",
253
+ "landscape",
254
+ "dark",
255
+ "light",
256
+ "reducedMotion",
257
+ "highContrast",
258
+ "print",
259
+ "hover",
260
+ "no-hover",
261
+ "fine",
262
+ "coarse"
263
+ ];
264
+ function levenshteinDistance(a, b) {
265
+ if (a.length === 0) return b.length;
266
+ if (b.length === 0) return a.length;
267
+ const matrix = [];
268
+ for (let i = 0; i <= b.length; i++) {
269
+ matrix[i] = [i];
270
+ }
271
+ for (let j = 0; j <= a.length; j++) {
272
+ matrix[0][j] = j;
273
+ }
274
+ for (let i = 1; i <= b.length; i++) {
275
+ for (let j = 1; j <= a.length; j++) {
276
+ const cost = a[j - 1] === b[i - 1] ? 0 : 1;
277
+ matrix[i][j] = Math.min(
278
+ matrix[i - 1][j] + 1,
279
+ // deletion
280
+ matrix[i][j - 1] + 1,
281
+ // insertion
282
+ matrix[i - 1][j - 1] + cost
283
+ // substitution
284
+ );
285
+ }
286
+ }
287
+ return matrix[b.length][a.length];
288
+ }
289
+ function findBestMatches(query, candidates, maxResults = 3, maxDistance = 3) {
290
+ const matches = [];
291
+ for (const candidate of candidates) {
292
+ const distance = levenshteinDistance(query.toLowerCase(), candidate.toLowerCase());
293
+ if (distance <= maxDistance) {
294
+ matches.push({
295
+ name: candidate,
296
+ distance,
297
+ type: getTypeForCandidate(candidate)
298
+ });
299
+ }
300
+ }
301
+ matches.sort((a, b) => {
302
+ if (a.distance !== b.distance) return a.distance - b.distance;
303
+ return a.name.localeCompare(b.name);
304
+ });
305
+ return matches.slice(0, maxResults);
306
+ }
307
+ function getTypeForCandidate(candidate) {
308
+ if (KNOWN_SHORTHANDS.includes(candidate)) return "shorthand";
309
+ if (COMMON_CSS_PROPERTIES.includes(candidate)) return "css-property";
310
+ if (ANIMATION_PRESETS.includes(candidate)) return "animation";
311
+ if (BREAKPOINTS.includes(candidate)) return "breakpoint";
312
+ return "macro";
313
+ }
314
+ function getSuggestion(prop, validProperties = [], type = "all") {
315
+ let candidates = [];
316
+ if (type === "shorthand") {
317
+ candidates = KNOWN_SHORTHANDS;
318
+ } else if (type === "css-property") {
319
+ candidates = [...COMMON_CSS_PROPERTIES, ...validProperties];
320
+ } else {
321
+ candidates = [
322
+ ...KNOWN_SHORTHANDS,
323
+ ...COMMON_CSS_PROPERTIES,
324
+ ...validProperties,
325
+ ...ANIMATION_PRESETS,
326
+ ...BREAKPOINTS
327
+ ];
328
+ }
329
+ candidates = [...new Set(candidates)];
330
+ const matches = findBestMatches(prop, candidates, 1, 3);
331
+ if (matches.length > 0) {
332
+ return matches[0];
333
+ }
334
+ return null;
335
+ }
336
+
337
+ // src/compiler/tokens.ts
338
+ var defaultTokens = {
339
+ colors: {
340
+ primary: "#667eea",
341
+ secondary: "#764ba2",
342
+ success: "#48bb78",
343
+ danger: "#f56565",
344
+ warning: "#ed8936",
345
+ info: "#4299e1",
346
+ light: "#f7fafc",
347
+ dark: "#1a202c",
348
+ white: "#ffffff",
349
+ black: "#000000",
350
+ gray: {
351
+ 50: "#f9fafb",
352
+ 100: "#f7fafc",
353
+ 200: "#edf2f7",
354
+ 300: "#e2e8f0",
355
+ 400: "#cbd5e0",
356
+ 500: "#a0aec0",
357
+ 600: "#718096",
358
+ 700: "#4a5568",
359
+ 800: "#2d3748",
360
+ 900: "#1a202c"
361
+ },
362
+ blue: {
363
+ 50: "#eff6ff",
364
+ 100: "#dbeafe",
365
+ 200: "#bfdbfe",
366
+ 300: "#93c5fd",
367
+ 400: "#60a5fa",
368
+ 500: "#3b82f6",
369
+ 600: "#2563eb",
370
+ 700: "#1d4ed8",
371
+ 800: "#1e40af",
372
+ 900: "#1e3a8a"
373
+ },
374
+ green: {
375
+ 50: "#f0fdf4",
376
+ 100: "#dcfce7",
377
+ 200: "#bbf7d0",
378
+ 300: "#86efac",
379
+ 400: "#4ade80",
380
+ 500: "#22c55e",
381
+ 600: "#16a34a",
382
+ 700: "#15803d",
383
+ 800: "#166534",
384
+ 900: "#14532d"
385
+ },
386
+ red: {
387
+ 50: "#fef2f2",
388
+ 100: "#fee2e2",
389
+ 200: "#fecaca",
390
+ 300: "#fca5a5",
391
+ 400: "#f87171",
392
+ 500: "#ef4444",
393
+ 600: "#dc2626",
394
+ 700: "#b91c1c",
395
+ 800: "#991b1b",
396
+ 900: "#7f1d1d"
397
+ },
398
+ yellow: {
399
+ 50: "#fefce8",
400
+ 100: "#fef9c3",
401
+ 200: "#fef08a",
402
+ 300: "#fde047",
403
+ 400: "#facc15",
404
+ 500: "#eab308",
405
+ 600: "#ca8a04",
406
+ 700: "#a16207",
407
+ 800: "#854d0e",
408
+ 900: "#713f12"
409
+ }
410
+ },
411
+ spacing: {
412
+ 0: "0",
413
+ 0.5: "0.125rem",
414
+ 1: "0.25rem",
415
+ 1.5: "0.375rem",
416
+ 2: "0.5rem",
417
+ 2.5: "0.625rem",
418
+ 3: "0.75rem",
419
+ 3.5: "0.875rem",
420
+ 4: "1rem",
421
+ 5: "1.25rem",
422
+ 6: "1.5rem",
423
+ 7: "1.75rem",
424
+ 8: "2rem",
425
+ 9: "2.25rem",
426
+ 10: "2.5rem",
427
+ 11: "2.75rem",
428
+ 12: "3rem",
429
+ 14: "3.5rem",
430
+ 16: "4rem",
431
+ 20: "5rem",
432
+ 24: "6rem",
433
+ 28: "7rem",
434
+ 32: "8rem",
435
+ 36: "9rem",
436
+ 40: "10rem",
437
+ 44: "11rem",
438
+ 48: "12rem",
439
+ 52: "13rem",
440
+ 56: "14rem",
441
+ 60: "15rem",
442
+ 64: "16rem",
443
+ 72: "18rem",
444
+ 80: "20rem",
445
+ 96: "24rem",
446
+ xs: "0.5rem",
447
+ sm: "1rem",
448
+ md: "1.5rem",
449
+ lg: "2rem",
450
+ xl: "3rem",
451
+ "2xl": "4rem",
452
+ "3xl": "6rem",
453
+ "4xl": "8rem",
454
+ "5xl": "10rem"
455
+ },
456
+ typography: {
457
+ fontFamily: {
458
+ sans: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
459
+ serif: 'Georgia, Cambria, "Times New Roman", Times, serif',
460
+ mono: 'SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
461
+ system: "system-ui, -apple-system, sans-serif"
462
+ },
463
+ fontSize: {
464
+ xs: "0.75rem",
465
+ sm: "0.875rem",
466
+ base: "1rem",
467
+ lg: "1.125rem",
468
+ xl: "1.25rem",
469
+ "2xl": "1.5rem",
470
+ "3xl": "1.875rem",
471
+ "4xl": "2.25rem",
472
+ "5xl": "3rem",
473
+ "6xl": "3.75rem",
474
+ "7xl": "4.5rem",
475
+ "8xl": "6rem",
476
+ "9xl": "8rem"
477
+ },
478
+ fontWeight: {
479
+ hairline: "100",
480
+ thin: "200",
481
+ light: "300",
482
+ normal: "400",
483
+ medium: "500",
484
+ semibold: "600",
485
+ bold: "700",
486
+ extrabold: "800",
487
+ black: "900"
488
+ },
489
+ lineHeight: {
490
+ none: "1",
491
+ tight: "1.25",
492
+ snug: "1.375",
493
+ normal: "1.5",
494
+ relaxed: "1.625",
495
+ loose: "2",
496
+ 3: ".75rem",
497
+ 4: "1rem",
498
+ 5: "1.25rem",
499
+ 6: "1.5rem",
500
+ 7: "1.75rem",
501
+ 8: "2rem",
502
+ 9: "2.25rem",
503
+ 10: "2.5rem"
504
+ },
505
+ letterSpacing: {
506
+ tighter: "-0.05em",
507
+ tight: "-0.025em",
508
+ normal: "0",
509
+ wide: "0.025em",
510
+ wider: "0.05em",
511
+ widest: "0.1em"
512
+ }
513
+ },
514
+ breakpoints: {
515
+ sm: "640px",
516
+ md: "768px",
517
+ lg: "1024px",
518
+ xl: "1280px",
519
+ "2xl": "1536px",
520
+ "3xl": "1920px",
521
+ mobile: "640px",
522
+ tablet: "768px",
523
+ desktop: "1024px",
524
+ wide: "1280px"
525
+ },
526
+ zIndex: {
527
+ 0: "0",
528
+ 10: "10",
529
+ 20: "20",
530
+ 30: "30",
531
+ 40: "40",
532
+ 50: "50",
533
+ auto: "auto",
534
+ dropdown: "1000",
535
+ sticky: "1020",
536
+ fixed: "1030",
537
+ modal: "1040",
538
+ popover: "1050",
539
+ tooltip: "1060",
540
+ toast: "1070",
541
+ overlay: "1080"
542
+ },
543
+ shadows: {
544
+ xs: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
545
+ sm: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
546
+ base: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)",
547
+ md: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
548
+ lg: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",
549
+ xl: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
550
+ "2xl": "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
551
+ inner: "inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)",
552
+ none: "none",
553
+ "glow-sm": "0 0 10px rgba(102, 126, 234, 0.5)",
554
+ "glow-md": "0 0 20px rgba(102, 126, 234, 0.5)",
555
+ "glow-lg": "0 0 30px rgba(102, 126, 234, 0.5)"
556
+ },
557
+ borderRadius: {
558
+ none: "0",
559
+ sm: "0.125rem",
560
+ base: "0.25rem",
561
+ md: "0.375rem",
562
+ lg: "0.5rem",
563
+ xl: "0.75rem",
564
+ "2xl": "1rem",
565
+ "3xl": "1.5rem",
566
+ "4xl": "2rem",
567
+ full: "9999px"
568
+ },
569
+ // Additional animation presets
570
+ animations: {
571
+ fade: {
572
+ "0%": { opacity: 0 },
573
+ "100%": { opacity: 1 }
574
+ },
575
+ slideUp: {
576
+ "0%": { transform: "translateY(20px)", opacity: 0 },
577
+ "100%": { transform: "translateY(0)", opacity: 1 }
578
+ },
579
+ slideDown: {
580
+ "0%": { transform: "translateY(-20px)", opacity: 0 },
581
+ "100%": { transform: "translateY(0)", opacity: 1 }
582
+ },
583
+ slideLeft: {
584
+ "0%": { transform: "translateX(20px)", opacity: 0 },
585
+ "100%": { transform: "translateX(0)", opacity: 1 }
586
+ },
587
+ slideRight: {
588
+ "0%": { transform: "translateX(-20px)", opacity: 0 },
589
+ "100%": { transform: "translateX(0)", opacity: 1 }
590
+ },
591
+ scale: {
592
+ "0%": { transform: "scale(0.95)", opacity: 0 },
593
+ "100%": { transform: "scale(1)", opacity: 1 }
594
+ },
595
+ bounce: {
596
+ "0%, 100%": { transform: "translateY(0)" },
597
+ "50%": { transform: "translateY(-25%)" }
598
+ },
599
+ pulse: {
600
+ "0%, 100%": { opacity: 1 },
601
+ "50%": { opacity: 0.5 }
602
+ },
603
+ spin: {
604
+ "0%": { transform: "rotate(0deg)" },
605
+ "100%": { transform: "rotate(360deg)" }
606
+ },
607
+ shimmer: {
608
+ "0%": { backgroundPosition: "-200% 0" },
609
+ "100%": { backgroundPosition: "200% 0" }
610
+ }
611
+ }
612
+ };
613
+ var DesignTokens = class _DesignTokens {
614
+ customTokens;
615
+ customFlattened;
616
+ defaultFlattened;
617
+ tokenCache = /* @__PURE__ */ new Map();
618
+ constructor(customTokens = {}) {
619
+ this.customTokens = this.deepClone(customTokens);
620
+ this.customFlattened = this.flattenTokens(this.customTokens);
621
+ this.defaultFlattened = this.flattenTokens(defaultTokens);
622
+ Object.freeze(this.customTokens);
623
+ Object.freeze(this.customFlattened);
624
+ Object.freeze(this.defaultFlattened);
625
+ }
626
+ // Deep clone objects
627
+ deepClone(obj) {
628
+ if (obj === null || typeof obj !== "object") return obj;
629
+ if (Array.isArray(obj)) return obj.map((item) => this.deepClone(item));
630
+ const cloned = {};
631
+ for (const key in obj) {
632
+ if (obj.hasOwnProperty(key)) {
633
+ cloned[key] = this.deepClone(obj[key]);
634
+ }
635
+ }
636
+ return cloned;
637
+ }
638
+ // Deep freeze to prevent accidental modifications
639
+ deepFreeze(obj) {
640
+ Object.keys(obj).forEach((key) => {
641
+ const value = obj[key];
642
+ if (typeof value === "object" && value !== null && !Object.isFrozen(value)) {
643
+ this.deepFreeze(value);
644
+ }
645
+ });
646
+ return Object.freeze(obj);
647
+ }
648
+ // Flatten nested tokens for easy access
649
+ flattenTokens(obj, prefix = "") {
650
+ const result = {};
651
+ for (const [key, value] of Object.entries(obj)) {
652
+ const prefixed = prefix ? `${prefix}.${key}` : key;
653
+ if (value && typeof value === "object" && !Array.isArray(value)) {
654
+ Object.assign(result, this.flattenTokens(value, prefixed));
655
+ } else {
656
+ result[prefixed] = String(value);
657
+ }
658
+ }
659
+ return result;
660
+ }
661
+ // Get token value by path (e.g., 'colors.primary')
662
+ // Checks custom tokens first, then falls back to default tokens
663
+ get(path, defaultValue = "") {
664
+ if (this.tokenCache.has(path)) {
665
+ return this.tokenCache.get(path);
666
+ }
667
+ let value;
668
+ if (path in this.customFlattened) {
669
+ value = this.customFlattened[path];
670
+ }
671
+ if (value === void 0 && path in this.defaultFlattened) {
672
+ value = this.defaultFlattened[path];
673
+ }
674
+ if (value && value.startsWith("$")) {
675
+ const refPath = value.substring(1);
676
+ value = this.get(refPath, defaultValue);
677
+ }
678
+ const result = value !== void 0 ? value : defaultValue;
679
+ this.tokenCache.set(path, result);
680
+ return result;
681
+ }
682
+ // Get token with type safety
683
+ getColor(path, defaultValue = "#000000") {
684
+ return this.get(`colors.${path}`, defaultValue);
685
+ }
686
+ getSpacing(path, defaultValue = "0") {
687
+ return this.get(`spacing.${path}`, defaultValue);
688
+ }
689
+ getFontSize(path, defaultValue = "1rem") {
690
+ return this.get(`typography.fontSize.${path}`, defaultValue);
691
+ }
692
+ getFontWeight(path, defaultValue = "400") {
693
+ return this.get(`typography.fontWeight.${path}`, defaultValue);
694
+ }
695
+ getLineHeight(path, defaultValue = "1.5") {
696
+ return this.get(`typography.lineHeight.${path}`, defaultValue);
697
+ }
698
+ getBreakpoint(path, defaultValue = "768px") {
699
+ return this.get(`breakpoints.${path}`, defaultValue);
700
+ }
701
+ getZIndex(path, defaultValue = "0") {
702
+ return this.get(`zIndex.${path}`, defaultValue);
703
+ }
704
+ getShadow(path, defaultValue = "none") {
705
+ return this.get(`shadows.${path}`, defaultValue);
706
+ }
707
+ getBorderRadius(path, defaultValue = "0") {
708
+ return this.get(`borderRadius.${path}`, defaultValue);
709
+ }
710
+ // Get all custom tokens (as flattened object)
711
+ getCustomTokens() {
712
+ return { ...this.customFlattened };
713
+ }
714
+ // Get all default tokens (as flattened object)
715
+ getDefaultTokens() {
716
+ return { ...this.defaultFlattened };
717
+ }
718
+ // Check if a token exists (in either custom or default)
719
+ has(path) {
720
+ return path in this.customFlattened || path in this.defaultFlattened;
721
+ }
722
+ // Generate CSS variables from tokens (combines both custom and default)
723
+ toCSSVariables(prefix = "chain") {
724
+ let css = ":root {\n";
725
+ const allTokens = { ...this.defaultFlattened, ...this.customFlattened };
726
+ for (const [key, value] of Object.entries(allTokens)) {
727
+ const varName = `--${prefix}-${key.replace(/\./g, "-")}`;
728
+ css += ` ${varName}: ${value};
729
+ `;
730
+ }
731
+ css += "}\n";
732
+ return css;
733
+ }
734
+ // Generate media queries from breakpoints
735
+ toMediaQueries() {
736
+ const queries = {};
737
+ for (const [name, value] of Object.entries(this.customFlattened)) {
738
+ if (name.startsWith("breakpoints.")) {
739
+ const breakpointName = name.replace("breakpoints.", "");
740
+ queries[breakpointName] = value;
741
+ }
742
+ }
743
+ return queries;
744
+ }
745
+ // Create a theme variant (overrides on top of defaults + custom)
746
+ createTheme(name, overrides) {
747
+ const newCustomTokens = this.deepClone(this.customTokens);
748
+ for (const [path, value] of Object.entries(overrides)) {
749
+ const parts = path.split(".");
750
+ let current = newCustomTokens;
751
+ for (let i = 0; i < parts.length - 1; i++) {
752
+ if (!current[parts[i]]) {
753
+ current[parts[i]] = {};
754
+ }
755
+ current = current[parts[i]];
756
+ }
757
+ current[parts[parts.length - 1]] = value;
758
+ }
759
+ return new _DesignTokens(newCustomTokens);
760
+ }
761
+ // Merge with another token set
762
+ merge(tokens2) {
763
+ const merged = this.deepClone(this.customTokens);
764
+ const deepMerge = (target, source) => {
765
+ for (const key in source) {
766
+ if (source.hasOwnProperty(key)) {
767
+ if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
768
+ if (!target[key]) target[key] = {};
769
+ deepMerge(target[key], source[key]);
770
+ } else {
771
+ target[key] = source[key];
772
+ }
773
+ }
774
+ }
775
+ };
776
+ deepMerge(merged, tokens2);
777
+ return new _DesignTokens(merged);
778
+ }
779
+ // Clear cache
780
+ clearCache() {
781
+ this.tokenCache.clear();
782
+ }
783
+ // Get token path suggestions for autocomplete
784
+ getSuggestions(partialPath) {
785
+ const allTokens = { ...this.defaultFlattened, ...this.customFlattened };
786
+ const suggestions = [];
787
+ for (const key of Object.keys(allTokens)) {
788
+ if (key.includes(partialPath)) {
789
+ suggestions.push(key);
790
+ }
791
+ }
792
+ return suggestions.sort();
793
+ }
794
+ };
795
+ var tokens = new DesignTokens(defaultTokens);
796
+
797
+ // src/compiler/token-resolver.ts
798
+ var currentTokenContext = null;
799
+ function resolveToken(value, useTokens = true, tokenContext) {
800
+ if (!useTokens || typeof value !== "string") return value;
801
+ const functionMatch = value.match(/^(?:token|\$token)\s*\(\s*['"]([^'"]+)['"]\s*\)$/);
802
+ if (functionMatch) {
803
+ const tokenPath = functionMatch[1];
804
+ const resolved = resolveTokenPath(tokenPath, tokenContext);
805
+ return resolved !== void 0 ? resolved : value;
806
+ }
807
+ if (value.includes("$")) {
808
+ return value.replace(/\$([a-zA-Z0-9.-]+)/g, (match, path) => {
809
+ const resolved = resolveTokenPath(path, tokenContext);
810
+ if (resolved !== void 0 && resolved !== null) {
811
+ return String(resolved);
812
+ }
813
+ if (true) {
814
+ console.warn(`[ChainCSS] Token not found: ${path}`);
815
+ }
816
+ return match;
817
+ });
818
+ }
819
+ return value;
820
+ }
821
+ function resolveTokenPath(path, tokenContext) {
822
+ let resolved = null;
823
+ if (tokenContext && typeof tokenContext.get === "function") {
824
+ resolved = tokenContext.get(path);
825
+ }
826
+ if ((resolved === void 0 || resolved === null) && currentTokenContext) {
827
+ resolved = currentTokenContext.get(path);
828
+ }
829
+ if (resolved === void 0 || resolved === null) {
830
+ if (tokens && typeof tokens.get === "function") {
831
+ resolved = tokens.get(path);
832
+ }
833
+ }
834
+ return resolved;
835
+ }
836
+
837
+ // src/compiler/breakpoints.ts
838
+ var DEFAULT_BREAKPOINTS = {
839
+ // Mobile-first breakpoints
840
+ sm: "(min-width: 640px)",
841
+ md: "(min-width: 768px)",
842
+ lg: "(min-width: 1024px)",
843
+ xl: "(min-width: 1280px)",
844
+ "2xl": "(min-width: 1536px)",
845
+ // Desktop-first breakpoints (alternative naming)
846
+ mobile: "(max-width: 767px)",
847
+ tablet: "(min-width: 768px) and (max-width: 1023px)",
848
+ desktop: "(min-width: 1024px)",
849
+ // Specific device breakpoints
850
+ "mobile-sm": "(max-width: 375px)",
851
+ "mobile-md": "(min-width: 376px) and (max-width: 768px)",
852
+ "tablet-sm": "(min-width: 769px) and (max-width: 834px)",
853
+ "tablet-lg": "(min-width: 835px) and (max-width: 1024px)",
854
+ "desktop-sm": "(min-width: 1025px) and (max-width: 1280px)",
855
+ "desktop-md": "(min-width: 1281px) and (max-width: 1440px)",
856
+ "desktop-lg": "(min-width: 1441px)",
857
+ // Orientation breakpoints
858
+ portrait: "(orientation: portrait)",
859
+ landscape: "(orientation: landscape)",
860
+ // Feature breakpoints
861
+ dark: "(prefers-color-scheme: dark)",
862
+ light: "(prefers-color-scheme: light)",
863
+ reducedMotion: "(prefers-reduced-motion: reduce)",
864
+ highContrast: "(prefers-contrast: high)",
865
+ // Print
866
+ print: "print",
867
+ // Hover capabilities
868
+ hover: "(hover: hover)",
869
+ "no-hover": "(hover: none)",
870
+ // Pointer capabilities
871
+ fine: "(pointer: fine)",
872
+ coarse: "(pointer: coarse)"
873
+ };
874
+ var currentBreakpoints = { ...DEFAULT_BREAKPOINTS };
875
+
876
+ // src/compiler/animations.ts
877
+ var animationPresets = {
878
+ // Fades
879
+ fadeIn: {
880
+ "0%": { opacity: 0 },
881
+ "100%": { opacity: 1 }
882
+ },
883
+ fadeOut: {
884
+ "0%": { opacity: 1 },
885
+ "100%": { opacity: 0 }
886
+ },
887
+ fadeInUp: {
888
+ "0%": { opacity: 0, transform: "translateY(20px)" },
889
+ "100%": { opacity: 1, transform: "translateY(0)" }
890
+ },
891
+ fadeInDown: {
892
+ "0%": { opacity: 0, transform: "translateY(-20px)" },
893
+ "100%": { opacity: 1, transform: "translateY(0)" }
894
+ },
895
+ fadeInLeft: {
896
+ "0%": { opacity: 0, transform: "translateX(-20px)" },
897
+ "100%": { opacity: 1, transform: "translateX(0)" }
898
+ },
899
+ fadeInRight: {
900
+ "0%": { opacity: 0, transform: "translateX(20px)" },
901
+ "100%": { opacity: 1, transform: "translateX(0)" }
902
+ },
903
+ fadeOutUp: {
904
+ "0%": { opacity: 1, transform: "translateY(0)" },
905
+ "100%": { opacity: 0, transform: "translateY(-20px)" }
906
+ },
907
+ fadeOutDown: {
908
+ "0%": { opacity: 1, transform: "translateY(0)" },
909
+ "100%": { opacity: 0, transform: "translateY(20px)" }
910
+ },
911
+ // Slides
912
+ slideInUp: {
913
+ "0%": { transform: "translateY(100%)" },
914
+ "100%": { transform: "translateY(0)" }
915
+ },
916
+ slideInDown: {
917
+ "0%": { transform: "translateY(-100%)" },
918
+ "100%": { transform: "translateY(0)" }
919
+ },
920
+ slideInLeft: {
921
+ "0%": { transform: "translateX(-100%)" },
922
+ "100%": { transform: "translateX(0)" }
923
+ },
924
+ slideInRight: {
925
+ "0%": { transform: "translateX(100%)" },
926
+ "100%": { transform: "translateX(0)" }
927
+ },
928
+ slideOutUp: {
929
+ "0%": { transform: "translateY(0)" },
930
+ "100%": { transform: "translateY(-100%)" }
931
+ },
932
+ slideOutDown: {
933
+ "0%": { transform: "translateY(0)" },
934
+ "100%": { transform: "translateY(100%)" }
935
+ },
936
+ // Zooms
937
+ zoomIn: {
938
+ "0%": { opacity: 0, transform: "scale(0.8)" },
939
+ "100%": { opacity: 1, transform: "scale(1)" }
940
+ },
941
+ zoomOut: {
942
+ "0%": { opacity: 1, transform: "scale(1)" },
943
+ "100%": { opacity: 0, transform: "scale(0.8)" }
944
+ },
945
+ zoomInUp: {
946
+ "0%": { opacity: 0, transform: "scale(0.8) translateY(20px)" },
947
+ "100%": { opacity: 1, transform: "scale(1) translateY(0)" }
948
+ },
949
+ zoomInDown: {
950
+ "0%": { opacity: 0, transform: "scale(0.8) translateY(-20px)" },
951
+ "100%": { opacity: 1, transform: "scale(1) translateY(0)" }
952
+ },
953
+ // Bounces
954
+ bounce: {
955
+ "0%, 100%": { transform: "translateY(0)" },
956
+ "50%": { transform: "translateY(-20px)" }
957
+ },
958
+ bounceIn: {
959
+ "0%": { opacity: 0, transform: "scale(0.8)" },
960
+ "50%": { transform: "scale(1.05)" },
961
+ "100%": { opacity: 1, transform: "scale(1)" }
962
+ },
963
+ bounceOut: {
964
+ "0%": { transform: "scale(1)" },
965
+ "50%": { transform: "scale(0.95)" },
966
+ "100%": { opacity: 0, transform: "scale(0.8)" }
967
+ },
968
+ // Pulses
969
+ pulse: {
970
+ "0%, 100%": { transform: "scale(1)" },
971
+ "50%": { transform: "scale(1.05)" }
972
+ },
973
+ pulseGlow: {
974
+ "0%, 100%": { opacity: 1, filter: "brightness(1)" },
975
+ "50%": { opacity: 0.8, filter: "brightness(1.2)" }
976
+ },
977
+ // Shakes
978
+ shake: {
979
+ "0%, 100%": { transform: "translateX(0)" },
980
+ "25%": { transform: "translateX(-5px)" },
981
+ "75%": { transform: "translateX(5px)" }
982
+ },
983
+ shakeX: {
984
+ "0%, 100%": { transform: "translateX(0)" },
985
+ "25%, 75%": { transform: "translateX(-10px)" },
986
+ "50%": { transform: "translateX(10px)" }
987
+ },
988
+ shakeY: {
989
+ "0%, 100%": { transform: "translateY(0)" },
990
+ "25%, 75%": { transform: "translateY(-10px)" },
991
+ "50%": { transform: "translateY(10px)" }
992
+ },
993
+ // Rotations
994
+ spin: {
995
+ "0%": { transform: "rotate(0deg)" },
996
+ "100%": { transform: "rotate(360deg)" }
997
+ },
998
+ spinReverse: {
999
+ "0%": { transform: "rotate(0deg)" },
1000
+ "100%": { transform: "rotate(-360deg)" }
1001
+ },
1002
+ wiggle: {
1003
+ "0%, 100%": { transform: "rotate(-3deg)" },
1004
+ "50%": { transform: "rotate(3deg)" }
1005
+ },
1006
+ wobble: {
1007
+ "0%": { transform: "translateX(0%)" },
1008
+ "15%": { transform: "translateX(-25%) rotate(-5deg)" },
1009
+ "30%": { transform: "translateX(20%) rotate(3deg)" },
1010
+ "45%": { transform: "translateX(-15%) rotate(-3deg)" },
1011
+ "60%": { transform: "translateX(10%) rotate(2deg)" },
1012
+ "75%": { transform: "translateX(-5%) rotate(-1deg)" },
1013
+ "100%": { transform: "translateX(0%)" }
1014
+ },
1015
+ // Flips
1016
+ flip: {
1017
+ "0%": { transform: "perspective(400px) rotateY(0)" },
1018
+ "100%": { transform: "perspective(400px) rotateY(180deg)" }
1019
+ },
1020
+ flipX: {
1021
+ "0%": { transform: "perspective(400px) rotateX(0)" },
1022
+ "100%": { transform: "perspective(400px) rotateX(180deg)" }
1023
+ },
1024
+ // Special effects
1025
+ blink: {
1026
+ "0%, 100%": { opacity: 1 },
1027
+ "50%": { opacity: 0 }
1028
+ },
1029
+ typing: {
1030
+ "0%": { width: "0" },
1031
+ "100%": { width: "100%" }
1032
+ },
1033
+ cursor: {
1034
+ "0%, 100%": { borderColor: "transparent" },
1035
+ "50%": { borderColor: "currentColor" }
1036
+ },
1037
+ shimmer: {
1038
+ "0%": { backgroundPosition: "-200% 0" },
1039
+ "100%": { backgroundPosition: "200% 0" }
1040
+ },
1041
+ ripple: {
1042
+ "0%": { transform: "scale(0)", opacity: 0.5 },
1043
+ "100%": { transform: "scale(4)", opacity: 0 }
1044
+ },
1045
+ float: {
1046
+ "0%, 100%": { transform: "translateY(0)" },
1047
+ "50%": { transform: "translateY(-10px)" }
1048
+ },
1049
+ sink: {
1050
+ "0%, 100%": { transform: "translateY(0)" },
1051
+ "50%": { transform: "translateY(10px)" }
1052
+ },
1053
+ swing: {
1054
+ "0%, 100%": { transform: "rotate(0deg)" },
1055
+ "25%": { transform: "rotate(15deg)" },
1056
+ "75%": { transform: "rotate(-15deg)" }
1057
+ },
1058
+ flash: {
1059
+ "0%, 100%": { opacity: 1 },
1060
+ "25%, 75%": { opacity: 0.5 },
1061
+ "50%": { opacity: 0 }
1062
+ },
1063
+ // Text animations
1064
+ textReveal: {
1065
+ "0%": { clipPath: "inset(0 100% 0 0)" },
1066
+ "100%": { clipPath: "inset(0 0 0 0)" }
1067
+ },
1068
+ textGlitch: {
1069
+ "0%, 100%": { transform: "translate(0, 0)" },
1070
+ "20%": { transform: "translate(-2px, 1px)" },
1071
+ "40%": { transform: "translate(2px, -1px)" },
1072
+ "60%": { transform: "translate(-1px, 2px)" },
1073
+ "80%": { transform: "translate(1px, -2px)" }
1074
+ }
1075
+ };
1076
+ var DEFAULT_ANIMATION_CONFIG = {
1077
+ name: "",
1078
+ // Add this missing property
1079
+ duration: "0.3s",
1080
+ delay: "0s",
1081
+ timing: "ease",
1082
+ iteration: 1,
1083
+ direction: "normal",
1084
+ fillMode: "both",
1085
+ playState: "running"
1086
+ };
1087
+ function createAnimation(animationName, config = {}) {
1088
+ const {
1089
+ duration = DEFAULT_ANIMATION_CONFIG.duration,
1090
+ delay = DEFAULT_ANIMATION_CONFIG.delay,
1091
+ timing = DEFAULT_ANIMATION_CONFIG.timing,
1092
+ iteration = DEFAULT_ANIMATION_CONFIG.iteration,
1093
+ direction = DEFAULT_ANIMATION_CONFIG.direction,
1094
+ fillMode = DEFAULT_ANIMATION_CONFIG.fillMode,
1095
+ playState = DEFAULT_ANIMATION_CONFIG.playState
1096
+ } = config;
1097
+ const animationValue = `${animationName} ${duration} ${timing} ${delay} ${iteration} ${direction} ${playState}`;
1098
+ return {
1099
+ animation: animationValue.trim(),
1100
+ animationFillMode: fillMode,
1101
+ animationName,
1102
+ animationDuration: duration,
1103
+ animationDelay: delay,
1104
+ animationTimingFunction: timing,
1105
+ animationIterationCount: iteration,
1106
+ animationDirection: direction,
1107
+ animationPlayState: playState
1108
+ };
1109
+ }
1110
+
1111
+ // src/compiler/helpers.ts
1112
+ function normalizeValue(value) {
1113
+ if (value === null || value === void 0) return "0";
1114
+ if (typeof value === "number") return `${value}px`;
1115
+ return String(value);
1116
+ }
1117
+ function performCalculation(a, b, operation, options = {}) {
1118
+ const valA = normalizeValue(a);
1119
+ const valB = normalizeValue(b);
1120
+ let result;
1121
+ switch (operation) {
1122
+ case "add":
1123
+ result = `calc(${valA} + ${valB})`;
1124
+ break;
1125
+ case "subtract":
1126
+ result = `calc(${valA} - ${valB})`;
1127
+ break;
1128
+ case "multiply":
1129
+ result = `calc(${valA} * ${valB})`;
1130
+ break;
1131
+ case "divide":
1132
+ result = `calc(${valA} / ${valB})`;
1133
+ break;
1134
+ default:
1135
+ result = `calc(${valA} ${operation} ${valB})`;
1136
+ }
1137
+ if (options.simplify) {
1138
+ result = simplifyCalc(result);
1139
+ }
1140
+ return result;
1141
+ }
1142
+ function simplifyCalc(calcExpr) {
1143
+ if (calcExpr.startsWith("calc(") && calcExpr.endsWith(")")) {
1144
+ const inner = calcExpr.slice(5, -1);
1145
+ if (!inner.includes("+") && !inner.includes("-") && !inner.includes("*") && !inner.includes("/")) {
1146
+ return inner.trim();
1147
+ }
1148
+ }
1149
+ return calcExpr;
1150
+ }
1151
+ function createCalc(expr, options = {}) {
1152
+ let result = `calc(${expr})`;
1153
+ if (options.simplify) {
1154
+ result = simplifyCalc(result);
1155
+ }
1156
+ return result;
1157
+ }
1158
+ var helpers = {
1159
+ // Basic calc
1160
+ calc: (expr, options) => createCalc(expr, options),
1161
+ // Arithmetic operations
1162
+ add: (a, b, options) => performCalculation(a, b, "add", options),
1163
+ subtract: (a, b, options) => performCalculation(a, b, "subtract", options),
1164
+ sub: (a, b, options) => performCalculation(a, b, "subtract", options),
1165
+ multiply: (a, b, options) => performCalculation(a, b, "multiply", options),
1166
+ mul: (a, b, options) => performCalculation(a, b, "multiply", options),
1167
+ divide: (a, b, options) => performCalculation(a, b, "divide", options),
1168
+ div: (a, b, options) => performCalculation(a, b, "divide", options),
1169
+ // Complex operations
1170
+ sum: (...values) => {
1171
+ const expr = values.map((v) => normalizeValue(v)).join(" + ");
1172
+ return createCalc(expr);
1173
+ },
1174
+ difference: (a, ...rest) => {
1175
+ const expr = [a, ...rest].map((v) => normalizeValue(v)).join(" - ");
1176
+ return createCalc(expr);
1177
+ },
1178
+ product: (...values) => {
1179
+ const expr = values.map((v) => normalizeValue(v)).join(" * ");
1180
+ return createCalc(expr);
1181
+ },
1182
+ quotient: (a, ...rest) => {
1183
+ const expr = [a, ...rest].map((v) => normalizeValue(v)).join(" / ");
1184
+ return createCalc(expr);
1185
+ },
1186
+ // Unit helpers with conversion
1187
+ mpx: (value) => {
1188
+ if (typeof value === "number") return `${value}px`;
1189
+ if (/^\d+(?:\.\d+)?(?:px|rem|em|%|vw|vh)$/.test(value)) return value;
1190
+ if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}px`;
1191
+ return value;
1192
+ },
1193
+ rem: (value, base = 16) => {
1194
+ if (typeof value === "number") return `${value}rem`;
1195
+ if (/^\d+(?:\.\d+)?rem$/.test(value)) return value;
1196
+ if (/^\d+(?:\.\d+)?px$/.test(value)) {
1197
+ const px = parseFloat(value);
1198
+ return `${px / base}rem`;
1199
+ }
1200
+ if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}rem`;
1201
+ return value;
1202
+ },
1203
+ em: (value, context = 16) => {
1204
+ if (typeof value === "number") return `${value}em`;
1205
+ if (/^\d+(?:\.\d+)?em$/.test(value)) return value;
1206
+ if (/^\d+(?:\.\d+)?px$/.test(value)) {
1207
+ const px = parseFloat(value);
1208
+ return `${px / context}em`;
1209
+ }
1210
+ if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}em`;
1211
+ return value;
1212
+ },
1213
+ percent: (value) => {
1214
+ if (typeof value === "number") return `${value}%`;
1215
+ if (/^\d+(?:\.\d+)?%$/.test(value)) return value;
1216
+ if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}%`;
1217
+ return value;
1218
+ },
1219
+ vw: (value) => {
1220
+ if (typeof value === "number") return `${value}vw`;
1221
+ if (/^\d+(?:\.\d+)?vw$/.test(value)) return value;
1222
+ if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}vw`;
1223
+ return value;
1224
+ },
1225
+ vh: (value) => {
1226
+ if (typeof value === "number") return `${value}vh`;
1227
+ if (/^\d+(?:\.\d+)?vh$/.test(value)) return value;
1228
+ if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}vh`;
1229
+ return value;
1230
+ },
1231
+ vmin: (value) => {
1232
+ if (typeof value === "number") return `${value}vmin`;
1233
+ if (/^\d+(?:\.\d+)?vmin$/.test(value)) return value;
1234
+ if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}vmin`;
1235
+ return value;
1236
+ },
1237
+ vmax: (value) => {
1238
+ if (typeof value === "number") return `${value}vmax`;
1239
+ if (/^\d+(?:\.\d+)?vmax$/.test(value)) return value;
1240
+ if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}vmax`;
1241
+ return value;
1242
+ },
1243
+ ch: (value) => {
1244
+ if (typeof value === "number") return `${value}ch`;
1245
+ if (/^\d+(?:\.\d+)?ch$/.test(value)) return value;
1246
+ if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}ch`;
1247
+ return value;
1248
+ },
1249
+ ex: (value) => {
1250
+ if (typeof value === "number") return `${value}ex`;
1251
+ if (/^\d+(?:\.\d+)?ex$/.test(value)) return value;
1252
+ if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}ex`;
1253
+ return value;
1254
+ },
1255
+ // Convert between units
1256
+ convert: (value, fromUnit, toUnit, context = 16) => {
1257
+ let numericValue;
1258
+ if (typeof value === "number") {
1259
+ numericValue = value;
1260
+ } else {
1261
+ numericValue = parseFloat(value);
1262
+ }
1263
+ let inPx;
1264
+ switch (fromUnit) {
1265
+ case "px":
1266
+ inPx = numericValue;
1267
+ break;
1268
+ case "rem":
1269
+ inPx = numericValue * context;
1270
+ break;
1271
+ case "em":
1272
+ inPx = numericValue * context;
1273
+ break;
1274
+ case "%":
1275
+ inPx = numericValue / 100 * context;
1276
+ break;
1277
+ case "vw":
1278
+ inPx = numericValue / 100 * 1920;
1279
+ break;
1280
+ case "vh":
1281
+ inPx = numericValue / 100 * 1080;
1282
+ break;
1283
+ default:
1284
+ inPx = numericValue;
1285
+ }
1286
+ let result;
1287
+ switch (toUnit) {
1288
+ case "px":
1289
+ result = inPx;
1290
+ break;
1291
+ case "rem":
1292
+ result = inPx / context;
1293
+ break;
1294
+ case "em":
1295
+ result = inPx / context;
1296
+ break;
1297
+ case "%":
1298
+ result = inPx / context * 100;
1299
+ break;
1300
+ case "vw":
1301
+ result = inPx / 1920 * 100;
1302
+ break;
1303
+ case "vh":
1304
+ result = inPx / 1080 * 100;
1305
+ break;
1306
+ default:
1307
+ result = inPx;
1308
+ }
1309
+ if (Math.abs(result - Math.round(result)) < 0.01) {
1310
+ return `${Math.round(result)}${toUnit}`;
1311
+ }
1312
+ return `${result.toFixed(2)}${toUnit}`;
1313
+ },
1314
+ // Min/Max/Clamp with better formatting
1315
+ min: (...values) => {
1316
+ const formatted = values.map((v) => normalizeValue(v)).join(", ");
1317
+ return `min(${formatted})`;
1318
+ },
1319
+ max: (...values) => {
1320
+ const formatted = values.map((v) => normalizeValue(v)).join(", ");
1321
+ return `max(${formatted})`;
1322
+ },
1323
+ clamp: (min, preferred, max, options) => {
1324
+ const minVal = normalizeValue(min);
1325
+ const prefVal = normalizeValue(preferred);
1326
+ const maxVal = normalizeValue(max);
1327
+ let result = `clamp(${minVal}, ${prefVal}, ${maxVal})`;
1328
+ if (options?.simplify) {
1329
+ result = simplifyCalc(result);
1330
+ }
1331
+ return result;
1332
+ },
1333
+ // Rounding helpers
1334
+ round: (value, precision = 2) => {
1335
+ const num = typeof value === "number" ? value : parseFloat(value);
1336
+ return num.toFixed(precision);
1337
+ },
1338
+ ceil: (value) => {
1339
+ const num = typeof value === "number" ? value : parseFloat(value);
1340
+ return Math.ceil(num).toString();
1341
+ },
1342
+ floor: (value) => {
1343
+ const num = typeof value === "number" ? value : parseFloat(value);
1344
+ return Math.floor(num).toString();
1345
+ },
1346
+ // Color helpers (returns CSS color values)
1347
+ rgba: (r, g, b, a = 1) => {
1348
+ return `rgba(${r}, ${g}, ${b}, ${a})`;
1349
+ },
1350
+ hsla: (h2, s, l, a = 1) => {
1351
+ return `hsla(${h2}, ${s}%, ${l}%, ${a})`;
1352
+ },
1353
+ // String helpers
1354
+ url: (path) => {
1355
+ return `url(${path})`;
1356
+ },
1357
+ format: (strings, ...values) => {
1358
+ let result = "";
1359
+ for (let i = 0; i < strings.length; i++) {
1360
+ result += strings[i];
1361
+ if (i < values.length) {
1362
+ result += normalizeValue(values[i]);
1363
+ }
1364
+ }
1365
+ return result;
1366
+ },
1367
+ // Conditional helpers
1368
+ if: (condition, trueValue, falseValue) => {
1369
+ return condition ? trueValue : falseValue;
1370
+ },
1371
+ // String manipulation
1372
+ camelToKebab: (str) => {
1373
+ return str.replace(/([A-Z])/g, "-$1").toLowerCase();
1374
+ },
1375
+ kebabToCamel: (str) => {
1376
+ return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
1377
+ },
1378
+ toPx: (value) => {
1379
+ if (typeof value === "number") return `${value}px`;
1380
+ if (/^\d+(?:\.\d+)?$/.test(value)) return `${value}px`;
1381
+ return value;
1382
+ },
1383
+ toRem: (value, base = 16) => {
1384
+ if (typeof value === "number") return `${value / base}rem`;
1385
+ if (/^\d+(?:\.\d+)?px$/.test(value)) {
1386
+ const px = parseFloat(value);
1387
+ return `${px / base}rem`;
1388
+ }
1389
+ if (/^\d+(?:\.\d+)?$/.test(value)) {
1390
+ const numValue = typeof value === "string" ? parseFloat(value) : value;
1391
+ return `${numValue / base}rem`;
1392
+ }
1393
+ return value;
1394
+ }
1395
+ };
1396
+
1397
+ // node_modules/chalk/source/vendor/ansi-styles/index.js
1398
+ var ANSI_BACKGROUND_OFFSET = 10;
1399
+ var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
1400
+ var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
1401
+ var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
1402
+ var styles = {
1403
+ modifier: {
1404
+ reset: [0, 0],
1405
+ // 21 isn't widely supported and 22 does the same thing
1406
+ bold: [1, 22],
1407
+ dim: [2, 22],
1408
+ italic: [3, 23],
1409
+ underline: [4, 24],
1410
+ overline: [53, 55],
1411
+ inverse: [7, 27],
1412
+ hidden: [8, 28],
1413
+ strikethrough: [9, 29]
1414
+ },
1415
+ color: {
1416
+ black: [30, 39],
1417
+ red: [31, 39],
1418
+ green: [32, 39],
1419
+ yellow: [33, 39],
1420
+ blue: [34, 39],
1421
+ magenta: [35, 39],
1422
+ cyan: [36, 39],
1423
+ white: [37, 39],
1424
+ // Bright color
1425
+ blackBright: [90, 39],
1426
+ gray: [90, 39],
1427
+ // Alias of `blackBright`
1428
+ grey: [90, 39],
1429
+ // Alias of `blackBright`
1430
+ redBright: [91, 39],
1431
+ greenBright: [92, 39],
1432
+ yellowBright: [93, 39],
1433
+ blueBright: [94, 39],
1434
+ magentaBright: [95, 39],
1435
+ cyanBright: [96, 39],
1436
+ whiteBright: [97, 39]
1437
+ },
1438
+ bgColor: {
1439
+ bgBlack: [40, 49],
1440
+ bgRed: [41, 49],
1441
+ bgGreen: [42, 49],
1442
+ bgYellow: [43, 49],
1443
+ bgBlue: [44, 49],
1444
+ bgMagenta: [45, 49],
1445
+ bgCyan: [46, 49],
1446
+ bgWhite: [47, 49],
1447
+ // Bright color
1448
+ bgBlackBright: [100, 49],
1449
+ bgGray: [100, 49],
1450
+ // Alias of `bgBlackBright`
1451
+ bgGrey: [100, 49],
1452
+ // Alias of `bgBlackBright`
1453
+ bgRedBright: [101, 49],
1454
+ bgGreenBright: [102, 49],
1455
+ bgYellowBright: [103, 49],
1456
+ bgBlueBright: [104, 49],
1457
+ bgMagentaBright: [105, 49],
1458
+ bgCyanBright: [106, 49],
1459
+ bgWhiteBright: [107, 49]
1460
+ }
1461
+ };
1462
+ var modifierNames = Object.keys(styles.modifier);
1463
+ var foregroundColorNames = Object.keys(styles.color);
1464
+ var backgroundColorNames = Object.keys(styles.bgColor);
1465
+ var colorNames = [...foregroundColorNames, ...backgroundColorNames];
1466
+ function assembleStyles() {
1467
+ const codes = /* @__PURE__ */ new Map();
1468
+ for (const [groupName, group] of Object.entries(styles)) {
1469
+ for (const [styleName, style] of Object.entries(group)) {
1470
+ styles[styleName] = {
1471
+ open: `\x1B[${style[0]}m`,
1472
+ close: `\x1B[${style[1]}m`
1473
+ };
1474
+ group[styleName] = styles[styleName];
1475
+ codes.set(style[0], style[1]);
1476
+ }
1477
+ Object.defineProperty(styles, groupName, {
1478
+ value: group,
1479
+ enumerable: false
1480
+ });
1481
+ }
1482
+ Object.defineProperty(styles, "codes", {
1483
+ value: codes,
1484
+ enumerable: false
1485
+ });
1486
+ styles.color.close = "\x1B[39m";
1487
+ styles.bgColor.close = "\x1B[49m";
1488
+ styles.color.ansi = wrapAnsi16();
1489
+ styles.color.ansi256 = wrapAnsi256();
1490
+ styles.color.ansi16m = wrapAnsi16m();
1491
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
1492
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
1493
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
1494
+ Object.defineProperties(styles, {
1495
+ rgbToAnsi256: {
1496
+ value(red, green, blue) {
1497
+ if (red === green && green === blue) {
1498
+ if (red < 8) {
1499
+ return 16;
1500
+ }
1501
+ if (red > 248) {
1502
+ return 231;
1503
+ }
1504
+ return Math.round((red - 8) / 247 * 24) + 232;
1505
+ }
1506
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
1507
+ },
1508
+ enumerable: false
1509
+ },
1510
+ hexToRgb: {
1511
+ value(hex) {
1512
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
1513
+ if (!matches) {
1514
+ return [0, 0, 0];
1515
+ }
1516
+ let [colorString] = matches;
1517
+ if (colorString.length === 3) {
1518
+ colorString = [...colorString].map((character) => character + character).join("");
1519
+ }
1520
+ const integer = Number.parseInt(colorString, 16);
1521
+ return [
1522
+ /* eslint-disable no-bitwise */
1523
+ integer >> 16 & 255,
1524
+ integer >> 8 & 255,
1525
+ integer & 255
1526
+ /* eslint-enable no-bitwise */
1527
+ ];
1528
+ },
1529
+ enumerable: false
1530
+ },
1531
+ hexToAnsi256: {
1532
+ value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
1533
+ enumerable: false
1534
+ },
1535
+ ansi256ToAnsi: {
1536
+ value(code) {
1537
+ if (code < 8) {
1538
+ return 30 + code;
1539
+ }
1540
+ if (code < 16) {
1541
+ return 90 + (code - 8);
1542
+ }
1543
+ let red;
1544
+ let green;
1545
+ let blue;
1546
+ if (code >= 232) {
1547
+ red = ((code - 232) * 10 + 8) / 255;
1548
+ green = red;
1549
+ blue = red;
1550
+ } else {
1551
+ code -= 16;
1552
+ const remainder = code % 36;
1553
+ red = Math.floor(code / 36) / 5;
1554
+ green = Math.floor(remainder / 6) / 5;
1555
+ blue = remainder % 6 / 5;
1556
+ }
1557
+ const value = Math.max(red, green, blue) * 2;
1558
+ if (value === 0) {
1559
+ return 30;
1560
+ }
1561
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
1562
+ if (value === 2) {
1563
+ result += 60;
1564
+ }
1565
+ return result;
1566
+ },
1567
+ enumerable: false
1568
+ },
1569
+ rgbToAnsi: {
1570
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
1571
+ enumerable: false
1572
+ },
1573
+ hexToAnsi: {
1574
+ value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
1575
+ enumerable: false
1576
+ }
1577
+ });
1578
+ return styles;
1579
+ }
1580
+ var ansiStyles = assembleStyles();
1581
+ var ansi_styles_default = ansiStyles;
1582
+
1583
+ // node_modules/chalk/source/vendor/supports-color/browser.js
1584
+ var level = (() => {
1585
+ if (!("navigator" in globalThis)) {
1586
+ return 0;
1587
+ }
1588
+ if (globalThis.navigator.userAgentData) {
1589
+ const brand = navigator.userAgentData.brands.find(({ brand: brand2 }) => brand2 === "Chromium");
1590
+ if (brand && brand.version > 93) {
1591
+ return 3;
1592
+ }
1593
+ }
1594
+ if (/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)) {
1595
+ return 1;
1596
+ }
1597
+ return 0;
1598
+ })();
1599
+ var colorSupport = level !== 0 && {
1600
+ level,
1601
+ hasBasic: true,
1602
+ has256: level >= 2,
1603
+ has16m: level >= 3
1604
+ };
1605
+ var supportsColor = {
1606
+ stdout: colorSupport,
1607
+ stderr: colorSupport
1608
+ };
1609
+ var browser_default = supportsColor;
1610
+
1611
+ // node_modules/chalk/source/utilities.js
1612
+ function stringReplaceAll(string, substring, replacer) {
1613
+ let index = string.indexOf(substring);
1614
+ if (index === -1) {
1615
+ return string;
1616
+ }
1617
+ const substringLength = substring.length;
1618
+ let endIndex = 0;
1619
+ let returnValue = "";
1620
+ do {
1621
+ returnValue += string.slice(endIndex, index) + substring + replacer;
1622
+ endIndex = index + substringLength;
1623
+ index = string.indexOf(substring, endIndex);
1624
+ } while (index !== -1);
1625
+ returnValue += string.slice(endIndex);
1626
+ return returnValue;
1627
+ }
1628
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
1629
+ let endIndex = 0;
1630
+ let returnValue = "";
1631
+ do {
1632
+ const gotCR = string[index - 1] === "\r";
1633
+ returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
1634
+ endIndex = index + 1;
1635
+ index = string.indexOf("\n", endIndex);
1636
+ } while (index !== -1);
1637
+ returnValue += string.slice(endIndex);
1638
+ return returnValue;
1639
+ }
1640
+
1641
+ // node_modules/chalk/source/index.js
1642
+ var { stdout: stdoutColor, stderr: stderrColor } = browser_default;
1643
+ var GENERATOR = /* @__PURE__ */ Symbol("GENERATOR");
1644
+ var STYLER = /* @__PURE__ */ Symbol("STYLER");
1645
+ var IS_EMPTY = /* @__PURE__ */ Symbol("IS_EMPTY");
1646
+ var levelMapping = [
1647
+ "ansi",
1648
+ "ansi",
1649
+ "ansi256",
1650
+ "ansi16m"
1651
+ ];
1652
+ var styles2 = /* @__PURE__ */ Object.create(null);
1653
+ var applyOptions = (object, options = {}) => {
1654
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
1655
+ throw new Error("The `level` option should be an integer from 0 to 3");
1656
+ }
1657
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
1658
+ object.level = options.level === void 0 ? colorLevel : options.level;
1659
+ };
1660
+ var chalkFactory = (options) => {
1661
+ const chalk2 = (...strings) => strings.join(" ");
1662
+ applyOptions(chalk2, options);
1663
+ Object.setPrototypeOf(chalk2, createChalk.prototype);
1664
+ return chalk2;
1665
+ };
1666
+ function createChalk(options) {
1667
+ return chalkFactory(options);
1668
+ }
1669
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
1670
+ for (const [styleName, style] of Object.entries(ansi_styles_default)) {
1671
+ styles2[styleName] = {
1672
+ get() {
1673
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
1674
+ Object.defineProperty(this, styleName, { value: builder });
1675
+ return builder;
1676
+ }
1677
+ };
1678
+ }
1679
+ styles2.visible = {
1680
+ get() {
1681
+ const builder = createBuilder(this, this[STYLER], true);
1682
+ Object.defineProperty(this, "visible", { value: builder });
1683
+ return builder;
1684
+ }
1685
+ };
1686
+ var getModelAnsi = (model, level2, type, ...arguments_) => {
1687
+ if (model === "rgb") {
1688
+ if (level2 === "ansi16m") {
1689
+ return ansi_styles_default[type].ansi16m(...arguments_);
1690
+ }
1691
+ if (level2 === "ansi256") {
1692
+ return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
1693
+ }
1694
+ return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
1695
+ }
1696
+ if (model === "hex") {
1697
+ return getModelAnsi("rgb", level2, type, ...ansi_styles_default.hexToRgb(...arguments_));
1698
+ }
1699
+ return ansi_styles_default[type][model](...arguments_);
1700
+ };
1701
+ var usedModels = ["rgb", "hex", "ansi256"];
1702
+ for (const model of usedModels) {
1703
+ styles2[model] = {
1704
+ get() {
1705
+ const { level: level2 } = this;
1706
+ return function(...arguments_) {
1707
+ const styler = createStyler(getModelAnsi(model, levelMapping[level2], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
1708
+ return createBuilder(this, styler, this[IS_EMPTY]);
1709
+ };
1710
+ }
1711
+ };
1712
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
1713
+ styles2[bgModel] = {
1714
+ get() {
1715
+ const { level: level2 } = this;
1716
+ return function(...arguments_) {
1717
+ const styler = createStyler(getModelAnsi(model, levelMapping[level2], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
1718
+ return createBuilder(this, styler, this[IS_EMPTY]);
1719
+ };
1720
+ }
1721
+ };
1722
+ }
1723
+ var proto = Object.defineProperties(() => {
1724
+ }, {
1725
+ ...styles2,
1726
+ level: {
1727
+ enumerable: true,
1728
+ get() {
1729
+ return this[GENERATOR].level;
1730
+ },
1731
+ set(level2) {
1732
+ this[GENERATOR].level = level2;
1733
+ }
1734
+ }
1735
+ });
1736
+ var createStyler = (open, close, parent) => {
1737
+ let openAll;
1738
+ let closeAll;
1739
+ if (parent === void 0) {
1740
+ openAll = open;
1741
+ closeAll = close;
1742
+ } else {
1743
+ openAll = parent.openAll + open;
1744
+ closeAll = close + parent.closeAll;
1745
+ }
1746
+ return {
1747
+ open,
1748
+ close,
1749
+ openAll,
1750
+ closeAll,
1751
+ parent
1752
+ };
1753
+ };
1754
+ var createBuilder = (self, _styler, _isEmpty) => {
1755
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
1756
+ Object.setPrototypeOf(builder, proto);
1757
+ builder[GENERATOR] = self;
1758
+ builder[STYLER] = _styler;
1759
+ builder[IS_EMPTY] = _isEmpty;
1760
+ return builder;
1761
+ };
1762
+ var applyStyle = (self, string) => {
1763
+ if (self.level <= 0 || !string) {
1764
+ return self[IS_EMPTY] ? "" : string;
1765
+ }
1766
+ let styler = self[STYLER];
1767
+ if (styler === void 0) {
1768
+ return string;
1769
+ }
1770
+ const { openAll, closeAll } = styler;
1771
+ if (string.includes("\x1B")) {
1772
+ while (styler !== void 0) {
1773
+ string = stringReplaceAll(string, styler.close, styler.open);
1774
+ styler = styler.parent;
1775
+ }
1776
+ }
1777
+ const lfIndex = string.indexOf("\n");
1778
+ if (lfIndex !== -1) {
1779
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
1780
+ }
1781
+ return openAll + string + closeAll;
1782
+ };
1783
+ Object.defineProperties(createChalk.prototype, styles2);
1784
+ var chalk = createChalk();
1785
+ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
1786
+ var source_default = chalk;
1787
+
1788
+ // src/compiler/Chain.ts
1789
+ var currentTokenContext2 = null;
1790
+ var debugMode = false;
1791
+ var PUBLIC_METHODS = /* @__PURE__ */ new Set([
1792
+ // Finalizers
1793
+ "$el",
1794
+ "end",
1795
+ // State & Nesting
1796
+ "hover",
1797
+ "use",
1798
+ "when",
1799
+ "nest",
1800
+ // Component
1801
+ "component",
1802
+ "componentName",
1803
+ "props",
1804
+ // Responsive & AT-Rules
1805
+ "responsive",
1806
+ "media",
1807
+ "supports",
1808
+ "containerQuery",
1809
+ "layer",
1810
+ "keyframes",
1811
+ "fontFace",
1812
+ // Animations
1813
+ "animation",
1814
+ "animate",
1815
+ "duration",
1816
+ "delay",
1817
+ "timing",
1818
+ "iteration",
1819
+ "infinite",
1820
+ // Math Helpers
1821
+ "calc",
1822
+ "add",
1823
+ "subtract",
1824
+ "sub",
1825
+ "multiply",
1826
+ "mul",
1827
+ "divide",
1828
+ "div",
1829
+ "mpx",
1830
+ "rem",
1831
+ "em",
1832
+ "percent",
1833
+ "vw",
1834
+ "vh",
1835
+ "min",
1836
+ "max",
1837
+ "clamp",
1838
+ // Meta
1839
+ "debug",
1840
+ "explain"
1841
+ ]);
1842
+ var ChainClass = class {
1843
+ catcher = {};
1844
+ useTokens;
1845
+ hoverCatcher = null;
1846
+ valueCache = /* @__PURE__ */ new Map();
1847
+ MAX_CACHE_SIZE = 200;
1848
+ __proxy = null;
1849
+ constructor(useTokens = true) {
1850
+ this.useTokens = useTokens;
1851
+ }
1852
+ // ==========================================================================
1853
+ // Core Methods
1854
+ // ==========================================================================
1855
+ resolveValue(value) {
1856
+ const cacheKey = typeof value === "function" ? `fn_${value.toString().slice(0, 100)}` : JSON.stringify(value);
1857
+ if (this.valueCache.has(cacheKey)) {
1858
+ return this.valueCache.get(cacheKey);
1859
+ }
1860
+ let resolved = value;
1861
+ if (typeof value === "function") {
1862
+ resolved = value(helpers);
1863
+ }
1864
+ if (this.useTokens && typeof resolved === "string" && resolved.includes("$")) {
1865
+ const tokenResolved = resolveToken(resolved, this.useTokens, currentTokenContext2);
1866
+ resolved = tokenResolved !== void 0 && tokenResolved !== null ? tokenResolved : resolved;
1867
+ }
1868
+ if (this.valueCache.size >= this.MAX_CACHE_SIZE) {
1869
+ const firstKey = this.valueCache.keys().next().value;
1870
+ if (firstKey) this.valueCache.delete(firstKey);
1871
+ }
1872
+ this.valueCache.set(cacheKey, resolved);
1873
+ return resolved;
1874
+ }
1875
+ setTransform(type, value) {
1876
+ if (!this.catcher._transforms) this.catcher._transforms = {};
1877
+ this.catcher._transforms[type] = this.resolveValue(value);
1878
+ return this.__proxy || this;
1879
+ }
1880
+ setProperty(prop, value) {
1881
+ if (handleShorthand(prop, value, this.catcher, this.useTokens)) {
1882
+ return this.__proxy || this;
1883
+ }
1884
+ const mappedProp = shorthandMap[prop] || prop;
1885
+ let resolvedValue = this.resolveValue(value);
1886
+ if (debugMode) {
1887
+ const displayProp = prop === mappedProp ? prop : `${prop} (${mappedProp})`;
1888
+ console.log(
1889
+ source_default.blue(`[ChainCSS Debug]`),
1890
+ source_default.gray(displayProp),
1891
+ "->",
1892
+ source_default.green(resolvedValue)
1893
+ );
1894
+ }
1895
+ const unitlessProperties = /* @__PURE__ */ new Set([
1896
+ "zIndex",
1897
+ "opacity",
1898
+ "flex",
1899
+ "order",
1900
+ "flexGrow",
1901
+ "flexShrink",
1902
+ "flexBasis",
1903
+ "fontWeight",
1904
+ "lineHeight",
1905
+ "scale",
1906
+ "zoom",
1907
+ "animationIterationCount",
1908
+ "columnCount",
1909
+ "orphans",
1910
+ "widows",
1911
+ "tabSize"
1912
+ ]);
1913
+ if (typeof resolvedValue === "number" && !unitlessProperties.has(prop) && !unitlessProperties.has(mappedProp)) {
1914
+ resolvedValue = `${resolvedValue}px`;
1915
+ }
1916
+ if (this.hoverCatcher !== null) {
1917
+ this.hoverCatcher[mappedProp] = resolvedValue;
1918
+ } else {
1919
+ this.catcher[mappedProp] = resolvedValue;
1920
+ }
1921
+ return this.__proxy || this;
1922
+ }
1923
+ // ==========================================================================
1924
+ // Proxy handler - routes all property access
1925
+ // ==========================================================================
1926
+ get(prop) {
1927
+ if (typeof prop === "symbol") return void 0;
1928
+ if (prop === "mx") return (value) => this.macroHandler("mx", value);
1929
+ if (prop === "my") return (value) => this.macroHandler("my", value);
1930
+ if (prop === "px") return (value) => this.macroHandler("px", value);
1931
+ if (prop === "py") return (value) => this.macroHandler("py", value);
1932
+ if (prop === "size") return (value) => this.macroHandler("size", value);
1933
+ if (prop === "inset") return (value) => this.macroHandler("inset", value);
1934
+ if (prop === "insetX") return (value) => this.macroHandler("insetX", value);
1935
+ if (prop === "insetY") return (value) => this.macroHandler("insetY", value);
1936
+ if (prop === "borderX") return (value) => this.macroHandler("borderX", value);
1937
+ if (prop === "borderY") return (value) => this.macroHandler("borderY", value);
1938
+ if (prop === "flex") return (value) => this.macroHandler("flex", value);
1939
+ if (prop === "inlineFlex") return (value) => this.macroHandler("inlineFlex", value);
1940
+ if (prop === "grid") return (value) => this.macroHandler("grid", value);
1941
+ if (prop === "inlineGrid") return (value) => this.macroHandler("inlineGrid", value);
1942
+ if (prop === "cols") return (value) => this.macroHandler("cols", value);
1943
+ if (prop === "rows") return (value) => this.macroHandler("rows", value);
1944
+ if (prop === "center") return (type) => this.macroHandler("center", type);
1945
+ if (prop === "flexCenter") return (dir) => this.macroHandler("flexCenter", dir);
1946
+ if (prop === "gridCenter") return () => this.macroHandler("gridCenter");
1947
+ if (prop === "stack") return (config) => this.macroHandler("stack", config);
1948
+ if (prop === "gridTable") return (minWidth) => this.macroHandler("gridTable", minWidth);
1949
+ if (prop === "aspect") return (ratio) => this.macroHandler("aspect", ratio);
1950
+ if (prop === "hide") return () => this.macroHandler("hide");
1951
+ if (prop === "show") return () => this.macroHandler("show");
1952
+ if (prop === "unselectable") return () => this.macroHandler("unselectable");
1953
+ if (prop === "scrollable") return (axis) => this.macroHandler("scrollable", axis);
1954
+ if (prop === "safeArea") return (edge) => this.macroHandler("safeArea", edge);
1955
+ if (prop === "absolute") return (coords) => this.macroHandler("absolute", coords);
1956
+ if (prop === "fixed") return (coords) => this.macroHandler("fixed", coords);
1957
+ if (prop === "sticky") return (coords) => this.macroHandler("sticky", coords);
1958
+ if (prop === "relative") return (coords) => this.macroHandler("relative", coords);
1959
+ if (prop === "circle") return (size) => this.macroHandler("circle", size);
1960
+ if (prop === "square") return (size) => this.macroHandler("square", size);
1961
+ if (prop === "truncate") return () => this.macroHandler("truncate");
1962
+ if (prop === "fluidText") return (config) => this.macroHandler("fluidText", config);
1963
+ if (prop === "glass") return (blur) => this.macroHandler("glass", blur);
1964
+ if (prop === "glow") return (config) => this.macroHandler("glow", config);
1965
+ if (prop === "textGradient") return (colors) => this.macroHandler("textGradient", colors);
1966
+ if (prop === "meshGradient") return (colors) => this.macroHandler("meshGradient", colors);
1967
+ if (prop === "noise") return (opacity) => this.macroHandler("noise", opacity);
1968
+ if (prop === "skeleton") return (active) => this.macroHandler("skeleton", active);
1969
+ if (prop === "clickScale") return (amount) => this.macroHandler("clickScale", amount);
1970
+ if (prop === "onInteracting") return (callback) => this.macroHandler("onInteracting", callback);
1971
+ if (prop === "children") return (callback) => this.macroHandler("children", callback);
1972
+ if (prop === "dark") return (callback) => this.macroHandler("dark", callback);
1973
+ if (prop === "light") return (callback) => this.macroHandler("light", callback);
1974
+ if (prop === "pill") return () => this.macroHandler("pill");
1975
+ if (prop === "containerMacro") return (maxWidth) => this.macroHandler("containerMacro", maxWidth);
1976
+ if (prop === "fullScreen") return (zIndex) => this.macroHandler("fullScreen", zIndex);
1977
+ if (prop === "shimmer") return () => this.macroHandler("shimmer");
1978
+ if (prop === "bento") return (cols) => this.macroHandler("bento", cols);
1979
+ if (prop === "pressable") return () => this.macroHandler("pressable");
1980
+ if (prop === "focusRing") return (color) => this.macroHandler("focusRing", color);
1981
+ if (prop === "outlineDebug") return () => this.macroHandler("outlineDebug");
1982
+ if (prop === "parallax") return (scale) => this.macroHandler("parallax", scale);
1983
+ if (prop === "lineClamp") return (lines) => this.macroHandler("lineClamp", lines);
1984
+ if (prop === "frostedNav") return (blur) => this.macroHandler("frostedNav", blur);
1985
+ if (prop === "gap") return (value) => this.setProperty("gap", value);
1986
+ if (prop === "gapX") return (value) => this.setProperty("columnGap", value);
1987
+ if (prop === "gapY") return (value) => this.setProperty("rowGap", value);
1988
+ if (prop === "hover") return this.createHover.bind(this);
1989
+ if (prop === "end") return this.endHover.bind(this);
1990
+ if (prop === "use") return this.useMixin.bind(this);
1991
+ if (prop === "when") return this.whenCondition.bind(this);
1992
+ if (prop === "nest") return this.nestSelector.bind(this);
1993
+ if (prop === "component") return this.setComponent.bind(this);
1994
+ if (prop === "componentName") return this.setComponentName.bind(this);
1995
+ if (prop === "props") return this.setProps.bind(this);
1996
+ if (prop === "debug") return this.enableDebugMode.bind(this);
1997
+ if (prop === "explain") return this.explainShorthand.bind(this);
1998
+ if (prop === "$el") return this.finalize.bind(this);
1999
+ if (prop === "scale") return (value) => this.setTransform("scale", value);
2000
+ if (prop === "rotate") return (value) => this.setTransform("rotate", value);
2001
+ if (prop === "x") return (value) => this.setTransform("translateX", value);
2002
+ if (prop === "y") return (value) => this.setTransform("translateY", value);
2003
+ if (prop === "skew") return (value) => this.setTransform("skew", value);
2004
+ if (animationPresets[prop]) {
2005
+ return (config) => this.applyAnimation(prop, config);
2006
+ }
2007
+ if (prop === "animate") return this.createAnimation.bind(this);
2008
+ if (prop === "duration") return (v) => this.setProperty("animationDuration", v);
2009
+ if (prop === "delay") return (v) => this.setProperty("animationDelay", v);
2010
+ if (prop === "timing") return (v) => this.setProperty("animationTimingFunction", v);
2011
+ if (prop === "iteration") return (v) => this.setProperty("animationIterationCount", v);
2012
+ if (prop === "infinite") return () => this.setProperty("animationIterationCount", "infinite");
2013
+ if (prop === "calc") return helpers.calc;
2014
+ if (prop === "add") return helpers.add;
2015
+ if (prop === "subtract" || prop === "sub") return helpers.subtract;
2016
+ if (prop === "multiply" || prop === "mul") return helpers.multiply;
2017
+ if (prop === "divide" || prop === "div") return helpers.divide;
2018
+ if (prop === "mpx") return (v) => helpers.mpx(v);
2019
+ if (prop === "rem") return (v) => helpers.rem(v);
2020
+ if (prop === "em") return helpers.em;
2021
+ if (prop === "percent") return helpers.percent;
2022
+ if (prop === "vw") return helpers.vw;
2023
+ if (prop === "vh") return helpers.vh;
2024
+ if (prop === "min") return helpers.min;
2025
+ if (prop === "max") return helpers.max;
2026
+ if (prop === "clamp") return helpers.clamp;
2027
+ if (currentBreakpoints && currentBreakpoints[prop]) {
2028
+ return (callback) => this.applyResponsive(prop, callback);
2029
+ }
2030
+ if (prop === "media") return this.applyMedia.bind(this);
2031
+ if (prop === "keyframes") return this.defineKeyframes.bind(this);
2032
+ if (prop === "fontFace") return this.defineFontFace.bind(this);
2033
+ if (prop === "supports") return this.applySupports.bind(this);
2034
+ if (prop === "containerQuery") return this.applyContainerQuery.bind(this);
2035
+ if (prop === "layer") return this.applyLayer.bind(this);
2036
+ return (value) => this.setProperty(prop, value);
2037
+ }
2038
+ // ==========================================================================
2039
+ // Finalize
2040
+ // ==========================================================================
2041
+ finalize(...selectors) {
2042
+ const styles3 = structuredClone(this.catcher);
2043
+ delete styles3._componentName;
2044
+ delete styles3._generateComponent;
2045
+ delete styles3._framework;
2046
+ delete styles3._propsDefinition;
2047
+ if (this.catcher._transforms) {
2048
+ const t = this.catcher._transforms;
2049
+ const transformString = Object.entries(t).map(([k, v]) => {
2050
+ const needsUnit = k.includes("translate") || k === "x" || k === "y";
2051
+ const unit = needsUnit && typeof v === "number" ? "px" : "";
2052
+ return `${k}(${v}${unit})`;
2053
+ }).join(" ");
2054
+ styles3.transform = transformString;
2055
+ delete styles3._transforms;
2056
+ }
2057
+ if (this.catcher.nestedRules) {
2058
+ styles3.nestedRules = structuredClone(this.catcher.nestedRules);
2059
+ }
2060
+ for (const key of Object.keys(styles3)) {
2061
+ if (key.startsWith("&:")) {
2062
+ const pseudoSelector = key.substring(1);
2063
+ styles3[pseudoSelector] = styles3[key];
2064
+ delete styles3[key];
2065
+ }
2066
+ }
2067
+ this.clear();
2068
+ if (selectors.length === 0) return styles3;
2069
+ if (debugMode) {
2070
+ console.log("[ChainCSS Debug] Raw selectors:", selectors);
2071
+ }
2072
+ const cleanSelectors = selectors.map((selector) => {
2073
+ let clean = selector;
2074
+ if (clean.startsWith(".chain-")) {
2075
+ clean = clean.replace(/^\./, "").replace(/^chain-/, "");
2076
+ } else if (clean.startsWith("chain-")) {
2077
+ clean = clean.substring(6);
2078
+ }
2079
+ if (debugMode) {
2080
+ console.log(`[ChainCSS Debug] Cleaned: "${selector}" -> "${clean}"`);
2081
+ }
2082
+ return clean;
2083
+ });
2084
+ if (debugMode) {
2085
+ console.log("[ChainCSS Debug] Final selectors:", cleanSelectors);
2086
+ }
2087
+ return {
2088
+ selectors: cleanSelectors,
2089
+ ...styles3
2090
+ };
2091
+ }
2092
+ // ==========================================================================
2093
+ // Public Method Implementations (renamed to avoid collisions)
2094
+ // ==========================================================================
2095
+ macroHandler(macroName, value) {
2096
+ const macroFn = macros[macroName];
2097
+ if (macroFn) {
2098
+ macroFn(value, this.catcher, this.useTokens);
2099
+ } else {
2100
+ this.setProperty(macroName, value);
2101
+ }
2102
+ return this.__proxy || this;
2103
+ }
2104
+ createHover() {
2105
+ if (debugMode) {
2106
+ console.log(` \u{1F5B1}\uFE0F Hover styles added`);
2107
+ }
2108
+ this.hoverCatcher = {};
2109
+ return this.__proxy || this;
2110
+ }
2111
+ endHover() {
2112
+ if (this.hoverCatcher !== null) {
2113
+ this.catcher.hover = { ...this.hoverCatcher };
2114
+ this.hoverCatcher = null;
2115
+ }
2116
+ return this.__proxy || this;
2117
+ }
2118
+ useMixin(mixin) {
2119
+ const { selectors, atRules, ...styles3 } = mixin;
2120
+ Object.assign(this.catcher, styles3);
2121
+ if (atRules) {
2122
+ this.catcher.atRules = [...this.catcher.atRules || [], ...atRules];
2123
+ }
2124
+ return this.__proxy || this;
2125
+ }
2126
+ whenCondition(condition, callback) {
2127
+ if (condition) {
2128
+ callback(this.__proxy || this);
2129
+ }
2130
+ return this.__proxy || this;
2131
+ }
2132
+ nestSelector(selector, callback) {
2133
+ const subChain = createChain(this.useTokens);
2134
+ callback(subChain);
2135
+ const result = subChain.$el();
2136
+ if (!this.catcher.nestedRules) this.catcher.nestedRules = [];
2137
+ this.catcher.nestedRules.push({
2138
+ selector,
2139
+ styles: result
2140
+ });
2141
+ return this.__proxy || this;
2142
+ }
2143
+ setComponentName(name) {
2144
+ this.catcher._componentName = name;
2145
+ return this.__proxy || this;
2146
+ }
2147
+ setComponent(framework = "auto") {
2148
+ this.catcher._generateComponent = true;
2149
+ this.catcher._framework = framework;
2150
+ return this.__proxy || this;
2151
+ }
2152
+ setProps(propsDefinition) {
2153
+ if (propsDefinition) {
2154
+ this.catcher._propsDefinition = propsDefinition;
2155
+ }
2156
+ return this.__proxy || this;
2157
+ }
2158
+ enableDebugMode() {
2159
+ debugMode = true;
2160
+ return this.__proxy || this;
2161
+ }
2162
+ explainShorthand(shorthand) {
2163
+ const mapped = shorthandMap[shorthand];
2164
+ if (mapped) {
2165
+ console.log(`
2166
+ \u{1F4D6} ChainCSS Explanation:`);
2167
+ console.log(` .${shorthand}() \u2192 ${mapped}`);
2168
+ console.log(` Example: .${shorthand}('value') sets CSS property '${mapped}'
2169
+ `);
2170
+ } else {
2171
+ const suggestion = getSuggestion(shorthand);
2172
+ if (suggestion && typeof suggestion === "string") {
2173
+ console.log(`
2174
+ \u26A0\uFE0F ChainCSS: '${shorthand}' is not a recognized shorthand.`);
2175
+ console.log(` Did you mean .${suggestion}()?
2176
+ `);
2177
+ } else {
2178
+ console.log(`
2179
+ \u26A0\uFE0F ChainCSS: '${shorthand}' is not a recognized shorthand or CSS property.
2180
+ `);
2181
+ }
2182
+ }
2183
+ return this.__proxy || this;
2184
+ }
2185
+ // ==========================================================================
2186
+ // Animation Methods
2187
+ // ==========================================================================
2188
+ applyAnimation(name, config) {
2189
+ if (!name) {
2190
+ console.warn("\u26A0\uFE0F ChainCSS: animation() requires a name parameter");
2191
+ return this.__proxy || this;
2192
+ }
2193
+ if (!this.catcher.atRules) this.catcher.atRules = [];
2194
+ const preset = animationPresets[name];
2195
+ if (!preset && !this.catcher.atRules.some((rule) => rule.type === "keyframes" && rule.name === name)) {
2196
+ console.warn(`\u26A0\uFE0F ChainCSS: Unknown animation preset '${name}'. Available: ${Object.keys(animationPresets).join(", ")}`);
2197
+ return this.__proxy || this;
2198
+ }
2199
+ const hasKeyframes = this.catcher.atRules.some(
2200
+ (rule) => rule.type === "keyframes" && rule.name === name
2201
+ );
2202
+ if (!hasKeyframes && preset) {
2203
+ this.catcher.atRules.push({
2204
+ type: "keyframes",
2205
+ name,
2206
+ steps: preset
2207
+ });
2208
+ }
2209
+ const animationStyles = createAnimation(name, config);
2210
+ Object.assign(this.catcher, animationStyles);
2211
+ return this.__proxy || this;
2212
+ }
2213
+ createAnimation(name, keyframes, config) {
2214
+ if (!name || !keyframes) {
2215
+ console.warn("\u26A0\uFE0F ChainCSS: animate() requires name and keyframes parameters");
2216
+ return this.__proxy || this;
2217
+ }
2218
+ if (!this.catcher.atRules) this.catcher.atRules = [];
2219
+ this.catcher.atRules.push({
2220
+ type: "keyframes",
2221
+ name,
2222
+ steps: keyframes
2223
+ });
2224
+ const animationStyles = createAnimation(name, config);
2225
+ Object.assign(this.catcher, animationStyles);
2226
+ return this.__proxy || this;
2227
+ }
2228
+ // ==========================================================================
2229
+ // Responsive & AT-Rules
2230
+ // ==========================================================================
2231
+ applyResponsive(breakpoint, callback) {
2232
+ const subChain = createChain(this.useTokens);
2233
+ callback(subChain);
2234
+ const result = subChain.$el();
2235
+ const { selectors, ...pureStyles } = result || {};
2236
+ if (!this.catcher.atRules) this.catcher.atRules = [];
2237
+ this.catcher.atRules.push({
2238
+ type: "media",
2239
+ query: currentBreakpoints[breakpoint],
2240
+ styles: pureStyles
2241
+ });
2242
+ return this.__proxy || this;
2243
+ }
2244
+ applyMedia(query, callback) {
2245
+ const subChain = createChain(this.useTokens);
2246
+ callback(subChain);
2247
+ const result = subChain.$el();
2248
+ const { selectors, ...pureStyles } = result || {};
2249
+ if (!this.catcher.atRules) this.catcher.atRules = [];
2250
+ this.catcher.atRules.push({
2251
+ type: "media",
2252
+ query,
2253
+ styles: pureStyles
2254
+ });
2255
+ return this.__proxy || this;
2256
+ }
2257
+ defineKeyframes(name, steps) {
2258
+ if (!this.catcher.atRules) this.catcher.atRules = [];
2259
+ this.catcher.atRules.push({
2260
+ type: "keyframes",
2261
+ name,
2262
+ steps
2263
+ });
2264
+ return this.__proxy || this;
2265
+ }
2266
+ defineFontFace(properties) {
2267
+ if (!this.catcher.atRules) this.catcher.atRules = [];
2268
+ this.catcher.atRules.push({
2269
+ type: "font-face",
2270
+ properties
2271
+ });
2272
+ return this.__proxy || this;
2273
+ }
2274
+ applySupports(condition, callback) {
2275
+ const subChain = createChain(this.useTokens);
2276
+ callback(subChain);
2277
+ const result = subChain.$el();
2278
+ if (!this.catcher.atRules) this.catcher.atRules = [];
2279
+ this.catcher.atRules.push({
2280
+ type: "supports",
2281
+ condition,
2282
+ styles: result
2283
+ });
2284
+ return this.__proxy || this;
2285
+ }
2286
+ applyContainerQuery(condition, callback) {
2287
+ const subChain = createChain(this.useTokens);
2288
+ callback(subChain);
2289
+ const result = subChain.$el();
2290
+ if (!this.catcher.atRules) this.catcher.atRules = [];
2291
+ this.catcher.atRules.push({
2292
+ type: "container",
2293
+ condition,
2294
+ styles: result
2295
+ });
2296
+ return this.__proxy || this;
2297
+ }
2298
+ applyLayer(name, callback) {
2299
+ const subChain = createChain(this.useTokens);
2300
+ callback(subChain);
2301
+ const result = subChain.$el();
2302
+ if (!this.catcher.atRules) this.catcher.atRules = [];
2303
+ this.catcher.atRules.push({
2304
+ type: "layer",
2305
+ name,
2306
+ styles: result
2307
+ });
2308
+ return this.__proxy || this;
2309
+ }
2310
+ // ==========================================================================
2311
+ // Cleanup
2312
+ // ==========================================================================
2313
+ clear() {
2314
+ this.catcher = {};
2315
+ this.hoverCatcher = null;
2316
+ this.valueCache.clear();
2317
+ }
2318
+ };
2319
+ function createChain(useTokens = true) {
2320
+ const chained = new ChainClass(useTokens);
2321
+ const proxy = new Proxy(chained, {
2322
+ get(target, prop) {
2323
+ if (typeof prop === "symbol") return void 0;
2324
+ if (PUBLIC_METHODS.has(prop) && prop in target) {
2325
+ const val = target[prop];
2326
+ return typeof val === "function" ? val.bind(target) : val;
2327
+ }
2328
+ return target.get(prop);
2329
+ }
2330
+ });
2331
+ chained.__proxy = proxy;
2332
+ return proxy;
2333
+ }
2334
+
2335
+ // src/compiler/shorthands.ts
2336
+ var shorthandMap = {
2337
+ "m": "margin",
2338
+ "mt": "marginTop",
2339
+ "mr": "marginRight",
2340
+ "mb": "marginBottom",
2341
+ "ml": "marginLeft",
2342
+ "p": "padding",
2343
+ "pt": "paddingTop",
2344
+ "pr": "paddingRight",
2345
+ "pb": "paddingBottom",
2346
+ "pl": "paddingLeft",
2347
+ "z": "zIndex",
2348
+ "op": "opacity",
2349
+ "ov": "overflow",
2350
+ "ovx": "overflowX",
2351
+ "ovy": "overflowY",
2352
+ "objFit": "objectFit",
2353
+ "objPos": "objectPosition",
2354
+ "d": "display",
2355
+ "pos": "position",
2356
+ "w": "width",
2357
+ "h": "height",
2358
+ "minW": "minWidth",
2359
+ "maxW": "maxWidth",
2360
+ "minH": "minHeight",
2361
+ "maxH": "maxHeight",
2362
+ "bg": "backgroundColor",
2363
+ "bgImg": "backgroundImage",
2364
+ "bgPos": "backgroundPosition",
2365
+ "bgSize": "backgroundSize",
2366
+ "c": "color",
2367
+ "flexDir": "flexDirection",
2368
+ "flexWrap": "flexWrap",
2369
+ "justify": "justifyContent",
2370
+ "items": "alignItems",
2371
+ "self": "alignSelf",
2372
+ "content": "alignContent",
2373
+ "gap": "gap",
2374
+ "gapX": "columnGap",
2375
+ "gapY": "rowGap",
2376
+ "grow": "flexGrow",
2377
+ "shrink": "flexShrink",
2378
+ "basis": "flexBasis",
2379
+ "order": "order",
2380
+ "gridCols": "gridTemplateColumns",
2381
+ "gridRows": "gridTemplateRows",
2382
+ "gridRow": "gridRow",
2383
+ "gridCol": "gridColumn",
2384
+ "rounded": "borderRadius",
2385
+ "br": "borderRadius",
2386
+ "radius": "borderRadius",
2387
+ "roundedTL": "borderTopLeftRadius",
2388
+ "roundedTR": "borderTopRightRadius",
2389
+ "roundedBR": "borderBottomRightRadius",
2390
+ "roundedBL": "borderBottomLeftRadius",
2391
+ "border": "border",
2392
+ "borderW": "borderWidth",
2393
+ "borderC": "borderColor",
2394
+ "borderS": "borderStyle",
2395
+ "borderT": "borderTop",
2396
+ "borderR": "borderRight",
2397
+ "borderB": "borderBottom",
2398
+ "borderL": "borderLeft",
2399
+ "fontF": "fontFamily",
2400
+ "text": "color",
2401
+ "align": "textAlign",
2402
+ "fs": "fontSize",
2403
+ "fw": "fontWeight",
2404
+ "lh": "lineHeight",
2405
+ "ls": "letterSpacing",
2406
+ "shadow": "boxShadow",
2407
+ "textShadow": "textShadow",
2408
+ "transform": "transform",
2409
+ "transformOrigin": "transformOrigin",
2410
+ "transition": "transition",
2411
+ "transitionAll": "transition",
2412
+ "cursor": "cursor",
2413
+ "pointer": "cursor",
2414
+ "resize": "resize",
2415
+ "filter": "filter",
2416
+ "backdropFilter": "backdropFilter"
2417
+ };
2418
+ var macros = {
2419
+ // --- Spacing & Sizing ---
2420
+ mx: (v, c) => {
2421
+ const value = typeof v === "number" ? `${v}px` : v;
2422
+ c.marginLeft = value;
2423
+ c.marginRight = value;
2424
+ },
2425
+ my: (v, c) => {
2426
+ const value = typeof v === "number" ? `${v}px` : v;
2427
+ c.marginTop = value;
2428
+ c.marginBottom = value;
2429
+ },
2430
+ px: (v, c) => {
2431
+ const value = typeof v === "number" ? `${v}px` : v;
2432
+ c.paddingLeft = value;
2433
+ c.paddingRight = value;
2434
+ },
2435
+ py: (v, c) => {
2436
+ const value = typeof v === "number" ? `${v}px` : v;
2437
+ c.paddingTop = value;
2438
+ c.paddingBottom = value;
2439
+ },
2440
+ size: (v, c) => {
2441
+ c.width = v;
2442
+ c.height = v;
2443
+ },
2444
+ inset: (v, c) => {
2445
+ if (typeof v === "object") {
2446
+ if (v.top !== void 0) c.top = v.top;
2447
+ if (v.right !== void 0) c.right = v.right;
2448
+ if (v.bottom !== void 0) c.bottom = v.bottom;
2449
+ if (v.left !== void 0) c.left = v.left;
2450
+ } else {
2451
+ c.top = v;
2452
+ c.right = v;
2453
+ c.bottom = v;
2454
+ c.left = v;
2455
+ }
2456
+ },
2457
+ insetX: (v, c) => {
2458
+ c.left = v;
2459
+ c.right = v;
2460
+ },
2461
+ insetY: (v, c) => {
2462
+ c.top = v;
2463
+ c.bottom = v;
2464
+ },
2465
+ // --- Borders ---
2466
+ borderX: (v, c) => {
2467
+ c.borderLeft = v;
2468
+ c.borderRight = v;
2469
+ },
2470
+ borderY: (v, c) => {
2471
+ c.borderTop = v;
2472
+ c.borderBottom = v;
2473
+ },
2474
+ // --- Layouts & Display ---
2475
+ flex: (v, c) => {
2476
+ c.display = "flex";
2477
+ if (v && v !== true && typeof v === "string") c.flex = v;
2478
+ },
2479
+ inlineFlex: (v, c) => {
2480
+ c.display = "inline-flex";
2481
+ },
2482
+ grid: (v, c) => {
2483
+ c.display = "grid";
2484
+ if (v && v !== true && typeof v === "string") c.grid = v;
2485
+ },
2486
+ inlineGrid: (v, c) => {
2487
+ c.display = "inline-grid";
2488
+ },
2489
+ cols: (v, c) => {
2490
+ c.gridTemplateColumns = typeof v === "number" ? `repeat(${v}, minmax(0, 1fr))` : v;
2491
+ },
2492
+ rows: (v, c) => {
2493
+ c.gridTemplateRows = typeof v === "number" ? `repeat(${v}, minmax(0, 1fr))` : v;
2494
+ },
2495
+ center: (v, c) => {
2496
+ c.display = v === "inline" ? "inline-flex" : "flex";
2497
+ c.alignItems = "center";
2498
+ c.justifyContent = "center";
2499
+ },
2500
+ flexCenter: (v, c) => {
2501
+ c.display = "flex";
2502
+ c.alignItems = "center";
2503
+ c.justifyContent = "center";
2504
+ if (v === "col" || v === "column") c.flexDirection = "column";
2505
+ },
2506
+ gridCenter: (v, c) => {
2507
+ c.display = "grid";
2508
+ c.placeItems = "center";
2509
+ },
2510
+ stack: (v, c) => {
2511
+ c.display = "flex";
2512
+ if (typeof v === "object") {
2513
+ c.flexDirection = v.dir === "row" ? "row" : "column";
2514
+ c.gap = v.spacing;
2515
+ } else if (v === "row") {
2516
+ c.flexDirection = "row";
2517
+ c.gap = "1rem";
2518
+ } else {
2519
+ c.flexDirection = "column";
2520
+ c.gap = typeof v === "number" ? `${v}px` : v || "1rem";
2521
+ }
2522
+ },
2523
+ gridTable: (v, c) => {
2524
+ const min = typeof v === "number" ? `${v}px` : v;
2525
+ c.display = "grid";
2526
+ c.gridTemplateColumns = `repeat(auto-fit, minmax(${min}, 1fr))`;
2527
+ },
2528
+ // --- Visibility & Behavior ---
2529
+ hide: (v, c) => {
2530
+ c.opacity = 0;
2531
+ c.visibility = "hidden";
2532
+ c.pointerEvents = "none";
2533
+ },
2534
+ show: (v, c) => {
2535
+ c.opacity = 1;
2536
+ c.visibility = "visible";
2537
+ c.pointerEvents = "auto";
2538
+ },
2539
+ unselectable: (v, c) => {
2540
+ c.userSelect = "none";
2541
+ c.WebkitUserSelect = "none";
2542
+ c.MozUserSelect = "none";
2543
+ c.msUserSelect = "none";
2544
+ c.cursor = "default";
2545
+ },
2546
+ scrollable: (v, c) => {
2547
+ if (v === "x") {
2548
+ c.overflowX = "auto";
2549
+ c.overflowY = "hidden";
2550
+ } else if (v === "y") {
2551
+ c.overflowX = "hidden";
2552
+ c.overflowY = "auto";
2553
+ } else if (v === "both") {
2554
+ c.overflow = "auto";
2555
+ } else {
2556
+ c.overflow = "auto";
2557
+ }
2558
+ c.WebkitOverflowScrolling = "touch";
2559
+ },
2560
+ // --- Positioning ---
2561
+ absolute: (v, c) => handlePosition("absolute", v, c),
2562
+ fixed: (v, c) => handlePosition("fixed", v, c),
2563
+ sticky: (v, c) => handlePosition("sticky", v, c),
2564
+ relative: (v, c) => handlePosition("relative", v, c),
2565
+ // --- Shapes & Content ---
2566
+ circle: (v, c) => {
2567
+ c.width = v;
2568
+ c.height = v;
2569
+ c.borderRadius = "50%";
2570
+ c.display = "flex";
2571
+ c.alignItems = "center";
2572
+ c.justifyContent = "center";
2573
+ },
2574
+ square: (v, c) => {
2575
+ c.width = v;
2576
+ c.height = v;
2577
+ c.display = "flex";
2578
+ c.alignItems = "center";
2579
+ c.justifyContent = "center";
2580
+ },
2581
+ truncate: (v, c) => {
2582
+ c.overflow = "hidden";
2583
+ c.textOverflow = "ellipsis";
2584
+ c.whiteSpace = "nowrap";
2585
+ },
2586
+ aspect: (v, c) => {
2587
+ const map = {
2588
+ square: "1 / 1",
2589
+ video: "16 / 9",
2590
+ golden: "1.618 / 1",
2591
+ portrait: "3 / 4",
2592
+ landscape: "4 / 3"
2593
+ };
2594
+ c.aspectRatio = map[v] || v;
2595
+ },
2596
+ // --- Aesthetic Effects ---
2597
+ glass: (v, c) => {
2598
+ const blur = typeof v === "number" ? `${v}px` : v || "10px";
2599
+ c.backdropFilter = `blur(${blur})`;
2600
+ c.WebkitBackdropFilter = `blur(${blur})`;
2601
+ c.backgroundColor = "rgba(255, 255, 255, 0.1)";
2602
+ c.border = "1px solid rgba(255, 255, 255, 0.2)";
2603
+ },
2604
+ glow: (v, c) => {
2605
+ let color;
2606
+ let size;
2607
+ if (typeof v === "string") {
2608
+ color = v;
2609
+ size = 20;
2610
+ } else {
2611
+ color = v.color || "rgba(255,255,255,0.5)";
2612
+ size = v.size || 20;
2613
+ }
2614
+ c.boxShadow = `0 0 ${size / 4}px ${color}, 0 0 ${size / 2}px ${color}, 0 0 ${size}px ${color}`;
2615
+ },
2616
+ textGradient: (v, c) => {
2617
+ let colors;
2618
+ let angle;
2619
+ if (Array.isArray(v)) {
2620
+ colors = v;
2621
+ angle = 90;
2622
+ } else {
2623
+ colors = v.colors;
2624
+ angle = v.angle || 90;
2625
+ }
2626
+ c.backgroundImage = `linear-gradient(${angle}deg, ${colors.join(", ")})`;
2627
+ c.WebkitBackgroundClip = "text";
2628
+ c.backgroundClip = "text";
2629
+ c.WebkitTextFillColor = "transparent";
2630
+ c.color = "transparent";
2631
+ c.display = "inline-block";
2632
+ },
2633
+ meshGradient: (v, c) => {
2634
+ const [c1, c2, c3, c4] = Array.isArray(v) ? v : [v[0], v[1], v[2], v[3]];
2635
+ c.backgroundColor = c1;
2636
+ c.backgroundImage = `radial-gradient(at 0% 0%, ${c2} 0px, transparent 50%), radial-gradient(at 100% 0%, ${c3} 0px, transparent 50%), radial-gradient(at 100% 100%, ${c4} 0px, transparent 50%)`;
2637
+ },
2638
+ noise: (v, c) => {
2639
+ const op = typeof v === "number" ? v : 0.05;
2640
+ c.backgroundImage = `url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='${op}'/%3E%3C/svg%3E")`;
2641
+ },
2642
+ // --- Logic & Responsive ---
2643
+ skeleton: (v, c) => {
2644
+ let active;
2645
+ let baseColor;
2646
+ let highlightColor;
2647
+ if (typeof v === "boolean") {
2648
+ active = v;
2649
+ baseColor = "rgba(0,0,0,0.1)";
2650
+ highlightColor = "rgba(0,0,0,0.05)";
2651
+ } else {
2652
+ active = v.active;
2653
+ baseColor = v.color || "rgba(0,0,0,0.1)";
2654
+ highlightColor = v.highlight || "rgba(0,0,0,0.05)";
2655
+ }
2656
+ if (!active) return;
2657
+ c.backgroundColor = baseColor;
2658
+ c.backgroundImage = `linear-gradient(90deg, ${baseColor} 25%, ${highlightColor} 50%, ${baseColor} 75%)`;
2659
+ c.backgroundSize = "200% 100%";
2660
+ c.animation = "skeleton-loading 1.5s infinite linear";
2661
+ if (!c.atRules) c.atRules = [];
2662
+ c.atRules.push({
2663
+ type: "keyframes",
2664
+ name: "skeleton-loading",
2665
+ steps: {
2666
+ "0%": { backgroundPosition: "200% 0" },
2667
+ "100%": { backgroundPosition: "-200% 0" }
2668
+ }
2669
+ });
2670
+ },
2671
+ fluidText: (v, c) => {
2672
+ const min = typeof v.min === "number" ? `${v.min}px` : v.min;
2673
+ const max = typeof v.max === "number" ? `${v.max}px` : v.max;
2674
+ c.fontSize = `clamp(${min}, ${v.vw || "4vw"}, ${max})`;
2675
+ },
2676
+ safeArea: (v, c) => {
2677
+ const edges = Array.isArray(v) ? v : [v || "all"];
2678
+ const map = {
2679
+ top: "Top",
2680
+ bottom: "Bottom",
2681
+ left: "Left",
2682
+ right: "Right"
2683
+ };
2684
+ edges.forEach((e) => {
2685
+ if (e === "all") {
2686
+ Object.keys(map).forEach((k) => {
2687
+ c[`padding${map[k]}`] = `env(safe-area-inset-${k})`;
2688
+ });
2689
+ } else if (map[e]) {
2690
+ c[`padding${map[e]}`] = `env(safe-area-inset-${e})`;
2691
+ }
2692
+ });
2693
+ },
2694
+ // --- Nested Rules & Interactions ---
2695
+ clickScale: (v, c) => {
2696
+ const s = typeof v === "number" ? v : 0.95;
2697
+ if (!c.nestedRules) c.nestedRules = [];
2698
+ c.nestedRules.push({
2699
+ selector: "&:active",
2700
+ styles: {
2701
+ transform: `scale(${s})`,
2702
+ transition: "transform 0.1s cubic-bezier(0.4, 0, 0.2, 1)"
2703
+ }
2704
+ });
2705
+ },
2706
+ onInteracting: (v, c, useTokens) => {
2707
+ const res = getSubStyles(v, useTokens);
2708
+ if (!c.nestedRules) c.nestedRules = [];
2709
+ ["&:hover", "&:focus-visible", "&:active"].forEach(
2710
+ (s) => c.nestedRules.push({ selector: s, styles: res })
2711
+ );
2712
+ },
2713
+ children: (v, c, useTokens) => {
2714
+ const res = getSubStyles(v, useTokens);
2715
+ if (!c.nestedRules) c.nestedRules = [];
2716
+ c.nestedRules.push({ selector: "& > *", styles: res });
2717
+ },
2718
+ dark: (v, c, useTokens) => handleTheme(v, c, "dark", useTokens),
2719
+ light: (v, c, useTokens) => handleTheme(v, c, "light", useTokens),
2720
+ // --- Utility Macros ---
2721
+ pill: (v, c) => {
2722
+ c.borderRadius = "9999px";
2723
+ c.padding = "8px 20px";
2724
+ c.display = "inline-flex";
2725
+ c.alignItems = "center";
2726
+ c.whiteSpace = "nowrap";
2727
+ },
2728
+ containerMacro: (v, c) => {
2729
+ c.width = "100%";
2730
+ c.maxWidth = typeof v === "number" ? `${v}px` : v || "1200px";
2731
+ macros.mx("auto", c, false);
2732
+ macros.px("20px", c, false);
2733
+ },
2734
+ fullScreen: (v, c) => {
2735
+ c.position = "fixed";
2736
+ c.top = 0;
2737
+ c.right = 0;
2738
+ c.bottom = 0;
2739
+ c.left = 0;
2740
+ c.zIndex = typeof v === "number" ? v : 9999;
2741
+ },
2742
+ shimmer: (v, c) => {
2743
+ c.backgroundImage = "linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent)";
2744
+ c.backgroundSize = "200% 100%";
2745
+ c.animation = "shimmer 2s infinite linear";
2746
+ if (!c.atRules) c.atRules = [];
2747
+ c.atRules.push({
2748
+ type: "keyframes",
2749
+ name: "shimmer",
2750
+ steps: {
2751
+ "0%": { backgroundPosition: "-200% 0" },
2752
+ "100%": { backgroundPosition: "200% 0" }
2753
+ }
2754
+ });
2755
+ },
2756
+ bento: (v, c, useTokens) => {
2757
+ c.display = "grid";
2758
+ if (typeof v === "number") {
2759
+ c.gridTemplateColumns = `repeat(${v}, minmax(0, 1fr))`;
2760
+ c.gap = "16px";
2761
+ } else if (typeof v === "object") {
2762
+ c.gridTemplateColumns = `repeat(${v.cols || 4}, minmax(0, 1fr))`;
2763
+ c.gap = typeof v.gap === "number" ? `${v.gap}px` : v.gap || "16px";
2764
+ }
2765
+ if (!c.nestedRules) c.nestedRules = [];
2766
+ const childStyles = typeof v?.children === "function" ? getSubStyles(v.children, useTokens) : {
2767
+ borderRadius: "12px",
2768
+ padding: "20px",
2769
+ backgroundColor: "rgba(255,255,255,0.05)"
2770
+ };
2771
+ c.nestedRules.push({
2772
+ selector: "& > *",
2773
+ styles: childStyles
2774
+ });
2775
+ },
2776
+ pressable: (v, c, useTokens) => {
2777
+ c.cursor = "pointer";
2778
+ macros.unselectable(v, c, useTokens);
2779
+ macros.clickScale(v, c, useTokens);
2780
+ if (!c.nestedRules) c.nestedRules = [];
2781
+ c.nestedRules.push({
2782
+ selector: "&:hover",
2783
+ styles: { opacity: 0.8 }
2784
+ });
2785
+ },
2786
+ focusRing: (v, c, useTokens) => {
2787
+ const ringColor = typeof v === "string" ? v : "#3b82f6";
2788
+ if (!c.nestedRules) c.nestedRules = [];
2789
+ c.nestedRules.push({
2790
+ selector: "&:focus-visible",
2791
+ styles: {
2792
+ outline: `2px solid ${ringColor}`,
2793
+ outlineOffset: "2px"
2794
+ }
2795
+ });
2796
+ },
2797
+ outlineDebug: (v, c) => {
2798
+ c.border = "1px solid red";
2799
+ if (!c.nestedRules) c.nestedRules = [];
2800
+ c.nestedRules.push({
2801
+ selector: "& > *",
2802
+ styles: { outline: "1px solid rgba(0,255,0,0.5)" }
2803
+ });
2804
+ },
2805
+ parallax: (v, c) => {
2806
+ c.transformStyle = "preserve-3d";
2807
+ c.perspective = "1px";
2808
+ c.height = "100vh";
2809
+ c.overflowX = "hidden";
2810
+ c.overflowY = "auto";
2811
+ if (!c.nestedRules) c.nestedRules = [];
2812
+ const scale = typeof v === "number" ? v : 2;
2813
+ c.nestedRules.push({
2814
+ selector: "& > *",
2815
+ styles: { transform: `translateZ(-1px) scale(${scale})` }
2816
+ });
2817
+ },
2818
+ lineClamp: (v, c) => {
2819
+ const lines = typeof v === "number" ? v : 3;
2820
+ c.display = "-webkit-box";
2821
+ c.WebkitLineClamp = lines;
2822
+ c.WebkitBoxOrient = "vertical";
2823
+ c.overflow = "hidden";
2824
+ },
2825
+ frostedNav: (v, c, useTokens) => {
2826
+ macros.fixed({ top: 0, left: 0 }, c, useTokens);
2827
+ c.width = "100%";
2828
+ macros.glass(v || 15, c, useTokens);
2829
+ macros.safeArea("top", c, useTokens);
2830
+ c.zIndex = 1e3;
2831
+ }
2832
+ };
2833
+ function handlePosition(type, v, c) {
2834
+ c.position = type;
2835
+ if (v && typeof v === "object") {
2836
+ if (v.top !== void 0) c.top = v.top;
2837
+ if (v.right !== void 0) c.right = v.right;
2838
+ if (v.bottom !== void 0) c.bottom = v.bottom;
2839
+ if (v.left !== void 0) c.left = v.left;
2840
+ } else if (v !== void 0 && typeof v !== "boolean") {
2841
+ c.top = v;
2842
+ c.right = v;
2843
+ c.bottom = v;
2844
+ c.left = v;
2845
+ }
2846
+ }
2847
+ function getSubStyles(callback, useTokens) {
2848
+ const sub = createChain(useTokens);
2849
+ callback(sub);
2850
+ const result = sub.$el();
2851
+ const { selectors, atRules, nestedRules, ...pure } = result;
2852
+ return pure;
2853
+ }
2854
+ function handleTheme(cb, c, mode, useTokens) {
2855
+ if (!c.atRules) c.atRules = [];
2856
+ c.atRules.push({
2857
+ type: "media",
2858
+ query: `(prefers-color-scheme: ${mode})`,
2859
+ styles: getSubStyles(cb, useTokens)
2860
+ });
2861
+ }
2862
+ function handleShorthand(prop, value, catcher, useTokens = true) {
2863
+ if (macros[prop]) {
2864
+ macros[prop](value, catcher, useTokens);
2865
+ return true;
2866
+ }
2867
+ if (["scale", "rotate", "skew"].includes(prop)) {
2868
+ if (!catcher._transforms) catcher._transforms = {};
2869
+ catcher._transforms[prop] = value;
2870
+ return true;
2871
+ }
2872
+ if (prop === "x") {
2873
+ if (!catcher._transforms) catcher._transforms = {};
2874
+ catcher._transforms.translateX = value;
2875
+ return true;
2876
+ }
2877
+ if (prop === "y") {
2878
+ if (!catcher._transforms) catcher._transforms = {};
2879
+ catcher._transforms.translateY = value;
2880
+ return true;
2881
+ }
2882
+ return false;
2883
+ }
2884
+
2885
+ // src/core/common-utils.ts
2886
+ function kebabCase(str) {
2887
+ return str.replace(/([A-Z])/g, "-$1").toLowerCase();
2888
+ }
2889
+ function resolveToken2(value, tokenStore = {}, debug = false) {
2890
+ if (typeof value !== "string" || !value.includes("$")) return value;
2891
+ return value.replace(/\$([a-zA-Z0-9.-]+)/g, (match, pathStr) => {
2892
+ const parts = pathStr.split(".");
2893
+ let current = tokenStore;
2894
+ if (current && typeof current.get === "function") {
2895
+ const resolved = current.get(pathStr);
2896
+ if (resolved !== void 0 && resolved !== null) {
2897
+ if (debug) {
2898
+ console.log(`\u2728 Resolved ${match} to ${resolved}`);
2899
+ }
2900
+ return String(resolved);
2901
+ }
2902
+ }
2903
+ for (const part of parts) {
2904
+ if (current && current[part] !== void 0) {
2905
+ current = current[part];
2906
+ } else {
2907
+ if (debug) {
2908
+ console.warn(`\u26A0\uFE0F Token not found: ${match}`);
2909
+ }
2910
+ return match;
2911
+ }
2912
+ }
2913
+ if (typeof current === "string" || typeof current === "number") {
2914
+ if (debug) {
2915
+ console.log(`\u2728 Resolved ${match} to ${current}`);
2916
+ }
2917
+ return String(current);
2918
+ }
2919
+ return match;
2920
+ });
2921
+ }
2922
+ function processStyleObject(obj, tokenStore = {}, options = {}) {
2923
+ const { useTokens = true, debug = false } = options;
2924
+ let css = "";
2925
+ const expandedProps = {};
2926
+ if (debug) {
2927
+ console.log("[ChainCSS] Processing style object:", obj);
2928
+ if (tokenStore && typeof tokenStore === "object") {
2929
+ const tokenKeys = Object.keys(tokenStore);
2930
+ if (tokenKeys.length > 0) {
2931
+ console.log("[ChainCSS] Token store available:", tokenKeys);
2932
+ }
2933
+ }
2934
+ }
2935
+ for (let [key, value] of Object.entries(obj)) {
2936
+ if (key.startsWith("_")) continue;
2937
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
2938
+ continue;
2939
+ }
2940
+ if (macros && macros[key]) {
2941
+ try {
2942
+ macros[key](value, expandedProps, useTokens);
2943
+ } catch (error) {
2944
+ console.warn(`[ChainCSS] Error applying macro "${key}":`, error);
2945
+ }
2946
+ } else {
2947
+ const realKey = shorthandMap[key] || key;
2948
+ expandedProps[realKey] = value;
2949
+ }
2950
+ }
2951
+ if (debug) {
2952
+ console.log("[ChainCSS] Expanded properties:", expandedProps);
2953
+ }
2954
+ const unitlessProps = [
2955
+ "opacity",
2956
+ "zIndex",
2957
+ "fontWeight",
2958
+ "flex",
2959
+ "flexGrow",
2960
+ "flexShrink",
2961
+ "order",
2962
+ "gridColumn",
2963
+ "gridRow",
2964
+ "animationIterationCount",
2965
+ "lineHeight"
2966
+ ];
2967
+ for (let [key, value] of Object.entries(expandedProps)) {
2968
+ if (debug) {
2969
+ console.log(`[ChainCSS] Processing property: ${key} = ${value}`);
2970
+ }
2971
+ let finalValue = value;
2972
+ if (useTokens && typeof value === "string") {
2973
+ finalValue = resolveToken2(value, tokenStore, debug);
2974
+ }
2975
+ const kebabKey = kebabCase(key);
2976
+ let unit = "";
2977
+ if (typeof value === "number" && !unitlessProps.includes(key)) {
2978
+ unit = "px";
2979
+ }
2980
+ css += ` ${kebabKey}: ${finalValue}${unit};
2981
+ `;
2982
+ }
2983
+ return css;
2984
+ }
2985
+
1
2986
  // src/runtime/injector.ts
2987
+ var TOKEN_V2_KEY = "__CHAINCSS_V2_TOKENS__";
2
2988
  var StyleInjector = class {
3
2989
  styleElement = null;
4
- stylesCache = /* @__PURE__ */ new Map();
5
- injectedStyles = /* @__PURE__ */ new Set();
2990
+ injectedHashes = /* @__PURE__ */ new Set();
2991
+ moduleMap = /* @__PURE__ */ new Map();
2992
+ debugMode = false;
2993
+ get tokenStore() {
2994
+ if (typeof window === "undefined") {
2995
+ return this._internalFallbackStore || {};
2996
+ }
2997
+ if (!window[TOKEN_V2_KEY]) {
2998
+ Object.defineProperty(window, TOKEN_V2_KEY, {
2999
+ value: {},
3000
+ writable: true,
3001
+ enumerable: false,
3002
+ configurable: true
3003
+ });
3004
+ }
3005
+ return window[TOKEN_V2_KEY];
3006
+ }
6
3007
  constructor() {
7
- this.initStyleElement();
3008
+ if (typeof document !== "undefined") {
3009
+ const existing = document.getElementById("chaincss-runtime-styles");
3010
+ if (existing) {
3011
+ this.styleElement = existing;
3012
+ } else {
3013
+ const style = document.createElement("style");
3014
+ style.id = "chaincss-runtime-styles";
3015
+ style.setAttribute("data-chaincss", "runtime");
3016
+ document.head.appendChild(style);
3017
+ this.styleElement = style;
3018
+ }
3019
+ }
8
3020
  }
9
- initStyleElement() {
10
- if (typeof document === "undefined")
11
- return;
12
- const existing = document.getElementById("chaincss-runtime-styles");
13
- if (existing) {
14
- this.styleElement = existing;
15
- return;
3021
+ /**
3022
+ * Enable debug logging
3023
+ */
3024
+ enableDebug(enable = true) {
3025
+ this.debugMode = enable;
3026
+ }
3027
+ /**
3028
+ * Set global tokens (e.g., brand colors, spacing scales)
3029
+ */
3030
+ setTokens(tokens2) {
3031
+ if (this.debugMode) {
3032
+ console.log("[ChainCSS] Tokens set:", Object.keys(tokens2));
3033
+ }
3034
+ Object.assign(this.tokenStore, tokens2);
3035
+ }
3036
+ /**
3037
+ * Get a token value by path
3038
+ */
3039
+ getToken(path) {
3040
+ const parts = path.split(".");
3041
+ let current = this.tokenStore;
3042
+ for (const part of parts) {
3043
+ if (current && current[part] !== void 0) {
3044
+ current = current[part];
3045
+ } else {
3046
+ return void 0;
3047
+ }
16
3048
  }
17
- const style = document.createElement("style");
18
- style.id = "chaincss-runtime-styles";
19
- style.setAttribute("data-chaincss", "runtime");
20
- document.head.appendChild(style);
21
- this.styleElement = style;
3049
+ return current;
22
3050
  }
23
- generateClassName(styleId) {
24
- let hash = 0;
25
- for (let i = 0; i < styleId.length; i++) {
26
- hash = (hash << 5) - hash + styleId.charCodeAt(i);
27
- hash |= 0;
3051
+ /**
3052
+ * Resolves $variables within a string using the tokenStore
3053
+ */
3054
+ resolveToken(value) {
3055
+ if (typeof value !== "string") return value;
3056
+ if (value.startsWith("$")) {
3057
+ const tokenValue = this.getToken(value.slice(1));
3058
+ return tokenValue !== void 0 ? tokenValue : value;
28
3059
  }
29
- return `c_${Math.abs(hash).toString(36)}`;
3060
+ return value.replace(/\$([a-zA-Z0-9.-]+)/g, (match, path) => {
3061
+ const tokenValue = this.getToken(path);
3062
+ return tokenValue !== void 0 ? String(tokenValue) : match;
3063
+ });
30
3064
  }
31
3065
  generateCSS(style, className) {
32
3066
  let css = "";
33
3067
  const selector = `.${className}`;
34
- let normalStyles = "";
35
- for (const [key, value] of Object.entries(style)) {
36
- if (key === "selectors" || key === "hover")
37
- continue;
38
- const kebabKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
39
- normalStyles += ` ${kebabKey}: ${value};
3068
+ const mainBody = processStyleObject(style, this.tokenStore, { useTokens: true, debug: false });
3069
+ if (mainBody && Object.keys(mainBody).length > 0) {
3070
+ let rules = "";
3071
+ for (const [prop, val] of Object.entries(mainBody)) {
3072
+ rules += ` ${prop}: ${val};
40
3073
  `;
41
- }
42
- if (normalStyles) {
3074
+ }
43
3075
  css += `${selector} {
44
- ${normalStyles}}
3076
+ ${rules}}
45
3077
  `;
46
3078
  }
47
- if (style.hover && typeof style.hover === "object") {
48
- let hoverStyles = "";
49
- for (const [key, value] of Object.entries(style.hover)) {
50
- const kebabKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
51
- hoverStyles += ` ${kebabKey}: ${value};
3079
+ if (style.hover) {
3080
+ const hoverBody = processStyleObject(style.hover, this.tokenStore, { useTokens: true, debug: false });
3081
+ if (hoverBody && Object.keys(hoverBody).length > 0) {
3082
+ let rules = "";
3083
+ for (const [prop, val] of Object.entries(hoverBody)) {
3084
+ rules += ` ${prop}: ${val};
52
3085
  `;
53
- }
54
- if (hoverStyles) {
3086
+ }
55
3087
  css += `${selector}:hover {
56
- ${hoverStyles}}
3088
+ ${rules}}
57
3089
  `;
58
3090
  }
59
3091
  }
60
3092
  return css;
61
3093
  }
62
- inject(styleId, style) {
63
- if (this.stylesCache.has(styleId)) {
64
- return this.stylesCache.get(styleId);
65
- }
66
- const className = this.generateClassName(styleId);
67
- const css = this.generateCSS(style, className);
68
- this.stylesCache.set(styleId, className);
69
- if (!this.injectedStyles.has(styleId) && this.styleElement && css) {
70
- this.styleElement.textContent += css;
71
- this.injectedStyles.add(styleId);
72
- }
73
- return className;
74
- }
75
- injectMultiple(styles) {
3094
+ injectMultiple(styles3, moduleId) {
76
3095
  const result = {};
77
- let allCSS = "";
78
- for (const [styleId, style] of Object.entries(styles)) {
79
- if (this.stylesCache.has(styleId)) {
80
- result[styleId] = this.stylesCache.get(styleId);
81
- continue;
3096
+ let newCSS = "";
3097
+ const moduleClasses = /* @__PURE__ */ new Set();
3098
+ for (const [name, style] of Object.entries(styles3)) {
3099
+ const className = name;
3100
+ result[name] = className;
3101
+ if (!this.injectedHashes.has(className)) {
3102
+ const generatedCSS = this.generateCSS(style, className);
3103
+ if (generatedCSS) {
3104
+ newCSS += generatedCSS;
3105
+ this.injectedHashes.add(className);
3106
+ }
82
3107
  }
83
- const className = this.generateClassName(styleId);
84
- const css = this.generateCSS(style, className);
85
- this.stylesCache.set(styleId, className);
86
- result[styleId] = className;
87
- allCSS += css;
3108
+ moduleClasses.add(className);
3109
+ }
3110
+ if (moduleId && moduleClasses.size > 0) {
3111
+ this.moduleMap.set(moduleId, moduleClasses);
88
3112
  }
89
- if (allCSS && this.styleElement) {
90
- this.styleElement.textContent += allCSS;
3113
+ if (newCSS) {
3114
+ this.writeToDOM(newCSS);
3115
+ if (this.debugMode) {
3116
+ console.log(`[ChainCSS] Injected ${newCSS.length} bytes of CSS (${moduleId || "anonymous"})`);
3117
+ }
91
3118
  }
92
3119
  return result;
93
3120
  }
94
- update(styleId, style) {
95
- this.injectedStyles.delete(styleId);
96
- const className = this.generateClassName(styleId);
97
- const css = this.generateCSS(style, className);
98
- this.stylesCache.set(styleId, className);
99
- if (this.styleElement) {
100
- let allCSS = "";
101
- for (const [id, className2] of this.stylesCache) {
3121
+ writeToDOM(css) {
3122
+ if (css && this.styleElement) {
3123
+ this.styleElement.textContent += css;
3124
+ }
3125
+ }
3126
+ removeModule(moduleId) {
3127
+ const classes = this.moduleMap.get(moduleId);
3128
+ if (!classes || !this.styleElement?.sheet) return;
3129
+ const sheet = this.styleElement.sheet;
3130
+ let removedCount = 0;
3131
+ for (let i = sheet.cssRules.length - 1; i >= 0; i--) {
3132
+ const rule = sheet.cssRules[i];
3133
+ if (rule.selectorText) {
3134
+ const match = rule.selectorText.match(/\.([a-zA-Z0-9_-]+)/);
3135
+ if (match && classes.has(match[1])) {
3136
+ sheet.deleteRule(i);
3137
+ this.injectedHashes.delete(match[1]);
3138
+ removedCount++;
3139
+ }
102
3140
  }
103
- this.styleElement.textContent = allCSS;
104
- this.injectedStyles.add(styleId);
105
3141
  }
106
- return className;
3142
+ this.moduleMap.delete(moduleId);
3143
+ if (this.debugMode) {
3144
+ console.log(`[ChainCSS] Removed ${removedCount} rules for module ${moduleId}`);
3145
+ }
107
3146
  }
108
- remove(styleId) {
109
- this.injectedStyles.delete(styleId);
110
- this.stylesCache.delete(styleId);
3147
+ removeAll() {
111
3148
  if (this.styleElement) {
112
- let allCSS = "";
113
- for (const [id, className] of this.stylesCache) {
3149
+ this.styleElement.textContent = "";
3150
+ this.injectedHashes.clear();
3151
+ this.moduleMap.clear();
3152
+ if (this.debugMode) {
3153
+ console.log("[ChainCSS] All runtime styles removed");
114
3154
  }
115
- this.styleElement.textContent = allCSS;
116
3155
  }
117
3156
  }
118
3157
  getStyleElement() {
119
3158
  return this.styleElement;
120
3159
  }
121
- clear() {
122
- this.stylesCache.clear();
123
- this.injectedStyles.clear();
124
- if (this.styleElement) {
125
- this.styleElement.textContent = "";
126
- }
3160
+ getStats() {
3161
+ return {
3162
+ injectedStyles: this.injectedHashes.size,
3163
+ modules: this.moduleMap.size
3164
+ };
127
3165
  }
128
3166
  };
129
3167
  var styleInjector = new StyleInjector();
130
- function chainRuntime(useTokens = false) {
131
- const catcher = {};
132
- const handler = {
133
- get: (target, prop) => {
134
- if (prop === "$el") {
135
- return (...selectors) => {
136
- if (selectors.length === 0) {
137
- const result2 = { ...catcher };
138
- Object.keys(catcher).forEach((key) => delete catcher[key]);
139
- return result2;
140
- }
141
- const result = {
142
- selectors,
143
- ...catcher
144
- };
145
- Object.keys(catcher).forEach((key) => delete catcher[key]);
146
- return result;
147
- };
148
- }
149
- if (prop === "hover") {
150
- return () => {
151
- const hoverCatcher = {};
152
- const hoverHandler = {
153
- get: (_, hoverProp) => {
154
- if (hoverProp === "end") {
155
- return () => {
156
- catcher.hover = { ...hoverCatcher };
157
- Object.keys(hoverCatcher).forEach((key) => delete hoverCatcher[key]);
158
- return proxy;
159
- };
160
- }
161
- return (value) => {
162
- hoverCatcher[hoverProp] = value;
163
- return hoverProxy;
164
- };
165
- }
166
- };
167
- const hoverProxy = new Proxy({}, hoverHandler);
168
- return hoverProxy;
169
- };
170
- }
171
- if (prop === "end") {
172
- return () => proxy;
173
- }
174
- return (value) => {
175
- catcher[prop] = value;
176
- return proxy;
177
- };
178
- }
179
- };
180
- const proxy = new Proxy({}, handler);
181
- return proxy;
182
- }
183
- var $ = chainRuntime();
184
- function compileRuntime(styles) {
185
- return styleInjector.injectMultiple(styles);
186
- }
187
- function runRuntime(...styles) {
3168
+ var setTokens = (t) => styleInjector.setTokens(t);
3169
+ var compileRuntime = (s, moduleId) => styleInjector.injectMultiple(s, moduleId);
3170
+ var removeRuntimeModule = (moduleId) => styleInjector.removeModule(moduleId);
3171
+ function runRuntime(...styles3) {
188
3172
  let css = "";
189
- for (const style of styles) {
190
- if (style.selectors) {
191
- let normalStyles = "";
192
- let hoverStyles = "";
193
- for (const [key, value] of Object.entries(style)) {
194
- if (key === "selectors")
195
- continue;
196
- if (key === "hover" && typeof value === "object") {
197
- hoverStyles = `${style.selectors.join(", ")}:hover {
3173
+ for (const style of styles3) {
3174
+ if (style.selectors && style.selectors.length > 0) {
3175
+ const combinedSelector = style.selectors.join(", ");
3176
+ const mainBody = processStyleObject(style, styleInjector["tokenStore"], { useTokens: true, debug: false });
3177
+ if (mainBody && Object.keys(mainBody).length > 0) {
3178
+ let rules = "";
3179
+ for (const [prop, val] of Object.entries(mainBody)) {
3180
+ rules += ` ${prop}: ${val};
198
3181
  `;
199
- for (const [hoverKey, hoverValue] of Object.entries(value)) {
200
- const kebabKey = hoverKey.replace(/([A-Z])/g, "-$1").toLowerCase();
201
- hoverStyles += ` ${kebabKey}: ${hoverValue};
3182
+ }
3183
+ css += `${combinedSelector} {
3184
+ ${rules}}
202
3185
  `;
203
- }
204
- hoverStyles += `}
3186
+ }
3187
+ if (style.hover) {
3188
+ const hoverBody = processStyleObject(style.hover, styleInjector["tokenStore"], { useTokens: true, debug: false });
3189
+ if (hoverBody && Object.keys(hoverBody).length > 0) {
3190
+ let rules = "";
3191
+ for (const [prop, val] of Object.entries(hoverBody)) {
3192
+ rules += ` ${prop}: ${val};
205
3193
  `;
206
- } else {
207
- const kebabKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
208
- normalStyles += ` ${kebabKey}: ${value};
3194
+ }
3195
+ css += `${combinedSelector}:hover {
3196
+ ${rules}}
209
3197
  `;
210
3198
  }
211
3199
  }
212
- if (normalStyles) {
213
- css += `${style.selectors.join(", ")} {
214
- ${normalStyles}}
215
- `;
216
- }
217
- if (hoverStyles) {
218
- css += hoverStyles;
219
- }
220
3200
  }
221
3201
  }
222
- if (css && styleInjector.getStyleElement()) {
223
- styleInjector.getStyleElement().textContent += css;
224
- }
3202
+ styleInjector.writeToDOM(css);
225
3203
  return css;
226
3204
  }
227
3205
 
3206
+ // src/runtime/Chain.ts
3207
+ var debugMode2 = false;
3208
+ var runtimeMacros = { ...macros };
3209
+ var globalManifest = {};
3210
+ var setManifest = (manifest) => {
3211
+ if (manifest.atomicMap) {
3212
+ globalManifest = manifest.atomicMap;
3213
+ } else if (manifest.atomicClasses) {
3214
+ globalManifest = manifest.atomicClasses;
3215
+ } else {
3216
+ globalManifest = manifest || {};
3217
+ }
3218
+ if (debugMode2) {
3219
+ console.log("[ChainCSS] Manifest loaded with", Object.keys(globalManifest).length, "entries");
3220
+ }
3221
+ };
3222
+ var RuntimeChain = class _RuntimeChain {
3223
+ constructor(useTokens = false) {
3224
+ this.useTokens = useTokens;
3225
+ const PUBLIC_METHODS2 = /* @__PURE__ */ new Set([
3226
+ "use",
3227
+ "hover",
3228
+ "$el",
3229
+ "$name",
3230
+ "end",
3231
+ "getCatcher"
3232
+ ]);
3233
+ this.proxy = new Proxy(this, {
3234
+ /**
3235
+ * 1. TRAPS FOR EXTERNAL TOOLS (React, DevTools, JSON.stringify)
3236
+ * This prevents the "cyclic object value" error.
3237
+ */
3238
+ get: (target, prop) => {
3239
+ if (prop === "toJSON") return () => target.catcher;
3240
+ if (prop === "constructor") return _RuntimeChain;
3241
+ if (prop === Symbol.toStringTag) return "RuntimeChain";
3242
+ if (prop === "_isChain") return true;
3243
+ if (typeof prop !== "string") return target[prop];
3244
+ if (prop in target && PUBLIC_METHODS2.has(prop)) {
3245
+ const val = target[prop];
3246
+ return typeof val === "function" ? val.bind(target) : val;
3247
+ }
3248
+ if (prop in target && typeof target[prop] === "function") {
3249
+ if (debugMode2) {
3250
+ console.warn(`[ChainCSS] '${prop}' is an internal method, not part of the public API`);
3251
+ }
3252
+ return void 0;
3253
+ }
3254
+ const realProp = shorthandMap[prop] || prop;
3255
+ if (runtimeMacros[prop]) {
3256
+ return (val) => {
3257
+ runtimeMacros[prop](val, target.catcher, target.useTokens);
3258
+ return target.proxy;
3259
+ };
3260
+ }
3261
+ return (val) => {
3262
+ let finalVal = val;
3263
+ let valueWithUnit = val;
3264
+ const unitless = ["opacity", "zIndex", "flex", "fontWeight", "flexGrow", "flexShrink", "flexBasis", "order", "lineHeight", "animationIterationCount", "orphans", "widows", "columnCount"];
3265
+ if (typeof finalVal === "number" && !unitless.includes(realProp)) {
3266
+ valueWithUnit = `${val}px`;
3267
+ finalVal = valueWithUnit;
3268
+ }
3269
+ const lookupKey = `${realProp}:${valueWithUnit}`;
3270
+ const staticClass = globalManifest[lookupKey];
3271
+ if (staticClass) {
3272
+ if (!target.catcher._classes.includes(staticClass)) {
3273
+ target.catcher._classes.push(staticClass);
3274
+ if (debugMode2) {
3275
+ console.log(`[ChainCSS] Using atomic class: ${staticClass} for ${lookupKey}`);
3276
+ }
3277
+ }
3278
+ } else {
3279
+ if (debugMode2) {
3280
+ console.log(`[ChainCSS] No atomic class for ${lookupKey}, will inject at runtime`);
3281
+ }
3282
+ target.catcher[realProp] = finalVal;
3283
+ }
3284
+ return target.proxy;
3285
+ };
3286
+ }
3287
+ });
3288
+ }
3289
+ useTokens;
3290
+ // catcher now tracks both raw styles and pre-baked class names
3291
+ catcher = { _classes: [] };
3292
+ componentName = "";
3293
+ proxy;
3294
+ use(plugin) {
3295
+ const { selectors, atRules, ...styles3 } = plugin;
3296
+ Object.entries(styles3).forEach(([key, val]) => {
3297
+ const realProp = shorthandMap[key] || key;
3298
+ this.catcher[realProp] = val;
3299
+ });
3300
+ return this.proxy;
3301
+ }
3302
+ hover() {
3303
+ const hoverCatcher = { _classes: [] };
3304
+ const hoverHandler = {
3305
+ get: (_, prop) => {
3306
+ if (prop === "end") {
3307
+ return () => {
3308
+ this.catcher.hover = { ...this.catcher.hover, ...hoverCatcher };
3309
+ return this.proxy;
3310
+ };
3311
+ }
3312
+ const realProp = shorthandMap[prop] || prop;
3313
+ return (val) => {
3314
+ const lookupKey = `hover:${realProp}:${val}`;
3315
+ const staticClass = globalManifest[lookupKey];
3316
+ if (staticClass) {
3317
+ if (!hoverCatcher._classes.includes(staticClass)) {
3318
+ hoverCatcher._classes.push(staticClass);
3319
+ }
3320
+ } else if (runtimeMacros[prop]) {
3321
+ runtimeMacros[prop](val, hoverCatcher, this.useTokens);
3322
+ } else {
3323
+ hoverCatcher[realProp] = val;
3324
+ }
3325
+ return hoverProxy;
3326
+ };
3327
+ }
3328
+ };
3329
+ const hoverProxy = new Proxy({}, hoverHandler);
3330
+ return hoverProxy;
3331
+ }
3332
+ /**
3333
+ * Set the component name for class generation
3334
+ */
3335
+ $name(name) {
3336
+ this.componentName = name;
3337
+ return this;
3338
+ }
3339
+ /**
3340
+ * Finalizes the chain. Returns the style object and resets the catcher.
3341
+ */
3342
+ $el(name) {
3343
+ const result = structuredClone(this.catcher);
3344
+ result._name = name || this.componentName || "element";
3345
+ delete result._componentName;
3346
+ delete result._generateComponent;
3347
+ delete result._framework;
3348
+ delete result._propsDefinition;
3349
+ this.catcher = { _classes: [] };
3350
+ this.componentName = "";
3351
+ return result;
3352
+ }
3353
+ end(name) {
3354
+ return this.$el(name);
3355
+ }
3356
+ /**
3357
+ * Get the current catcher (for debugging)
3358
+ */
3359
+ getCatcher() {
3360
+ return { ...this.catcher };
3361
+ }
3362
+ };
3363
+ var $ = () => new RuntimeChain(false).proxy;
3364
+ var $t = () => new RuntimeChain(true).proxy;
3365
+ var chain = (useTokens = false) => new RuntimeChain(useTokens).proxy;
3366
+
228
3367
  // src/runtime/react.tsx
229
- import React, { useMemo, useEffect, useRef, useState } from "react";
230
- import { jsx } from "react/jsx-runtime";
231
- var styleCache = /* @__PURE__ */ new Map();
232
- function useChainStyles(styles, deps = [], options = {}) {
233
- const { cache = true, namespace = "chain", watch: watch2 = false } = options;
234
- const id = useRef(`chain-${Math.random().toString(36).substr(2, 9)}`);
235
- const [classNames, setClassNames] = useState({});
236
- const processed = useMemo(() => {
237
- const resolvedStyles = typeof styles === "function" ? styles() : styles;
238
- if (!resolvedStyles || Object.keys(resolvedStyles).length === 0) {
239
- return { classNames: {}, css: "" };
240
- }
241
- const cacheKey = JSON.stringify(resolvedStyles);
242
- if (cache && styleCache.has(cacheKey)) {
243
- return { classNames: styleCache.get(cacheKey), css: "" };
244
- }
245
- const compiledStyles = {};
246
- const newClassNames = {};
247
- for (const [key, styleDef] of Object.entries(resolvedStyles)) {
248
- const className = `${namespace}-${key}-${id.current}`;
249
- const styleObj = typeof styleDef === "function" ? styleDef() : styleDef;
250
- newClassNames[key] = className;
251
- compiledStyles[`${key}_${id.current}`] = {
252
- selectors: [`.${className}`],
253
- ...styleObj
254
- };
255
- }
256
- const result = compileRuntime(compiledStyles);
257
- if (cache) {
258
- styleCache.set(cacheKey, result);
259
- }
260
- return { classNames: result, css: "" };
261
- }, [styles, namespace, id.current, ...deps]);
3368
+ import React, { useMemo, useRef, useState, useEffect } from "react";
3369
+ import { Fragment, jsx } from "react/jsx-runtime";
3370
+ function hashStyleObject(obj) {
3371
+ const str = JSON.stringify(obj);
3372
+ let hash = 0;
3373
+ for (let i = 0; i < str.length; i++) {
3374
+ const char = str.charCodeAt(i);
3375
+ hash = (hash << 5) - hash + char;
3376
+ hash = hash & hash;
3377
+ }
3378
+ return Math.abs(hash).toString(36);
3379
+ }
3380
+ function useChainStyles(styles3, deps = [], options = {}) {
3381
+ const { namespace = "c", debug = false, ssr = false } = options;
3382
+ const instanceId = useRef(Math.random().toString(36).substring(2, 7));
3383
+ const moduleId = useRef(`chaincss-module-${instanceId.current}`);
3384
+ const [forceUpdate, setForceUpdate] = useState(0);
262
3385
  useEffect(() => {
263
- setClassNames(processed.classNames);
264
3386
  return () => {
265
- if (!watch2) {
266
- for (const key of Object.keys(processed.classNames)) {
267
- styleInjector.remove(`${namespace}-${key}-${id.current}`);
3387
+ if (!ssr && moduleId.current) {
3388
+ removeRuntimeModule(moduleId.current);
3389
+ if (debug) {
3390
+ console.log(`[ChainCSS] Cleaned up module: ${moduleId.current}`);
268
3391
  }
269
3392
  }
270
3393
  };
271
- }, [processed.classNames, watch2]);
272
- return classNames;
3394
+ }, [ssr]);
3395
+ return useMemo(() => {
3396
+ const finalClassMap = {};
3397
+ const injectionBundle = {};
3398
+ for (const [key, styleDef] of Object.entries(styles3)) {
3399
+ let styleObject = {};
3400
+ if (styleDef && typeof styleDef.$el === "function") {
3401
+ styleObject = styleDef.$el();
3402
+ if (debug) {
3403
+ console.log(`[ChainCSS] Processing style: ${key}`, styleObject);
3404
+ }
3405
+ } else if (styleDef && typeof styleDef === "object") {
3406
+ styleObject = { ...styleDef };
3407
+ }
3408
+ const staticClasses = Array.isArray(styleObject._classes) ? styleObject._classes : [];
3409
+ const internalKeys = ["catcher", "proxy", "useTokens", "componentName", "_isChain", "_classes", "_name"];
3410
+ internalKeys.forEach((k) => delete styleObject[k]);
3411
+ const hash = hashStyleObject(styleObject);
3412
+ const dynamicClassName = `${namespace}-${key}-${hash}`;
3413
+ const hasStyles = Object.keys(styleObject).length > 0;
3414
+ if (!ssr && hasStyles) {
3415
+ injectionBundle[dynamicClassName] = styleObject;
3416
+ }
3417
+ const classParts = [...staticClasses];
3418
+ if (hasStyles) {
3419
+ classParts.push(dynamicClassName);
3420
+ }
3421
+ finalClassMap[key] = classParts.join(" ").trim();
3422
+ }
3423
+ if (!ssr && Object.keys(injectionBundle).length > 0) {
3424
+ compileRuntime(injectionBundle, moduleId.current);
3425
+ if (debug) {
3426
+ console.log(`[ChainCSS] Injected ${Object.keys(injectionBundle).length} styles for module ${moduleId.current}`);
3427
+ }
3428
+ }
3429
+ return finalClassMap;
3430
+ }, [forceUpdate, ...deps]);
273
3431
  }
274
3432
  function useDynamicChainStyles(styleFactory, deps = [], options) {
275
- const styles = useMemo(() => styleFactory(), deps);
276
- return useChainStyles(styles, deps, options);
3433
+ const styles3 = useMemo(() => styleFactory(), deps);
3434
+ return useChainStyles(styles3, deps, options);
277
3435
  }
278
- function useThemeChainStyles(styles, theme, options) {
3436
+ function useThemeChainStyles(styles3, theme, options) {
279
3437
  const themedStyles = useMemo(() => {
280
- if (typeof styles === "function")
281
- return styles(theme);
282
- return styles;
283
- }, [styles, theme]);
284
- return useChainStyles(themedStyles, [], options);
285
- }
286
- function ChainCSSGlobal({ styles }) {
287
- useChainStyles(styles, [], { watch: true });
288
- return null;
3438
+ if (typeof styles3 === "function") return styles3(theme);
3439
+ return styles3;
3440
+ }, [styles3, theme]);
3441
+ return useChainStyles(themedStyles, [theme], options);
289
3442
  }
290
- function cx(...classes) {
291
- return classes.filter(Boolean).join(" ");
292
- }
293
- var debugEnabled = false;
294
- function enableChainCSSDebug() {
295
- if (typeof window !== "undefined") {
296
- debugEnabled = true;
297
- window.__CHAINCSS_DEBUG__ = true;
298
- console.log("\u{1F50D} ChainCSS Debug Mode Enabled");
3443
+ function ChainCSSGlobal({ styles: styles3, tokens: tokens2, children }) {
3444
+ if (tokens2) {
3445
+ setTokens(tokens2);
299
3446
  }
300
- }
301
- function disableChainCSSDebug() {
302
- if (typeof window !== "undefined") {
303
- debugEnabled = false;
304
- window.__CHAINCSS_DEBUG__ = false;
305
- console.log("\u{1F50D} ChainCSS Debug Mode Disabled");
3447
+ if (styles3) {
3448
+ useChainStyles(styles3, [], { watch: true });
306
3449
  }
3450
+ return /* @__PURE__ */ jsx(Fragment, { children });
307
3451
  }
308
- function isDebugEnabled() {
309
- return debugEnabled || typeof window !== "undefined" && window.__CHAINCSS_DEBUG__;
3452
+ function cx(...classes) {
3453
+ const result = [];
3454
+ for (const cls of classes) {
3455
+ if (!cls) continue;
3456
+ if (typeof cls === "string") {
3457
+ result.push(cls);
3458
+ } else if (typeof cls === "object") {
3459
+ for (const [key, value] of Object.entries(cls)) {
3460
+ if (value) result.push(key);
3461
+ }
3462
+ }
3463
+ }
3464
+ return result.join(" ");
310
3465
  }
311
- function withChainStyles(styles, options) {
3466
+ function withChainStyles(styles3, options) {
312
3467
  return function WrappedComponent(props) {
313
- const classNames = useChainStyles(
314
- typeof styles === "function" ? styles(props) : styles,
315
- [],
316
- // ← Add empty deps array
317
- options
318
- );
3468
+ const styleProps = typeof styles3 === "function" ? styles3(props) : styles3;
3469
+ const classNames = useChainStyles(styleProps, [], options);
319
3470
  const Component = props.component || props.wrappedComponent;
320
3471
  return /* @__PURE__ */ jsx(Component, { ...props, chainStyles: classNames });
321
3472
  };
322
3473
  }
323
- function createStyledComponent(elementType, styles, options) {
3474
+ function createStyledComponent(elementType, styles3, options) {
324
3475
  const StyledComponent = (props) => {
325
3476
  const { className: additionalClassName, ...rest } = props;
326
- const classNames = useChainStyles(styles, [], options);
327
- const combinedClassName = [classNames.root, additionalClassName].filter(Boolean).join(" ");
3477
+ const styleDef = typeof styles3 === "function" ? styles3() : styles3;
3478
+ const classNames = useChainStyles({ root: styleDef }, [], options);
3479
+ const combinedClassName = cx(classNames.root, additionalClassName);
328
3480
  return React.createElement(elementType, {
329
3481
  ...rest,
330
3482
  className: combinedClassName
@@ -334,21 +3486,46 @@ function createStyledComponent(elementType, styles, options) {
334
3486
  StyledComponent.displayName = `ChainCSS.${displayName}`;
335
3487
  return StyledComponent;
336
3488
  }
337
- function useComputedStyles(styles, props, deps = [], options) {
338
- const computedStyles = useMemo(() => styles(props), [props, ...deps]);
3489
+ function useComputedStyles(styles3, props, deps = [], options) {
3490
+ const computedStyles = useMemo(() => styles3(props), [props, ...deps]);
339
3491
  return useChainStyles(computedStyles, deps, options);
340
3492
  }
3493
+ var debugEnabled = false;
3494
+ function enableChainCSSDebug() {
3495
+ debugEnabled = true;
3496
+ if (typeof window !== "undefined") {
3497
+ window.__CHAINCSS_DEBUG__ = true;
3498
+ console.log("\u{1F50D} ChainCSS Debug Mode Enabled");
3499
+ }
3500
+ }
3501
+ function disableChainCSSDebug() {
3502
+ debugEnabled = false;
3503
+ if (typeof window !== "undefined") {
3504
+ window.__CHAINCSS_DEBUG__ = false;
3505
+ console.log("\u{1F50D} ChainCSS Debug Mode Disabled");
3506
+ }
3507
+ }
3508
+ function isDebugEnabled() {
3509
+ return debugEnabled || typeof window !== "undefined" && window.__CHAINCSS_DEBUG__;
3510
+ }
341
3511
 
342
3512
  // src/runtime/vue.ts
343
- import { ref, computed, inject, provide, h } from "vue";
344
- var CHAIN_CSS_KEY = Symbol("chaincss");
345
- function useAtomicClasses(styles, options = {}) {
346
- const { atomic = true, global = false } = options;
347
- const id = `chain-${Math.random().toString(36).substr(2, 9)}`;
348
- const classes = computed(() => {
349
- const resolvedStyles = typeof styles === "function" ? styles() : styles?.value || styles;
350
- if (!resolvedStyles)
351
- return {};
3513
+ import { ref, computed, watch, onUnmounted, inject, provide, h } from "vue";
3514
+ var CHAIN_CSS_KEY = /* @__PURE__ */ Symbol("chaincss");
3515
+ function useAtomicClasses(styles3, options = {}) {
3516
+ const { atomic = true, global = false, debug = false } = options;
3517
+ const id = `chain-${Math.random().toString(36).substring(2, 11)}`;
3518
+ const moduleId = `chaincss-vue-module-${id}`;
3519
+ const classMap = ref({});
3520
+ onUnmounted(() => {
3521
+ removeRuntimeModule(moduleId);
3522
+ if (debug) {
3523
+ console.log(`[ChainCSS Vue] Cleaned up module: ${moduleId}`);
3524
+ }
3525
+ });
3526
+ const compileStyles = () => {
3527
+ const resolvedStyles = typeof styles3 === "function" ? styles3() : styles3?.value || styles3;
3528
+ if (!resolvedStyles) return {};
352
3529
  const compiledStyles = {};
353
3530
  const classNames = {};
354
3531
  for (const [key, styleDef] of Object.entries(resolvedStyles)) {
@@ -360,12 +3537,30 @@ function useAtomicClasses(styles, options = {}) {
360
3537
  ...styleObj
361
3538
  };
362
3539
  }
363
- return compileRuntime(compiledStyles);
364
- });
3540
+ const result = compileRuntime(compiledStyles, moduleId);
3541
+ if (debug) {
3542
+ console.log(`[ChainCSS Vue] Compiled ${Object.keys(classNames).length} styles for module ${moduleId}`);
3543
+ }
3544
+ classMap.value = classNames;
3545
+ return result;
3546
+ };
3547
+ if (typeof styles3 === "object" && styles3 !== null && "value" in styles3) {
3548
+ watch(styles3, () => {
3549
+ compileStyles();
3550
+ }, { deep: true });
3551
+ }
3552
+ compileStyles();
365
3553
  return {
366
- classes,
367
- cx: (name) => classes.value[name],
368
- cn: (...names) => names.map((name) => classes.value[name]).filter(Boolean).join(" ")
3554
+ classes: computed(() => classMap.value),
3555
+ cx: (name) => classMap.value[name] || "",
3556
+ cn: (...names) => names.map((name) => classMap.value[name]).filter(Boolean).join(" "),
3557
+ inject: (newStyles) => {
3558
+ const injectedId = `chaincss-injected-${Date.now()}`;
3559
+ compileRuntime(newStyles, injectedId);
3560
+ if (debug) {
3561
+ console.log(`[ChainCSS Vue] Injected additional styles: ${injectedId}`);
3562
+ }
3563
+ }
369
3564
  };
370
3565
  }
371
3566
  var ChainCSSGlobal2 = {
@@ -373,29 +3568,45 @@ var ChainCSSGlobal2 = {
373
3568
  props: {
374
3569
  styles: {
375
3570
  type: Object,
376
- required: true
3571
+ required: false,
3572
+ default: () => ({})
3573
+ },
3574
+ tokens: {
3575
+ type: Object,
3576
+ required: false,
3577
+ default: () => ({})
3578
+ },
3579
+ debug: {
3580
+ type: Boolean,
3581
+ default: false
377
3582
  }
378
3583
  },
379
3584
  setup(props) {
380
- useAtomicClasses(props.styles);
3585
+ if (props.tokens && Object.keys(props.tokens).length > 0) {
3586
+ styleInjector.setTokens(props.tokens);
3587
+ }
3588
+ if (props.styles && Object.keys(props.styles).length > 0) {
3589
+ useAtomicClasses(props.styles, { debug: props.debug });
3590
+ }
381
3591
  return () => null;
382
3592
  }
383
3593
  };
384
- function createStyledComponent2(styles, tag = "div") {
3594
+ function createStyledComponent2(styles3, tag = "div", options = {}) {
385
3595
  return {
386
3596
  name: "ChainCSSStyledComponent",
387
3597
  props: {
388
- className: { type: String, default: "" }
3598
+ className: { type: String, default: "" },
3599
+ as: { type: String, default: tag }
389
3600
  },
390
3601
  setup(props, { slots, attrs }) {
391
- const resolvedStyles = typeof styles === "function" ? styles() : styles;
392
- const { classes } = useAtomicClasses({ root: resolvedStyles });
3602
+ const resolvedStyles = typeof styles3 === "function" ? styles3() : styles3;
3603
+ const { classes } = useAtomicClasses({ root: resolvedStyles }, options);
393
3604
  const combinedClass = computed(() => {
394
3605
  const rootClass = classes.value?.root || "";
395
3606
  return [rootClass, props.className].filter(Boolean).join(" ");
396
3607
  });
397
3608
  return () => {
398
- return h(tag, {
3609
+ return h(props.as || tag, {
399
3610
  class: combinedClass.value,
400
3611
  ...attrs
401
3612
  }, slots.default?.());
@@ -403,17 +3614,17 @@ function createStyledComponent2(styles, tag = "div") {
403
3614
  }
404
3615
  };
405
3616
  }
406
- function createStyledComponents(components) {
3617
+ function createStyledComponents(components, options) {
407
3618
  const result = {};
408
3619
  for (const [name, config] of Object.entries(components)) {
409
- const { element = "div", styles } = config;
410
- result[name] = createStyledComponent2(styles, element);
3620
+ const { element = "div", styles: styles3 } = config;
3621
+ result[name] = createStyledComponent2(styles3, element, options);
411
3622
  }
412
3623
  return result;
413
3624
  }
414
- function useComputedStyles2(styles, props) {
415
- const computedStyles = computed(() => ({ root: styles(props) }));
416
- const { classes } = useAtomicClasses(computedStyles);
3625
+ function useComputedStyles2(styles3, props, options) {
3626
+ const computedStyles = computed(() => ({ root: styles3(props) }));
3627
+ const { classes } = useAtomicClasses(computedStyles, options);
417
3628
  return {
418
3629
  classes,
419
3630
  rootClass: computed(() => classes.value?.root || "")
@@ -428,25 +3639,149 @@ function injectStyleContext() {
428
3639
  return inject(CHAIN_CSS_KEY, ref({}));
429
3640
  }
430
3641
 
3642
+ // src/runtime/svelte.ts
3643
+ function useAtomicClasses2() {
3644
+ return { subscribe: () => {
3645
+ }, get: () => ({}) };
3646
+ }
3647
+ function cx2(...args) {
3648
+ return args.filter(Boolean).join(" ");
3649
+ }
3650
+ function ChainCSSGlobal3() {
3651
+ return null;
3652
+ }
3653
+ function createStyledComponent3() {
3654
+ return () => null;
3655
+ }
3656
+ function createStyledComponents2() {
3657
+ return {};
3658
+ }
3659
+ function useComputedStyles3() {
3660
+ return { subscribe: () => {
3661
+ }, get: () => "" };
3662
+ }
3663
+ function provideStyleContext2() {
3664
+ }
3665
+ function injectStyleContext2() {
3666
+ return {};
3667
+ }
3668
+ function chainStyles() {
3669
+ return {};
3670
+ }
3671
+
431
3672
  // src/runtime/hmr.ts
3673
+ function getHMREnvironment() {
3674
+ if (typeof window === "undefined") return "none";
3675
+ if (typeof import.meta !== "undefined" && import.meta.hot) {
3676
+ return "vite";
3677
+ }
3678
+ if (module.hot) {
3679
+ return "webpack";
3680
+ }
3681
+ return "none";
3682
+ }
432
3683
  function setupHMR() {
433
- if (typeof window === "undefined")
434
- return;
435
- if (import.meta.hot) {
436
- import.meta.hot.on("chaincss:update", (payload) => {
437
- console.log(`[HMR] Updating styles for ${payload.file}`);
438
- });
3684
+ const env = getHMREnvironment();
3685
+ if (env === "vite") {
3686
+ setupViteHMR();
3687
+ } else if (env === "webpack") {
3688
+ setupWebpackHMR();
439
3689
  }
440
3690
  }
441
- function registerForHMR(moduleId, styles) {
442
- if (typeof window === "undefined")
443
- return;
444
- if (import.meta.hot) {
445
- import.meta.hot.accept((newModule) => {
446
- console.log(`[HMR] Accepting update for ${moduleId}`);
447
- });
3691
+ function setupViteHMR() {
3692
+ if (typeof window === "undefined") return;
3693
+ const hot = import.meta.hot;
3694
+ if (!hot) return;
3695
+ hot.on("chaincss:update", (payload) => {
3696
+ console.log(`[ChainCSS HMR] \u{1F504} Updating styles for ${payload.file}`);
3697
+ if (payload.css) {
3698
+ const styleId = "chaincss-hmr-styles";
3699
+ let styleElement = document.getElementById(styleId);
3700
+ if (!styleElement) {
3701
+ styleElement = document.createElement("style");
3702
+ styleElement.id = styleId;
3703
+ styleElement.setAttribute("data-chaincss", "hmr");
3704
+ document.head.appendChild(styleElement);
3705
+ }
3706
+ styleElement.textContent = payload.css;
3707
+ console.log(`[ChainCSS HMR] \u2705 Injected ${payload.css.length} bytes of CSS`);
3708
+ }
3709
+ if (payload.map) {
3710
+ if (typeof window !== "undefined") {
3711
+ window.__CHAINCSS_MANIFEST__ = payload.map;
3712
+ }
3713
+ console.log(`[ChainCSS HMR] \u2705 Updated manifest with ${Object.keys(payload.map).length} entries`);
3714
+ }
3715
+ if (payload.styles) {
3716
+ const moduleId = `hmr-${payload.file}-${payload.timestamp || Date.now()}`;
3717
+ const result = compileRuntime(payload.styles, moduleId);
3718
+ console.log(`[ChainCSS HMR] \u2705 Recompiled ${Object.keys(result).length} styles`);
3719
+ }
3720
+ });
3721
+ hot.on("vite:beforeUpdate", () => {
3722
+ console.log("[ChainCSS HMR] \u{1F9F9} Clearing runtime styles before update");
3723
+ styleInjector.removeAll();
3724
+ });
3725
+ console.log("[ChainCSS HMR] \u2705 Vite HMR setup complete");
3726
+ }
3727
+ function setupWebpackHMR() {
3728
+ if (typeof window === "undefined") return;
3729
+ const hot = module.hot;
3730
+ if (!hot) return;
3731
+ hot.accept((err) => {
3732
+ if (err) {
3733
+ console.error("[ChainCSS HMR] \u274C Update failed:", err);
3734
+ return;
3735
+ }
3736
+ console.log("[ChainCSS HMR] \u{1F504} Webpack HMR update");
3737
+ styleInjector.removeAll();
3738
+ });
3739
+ hot.dispose(() => {
3740
+ console.log("[ChainCSS HMR] \u{1F9F9} Cleaning up styles");
3741
+ styleInjector.removeAll();
3742
+ });
3743
+ console.log("[ChainCSS HMR] \u2705 Webpack HMR setup complete");
3744
+ }
3745
+ function registerForHMR(moduleId, styles3, callback) {
3746
+ const env = getHMREnvironment();
3747
+ if (env === "vite") {
3748
+ registerViteHMR(moduleId, styles3, callback);
3749
+ } else if (env === "webpack") {
3750
+ registerWebpackHMR(moduleId, styles3, callback);
448
3751
  }
449
3752
  }
3753
+ function registerViteHMR(moduleId, styles3, callback) {
3754
+ const hot = import.meta.hot;
3755
+ if (!hot) return;
3756
+ hot.accept(() => {
3757
+ console.log(`[ChainCSS HMR] \u{1F504} Accepting update for ${moduleId}`);
3758
+ styleInjector.removeModule(moduleId);
3759
+ if (callback && styles3) {
3760
+ callback(styles3);
3761
+ }
3762
+ });
3763
+ hot.dispose(() => {
3764
+ console.log(`[ChainCSS HMR] \u{1F9F9} Disposing module: ${moduleId}`);
3765
+ styleInjector.removeModule(moduleId);
3766
+ });
3767
+ }
3768
+ function registerWebpackHMR(moduleId, styles3, callback) {
3769
+ const hot = module.hot;
3770
+ if (!hot) return;
3771
+ hot.accept(() => {
3772
+ console.log(`[ChainCSS HMR] \u{1F504} Webpack HMR accept for ${moduleId}`);
3773
+ if (callback && styles3) {
3774
+ callback(styles3);
3775
+ }
3776
+ });
3777
+ hot.dispose(() => {
3778
+ console.log(`[ChainCSS HMR] \u{1F9F9} Webpack HMR dispose for ${moduleId}`);
3779
+ styleInjector.removeModule(moduleId);
3780
+ });
3781
+ }
3782
+ if (typeof window !== "undefined") {
3783
+ setupHMR();
3784
+ }
450
3785
 
451
3786
  // src/runtime/utils.ts
452
3787
  function generateStyleId(prefix = "chain") {
@@ -462,7 +3797,7 @@ function hashString(str) {
462
3797
  }
463
3798
  return Math.abs(hash).toString(36);
464
3799
  }
465
- function kebabCase(str) {
3800
+ function kebabCase2(str) {
466
3801
  return str.replace(/([A-Z])/g, "-$1").toLowerCase();
467
3802
  }
468
3803
  var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
@@ -477,7 +3812,7 @@ function debounce(fn, delay) {
477
3812
  }
478
3813
  function memoize(fn) {
479
3814
  const cache = /* @__PURE__ */ new Map();
480
- const memoized = (...args) => {
3815
+ const memoized = ((...args) => {
481
3816
  const key = JSON.stringify(args);
482
3817
  if (cache.has(key)) {
483
3818
  return cache.get(key);
@@ -485,7 +3820,7 @@ function memoize(fn) {
485
3820
  const result = fn(...args);
486
3821
  cache.set(key, result);
487
3822
  return result;
488
- };
3823
+ });
489
3824
  memoized.cache = cache;
490
3825
  return memoized;
491
3826
  }
@@ -505,24 +3840,31 @@ function devLog(message, ...args) {
505
3840
  function logError(message, error) {
506
3841
  console.error(`[ChainCSS] ${message}`, error || "");
507
3842
  }
508
- function createDebugger(module) {
3843
+ function createDebugger(module2) {
509
3844
  return {
510
- log: (...args) => devLog(`[${module}]`, ...args),
511
- warn: (...args) => devWarn(`[${module}]`, ...args),
512
- error: (...args) => logError(`[${module}]`, ...args)
3845
+ log: (...args) => devLog(`[${module2}]`, ...args),
3846
+ warn: (...args) => devWarn(`[${module2}]`, ...args),
3847
+ error: (...args) => logError(`[${module2}]`, ...args)
513
3848
  };
514
3849
  }
515
3850
  export {
516
3851
  $,
3852
+ $t,
517
3853
  ChainCSSGlobal,
3854
+ ChainCSSGlobal3 as ChainCSSGlobalSvelte,
518
3855
  ChainCSSGlobal2 as ChainCSSGlobalVue,
3856
+ chain,
3857
+ chainStyles,
519
3858
  cn as cnUtils,
520
3859
  compileRuntime as compile,
521
3860
  createDebugger,
522
3861
  createStyledComponent,
3862
+ createStyledComponent3 as createStyledSvelteComponent,
3863
+ createStyledComponents2 as createStyledSvelteComponents,
523
3864
  createStyledComponent2 as createStyledVueComponent,
524
3865
  createStyledComponents as createStyledVueComponents,
525
3866
  cx,
3867
+ cx2 as cxSvelte,
526
3868
  debounce,
527
3869
  devLog,
528
3870
  devWarn,
@@ -531,21 +3873,26 @@ export {
531
3873
  generateStyleId,
532
3874
  hashString,
533
3875
  injectStyleContext,
3876
+ injectStyleContext2 as injectStyleContextSvelte,
534
3877
  isBrowser,
535
3878
  isDebugEnabled,
536
3879
  isDevelopment,
537
3880
  isProduction,
538
- kebabCase,
3881
+ kebabCase2 as kebabCase,
539
3882
  logError,
540
3883
  memoize,
541
3884
  provideStyleContext,
3885
+ provideStyleContext2 as provideStyleContextSvelte,
542
3886
  registerForHMR,
543
3887
  runRuntime as run,
3888
+ setManifest,
544
3889
  setupHMR,
545
3890
  styleInjector,
546
3891
  useAtomicClasses,
3892
+ useAtomicClasses2 as useAtomicClassesSvelte,
547
3893
  useChainStyles,
548
3894
  useComputedStyles,
3895
+ useComputedStyles3 as useComputedStylesSvelte,
549
3896
  useComputedStyles2 as useComputedStylesVue,
550
3897
  useDynamicChainStyles,
551
3898
  useThemeChainStyles,