@kbach/react-native 1.0.0-beta.8 → 1.0.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 (51) hide show
  1. package/AGENTS.md +495 -0
  2. package/LICENSE +21 -0
  3. package/README.md +209 -249
  4. package/THIRD_PARTY_NOTICES.md +41 -0
  5. package/android/src/main/jniLibs/arm64-v8a/libkbach_core_engine.so +0 -0
  6. package/android/src/main/jniLibs/x86_64/libkbach_core_engine.so +0 -0
  7. package/dist/chunk-7CNURQSH.mjs +112 -0
  8. package/dist/{chunk-OIW7OQWO.mjs → chunk-HYQFT32E.mjs} +2 -2
  9. package/dist/chunk-MUPEQJRT.mjs +623 -0
  10. package/dist/darkModeStore.d.ts +73 -0
  11. package/dist/darkModeStore.js +118 -0
  12. package/dist/dynamicTokens.d.ts +53 -0
  13. package/dist/dynamicTokens.js +75 -0
  14. package/dist/index.d.ts +90 -71
  15. package/dist/index.js +1433 -606
  16. package/dist/index.web.d.ts +91 -1
  17. package/dist/index.web.js +323 -428
  18. package/dist/index.web.mjs +297 -11
  19. package/dist/jsx-dev-runtime.d.ts +2 -2
  20. package/dist/jsx-dev-runtime.js +1540 -589
  21. package/dist/jsx-dev-runtime.web.d.ts +2 -2
  22. package/dist/jsx-dev-runtime.web.js +20 -340
  23. package/dist/jsx-dev-runtime.web.mjs +18 -6
  24. package/dist/jsx-runtime.d.ts +3 -3
  25. package/dist/jsx-runtime.js +1530 -579
  26. package/dist/jsx-runtime.web.d.ts +3 -3
  27. package/dist/jsx-runtime.web.js +17 -340
  28. package/dist/jsx-runtime.web.mjs +2 -3
  29. package/dist/semanticElements-Bk3TB-vt.d.ts +334 -0
  30. package/dist/theme.d.ts +79 -0
  31. package/dist/{chunk-4BXM3QUV.mjs → theme.js} +120 -17
  32. package/llms.txt +38 -0
  33. package/package.json +15 -13
  34. package/src/babel-plugin.js +144 -2
  35. package/dist/ThemeContext-Dc5AC-m0.d.mts +0 -98
  36. package/dist/ThemeContext-Dc5AC-m0.d.ts +0 -98
  37. package/dist/chunk-CGU7UM2F.mjs +0 -66
  38. package/dist/chunk-DLIXI5OW.mjs +0 -53
  39. package/dist/chunk-JR3BLUAV.mjs +0 -1204
  40. package/dist/chunk-JS5KIGAB.mjs +0 -192
  41. package/dist/chunk-KV3ZIXSH.mjs +0 -14
  42. package/dist/chunk-Z664AKW7.mjs +0 -54
  43. package/dist/index.d.mts +0 -84
  44. package/dist/index.mjs +0 -34
  45. package/dist/index.web.d.mts +0 -15
  46. package/dist/jsx-dev-runtime.d.mts +0 -10
  47. package/dist/jsx-dev-runtime.mjs +0 -18
  48. package/dist/jsx-dev-runtime.web.d.mts +0 -10
  49. package/dist/jsx-runtime.d.mts +0 -7
  50. package/dist/jsx-runtime.mjs +0 -15
  51. package/dist/jsx-runtime.web.d.mts +0 -7
@@ -30,407 +30,8 @@ module.exports = __toCommonJS(jsx_runtime_exports);
30
30
  var import_jsx_runtime = require("react/jsx-runtime");
31
31
  var import_react = require("react");
32
32
  var import_react_native = require("react-native");
33
- function makeElement(isStaticChildren, type, props, key) {
34
- return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
35
- }
36
- function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed) {
37
- const resolved = resolveStyle2(classStrRaw, pressed);
38
- if (userStyle === void 0) {
39
- return resolved;
40
- }
41
- if (typeof userStyle === "function") {
42
- return [resolved, userStyle({ pressed })];
43
- }
44
- return [resolved, userStyle];
45
- }
46
- function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
47
- if (type === null || typeof type === "symbol" || !rawProps) {
48
- return makeElement(isStaticChildren, type, rawProps ?? {}, key);
49
- }
50
- const { className: classStrRaw, style: userStyle, ...rest } = rawProps;
51
- if (typeof classStrRaw !== "string") {
52
- return makeElement(isStaticChildren, type, rawProps, key);
53
- }
54
- const finalStyle = type === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false);
55
- return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, key);
56
- }
57
- function createJsxFunctions(resolveStyle2) {
58
- function jsx2(type, props, key) {
59
- return processElement(resolveStyle2, type, props, key, false);
60
- }
61
- function jsxs2(type, props, key) {
62
- return processElement(resolveStyle2, type, props, key, true);
63
- }
64
- return { jsx: jsx2, jsxs: jsxs2 };
65
- }
66
-
67
- // src/nativeBridge.ts
68
- var import_react_native3 = require("react-native");
69
-
70
- // src/generatedPalette.ts
71
- var PALETTE = {
72
- "amber-1": "#fffbeb",
73
- "amber-10": "#78350f",
74
- "amber-11": "#451a03",
75
- "amber-12": "#291002",
76
- "amber-2": "#fef3c7",
77
- "amber-3": "#fde68a",
78
- "amber-4": "#fcd34d",
79
- "amber-5": "#fbbf24",
80
- "amber-6": "#f59e0b",
81
- "amber-7": "#d97706",
82
- "amber-8": "#b45309",
83
- "amber-9": "#92400e",
84
- "black": "#000000",
85
- "blue-1": "#eff6ff",
86
- "blue-10": "#1e3a8a",
87
- "blue-11": "#172554",
88
- "blue-12": "#0d1633",
89
- "blue-2": "#dbeafe",
90
- "blue-3": "#bfdbfe",
91
- "blue-4": "#93c5fd",
92
- "blue-5": "#60a5fa",
93
- "blue-6": "#3b82f6",
94
- "blue-7": "#2563eb",
95
- "blue-8": "#1d4ed8",
96
- "blue-9": "#1e40af",
97
- "bronze": "#cd7f32",
98
- "coal": "#1c1c1c",
99
- "copper": "#b87333",
100
- "current": "currentColor",
101
- "cyan-1": "#ecfeff",
102
- "cyan-10": "#164e63",
103
- "cyan-11": "#083344",
104
- "cyan-12": "#041e28",
105
- "cyan-2": "#cffafe",
106
- "cyan-3": "#a5f3fc",
107
- "cyan-4": "#67e8f9",
108
- "cyan-5": "#22d3ee",
109
- "cyan-6": "#06b6d4",
110
- "cyan-7": "#0891b2",
111
- "cyan-8": "#0e7490",
112
- "cyan-9": "#155e75",
113
- "emerald-1": "#ecfdf5",
114
- "emerald-10": "#064e3b",
115
- "emerald-11": "#022c22",
116
- "emerald-12": "#011a14",
117
- "emerald-2": "#d1fae5",
118
- "emerald-3": "#a7f3d0",
119
- "emerald-4": "#6ee7b7",
120
- "emerald-5": "#34d399",
121
- "emerald-6": "#10b981",
122
- "emerald-7": "#059669",
123
- "emerald-8": "#047857",
124
- "emerald-9": "#065f46",
125
- "fuchsia-1": "#fdf4ff",
126
- "fuchsia-10": "#701a75",
127
- "fuchsia-11": "#4a044e",
128
- "fuchsia-12": "#2d022f",
129
- "fuchsia-2": "#fae8ff",
130
- "fuchsia-3": "#f5d0fe",
131
- "fuchsia-4": "#f0abfc",
132
- "fuchsia-5": "#e879f9",
133
- "fuchsia-6": "#d946ef",
134
- "fuchsia-7": "#c026d3",
135
- "fuchsia-8": "#a21caf",
136
- "fuchsia-9": "#86198f",
137
- "gold": "#d4af37",
138
- "gray-1": "#f9fafb",
139
- "gray-10": "#111827",
140
- "gray-11": "#030712",
141
- "gray-12": "#020409",
142
- "gray-2": "#f3f4f6",
143
- "gray-3": "#e5e7eb",
144
- "gray-4": "#d1d5db",
145
- "gray-5": "#9ca3af",
146
- "gray-6": "#6b7280",
147
- "gray-7": "#4b5563",
148
- "gray-8": "#374151",
149
- "gray-9": "#1f2937",
150
- "green-1": "#f0fdf4",
151
- "green-10": "#14532d",
152
- "green-11": "#052e16",
153
- "green-12": "#031b0d",
154
- "green-2": "#dcfce7",
155
- "green-3": "#bbf7d0",
156
- "green-4": "#86efac",
157
- "green-5": "#4ade80",
158
- "green-6": "#22c55e",
159
- "green-7": "#16a34a",
160
- "green-8": "#15803d",
161
- "green-9": "#166534",
162
- "indigo-1": "#eef2ff",
163
- "indigo-10": "#312e81",
164
- "indigo-11": "#1e1b4b",
165
- "indigo-12": "#12102d",
166
- "indigo-2": "#e0e7ff",
167
- "indigo-3": "#c7d2fe",
168
- "indigo-4": "#a5b4fc",
169
- "indigo-5": "#818cf8",
170
- "indigo-6": "#6366f1",
171
- "indigo-7": "#4f46e5",
172
- "indigo-8": "#4338ca",
173
- "indigo-9": "#3730a3",
174
- "lime-1": "#f7fee7",
175
- "lime-10": "#365314",
176
- "lime-11": "#1a2e05",
177
- "lime-12": "#0f1b03",
178
- "lime-2": "#ecfccb",
179
- "lime-3": "#d9f99d",
180
- "lime-4": "#bef264",
181
- "lime-5": "#a3e635",
182
- "lime-6": "#84cc16",
183
- "lime-7": "#65a30d",
184
- "lime-8": "#4d7c0f",
185
- "lime-9": "#3f6212",
186
- "neutral-1": "#fafafa",
187
- "neutral-10": "#171717",
188
- "neutral-11": "#0a0a0a",
189
- "neutral-12": "#050505",
190
- "neutral-2": "#f5f5f5",
191
- "neutral-3": "#e5e5e5",
192
- "neutral-4": "#d4d4d4",
193
- "neutral-5": "#a3a3a3",
194
- "neutral-6": "#737373",
195
- "neutral-7": "#525252",
196
- "neutral-8": "#404040",
197
- "neutral-9": "#262626",
198
- "orange-1": "#fff7ed",
199
- "orange-10": "#7c2d12",
200
- "orange-11": "#431407",
201
- "orange-12": "#270c04",
202
- "orange-2": "#ffedd5",
203
- "orange-3": "#fed7aa",
204
- "orange-4": "#fdba74",
205
- "orange-5": "#fb923c",
206
- "orange-6": "#f97316",
207
- "orange-7": "#ea580c",
208
- "orange-8": "#c2410c",
209
- "orange-9": "#9a3412",
210
- "pink-1": "#fdf2f8",
211
- "pink-10": "#831843",
212
- "pink-11": "#500724",
213
- "pink-12": "#300415",
214
- "pink-2": "#fce7f3",
215
- "pink-3": "#fbcfe8",
216
- "pink-4": "#f9a8d4",
217
- "pink-5": "#f472b6",
218
- "pink-6": "#ec4899",
219
- "pink-7": "#db2777",
220
- "pink-8": "#be185d",
221
- "pink-9": "#9d174d",
222
- "purple-1": "#faf5ff",
223
- "purple-10": "#581c87",
224
- "purple-11": "#3b0764",
225
- "purple-12": "#23043c",
226
- "purple-2": "#f3e8ff",
227
- "purple-3": "#e9d5ff",
228
- "purple-4": "#d8b4fe",
229
- "purple-5": "#c084fc",
230
- "purple-6": "#a855f7",
231
- "purple-7": "#9333ea",
232
- "purple-8": "#7e22ce",
233
- "purple-9": "#6b21a8",
234
- "red-1": "#fef2f2",
235
- "red-10": "#7f1d1d",
236
- "red-11": "#450a0a",
237
- "red-12": "#280606",
238
- "red-2": "#fee2e2",
239
- "red-3": "#fecaca",
240
- "red-4": "#fca5a5",
241
- "red-5": "#f87171",
242
- "red-6": "#ef4444",
243
- "red-7": "#dc2626",
244
- "red-8": "#b91c1c",
245
- "red-9": "#991b1b",
246
- "rose-1": "#fff1f2",
247
- "rose-10": "#881337",
248
- "rose-11": "#4c0519",
249
- "rose-12": "#2d030e",
250
- "rose-2": "#ffe4e6",
251
- "rose-3": "#fecdd3",
252
- "rose-4": "#fda4af",
253
- "rose-5": "#fb7185",
254
- "rose-6": "#f43f5e",
255
- "rose-7": "#e11d48",
256
- "rose-8": "#be123c",
257
- "rose-9": "#9f1239",
258
- "silver": "#c0c0c0",
259
- "sky-1": "#f0f9ff",
260
- "sky-10": "#0c4a6e",
261
- "sky-11": "#082f49",
262
- "sky-12": "#041b2b",
263
- "sky-2": "#e0f2fe",
264
- "sky-3": "#bae6fd",
265
- "sky-4": "#7dd3fc",
266
- "sky-5": "#38bdf8",
267
- "sky-6": "#0ea5e9",
268
- "sky-7": "#0284c7",
269
- "sky-8": "#0369a1",
270
- "sky-9": "#075985",
271
- "slate-1": "#f8fafc",
272
- "slate-10": "#0f172a",
273
- "slate-11": "#020617",
274
- "slate-12": "#01020a",
275
- "slate-2": "#f1f5f9",
276
- "slate-3": "#e2e8f0",
277
- "slate-4": "#cbd5e1",
278
- "slate-5": "#94a3b8",
279
- "slate-6": "#64748b",
280
- "slate-7": "#475569",
281
- "slate-8": "#334155",
282
- "slate-9": "#1e293b",
283
- "stone-1": "#fafaf9",
284
- "stone-10": "#1c1917",
285
- "stone-11": "#0c0a09",
286
- "stone-12": "#070605",
287
- "stone-2": "#f5f5f4",
288
- "stone-3": "#e7e5e4",
289
- "stone-4": "#d6d3d1",
290
- "stone-5": "#a8a29e",
291
- "stone-6": "#78716c",
292
- "stone-7": "#57534e",
293
- "stone-8": "#44403c",
294
- "stone-9": "#292524",
295
- "teal-1": "#f0fdfa",
296
- "teal-10": "#134e4a",
297
- "teal-11": "#042f2e",
298
- "teal-12": "#021c1b",
299
- "teal-2": "#ccfbf1",
300
- "teal-3": "#99f6e4",
301
- "teal-4": "#5eead4",
302
- "teal-5": "#2dd4bf",
303
- "teal-6": "#14b8a6",
304
- "teal-7": "#0d9488",
305
- "teal-8": "#0f766e",
306
- "teal-9": "#115e59",
307
- "transparent": "transparent",
308
- "violet-1": "#f5f3ff",
309
- "violet-10": "#4c1d95",
310
- "violet-11": "#2e1065",
311
- "violet-12": "#1c0a3d",
312
- "violet-2": "#ede9fe",
313
- "violet-3": "#ddd6fe",
314
- "violet-4": "#c4b5fd",
315
- "violet-5": "#a78bfa",
316
- "violet-6": "#8b5cf6",
317
- "violet-7": "#7c3aed",
318
- "violet-8": "#6d28d9",
319
- "violet-9": "#5b21b6",
320
- "white": "#ffffff",
321
- "yellow-1": "#fefce8",
322
- "yellow-10": "#713f12",
323
- "yellow-11": "#422006",
324
- "yellow-12": "#271304",
325
- "yellow-2": "#fef9c3",
326
- "yellow-3": "#fef08a",
327
- "yellow-4": "#fde047",
328
- "yellow-5": "#facc15",
329
- "yellow-6": "#eab308",
330
- "yellow-7": "#ca8a04",
331
- "yellow-8": "#a16207",
332
- "yellow-9": "#854d0e",
333
- "zinc-1": "#fafafa",
334
- "zinc-10": "#18181b",
335
- "zinc-11": "#09090b",
336
- "zinc-12": "#050506",
337
- "zinc-2": "#f4f4f5",
338
- "zinc-3": "#e4e4e7",
339
- "zinc-4": "#d4d4d8",
340
- "zinc-5": "#a1a1aa",
341
- "zinc-6": "#71717a",
342
- "zinc-7": "#52525b",
343
- "zinc-8": "#3f3f46",
344
- "zinc-9": "#27272a"
345
- };
346
-
347
- // src/theme.ts
348
- var defaultTheme = {
349
- colors: PALETTE,
350
- // Real Tailwind's default spacing scale in full — every step is exactly
351
- // `n * 4px`, including the fractional `.5` steps (`1.5` -> 6px, `2.5` ->
352
- // 10px, `3.5` -> 14px) and the "px" literal (a bare 1px). Previously
353
- // this only had {0,1,2,4,6,8} — a handful of spot-checked values, not
354
- // the real scale — so anything else (`p-3`, `w-5`, `border-2`,
355
- // `gap-10`, ...) silently failed to resolve. Mirrors @kbach/react's
356
- // theme.ts exactly.
357
- spacing: {
358
- "0": 0,
359
- "px": 1,
360
- "0.5": 2,
361
- "1": 4,
362
- "1.5": 6,
363
- "2": 8,
364
- "2.5": 10,
365
- "3": 12,
366
- "3.5": 14,
367
- "4": 16,
368
- "5": 20,
369
- "6": 24,
370
- "7": 28,
371
- "8": 32,
372
- "9": 36,
373
- "10": 40,
374
- "11": 44,
375
- "12": 48,
376
- "14": 56,
377
- "16": 64,
378
- "20": 80,
379
- "24": 96,
380
- "28": 112,
381
- "32": 128,
382
- "36": 144,
383
- "40": 160,
384
- "44": 176,
385
- "48": 192,
386
- "52": 208,
387
- "56": 224,
388
- "60": 240,
389
- "64": 256,
390
- "72": 288,
391
- "80": 320,
392
- "96": 384
393
- },
394
- screens: {
395
- sm: 640,
396
- md: 768,
397
- lg: 1024,
398
- xl: 1280,
399
- "2xl": 1536
400
- },
401
- darkMode: "attribute"
402
- };
403
- var activeTheme = defaultTheme;
404
- var activeThemeJson = JSON.stringify(defaultTheme);
405
- function getTheme() {
406
- return activeTheme;
407
- }
408
- function getThemeJson() {
409
- return activeThemeJson;
410
- }
411
-
412
- // src/darkModeStore.ts
413
- var import_react_native2 = require("react-native");
414
- var listeners = /* @__PURE__ */ new Set();
415
- function systemPrefersDark() {
416
- return import_react_native2.Appearance.getColorScheme() === "dark";
417
- }
418
- function resolveIsDark(m) {
419
- return m === "system" ? systemPrefersDark() : m === "dark";
420
- }
421
- var mode = "system";
422
- var isDark = resolveIsDark(mode);
423
- var subscription = import_react_native2.Appearance.addChangeListener(({ colorScheme }) => {
424
- if (mode !== "system") return;
425
- isDark = colorScheme === "dark";
426
- notify();
427
- });
428
- function notify() {
429
- for (const listener of listeners) listener();
430
- }
431
- function getGlobalDarkMode() {
432
- return isDark;
433
- }
33
+ var import_darkModeStore = require("./darkModeStore");
34
+ var import_theme = require("./theme");
434
35
 
