@kbach/react-native 1.0.0-beta.2 → 1.0.0-beta.21

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 (42) hide show
  1. package/README.md +253 -87
  2. package/android/build.gradle +36 -0
  3. package/android/src/main/AndroidManifest.xml +14 -0
  4. package/android/src/main/java/com/kbachnative/KbachModule.kt +83 -0
  5. package/android/src/main/java/com/kbachnative/KbachPackage.kt +54 -0
  6. package/android/src/main/jniLibs/arm64-v8a/libkbach_core_engine.so +0 -0
  7. package/android/src/main/jniLibs/x86_64/libkbach_core_engine.so +0 -0
  8. package/dist/chunk-AG7ZQ2K4.mjs +552 -0
  9. package/dist/chunk-OS7EPBH5.mjs +40 -0
  10. package/dist/chunk-TS2EEVOE.mjs +107 -0
  11. package/dist/darkModeStore.d.ts +58 -0
  12. package/dist/darkModeStore.js +112 -0
  13. package/dist/dynamicTokens.d.ts +36 -0
  14. package/dist/dynamicTokens.js +75 -0
  15. package/dist/index.d.ts +53 -102
  16. package/dist/index.js +1721 -385
  17. package/dist/index.web.d.ts +18 -0
  18. package/dist/index.web.js +436 -0
  19. package/dist/index.web.mjs +210 -0
  20. package/dist/jsx-dev-runtime.d.ts +3 -12
  21. package/dist/jsx-dev-runtime.js +1738 -343
  22. package/dist/jsx-dev-runtime.web.d.ts +10 -0
  23. package/dist/jsx-dev-runtime.web.js +270 -0
  24. package/dist/jsx-dev-runtime.web.mjs +29 -0
  25. package/dist/jsx-runtime.d.ts +3 -23
  26. package/dist/jsx-runtime.js +1729 -335
  27. package/dist/jsx-runtime.web.d.ts +7 -0
  28. package/dist/jsx-runtime.web.js +252 -0
  29. package/dist/{jsx-runtime.mjs → jsx-runtime.web.mjs} +2 -2
  30. package/dist/theme.d.ts +54 -0
  31. package/dist/{chunk-YHF3QLRL.mjs → theme.js} +94 -72
  32. package/dist/useDynamicToken-Dr15c88t.d.ts +160 -0
  33. package/package.json +62 -14
  34. package/react-native.config.js +29 -0
  35. package/specs/NativeKbachModule.ts +31 -0
  36. package/src/babel-plugin.js +74 -2
  37. package/dist/chunk-SVMYVXY6.mjs +0 -44
  38. package/dist/index.d.mts +0 -148
  39. package/dist/index.mjs +0 -80
  40. package/dist/jsx-dev-runtime.d.mts +0 -19
  41. package/dist/jsx-dev-runtime.mjs +0 -20
  42. package/dist/jsx-runtime.d.mts +0 -27
@@ -25,349 +25,500 @@ __export(jsx_runtime_exports, {
25
25
  jsxs: () => jsxs
26
26
  });
27
27
  module.exports = __toCommonJS(jsx_runtime_exports);
28
+
29
+ // src/jsxRuntimeCore.ts
28
30
  var import_jsx_runtime = require("react/jsx-runtime");
29
31
  var import_react = require("react");
30
- var import_react_native3 = require("react-native");
31
-
32
- // src/nativeBridge.ts
33
- var import_react_native2 = require("react-native");
32
+ var import_react_native = require("react-native");
33
+ var import_darkModeStore = require("./darkModeStore");
34
+ var import_dynamicTokens = require("./dynamicTokens");
34
35
 
