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

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