435
36
  // src/jsEngine/parser.ts
436
37
  var VALUE_PREFIXES = [
@@ -518,12 +119,23 @@ var VALUE_PREFIXES = [
518
119
  "leading-",
519
120
  "tracking-",
520
121
  "font-",
122
+ "align-",
521
123
  "z-",
124
+ "inset-x-",
125
+ "inset-y-",
522
126
  "inset-",
523
127
  "top-",
524
128
  "right-",
525
129
  "bottom-",
526
130
  "left-",
131
+ "start-",
132
+ "end-",
133
+ "overflow-x-",
134
+ "overflow-y-",
135
+ "overscroll-x-",
136
+ "overscroll-y-",
137
+ "overscroll-",
138
+ "aspect-",
527
139
  "divide-color-",
528
140
  "space-x-",
529
141
  "space-y-",
@@ -551,12 +163,23 @@ var VALUE_PREFIXES = [
551
163
  "justify-self-",
552
164
  "scale-x-",
553
165
  "scale-y-",
166
+ "scale-z-",
554
167
  "scale-",
168
+ "rotate-x-",
169
+ "rotate-y-",
170
+ "rotate-z-",
555
171
  "rotate-",
172
+ // Bare 'translate-'/'skew-' (both axes) after their per-axis forms, same
173
+ // longer-before-shorter rule as resolvers/parser.rs.
556
174
  "translate-x-",
557
175
  "translate-y-",
176
+ "translate-z-",
177
+ "translate-",
558
178
  "skew-x-",
559
179
  "skew-y-",
180
+ "skew-",
181
+ "perspective-origin-",
182
+ "perspective-",
560
183
  "origin-",
561
184
  "blur-",
562
185
  "brightness-",
@@ -589,14 +212,200 @@ var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
589
212
  function isSafeArbitraryValue(value) {
590
213
  return !value.includes("{") && !value.includes("}") && !value.includes(";");
591
214
  }
215
+ function normalizeMathWhitespace(raw) {
216
+ if (!(raw.startsWith("calc(") || raw.startsWith("min(") || raw.startsWith("max(") || raw.startsWith("clamp("))) {
217
+ return raw;
218
+ }
219
+ const chars = Array.from(raw);
220
+ let out = "";
221
+ let i = 0;
222
+ let prevEndsValue = false;
223
+ while (i < chars.length) {
224
+ const c = chars[i];
225
+ if (c === "v" && chars[i + 1] === "a" && chars[i + 2] === "r" && chars[i + 3] === "(") {
226
+ const start = i;
227
+ let depth = 0;
228
+ while (i < chars.length) {
229
+ if (chars[i] === "(") depth++;
230
+ else if (chars[i] === ")") {
231
+ depth--;
232
+ if (depth === 0) {
233
+ i++;
234
+ break;
235
+ }
236
+ }
237
+ i++;
238
+ }
239
+ out += chars.slice(start, i).join("");
240
+ prevEndsValue = true;
241
+ continue;
242
+ }
243
+ if (c === "+" || c === "-") {
244
+ if (prevEndsValue) {
245
+ out += ` ${c} `;
246
+ i++;
247
+ while (i < chars.length && /\s/.test(chars[i])) i++;
248
+ prevEndsValue = false;
249
+ continue;
250
+ }
251
+ out += c;
252
+ prevEndsValue = false;
253
+ } else if (c === "(" || c === ",") {
254
+ out += c;
255
+ if (c === ",") out += " ";
256
+ prevEndsValue = false;
257
+ } else if (c === ")") {
258
+ out += c;
259
+ prevEndsValue = true;
260
+ } else if (/\s/.test(c)) {
261
+ } else if (c === "*" || c === "/") {
262
+ out += c;
263
+ prevEndsValue = false;
264
+ } else {
265
+ out += c;
266
+ prevEndsValue = true;
267
+ }
268
+ i++;
269
+ }
270
+ return out;
271
+ }
272
+ var TYPE_HINTS = /* @__PURE__ */ new Set([
273
+ "color",
274
+ "length",
275
+ "size",
276
+ "line-width",
277
+ "percentage",
278
+ "number",
279
+ "integer",
280
+ "image",
281
+ "url",
282
+ "position",
283
+ "bg-size",
284
+ "family-name",
285
+ "generic-name",
286
+ "absolute-size",
287
+ "relative-size",
288
+ "angle",
289
+ "shadow",
290
+ "any"
291
+ ]);
292
+ function arbitraryModifier(modifier) {
293
+ const bracketed = parenVarShorthand(modifier) ?? modifier;
294
+ if (!(bracketed.length > 2 && bracketed.startsWith("[") && bracketed.endsWith("]"))) return null;
295
+ const raw = bracketed.slice(1, -1);
296
+ if (!isSafeArbitraryValue(raw)) return null;
297
+ return normalizeMathWhitespace(raw.replace(/_/g, " "));
298
+ }
299
+ function splitTypeHint(raw) {
300
+ const i = raw.indexOf(":");
301
+ if (i > 0 && i < raw.length - 1 && TYPE_HINTS.has(raw.slice(0, i))) return [raw.slice(0, i), raw.slice(i + 1)];
302
+ return [null, raw];
303
+ }
304
+ function parenVarShorthand(value) {
305
+ const m = /^\((?:([a-z-]+):)?--([A-Za-z0-9_-]+)\)(\/.*)?$/.exec(value);
306
+ if (!m) return null;
307
+ const [, hint, name, tail = ""] = m;
308
+ if (hint !== void 0 && !TYPE_HINTS.has(hint)) return null;
309
+ return hint ? `[${hint}:var(--${name})]${tail}` : `[var(--${name})]${tail}`;
310
+ }
311
+ function splitBracketModifier(value) {
312
+ if (!value.startsWith("[")) return [value, null];
313
+ let depth = 0;
314
+ for (let i = 0; i < value.length; i++) {
315
+ const ch = value[i];
316
+ if (ch === "[") depth += 1;
317
+ else if (ch === "]") {
318
+ depth -= 1;
319
+ if (depth === 0) {
320
+ const after = value.slice(i + 1);
321
+ return after.startsWith("/") && after.length > 1 ? [value.slice(0, i + 1), after.slice(1)] : [value, null];
322
+ }
323
+ }
324
+ }
325
+ return [value, null];
326
+ }
327
+ function trimNumber(n) {
328
+ return `${Math.round(n * 1e6) / 1e6}`;
329
+ }
330
+ function parseAlpha(modifier) {
331
+ const raw = arbitraryModifier(modifier);
332
+ if (raw !== null) {
333
+ if (raw.endsWith("%")) {
334
+ const n3 = strictNumber(raw.slice(0, -1));
335
+ return n3 !== null && n3 >= 0 && n3 <= 100 ? { fraction: n3 / 100 } : null;
336
+ }
337
+ const n2 = strictNumber(raw);
338
+ if (n2 !== null) return n2 >= 0 && n2 <= 1 ? { fraction: n2 } : null;
339
+ return raw.startsWith("var(") || raw.startsWith("calc(") ? { raw } : null;
340
+ }
341
+ if (!/^(?:\d+\.?\d*|\.\d+)$/.test(modifier)) return null;
342
+ const n = Number(modifier);
343
+ return n <= 100 ? { fraction: n / 100 } : null;
344
+ }
345
+ function strictNumber(text) {
346
+ return /^[+-]?(?:\d+\.?\d*|\.\d+)$/.test(text) ? Number(text) : null;
347
+ }
348
+ function expandThemeFunctions(raw) {
349
+ if (!raw.includes("--spacing(") && !raw.includes("--alpha(")) return raw;
350
+ let out = "";
351
+ let rest = raw;
352
+ for (; ; ) {
353
+ const found = ["--spacing(", "--alpha("].map((name) => ({ name, at: rest.indexOf(name) })).filter((f) => f.at !== -1).sort((a, b) => a.at - b.at)[0];
354
+ if (found === void 0) break;
355
+ const argsFrom = found.at + found.name.length;
356
+ let depth = 1;
357
+ let close = -1;
358
+ for (let i = argsFrom; i < rest.length; i++) {
359
+ if (rest[i] === "(") depth += 1;
360
+ else if (rest[i] === ")") {
361
+ depth -= 1;
362
+ if (depth === 0) {
363
+ close = i;
364
+ break;
365
+ }
366
+ }
367
+ }
368
+ if (close === -1) break;
369
+ const arg = expandThemeFunctions(rest.slice(argsFrom, close).trim());
370
+ out += rest.slice(0, found.at);
371
+ if (found.name === "--spacing(") {
372
+ const n = strictNumber(arg);
373
+ out += n !== null ? `${trimNumber(n * 4)}px` : `calc(4px * ${arg})`;
374
+ } else {
375
+ const slash = arg.lastIndexOf("/");
376
+ if (slash === -1) {
377
+ out += arg;
378
+ } else {
379
+ const alpha = arg.slice(slash + 1).trim();
380
+ const n = strictNumber(alpha);
381
+ out += `color-mix(in srgb, ${arg.slice(0, slash).trim()} ${n !== null ? `${trimNumber(n * 100)}%` : alpha}, transparent)`;
382
+ }
383
+ }
384
+ rest = rest.slice(close + 1);
385
+ }
386
+ return out + rest;
387
+ }
388
+ var COLOR_FUNCTIONS = ["rgb(", "rgba(", "hsl(", "hsla(", "hwb(", "lab(", "lch(", "oklab(", "oklch(", "color(", "color-mix(", "var("];
389
+ function looksLikeColor(value) {
390
+ return value.startsWith("#") || COLOR_FUNCTIONS.some((f) => value.startsWith(f)) || /^[A-Za-z]+$/.test(value);
391
+ }
392
+ function colorWithOpacity(color, alpha) {
393
+ const m = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(color);
394
+ if (m && "fraction" in alpha) {
395
+ const h = m[1].length === 3 ? m[1].split("").map((c) => c + c).join("") : m[1];
396
+ const [r, g, b] = [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16));
397
+ return `rgba(${r},${g},${b},${trimNumber(alpha.fraction)})`;
398
+ }
399
+ return `color-mix(in srgb, ${color} ${"fraction" in alpha ? `${trimNumber(alpha.fraction * 100)}%` : alpha.raw}, transparent)`;
400
+ }
592
401
  function splitRespectingBrackets(token) {
593
402
  const parts = [];
594
403
  let depth = 0;
595
404
  let start = 0;
596
405
  for (let i = 0; i < token.length; i++) {
597
406
  const ch = token[i];
598
- if (ch === "[") depth += 1;
599
- else if (ch === "]") depth -= 1;
407
+ if (ch === "[" || ch === "(") depth += 1;
408
+ else if (ch === "]" || ch === ")") depth -= 1;
600
409
  else if (ch === ":" && depth <= 0) {
601
410
  parts.push(token.slice(start, i));
602
411
  start = i + 1;
@@ -609,9 +418,11 @@ function parseClass(token) {
609
418
  const parts = splitRespectingBrackets(token);
610
419
  let base = parts.pop() ?? token;
611
420
  const modifiers = parts;
612
- const important = base.startsWith("!");
613
- if (important) {
421
+ const important = base.startsWith("!") || base.length > 1 && base.endsWith("!");
422
+ if (base.startsWith("!")) {
614
423
  base = base.slice(1);
424
+ } else if (important) {
425
+ base = base.slice(0, -1);
615
426
  }
616
427
  const negative = base.startsWith("-");
617
428
  if (negative) {
@@ -624,7 +435,7 @@ function parseClass(token) {
624
435
  const property = raw.slice(0, colonIdx);
625
436
  const rawValue = raw.slice(colonIdx + 1);
626
437
  if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
627
- const value = rawValue.replace(/_/g, " ");
438
+ const value = normalizeMathWhitespace(expandThemeFunctions(rawValue.replace(/_/g, " ")));
628
439
  return {
629
440
  modifiers,
630
441
  utility: ARBITRARY_PROPERTY_SENTINEL,
@@ -639,28 +450,46 @@ function parseClass(token) {
639
450
  }
640
451
  for (const prefix of VALUE_PREFIXES) {
641
452
  if (!base.startsWith(prefix)) continue;
642
- const value = base.slice(prefix.length);
643
- if (value === "") continue;
453
+ const written = base.slice(prefix.length);
454
+ if (written === "") continue;
455
+ const [value, tail] = splitBracketModifier(parenVarShorthand(written) ?? written);
644
456
  if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
645
457
  const raw = value.slice(1, -1);
646
458
  if (!isSafeArbitraryValue(raw)) {
647
459
  continue;
648
460
  }
649
- const spaced = raw.replace(/_/g, " ");
461
+ const spaced = normalizeMathWhitespace(expandThemeFunctions(raw.replace(/_/g, " ")));
462
+ let [typeHint, hinted] = splitTypeHint(spaced);
463
+ let modifier = null;
464
+ if (tail !== null) {
465
+ const isColor = typeHint === "color" || typeHint === null && looksLikeColor(hinted);
466
+ const alpha = isColor ? parseAlpha(tail) : null;
467
+ if (alpha !== null) {
468
+ hinted = colorWithOpacity(hinted, alpha);
469
+ typeHint = "color";
470
+ } else if (prefix === "text-") {
471
+ modifier = tail;
472
+ } else {
473
+ continue;
474
+ }
475
+ }
650
476
  return {
651
477
  modifiers,
652
478
  utility: prefix.slice(0, -1),
653
- value: spaced,
479
+ value: hinted,
480
+ typeHint,
654
481
  isArbitrary: true,
655
482
  important,
656
483
  negative,
657
- original: token
484
+ original: token,
485
+ modifier
658
486
  };
659
487
  }
660
488
  return {
661
489
  modifiers,
662
490
  utility: prefix.slice(0, -1),
663
- value,
491
+ // a named value keeps its own /opacity (`bg-blue-6/50`)
492
+ value: tail === null ? value : `${value}/${tail}`,
664
493
  isArbitrary: false,
665
494
  important,
666
495
  negative,
@@ -678,10 +507,652 @@ function parseClass(token) {
678
507
  };
679
508
  }
680
509
 
510
+ // src/jsEngine/resolvers/color.ts
511
+ function lookupHex(theme, key) {
512
+ const entry = theme.colors[key];
513
+ return typeof entry === "string" ? entry : null;
514
+ }
515
+ var MODE_AWARE_COLOR_PREFIXES = ["bg-", "text-", "border-"];
516
+ function findModeAwareColor(base, theme) {
517
+ const important = base.startsWith("!") ? "!" : "";
518
+ const rest = important ? base.slice(1) : base;
519
+ for (const prefix of MODE_AWARE_COLOR_PREFIXES) {
520
+ if (!rest.startsWith(prefix)) continue;
521
+ const [name, opacity] = splitOpacity(rest.slice(prefix.length));
522
+ const entry = theme.colors[name];
523
+ if (typeof entry === "object" && entry !== null) {
524
+ return { prefix: `${important}${prefix}`, opacity, light: entry.light, dark: entry.dark };
525
+ }
526
+ }
527
+ return null;
528
+ }
529
+ function applyOpacityToHex(hex, opacity) {
530
+ if (opacity === null) return hex;
531
+ if (hexToRgb(hex) === null) return hex;
532
+ return colorWithOpacity(hex.trim(), opacity).replace(/ /g, "_");
533
+ }
534
+ function substituteModeAwareColorToken(token, theme, colorScheme) {
535
+ const segments = token.split(":");
536
+ const base = segments.pop() ?? token;
537
+ const modifierPrefix = segments.length > 0 ? `${segments.join(":")}:` : "";
538
+ const found = findModeAwareColor(base, theme);
539
+ if (found === null) return token;
540
+ const hex = colorScheme === "dark" ? found.dark : found.light;
541
+ return `${modifierPrefix}${found.prefix}[${applyOpacityToHex(hex, found.opacity)}]`;
542
+ }
543
+ function classStringUsesModeAwareColor(classString, theme) {
544
+ return classString.split(/\s+/).some((rawToken) => {
545
+ if (!rawToken) return false;
546
+ const segments = rawToken.split(":");
547
+ const base = segments.pop() ?? rawToken;
548
+ return findModeAwareColor(base, theme) !== null;
549
+ });
550
+ }
551
+ function hexToRgb(hex) {
552
+ const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
553
+ if (!m) return null;
554
+ let h = m[1];
555
+ if (h.length === 3) h = h.split("").map((c) => c + c).join("");
556
+ const n = parseInt(h, 16);
557
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
558
+ }
559
+ function splitOpacity(value) {
560
+ const slash = value.indexOf("/");
561
+ if (slash === -1) return [value, null];
562
+ const alpha = parseAlpha(value.slice(slash + 1));
563
+ return alpha === null ? [value, null] : [value.slice(0, slash), alpha];
564
+ }
565
+ function colorValue(theme, parsed) {
566
+ const value = parsed.value;
567
+ if (value === null) return null;
568
+ if (parsed.isArbitrary) return value;
569
+ const [name, opacity] = splitOpacity(value);
570
+ const hex = lookupHex(theme, name);
571
+ if (hex === null) return null;
572
+ return opacity === null ? hex : colorWithOpacity(hex, opacity);
573
+ }
574
+ var LENGTH_UNITS = ["px", "rem", "em", "%", "vh", "vw"];
575
+ function looksLikeLength(value) {
576
+ const unit = LENGTH_UNITS.find((u) => value.endsWith(u));
577
+ const withoutUnit = unit ? value.slice(0, value.length - unit.length) : value;
578
+ if (withoutUnit !== "" && Number.isFinite(Number(withoutUnit))) return true;
579
+ if (!["calc(", "clamp(", "min(", "max("].some((f) => value.startsWith(f))) return false;
580
+ return MATH_LENGTH_UNIT.test(value);
581
+ }
582
+ var MATH_LENGTH_UNIT = /\d(?:px|rem|em|%|vh|vw|vmin|vmax|dvh|dvw|svh|svw|lvh|lvw|ch|ex|lh|cqw|cqh|cqi|cqb)(?![A-Za-z])/;
583
+ function isLength(parsed, value) {
584
+ switch (parsed.typeHint ?? null) {
585
+ case null:
586
+ return looksLikeLength(value);
587
+ case "length":
588
+ case "size":
589
+ case "line-width":
590
+ case "percentage":
591
+ case "number":
592
+ case "integer":
593
+ case "absolute-size":
594
+ case "relative-size":
595
+ return true;
596
+ default:
597
+ return false;
598
+ }
599
+ }
600
+
601
+ // src/jsxRuntimeCore.ts
602
+ var import_dynamicTokens = require("./dynamicTokens");
603
+
604
+ // src/jsEngine/calc.ts
605
+ function reduceConstantMath(raw) {
606
+ const trimmed = raw.trim();
607
+ const calc = stripCall(trimmed, "calc");
608
+ if (calc !== null) {
609
+ return new Evaluator(calc).parseExprToEnd();
610
+ }
611
+ const clamp = stripCall(trimmed, "clamp");
612
+ if (clamp !== null) {
613
+ const args = splitTopLevelCommas(clamp);
614
+ if (args.length !== 3) return null;
615
+ const [min2, preferred, max2] = args.map((a) => new Evaluator(a).parseExprToEnd());
616
+ if (min2 === null || preferred === null || max2 === null) return null;
617
+ return Math.max(min2, Math.min(preferred, max2));
618
+ }
619
+ const min = stripCall(trimmed, "min");
620
+ if (min !== null) {
621
+ const values = splitTopLevelCommas(min).map((a) => new Evaluator(a).parseExprToEnd());
622
+ return values.some((v) => v === null) ? null : Math.min(...values);
623
+ }
624
+ const max = stripCall(trimmed, "max");
625
+ if (max !== null) {
626
+ const values = splitTopLevelCommas(max).map((a) => new Evaluator(a).parseExprToEnd());
627
+ return values.some((v) => v === null) ? null : Math.max(...values);
628
+ }
629
+ return null;
630
+ }
631
+ function stripCall(raw, name) {
632
+ if (!raw.startsWith(name)) return null;
633
+ const afterName = raw.slice(name.length).trimStart();
634
+ if (!afterName.startsWith("(") || !afterName.endsWith(")")) return null;
635
+ return afterName.slice(1, -1);
636
+ }
637
+ function splitTopLevelCommas(s) {
638
+ const parts = [];
639
+ let depth = 0;
640
+ let start = 0;
641
+ for (let i = 0; i < s.length; i++) {
642
+ const ch = s[i];
643
+ if (ch === "(") depth++;
644
+ else if (ch === ")") depth--;
645
+ else if (ch === "," && depth === 0) {
646
+ parts.push(s.slice(start, i).trim());
647
+ start = i + 1;
648
+ }
649
+ }
650
+ parts.push(s.slice(start).trim());
651
+ return parts;
652
+ }
653
+ var Evaluator = class {
654
+ constructor(s) {
655
+ this.pos = 0;
656
+ this.s = s;
657
+ }
658
+ parseExprToEnd() {
659
+ const value = this.expr();
660
+ if (value === null) return null;
661
+ this.skipWs();
662
+ return this.pos === this.s.length ? value : null;
663
+ }
664
+ skipWs() {
665
+ while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
666
+ }
667
+ peek() {
668
+ this.skipWs();
669
+ return this.s[this.pos];
670
+ }
671
+ expr() {
672
+ let value = this.term();
673
+ if (value === null) return null;
674
+ for (; ; ) {
675
+ const ch = this.peek();
676
+ if (ch === "+") {
677
+ this.pos++;
678
+ const rhs = this.term();
679
+ if (rhs === null) return null;
680
+ value += rhs;
681
+ } else if (ch === "-") {
682
+ this.pos++;
683
+ const rhs = this.term();
684
+ if (rhs === null) return null;
685
+ value -= rhs;
686
+ } else {
687
+ return value;
688
+ }
689
+ }
690
+ }
691
+ term() {
692
+ let value = this.factor();
693
+ if (value === null) return null;
694
+ for (; ; ) {
695
+ const ch = this.peek();
696
+ if (ch === "*") {
697
+ this.pos++;
698
+ const rhs = this.factor();
699
+ if (rhs === null) return null;
700
+ value *= rhs;
701
+ } else if (ch === "/") {
702
+ this.pos++;
703
+ const divisor = this.factor();
704
+ if (divisor === null || divisor === 0) return null;
705
+ value /= divisor;
706
+ } else {
707
+ return value;
708
+ }
709
+ }
710
+ }
711
+ factor() {
712
+ const ch = this.peek();
713
+ if (ch === void 0) return null;
714
+ if (ch === "(") {
715
+ this.pos++;
716
+ const value = this.expr();
717
+ if (value === null || this.peek() !== ")") return null;
718
+ this.pos++;
719
+ return value;
720
+ }
721
+ if (ch === "-") {
722
+ this.pos++;
723
+ const value = this.factor();
724
+ return value === null ? null : -value;
725
+ }
726
+ return this.numberWithUnit();
727
+ }
728
+ numberWithUnit() {
729
+ this.skipWs();
730
+ const start = this.pos;
731
+ while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
732
+ if (this.pos === start) return null;
733
+ const n = Number(this.s.slice(start, this.pos));
734
+ if (!Number.isFinite(n)) return null;
735
+ const unitStart = this.pos;
736
+ while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
737
+ const unit = this.s.slice(unitStart, this.pos);
738
+ switch (unit) {
739
+ case "":
740
+ return n;
741
+ case "px":
742
+ return n;
743
+ case "rem":
744
+ return n * 16;
745
+ default:
746
+ return null;
747
+ }
748
+ }
749
+ };
750
+
751
+ // src/layoutCalc.ts
752
+ var NEG = (v) => ({ percent: -v.percent, px: -v.px });
753
+ var ADD = (a, b) => ({ percent: a.percent + b.percent, px: a.px + b.px });
754
+ var SUB = (a, b) => ({ percent: a.percent - b.percent, px: a.px - b.px });
755
+ function MUL(a, b) {
756
+ if (a.percent === 0) return { percent: b.percent * a.px, px: b.px * a.px };
757
+ if (b.percent === 0) return { percent: a.percent * b.px, px: a.px * b.px };
758
+ return null;
759
+ }
760
+ function DIV(a, b) {
761
+ if (b.percent !== 0 || b.px === 0) return null;
762
+ return { percent: a.percent / b.px, px: a.px / b.px };
763
+ }
764
+ var PercentAwareEvaluator = class {
765
+ constructor(s) {
766
+ this.pos = 0;
767
+ this.s = s;
768
+ }
769
+ parseExprToEnd() {
770
+ const value = this.expr();
771
+ if (value === null) return null;
772
+ this.skipWs();
773
+ return this.pos === this.s.length ? value : null;
774
+ }
775
+ skipWs() {
776
+ while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
777
+ }
778
+ peek() {
779
+ this.skipWs();
780
+ return this.s[this.pos];
781
+ }
782
+ expr() {
783
+ let value = this.term();
784
+ if (value === null) return null;
785
+ for (; ; ) {
786
+ const ch = this.peek();
787
+ if (ch === "+") {
788
+ this.pos++;
789
+ const rhs = this.term();
790
+ if (rhs === null) return null;
791
+ value = ADD(value, rhs);
792
+ } else if (ch === "-") {
793
+ this.pos++;
794
+ const rhs = this.term();
795
+ if (rhs === null) return null;
796
+ value = SUB(value, rhs);
797
+ } else {
798
+ return value;
799
+ }
800
+ }
801
+ }
802
+ term() {
803
+ let value = this.factor();
804
+ if (value === null) return null;
805
+ for (; ; ) {
806
+ const ch = this.peek();
807
+ if (ch === "*") {
808
+ this.pos++;
809
+ const rhs = this.factor();
810
+ if (rhs === null) return null;
811
+ const result = MUL(value, rhs);
812
+ if (result === null) return null;
813
+ value = result;
814
+ } else if (ch === "/") {
815
+ this.pos++;
816
+ const rhs = this.factor();
817
+ if (rhs === null) return null;
818
+ const result = DIV(value, rhs);
819
+ if (result === null) return null;
820
+ value = result;
821
+ } else {
822
+ return value;
823
+ }
824
+ }
825
+ }
826
+ factor() {
827
+ const ch = this.peek();
828
+ if (ch === void 0) return null;
829
+ if (ch === "(") {
830
+ this.pos++;
831
+ const value = this.expr();
832
+ if (value === null || this.peek() !== ")") return null;
833
+ this.pos++;
834
+ return value;
835
+ }
836
+ if (ch === "-") {
837
+ this.pos++;
838
+ const value = this.factor();
839
+ return value === null ? null : NEG(value);
840
+ }
841
+ return this.numberWithUnit();
842
+ }
843
+ numberWithUnit() {
844
+ this.skipWs();
845
+ const start = this.pos;
846
+ while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
847
+ if (this.pos === start) return null;
848
+ const n = Number(this.s.slice(start, this.pos));
849
+ if (!Number.isFinite(n)) return null;
850
+ if (this.s[this.pos] === "%") {
851
+ this.pos++;
852
+ return { percent: n, px: 0 };
853
+ }
854
+ const unitStart = this.pos;
855
+ while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
856
+ const unit = this.s.slice(unitStart, this.pos);
857
+ switch (unit) {
858
+ case "":
859
+ return { percent: 0, px: n };
860
+ case "px":
861
+ return { percent: 0, px: n };
862
+ case "rem":
863
+ return { percent: 0, px: n * 16 };
864
+ default:
865
+ return null;
866
+ }
867
+ }
868
+ };
869
+ var PERCENT_TOKEN_OUTER_RE = /^(w|h)-\[(.+)\]$/;
870
+ function parsePercentRelativeCalc(token) {
871
+ const m = PERCENT_TOKEN_OUTER_RE.exec(token);
872
+ if (!m) return null;
873
+ const property = m[1] === "w" ? "width" : "height";
874
+ const inner = stripCall(m[2].replace(/_/g, " ").trim(), "calc");
875
+ if (inner === null) return null;
876
+ const result = new PercentAwareEvaluator(inner).parseExprToEnd();
877
+ if (result === null || result.percent === 0) return null;
878
+ return { property, percentCoefficient: result.percent, constantPx: result.px };
879
+ }
880
+ function resolvePercentRelativeCalc(basisPx, calc) {
881
+ return basisPx * calc.percentCoefficient / 100 + calc.constantPx;
882
+ }
883
+ function parsePercentRelativeMinMaxClamp(token) {
884
+ const m = PERCENT_TOKEN_OUTER_RE.exec(token);
885
+ if (!m) return null;
886
+ const property = m[1] === "w" ? "width" : "height";
887
+ const spaced = m[2].replace(/_/g, " ");
888
+ let kind;
889
+ let inner;
890
+ if ((inner = stripCall(spaced, "min")) !== null) kind = "min";
891
+ else if ((inner = stripCall(spaced, "max")) !== null) kind = "max";
892
+ else if ((inner = stripCall(spaced, "clamp")) !== null) kind = "clamp";
893
+ else return null;
894
+ const args = splitTopLevelCommas(inner);
895
+ if (kind === "clamp" && args.length !== 3) return null;
896
+ if (kind !== "clamp" && args.length < 1) return null;
897
+ const operands = args.map((arg) => new PercentAwareEvaluator(arg.trim()).parseExprToEnd());
898
+ if (operands.some((o) => o === null)) return null;
899
+ const resolved = operands;
900
+ if (!resolved.some((o) => o.percent !== 0)) return null;
901
+ return {
902
+ property,
903
+ resolve(basisPx) {
904
+ const values = resolved.map((o) => basisPx * o.percent / 100 + o.px);
905
+ if (kind === "min") return Math.min(...values);
906
+ if (kind === "max") return Math.max(...values);
907
+ const [min, preferred, max] = values;
908
+ return Math.max(min, Math.min(preferred, max));
909
+ }
910
+ };
911
+ }
912
+ function parsePercentRelativeExpr(token) {
913
+ const calc = parsePercentRelativeCalc(token);
914
+ if (calc) return { property: calc.property, resolve: (basisPx) => resolvePercentRelativeCalc(basisPx, calc) };
915
+ return parsePercentRelativeMinMaxClamp(token);
916
+ }
917
+
918
+ // src/jsxRuntimeCore.ts
919
+ var DYNAMIC_TOKEN_MATCH_RE = /var\(--([a-zA-Z0-9-]+)\)/g;
920
+ function substituteDynamicTokens(classStrRaw) {
921
+ if (!classStrRaw.includes("var(--")) return classStrRaw;
922
+ return classStrRaw.replace(DYNAMIC_TOKEN_MATCH_RE, (whole, name) => {
923
+ const value = (0, import_dynamicTokens.getDynamicToken)(name);
924
+ return value ?? whole;
925
+ });
926
+ }
927
+ var PERCENT_RELATIVE_CALC_HINT_RE = /[wh]-\[(calc|min|max|clamp)\(.*%.*\)\]/;
928
+ function extractPercentRelativeCalcs(classStrRaw) {
929
+ const found = [];
930
+ for (const token of classStrRaw.split(/\s+/)) {
931
+ const parsed = parsePercentRelativeExpr(token);
932
+ if (parsed) found.push(parsed);
933
+ }
934
+ return found;
935
+ }
936
+ function stripPercentRelativeCalcTokens(classStrRaw) {
937
+ return classStrRaw.split(/\s+/).filter((token) => token && parsePercentRelativeExpr(token) === null).join(" ");
938
+ }
939
+ var STATE_MODIFIER_NAMES = /* @__PURE__ */ new Set(["hover", "focus", "disabled"]);
940
+ var STATIC_ARIA_SHORTCUT_NAMES = /* @__PURE__ */ new Set([
941
+ "aria-checked",
942
+ "aria-disabled",
943
+ "aria-expanded",
944
+ "aria-hidden",
945
+ "aria-pressed",
946
+ "aria-readonly",
947
+ "aria-required",
948
+ "aria-selected",
949
+ "aria-busy"
950
+ ]);
951
+ var STATE_MODIFIER_HINT_RE = /(^|\s|:)(hover|focus|disabled|aria-checked|aria-disabled|aria-expanded|aria-hidden|aria-pressed|aria-readonly|aria-required|aria-selected|aria-busy):|data-\[|aria-\[/;
952
+ function bracketContent(name, prefix) {
953
+ if (!name.startsWith(prefix)) return null;
954
+ const rest = name.slice(prefix.length);
955
+ if (!rest.startsWith("[") || !rest.endsWith("]")) return null;
956
+ return rest.slice(1, -1);
957
+ }
958
+ function evalAttrCondition(hostRest, attrPrefix, inner) {
959
+ const eqIdx = inner.indexOf("=");
960
+ if (eqIdx === -1) return Boolean(hostRest[`${attrPrefix}${inner}`]);
961
+ const key = inner.slice(0, eqIdx);
962
+ const value = inner.slice(eqIdx + 1);
963
+ return String(hostRest[`${attrPrefix}${key}`]) === value;
964
+ }
965
+ function isAriaTruthy(value) {
966
+ return value === true || value === "true";
967
+ }
968
+ function propBasedModifierState(name, states, hostRest) {
969
+ if (STATE_MODIFIER_NAMES.has(name)) return states[name];
970
+ if (STATIC_ARIA_SHORTCUT_NAMES.has(name)) return isAriaTruthy(hostRest[name]);
971
+ const dataInner = bracketContent(name, "data-");
972
+ if (dataInner !== null) return evalAttrCondition(hostRest, "data-", dataInner);
973
+ const ariaInner = bracketContent(name, "aria-");
974
+ if (ariaInner !== null) return evalAttrCondition(hostRest, "aria-", ariaInner);
975
+ return null;
976
+ }
977
+ var STATE_HOLD_MARKER = "_kbon";
978
+ function markSatisfiedStateModifiers(parts, namesToReplace) {
979
+ const utility = parts[parts.length - 1] ?? "";
980
+ const modifiers = parts.slice(0, -1).map((m) => namesToReplace.has(m) ? STATE_HOLD_MARKER : m);
981
+ return [...modifiers, utility].join(":");
982
+ }
983
+ function substituteStateModifiers(classStrRaw, states, hostRest) {
984
+ if (!STATE_MODIFIER_HINT_RE.test(classStrRaw)) return classStrRaw;
985
+ const kept = [];
986
+ for (const token of classStrRaw.split(/\s+/)) {
987
+ if (!token) continue;
988
+ const parts = splitRespectingBrackets(token);
989
+ const modifiers = parts.slice(0, -1);
990
+ const resolved = modifiers.map((m) => [m, propBasedModifierState(m, states, hostRest)]);
991
+ const required = resolved.filter(([, v]) => v !== null);
992
+ if (required.length === 0) {
993
+ kept.push(token);
994
+ continue;
995
+ }
996
+ if (required.every(([, v]) => v === true)) {
997
+ const requiredNames = new Set(required.map(([m]) => m));
998
+ kept.push(markSatisfiedStateModifiers(parts, requiredNames));
999
+ }
1000
+ }
1001
+ return kept.join(" ");
1002
+ }
1003
+ function makeElement(isStaticChildren, type, props, key) {
1004
+ return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
1005
+ }
1006
+ function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed, hostRest, layoutOverrides, states = { hover: false, focus: false, disabled: false }) {
1007
+ const stateResolved = substituteStateModifiers(classStrRaw, states, hostRest);
1008
+ const cleaned = stripPercentRelativeCalcTokens(substituteDynamicTokens(stateResolved));
1009
+ const resolved = resolveStyle2(cleaned, pressed);
1010
+ if (layoutOverrides) {
1011
+ Object.assign(resolved, layoutOverrides);
1012
+ }
1013
+ if (userStyle === void 0) {
1014
+ return resolved;
1015
+ }
1016
+ if (typeof userStyle === "function") {
1017
+ return [resolved, userStyle({ pressed })];
1018
+ }
1019
+ return [resolved, userStyle];
1020
+ }
1021
+ var DARK_MODIFIER_RE = /(^|\s|:)dark:/;
1022
+ var BREAKPOINT_MODIFIER_RE = /(^|\s|:)(sm|md|lg|xl|2xl):|(^|\s|:)(min|max)-\[[^\]]*\]:/;
1023
+ var HOVER_MODIFIER_RE = /(^|\s|:)hover:/;
1024
+ var FOCUS_MODIFIER_RE = /(^|\s|:)focus:/;
1025
+ function usesModeAwareColor(classStrRaw) {
1026
+ return classStringUsesModeAwareColor(classStrRaw, (0, import_theme.getTheme)());
1027
+ }
1028
+ function ReactiveElement({
1029
+ hostType,
1030
+ hostRest,
1031
+ classStrRaw,
1032
+ userStyle,
1033
+ resolveStyle: resolveStyle2,
1034
+ elementKey,
1035
+ isStaticChildren
1036
+ }) {
1037
+ (0, import_react.useSyncExternalStore)(import_darkModeStore.subscribeGlobalDarkMode, import_darkModeStore.getGlobalDarkMode);
1038
+ (0, import_react.useSyncExternalStore)(import_dynamicTokens.subscribeDynamicTokens, import_dynamicTokens.getDynamicTokensVersion);
1039
+ const windowSize = (0, import_react_native.useWindowDimensions)();
1040
+ const [measuredBasis, setMeasuredBasis] = (0, import_react.useState)(null);
1041
+ const lastWindowSizeRef = (0, import_react.useRef)(windowSize);
1042
+ if (lastWindowSizeRef.current.width !== windowSize.width || lastWindowSizeRef.current.height !== windowSize.height) {
1043
+ lastWindowSizeRef.current = windowSize;
1044
+ if (measuredBasis !== null) {
1045
+ setMeasuredBasis(null);
1046
+ }
1047
+ }
1048
+ const measure = (0, import_react.useCallback)((e) => {
1049
+ const { width: w, height: h } = e.nativeEvent.layout;
1050
+ setMeasuredBasis((prev) => prev === null ? { width: w, height: h } : prev);
1051
+ }, []);
1052
+ const [isHovered, setIsHovered] = (0, import_react.useState)(false);
1053
+ const [isFocused, setIsFocused] = (0, import_react.useState)(false);
1054
+ const percentCalcs = extractPercentRelativeCalcs(classStrRaw);
1055
+ let layoutOverrides;
1056
+ let hostRestWithLayout = hostRest;
1057
+ if (percentCalcs.length > 0) {
1058
+ layoutOverrides = {};
1059
+ for (const calc of percentCalcs) {
1060
+ const basis = measuredBasis?.[calc.property];
1061
+ layoutOverrides[calc.property] = basis === void 0 ? "100%" : calc.resolve(basis);
1062
+ }
1063
+ const userOnLayout = hostRest.onLayout;
1064
+ hostRestWithLayout = {
1065
+ ...hostRest,
1066
+ onLayout: userOnLayout ? (e) => {
1067
+ measure(e);
1068
+ userOnLayout(e);
1069
+ } : measure
1070
+ };
1071
+ }
1072
+ if (HOVER_MODIFIER_RE.test(classStrRaw)) {
1073
+ const userOnHoverIn = hostRestWithLayout.onHoverIn;
1074
+ const userOnHoverOut = hostRestWithLayout.onHoverOut;
1075
+ hostRestWithLayout = {
1076
+ ...hostRestWithLayout,
1077
+ onHoverIn: (e) => {
1078
+ setIsHovered(true);
1079
+ userOnHoverIn?.(e);
1080
+ },
1081
+ onHoverOut: (e) => {
1082
+ setIsHovered(false);
1083
+ userOnHoverOut?.(e);
1084
+ }
1085
+ };
1086
+ }
1087
+ if (FOCUS_MODIFIER_RE.test(classStrRaw)) {
1088
+ const userOnFocus = hostRestWithLayout.onFocus;
1089
+ const userOnBlur = hostRestWithLayout.onBlur;
1090
+ hostRestWithLayout = {
1091
+ ...hostRestWithLayout,
1092
+ onFocus: (e) => {
1093
+ setIsFocused(true);
1094
+ userOnFocus?.(e);
1095
+ },
1096
+ onBlur: (e) => {
1097
+ setIsFocused(false);
1098
+ userOnBlur?.(e);
1099
+ }
1100
+ };
1101
+ }
1102
+ const states = { hover: isHovered, focus: isFocused, disabled: hostRest.disabled === true };
1103
+ const finalStyle = hostType === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed, hostRest, layoutOverrides, states) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false, hostRest, layoutOverrides, states);
1104
+ return makeElement(
1105
+ isStaticChildren,
1106
+ hostType,
1107
+ { ...hostRestWithLayout, className: classStrRaw, style: finalStyle },
1108
+ elementKey
1109
+ );
1110
+ }
1111
+ function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
1112
+ if (type === null || typeof type === "symbol" || !rawProps) {
1113
+ return makeElement(isStaticChildren, type, rawProps ?? {}, key);
1114
+ }
1115
+ const { className: classStrRaw, style: userStyle, ...rest } = rawProps;
1116
+ if (typeof classStrRaw !== "string") {
1117
+ return makeElement(isStaticChildren, type, rawProps, key);
1118
+ }
1119
+ if (DARK_MODIFIER_RE.test(classStrRaw) || BREAKPOINT_MODIFIER_RE.test(classStrRaw) || HOVER_MODIFIER_RE.test(classStrRaw) || FOCUS_MODIFIER_RE.test(classStrRaw) || classStrRaw.includes("var(--") || PERCENT_RELATIVE_CALC_HINT_RE.test(classStrRaw) || usesModeAwareColor(classStrRaw)) {
1120
+ return (0, import_jsx_runtime.jsx)(
1121
+ ReactiveElement,
1122
+ { hostType: type, hostRest: rest, classStrRaw, userStyle, resolveStyle: resolveStyle2, elementKey: key, isStaticChildren },
1123
+ key
1124
+ );
1125
+ }
1126
+ const staticStates = { hover: false, focus: false, disabled: rest.disabled === true };
1127
+ const finalStyle = type === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed, rest, void 0, staticStates) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false, rest, void 0, staticStates);
1128
+ return makeElement(isStaticChildren, type, { ...rest, className: classStrRaw, style: finalStyle }, key);
1129
+ }
1130
+ function createJsxFunctions(resolveStyle2) {
1131
+ function jsx2(type, props, key) {
1132
+ return processElement(resolveStyle2, type, props, key, false);
1133
+ }
1134
+ function jsxs2(type, props, key) {
1135
+ return processElement(resolveStyle2, type, props, key, true);
1136
+ }
1137
+ return { jsx: jsx2, jsxs: jsxs2 };
1138
+ }
1139
+
1140
+ // src/nativeBridge.ts
1141
+ var import_react_native2 = require("react-native");
1142
+ var import_theme2 = require("./theme");
1143
+ var import_darkModeStore2 = require("./darkModeStore");
1144
+
681
1145
  // src/jsEngine/shared.ts
682
1146
  function decl(property, value) {
683
1147
  return { property, value };
684
1148
  }
1149
+ function spacingPx(theme, value) {
1150
+ const fromTable = theme.spacing[value];
1151
+ if (fromTable !== void 0) return fromTable;
1152
+ if (value === "px") return 1;
1153
+ const n = Number(value);
1154
+ return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
1155
+ }
685
1156
  function resolveLength(theme, parsed) {
686
1157
  if (parsed.negative) return null;
687
1158
  const value = parsed.value;
@@ -689,24 +1160,87 @@ function resolveLength(theme, parsed) {
689
1160
  if (parsed.isArbitrary) return value;
690
1161
  if (value === "full") return "100%";
691
1162
  if (value === "auto") return "auto";
692
- const px = theme.spacing[value];
1163
+ const px = spacingPx(theme, value);
693
1164
  return px === void 0 ? null : `${px}px`;
694
1165
  }
695
1166
  function resolveNegatableLength(theme, parsed) {
696
1167
  if (!parsed.negative) return resolveLength(theme, parsed);
697
- if (parsed.isArbitrary) return null;
1168
+ if (parsed.isArbitrary) {
1169
+ const value2 = parsed.value;
1170
+ return value2 === null ? null : `calc(${value2} * -1)`;
1171
+ }
698
1172
  const value = parsed.value;
699
1173
  if (value === null) return null;
700
- const px = theme.spacing[value];
1174
+ const px = spacingPx(theme, value);
701
1175
  if (px === void 0) return null;
702
1176
  if (px === 0) return "0px";
703
1177
  return `-${px}px`;
704
1178
  }
1179
+ function fractionPercent(value) {
1180
+ const slashIdx = value.indexOf("/");
1181
+ if (slashIdx === -1) return null;
1182
+ const numStr = value.slice(0, slashIdx);
1183
+ const denStr = value.slice(slashIdx + 1);
1184
+ const num = Number(numStr);
1185
+ const den = Number(denStr);
1186
+ if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
1187
+ if (den === 0) return null;
1188
+ const pct = num / den * 100;
1189
+ const formatted = pct.toFixed(6);
1190
+ const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
1191
+ return `${trimmed}%`;
1192
+ }
1193
+ function resolveNegatableSize(theme, parsed) {
1194
+ if (!parsed.isArbitrary && parsed.value !== null) {
1195
+ if (parsed.negative && parsed.value === "full") return "-100%";
1196
+ const pct = fractionPercent(parsed.value);
1197
+ if (pct !== null) return parsed.negative ? `-${pct}` : pct;
1198
+ }
1199
+ return resolveNegatableLength(theme, parsed);
1200
+ }
1201
+ function negate(value) {
1202
+ const numeric = (v) => /^[\d.]/.test(v);
1203
+ if (value.startsWith("-")) return numeric(value.slice(1)) ? value.slice(1) : `calc(${value} * -1)`;
1204
+ return numeric(value) ? `-${value}` : `calc(${value} * -1)`;
1205
+ }
1206
+ function resolvePercent(parsed) {
1207
+ if (parsed.negative) return null;
1208
+ const value = parsed.value;
1209
+ if (value === null) return null;
1210
+ if (parsed.isArbitrary) return value;
1211
+ const pct = Number(value);
1212
+ if (!Number.isFinite(pct) || value.trim() === "") return null;
1213
+ return String(pct / 100);
1214
+ }
705
1215
 
706
1216
  // src/jsEngine/resolvers/layout.ts
707
1217
  function negateRaw(value, negative) {
708
1218
  return negative ? `-${value}` : value;
709
1219
  }
1220
+ var WHOLE = /^\d+$/;
1221
+ var PLAIN_NUMBER = /^(?:\d+\.?\d*|\.\d+)$/;
1222
+ function overflowAxisValue(property, value) {
1223
+ switch (value) {
1224
+ case "auto":
1225
+ case "hidden":
1226
+ case "clip":
1227
+ case "visible":
1228
+ case "scroll":
1229
+ return [decl(property, value)];
1230
+ default:
1231
+ return null;
1232
+ }
1233
+ }
1234
+ function overscrollValue(property, value) {
1235
+ switch (value) {
1236
+ case "auto":
1237
+ case "contain":
1238
+ case "none":
1239
+ return [decl(property, value)];
1240
+ default:
1241
+ return null;
1242
+ }
1243
+ }
710
1244
  function resolve(parsed, theme) {
711
1245
  switch (parsed.utility) {
712
1246
  case "flex":
@@ -753,6 +1287,12 @@ function resolve(parsed, theme) {
753
1287
  return [decl("justify-content", "space-around")];
754
1288
  case "justify-evenly":
755
1289
  return [decl("justify-content", "space-evenly")];
1290
+ case "justify-normal":
1291
+ return [decl("justify-content", "normal")];
1292
+ case "justify-stretch":
1293
+ return [decl("justify-content", "stretch")];
1294
+ case "content-normal":
1295
+ return [decl("align-content", "normal")];
756
1296
  case "content-start":
757
1297
  return [decl("align-content", "flex-start")];
758
1298
  case "content-end":
@@ -787,6 +1327,18 @@ function resolve(parsed, theme) {
787
1327
  return [decl("overflow", "scroll")];
788
1328
  case "overflow-visible":
789
1329
  return [decl("overflow", "visible")];
1330
+ case "overflow-clip":
1331
+ return [decl("overflow", "clip")];
1332
+ case "overflow-x":
1333
+ return parsed.value === null ? null : overflowAxisValue("overflow-x", parsed.value);
1334
+ case "overflow-y":
1335
+ return parsed.value === null ? null : overflowAxisValue("overflow-y", parsed.value);
1336
+ case "overscroll":
1337
+ return parsed.value === null ? null : overscrollValue("overscroll-behavior", parsed.value);
1338
+ case "overscroll-x":
1339
+ return parsed.value === null ? null : overscrollValue("overscroll-behavior-x", parsed.value);
1340
+ case "overscroll-y":
1341
+ return parsed.value === null ? null : overscrollValue("overscroll-behavior-y", parsed.value);
790
1342
  case "static":
791
1343
  return [decl("position", "static")];
792
1344
  case "relative":
@@ -797,40 +1349,91 @@ function resolve(parsed, theme) {
797
1349
  return [decl("position", "fixed")];
798
1350
  case "sticky":
799
1351
  return [decl("position", "sticky")];
800
- case "z":
801
- return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
802
- case "order":
803
- return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
1352
+ // Only real values, mirroring layout.rs: a whole number, z-auto, the
1353
+ // order-first/-last/-none keywords, or an arbitrary [...]. Anything
1354
+ // else used to pass straight through (z-banana -> z-index: banana).
1355
+ case "z": {
1356
+ const v = parsed.value;
1357
+ if (v === null || !(parsed.isArbitrary || v === "auto" || WHOLE.test(v))) return null;
1358
+ return [decl("z-index", negateRaw(v, parsed.negative))];
1359
+ }
1360
+ case "order": {
1361
+ const v = parsed.value;
1362
+ if (v === null) return null;
1363
+ if (v === "first") return [decl("order", "-9999")];
1364
+ if (v === "last") return [decl("order", "9999")];
1365
+ if (v === "none") return [decl("order", "0")];
1366
+ if (!(parsed.isArbitrary || WHOLE.test(v))) return null;
1367
+ return [decl("order", negateRaw(v, parsed.negative))];
1368
+ }
804
1369
  case "grow":
805
- return [decl("flex-grow", parsed.value ?? "1")];
806
- case "shrink":
807
- return [decl("flex-shrink", parsed.value ?? "1")];
1370
+ case "shrink": {
1371
+ const v = parsed.value ?? "1";
1372
+ if (!(parsed.isArbitrary || PLAIN_NUMBER.test(v))) return null;
1373
+ return [decl(parsed.utility === "grow" ? "flex-grow" : "flex-shrink", v)];
1374
+ }
808
1375
  // top/right/bottom/left/inset support real Tailwind's negative-value
809
- // convention ("-top-4") — see resolveNegatableLength's own doc comment.
1376
+ // convention ("-top-4") AND its percentage-fraction scale ("top-1/2",
1377
+ // "-inset-1/3") — see resolveNegatableSize's own doc comment.
810
1378
  case "top": {
811
- const v = resolveNegatableLength(theme, parsed);
1379
+ const v = resolveNegatableSize(theme, parsed);
812
1380
  return v === null ? null : [decl("top", v)];
813
1381
  }
814
1382
  case "right": {
815
- const v = resolveNegatableLength(theme, parsed);
1383
+ const v = resolveNegatableSize(theme, parsed);
816
1384
  return v === null ? null : [decl("right", v)];
817
1385
  }
818
1386
  case "bottom": {
819
- const v = resolveNegatableLength(theme, parsed);
1387
+ const v = resolveNegatableSize(theme, parsed);
820
1388
  return v === null ? null : [decl("bottom", v)];
821
1389
  }
822
1390
  case "left": {
823
- const v = resolveNegatableLength(theme, parsed);
1391
+ const v = resolveNegatableSize(theme, parsed);
824
1392
  return v === null ? null : [decl("left", v)];
825
1393
  }
826
1394
  case "inset": {
827
- const v = resolveNegatableLength(theme, parsed);
1395
+ const v = resolveNegatableSize(theme, parsed);
828
1396
  return v === null ? null : [decl("inset", v)];
829
1397
  }
830
- case "aspect-square":
831
- return [decl("aspect-ratio", "1 / 1")];
832
- case "aspect-video":
833
- return [decl("aspect-ratio", "16 / 9")];
1398
+ case "inset-x": {
1399
+ const v = resolveNegatableSize(theme, parsed);
1400
+ return v === null ? null : [decl("left", v), decl("right", v)];
1401
+ }
1402
+ case "inset-y": {
1403
+ const v = resolveNegatableSize(theme, parsed);
1404
+ return v === null ? null : [decl("top", v), decl("bottom", v)];
1405
+ }
1406
+ // Logical inset — just a different CSS property name, same reasoning
1407
+ // as Rust's layout.rs (no direction-tracking logic needed here).
1408
+ case "start": {
1409
+ const v = resolveNegatableSize(theme, parsed);
1410
+ return v === null ? null : [decl("inset-inline-start", v)];
1411
+ }
1412
+ case "end": {
1413
+ const v = resolveNegatableSize(theme, parsed);
1414
+ return v === null ? null : [decl("inset-inline-end", v)];
1415
+ }
1416
+ // "aspect-" is a registered VALUE_PREFIXES entry (parser.ts), so
1417
+ // "aspect-square"/"aspect-video"/"aspect-auto"/arbitrary all arrive
1418
+ // here as utility="aspect" + a value, mirroring layout.rs's own
1419
+ // "aspect" arm.
1420
+ case "aspect": {
1421
+ const value = parsed.value;
1422
+ if (value === null) return null;
1423
+ if (parsed.isArbitrary) return [decl("aspect-ratio", value)];
1424
+ switch (value) {
1425
+ case "square":
1426
+ return [decl("aspect-ratio", "1 / 1")];
1427
+ case "video":
1428
+ return [decl("aspect-ratio", "16 / 9")];
1429
+ case "auto":
1430
+ return [decl("aspect-ratio", "auto")];
1431
+ default: {
1432
+ const m = /^(\d+(?:\.\d*)?|\.\d+)\/(\d+(?:\.\d*)?|\.\d+)$/.exec(value);
1433
+ return m ? [decl("aspect-ratio", `${m[1]} / ${m[2]}`)] : null;
1434
+ }
1435
+ }
1436
+ }
834
1437
  default:
835
1438
  return null;
836
1439
  }
@@ -872,7 +1475,7 @@ function resolveFlex(parsed, web) {
872
1475
  case "shrink-0":
873
1476
  return [decl("flex-shrink", "0")];
874
1477
  default:
875
- return null;
1478
+ return /^\d+$/.test(value) ? [decl("flex", value)] : null;
876
1479
  }
877
1480
  }
878
1481
 
@@ -907,20 +1510,6 @@ function namedSize(key) {
907
1510
  return null;
908
1511
  }
909
1512
  }
910
- function fractionPercent(value) {
911
- const slashIdx = value.indexOf("/");
912
- if (slashIdx === -1) return null;
913
- const numStr = value.slice(0, slashIdx);
914
- const denStr = value.slice(slashIdx + 1);
915
- const num = Number(numStr);
916
- const den = Number(denStr);
917
- if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
918
- if (den === 0) return null;
919
- const pct = num / den * 100;
920
- const formatted = pct.toFixed(6);
921
- const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
922
- return `${trimmed}%`;
923
- }
924
1513
  function cssSizeKeyword(key) {
925
1514
  switch (key) {
926
1515
  case "min":
@@ -1054,18 +1643,16 @@ function resolve2(parsed, theme) {
1054
1643
  }
1055
1644
  }
1056
1645
 
1057
- // src/jsEngine/resolvers/color.ts
1058
- function lookupHex(theme, key) {
1059
- return theme.colors[key] ?? null;
1060
- }
1061
-
1062
1646
  // src/jsEngine/resolvers/border.ts
1063
1647
  function radiusSize(key) {
1064
1648
  switch (key) {
1065
1649
  case "none":
1066
1650
  return "0px";
1067
- case "sm":
1651
+ // Tailwind v4.3's radius scale: `sm` is 0.25rem (v3's 0.125rem is `xs`).
1652
+ case "xs":
1068
1653
  return "0.125rem";
1654
+ case "sm":
1655
+ return "0.25rem";
1069
1656
  case "md":
1070
1657
  return "0.375rem";
1071
1658
  case "lg":
@@ -1076,12 +1663,19 @@ function radiusSize(key) {
1076
1663
  return "1rem";
1077
1664
  case "3xl":
1078
1665
  return "1.5rem";
1666
+ case "4xl":
1667
+ return "2rem";
1079
1668
  case "full":
1080
1669
  return "9999px";
1081
1670
  default:
1082
1671
  return null;
1083
1672
  }
1084
1673
  }
1674
+ function borderWidthPx(parsed) {
1675
+ if (parsed.negative || parsed.isArbitrary || parsed.value === null) return null;
1676
+ const n = Number(parsed.value);
1677
+ return Number.isFinite(n) && n >= 0 && parsed.value.trim() !== "" ? `${n}px` : null;
1678
+ }
1085
1679
  function borderSideProperty(side) {
1086
1680
  switch (side) {
1087
1681
  case "t":
@@ -1104,49 +1698,68 @@ function borderValue(theme, parsed) {
1104
1698
  if (side !== null) {
1105
1699
  return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
1106
1700
  }
1701
+ const pair = value === "x" ? ["border-left", "border-right"] : value === "y" ? ["border-top", "border-bottom"] : null;
1702
+ if (pair !== null) {
1703
+ return [
1704
+ decl(`${pair[0]}-width`, "1px"),
1705
+ decl(`${pair[1]}-width`, "1px"),
1706
+ decl(`${pair[0]}-style`, "solid"),
1707
+ decl(`${pair[1]}-style`, "solid")
1708
+ ];
1709
+ }
1107
1710
  if (value === "collapse") return [decl("border-collapse", "collapse")];
1108
1711
  if (value === "separate") return [decl("border-collapse", "separate")];
1109
1712
  }
1110
1713
  if (parsed.isArbitrary) {
1111
- return [decl("border-width", value)];
1714
+ if (isLength(parsed, value)) return [decl("border-width", value)];
1715
+ const color2 = colorValue(theme, parsed);
1716
+ return color2 === null ? null : [decl("border-color", color2)];
1112
1717
  }
1113
1718
  if (Number.isFinite(Number(value)) && value.trim() !== "") {
1114
- const v = resolveLength(theme, parsed);
1719
+ const v = borderWidthPx(parsed);
1115
1720
  return v === null ? null : [decl("border-width", v)];
1116
1721
  }
1117
1722
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1118
1723
  return [decl("border-style", value)];
1119
1724
  }
1120
- const hex = lookupHex(theme, value);
1121
- return hex === null ? null : [decl("border-color", hex)];
1725
+ const color = colorValue(theme, parsed);
1726
+ return color === null ? null : [decl("border-color", color)];
1122
1727
  }
1123
1728
  function borderSideValue(theme, parsed, sideProperty) {
1124
1729
  const value = parsed.value;
1125
1730
  if (value === null) return null;
1126
- if (parsed.isArbitrary) return [decl(`${sideProperty}-width`, value)];
1731
+ if (parsed.isArbitrary) {
1732
+ if (isLength(parsed, value)) return [decl(`${sideProperty}-width`, value)];
1733
+ const color2 = colorValue(theme, parsed);
1734
+ return color2 === null ? null : [decl(`${sideProperty}-color`, color2)];
1735
+ }
1127
1736
  if (Number.isFinite(Number(value)) && value.trim() !== "") {
1128
- const v = resolveLength(theme, parsed);
1737
+ const v = borderWidthPx(parsed);
1129
1738
  return v === null ? null : [decl(`${sideProperty}-width`, v)];
1130
1739
  }
1131
1740
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1132
1741
  return [decl(`${sideProperty}-style`, value)];
1133
1742
  }
1134
- const hex = lookupHex(theme, value);
1135
- return hex === null ? null : [decl(`${sideProperty}-color`, hex)];
1743
+ const color = colorValue(theme, parsed);
1744
+ return color === null ? null : [decl(`${sideProperty}-color`, color)];
1136
1745
  }
1137
1746
  function borderAxisValue(theme, parsed, sideA, sideB) {
1138
1747
  const value = parsed.value;
1139
1748
  if (value === null) return null;
1140
- if (parsed.isArbitrary) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
1749
+ if (parsed.isArbitrary) {
1750
+ if (isLength(parsed, value)) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
1751
+ const color2 = colorValue(theme, parsed);
1752
+ return color2 === null ? null : [decl(`${sideA}-color`, color2), decl(`${sideB}-color`, color2)];
1753
+ }
1141
1754
  if (Number.isFinite(Number(value)) && value.trim() !== "") {
1142
- const v = resolveLength(theme, parsed);
1755
+ const v = borderWidthPx(parsed);
1143
1756
  return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
1144
1757
  }
1145
1758
  if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1146
1759
  return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
1147
1760
  }
1148
- const hex = lookupHex(theme, value);
1149
- return hex === null ? null : [decl(`${sideA}-color`, hex), decl(`${sideB}-color`, hex)];
1761
+ const color = colorValue(theme, parsed);
1762
+ return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
1150
1763
  }
1151
1764
  function radiusProperties(side) {
1152
1765
  switch (side) {
@@ -1186,79 +1799,28 @@ function resolveRadiusSide(theme, parsed, side) {
1186
1799
  }
1187
1800
  var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
1188
1801
  function outlineWidthValue(key) {
1189
- switch (key) {
1190
- case "0":
1191
- return "0px";
1192
- case "1":
1193
- return "1px";
1194
- case "2":
1195
- return "2px";
1196
- case "4":
1197
- return "4px";
1198
- case "8":
1199
- return "8px";
1200
- default:
1201
- return null;
1202
- }
1802
+ return /^\d+$/.test(key) ? `${Number(key)}px` : null;
1203
1803
  }
1204
1804
  function outlineValue(theme, parsed) {
1205
1805
  const value = parsed.value;
1206
1806
  if (value === null) return null;
1207
- if (parsed.isArbitrary) return [decl("outline-width", value)];
1807
+ if (parsed.isArbitrary) {
1808
+ if (isLength(parsed, value)) return [decl("outline-width", value)];
1809
+ const color2 = colorValue(theme, parsed);
1810
+ return color2 === null ? null : [decl("outline-color", color2)];
1811
+ }
1208
1812
  const w = outlineWidthValue(value);
1209
1813
  if (w !== null) return [decl("outline-width", w)];
1210
1814
  if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
1211
- const hex = lookupHex(theme, value);
1212
- return hex === null ? null : [decl("outline-color", hex)];
1815
+ const color = colorValue(theme, parsed);
1816
+ return color === null ? null : [decl("outline-color", color)];
1213
1817
  }
1214
1818
  function outlineOffsetValue(parsed) {
1215
1819
  const value = parsed.value;
1216
1820
  if (value === null) return null;
1217
- if (parsed.isArbitrary) return [decl("outline-offset", value)];
1218
- const w = outlineWidthValue(value);
1219
- return w === null ? null : [decl("outline-offset", w)];
1220
- }
1221
- var RING_BOX_SHADOW = "var(--kb-ring-inset,) 0 0 0 var(--kb-ring-offset-width, 0px) var(--kb-ring-offset-color, #fff), var(--kb-ring-inset,) 0 0 0 calc(var(--kb-ring-width, 0px) + var(--kb-ring-offset-width, 0px)) var(--kb-ring-color, rgba(59,130,246,0.5))";
1222
- function ringWidth(key) {
1223
- switch (key) {
1224
- case "0":
1225
- return "0px";
1226
- case "1":
1227
- return "1px";
1228
- case "2":
1229
- return "2px";
1230
- case "4":
1231
- return "4px";
1232
- case "8":
1233
- return "8px";
1234
- default:
1235
- return null;
1236
- }
1237
- }
1238
- function ringValue(theme, parsed) {
1239
- const value = parsed.value;
1240
- if (value === null) return null;
1241
- if (value === "inset") {
1242
- return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
1243
- }
1244
- if (!parsed.isArbitrary) {
1245
- const w = ringWidth(value);
1246
- if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
1247
- }
1248
- const color = parsed.isArbitrary ? value : lookupHex(theme, value);
1249
- if (color === null) return null;
1250
- return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
1251
- }
1252
- function ringOffsetValue(theme, parsed) {
1253
- const value = parsed.value;
1254
- if (value === null) return null;
1255
- if (!parsed.isArbitrary) {
1256
- const w = ringWidth(value);
1257
- if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
1258
- }
1259
- const color = parsed.isArbitrary ? value : lookupHex(theme, value);
1260
- if (color === null) return null;
1261
- return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
1821
+ const v = parsed.isArbitrary ? value : outlineWidthValue(value);
1822
+ if (v === null) return null;
1823
+ return [decl("outline-offset", parsed.negative ? negate(v) : v)];
1262
1824
  }
1263
1825
  var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
1264
1826
  function resolve3(parsed, theme) {
@@ -1288,14 +1850,19 @@ function resolve3(parsed, theme) {
1288
1850
  const v = resolveLength(theme, parsed);
1289
1851
  return v === null ? null : [decl("border-radius", v)];
1290
1852
  }
1853
+ // Rings are web-only (a var()-composed CSS box-shadow React Native can't
1854
+ // parse) — same as resolvers/mod.rs's native dispatcher.
1291
1855
  case "ring":
1292
- if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
1293
- return ringValue(theme, parsed);
1294
1856
  case "ring-offset":
1295
- return ringOffsetValue(theme, parsed);
1857
+ return null;
1858
+ // Outlines: the same final native style the Rust engine produces once
1859
+ // its var()-based web declarations are filtered out (resolve_style.rs):
1860
+ // bare `outline` is a 1px width, `outline-none` is outline-style: none,
1861
+ // `outline-hidden` keeps only its offset (RN has no `outline` shorthand).
1296
1862
  case "outline":
1297
- if (parsed.value === null) return [decl("outline-style", "solid")];
1298
- if (parsed.value === "none") return [decl("outline", "none")];
1863
+ if (parsed.value === null) return [decl("outline-width", "1px")];
1864
+ if (parsed.value === "none") return [decl("outline-style", "none")];
1865
+ if (!parsed.isArbitrary && parsed.value === "hidden") return [decl("outline-offset", "2px")];
1299
1866
  return outlineValue(theme, parsed);
1300
1867
  case "outline-offset":
1301
1868
  return outlineOffsetValue(parsed);
@@ -1326,32 +1893,75 @@ function textSize(key) {
1326
1893
  return "1.875rem";
1327
1894
  case "4xl":
1328
1895
  return "2.25rem";
1896
+ case "5xl":
1897
+ return "3rem";
1898
+ case "6xl":
1899
+ return "3.75rem";
1900
+ case "7xl":
1901
+ return "4.5rem";
1902
+ case "8xl":
1903
+ return "6rem";
1904
+ case "9xl":
1905
+ return "8rem";
1329
1906
  default:
1330
1907
  return null;
1331
1908
  }
1332
1909
  }
1333
1910
  function lineHeightSize(key) {
1911
+ if (key === "px") return "1px";
1912
+ if (key.trim() === "") return null;
1913
+ const n = Number(key);
1914
+ return Number.isFinite(n) && n >= 0 ? `${n * 0.25}rem` : null;
1915
+ }
1916
+ function leadingNamed(key) {
1334
1917
  switch (key) {
1335
- case "3":
1336
- return "0.75rem";
1337
- case "4":
1338
- return "1rem";
1339
- case "5":
1340
- return "1.25rem";
1341
- case "6":
1342
- return "1.5rem";
1343
- case "7":
1344
- return "1.75rem";
1345
- case "8":
1346
- return "2rem";
1347
- case "9":
1348
- return "2.25rem";
1349
- case "10":
1350
- return "2.5rem";
1918
+ case "none":
1919
+ return 1;
1920
+ case "tight":
1921
+ return 1.25;
1922
+ case "snug":
1923
+ return 1.375;
1924
+ case "normal":
1925
+ return 1.5;
1926
+ case "relaxed":
1927
+ return 1.625;
1928
+ case "loose":
1929
+ return 2;
1351
1930
  default:
1352
1931
  return null;
1353
1932
  }
1354
1933
  }
1934
+ function splitSizeLeading(value) {
1935
+ const i = value.indexOf("/");
1936
+ if (i === -1) return null;
1937
+ const size = textSize(value.slice(0, i));
1938
+ const leading = value.slice(i + 1);
1939
+ return size === null || leading === "" ? null : [size, leading];
1940
+ }
1941
+ function sizeLeadingNative(size, leading) {
1942
+ const rem = (n) => {
1943
+ const unit = size.endsWith("rem") ? "rem" : size.endsWith("px") ? "px" : null;
1944
+ if (unit === null) return null;
1945
+ const number = size.slice(0, -unit.length);
1946
+ const s = Number(number);
1947
+ return number.trim() !== "" && Number.isFinite(s) ? `${s * n}${unit}` : null;
1948
+ };
1949
+ const arbitrary = arbitraryModifier(leading);
1950
+ if (arbitrary !== null) {
1951
+ if (arbitrary.startsWith("var(")) return null;
1952
+ const n = Number(arbitrary);
1953
+ return arbitrary.trim() !== "" && Number.isFinite(n) ? rem(n) : arbitrary;
1954
+ }
1955
+ const scale = lineHeightSize(leading);
1956
+ if (scale !== null) return scale;
1957
+ const m = leadingNamed(leading);
1958
+ return m === null ? null : rem(m);
1959
+ }
1960
+ function arbitraryFontIsWeight(parsed, value) {
1961
+ const hint = parsed.typeHint ?? null;
1962
+ if (hint !== null) return hint === "number" || hint === "integer";
1963
+ return value.trim() !== "" && Number.isFinite(Number(value)) || value.startsWith("var(") && value.endsWith(")") && !value.includes(",");
1964
+ }
1355
1965
  function textAlign(key) {
1356
1966
  switch (key) {
1357
1967
  case "left":
@@ -1362,6 +1972,12 @@ function textAlign(key) {
1362
1972
  return "right";
1363
1973
  case "justify":
1364
1974
  return "justify";
1975
+ // Logical alignment — same "no direction-tracking logic needed" reasoning
1976
+ // as layout.rs's start/end inset properties.
1977
+ case "start":
1978
+ return "start";
1979
+ case "end":
1980
+ return "end";
1365
1981
  default:
1366
1982
  return null;
1367
1983
  }
@@ -1370,6 +1986,10 @@ function fontWeight(key) {
1370
1986
  switch (key) {
1371
1987
  case "thin":
1372
1988
  return "100";
1989
+ case "extralight":
1990
+ return "200";
1991
+ case "light":
1992
+ return "300";
1373
1993
  case "normal":
1374
1994
  return "400";
1375
1995
  case "medium":
@@ -1380,6 +2000,22 @@ function fontWeight(key) {
1380
2000
  return "700";
1381
2001
  case "extrabold":
1382
2002
  return "800";
2003
+ case "black":
2004
+ return "900";
2005
+ default:
2006
+ return null;
2007
+ }
2008
+ }
2009
+ function fontFamilyValue(theme, key) {
2010
+ const fromTheme = theme.fontFamily?.[key];
2011
+ if (fromTheme !== void 0) return fromTheme;
2012
+ switch (key) {
2013
+ case "sans":
2014
+ return 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
2015
+ case "serif":
2016
+ return 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif';
2017
+ case "mono":
2018
+ return 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
1383
2019
  default:
1384
2020
  return null;
1385
2021
  }
@@ -1388,8 +2024,14 @@ function fontWeight(key) {
1388
2024
  // src/jsEngine/resolvers/effects.ts
1389
2025
  function nativeShadowValue(key) {
1390
2026
  switch (key) {
1391
- case "sm":
2027
+ // Tailwind v4.3's scale, like effects.rs: `sm` is the default shadow,
2028
+ // v3's `sm` is `xs`.
2029
+ case "2xs":
2030
+ return { offsetY: 1, radius: 0, opacity: 0.05, elevation: 1 };
2031
+ case "xs":
1392
2032
  return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
2033
+ case "sm":
2034
+ return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
1393
2035
  case "DEFAULT":
1394
2036
  return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
1395
2037
  case "md":
@@ -1421,13 +2063,115 @@ function nativeShadowDeclarations(parsed) {
1421
2063
  ];
1422
2064
  }
1423
2065
 
2066
+ // src/jsEngine/resolvers/transform.ts
2067
+ function scaleFactor(parsed) {
2068
+ if (parsed.value === null || parsed.value.trim() === "") return null;
2069
+ const n = Number(parsed.value);
2070
+ if (!Number.isFinite(n)) return null;
2071
+ const factor = parsed.isArbitrary ? n : n / 100;
2072
+ return parsed.negative ? -factor : factor;
2073
+ }
2074
+ function angle(parsed) {
2075
+ if (parsed.value === null) return null;
2076
+ if (parsed.isArbitrary) {
2077
+ if (!parsed.negative) return parsed.value;
2078
+ if (parsed.value.startsWith("-")) return parsed.value.slice(1);
2079
+ if (/^[\d.]/.test(parsed.value)) return `-${parsed.value}`;
2080
+ return `calc(${parsed.value} * -1)`;
2081
+ }
2082
+ const n = Number(parsed.value);
2083
+ if (!Number.isFinite(n)) return null;
2084
+ return `${parsed.negative ? -n : n}deg`;
2085
+ }
2086
+ function resolveNative(parsed, theme) {
2087
+ switch (parsed.utility) {
2088
+ case "transform-none":
2089
+ return [decl("transform-op-none", "1")];
2090
+ // Both axes at once (`translate-4`, `-skew-3`); mirrors transform.rs.
2091
+ case "translate": {
2092
+ if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-translate-x", "0"), decl("transform-op-translate-y", "0")];
2093
+ const v = resolveNegatableSize(theme, parsed);
2094
+ return v === null ? null : [decl("transform-op-translate-x", v), decl("transform-op-translate-y", v)];
2095
+ }
2096
+ case "skew": {
2097
+ const deg = angle(parsed);
2098
+ return deg === null ? null : [decl("transform-op-skew-x", deg), decl("transform-op-skew-y", deg)];
2099
+ }
2100
+ case "backface-visible":
2101
+ return [decl("backface-visibility", "visible")];
2102
+ case "backface-hidden":
2103
+ return [decl("backface-visibility", "hidden")];
2104
+ case "translate-x": {
2105
+ const v = resolveNegatableSize(theme, parsed);
2106
+ return v === null ? null : [decl("transform-op-translate-x", v)];
2107
+ }
2108
+ case "translate-y": {
2109
+ const v = resolveNegatableSize(theme, parsed);
2110
+ return v === null ? null : [decl("transform-op-translate-y", v)];
2111
+ }
2112
+ case "scale": {
2113
+ if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-scale-x", "1"), decl("transform-op-scale-y", "1")];
2114
+ const n = scaleFactor(parsed);
2115
+ return n === null ? null : [decl("transform-op-scale-x", `${n}`), decl("transform-op-scale-y", `${n}`)];
2116
+ }
2117
+ case "scale-x": {
2118
+ const n = scaleFactor(parsed);
2119
+ return n === null ? null : [decl("transform-op-scale-x", `${n}`)];
2120
+ }
2121
+ case "scale-y": {
2122
+ const n = scaleFactor(parsed);
2123
+ return n === null ? null : [decl("transform-op-scale-y", `${n}`)];
2124
+ }
2125
+ case "rotate": {
2126
+ if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-rotate", "0deg")];
2127
+ const deg = angle(parsed);
2128
+ return deg === null ? null : [decl("transform-op-rotate", deg)];
2129
+ }
2130
+ case "rotate-x": {
2131
+ const deg = angle(parsed);
2132
+ return deg === null ? null : [decl("transform-op-rotate-x", deg)];
2133
+ }
2134
+ case "rotate-y": {
2135
+ const deg = angle(parsed);
2136
+ return deg === null ? null : [decl("transform-op-rotate-y", deg)];
2137
+ }
2138
+ case "rotate-z": {
2139
+ const deg = angle(parsed);
2140
+ return deg === null ? null : [decl("transform-op-rotate-z", deg)];
2141
+ }
2142
+ case "skew-x": {
2143
+ const deg = angle(parsed);
2144
+ return deg === null ? null : [decl("transform-op-skew-x", deg)];
2145
+ }
2146
+ case "skew-y": {
2147
+ const deg = angle(parsed);
2148
+ return deg === null ? null : [decl("transform-op-skew-y", deg)];
2149
+ }
2150
+ default:
2151
+ return null;
2152
+ }
2153
+ }
2154
+
1424
2155
  // src/jsEngine/resolveUtilityNative.ts
1425
- function resolveTypographyNative(parsed) {
2156
+ function firstFontName(stack) {
2157
+ const first = stack.split(",")[0] ?? stack;
2158
+ return first.trim().replace(/^["']|["']$/g, "");
2159
+ }
2160
+ function resolveTypographyNative(parsed, theme) {
1426
2161
  switch (parsed.utility) {
1427
2162
  case "font": {
1428
2163
  if (parsed.value === null) return null;
2164
+ if (parsed.isArbitrary) {
2165
+ if (arbitraryFontIsWeight(parsed, parsed.value)) {
2166
+ const n = Number(parsed.value);
2167
+ return /^\d+$/.test(parsed.value) && n % 100 === 0 && n >= 100 && n <= 900 ? [decl("font-weight", parsed.value)] : null;
2168
+ }
2169
+ return [decl("font-family", firstFontName(parsed.value))];
2170
+ }
1429
2171
  const w = fontWeight(parsed.value);
1430
- return w === null ? null : [decl("font-weight", w)];
2172
+ if (w !== null) return [decl("font-weight", w)];
2173
+ const family = fontFamilyValue(theme, parsed.value);
2174
+ return family === null ? null : [decl("font-family", firstFontName(family))];
1431
2175
  }
1432
2176
  case "uppercase":
1433
2177
  return [decl("text-transform", "uppercase")];
@@ -1463,16 +2207,27 @@ function resolveLeadingTrackingNative(parsed) {
1463
2207
  return null;
1464
2208
  }
1465
2209
  function nativeHexColor(parsed, theme) {
1466
- const value = parsed.value;
1467
- if (value === null) return null;
1468
- return parsed.isArbitrary ? value : lookupHex(theme, value);
2210
+ return colorValue(theme, parsed);
1469
2211
  }
1470
2212
  function resolveTextNative(parsed, theme) {
1471
2213
  if (!parsed.isArbitrary && parsed.value !== null) {
1472
2214
  const size = textSize(parsed.value);
1473
2215
  if (size !== null) return [decl("font-size", size)];
2216
+ const sized = splitSizeLeading(parsed.value);
2217
+ if (sized !== null) {
2218
+ const lh = sizeLeadingNative(sized[0], sized[1]);
2219
+ return lh === null ? null : [decl("font-size", sized[0]), decl("line-height", lh)];
2220
+ }
1474
2221
  const align = textAlign(parsed.value);
1475
2222
  if (align !== null) return [decl("text-align", align)];
2223
+ } else if (parsed.isArbitrary && parsed.value !== null) {
2224
+ const leading = parsed.modifier ?? null;
2225
+ if (isLength(parsed, parsed.value)) {
2226
+ if (leading === null) return [decl("font-size", parsed.value)];
2227
+ const lh = sizeLeadingNative(parsed.value, leading);
2228
+ return lh === null ? null : [decl("font-size", parsed.value), decl("line-height", lh)];
2229
+ }
2230
+ if (leading !== null) return null;
1476
2231
  }
1477
2232
  const hex = nativeHexColor(parsed, theme);
1478
2233
  return hex === null ? null : [decl("color", hex)];
@@ -1489,13 +2244,20 @@ function resolveColorNative(parsed, theme) {
1489
2244
  return null;
1490
2245
  }
1491
2246
  }
2247
+ function resolveOpacityNative(parsed) {
2248
+ if (parsed.utility !== "opacity") return null;
2249
+ const v = resolvePercent(parsed);
2250
+ return v === null ? null : [decl("opacity", v)];
2251
+ }
1492
2252
  function resolveUtilityNative(parsed, theme) {
1493
- return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed) ?? nativeShadowDeclarations(parsed);
2253
+ return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed, theme) ?? resolveOpacityNative(parsed) ?? nativeShadowDeclarations(parsed) ?? resolveNative(parsed, theme);
1494
2254
  }
1495
2255
 
1496
2256
  // src/jsEngine/resolveStyle.ts
1497
2257
  var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
2258
+ var STATE_HOLD_MARKER2 = "_kbon";
1498
2259
  function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
2260
+ if (modifier === STATE_HOLD_MARKER2) return true;
1499
2261
  if (modifier === "dark") return colorScheme === "dark";
1500
2262
  if (modifier === "active") return pressed;
1501
2263
  if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
@@ -1503,6 +2265,34 @@ function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
1503
2265
  if (minWidth === void 0) return null;
1504
2266
  return width >= minWidth;
1505
2267
  }
2268
+ if (modifier.startsWith("min-[") && modifier.endsWith("]")) {
2269
+ const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
2270
+ return px === null ? null : width >= px;
2271
+ }
2272
+ if (modifier.startsWith("max-[") && modifier.endsWith("]")) {
2273
+ const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
2274
+ return px === null ? null : width < px;
2275
+ }
2276
+ const screen = (name) => Object.prototype.hasOwnProperty.call(theme.screens, name) ? theme.screens[name] : void 0;
2277
+ const custom = screen(modifier);
2278
+ if (typeof custom === "number") return width >= custom;
2279
+ if (modifier.startsWith("max-")) {
2280
+ const max = screen(modifier.slice(4));
2281
+ if (typeof max === "number") return width < max;
2282
+ }
2283
+ if (modifier.startsWith("min-")) {
2284
+ const min = screen(modifier.slice(4));
2285
+ if (typeof min === "number") return width >= min;
2286
+ }
2287
+ if (modifier.startsWith("not-")) {
2288
+ const rest = modifier.slice(4);
2289
+ if (rest === "dark") return colorScheme !== "dark";
2290
+ const isBreakpoint = (name) => typeof screen(name) === "number";
2291
+ if (isBreakpoint(rest) || (rest.startsWith("max-") || rest.startsWith("min-")) && isBreakpoint(rest.slice(4))) {
2292
+ const holds = nativeModifierState(rest, theme, colorScheme, pressed, width);
2293
+ return holds === null ? null : !holds;
2294
+ }
2295
+ }
1506
2296
  return null;
1507
2297
  }
1508
2298
  function kebabToCamel(s) {
@@ -1547,6 +2337,7 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
1547
2337
  "shadow-opacity",
1548
2338
  "shadow-radius",
1549
2339
  "elevation",
2340
+ "opacity",
1550
2341
  // Per-side border width + per-corner radius — see resolvers/border.ts's
1551
2342
  // new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
1552
2343
  // style system wants plain numbers for these exactly like the generic
@@ -1560,29 +2351,104 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
1560
2351
  "border-bottom-right-radius",
1561
2352
  "border-bottom-left-radius",
1562
2353
  "outline-width",
1563
- "outline-offset"
2354
+ "outline-offset",
2355
+ // The transform ops whose RN value is a plain JS number — translate takes
2356
+ // a length (px/percentage, same as top/left/etc. above) and scale takes a
2357
+ // bare decimal factor (parsed by the same "raw value" fallback branch
2358
+ // below). transform-op-rotate*/transform-op-skew* stay OUT of this set on
2359
+ // purpose, since RN wants those as literal "45deg"-shaped strings, not
2360
+ // numbers. See the transform-ops accumulator below for how these markers
2361
+ // get collected into the final array.
2362
+ "transform-op-translate-x",
2363
+ "transform-op-translate-y",
2364
+ "transform-op-scale-x",
2365
+ "transform-op-scale-y"
1564
2366
  ]);
2367
+ var TRANSFORM_OP_KEYS = /* @__PURE__ */ new Map([
2368
+ ["transform-op-translate-x", "translateX"],
2369
+ ["transform-op-translate-y", "translateY"],
2370
+ ["transform-op-rotate", "rotate"],
2371
+ ["transform-op-rotate-x", "rotateX"],
2372
+ ["transform-op-rotate-y", "rotateY"],
2373
+ ["transform-op-rotate-z", "rotateZ"],
2374
+ ["transform-op-skew-x", "skewX"],
2375
+ ["transform-op-skew-y", "skewY"],
2376
+ ["transform-op-scale-x", "scaleX"],
2377
+ ["transform-op-scale-y", "scaleY"]
2378
+ ]);
2379
+ var TRANSFORM_OP_ORDER = ["translateX", "translateY", "rotate", "rotateX", "rotateY", "rotateZ", "skewX", "skewY", "scaleX", "scaleY"];
2380
+ function isPlainPercentage(value) {
2381
+ if (!value.endsWith("%")) return false;
2382
+ let digits = value.slice(0, -1);
2383
+ if (digits.startsWith("-")) digits = digits.slice(1);
2384
+ return digits.length > 0 && /^[0-9.]+$/.test(digits);
2385
+ }
2386
+ function sanitizeForWarning(value) {
2387
+ const MAX_CHARS = 60;
2388
+ const escaped = value.replace(/"/g, "'").replace(/[\n\r]/g, " ");
2389
+ if (escaped.length <= MAX_CHARS) return escaped;
2390
+ return `${escaped.slice(0, MAX_CHARS)}\u2026`;
2391
+ }
1565
2392
  function rnStyleValue(property, value) {
1566
- if (NUMERIC_LENGTH_PROPS.has(property)) {
1567
- let px = null;
1568
- if (value.endsWith("px")) {
1569
- const n = Number(value.slice(0, -2));
1570
- px = Number.isFinite(n) ? n : null;
1571
- } else if (value.endsWith("rem")) {
1572
- const n = Number(value.slice(0, -3));
1573
- px = Number.isFinite(n) ? n * 16 : null;
1574
- } else {
1575
- const n = Number(value);
1576
- px = value.trim() !== "" && Number.isFinite(n) ? n : null;
2393
+ if (value.startsWith("color-mix(in srgb, ") && value.endsWith(", transparent)")) {
2394
+ const inner = value.slice("color-mix(in srgb, ".length, -", transparent)".length);
2395
+ const space = inner.lastIndexOf(" ");
2396
+ if (space !== -1) return rnStyleValue(property, inner.slice(0, space));
2397
+ }
2398
+ if (property === "aspect-ratio") {
2399
+ if (value.trim() === "auto") return { value: null, warning: null };
2400
+ const parts = value.split("/").map((s) => s.trim());
2401
+ let n = null;
2402
+ if (parts.length === 1) {
2403
+ const a = Number(parts[0]);
2404
+ n = Number.isFinite(a) ? a : null;
2405
+ } else if (parts.length === 2) {
2406
+ const a = Number(parts[0]);
2407
+ const b = Number(parts[1]);
2408
+ n = Number.isFinite(a) && Number.isFinite(b) && b !== 0 ? a / b : null;
1577
2409
  }
1578
- if (px !== null) return px;
2410
+ return { value: n, warning: null };
2411
+ }
2412
+ if (!NUMERIC_LENGTH_PROPS.has(property)) {
2413
+ return { value, warning: null };
2414
+ }
2415
+ if (value === "auto") {
2416
+ return { value: "auto", warning: null };
1579
2417
  }
1580
- return value;
2418
+ let px = null;
2419
+ if (value.endsWith("px")) {
2420
+ const n = Number(value.slice(0, -2));
2421
+ px = Number.isFinite(n) ? n : null;
2422
+ } else if (value.endsWith("rem")) {
2423
+ const n = Number(value.slice(0, -3));
2424
+ px = Number.isFinite(n) ? n * 16 : null;
2425
+ } else {
2426
+ const n = Number(value);
2427
+ px = value.trim() !== "" && Number.isFinite(n) ? n : null;
2428
+ }
2429
+ if (px !== null) return { value: px, warning: null };
2430
+ if (isPlainPercentage(value)) {
2431
+ return { value, warning: null };
2432
+ }
2433
+ const reduced = reduceConstantMath(value);
2434
+ if (reduced !== null) {
2435
+ return { value: reduced, warning: null };
2436
+ }
2437
+ const sanitizedValue = sanitizeForWarning(value);
2438
+ const warning = `[Kbach] "${sanitizedValue}" isn't a valid native value for "${property}" \u2014 dropped.
2439
+ calc()/min()/max()/clamp() only resolve on native when every operand is a constant px/rem length (no %, vw, vh, var(), or other viewport/CSS-variable units \u2014 those need real layout/DOM, which doesn't exist on native at paint time).
2440
+ Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this value in JS instead.`;
2441
+ return { value: null, warning };
1581
2442
  }
1582
- function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
2443
+ function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
1583
2444
  const style = {};
2445
+ const warnings = [];
1584
2446
  let shadowOffset = null;
1585
- for (const token of classString.split(/\s+/).filter(Boolean)) {
2447
+ const transformOps = /* @__PURE__ */ new Map();
2448
+ const keySpecificity = /* @__PURE__ */ new Map();
2449
+ const transformSpecificity = /* @__PURE__ */ new Map();
2450
+ for (const rawToken of classString.split(/\s+/).filter(Boolean)) {
2451
+ const token = substituteModeAwareColorToken(rawToken, theme, colorScheme);
1586
2452
  const parsed = parseClass(token);
1587
2453
  const allModifiersHold = parsed.modifiers.every(
1588
2454
  (m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
@@ -1590,36 +2456,121 @@ function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
1590
2456
  if (!allModifiersHold) continue;
1591
2457
  const decls = resolveUtilityNative(parsed, theme);
1592
2458
  if (decls === null) continue;
2459
+ const spec = parsed.modifiers.length;
1593
2460
  for (const d of decls) {
1594
2461
  if (d.property.startsWith("__")) {
1595
2462
  continue;
1596
2463
  }
2464
+ if (d.property.startsWith("--") || d.value.includes("var(") || d.property === "outline" || d.property === "object-position" || d.property === "container-type" || d.property === "container-name") {
2465
+ continue;
2466
+ }
1597
2467
  if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
2468
+ if (spec < (keySpecificity.get("shadowOffset") ?? 0)) continue;
1598
2469
  const n = Number(d.value);
1599
2470
  if (!Number.isFinite(n)) continue;
1600
2471
  if (shadowOffset === null) shadowOffset = {};
1601
2472
  shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
2473
+ keySpecificity.set("shadowOffset", spec);
2474
+ continue;
2475
+ }
2476
+ if (d.property === "transform-op-none") {
2477
+ transformOps.clear();
2478
+ transformSpecificity.clear();
2479
+ continue;
2480
+ }
2481
+ const opKey = TRANSFORM_OP_KEYS.get(d.property);
2482
+ if (opKey !== void 0) {
2483
+ if (spec < (transformSpecificity.get(opKey) ?? 0)) continue;
2484
+ const { value: value2, warning: warning2 } = rnStyleValue(d.property, d.value);
2485
+ if (warning2 !== null) warnings.push(warning2);
2486
+ if (value2 !== null) {
2487
+ transformOps.set(opKey, value2);
2488
+ transformSpecificity.set(opKey, spec);
2489
+ }
1602
2490
  continue;
1603
2491
  }
1604
- style[kebabToCamel(d.property)] = rnStyleValue(d.property, d.value);
2492
+ const key = kebabToCamel(d.property);
2493
+ if (spec < (keySpecificity.get(key) ?? 0)) continue;
2494
+ const { value, warning } = rnStyleValue(d.property, d.value);
2495
+ if (warning !== null) warnings.push(warning);
2496
+ if (value !== null) {
2497
+ style[key] = value;
2498
+ keySpecificity.set(key, spec);
2499
+ }
1605
2500
  }
1606
2501
  }
1607
2502
  if (shadowOffset !== null) {
1608
2503
  style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
1609
2504
  }
1610
- return style;
2505
+ if (transformOps.size > 0) {
2506
+ style.transform = TRANSFORM_OP_ORDER.filter((key) => transformOps.has(key)).map((key) => ({
2507
+ [key]: transformOps.get(key)
2508
+ }));
2509
+ }
2510
+ return { style, warnings };
1611
2511
  }
1612
2512
 
1613
2513
  // src/nativeBridge.ts
2514
+ var RESOLVE_STYLE_CACHE_MAX = 500;
2515
+ var resolveStyleCache = /* @__PURE__ */ new Map();
2516
+ var cachedForThemeJson = null;
1614
2517
  function resolveStyle(classString, pressed = false) {
1615
- const colorScheme = getGlobalDarkMode() ? "dark" : "light";
1616
- const width = import_react_native3.Dimensions.get("window").width;
1617
- const KbachModule = import_react_native3.TurboModuleRegistry.get("KbachModule");
2518
+ const colorScheme = (0, import_darkModeStore2.getGlobalDarkMode)() ? "dark" : "light";
2519
+ const width = import_react_native2.Dimensions.get("window").width;
2520
+ const themeJson = (0, import_theme2.getThemeJson)();
2521
+ if (themeJson !== cachedForThemeJson) {
2522
+ resolveStyleCache.clear();
2523
+ cachedForThemeJson = themeJson;
2524
+ }
2525
+ const cacheKey = `${classString}\0${pressed}\0${colorScheme}\0${width}`;
2526
+ const cached = resolveStyleCache.get(cacheKey);
2527
+ if (cached !== void 0) return { ...cached };
2528
+ const style = resolveStyleUncached(classString, pressed, colorScheme, width, themeJson);
2529
+ if (resolveStyleCache.size >= RESOLVE_STYLE_CACHE_MAX) resolveStyleCache.clear();
2530
+ resolveStyleCache.set(cacheKey, style);
2531
+ return { ...style };
2532
+ }
2533
+ function resolveStyleUncached(classString, pressed, colorScheme, width, themeJson) {
2534
+ const KbachModule = import_react_native2.TurboModuleRegistry.get("KbachModule");
1618
2535
  if (!KbachModule) {
1619
- return resolveStyleJs(classString, getTheme(), colorScheme, pressed, width);
2536
+ const { style: style2, warnings: warnings2 } = resolveStyleJsWithWarnings(classString, (0, import_theme2.getTheme)(), colorScheme, pressed, width);
2537
+ warnIfDev(classString, warnings2);
2538
+ return style2;
2539
+ }
2540
+ const json = KbachModule.resolveStyle(classString, themeJson, colorScheme, pressed, width);
2541
+ const style = JSON.parse(json);
2542
+ const warnings = style.__kbachWarnings;
2543
+ if (warnings !== void 0) {
2544
+ delete style.__kbachWarnings;
2545
+ warnIfDev(classString, warnings);
2546
+ }
2547
+ return style;
2548
+ }
2549
+ var WARNED_MESSAGES_MAX = 500;
2550
+ var warnedMessages = /* @__PURE__ */ new Set();
2551
+ var QUOTED_TOKEN_RE = /"([^"]*)"/;
2552
+ function highlightToken(classString, warning) {
2553
+ const match = QUOTED_TOKEN_RE.exec(warning);
2554
+ if (match === null) return classString;
2555
+ const quoted = match[1].replace(/\s+/g, "");
2556
+ if (quoted === "") return classString;
2557
+ const parts = classString.split(/(\s+)/);
2558
+ const idx = parts.findIndex((part) => part.replace(/\s+/g, "").includes(quoted));
2559
+ if (idx === -1) return classString;
2560
+ parts[idx] = `\xBB${parts[idx]}\xAB`;
2561
+ return parts.join("");
2562
+ }
2563
+ function warnIfDev(classString, warnings) {
2564
+ if (warnings.length === 0) return;
2565
+ if (typeof __DEV__ !== "undefined" && !__DEV__) return;
2566
+ for (const warning of warnings) {
2567
+ const message = `${warning}
2568
+ From className: "${highlightToken(classString, warning)}"`;
2569
+ if (warnedMessages.has(message)) continue;
2570
+ if (warnedMessages.size >= WARNED_MESSAGES_MAX) warnedMessages.clear();
2571
+ warnedMessages.add(message);
2572
+ console.warn(message);
1620
2573
  }
1621
- const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
1622
- return JSON.parse(json);
1623
2574
  }
1624
2575
 
1625
2576
  // src/jsx-runtime.tsx