35
- // src/generatedPalette.ts
36
- var PALETTE = {
37
- "amber-1": "#fffbeb",
38
- "amber-10": "#78350f",
39
- "amber-11": "#451a03",
40
- "amber-12": "#291002",
41
- "amber-2": "#fef3c7",
42
- "amber-3": "#fde68a",
43
- "amber-4": "#fcd34d",
44
- "amber-5": "#fbbf24",
45
- "amber-6": "#f59e0b",
46
- "amber-7": "#d97706",
47
- "amber-8": "#b45309",
48
- "amber-9": "#92400e",
49
- "black": "#000000",
50
- "blue-1": "#eff6ff",
51
- "blue-10": "#1e3a8a",
52
- "blue-11": "#172554",
53
- "blue-12": "#0d1633",
54
- "blue-2": "#dbeafe",
55
- "blue-3": "#bfdbfe",
56
- "blue-4": "#93c5fd",
57
- "blue-5": "#60a5fa",
58
- "blue-6": "#3b82f6",
59
- "blue-7": "#2563eb",
60
- "blue-8": "#1d4ed8",
61
- "blue-9": "#1e40af",
62
- "bronze": "#cd7f32",
63
- "coal": "#1c1c1c",
64
- "copper": "#b87333",
65
- "current": "currentColor",
66
- "cyan-1": "#ecfeff",
67
- "cyan-10": "#164e63",
68
- "cyan-11": "#083344",
69
- "cyan-12": "#041e28",
70
- "cyan-2": "#cffafe",
71
- "cyan-3": "#a5f3fc",
72
- "cyan-4": "#67e8f9",
73
- "cyan-5": "#22d3ee",
74
- "cyan-6": "#06b6d4",
75
- "cyan-7": "#0891b2",
76
- "cyan-8": "#0e7490",
77
- "cyan-9": "#155e75",
78
- "emerald-1": "#ecfdf5",
79
- "emerald-10": "#064e3b",
80
- "emerald-11": "#022c22",
81
- "emerald-12": "#011a14",
82
- "emerald-2": "#d1fae5",
83
- "emerald-3": "#a7f3d0",
84
- "emerald-4": "#6ee7b7",
85
- "emerald-5": "#34d399",
86
- "emerald-6": "#10b981",
87
- "emerald-7": "#059669",
88
- "emerald-8": "#047857",
89
- "emerald-9": "#065f46",
90
- "fuchsia-1": "#fdf4ff",
91
- "fuchsia-10": "#701a75",
92
- "fuchsia-11": "#4a044e",
93
- "fuchsia-12": "#2d022f",
94
- "fuchsia-2": "#fae8ff",
95
- "fuchsia-3": "#f5d0fe",
96
- "fuchsia-4": "#f0abfc",
97
- "fuchsia-5": "#e879f9",
98
- "fuchsia-6": "#d946ef",
99
- "fuchsia-7": "#c026d3",
100
- "fuchsia-8": "#a21caf",
101
- "fuchsia-9": "#86198f",
102
- "gold": "#d4af37",
103
- "gray-1": "#f9fafb",
104
- "gray-10": "#111827",
105
- "gray-11": "#030712",
106
- "gray-12": "#020409",
107
- "gray-2": "#f3f4f6",
108
- "gray-3": "#e5e7eb",
109
- "gray-4": "#d1d5db",
110
- "gray-5": "#9ca3af",
111
- "gray-6": "#6b7280",
112
- "gray-7": "#4b5563",
113
- "gray-8": "#374151",
114
- "gray-9": "#1f2937",
115
- "green-1": "#f0fdf4",
116
- "green-10": "#14532d",
117
- "green-11": "#052e16",
118
- "green-12": "#031b0d",
119
- "green-2": "#dcfce7",
120
- "green-3": "#bbf7d0",
121
- "green-4": "#86efac",
122
- "green-5": "#4ade80",
123
- "green-6": "#22c55e",
124
- "green-7": "#16a34a",
125
- "green-8": "#15803d",
126
- "green-9": "#166534",
127
- "indigo-1": "#eef2ff",
128
- "indigo-10": "#312e81",
129
- "indigo-11": "#1e1b4b",
130
- "indigo-12": "#12102d",
131
- "indigo-2": "#e0e7ff",
132
- "indigo-3": "#c7d2fe",
133
- "indigo-4": "#a5b4fc",
134
- "indigo-5": "#818cf8",
135
- "indigo-6": "#6366f1",
136
- "indigo-7": "#4f46e5",
137
- "indigo-8": "#4338ca",
138
- "indigo-9": "#3730a3",
139
- "lime-1": "#f7fee7",
140
- "lime-10": "#365314",
141
- "lime-11": "#1a2e05",
142
- "lime-12": "#0f1b03",
143
- "lime-2": "#ecfccb",
144
- "lime-3": "#d9f99d",
145
- "lime-4": "#bef264",
146
- "lime-5": "#a3e635",
147
- "lime-6": "#84cc16",
148
- "lime-7": "#65a30d",
149
- "lime-8": "#4d7c0f",
150
- "lime-9": "#3f6212",
151
- "neutral-1": "#fafafa",
152
- "neutral-10": "#171717",
153
- "neutral-11": "#0a0a0a",
154
- "neutral-12": "#050505",
155
- "neutral-2": "#f5f5f5",
156
- "neutral-3": "#e5e5e5",
157
- "neutral-4": "#d4d4d4",
158
- "neutral-5": "#a3a3a3",
159
- "neutral-6": "#737373",
160
- "neutral-7": "#525252",
161
- "neutral-8": "#404040",
162
- "neutral-9": "#262626",
163
- "orange-1": "#fff7ed",
164
- "orange-10": "#7c2d12",
165
- "orange-11": "#431407",
166
- "orange-12": "#270c04",
167
- "orange-2": "#ffedd5",
168
- "orange-3": "#fed7aa",
169
- "orange-4": "#fdba74",
170
- "orange-5": "#fb923c",
171
- "orange-6": "#f97316",
172
- "orange-7": "#ea580c",
173
- "orange-8": "#c2410c",
174
- "orange-9": "#9a3412",
175
- "pink-1": "#fdf2f8",
176
- "pink-10": "#831843",
177
- "pink-11": "#500724",
178
- "pink-12": "#300415",
179
- "pink-2": "#fce7f3",
180
- "pink-3": "#fbcfe8",
181
- "pink-4": "#f9a8d4",
182
- "pink-5": "#f472b6",
183
- "pink-6": "#ec4899",
184
- "pink-7": "#db2777",
185
- "pink-8": "#be185d",
186
- "pink-9": "#9d174d",
187
- "purple-1": "#faf5ff",
188
- "purple-10": "#581c87",
189
- "purple-11": "#3b0764",
190
- "purple-12": "#23043c",
191
- "purple-2": "#f3e8ff",
192
- "purple-3": "#e9d5ff",
193
- "purple-4": "#d8b4fe",
194
- "purple-5": "#c084fc",
195
- "purple-6": "#a855f7",
196
- "purple-7": "#9333ea",
197
- "purple-8": "#7e22ce",
198
- "purple-9": "#6b21a8",
199
- "red-1": "#fef2f2",
200
- "red-10": "#7f1d1d",
201
- "red-11": "#450a0a",
202
- "red-12": "#280606",
203
- "red-2": "#fee2e2",
204
- "red-3": "#fecaca",
205
- "red-4": "#fca5a5",
206
- "red-5": "#f87171",
207
- "red-6": "#ef4444",
208
- "red-7": "#dc2626",
209
- "red-8": "#b91c1c",
210
- "red-9": "#991b1b",
211
- "rose-1": "#fff1f2",
212
- "rose-10": "#881337",
213
- "rose-11": "#4c0519",
214
- "rose-12": "#2d030e",
215
- "rose-2": "#ffe4e6",
216
- "rose-3": "#fecdd3",
217
- "rose-4": "#fda4af",
218
- "rose-5": "#fb7185",
219
- "rose-6": "#f43f5e",
220
- "rose-7": "#e11d48",
221
- "rose-8": "#be123c",
222
- "rose-9": "#9f1239",
223
- "silver": "#c0c0c0",
224
- "sky-1": "#f0f9ff",
225
- "sky-10": "#0c4a6e",
226
- "sky-11": "#082f49",
227
- "sky-12": "#041b2b",
228
- "sky-2": "#e0f2fe",
229
- "sky-3": "#bae6fd",
230
- "sky-4": "#7dd3fc",
231
- "sky-5": "#38bdf8",
232
- "sky-6": "#0ea5e9",
233
- "sky-7": "#0284c7",
234
- "sky-8": "#0369a1",
235
- "sky-9": "#075985",
236
- "slate-1": "#f8fafc",
237
- "slate-10": "#0f172a",
238
- "slate-11": "#020617",
239
- "slate-12": "#01020a",
240
- "slate-2": "#f1f5f9",
241
- "slate-3": "#e2e8f0",
242
- "slate-4": "#cbd5e1",
243
- "slate-5": "#94a3b8",
244
- "slate-6": "#64748b",
245
- "slate-7": "#475569",
246
- "slate-8": "#334155",
247
- "slate-9": "#1e293b",
248
- "stone-1": "#fafaf9",
249
- "stone-10": "#1c1917",
250
- "stone-11": "#0c0a09",
251
- "stone-12": "#070605",
252
- "stone-2": "#f5f5f4",
253
- "stone-3": "#e7e5e4",
254
- "stone-4": "#d6d3d1",
255
- "stone-5": "#a8a29e",
256
- "stone-6": "#78716c",
257
- "stone-7": "#57534e",
258
- "stone-8": "#44403c",
259
- "stone-9": "#292524",
260
- "teal-1": "#f0fdfa",
261
- "teal-10": "#134e4a",
262
- "teal-11": "#042f2e",
263
- "teal-12": "#021c1b",
264
- "teal-2": "#ccfbf1",
265
- "teal-3": "#99f6e4",
266
- "teal-4": "#5eead4",
267
- "teal-5": "#2dd4bf",
268
- "teal-6": "#14b8a6",
269
- "teal-7": "#0d9488",
270
- "teal-8": "#0f766e",
271
- "teal-9": "#115e59",
272
- "transparent": "transparent",
273
- "violet-1": "#f5f3ff",
274
- "violet-10": "#4c1d95",
275
- "violet-11": "#2e1065",
276
- "violet-12": "#1c0a3d",
277
- "violet-2": "#ede9fe",
278
- "violet-3": "#ddd6fe",
279
- "violet-4": "#c4b5fd",
280
- "violet-5": "#a78bfa",
281
- "violet-6": "#8b5cf6",
282
- "violet-7": "#7c3aed",
283
- "violet-8": "#6d28d9",
284
- "violet-9": "#5b21b6",
285
- "white": "#ffffff",
286
- "yellow-1": "#fefce8",
287
- "yellow-10": "#713f12",
288
- "yellow-11": "#422006",
289
- "yellow-12": "#271304",
290
- "yellow-2": "#fef9c3",
291
- "yellow-3": "#fef08a",
292
- "yellow-4": "#fde047",
293
- "yellow-5": "#facc15",
294
- "yellow-6": "#eab308",
295
- "yellow-7": "#ca8a04",
296
- "yellow-8": "#a16207",
297
- "yellow-9": "#854d0e",
298
- "zinc-1": "#fafafa",
299
- "zinc-10": "#18181b",
300
- "zinc-11": "#09090b",
301
- "zinc-12": "#050506",
302
- "zinc-2": "#f4f4f5",
303
- "zinc-3": "#e4e4e7",
304
- "zinc-4": "#d4d4d8",
305
- "zinc-5": "#a1a1aa",
306
- "zinc-6": "#71717a",
307
- "zinc-7": "#52525b",
308
- "zinc-8": "#3f3f46",
309
- "zinc-9": "#27272a"
36
+ // src/jsEngine/calc.ts
37
+ function reduceConstantMath(raw) {
38
+ const trimmed = raw.trim();
39
+ const calc = stripCall(trimmed, "calc");
40
+ if (calc !== null) {
41
+ return new Evaluator(calc).parseExprToEnd();
42
+ }
43
+ const clamp = stripCall(trimmed, "clamp");
44
+ if (clamp !== null) {
45
+ const args = splitTopLevelCommas(clamp);
46
+ if (args.length !== 3) return null;
47
+ const [min2, preferred, max2] = args.map((a) => new Evaluator(a).parseExprToEnd());
48
+ if (min2 === null || preferred === null || max2 === null) return null;
49
+ return Math.max(min2, Math.min(preferred, max2));
50
+ }
51
+ const min = stripCall(trimmed, "min");
52
+ if (min !== null) {
53
+ const values = splitTopLevelCommas(min).map((a) => new Evaluator(a).parseExprToEnd());
54
+ return values.some((v) => v === null) ? null : Math.min(...values);
55
+ }
56
+ const max = stripCall(trimmed, "max");
57
+ if (max !== null) {
58
+ const values = splitTopLevelCommas(max).map((a) => new Evaluator(a).parseExprToEnd());
59
+ return values.some((v) => v === null) ? null : Math.max(...values);
60
+ }
61
+ return null;
62
+ }
63
+ function stripCall(raw, name) {
64
+ if (!raw.startsWith(name)) return null;
65
+ const afterName = raw.slice(name.length).trimStart();
66
+ if (!afterName.startsWith("(") || !afterName.endsWith(")")) return null;
67
+ return afterName.slice(1, -1);
68
+ }
69
+ function splitTopLevelCommas(s) {
70
+ const parts = [];
71
+ let depth = 0;
72
+ let start = 0;
73
+ for (let i = 0; i < s.length; i++) {
74
+ const ch = s[i];
75
+ if (ch === "(") depth++;
76
+ else if (ch === ")") depth--;
77
+ else if (ch === "," && depth === 0) {
78
+ parts.push(s.slice(start, i).trim());
79
+ start = i + 1;
80
+ }
81
+ }
82
+ parts.push(s.slice(start).trim());
83
+ return parts;
84
+ }
85
+ var Evaluator = class {
86
+ constructor(s) {
87
+ this.pos = 0;
88
+ this.s = s;
89
+ }
90
+ parseExprToEnd() {
91
+ const value = this.expr();
92
+ if (value === null) return null;
93
+ this.skipWs();
94
+ return this.pos === this.s.length ? value : null;
95
+ }
96
+ skipWs() {
97
+ while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
98
+ }
99
+ peek() {
100
+ this.skipWs();
101
+ return this.s[this.pos];
102
+ }
103
+ expr() {
104
+ let value = this.term();
105
+ if (value === null) return null;
106
+ for (; ; ) {
107
+ const ch = this.peek();
108
+ if (ch === "+") {
109
+ this.pos++;
110
+ const rhs = this.term();
111
+ if (rhs === null) return null;
112
+ value += rhs;
113
+ } else if (ch === "-") {
114
+ this.pos++;
115
+ const rhs = this.term();
116
+ if (rhs === null) return null;
117
+ value -= rhs;
118
+ } else {
119
+ return value;
120
+ }
121
+ }
122
+ }
123
+ term() {
124
+ let value = this.factor();
125
+ if (value === null) return null;
126
+ for (; ; ) {
127
+ const ch = this.peek();
128
+ if (ch === "*") {
129
+ this.pos++;
130
+ const rhs = this.factor();
131
+ if (rhs === null) return null;
132
+ value *= rhs;
133
+ } else if (ch === "/") {
134
+ this.pos++;
135
+ const divisor = this.factor();
136
+ if (divisor === null || divisor === 0) return null;
137
+ value /= divisor;
138
+ } else {
139
+ return value;
140
+ }
141
+ }
142
+ }
143
+ factor() {
144
+ const ch = this.peek();
145
+ if (ch === void 0) return null;
146
+ if (ch === "(") {
147
+ this.pos++;
148
+ const value = this.expr();
149
+ if (value === null || this.peek() !== ")") return null;
150
+ this.pos++;
151
+ return value;
152
+ }
153
+ if (ch === "-") {
154
+ this.pos++;
155
+ const value = this.factor();
156
+ return value === null ? null : -value;
157
+ }
158
+ return this.numberWithUnit();
159
+ }
160
+ numberWithUnit() {
161
+ this.skipWs();
162
+ const start = this.pos;
163
+ while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
164
+ if (this.pos === start) return null;
165
+ const n = Number(this.s.slice(start, this.pos));
166
+ if (!Number.isFinite(n)) return null;
167
+ const unitStart = this.pos;
168
+ while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
169
+ const unit = this.s.slice(unitStart, this.pos);
170
+ switch (unit) {
171
+ case "":
172
+ return n;
173
+ case "px":
174
+ return n;
175
+ case "rem":
176
+ return n * 16;
177
+ default:
178
+ return null;
179
+ }
180
+ }
310
181
  };
311
182
 
312
- // src/theme.ts
313
- var defaultTheme = {
314
- colors: PALETTE,
315
- spacing: {
316
- // "0" is always a hardcoded zero in real Tailwind's own scale too,
317
- // regardless of the base spacing unit — needed for `p-0`/`m-0`/etc.
318
- // Mirrors the identical fix in @kbach/react's theme.ts.
319
- "0": 0,
320
- "1": 4,
321
- "2": 8,
322
- "4": 16,
323
- "6": 24,
324
- "8": 32
325
- },
326
- screens: {},
327
- darkMode: "attribute"
328
- };
329
- var activeThemeJson = JSON.stringify(defaultTheme);
330
- function getThemeJson() {
331
- return activeThemeJson;
183
+ // src/layoutCalc.ts
184
+ var PERCENT_CALC_TOKEN_RE = /^(w|h)-\[calc\(([^)]+)\)\]$/;
185
+ function parsePercentRelativeCalc(token) {
186
+ const m = PERCENT_CALC_TOKEN_RE.exec(token);
187
+ if (!m) return null;
188
+ const property = m[1] === "w" ? "width" : "height";
189
+ const inner = m[2].replace(/_/g, " ").trim();
190
+ let mm = /^(-?[\d.]+)%\s*([+-])\s*(.+)$/.exec(inner);
191
+ if (mm) {
192
+ const percentCoefficient = Number(mm[1]);
193
+ const magnitude = reduceConstantMath(`calc(${mm[3].trim()})`);
194
+ if (!Number.isFinite(percentCoefficient) || magnitude === null) return null;
195
+ return { property, percentCoefficient, constantPx: mm[2] === "+" ? magnitude : -magnitude };
196
+ }
197
+ mm = /^(.+?)\s*([+-])\s*(-?[\d.]+)%$/.exec(inner);
198
+ if (mm) {
199
+ const constantPx = reduceConstantMath(`calc(${mm[1].trim()})`);
200
+ const percentMagnitude = Number(mm[3]);
201
+ if (constantPx === null || !Number.isFinite(percentMagnitude)) return null;
202
+ return { property, percentCoefficient: mm[2] === "+" ? percentMagnitude : -percentMagnitude, constantPx };
203
+ }
204
+ return null;
205
+ }
206
+ function resolvePercentRelativeCalc(basisPx, calc) {
207
+ return basisPx * calc.percentCoefficient / 100 + calc.constantPx;
332
208
  }
333
209
 
334
- // src/darkModeStore.ts
335
- var import_react_native = require("react-native");
336
- var listeners = /* @__PURE__ */ new Set();
337
- function systemPrefersDark() {
338
- return import_react_native.Appearance.getColorScheme() === "dark";
339
- }
340
- function resolveIsDark(m) {
341
- return m === "system" ? systemPrefersDark() : m === "dark";
342
- }
343
- var mode = "system";
344
- var isDark = resolveIsDark(mode);
345
- var subscription = import_react_native.Appearance.addChangeListener(({ colorScheme }) => {
346
- if (mode !== "system") return;
347
- isDark = colorScheme === "dark";
348
- notify();
349
- });
350
- function notify() {
351
- for (const listener of listeners) listener();
210
+ // src/jsEngine/parser.ts
211
+ var VALUE_PREFIXES = [
212
+ "bg-opacity-",
213
+ "text-opacity-",
214
+ "bg-blend-",
215
+ "text-shadow-",
216
+ "bg-",
217
+ "text-",
218
+ "border-x-",
219
+ "border-y-",
220
+ "border-t-",
221
+ "border-r-",
222
+ "border-b-",
223
+ "border-l-",
224
+ "border-",
225
+ "caret-",
226
+ "accent-",
227
+ "fill-",
228
+ "stroke-width-",
229
+ "stroke-",
230
+ "resize-",
231
+ "touch-",
232
+ "will-change-",
233
+ "scroll-mx-",
234
+ "scroll-my-",
235
+ "scroll-mt-",
236
+ "scroll-mr-",
237
+ "scroll-mb-",
238
+ "scroll-ml-",
239
+ "scroll-m-",
240
+ "scroll-px-",
241
+ "scroll-py-",
242
+ "scroll-pt-",
243
+ "scroll-pr-",
244
+ "scroll-pb-",
245
+ "scroll-pl-",
246
+ "scroll-p-",
247
+ "px-",
248
+ "py-",
249
+ "pt-",
250
+ "pr-",
251
+ "pb-",
252
+ "pl-",
253
+ "p-",
254
+ "mx-",
255
+ "my-",
256
+ "mt-",
257
+ "mr-",
258
+ "mb-",
259
+ "ml-",
260
+ "m-",
261
+ "gap-x-",
262
+ "gap-y-",
263
+ "gap-",
264
+ "min-w-",
265
+ "max-w-",
266
+ "w-",
267
+ "min-h-",
268
+ "max-h-",
269
+ "h-",
270
+ "size-",
271
+ "basis-",
272
+ "rounded-tl-",
273
+ "rounded-tr-",
274
+ "rounded-br-",
275
+ "rounded-bl-",
276
+ "rounded-t-",
277
+ "rounded-r-",
278
+ "rounded-b-",
279
+ "rounded-l-",
280
+ "rounded-",
281
+ "ring-offset-",
282
+ "ring-",
283
+ "outline-offset-",
284
+ "outline-",
285
+ "shadow-",
286
+ "opacity-",
287
+ "duration-",
288
+ "delay-",
289
+ "ease-",
290
+ "cursor-",
291
+ "mix-blend-",
292
+ "animate-",
293
+ "leading-",
294
+ "tracking-",
295
+ "font-",
296
+ "z-",
297
+ "inset-x-",
298
+ "inset-y-",
299
+ "inset-",
300
+ "top-",
301
+ "right-",
302
+ "bottom-",
303
+ "left-",
304
+ "start-",
305
+ "end-",
306
+ "overflow-x-",
307
+ "overflow-y-",
308
+ "overscroll-x-",
309
+ "overscroll-y-",
310
+ "overscroll-",
311
+ "aspect-",
312
+ "divide-color-",
313
+ "space-x-",
314
+ "space-y-",
315
+ "flex-",
316
+ "grow-",
317
+ "shrink-",
318
+ "order-",
319
+ "grid-cols-",
320
+ "grid-rows-",
321
+ "grid-flow-",
322
+ "auto-cols-",
323
+ "auto-rows-",
324
+ "col-span-",
325
+ "col-start-",
326
+ "col-end-",
327
+ "col-",
328
+ "row-span-",
329
+ "row-start-",
330
+ "row-end-",
331
+ "row-",
332
+ "place-items-",
333
+ "place-content-",
334
+ "place-self-",
335
+ "justify-items-",
336
+ "justify-self-",
337
+ "scale-x-",
338
+ "scale-y-",
339
+ "scale-",
340
+ "rotate-",
341
+ "translate-x-",
342
+ "translate-y-",
343
+ "skew-x-",
344
+ "skew-y-",
345
+ "origin-",
346
+ "blur-",
347
+ "brightness-",
348
+ "contrast-",
349
+ "grayscale-",
350
+ "hue-rotate-",
351
+ "invert-",
352
+ "saturate-",
353
+ "sepia-",
354
+ "drop-shadow-",
355
+ "filter-",
356
+ "backdrop-blur-",
357
+ "backdrop-brightness-",
358
+ "backdrop-contrast-",
359
+ "backdrop-grayscale-",
360
+ "backdrop-hue-rotate-",
361
+ "backdrop-invert-",
362
+ "backdrop-opacity-",
363
+ "backdrop-saturate-",
364
+ "backdrop-sepia-",
365
+ "backdrop-filter-",
366
+ "decoration-",
367
+ "underline-offset-",
368
+ "indent-",
369
+ "from-",
370
+ "via-",
371
+ "to-"
372
+ ];
373
+ var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
374
+ function isSafeArbitraryValue(value) {
375
+ return !value.includes("{") && !value.includes("}") && !value.includes(";");
352
376
  }
353
- function getGlobalDarkMode() {
354
- return isDark;
377
+ function splitRespectingBrackets(token) {
378
+ const parts = [];
379
+ let depth = 0;
380
+ let start = 0;
381
+ for (let i = 0; i < token.length; i++) {
382
+ const ch = token[i];
383
+ if (ch === "[") depth += 1;
384
+ else if (ch === "]") depth -= 1;
385
+ else if (ch === ":" && depth <= 0) {
386
+ parts.push(token.slice(start, i));
387
+ start = i + 1;
388
+ }
389
+ }
390
+ parts.push(token.slice(start));
391
+ return parts;
355
392
  }
356
-
357
- // src/nativeBridge.ts
358
- function resolveStyle(classString, pressed = false) {
359
- const KbachModule = import_react_native2.TurboModuleRegistry.getEnforcing("KbachModule");
360
- const colorScheme = getGlobalDarkMode() ? "dark" : "light";
361
- const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed);
362
- return JSON.parse(json);
393
+ function parseClass(token) {
394
+ const parts = splitRespectingBrackets(token);
395
+ let base = parts.pop() ?? token;
396
+ const modifiers = parts;
397
+ const important = base.startsWith("!");
398
+ if (important) {
399
+ base = base.slice(1);
400
+ }
401
+ const negative = base.startsWith("-");
402
+ if (negative) {
403
+ base = base.slice(1);
404
+ }
405
+ if (base.length >= 2 && base.startsWith("[") && base.endsWith("]")) {
406
+ const raw = base.slice(1, -1);
407
+ const colonIdx = raw.indexOf(":");
408
+ if (colonIdx !== -1) {
409
+ const property = raw.slice(0, colonIdx);
410
+ const rawValue = raw.slice(colonIdx + 1);
411
+ if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
412
+ const value = rawValue.replace(/_/g, " ");
413
+ return {
414
+ modifiers,
415
+ utility: ARBITRARY_PROPERTY_SENTINEL,
416
+ value: `${property}:${value}`,
417
+ isArbitrary: true,
418
+ important,
419
+ negative,
420
+ original: token
421
+ };
422
+ }
423
+ }
424
+ }
425
+ for (const prefix of VALUE_PREFIXES) {
426
+ if (!base.startsWith(prefix)) continue;
427
+ const value = base.slice(prefix.length);
428
+ if (value === "") continue;
429
+ if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
430
+ const raw = value.slice(1, -1);
431
+ if (!isSafeArbitraryValue(raw)) {
432
+ continue;
433
+ }
434
+ const spaced = raw.replace(/_/g, " ");
435
+ return {
436
+ modifiers,
437
+ utility: prefix.slice(0, -1),
438
+ value: spaced,
439
+ isArbitrary: true,
440
+ important,
441
+ negative,
442
+ original: token
443
+ };
444
+ }
445
+ return {
446
+ modifiers,
447
+ utility: prefix.slice(0, -1),
448
+ value,
449
+ isArbitrary: false,
450
+ important,
451
+ negative,
452
+ original: token
453
+ };
454
+ }
455
+ return {
456
+ modifiers,
457
+ utility: base,
458
+ value: null,
459
+ isArbitrary: false,
460
+ important,
461
+ negative,
462
+ original: token
463
+ };
363
464
  }
364
465
 
365
- // src/jsx-runtime.tsx
466
+ // src/jsxRuntimeCore.ts
467
+ var DYNAMIC_TOKEN_MATCH_RE = /var\(--([a-zA-Z0-9-]+)\)/g;
468
+ function substituteDynamicTokens(classStrRaw) {
469
+ if (!classStrRaw.includes("var(--")) return classStrRaw;
470
+ return classStrRaw.replace(DYNAMIC_TOKEN_MATCH_RE, (whole, name) => {
471
+ const value = (0, import_dynamicTokens.getDynamicToken)(name);
472
+ return value ?? whole;
473
+ });
474
+ }
475
+ var PERCENT_RELATIVE_CALC_HINT_RE = /[wh]-\[calc\([^)]*%[^)]*\)\]/;
476
+ function extractPercentRelativeCalcs(classStrRaw) {
477
+ const found = [];
478
+ for (const token of classStrRaw.split(/\s+/)) {
479
+ const parsed = parsePercentRelativeCalc(token);
480
+ if (parsed) found.push(parsed);
481
+ }
482
+ return found;
483
+ }
484
+ function stripPercentRelativeCalcTokens(classStrRaw) {
485
+ return classStrRaw.split(/\s+/).filter((token) => token && parsePercentRelativeCalc(token) === null).join(" ");
486
+ }
487
+ var STATE_MODIFIER_NAMES = /* @__PURE__ */ new Set(["hover", "focus", "disabled"]);
488
+ var STATE_MODIFIER_HINT_RE = /(^|\s|:)(hover|focus|disabled):/;
489
+ function stripModifiers(parts, namesToStrip) {
490
+ const utility = parts[parts.length - 1] ?? "";
491
+ const modifiers = parts.slice(0, -1).filter((m) => !namesToStrip.has(m));
492
+ return [...modifiers, utility].join(":");
493
+ }
494
+ function substituteStateModifiers(classStrRaw, states) {
495
+ if (!STATE_MODIFIER_HINT_RE.test(classStrRaw)) return classStrRaw;
496
+ const kept = [];
497
+ for (const token of classStrRaw.split(/\s+/)) {
498
+ if (!token) continue;
499
+ const parts = splitRespectingBrackets(token);
500
+ const modifiers = parts.slice(0, -1);
501
+ const required = modifiers.filter((m) => STATE_MODIFIER_NAMES.has(m));
502
+ if (required.length === 0) {
503
+ kept.push(token);
504
+ continue;
505
+ }
506
+ if (required.every((m) => states[m])) {
507
+ kept.push(stripModifiers(parts, STATE_MODIFIER_NAMES));
508
+ }
509
+ }
510
+ return kept.join(" ");
511
+ }
366
512
  function makeElement(isStaticChildren, type, props, key) {
367
513
  return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
368
514
  }
369
- function resolvedStyleFor(classStrRaw, userStyle, pressed) {
370
- const resolved = resolveStyle(classStrRaw, pressed);
515
+ function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed, layoutOverrides, states = { hover: false, focus: false, disabled: false }) {
516
+ const stateResolved = substituteStateModifiers(classStrRaw, states);
517
+ const cleaned = stripPercentRelativeCalcTokens(substituteDynamicTokens(stateResolved));
518
+ const resolved = resolveStyle2(cleaned, pressed);
519
+ if (layoutOverrides) {
520
+ Object.assign(resolved, layoutOverrides);
521
+ }
371
522
  if (userStyle === void 0) {
372
523
  return resolved;
373
524
  }
@@ -376,7 +527,82 @@ function resolvedStyleFor(classStrRaw, userStyle, pressed) {
376
527
  }
377
528
  return [resolved, userStyle];
378
529
  }
379
- function processElement(type, rawProps, key, isStaticChildren) {
530
+ var DARK_MODIFIER_RE = /(^|\s|:)dark:/;
531
+ var BREAKPOINT_MODIFIER_RE = /(^|\s|:)(sm|md|lg|xl|2xl):/;
532
+ var HOVER_MODIFIER_RE = /(^|\s|:)hover:/;
533
+ var FOCUS_MODIFIER_RE = /(^|\s|:)focus:/;
534
+ function ReactiveElement({
535
+ hostType,
536
+ hostRest,
537
+ classStrRaw,
538
+ userStyle,
539
+ resolveStyle: resolveStyle2,
540
+ elementKey,
541
+ isStaticChildren
542
+ }) {
543
+ (0, import_react.useSyncExternalStore)(import_darkModeStore.subscribeGlobalDarkMode, import_darkModeStore.getGlobalDarkMode);
544
+ (0, import_react.useSyncExternalStore)(import_dynamicTokens.subscribeDynamicTokens, import_dynamicTokens.getDynamicTokensVersion);
545
+ (0, import_react_native.useWindowDimensions)();
546
+ const [measuredBasis, setMeasuredBasis] = (0, import_react.useState)(null);
547
+ const measure = (0, import_react.useCallback)((e) => {
548
+ const { width: w, height: h } = e.nativeEvent.layout;
549
+ setMeasuredBasis((prev) => prev && prev.width === w && prev.height === h ? prev : { width: w, height: h });
550
+ }, []);
551
+ const [isHovered, setIsHovered] = (0, import_react.useState)(false);
552
+ const [isFocused, setIsFocused] = (0, import_react.useState)(false);
553
+ const percentCalcs = extractPercentRelativeCalcs(classStrRaw);
554
+ let layoutOverrides;
555
+ let hostRestWithLayout = hostRest;
556
+ if (percentCalcs.length > 0) {
557
+ layoutOverrides = {};
558
+ for (const calc of percentCalcs) {
559
+ const basis = measuredBasis?.[calc.property];
560
+ layoutOverrides[calc.property] = basis === void 0 ? "100%" : resolvePercentRelativeCalc(basis, calc);
561
+ }
562
+ const userOnLayout = hostRest.onLayout;
563
+ hostRestWithLayout = {
564
+ ...hostRest,
565
+ onLayout: userOnLayout ? (e) => {
566
+ measure(e);
567
+ userOnLayout(e);
568
+ } : measure
569
+ };
570
+ }
571
+ if (HOVER_MODIFIER_RE.test(classStrRaw)) {
572
+ const userOnHoverIn = hostRestWithLayout.onHoverIn;
573
+ const userOnHoverOut = hostRestWithLayout.onHoverOut;
574
+ hostRestWithLayout = {
575
+ ...hostRestWithLayout,
576
+ onHoverIn: (e) => {
577
+ setIsHovered(true);
578
+ userOnHoverIn?.(e);
579
+ },
580
+ onHoverOut: (e) => {
581
+ setIsHovered(false);
582
+ userOnHoverOut?.(e);
583
+ }
584
+ };
585
+ }
586
+ if (FOCUS_MODIFIER_RE.test(classStrRaw)) {
587
+ const userOnFocus = hostRestWithLayout.onFocus;
588
+ const userOnBlur = hostRestWithLayout.onBlur;
589
+ hostRestWithLayout = {
590
+ ...hostRestWithLayout,
591
+ onFocus: (e) => {
592
+ setIsFocused(true);
593
+ userOnFocus?.(e);
594
+ },
595
+ onBlur: (e) => {
596
+ setIsFocused(false);
597
+ userOnBlur?.(e);
598
+ }
599
+ };
600
+ }
601
+ const states = { hover: isHovered, focus: isFocused, disabled: hostRest.disabled === true };
602
+ const finalStyle = hostType === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed, layoutOverrides, states) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false, layoutOverrides, states);
603
+ return makeElement(isStaticChildren, hostType, { ...hostRestWithLayout, style: finalStyle }, elementKey);
604
+ }
605
+ function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
380
606
  if (type === null || typeof type === "symbol" || !rawProps) {
381
607
  return makeElement(isStaticChildren, type, rawProps ?? {}, key);
382
608
  }
@@ -384,15 +610,1183 @@ function processElement(type, rawProps, key, isStaticChildren) {
384
610
  if (typeof classStrRaw !== "string") {
385
611
  return makeElement(isStaticChildren, type, rawProps, key);
386
612
  }
387
- const finalStyle = type === import_react_native3.Pressable ? (state) => resolvedStyleFor(classStrRaw, userStyle, state.pressed) : resolvedStyleFor(classStrRaw, userStyle, false);
613
+ 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)) {
614
+ return (0, import_jsx_runtime.jsx)(
615
+ ReactiveElement,
616
+ { hostType: type, hostRest: rest, classStrRaw, userStyle, resolveStyle: resolveStyle2, elementKey: key, isStaticChildren },
617
+ key
618
+ );
619
+ }
620
+ const staticStates = { hover: false, focus: false, disabled: rest.disabled === true };
621
+ const finalStyle = type === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed, void 0, staticStates) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false, void 0, staticStates);
388
622
  return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, key);
389
623
  }
390
- function jsx(type, props, key) {
391
- return processElement(type, props, key, false);
624
+ function createJsxFunctions(resolveStyle2) {
625
+ function jsx2(type, props, key) {
626
+ return processElement(resolveStyle2, type, props, key, false);
627
+ }
628
+ function jsxs2(type, props, key) {
629
+ return processElement(resolveStyle2, type, props, key, true);
630
+ }
631
+ return { jsx: jsx2, jsxs: jsxs2 };
632
+ }
633
+
634
+ // src/nativeBridge.ts
635
+ var import_react_native2 = require("react-native");
636
+ var import_theme = require("./theme");
637
+ var import_darkModeStore2 = require("./darkModeStore");
638
+
639
+ // src/jsEngine/shared.ts
640
+ function decl(property, value) {
641
+ return { property, value };
642
+ }
643
+ function spacingPx(theme, value) {
644
+ const fromTable = theme.spacing[value];
645
+ if (fromTable !== void 0) return fromTable;
646
+ const n = Number(value);
647
+ return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
648
+ }
649
+ function resolveLength(theme, parsed) {
650
+ if (parsed.negative) return null;
651
+ const value = parsed.value;
652
+ if (value === null) return null;
653
+ if (parsed.isArbitrary) return value;
654
+ if (value === "full") return "100%";
655
+ if (value === "auto") return "auto";
656
+ const px = spacingPx(theme, value);
657
+ return px === void 0 ? null : `${px}px`;
658
+ }
659
+ function resolveNegatableLength(theme, parsed) {
660
+ if (!parsed.negative) return resolveLength(theme, parsed);
661
+ if (parsed.isArbitrary) return null;
662
+ const value = parsed.value;
663
+ if (value === null) return null;
664
+ const px = spacingPx(theme, value);
665
+ if (px === void 0) return null;
666
+ if (px === 0) return "0px";
667
+ return `-${px}px`;
668
+ }
669
+ function resolvePercent(parsed) {
670
+ if (parsed.negative) return null;
671
+ const value = parsed.value;
672
+ if (value === null) return null;
673
+ if (parsed.isArbitrary) return value;
674
+ const pct = Number(value);
675
+ if (!Number.isFinite(pct) || value.trim() === "") return null;
676
+ return String(pct / 100);
392
677
  }
393
- function jsxs(type, props, key) {
394
- return processElement(type, props, key, true);
678
+
679
+ // src/jsEngine/resolvers/layout.ts
680
+ function negateRaw(value, negative) {
681
+ return negative ? `-${value}` : value;
682
+ }
683
+ function overflowAxisValue(property, value) {
684
+ switch (value) {
685
+ case "auto":
686
+ case "hidden":
687
+ case "clip":
688
+ case "visible":
689
+ case "scroll":
690
+ return [decl(property, value)];
691
+ default:
692
+ return null;
693
+ }
694
+ }
695
+ function overscrollValue(property, value) {
696
+ switch (value) {
697
+ case "auto":
698
+ case "contain":
699
+ case "none":
700
+ return [decl(property, value)];
701
+ default:
702
+ return null;
703
+ }
395
704
  }
705
+ function resolve(parsed, theme) {
706
+ switch (parsed.utility) {
707
+ case "flex":
708
+ return parsed.value === null ? [decl("display", "flex")] : null;
709
+ case "grid":
710
+ return [decl("display", "grid")];
711
+ case "block":
712
+ return [decl("display", "block")];
713
+ case "inline-block":
714
+ return [decl("display", "inline-block")];
715
+ case "inline":
716
+ return [decl("display", "inline")];
717
+ case "inline-flex":
718
+ return [decl("display", "inline-flex")];
719
+ case "inline-grid":
720
+ return [decl("display", "inline-grid")];
721
+ case "contents":
722
+ return [decl("display", "contents")];
723
+ case "flow-root":
724
+ return [decl("display", "flow-root")];
725
+ case "hidden":
726
+ return [decl("display", "none")];
727
+ case "@container":
728
+ return [decl("container-type", "inline-size")];
729
+ case "items-center":
730
+ return [decl("align-items", "center")];
731
+ case "items-start":
732
+ return [decl("align-items", "flex-start")];
733
+ case "items-end":
734
+ return [decl("align-items", "flex-end")];
735
+ case "items-baseline":
736
+ return [decl("align-items", "baseline")];
737
+ case "items-stretch":
738
+ return [decl("align-items", "stretch")];
739
+ case "justify-center":
740
+ return [decl("justify-content", "center")];
741
+ case "justify-start":
742
+ return [decl("justify-content", "flex-start")];
743
+ case "justify-end":
744
+ return [decl("justify-content", "flex-end")];
745
+ case "justify-between":
746
+ return [decl("justify-content", "space-between")];
747
+ case "justify-around":
748
+ return [decl("justify-content", "space-around")];
749
+ case "justify-evenly":
750
+ return [decl("justify-content", "space-evenly")];
751
+ case "justify-normal":
752
+ return [decl("justify-content", "normal")];
753
+ case "justify-stretch":
754
+ return [decl("justify-content", "stretch")];
755
+ case "content-normal":
756
+ return [decl("align-content", "normal")];
757
+ case "content-start":
758
+ return [decl("align-content", "flex-start")];
759
+ case "content-end":
760
+ return [decl("align-content", "flex-end")];
761
+ case "content-center":
762
+ return [decl("align-content", "center")];
763
+ case "content-between":
764
+ return [decl("align-content", "space-between")];
765
+ case "content-around":
766
+ return [decl("align-content", "space-around")];
767
+ case "content-evenly":
768
+ return [decl("align-content", "space-evenly")];
769
+ case "content-stretch":
770
+ return [decl("align-content", "stretch")];
771
+ case "self-auto":
772
+ return [decl("align-self", "auto")];
773
+ case "self-center":
774
+ return [decl("align-self", "center")];
775
+ case "self-start":
776
+ return [decl("align-self", "flex-start")];
777
+ case "self-end":
778
+ return [decl("align-self", "flex-end")];
779
+ case "self-stretch":
780
+ return [decl("align-self", "stretch")];
781
+ case "self-baseline":
782
+ return [decl("align-self", "baseline")];
783
+ case "overflow-hidden":
784
+ return [decl("overflow", "hidden")];
785
+ case "overflow-auto":
786
+ return [decl("overflow", "auto")];
787
+ case "overflow-scroll":
788
+ return [decl("overflow", "scroll")];
789
+ case "overflow-visible":
790
+ return [decl("overflow", "visible")];
791
+ case "overflow-clip":
792
+ return [decl("overflow", "clip")];
793
+ case "overflow-x":
794
+ return parsed.value === null ? null : overflowAxisValue("overflow-x", parsed.value);
795
+ case "overflow-y":
796
+ return parsed.value === null ? null : overflowAxisValue("overflow-y", parsed.value);
797
+ case "overscroll":
798
+ return parsed.value === null ? null : overscrollValue("overscroll-behavior", parsed.value);
799
+ case "overscroll-x":
800
+ return parsed.value === null ? null : overscrollValue("overscroll-behavior-x", parsed.value);
801
+ case "overscroll-y":
802
+ return parsed.value === null ? null : overscrollValue("overscroll-behavior-y", parsed.value);
803
+ case "static":
804
+ return [decl("position", "static")];
805
+ case "relative":
806
+ return [decl("position", "relative")];
807
+ case "absolute":
808
+ return [decl("position", "absolute")];
809
+ case "fixed":
810
+ return [decl("position", "fixed")];
811
+ case "sticky":
812
+ return [decl("position", "sticky")];
813
+ case "z":
814
+ return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
815
+ case "order":
816
+ return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
817
+ case "grow":
818
+ return [decl("flex-grow", parsed.value ?? "1")];
819
+ case "shrink":
820
+ return [decl("flex-shrink", parsed.value ?? "1")];
821
+ // top/right/bottom/left/inset support real Tailwind's negative-value
822
+ // convention ("-top-4") — see resolveNegatableLength's own doc comment.
823
+ case "top": {
824
+ const v = resolveNegatableLength(theme, parsed);
825
+ return v === null ? null : [decl("top", v)];
826
+ }
827
+ case "right": {
828
+ const v = resolveNegatableLength(theme, parsed);
829
+ return v === null ? null : [decl("right", v)];
830
+ }
831
+ case "bottom": {
832
+ const v = resolveNegatableLength(theme, parsed);
833
+ return v === null ? null : [decl("bottom", v)];
834
+ }
835
+ case "left": {
836
+ const v = resolveNegatableLength(theme, parsed);
837
+ return v === null ? null : [decl("left", v)];
838
+ }
839
+ case "inset": {
840
+ const v = resolveNegatableLength(theme, parsed);
841
+ return v === null ? null : [decl("inset", v)];
842
+ }
843
+ case "inset-x": {
844
+ const v = resolveNegatableLength(theme, parsed);
845
+ return v === null ? null : [decl("left", v), decl("right", v)];
846
+ }
847
+ case "inset-y": {
848
+ const v = resolveNegatableLength(theme, parsed);
849
+ return v === null ? null : [decl("top", v), decl("bottom", v)];
850
+ }
851
+ // Logical inset — just a different CSS property name, same reasoning
852
+ // as Rust's layout.rs (no direction-tracking logic needed here).
853
+ case "start": {
854
+ const v = resolveNegatableLength(theme, parsed);
855
+ return v === null ? null : [decl("inset-inline-start", v)];
856
+ }
857
+ case "end": {
858
+ const v = resolveNegatableLength(theme, parsed);
859
+ return v === null ? null : [decl("inset-inline-end", v)];
860
+ }
861
+ // "aspect-" is a registered VALUE_PREFIXES entry (parser.ts), so
862
+ // "aspect-square"/"aspect-video"/"aspect-auto"/arbitrary all arrive
863
+ // here as utility="aspect" + a value, mirroring layout.rs's own
864
+ // "aspect" arm.
865
+ case "aspect": {
866
+ const value = parsed.value;
867
+ if (value === null) return null;
868
+ if (parsed.isArbitrary) return [decl("aspect-ratio", value)];
869
+ switch (value) {
870
+ case "square":
871
+ return [decl("aspect-ratio", "1 / 1")];
872
+ case "video":
873
+ return [decl("aspect-ratio", "16 / 9")];
874
+ case "auto":
875
+ return [decl("aspect-ratio", "auto")];
876
+ default:
877
+ return null;
878
+ }
879
+ }
880
+ default:
881
+ return null;
882
+ }
883
+ }
884
+ function resolveFlex(parsed, web) {
885
+ if (parsed.utility !== "flex") return null;
886
+ const value = parsed.value;
887
+ if (value === null) return null;
888
+ if (parsed.isArbitrary) return [decl("flex", value)];
889
+ switch (value) {
890
+ case "row":
891
+ return [decl("flex-direction", "row")];
892
+ case "col":
893
+ return [decl("flex-direction", "column")];
894
+ case "row-reverse":
895
+ return [decl("flex-direction", "row-reverse")];
896
+ case "col-reverse":
897
+ return [decl("flex-direction", "column-reverse")];
898
+ case "wrap":
899
+ return [decl("flex-wrap", "wrap")];
900
+ case "wrap-reverse":
901
+ return [decl("flex-wrap", "wrap-reverse")];
902
+ case "nowrap":
903
+ return [decl("flex-wrap", "nowrap")];
904
+ case "1":
905
+ return [decl("flex", "1")];
906
+ case "auto":
907
+ return [decl("flex", web ? "auto" : "1")];
908
+ case "initial":
909
+ return [decl("flex", web ? "initial" : "1")];
910
+ case "none":
911
+ return [decl("flex", web ? "none" : "0")];
912
+ case "grow":
913
+ return [decl("flex-grow", "1")];
914
+ case "grow-0":
915
+ return [decl("flex-grow", "0")];
916
+ case "shrink":
917
+ return [decl("flex-shrink", "1")];
918
+ case "shrink-0":
919
+ return [decl("flex-shrink", "0")];
920
+ default:
921
+ return null;
922
+ }
923
+ }
924
+
925
+ // src/jsEngine/resolvers/spacing.ts
926
+ function namedSize(key) {
927
+ switch (key) {
928
+ case "sm":
929
+ return "24rem";
930
+ case "md":
931
+ return "28rem";
932
+ case "lg":
933
+ return "32rem";
934
+ case "xl":
935
+ return "36rem";
936
+ case "2xl":
937
+ return "42rem";
938
+ case "3xl":
939
+ return "48rem";
940
+ case "4xl":
941
+ return "56rem";
942
+ case "5xl":
943
+ return "64rem";
944
+ case "6xl":
945
+ return "72rem";
946
+ case "7xl":
947
+ return "80rem";
948
+ case "8xl":
949
+ return "88rem";
950
+ case "9xl":
951
+ return "96rem";
952
+ default:
953
+ return null;
954
+ }
955
+ }
956
+ function fractionPercent(value) {
957
+ const slashIdx = value.indexOf("/");
958
+ if (slashIdx === -1) return null;
959
+ const numStr = value.slice(0, slashIdx);
960
+ const denStr = value.slice(slashIdx + 1);
961
+ const num = Number(numStr);
962
+ const den = Number(denStr);
963
+ if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
964
+ if (den === 0) return null;
965
+ const pct = num / den * 100;
966
+ const formatted = pct.toFixed(6);
967
+ const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
968
+ return `${trimmed}%`;
969
+ }
970
+ function cssSizeKeyword(key) {
971
+ switch (key) {
972
+ case "min":
973
+ return "min-content";
974
+ case "max":
975
+ return "max-content";
976
+ case "fit":
977
+ return "fit-content";
978
+ default:
979
+ return null;
980
+ }
981
+ }
982
+ function resolveSize(theme, parsed) {
983
+ if (!parsed.isArbitrary && parsed.value !== null) {
984
+ const named = namedSize(parsed.value);
985
+ if (named !== null) return named;
986
+ const kw = cssSizeKeyword(parsed.value);
987
+ if (kw !== null) return kw;
988
+ const fraction = fractionPercent(parsed.value);
989
+ if (fraction !== null) return fraction;
990
+ }
991
+ return resolveLength(theme, parsed);
992
+ }
993
+ function resolve2(parsed, theme) {
994
+ const length = () => resolveLength(theme, parsed);
995
+ const size = () => resolveSize(theme, parsed);
996
+ const negatableLength = () => resolveNegatableLength(theme, parsed);
997
+ switch (parsed.utility) {
998
+ case "p": {
999
+ const v = length();
1000
+ return v === null ? null : [decl("padding", v)];
1001
+ }
1002
+ case "px": {
1003
+ const v = length();
1004
+ return v === null ? null : [decl("padding-left", v), decl("padding-right", v)];
1005
+ }
1006
+ case "py": {
1007
+ const v = length();
1008
+ return v === null ? null : [decl("padding-top", v), decl("padding-bottom", v)];
1009
+ }
1010
+ case "pt": {
1011
+ const v = length();
1012
+ return v === null ? null : [decl("padding-top", v)];
1013
+ }
1014
+ case "pr": {
1015
+ const v = length();
1016
+ return v === null ? null : [decl("padding-right", v)];
1017
+ }
1018
+ case "pb": {
1019
+ const v = length();
1020
+ return v === null ? null : [decl("padding-bottom", v)];
1021
+ }
1022
+ case "pl": {
1023
+ const v = length();
1024
+ return v === null ? null : [decl("padding-left", v)];
1025
+ }
1026
+ case "m": {
1027
+ const v = negatableLength();
1028
+ return v === null ? null : [decl("margin", v)];
1029
+ }
1030
+ case "mx": {
1031
+ const v = negatableLength();
1032
+ return v === null ? null : [decl("margin-left", v), decl("margin-right", v)];
1033
+ }
1034
+ case "my": {
1035
+ const v = negatableLength();
1036
+ return v === null ? null : [decl("margin-top", v), decl("margin-bottom", v)];
1037
+ }
1038
+ case "mt": {
1039
+ const v = negatableLength();
1040
+ return v === null ? null : [decl("margin-top", v)];
1041
+ }
1042
+ case "mr": {
1043
+ const v = negatableLength();
1044
+ return v === null ? null : [decl("margin-right", v)];
1045
+ }
1046
+ case "mb": {
1047
+ const v = negatableLength();
1048
+ return v === null ? null : [decl("margin-bottom", v)];
1049
+ }
1050
+ case "ml": {
1051
+ const v = negatableLength();
1052
+ return v === null ? null : [decl("margin-left", v)];
1053
+ }
1054
+ case "gap": {
1055
+ const v = length();
1056
+ return v === null ? null : [decl("gap", v)];
1057
+ }
1058
+ case "gap-x": {
1059
+ const v = length();
1060
+ return v === null ? null : [decl("column-gap", v)];
1061
+ }
1062
+ case "gap-y": {
1063
+ const v = length();
1064
+ return v === null ? null : [decl("row-gap", v)];
1065
+ }
1066
+ case "w": {
1067
+ const v = size();
1068
+ return v === null ? null : [decl("width", v)];
1069
+ }
1070
+ case "h": {
1071
+ const v = size();
1072
+ return v === null ? null : [decl("height", v)];
1073
+ }
1074
+ case "min-w": {
1075
+ const v = size();
1076
+ return v === null ? null : [decl("min-width", v)];
1077
+ }
1078
+ case "max-w": {
1079
+ const v = size();
1080
+ return v === null ? null : [decl("max-width", v)];
1081
+ }
1082
+ case "min-h": {
1083
+ const v = size();
1084
+ return v === null ? null : [decl("min-height", v)];
1085
+ }
1086
+ case "max-h": {
1087
+ const v = size();
1088
+ return v === null ? null : [decl("max-height", v)];
1089
+ }
1090
+ case "size": {
1091
+ const v = size();
1092
+ return v === null ? null : [decl("width", v), decl("height", v)];
1093
+ }
1094
+ case "basis": {
1095
+ const v = size();
1096
+ return v === null ? null : [decl("flex-basis", v)];
1097
+ }
1098
+ default:
1099
+ return null;
1100
+ }
1101
+ }
1102
+
1103
+ // src/jsEngine/resolvers/color.ts
1104
+ function lookupHex(theme, key) {
1105
+ const entry = theme.colors[key];
1106
+ return typeof entry === "string" ? entry : null;
1107
+ }
1108
+ function hexToRgb(hex) {
1109
+ const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
1110
+ if (!m) return null;
1111
+ let h = m[1];
1112
+ if (h.length === 3) h = h.split("").map((c) => c + c).join("");
1113
+ const n = parseInt(h, 16);
1114
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
1115
+ }
1116
+ function splitOpacity(value) {
1117
+ const slash = value.lastIndexOf("/");
1118
+ if (slash === -1) return [value, null];
1119
+ const opacityText = value.slice(slash + 1);
1120
+ const n = Number(opacityText);
1121
+ if (opacityText !== "" && Number.isInteger(n) && n >= 0 && n <= 100) {
1122
+ return [value.slice(0, slash), n];
1123
+ }
1124
+ return [value, null];
1125
+ }
1126
+ function colorValue(theme, parsed) {
1127
+ const value = parsed.value;
1128
+ if (value === null) return null;
1129
+ if (parsed.isArbitrary) return value;
1130
+ const [name, opacity] = splitOpacity(value);
1131
+ const hex = lookupHex(theme, name);
1132
+ if (hex === null) return null;
1133
+ if (opacity === null) return hex;
1134
+ const rgb = hexToRgb(hex);
1135
+ if (rgb === null) return hex;
1136
+ return `rgba(${rgb.join(",")},${opacity / 100})`;
1137
+ }
1138
+
1139
+ // src/jsEngine/resolvers/border.ts
1140
+ function radiusSize(key) {
1141
+ switch (key) {
1142
+ case "none":
1143
+ return "0px";
1144
+ case "sm":
1145
+ return "0.125rem";
1146
+ case "md":
1147
+ return "0.375rem";
1148
+ case "lg":
1149
+ return "0.5rem";
1150
+ case "xl":
1151
+ return "0.75rem";
1152
+ case "2xl":
1153
+ return "1rem";
1154
+ case "3xl":
1155
+ return "1.5rem";
1156
+ case "full":
1157
+ return "9999px";
1158
+ default:
1159
+ return null;
1160
+ }
1161
+ }
1162
+ function borderSideProperty(side) {
1163
+ switch (side) {
1164
+ case "t":
1165
+ return "border-top";
1166
+ case "r":
1167
+ return "border-right";
1168
+ case "b":
1169
+ return "border-bottom";
1170
+ case "l":
1171
+ return "border-left";
1172
+ default:
1173
+ return null;
1174
+ }
1175
+ }
1176
+ function borderValue(theme, parsed) {
1177
+ const value = parsed.value;
1178
+ if (value === null) return null;
1179
+ if (!parsed.isArbitrary) {
1180
+ const side = borderSideProperty(value);
1181
+ if (side !== null) {
1182
+ return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
1183
+ }
1184
+ if (value === "collapse") return [decl("border-collapse", "collapse")];
1185
+ if (value === "separate") return [decl("border-collapse", "separate")];
1186
+ }
1187
+ if (parsed.isArbitrary) {
1188
+ return [decl("border-width", value)];
1189
+ }
1190
+ if (Number.isFinite(Number(value)) && value.trim() !== "") {
1191
+ const v = resolveLength(theme, parsed);
1192
+ return v === null ? null : [decl("border-width", v)];
1193
+ }
1194
+ if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1195
+ return [decl("border-style", value)];
1196
+ }
1197
+ const color = colorValue(theme, parsed);
1198
+ return color === null ? null : [decl("border-color", color)];
1199
+ }
1200
+ function borderSideValue(theme, parsed, sideProperty) {
1201
+ const value = parsed.value;
1202
+ if (value === null) return null;
1203
+ if (parsed.isArbitrary) return [decl(`${sideProperty}-width`, value)];
1204
+ if (Number.isFinite(Number(value)) && value.trim() !== "") {
1205
+ const v = resolveLength(theme, parsed);
1206
+ return v === null ? null : [decl(`${sideProperty}-width`, v)];
1207
+ }
1208
+ if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1209
+ return [decl(`${sideProperty}-style`, value)];
1210
+ }
1211
+ const color = colorValue(theme, parsed);
1212
+ return color === null ? null : [decl(`${sideProperty}-color`, color)];
1213
+ }
1214
+ function borderAxisValue(theme, parsed, sideA, sideB) {
1215
+ const value = parsed.value;
1216
+ if (value === null) return null;
1217
+ if (parsed.isArbitrary) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
1218
+ if (Number.isFinite(Number(value)) && value.trim() !== "") {
1219
+ const v = resolveLength(theme, parsed);
1220
+ return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
1221
+ }
1222
+ if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
1223
+ return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
1224
+ }
1225
+ const color = colorValue(theme, parsed);
1226
+ return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
1227
+ }
1228
+ function radiusProperties(side) {
1229
+ switch (side) {
1230
+ case "t":
1231
+ return ["border-top-left-radius", "border-top-right-radius"];
1232
+ case "r":
1233
+ return ["border-top-right-radius", "border-bottom-right-radius"];
1234
+ case "b":
1235
+ return ["border-bottom-right-radius", "border-bottom-left-radius"];
1236
+ case "l":
1237
+ return ["border-top-left-radius", "border-bottom-left-radius"];
1238
+ case "tl":
1239
+ return ["border-top-left-radius"];
1240
+ case "tr":
1241
+ return ["border-top-right-radius"];
1242
+ case "br":
1243
+ return ["border-bottom-right-radius"];
1244
+ case "bl":
1245
+ return ["border-bottom-left-radius"];
1246
+ default:
1247
+ return null;
1248
+ }
1249
+ }
1250
+ function resolveRadiusValue(theme, parsed) {
1251
+ if (!parsed.isArbitrary && parsed.value !== null) {
1252
+ const size = radiusSize(parsed.value);
1253
+ if (size !== null) return size;
1254
+ }
1255
+ return resolveLength(theme, parsed);
1256
+ }
1257
+ function resolveRadiusSide(theme, parsed, side) {
1258
+ const properties = radiusProperties(side);
1259
+ if (properties === null) return null;
1260
+ const value = resolveRadiusValue(theme, parsed);
1261
+ if (value === null) return null;
1262
+ return properties.map((p) => decl(p, value));
1263
+ }
1264
+ var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
1265
+ function outlineWidthValue(key) {
1266
+ switch (key) {
1267
+ case "0":
1268
+ return "0px";
1269
+ case "1":
1270
+ return "1px";
1271
+ case "2":
1272
+ return "2px";
1273
+ case "4":
1274
+ return "4px";
1275
+ case "8":
1276
+ return "8px";
1277
+ default:
1278
+ return null;
1279
+ }
1280
+ }
1281
+ function outlineValue(theme, parsed) {
1282
+ const value = parsed.value;
1283
+ if (value === null) return null;
1284
+ if (parsed.isArbitrary) return [decl("outline-width", value)];
1285
+ const w = outlineWidthValue(value);
1286
+ if (w !== null) return [decl("outline-width", w)];
1287
+ if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
1288
+ const color = colorValue(theme, parsed);
1289
+ return color === null ? null : [decl("outline-color", color)];
1290
+ }
1291
+ function outlineOffsetValue(parsed) {
1292
+ const value = parsed.value;
1293
+ if (value === null) return null;
1294
+ if (parsed.isArbitrary) return [decl("outline-offset", value)];
1295
+ const w = outlineWidthValue(value);
1296
+ return w === null ? null : [decl("outline-offset", w)];
1297
+ }
1298
+ 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))";
1299
+ function ringWidth(key) {
1300
+ switch (key) {
1301
+ case "0":
1302
+ return "0px";
1303
+ case "1":
1304
+ return "1px";
1305
+ case "2":
1306
+ return "2px";
1307
+ case "4":
1308
+ return "4px";
1309
+ case "8":
1310
+ return "8px";
1311
+ default:
1312
+ return null;
1313
+ }
1314
+ }
1315
+ function ringValue(theme, parsed) {
1316
+ const value = parsed.value;
1317
+ if (value === null) return null;
1318
+ if (value === "inset") {
1319
+ return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
1320
+ }
1321
+ if (!parsed.isArbitrary) {
1322
+ const w = ringWidth(value);
1323
+ if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
1324
+ }
1325
+ const color = colorValue(theme, parsed);
1326
+ if (color === null) return null;
1327
+ return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
1328
+ }
1329
+ function ringOffsetValue(theme, parsed) {
1330
+ const value = parsed.value;
1331
+ if (value === null) return null;
1332
+ if (!parsed.isArbitrary) {
1333
+ const w = ringWidth(value);
1334
+ if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
1335
+ }
1336
+ const color = colorValue(theme, parsed);
1337
+ if (color === null) return null;
1338
+ return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
1339
+ }
1340
+ var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
1341
+ function resolve3(parsed, theme) {
1342
+ switch (parsed.utility) {
1343
+ case "border":
1344
+ if (parsed.value === null) return [decl("border-width", "1px"), decl("border-style", "solid")];
1345
+ return borderValue(theme, parsed);
1346
+ case "border-t":
1347
+ return borderSideValue(theme, parsed, "border-top");
1348
+ case "border-r":
1349
+ return borderSideValue(theme, parsed, "border-right");
1350
+ case "border-b":
1351
+ return borderSideValue(theme, parsed, "border-bottom");
1352
+ case "border-l":
1353
+ return borderSideValue(theme, parsed, "border-left");
1354
+ case "border-x":
1355
+ return borderAxisValue(theme, parsed, "border-left", "border-right");
1356
+ case "border-y":
1357
+ return borderAxisValue(theme, parsed, "border-top", "border-bottom");
1358
+ case "rounded": {
1359
+ if (parsed.value === null) return [decl("border-radius", "0.25rem")];
1360
+ const value = parsed.value;
1361
+ if (!parsed.isArbitrary) {
1362
+ const size = radiusSize(value);
1363
+ if (size !== null) return [decl("border-radius", size)];
1364
+ }
1365
+ const v = resolveLength(theme, parsed);
1366
+ return v === null ? null : [decl("border-radius", v)];
1367
+ }
1368
+ case "ring":
1369
+ if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
1370
+ return ringValue(theme, parsed);
1371
+ case "ring-offset":
1372
+ return ringOffsetValue(theme, parsed);
1373
+ case "outline":
1374
+ if (parsed.value === null) return [decl("outline-style", "solid")];
1375
+ if (parsed.value === "none") return [decl("outline", "none")];
1376
+ return outlineValue(theme, parsed);
1377
+ case "outline-offset":
1378
+ return outlineOffsetValue(parsed);
1379
+ default:
1380
+ if (parsed.utility.startsWith("rounded-") && RADIUS_SIDES.has(parsed.utility.slice("rounded-".length))) {
1381
+ return resolveRadiusSide(theme, parsed, parsed.utility.slice("rounded-".length));
1382
+ }
1383
+ return null;
1384
+ }
1385
+ }
1386
+
1387
+ // src/jsEngine/resolvers/typography.ts
1388
+ function textSize(key) {
1389
+ switch (key) {
1390
+ case "xs":
1391
+ return "0.75rem";
1392
+ case "sm":
1393
+ return "0.875rem";
1394
+ case "base":
1395
+ return "1rem";
1396
+ case "lg":
1397
+ return "1.125rem";
1398
+ case "xl":
1399
+ return "1.25rem";
1400
+ case "2xl":
1401
+ return "1.5rem";
1402
+ case "3xl":
1403
+ return "1.875rem";
1404
+ case "4xl":
1405
+ return "2.25rem";
1406
+ case "5xl":
1407
+ return "3rem";
1408
+ case "6xl":
1409
+ return "3.75rem";
1410
+ case "7xl":
1411
+ return "4.5rem";
1412
+ case "8xl":
1413
+ return "6rem";
1414
+ case "9xl":
1415
+ return "8rem";
1416
+ default:
1417
+ return null;
1418
+ }
1419
+ }
1420
+ function lineHeightSize(key) {
1421
+ switch (key) {
1422
+ case "3":
1423
+ return "0.75rem";
1424
+ case "4":
1425
+ return "1rem";
1426
+ case "5":
1427
+ return "1.25rem";
1428
+ case "6":
1429
+ return "1.5rem";
1430
+ case "7":
1431
+ return "1.75rem";
1432
+ case "8":
1433
+ return "2rem";
1434
+ case "9":
1435
+ return "2.25rem";
1436
+ case "10":
1437
+ return "2.5rem";
1438
+ default:
1439
+ return null;
1440
+ }
1441
+ }
1442
+ function textAlign(key) {
1443
+ switch (key) {
1444
+ case "left":
1445
+ return "left";
1446
+ case "center":
1447
+ return "center";
1448
+ case "right":
1449
+ return "right";
1450
+ case "justify":
1451
+ return "justify";
1452
+ // Logical alignment — same "no direction-tracking logic needed" reasoning
1453
+ // as layout.rs's start/end inset properties.
1454
+ case "start":
1455
+ return "start";
1456
+ case "end":
1457
+ return "end";
1458
+ default:
1459
+ return null;
1460
+ }
1461
+ }
1462
+ function fontWeight(key) {
1463
+ switch (key) {
1464
+ case "thin":
1465
+ return "100";
1466
+ case "extralight":
1467
+ return "200";
1468
+ case "light":
1469
+ return "300";
1470
+ case "normal":
1471
+ return "400";
1472
+ case "medium":
1473
+ return "500";
1474
+ case "semibold":
1475
+ return "600";
1476
+ case "bold":
1477
+ return "700";
1478
+ case "extrabold":
1479
+ return "800";
1480
+ case "black":
1481
+ return "900";
1482
+ default:
1483
+ return null;
1484
+ }
1485
+ }
1486
+ function fontFamilyValue(theme, key) {
1487
+ const fromTheme = theme.fontFamily?.[key];
1488
+ if (fromTheme !== void 0) return fromTheme;
1489
+ switch (key) {
1490
+ case "sans":
1491
+ return 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
1492
+ case "serif":
1493
+ return 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif';
1494
+ case "mono":
1495
+ return 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
1496
+ default:
1497
+ return null;
1498
+ }
1499
+ }
1500
+
1501
+ // src/jsEngine/resolvers/effects.ts
1502
+ function nativeShadowValue(key) {
1503
+ switch (key) {
1504
+ case "sm":
1505
+ return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
1506
+ case "DEFAULT":
1507
+ return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
1508
+ case "md":
1509
+ return { offsetY: 4, radius: 6, opacity: 0.1, elevation: 4 };
1510
+ case "lg":
1511
+ return { offsetY: 10, radius: 15, opacity: 0.1, elevation: 8 };
1512
+ case "xl":
1513
+ return { offsetY: 20, radius: 25, opacity: 0.1, elevation: 12 };
1514
+ case "2xl":
1515
+ return { offsetY: 25, radius: 50, opacity: 0.25, elevation: 16 };
1516
+ case "none":
1517
+ return { offsetY: 0, radius: 0, opacity: 0, elevation: 0 };
1518
+ default:
1519
+ return null;
1520
+ }
1521
+ }
1522
+ function nativeShadowDeclarations(parsed) {
1523
+ if (parsed.utility !== "shadow" || parsed.isArbitrary) return null;
1524
+ const key = parsed.value ?? "DEFAULT";
1525
+ const s = nativeShadowValue(key);
1526
+ if (s === null) return null;
1527
+ return [
1528
+ decl("shadow-color", "#000000"),
1529
+ decl("shadow-offset-x", "0"),
1530
+ decl("shadow-offset-y", String(s.offsetY)),
1531
+ decl("shadow-opacity", String(s.opacity)),
1532
+ decl("shadow-radius", String(s.radius)),
1533
+ decl("elevation", String(s.elevation))
1534
+ ];
1535
+ }
1536
+
1537
+ // src/jsEngine/resolveUtilityNative.ts
1538
+ function firstFontName(stack) {
1539
+ const first = stack.split(",")[0] ?? stack;
1540
+ return first.trim().replace(/^["']|["']$/g, "");
1541
+ }
1542
+ function resolveTypographyNative(parsed, theme) {
1543
+ switch (parsed.utility) {
1544
+ case "font": {
1545
+ if (parsed.value === null) return null;
1546
+ if (parsed.isArbitrary) {
1547
+ return [decl("font-family", firstFontName(parsed.value))];
1548
+ }
1549
+ const w = fontWeight(parsed.value);
1550
+ if (w !== null) return [decl("font-weight", w)];
1551
+ const family = fontFamilyValue(theme, parsed.value);
1552
+ return family === null ? null : [decl("font-family", firstFontName(family))];
1553
+ }
1554
+ case "uppercase":
1555
+ return [decl("text-transform", "uppercase")];
1556
+ case "lowercase":
1557
+ return [decl("text-transform", "lowercase")];
1558
+ case "capitalize":
1559
+ return [decl("text-transform", "capitalize")];
1560
+ case "underline":
1561
+ return [decl("text-decoration-line", "underline")];
1562
+ case "line-through":
1563
+ return [decl("text-decoration-line", "line-through")];
1564
+ case "no-underline":
1565
+ return [decl("text-decoration-line", "none")];
1566
+ case "italic":
1567
+ return [decl("font-style", "italic")];
1568
+ case "not-italic":
1569
+ return [decl("font-style", "normal")];
1570
+ default:
1571
+ return null;
1572
+ }
1573
+ }
1574
+ function resolveLeadingTrackingNative(parsed) {
1575
+ const value = parsed.value;
1576
+ if (value === null) return null;
1577
+ if (parsed.utility === "leading") {
1578
+ if (parsed.isArbitrary) return [decl("line-height", value)];
1579
+ const v = lineHeightSize(value);
1580
+ return v === null ? null : [decl("line-height", v)];
1581
+ }
1582
+ if (parsed.utility === "tracking" && parsed.isArbitrary) {
1583
+ return [decl("letter-spacing", value)];
1584
+ }
1585
+ return null;
1586
+ }
1587
+ function nativeHexColor(parsed, theme) {
1588
+ return colorValue(theme, parsed);
1589
+ }
1590
+ function resolveTextNative(parsed, theme) {
1591
+ if (!parsed.isArbitrary && parsed.value !== null) {
1592
+ const size = textSize(parsed.value);
1593
+ if (size !== null) return [decl("font-size", size)];
1594
+ const align = textAlign(parsed.value);
1595
+ if (align !== null) return [decl("text-align", align)];
1596
+ }
1597
+ const hex = nativeHexColor(parsed, theme);
1598
+ return hex === null ? null : [decl("color", hex)];
1599
+ }
1600
+ function resolveColorNative(parsed, theme) {
1601
+ switch (parsed.utility) {
1602
+ case "bg": {
1603
+ const hex = nativeHexColor(parsed, theme);
1604
+ return hex === null ? null : [decl("background-color", hex)];
1605
+ }
1606
+ case "text":
1607
+ return resolveTextNative(parsed, theme);
1608
+ default:
1609
+ return null;
1610
+ }
1611
+ }
1612
+ function resolveOpacityNative(parsed) {
1613
+ if (parsed.utility !== "opacity") return null;
1614
+ const v = resolvePercent(parsed);
1615
+ return v === null ? null : [decl("opacity", v)];
1616
+ }
1617
+ function resolveUtilityNative(parsed, theme) {
1618
+ 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);
1619
+ }
1620
+
1621
+ // src/jsEngine/resolveStyle.ts
1622
+ var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
1623
+ function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
1624
+ if (modifier === "dark") return colorScheme === "dark";
1625
+ if (modifier === "active") return pressed;
1626
+ if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
1627
+ const minWidth = theme.screens[modifier];
1628
+ if (minWidth === void 0) return null;
1629
+ return width >= minWidth;
1630
+ }
1631
+ return null;
1632
+ }
1633
+ function kebabToCamel(s) {
1634
+ return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
1635
+ }
1636
+ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
1637
+ "padding",
1638
+ "padding-top",
1639
+ "padding-right",
1640
+ "padding-bottom",
1641
+ "padding-left",
1642
+ "margin",
1643
+ "margin-top",
1644
+ "margin-right",
1645
+ "margin-bottom",
1646
+ "margin-left",
1647
+ "gap",
1648
+ "column-gap",
1649
+ "row-gap",
1650
+ "width",
1651
+ "height",
1652
+ "min-width",
1653
+ "max-width",
1654
+ "min-height",
1655
+ "max-height",
1656
+ "top",
1657
+ "right",
1658
+ "bottom",
1659
+ "left",
1660
+ "inset",
1661
+ "border-radius",
1662
+ "border-width",
1663
+ "font-size",
1664
+ "z-index",
1665
+ "line-height",
1666
+ "letter-spacing",
1667
+ "flex",
1668
+ "flex-grow",
1669
+ "flex-shrink",
1670
+ "order",
1671
+ "flex-basis",
1672
+ "shadow-opacity",
1673
+ "shadow-radius",
1674
+ "elevation",
1675
+ "opacity",
1676
+ // Per-side border width + per-corner radius — see resolvers/border.ts's
1677
+ // new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
1678
+ // style system wants plain numbers for these exactly like the generic
1679
+ // "border-width"/"border-radius" forms above.
1680
+ "border-top-width",
1681
+ "border-right-width",
1682
+ "border-bottom-width",
1683
+ "border-left-width",
1684
+ "border-top-left-radius",
1685
+ "border-top-right-radius",
1686
+ "border-bottom-right-radius",
1687
+ "border-bottom-left-radius",
1688
+ "outline-width",
1689
+ "outline-offset"
1690
+ ]);
1691
+ function isPlainPercentage(value) {
1692
+ if (!value.endsWith("%")) return false;
1693
+ let digits = value.slice(0, -1);
1694
+ if (digits.startsWith("-")) digits = digits.slice(1);
1695
+ return digits.length > 0 && /^[0-9.]+$/.test(digits);
1696
+ }
1697
+ function rnStyleValue(property, value) {
1698
+ if (!NUMERIC_LENGTH_PROPS.has(property)) {
1699
+ return { value, warning: null };
1700
+ }
1701
+ let px = null;
1702
+ if (value.endsWith("px")) {
1703
+ const n = Number(value.slice(0, -2));
1704
+ px = Number.isFinite(n) ? n : null;
1705
+ } else if (value.endsWith("rem")) {
1706
+ const n = Number(value.slice(0, -3));
1707
+ px = Number.isFinite(n) ? n * 16 : null;
1708
+ } else {
1709
+ const n = Number(value);
1710
+ px = value.trim() !== "" && Number.isFinite(n) ? n : null;
1711
+ }
1712
+ if (px !== null) return { value: px, warning: null };
1713
+ if (isPlainPercentage(value)) {
1714
+ return { value, warning: null };
1715
+ }
1716
+ const reduced = reduceConstantMath(value);
1717
+ if (reduced !== null) {
1718
+ return { value: reduced, warning: null };
1719
+ }
1720
+ const warning = `Kbach: "${value}" is not a valid native value for "${property}" \u2014 dropped. calc()/clamp()/min()/max() 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). Use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this value in JS instead.`;
1721
+ return { value: null, warning };
1722
+ }
1723
+ function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
1724
+ const style = {};
1725
+ const warnings = [];
1726
+ let shadowOffset = null;
1727
+ for (const token of classString.split(/\s+/).filter(Boolean)) {
1728
+ const parsed = parseClass(token);
1729
+ const allModifiersHold = parsed.modifiers.every(
1730
+ (m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
1731
+ );
1732
+ if (!allModifiersHold) continue;
1733
+ const decls = resolveUtilityNative(parsed, theme);
1734
+ if (decls === null) continue;
1735
+ for (const d of decls) {
1736
+ if (d.property.startsWith("__")) {
1737
+ continue;
1738
+ }
1739
+ if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
1740
+ const n = Number(d.value);
1741
+ if (!Number.isFinite(n)) continue;
1742
+ if (shadowOffset === null) shadowOffset = {};
1743
+ shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
1744
+ continue;
1745
+ }
1746
+ const { value, warning } = rnStyleValue(d.property, d.value);
1747
+ if (warning !== null) warnings.push(warning);
1748
+ if (value !== null) style[kebabToCamel(d.property)] = value;
1749
+ }
1750
+ }
1751
+ if (shadowOffset !== null) {
1752
+ style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
1753
+ }
1754
+ return { style, warnings };
1755
+ }
1756
+
1757
+ // src/nativeBridge.ts
1758
+ function resolveStyle(classString, pressed = false) {
1759
+ const colorScheme = (0, import_darkModeStore2.getGlobalDarkMode)() ? "dark" : "light";
1760
+ const width = import_react_native2.Dimensions.get("window").width;
1761
+ const KbachModule = import_react_native2.TurboModuleRegistry.get("KbachModule");
1762
+ if (!KbachModule) {
1763
+ const { style: style2, warnings: warnings2 } = resolveStyleJsWithWarnings(classString, (0, import_theme.getTheme)(), colorScheme, pressed, width);
1764
+ warnIfDev(classString, warnings2);
1765
+ return style2;
1766
+ }
1767
+ const json = KbachModule.resolveStyle(classString, (0, import_theme.getThemeJson)(), colorScheme, pressed, width);
1768
+ const style = JSON.parse(json);
1769
+ const warnings = style.__kbachWarnings;
1770
+ if (warnings !== void 0) {
1771
+ delete style.__kbachWarnings;
1772
+ warnIfDev(classString, warnings);
1773
+ }
1774
+ return style;
1775
+ }
1776
+ var warnedMessages = /* @__PURE__ */ new Set();
1777
+ function warnIfDev(classString, warnings) {
1778
+ if (warnings.length === 0) return;
1779
+ if (typeof __DEV__ !== "undefined" && !__DEV__) return;
1780
+ for (const warning of warnings) {
1781
+ const message = `${warning} (from className "${classString}")`;
1782
+ if (warnedMessages.has(message)) continue;
1783
+ warnedMessages.add(message);
1784
+ console.warn(message);
1785
+ }
1786
+ }
1787
+
1788
+ // src/jsx-runtime.tsx
1789
+ var { jsx, jsxs } = createJsxFunctions(resolveStyle);
396
1790
  // Annotate the CommonJS export names for ESM import in node:
397
1791
  0 && (module.exports = {
398
1792
  Fragment,