tailwind-styled-v4 5.0.10 → 5.0.11

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 (93) hide show
  1. package/README.md +245 -373
  2. package/dist/analyzer.js +75 -22
  3. package/dist/analyzer.js.map +1 -1
  4. package/dist/analyzer.mjs +74 -21
  5. package/dist/analyzer.mjs.map +1 -1
  6. package/dist/animate.js +4 -2
  7. package/dist/animate.js.map +1 -1
  8. package/dist/animate.mjs +4 -2
  9. package/dist/animate.mjs.map +1 -1
  10. package/dist/atomic.js +20 -5
  11. package/dist/atomic.js.map +1 -1
  12. package/dist/atomic.mjs +20 -5
  13. package/dist/atomic.mjs.map +1 -1
  14. package/dist/cli.js +174 -67
  15. package/dist/cli.js.map +1 -1
  16. package/dist/cli.mjs +171 -64
  17. package/dist/cli.mjs.map +1 -1
  18. package/dist/compiler.d.mts +7 -1
  19. package/dist/compiler.d.ts +7 -1
  20. package/dist/compiler.js +53 -27
  21. package/dist/compiler.js.map +1 -1
  22. package/dist/compiler.mjs +53 -27
  23. package/dist/compiler.mjs.map +1 -1
  24. package/dist/devtools.js.map +1 -1
  25. package/dist/devtools.mjs.map +1 -1
  26. package/dist/engine.js +159 -61
  27. package/dist/engine.js.map +1 -1
  28. package/dist/engine.mjs +159 -61
  29. package/dist/engine.mjs.map +1 -1
  30. package/dist/index.browser.mjs +1512 -0
  31. package/dist/index.browser.mjs.map +1 -0
  32. package/dist/index.d.mts +94 -12
  33. package/dist/index.d.ts +94 -12
  34. package/dist/index.js +436 -106
  35. package/dist/index.js.map +1 -1
  36. package/dist/index.mjs +436 -106
  37. package/dist/index.mjs.map +1 -1
  38. package/dist/next.js +1946 -47
  39. package/dist/next.js.map +1 -1
  40. package/dist/next.mjs +1929 -44
  41. package/dist/next.mjs.map +1 -1
  42. package/dist/plugin-api.js.map +1 -1
  43. package/dist/plugin-api.mjs.map +1 -1
  44. package/dist/plugin-registry.js +23 -10
  45. package/dist/plugin-registry.js.map +1 -1
  46. package/dist/plugin-registry.mjs +23 -11
  47. package/dist/plugin-registry.mjs.map +1 -1
  48. package/dist/plugin.js.map +1 -1
  49. package/dist/plugin.mjs.map +1 -1
  50. package/dist/rspack.js.map +1 -1
  51. package/dist/rspack.mjs.map +1 -1
  52. package/dist/scanner.js +72 -19
  53. package/dist/scanner.js.map +1 -1
  54. package/dist/scanner.mjs +71 -18
  55. package/dist/scanner.mjs.map +1 -1
  56. package/dist/shared.js +32 -15
  57. package/dist/shared.js.map +1 -1
  58. package/dist/shared.mjs +32 -15
  59. package/dist/shared.mjs.map +1 -1
  60. package/dist/svelte.js +38 -12
  61. package/dist/svelte.js.map +1 -1
  62. package/dist/svelte.mjs +38 -12
  63. package/dist/svelte.mjs.map +1 -1
  64. package/dist/syntax.js +17 -5
  65. package/dist/syntax.js.map +1 -1
  66. package/dist/syntax.mjs +17 -5
  67. package/dist/syntax.mjs.map +1 -1
  68. package/dist/theme.js +4 -2
  69. package/dist/theme.js.map +1 -1
  70. package/dist/theme.mjs +4 -2
  71. package/dist/theme.mjs.map +1 -1
  72. package/dist/turbopackLoader.js +87 -33
  73. package/dist/turbopackLoader.js.map +1 -1
  74. package/dist/turbopackLoader.mjs +87 -33
  75. package/dist/turbopackLoader.mjs.map +1 -1
  76. package/dist/tw.js +174 -67
  77. package/dist/tw.js.map +1 -1
  78. package/dist/tw.mjs +171 -64
  79. package/dist/tw.mjs.map +1 -1
  80. package/dist/vite.js +145 -63
  81. package/dist/vite.js.map +1 -1
  82. package/dist/vite.mjs +145 -63
  83. package/dist/vite.mjs.map +1 -1
  84. package/dist/vue.js +38 -12
  85. package/dist/vue.js.map +1 -1
  86. package/dist/vue.mjs +38 -12
  87. package/dist/vue.mjs.map +1 -1
  88. package/dist/webpackLoader.js +20 -5
  89. package/dist/webpackLoader.js.map +1 -1
  90. package/dist/webpackLoader.mjs +20 -5
  91. package/dist/webpackLoader.mjs.map +1 -1
  92. package/native/tailwind-styled-native.node +0 -0
  93. package/package.json +29 -24
@@ -0,0 +1,1512 @@
1
+ import React3 from 'react';
2
+
3
+ /* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
4
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
+ }) : x)(function(x) {
7
+ if (typeof require !== "undefined") return require.apply(this, arguments);
8
+ throw Error('Dynamic require of "' + x + '" is not supported');
9
+ });
10
+
11
+ // packages/domain/core/src/native.browser.ts
12
+ var getNativeBinding = () => null;
13
+
14
+ // packages/domain/core/src/containerQuery.ts
15
+ var CONTAINER_BREAKPOINTS = {
16
+ xs: "240px",
17
+ sm: "320px",
18
+ md: "640px",
19
+ lg: "1024px",
20
+ xl: "1280px",
21
+ "2xl": "1536px"
22
+ };
23
+ var containerRegistry = /* @__PURE__ */ new Map();
24
+ if (typeof window !== "undefined") {
25
+ window.__TW_CONTAINER_REGISTRY__ = containerRegistry;
26
+ }
27
+ var _hashContainerCache = /* @__PURE__ */ new Map();
28
+ function hashContainer(tag, container, name) {
29
+ const sortedKey = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
30
+ const cached = _hashContainerCache.get(sortedKey);
31
+ if (cached) return cached;
32
+ let id;
33
+ try {
34
+ const native = getNativeBinding();
35
+ if (native?.hashContent) ; else {
36
+ throw new Error("no hashContent");
37
+ }
38
+ } catch {
39
+ const hash = sortedKey.split("").reduce((h, char) => (h << 5) + h ^ char.charCodeAt(0), 5381);
40
+ id = `tw-cq-${Math.abs(hash).toString(36).slice(0, 6)}`;
41
+ }
42
+ _hashContainerCache.set(sortedKey, id);
43
+ return id;
44
+ }
45
+ var LAYOUT_MAP = {
46
+ "flex-col": "flex-direction:column",
47
+ "flex-row": "flex-direction:row",
48
+ "flex-wrap": "flex-wrap:wrap",
49
+ "flex-nowrap": "flex-wrap:nowrap",
50
+ "flex-1": "flex:1 1 0%",
51
+ hidden: "display:none",
52
+ block: "display:block",
53
+ flex: "display:flex",
54
+ grid: "display:grid",
55
+ "grid-cols-1": "grid-template-columns:repeat(1,minmax(0,1fr))",
56
+ "grid-cols-2": "grid-template-columns:repeat(2,minmax(0,1fr))",
57
+ "grid-cols-3": "grid-template-columns:repeat(3,minmax(0,1fr))",
58
+ "grid-cols-4": "grid-template-columns:repeat(4,minmax(0,1fr))",
59
+ "grid-cols-6": "grid-template-columns:repeat(6,minmax(0,1fr))",
60
+ "grid-cols-12": "grid-template-columns:repeat(12,minmax(0,1fr))",
61
+ "text-sm": "font-size:0.875rem;line-height:1.25rem",
62
+ "text-base": "font-size:1rem;line-height:1.5rem",
63
+ "text-lg": "font-size:1.125rem;line-height:1.75rem",
64
+ "text-xl": "font-size:1.25rem;line-height:1.75rem",
65
+ "text-2xl": "font-size:1.5rem;line-height:2rem",
66
+ "text-xs": "font-size:0.75rem;line-height:1rem",
67
+ "p-2": "padding:0.5rem",
68
+ "p-4": "padding:1rem",
69
+ "p-6": "padding:1.5rem",
70
+ "p-8": "padding:2rem",
71
+ "px-2": "padding-left:0.5rem;padding-right:0.5rem",
72
+ "px-4": "padding-left:1rem;padding-right:1rem",
73
+ "px-6": "padding-left:1.5rem;padding-right:1.5rem",
74
+ "py-2": "padding-top:0.5rem;padding-bottom:0.5rem",
75
+ "py-4": "padding-top:1rem;padding-bottom:1rem",
76
+ "gap-2": "gap:0.5rem",
77
+ "gap-4": "gap:1rem",
78
+ "gap-6": "gap:1.5rem",
79
+ "gap-8": "gap:2rem",
80
+ "w-full": "width:100%",
81
+ "w-1/2": "width:50%",
82
+ "w-1/3": "width:33.333333%",
83
+ "w-2/3": "width:66.666667%",
84
+ "max-w-sm": "max-width:24rem",
85
+ "max-w-md": "max-width:28rem",
86
+ "max-w-lg": "max-width:32rem",
87
+ "max-w-xl": "max-width:36rem",
88
+ "items-center": "align-items:center",
89
+ "items-start": "align-items:flex-start",
90
+ "items-end": "align-items:flex-end",
91
+ "justify-center": "justify-content:center",
92
+ "justify-between": "justify-content:space-between",
93
+ "justify-start": "justify-content:flex-start",
94
+ "justify-end": "justify-content:flex-end"
95
+ };
96
+ function layoutClassesToCss(classes) {
97
+ try {
98
+ const native = getNativeBinding();
99
+ if (native?.layoutClassesToCss) ;
100
+ } catch {
101
+ }
102
+ const decls = [];
103
+ for (const cls of classes.trim().split(/\s+/)) {
104
+ if (LAYOUT_MAP[cls]) decls.push(LAYOUT_MAP[cls]);
105
+ else if (cls.startsWith("w-[")) {
106
+ const val = cls.match(/\[(.+)\]/)?.[1];
107
+ if (val) decls.push(`width:${val}`);
108
+ } else if (cls.startsWith("max-w-[")) {
109
+ const val = cls.match(/\[(.+)\]/)?.[1];
110
+ if (val) decls.push(`max-width:${val}`);
111
+ }
112
+ }
113
+ return decls.join(";");
114
+ }
115
+ function buildContainerRules(id, container, containerName) {
116
+ const rules = Object.entries(container).map(([key, value]) => {
117
+ const minWidth = typeof value === "string" ? CONTAINER_BREAKPOINTS[key] ?? key : value.minWidth ?? CONTAINER_BREAKPOINTS[key] ?? key;
118
+ const classes = typeof value === "string" ? value : value.classes;
119
+ const css = layoutClassesToCss(classes);
120
+ if (!css) return null;
121
+ const query = containerName ? `@container ${containerName} (min-width: ${minWidth})` : `@container (min-width: ${minWidth})`;
122
+ return `${query}{.${id}{${css}}}`;
123
+ }).filter(Boolean);
124
+ return rules.join("\n");
125
+ }
126
+ var _cqBatchedInjectFn = null;
127
+ try {
128
+ const mod = __require("@tailwind-styled/runtime-css/batched");
129
+ if (typeof mod?.batchedInject === "function") _cqBatchedInjectFn = mod.batchedInject;
130
+ } catch {
131
+ }
132
+ function injectContainerStyles(id, container, containerName) {
133
+ if (typeof document === "undefined") return;
134
+ const styleId = `tw-cq-${id}`;
135
+ if (document.getElementById(styleId)) return;
136
+ const css = buildContainerRules(id, container, containerName);
137
+ if (!css) return;
138
+ if (_cqBatchedInjectFn) {
139
+ for (const rule of css.split("\n").filter(Boolean)) _cqBatchedInjectFn(rule);
140
+ return;
141
+ }
142
+ const style = document.createElement("style");
143
+ style.id = styleId;
144
+ style.setAttribute("data-tw-container", id);
145
+ style.textContent = css;
146
+ document.head.appendChild(style);
147
+ }
148
+ function processContainer(tag, container, containerName) {
149
+ const id = hashContainer(tag, container, containerName);
150
+ if (!containerRegistry.has(id)) {
151
+ const breakpoints = Object.entries(container).map(([key, value]) => ({
152
+ minWidth: CONTAINER_BREAKPOINTS[key] ?? key,
153
+ classes: typeof value === "string" ? value : value.classes
154
+ }));
155
+ containerRegistry.set(id, {
156
+ id,
157
+ tag,
158
+ containerName,
159
+ breakpoints,
160
+ cssInjected: false
161
+ });
162
+ }
163
+ injectContainerStyles(id, container, containerName);
164
+ containerRegistry.get(id).cssInjected = true;
165
+ return { containerClass: id, hasContainer: true };
166
+ }
167
+ function generateContainerCss(tag, container, containerName) {
168
+ const id = hashContainer(tag, container, containerName);
169
+ try {
170
+ const native = getNativeBinding();
171
+ if (native?.buildContainerRules) ;
172
+ } catch {
173
+ }
174
+ return buildContainerRules(id, container, containerName);
175
+ }
176
+ function getContainerRegistry() {
177
+ return containerRegistry;
178
+ }
179
+
180
+ // packages/domain/core/src/merge.ts
181
+ function normalizeClassInput(classLists) {
182
+ const result = [];
183
+ for (let i = 0; i < classLists.length; i++) {
184
+ const v = classLists[i];
185
+ if (!v) continue;
186
+ const s = String(v).trim();
187
+ if (s.length > 0) result.push(s);
188
+ }
189
+ return result;
190
+ }
191
+ function createTwMerge(_options = {}) {
192
+ return function twMerge2(...classLists) {
193
+ const clean = normalizeClassInput(classLists);
194
+ if (clean.length === 0) return "";
195
+ try {
196
+ const native = getNativeBinding();
197
+ if (native?.twMergeMany) ;
198
+ } catch {
199
+ }
200
+ return clean.join(" ");
201
+ };
202
+ }
203
+ var twMerge = createTwMerge();
204
+ function mergeWithRules(rules, ...classLists) {
205
+ const base = twMerge(...classLists);
206
+ const classes = Object.values(rules).reduce(
207
+ (acc, rule) => twMerge(rule(acc)).split(/\s+/).filter(Boolean),
208
+ base.split(/\s+/).filter(Boolean)
209
+ );
210
+ return classes.join(" ");
211
+ }
212
+
213
+ // packages/domain/core/src/stateEngine.ts
214
+ var stateRegistry = /* @__PURE__ */ new Map();
215
+ if (typeof window !== "undefined") {
216
+ window.__TW_STATE_REGISTRY__ = stateRegistry;
217
+ }
218
+ var _hashStateCache = /* @__PURE__ */ new Map();
219
+ function hashState(tag, state) {
220
+ const sortedKey = tag + JSON.stringify(Object.entries(state).sort());
221
+ const cached = _hashStateCache.get(sortedKey);
222
+ if (cached) return cached;
223
+ let id;
224
+ try {
225
+ const native = getNativeBinding();
226
+ if (native?.hashContent) ; else {
227
+ throw new Error("no hashContent");
228
+ }
229
+ } catch {
230
+ const hash = sortedKey.split("").reduce((h, char) => (h << 5) + h ^ char.charCodeAt(0), 5381);
231
+ id = `tw-s-${Math.abs(hash).toString(36).slice(0, 6)}`;
232
+ }
233
+ _hashStateCache.set(sortedKey, id);
234
+ return id;
235
+ }
236
+ var _twClassesToCssCache = /* @__PURE__ */ new Map();
237
+ function twClassesToCss(classes) {
238
+ const cached = _twClassesToCssCache.get(classes);
239
+ if (cached !== void 0) return cached;
240
+ {
241
+ throw new Error("FATAL: Native binding 'twClassesToCss' is required but not available.");
242
+ }
243
+ }
244
+ var _batchedInjectFn = null;
245
+ try {
246
+ const mod = __require("@tailwind-styled/runtime-css/batched");
247
+ if (typeof mod?.batchedInject === "function") _batchedInjectFn = mod.batchedInject;
248
+ } catch {
249
+ }
250
+ function injectStateStyles(id, state) {
251
+ if (typeof document === "undefined") return;
252
+ const styleId = `tw-state-${id}`;
253
+ if (document.getElementById(styleId)) return;
254
+ const rules = Object.entries(state).map(([stateName, classes]) => {
255
+ const css = twClassesToCss(classes);
256
+ return css ? `.${id}[data-${stateName}="true"]{${css}}` : null;
257
+ }).filter(Boolean);
258
+ if (rules.length === 0) return;
259
+ if (_batchedInjectFn) {
260
+ for (const rule of rules) _batchedInjectFn(rule);
261
+ return;
262
+ }
263
+ const style = document.createElement("style");
264
+ style.id = styleId;
265
+ style.setAttribute("data-tw-state", id);
266
+ style.textContent = rules.join("\n");
267
+ document.head.appendChild(style);
268
+ }
269
+ function processState(tag, state) {
270
+ const id = hashState(tag, state);
271
+ const stateNames = Object.keys(state);
272
+ if (!stateRegistry.has(id)) {
273
+ stateRegistry.set(id, {
274
+ id,
275
+ tag,
276
+ states: stateNames,
277
+ cssInjected: false
278
+ });
279
+ }
280
+ injectStateStyles(id, state);
281
+ const entry = stateRegistry.get(id);
282
+ entry.cssInjected = true;
283
+ return { stateClass: id, hasState: true, stateNames };
284
+ }
285
+ function generateStateCss(tag, state) {
286
+ const id = hashState(tag, state);
287
+ const rules = Object.entries(state).map(([stateName, classes]) => {
288
+ const css = twClassesToCss(classes);
289
+ return css ? `.${id}[data-${stateName}="true"]{${css}}` : null;
290
+ }).filter(Boolean);
291
+ return rules.join("\n");
292
+ }
293
+ function getStateRegistry() {
294
+ return stateRegistry;
295
+ }
296
+
297
+ // packages/domain/core/src/createComponent.ts
298
+ var ALWAYS_BLOCKED = /* @__PURE__ */ new Set(["base", "_ref", "state", "container", "containerName"]);
299
+ var _templateParseCache = /* @__PURE__ */ new Map();
300
+ var _statesLookupCache = /* @__PURE__ */ new Map();
301
+ function _getParsedTemplate(template) {
302
+ const cached = _templateParseCache.get(template);
303
+ if (cached) return cached;
304
+ let result;
305
+ try {
306
+ const native = getNativeBinding();
307
+ if (native?.parseSubcomponentBlocksNapi) ;
308
+ } catch {
309
+ }
310
+ const subMap = /* @__PURE__ */ new Map();
311
+ const regex = /((?:\[[a-zA-Z][a-zA-Z0-9_-]*\]|[a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
312
+ let match;
313
+ while ((match = regex.exec(template)) !== null) {
314
+ const rawName = match[1];
315
+ const name = rawName.startsWith("[") ? rawName.slice(1, -1) : rawName;
316
+ const classes = match[2].trim().replace(/\s+/g, " ");
317
+ if (classes) subMap.set(name, classes);
318
+ }
319
+ const baseClasses = template.replace(/(?:\[[a-zA-Z][a-zA-Z0-9_-]*\]|[a-zA-Z][a-zA-Z0-9_-]*)\s*\{[^}]*\}/g, "").replace(/\s+/g, " ").trim();
320
+ result = { baseClasses, subMap };
321
+ _templateParseCache.set(template, result);
322
+ return result;
323
+ }
324
+ function parseSubComponentBlocks(template) {
325
+ return _getParsedTemplate(template).subMap;
326
+ }
327
+ function extractBaseClasses(template) {
328
+ return _getParsedTemplate(template).baseClasses;
329
+ }
330
+ var SEMANTIC_HTML_TAGS = /* @__PURE__ */ new Set([
331
+ "article",
332
+ "aside",
333
+ "details",
334
+ "figcaption",
335
+ "figure",
336
+ "footer",
337
+ "header",
338
+ "main",
339
+ "mark",
340
+ "nav",
341
+ "section",
342
+ "summary",
343
+ "time",
344
+ "h1",
345
+ "h2",
346
+ "h3",
347
+ "h4",
348
+ "h5",
349
+ "h6",
350
+ "p",
351
+ "ul",
352
+ "ol",
353
+ "li",
354
+ "dl",
355
+ "dt",
356
+ "dd",
357
+ "table",
358
+ "thead",
359
+ "tbody",
360
+ "tfoot",
361
+ "tr",
362
+ "th",
363
+ "td",
364
+ "form",
365
+ "fieldset",
366
+ "legend",
367
+ "label",
368
+ "a",
369
+ "button",
370
+ "img",
371
+ "span",
372
+ "div",
373
+ "blockquote",
374
+ "pre",
375
+ "code",
376
+ "em",
377
+ "strong",
378
+ "small"
379
+ ]);
380
+ function parseSubKey(key) {
381
+ const colonIdx = key.indexOf(":");
382
+ if (colonIdx !== -1) {
383
+ const tag = key.slice(0, colonIdx).trim();
384
+ const componentName = key.slice(colonIdx + 1).trim();
385
+ return { tag: tag || "span", componentName: componentName || tag };
386
+ }
387
+ const isSemanticTag = SEMANTIC_HTML_TAGS.has(key);
388
+ return { tag: isSemanticTag ? key : "span", componentName: key };
389
+ }
390
+ function createSubComponentAccessor(parentDisplayName, name, classes, tag = "span", asChild = false) {
391
+ const SubComponent = ({
392
+ children,
393
+ className
394
+ }) => {
395
+ const mergedClass = className ? `${classes} ${className}` : classes;
396
+ if (asChild && React3.isValidElement(children)) {
397
+ const child = React3.Children.only(children);
398
+ return React3.cloneElement(child, {
399
+ className: child.props.className ? `${mergedClass} ${child.props.className}` : mergedClass
400
+ });
401
+ }
402
+ return React3.createElement(tag, { className: mergedClass }, children);
403
+ };
404
+ SubComponent.displayName = `${parentDisplayName}[${name}]`;
405
+ return SubComponent;
406
+ }
407
+ function registerSubComponents(component, template, configSub) {
408
+ const displayName = component.displayName ?? "tw";
409
+ const map = component;
410
+ if (configSub) {
411
+ for (const [key, value] of Object.entries(configSub)) {
412
+ if (typeof value === "string") {
413
+ const { tag, componentName } = parseSubKey(key);
414
+ map[componentName] = createSubComponentAccessor(
415
+ displayName,
416
+ componentName,
417
+ value.trim().replace(/\s+/g, " "),
418
+ tag
419
+ );
420
+ } else {
421
+ const tag = key;
422
+ for (const [componentName, classes] of Object.entries(value)) {
423
+ map[componentName] = createSubComponentAccessor(
424
+ displayName,
425
+ componentName,
426
+ classes.trim().replace(/\s+/g, " "),
427
+ tag
428
+ );
429
+ }
430
+ }
431
+ }
432
+ }
433
+ const blocks = parseSubComponentBlocks(template);
434
+ for (const [name, classes] of blocks) {
435
+ if (!(name in map)) {
436
+ map[name] = createSubComponentAccessor(displayName, name, classes);
437
+ }
438
+ }
439
+ }
440
+ function normalizeClassName(value) {
441
+ return typeof value === "string" ? value : void 0;
442
+ }
443
+ function makeFilterProps(variantKeys, stateKeys = /* @__PURE__ */ new Set()) {
444
+ return function filterProps(props) {
445
+ const out = {};
446
+ for (const key in props) {
447
+ if (variantKeys.has(key)) continue;
448
+ if (stateKeys.has(key)) continue;
449
+ if (key.startsWith("$")) continue;
450
+ if (ALWAYS_BLOCKED.has(key)) continue;
451
+ out[key] = props[key];
452
+ }
453
+ return out;
454
+ };
455
+ }
456
+ function resolveVariants(variants, props, defaults) {
457
+ const variantKeys = Object.keys(variants);
458
+ const cleanProps = {};
459
+ for (const k of variantKeys) {
460
+ const v = props[k];
461
+ if (v !== void 0 && v !== null) cleanProps[k] = String(v);
462
+ }
463
+ try {
464
+ const binding = getNativeBinding();
465
+ if (binding?.resolveSimpleVariants) ;
466
+ } catch {
467
+ }
468
+ const resolved = { ...defaults, ...cleanProps };
469
+ const classes = [];
470
+ const sortedVariantEntries = Object.entries(variants).sort(([a], [b]) => a.localeCompare(b));
471
+ for (const [variantKey, variantMap] of sortedVariantEntries) {
472
+ const selected = resolved[variantKey];
473
+ if (selected !== void 0 && variantMap[selected] !== void 0) {
474
+ const normalized = variantMap[selected].trim().replace(/\s+/g, " ");
475
+ classes.push(normalized);
476
+ }
477
+ }
478
+ return classes.filter(Boolean).join(" ");
479
+ }
480
+ function resolveStates(statesConfig, stateKeys, statesLookup, props) {
481
+ if (statesLookup && stateKeys.length > 0) {
482
+ let mask = 0;
483
+ for (let i = 0; i < stateKeys.length; i++) {
484
+ if (props[stateKeys[i]]) mask |= 1 << i;
485
+ }
486
+ return statesLookup[mask] ?? "";
487
+ }
488
+ const activeClasses = stateKeys.filter((k) => props[k]).map((k) => statesConfig[k]).filter(Boolean);
489
+ return activeClasses.join(" ");
490
+ }
491
+ function resolveCompound(compounds, props) {
492
+ const classes = [];
493
+ for (const compound of compounds) {
494
+ const { class: compoundClass, ...conditions } = compound;
495
+ const matches = Object.entries(conditions).every(([key, value]) => props[key] === value);
496
+ if (matches) {
497
+ classes.push(compoundClass);
498
+ }
499
+ }
500
+ return classes.join(" ");
501
+ }
502
+ function carryOverSubComponents(target, source) {
503
+ const INTERNAL_KEYS = /* @__PURE__ */ new Set(["extend", "withVariants", "animate", "withSub", "displayName"]);
504
+ for (const key of Object.keys(source)) {
505
+ if (!INTERNAL_KEYS.has(key)) {
506
+ target[key] = source[key];
507
+ }
508
+ }
509
+ }
510
+ function attachExtend(component, originalTag, base, config) {
511
+ function extendWithClasses(stringsOrConfig) {
512
+ if (Array.isArray(stringsOrConfig) && "raw" in stringsOrConfig) {
513
+ const rawExtra = stringsOrConfig.raw.join("").trim().replace(/\s+/g, " ");
514
+ const merged2 = twMerge(extractBaseClasses(base), extractBaseClasses(rawExtra));
515
+ const extended2 = createComponent(
516
+ originalTag,
517
+ typeof config === "string" ? merged2 : { ...config, base: merged2 }
518
+ );
519
+ carryOverSubComponents(extended2, component);
520
+ const extendSubBlocks = parseSubComponentBlocks(rawExtra);
521
+ if (extendSubBlocks.size > 0) {
522
+ const extComp = extended2;
523
+ const displayName = extended2.displayName ?? "tw";
524
+ for (const [subName, subClasses] of extendSubBlocks) {
525
+ extComp[subName] = createSubComponentAccessor(displayName, subName, subClasses);
526
+ }
527
+ }
528
+ return extended2;
529
+ }
530
+ const extCfg = stringsOrConfig;
531
+ const extraClasses = extCfg.classes ?? "";
532
+ const merged = twMerge(extractBaseClasses(base), extraClasses);
533
+ const existing = typeof config === "object" ? config : {};
534
+ const extended = createComponent(originalTag, {
535
+ ...existing,
536
+ base: merged,
537
+ variants: { ...existing.variants ?? {}, ...extCfg.variants ?? {} },
538
+ compoundVariants: [
539
+ ...existing.compoundVariants ?? [],
540
+ ...extCfg.compoundVariants ?? []
541
+ ],
542
+ defaultVariants: {
543
+ ...existing.defaultVariants ?? {},
544
+ ...extCfg.defaultVariants ?? {}
545
+ }
546
+ });
547
+ carryOverSubComponents(extended, component);
548
+ return extended;
549
+ }
550
+ component.extend = extendWithClasses;
551
+ component.withVariants = (newConfig) => {
552
+ const existing = typeof config === "object" ? config : {};
553
+ return createComponent(originalTag, {
554
+ ...existing,
555
+ base,
556
+ variants: { ...existing.variants ?? {}, ...newConfig.variants ?? {} },
557
+ compoundVariants: [
558
+ ...existing.compoundVariants ?? [],
559
+ ...newConfig.compoundVariants ?? []
560
+ ],
561
+ defaultVariants: {
562
+ ...existing.defaultVariants ?? {},
563
+ ...newConfig.defaultVariants ?? {}
564
+ }
565
+ });
566
+ };
567
+ component.animate = async (_opts) => {
568
+ console.warn(
569
+ '[tailwind-styled-v4] .animate() tidak tersedia di main bundle.\nGunakan: import { animate } from "tailwind-styled-v4/animate"'
570
+ );
571
+ return component;
572
+ };
573
+ component.withSub = (() => component);
574
+ return component;
575
+ }
576
+ function createComponent(tag, config) {
577
+ const isStatic = typeof config === "string";
578
+ const base = typeof config === "string" ? config : config.base ?? "";
579
+ const variants = typeof config === "string" ? {} : config.variants ?? {};
580
+ const compoundVariants = typeof config === "string" ? [] : config.compoundVariants ?? [];
581
+ const defaultVariants = typeof config === "string" ? {} : config.defaultVariants ?? {};
582
+ const stateConfig = typeof config === "string" ? void 0 : config.state;
583
+ const containerConfig = typeof config === "string" ? void 0 : config.container;
584
+ const containerName = typeof config === "string" ? void 0 : config.containerName;
585
+ const configSub = typeof config === "string" ? void 0 : config.sub;
586
+ const statesConfig = typeof config === "string" ? void 0 : config.states;
587
+ let statesLookup = null;
588
+ let stateKeys = [];
589
+ if (statesConfig && Object.keys(statesConfig).length > 0) {
590
+ stateKeys = Object.keys(statesConfig);
591
+ const statesCacheKey = JSON.stringify(statesConfig, Object.keys(statesConfig).sort());
592
+ const cachedStates = _statesLookupCache.get(statesCacheKey);
593
+ if (cachedStates) {
594
+ statesLookup = cachedStates.lookup;
595
+ stateKeys = cachedStates.keys;
596
+ } else {
597
+ try {
598
+ const native = getNativeBinding();
599
+ if (native?.pregenerateStatesNapi) ;
600
+ } catch (e) {
601
+ console.warn("[tailwind-styled-v4] states pre-generation failed, falling back to runtime cx()", e);
602
+ }
603
+ }
604
+ }
605
+ const stateResult = stateConfig ? processState(typeof tag === "string" ? tag : "component", stateConfig) : null;
606
+ const containerResult = containerConfig ? processContainer(typeof tag === "string" ? tag : "component", containerConfig, containerName) : null;
607
+ const engineClasses = [stateResult?.stateClass, containerResult?.containerClass].filter(Boolean).join(" ");
608
+ const filterProps = makeFilterProps(new Set(Object.keys(variants)), new Set(stateKeys));
609
+ const tagLabel = typeof tag === "string" ? tag : tag.displayName ?? "Component";
610
+ if (isStatic || Object.keys(variants).length === 0) {
611
+ const baseComponent2 = React3.forwardRef((props, ref) => {
612
+ const { className, ...rest } = props;
613
+ const runtimeClassName = normalizeClassName(className);
614
+ const statesClasses = statesConfig ? resolveStates(statesConfig, stateKeys, statesLookup, props) : "";
615
+ const mergedBase = twMerge(extractBaseClasses(base), engineClasses, runtimeClassName);
616
+ const className2 = statesClasses ? `${mergedBase} ${statesClasses}`.trim() : mergedBase;
617
+ return React3.createElement(tag, {
618
+ ref,
619
+ ...filterProps(rest),
620
+ className: className2
621
+ });
622
+ });
623
+ const component2 = baseComponent2;
624
+ component2.displayName = `tw.${tagLabel}`;
625
+ const result2 = attachExtend(component2, tag, base, config);
626
+ registerSubComponents(result2, base, configSub);
627
+ return wrapWithSubProxy(result2, tagLabel);
628
+ }
629
+ const baseComponent = React3.forwardRef((props, ref) => {
630
+ const { className, ...rest } = props;
631
+ const runtimeClassName = normalizeClassName(className);
632
+ const variantClasses = resolveVariants(variants, props, defaultVariants);
633
+ const compoundClasses = resolveCompound(compoundVariants, props);
634
+ const statesClasses = statesConfig ? resolveStates(statesConfig, stateKeys, statesLookup, props) : "";
635
+ const mergedBase = twMerge(extractBaseClasses(base), variantClasses, compoundClasses, engineClasses, runtimeClassName);
636
+ const className2 = statesClasses ? `${mergedBase} ${statesClasses}`.trim() : mergedBase;
637
+ return React3.createElement(tag, {
638
+ ref,
639
+ ...filterProps(rest),
640
+ className: className2
641
+ });
642
+ });
643
+ const component = baseComponent;
644
+ component.displayName = `tw.${tagLabel}`;
645
+ const result = attachExtend(component, tag, base, config);
646
+ registerSubComponents(result, base, configSub);
647
+ return wrapWithSubProxy(result, tagLabel);
648
+ }
649
+ var SKIP_PROXY_KEYS = /* @__PURE__ */ new Set([
650
+ "extend",
651
+ "withVariants",
652
+ "animate",
653
+ "withSub",
654
+ "displayName",
655
+ "$$typeof",
656
+ "render",
657
+ "prototype",
658
+ "__esModule",
659
+ "then"
660
+ ]);
661
+ function wrapWithSubProxy(component, tagLabel) {
662
+ return new Proxy(component, {
663
+ get(target, prop) {
664
+ const value = target[prop];
665
+ if (value !== void 0) return value;
666
+ if (typeof prop === "symbol") return value;
667
+ if (SKIP_PROXY_KEYS.has(prop)) return value;
668
+ const Fallback = ({
669
+ children,
670
+ className
671
+ }) => React3.createElement("span", { className }, children);
672
+ Fallback.displayName = `tw.${tagLabel}.${prop}(fallback)`;
673
+ return Fallback;
674
+ }
675
+ });
676
+ }
677
+
678
+ // packages/domain/core/src/cv.ts
679
+ var __generatedRegistry = {};
680
+ var _sortedVariantKeysCache = /* @__PURE__ */ new Map();
681
+ function lookupGenerated(componentId, props, defaultVariants, variantKeys) {
682
+ const table = __generatedRegistry[componentId];
683
+ if (!table) return void 0;
684
+ const merged = { ...defaultVariants, ...props };
685
+ let sortedKeys = _sortedVariantKeysCache.get(componentId);
686
+ if (!sortedKeys) {
687
+ const keysToUse = variantKeys ? variantKeys : Object.keys(merged).filter((k) => k !== "className");
688
+ sortedKeys = [...keysToUse].sort();
689
+ _sortedVariantKeysCache.set(componentId, sortedKeys);
690
+ }
691
+ let key = "";
692
+ for (let i = 0; i < sortedKeys.length; i++) {
693
+ if (i > 0) key += "|";
694
+ key += sortedKeys[i] + ":" + String(merged[sortedKeys[i]]);
695
+ }
696
+ return table[key];
697
+ }
698
+ var _configJsonCache = /* @__PURE__ */ new WeakMap();
699
+ function _getConfigJson(config) {
700
+ let json = _configJsonCache.get(config);
701
+ if (!json) {
702
+ json = JSON.stringify(config);
703
+ _configJsonCache.set(config, json);
704
+ }
705
+ return json;
706
+ }
707
+ function resolveVariantsNative(config, props) {
708
+ const { base = "", variants = {}, compoundVariants = [], defaultVariants = {} } = config;
709
+ const variantKeys = Object.keys(variants);
710
+ try {
711
+ const binding = getNativeBinding();
712
+ if (binding?.resolveVariants) ;
713
+ if (binding?.resolveSimpleVariants) ;
714
+ } catch {
715
+ }
716
+ const resolved = {};
717
+ for (const k of variantKeys) {
718
+ const dv = defaultVariants[k];
719
+ if (dv !== void 0) resolved[k] = dv;
720
+ }
721
+ for (const k of variantKeys) {
722
+ const v = props[k];
723
+ if (v !== void 0 && v !== null) resolved[k] = String(v);
724
+ }
725
+ const classes = [];
726
+ if (base) classes.push(base);
727
+ for (const k of variantKeys) {
728
+ const variantMap = variants[k];
729
+ const selected = resolved[k];
730
+ if (selected !== void 0 && variantMap?.[selected] !== void 0) {
731
+ classes.push(variantMap[selected]);
732
+ }
733
+ }
734
+ const resolvedFull = { ...defaultVariants, ...props };
735
+ for (const compound of compoundVariants) {
736
+ const { class: compoundClass, className: compoundClassName, ...conditions } = compound;
737
+ const matches = Object.entries(conditions).every(([key, val]) => resolvedFull[key] === val);
738
+ if (matches) {
739
+ if (compoundClass) classes.push(String(compoundClass));
740
+ if (compoundClassName) classes.push(String(compoundClassName));
741
+ }
742
+ }
743
+ return classes.filter(Boolean).join(" ");
744
+ }
745
+ function cv(config, componentId) {
746
+ {
747
+ const { variants = {}, defaultVariants = {} } = config;
748
+ for (const dk of Object.keys(defaultVariants)) {
749
+ if (!(dk in variants)) {
750
+ console.warn(`[tailwind-styled] defaultVariants["${dk}"] not in variants`);
751
+ }
752
+ }
753
+ }
754
+ return (props = {}) => {
755
+ let result;
756
+ const variantKeys = Object.keys(config.variants ?? {});
757
+ if (componentId) {
758
+ const generated = lookupGenerated(
759
+ componentId,
760
+ props,
761
+ config.defaultVariants,
762
+ variantKeys
763
+ );
764
+ result = generated ?? resolveVariantsNative(config, props);
765
+ } else {
766
+ result = resolveVariantsNative(config, props);
767
+ }
768
+ return props.className ? twMerge(result, props.className) : result;
769
+ };
770
+ }
771
+
772
+ // packages/domain/core/src/cx.ts
773
+ function cn(...inputs) {
774
+ const strings = [];
775
+ for (const item of inputs) {
776
+ if (Array.isArray(item)) {
777
+ for (const v of item) {
778
+ if (v) strings.push(String(v));
779
+ }
780
+ } else if (item) {
781
+ strings.push(String(item));
782
+ }
783
+ }
784
+ if (strings.length === 0) return "";
785
+ try {
786
+ const native = getNativeBinding();
787
+ if (native?.resolveClassNames) ;
788
+ } catch {
789
+ }
790
+ return strings.join(" ");
791
+ }
792
+ function cx(...inputs) {
793
+ const filtered = inputs.flat().filter(Boolean);
794
+ if (filtered.length === 0) return "";
795
+ try {
796
+ const native = getNativeBinding();
797
+ if (native?.twMergeMany) ;
798
+ if (native?.twMerge) ;
799
+ } catch {
800
+ }
801
+ return filtered.join(" ");
802
+ }
803
+ var cxm = cx;
804
+ var TOKEN_ENGINE_KEY = "__TW_TOKEN_ENGINE__";
805
+ function tokenVar(name) {
806
+ const normalized = name.replace(/[^a-zA-Z0-9-]/g, "-").toLowerCase();
807
+ return `--tw-token-${normalized}`;
808
+ }
809
+ function tokenRef(name) {
810
+ return `var(${tokenVar(name)})`;
811
+ }
812
+ var buildRootCss = (tokens) => {
813
+ const vars = Object.entries(tokens).map(([name, value]) => ` ${tokenVar(name)}: ${value};`).join("\n");
814
+ return `:root {
815
+ ${vars}
816
+ }`;
817
+ };
818
+ var createLiveTokenEngine = () => {
819
+ const state = {
820
+ currentTokens: {},
821
+ styleEl: null
822
+ };
823
+ const subscribers = /* @__PURE__ */ new Set();
824
+ const syncStyleEl = () => {
825
+ if (typeof document === "undefined") return;
826
+ if (!state.styleEl) {
827
+ const styleEl = document.createElement("style");
828
+ styleEl.id = "tw-live-tokens";
829
+ styleEl.setAttribute("data-tw-tokens", "true");
830
+ document.head.appendChild(styleEl);
831
+ state.styleEl = styleEl;
832
+ }
833
+ state.styleEl.textContent = buildRootCss(state.currentTokens);
834
+ };
835
+ const notifySubscribers = () => {
836
+ const snapshot = { ...state.currentTokens };
837
+ for (const subscriber of subscribers) {
838
+ try {
839
+ subscriber(snapshot);
840
+ } catch {
841
+ }
842
+ }
843
+ };
844
+ const setToken2 = (name, value) => {
845
+ state.currentTokens = { ...state.currentTokens, [name]: value };
846
+ if (typeof document !== "undefined") {
847
+ document.documentElement.style.setProperty(tokenVar(name), value);
848
+ }
849
+ syncStyleEl();
850
+ notifySubscribers();
851
+ };
852
+ const setTokens2 = (tokens) => {
853
+ state.currentTokens = { ...state.currentTokens, ...tokens };
854
+ if (typeof document !== "undefined") {
855
+ const root = document.documentElement;
856
+ for (const [name, value] of Object.entries(tokens)) {
857
+ root.style.setProperty(tokenVar(name), value);
858
+ }
859
+ }
860
+ syncStyleEl();
861
+ notifySubscribers();
862
+ };
863
+ const applyTokenSet2 = (tokens) => {
864
+ if (typeof document !== "undefined") {
865
+ const root = document.documentElement;
866
+ for (const name of Object.keys(state.currentTokens)) {
867
+ if (!(name in tokens)) {
868
+ root.style.removeProperty(tokenVar(name));
869
+ }
870
+ }
871
+ for (const [name, value] of Object.entries(tokens)) {
872
+ root.style.setProperty(tokenVar(name), value);
873
+ }
874
+ }
875
+ state.currentTokens = { ...tokens };
876
+ syncStyleEl();
877
+ notifySubscribers();
878
+ };
879
+ return {
880
+ liveToken(tokens) {
881
+ setTokens2(tokens);
882
+ const vars = {};
883
+ for (const name of Object.keys(tokens)) {
884
+ vars[name] = tokenRef(name);
885
+ }
886
+ return {
887
+ vars,
888
+ get(name) {
889
+ return state.currentTokens[name];
890
+ },
891
+ set(name, value) {
892
+ setToken2(name, value);
893
+ },
894
+ setAll(nextTokens) {
895
+ setTokens2(nextTokens);
896
+ },
897
+ snapshot() {
898
+ return { ...state.currentTokens };
899
+ }
900
+ };
901
+ },
902
+ getToken(name) {
903
+ return state.currentTokens[name];
904
+ },
905
+ getTokens() {
906
+ return { ...state.currentTokens };
907
+ },
908
+ setToken: setToken2,
909
+ setTokens: setTokens2,
910
+ applyTokenSet: applyTokenSet2,
911
+ generateTokenCssString() {
912
+ return buildRootCss(state.currentTokens);
913
+ },
914
+ subscribe(fn) {
915
+ subscribers.add(fn);
916
+ return () => {
917
+ subscribers.delete(fn);
918
+ };
919
+ }
920
+ };
921
+ };
922
+ var engine = createLiveTokenEngine();
923
+ function liveToken(tokens) {
924
+ return engine.liveToken(tokens);
925
+ }
926
+ function setToken(name, value) {
927
+ engine.setToken(name, value);
928
+ }
929
+ function setTokens(tokens) {
930
+ engine.setTokens(tokens);
931
+ }
932
+ function applyTokenSet(tokens) {
933
+ engine.applyTokenSet(tokens);
934
+ }
935
+ function getToken(name) {
936
+ return engine.getToken(name);
937
+ }
938
+ function getTokens() {
939
+ return engine.getTokens();
940
+ }
941
+ function subscribeTokens(fn) {
942
+ return engine.subscribe(fn);
943
+ }
944
+ function generateTokenCssString() {
945
+ return engine.generateTokenCssString();
946
+ }
947
+ function createUseTokens() {
948
+ return function useTokens() {
949
+ const [tokens, setTokensState] = React3.useState(engine.getTokens());
950
+ React3.useEffect(() => {
951
+ setTokensState(engine.getTokens());
952
+ return engine.subscribe((nextTokens) => setTokensState(nextTokens));
953
+ }, []);
954
+ return tokens;
955
+ };
956
+ }
957
+ var liveTokenEngine = {
958
+ getToken: engine.getToken,
959
+ getTokens: engine.getTokens,
960
+ setToken: engine.setToken,
961
+ setTokens: engine.setTokens,
962
+ applyTokenSet: engine.applyTokenSet,
963
+ subscribeTokens: engine.subscribe,
964
+ subscribe: engine.subscribe
965
+ };
966
+ var globalTokenEngine = globalThis;
967
+ globalTokenEngine[TOKEN_ENGINE_KEY] = liveTokenEngine;
968
+ if (typeof window !== "undefined") {
969
+ window.__TW_TOKEN_ENGINE__ = liveTokenEngine;
970
+ }
971
+ var subComponentRegistry = /* @__PURE__ */ new Map();
972
+ function registerSubComponent(entry) {
973
+ subComponentRegistry.set(entry.name, entry);
974
+ }
975
+ function getSubComponent(name) {
976
+ return subComponentRegistry.get(name);
977
+ }
978
+ function getAllSubComponents() {
979
+ return Array.from(subComponentRegistry.values());
980
+ }
981
+ function withSubComponents(Component, subComponentNames) {
982
+ const result = { ...Component };
983
+ for (const name of subComponentNames) {
984
+ const entry = getSubComponent(name);
985
+ if (entry) result[name] = entry.component;
986
+ }
987
+ return result;
988
+ }
989
+ registerSubComponent({
990
+ name: "icon",
991
+ component: ({ children, className }) => React3.createElement("span", { className }, children),
992
+ defaultClasses: ""
993
+ });
994
+ registerSubComponent({
995
+ name: "text",
996
+ component: ({ children, className }) => React3.createElement("span", { className }, children),
997
+ defaultClasses: ""
998
+ });
999
+ registerSubComponent({
1000
+ name: "badge",
1001
+ component: ({ children, className }) => React3.createElement(
1002
+ "span",
1003
+ {
1004
+ className: `ml-2 px-2 py-0.5 text-xs rounded-full bg-red-500 text-white ${className || ""}`
1005
+ },
1006
+ children
1007
+ ),
1008
+ defaultClasses: "ml-2 px-2 py-0.5 text-xs rounded-full bg-red-500 text-white"
1009
+ });
1010
+ registerSubComponent({
1011
+ name: "header",
1012
+ component: ({ children, className }) => React3.createElement("header", { className: `font-bold text-lg ${className || ""}` }, children),
1013
+ defaultClasses: "font-bold text-lg"
1014
+ });
1015
+ registerSubComponent({
1016
+ name: "body",
1017
+ component: ({ children, className }) => React3.createElement("div", { className: `flex-1 ${className || ""}` }, children),
1018
+ defaultClasses: "flex-1"
1019
+ });
1020
+ registerSubComponent({
1021
+ name: "footer",
1022
+ component: ({ children, className }) => React3.createElement("footer", { className: `border-t pt-4 ${className || ""}` }, children),
1023
+ defaultClasses: "border-t pt-4"
1024
+ });
1025
+ registerSubComponent({
1026
+ name: "content",
1027
+ component: ({ children, className }) => React3.createElement("div", { className }, children),
1028
+ defaultClasses: ""
1029
+ });
1030
+ registerSubComponent({
1031
+ name: "title",
1032
+ component: ({ children, className }) => React3.createElement("div", { className: `font-semibold ${className || ""}` }, children),
1033
+ defaultClasses: "font-semibold"
1034
+ });
1035
+ registerSubComponent({
1036
+ name: "message",
1037
+ component: ({ children, className }) => React3.createElement("div", { className: `text-sm ${className || ""}` }, children),
1038
+ defaultClasses: "text-sm"
1039
+ });
1040
+ registerSubComponent({
1041
+ name: "close",
1042
+ component: ({ children, className }) => React3.createElement("span", { className: `cursor-pointer ${className || ""}` }, children),
1043
+ defaultClasses: "cursor-pointer"
1044
+ });
1045
+ registerSubComponent({
1046
+ name: "image",
1047
+ component: ({ className }) => React3.createElement("img", { className }),
1048
+ defaultClasses: ""
1049
+ });
1050
+
1051
+ // packages/domain/core/src/styled.ts
1052
+ function resolveVariantClass(options, props) {
1053
+ const out = [];
1054
+ const variants = options.variants ?? {};
1055
+ const defaults = options.defaultVariants ?? {};
1056
+ for (const [variantName, valueMap] of Object.entries(variants)) {
1057
+ const value = props[variantName] ?? defaults[variantName];
1058
+ if (value === void 0) continue;
1059
+ const key = String(value);
1060
+ const cls = valueMap[key];
1061
+ if (cls) out.push(cls);
1062
+ }
1063
+ for (const compound of options.compoundVariants ?? []) {
1064
+ const matches = Object.entries(compound.variants).every(([k, expected]) => {
1065
+ const current = props[k] ?? defaults[k];
1066
+ return String(current) === expected;
1067
+ });
1068
+ if (matches) out.push(compound.className);
1069
+ }
1070
+ return out;
1071
+ }
1072
+ function resolveStyledClassName(options, props = {}) {
1073
+ const parts = [options.base ?? "", ...resolveVariantClass(options, props), props.className ?? ""];
1074
+ return twMerge(...parts);
1075
+ }
1076
+ function styled(options) {
1077
+ return function getClassName(props = {}) {
1078
+ return resolveStyledClassName(options, props);
1079
+ };
1080
+ }
1081
+
1082
+ // packages/domain/core/src/styledSystem.ts
1083
+ function tokenVarName(prefix, group, name) {
1084
+ return `--${prefix}-${group}-${name}`;
1085
+ }
1086
+ function tokenVarRef(prefix, group, name) {
1087
+ return `var(${tokenVarName(prefix, group, name)})`;
1088
+ }
1089
+ function resolveTokenRef(tokens, prefix, value) {
1090
+ if (value.startsWith("token:")) {
1091
+ const path = value.slice(6);
1092
+ const [group, name] = path.split(".");
1093
+ if (group && name && tokens[group]?.[name] !== void 0) {
1094
+ return tokenVarRef(prefix, group, name);
1095
+ }
1096
+ }
1097
+ return value;
1098
+ }
1099
+ function injectTokensToRoot(tokens, prefix) {
1100
+ if (typeof document === "undefined") return;
1101
+ const styleId = `__tw-sys-tokens-${prefix}`;
1102
+ if (document.getElementById(styleId)) return;
1103
+ const lines = [":root {"];
1104
+ for (const [group, map] of Object.entries(tokens)) {
1105
+ for (const [name, value] of Object.entries(map)) {
1106
+ lines.push(` ${tokenVarName(prefix, group, name)}: ${value};`);
1107
+ }
1108
+ }
1109
+ lines.push("}");
1110
+ const style = document.createElement("style");
1111
+ style.id = styleId;
1112
+ style.textContent = lines.join("\n");
1113
+ document.head.appendChild(style);
1114
+ }
1115
+ function resolveComponentConfig(config, tokens, prefix) {
1116
+ const resolveStr = (s) => resolveTokenRef(tokens, prefix, s);
1117
+ const base = resolveStr(config.base ?? "");
1118
+ const systemBase = resolveStr(config.systemBase ?? "");
1119
+ const mergedBase = [systemBase, base].filter(Boolean).join(" ");
1120
+ const variants = {};
1121
+ for (const [variantKey, variantMap] of Object.entries(config.variants ?? {})) {
1122
+ variants[variantKey] = {};
1123
+ for (const [optKey, classes] of Object.entries(variantMap)) {
1124
+ variants[variantKey][optKey] = classes.split(" ").map(resolveStr).join(" ");
1125
+ }
1126
+ }
1127
+ const compoundVariants = (config.compoundVariants ?? []).map((cv2) => {
1128
+ const { class: cls, ...rest } = cv2;
1129
+ return { class: resolveStr(cls), ...rest };
1130
+ });
1131
+ return {
1132
+ base: mergedBase,
1133
+ variants,
1134
+ compoundVariants,
1135
+ defaultVariants: config.defaultVariants ?? {},
1136
+ state: config.state,
1137
+ container: config.container,
1138
+ containerName: config.containerName
1139
+ };
1140
+ }
1141
+ function createStyledSystem(config) {
1142
+ const prefix = config.prefix ?? "sys";
1143
+ const tokens = config.tokens ?? {};
1144
+ const componentDefs = config.components ?? {};
1145
+ const shouldInject = config.injectTokens !== false;
1146
+ if (shouldInject && typeof window !== "undefined") {
1147
+ injectTokensToRoot(tokens, prefix);
1148
+ }
1149
+ const resolvedConfigs = /* @__PURE__ */ new Map();
1150
+ for (const [name, compCfg] of Object.entries(componentDefs)) {
1151
+ resolvedConfigs.set(
1152
+ name,
1153
+ resolveComponentConfig(compCfg, tokens, prefix)
1154
+ );
1155
+ }
1156
+ const factories = {};
1157
+ for (const [name, compCfg] of Object.entries(componentDefs)) {
1158
+ const tag = compCfg.tag ?? "div";
1159
+ factories[name] = (overrides) => {
1160
+ const baseResolved = resolvedConfigs.get(name);
1161
+ const runtimeTag = tag;
1162
+ if (!overrides || Object.keys(overrides).length === 0) {
1163
+ return createComponent(runtimeTag, baseResolved);
1164
+ }
1165
+ const overrideResolved = resolveComponentConfig(
1166
+ overrides,
1167
+ tokens,
1168
+ prefix
1169
+ );
1170
+ const merged = {
1171
+ base: [baseResolved.base, overrideResolved.base].filter(Boolean).join(" "),
1172
+ variants: {
1173
+ ...baseResolved.variants ?? void 0,
1174
+ ...overrideResolved.variants ?? void 0
1175
+ },
1176
+ compoundVariants: [
1177
+ ...baseResolved.compoundVariants ?? [],
1178
+ ...overrideResolved.compoundVariants ?? []
1179
+ ],
1180
+ defaultVariants: {
1181
+ ...baseResolved.defaultVariants ?? void 0,
1182
+ ...overrideResolved.defaultVariants ?? void 0
1183
+ },
1184
+ state: overrideResolved.state ?? baseResolved.state,
1185
+ container: overrideResolved.container ?? baseResolved.container,
1186
+ containerName: overrideResolved.containerName ?? baseResolved.containerName
1187
+ };
1188
+ return createComponent(runtimeTag, merged);
1189
+ };
1190
+ }
1191
+ function token(path) {
1192
+ const [group, name] = path.split(".");
1193
+ if (!group || !name) return path;
1194
+ return tokenVarRef(prefix, group, name);
1195
+ }
1196
+ function rawToken(path) {
1197
+ const [group, name] = path.split(".");
1198
+ if (!group || !name) return void 0;
1199
+ return tokens[group]?.[name];
1200
+ }
1201
+ function setTokens2(updates) {
1202
+ if (typeof document === "undefined") return;
1203
+ const styleId = `__tw-sys-tokens-${prefix}`;
1204
+ const style = document.getElementById(styleId) ?? (() => {
1205
+ const el = document.createElement("style");
1206
+ el.id = styleId;
1207
+ document.head.appendChild(el);
1208
+ return el;
1209
+ })();
1210
+ for (const [group, map] of Object.entries(updates)) {
1211
+ if (!tokens[group]) continue;
1212
+ for (const [name, value] of Object.entries(map)) {
1213
+ tokens[group][name] = value;
1214
+ }
1215
+ }
1216
+ const lines = [":root {"];
1217
+ for (const [group, map] of Object.entries(tokens)) {
1218
+ for (const [name, value] of Object.entries(map)) {
1219
+ lines.push(` ${tokenVarName(prefix, group, name)}: ${value};`);
1220
+ }
1221
+ }
1222
+ lines.push("}");
1223
+ style.textContent = lines.join("\n");
1224
+ }
1225
+ function getConfig(name) {
1226
+ return resolvedConfigs.get(name);
1227
+ }
1228
+ return Object.assign(factories, {
1229
+ token,
1230
+ rawToken,
1231
+ setTokens: setTokens2,
1232
+ getConfig,
1233
+ tokens
1234
+ });
1235
+ }
1236
+ var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
1237
+ var COMMENT_RE = /\/\/[^\n]*/g;
1238
+ function parseTemplateFallback(strings, exprs) {
1239
+ const raw = strings.raw.reduce((acc, str, i) => {
1240
+ const expr = exprs[i];
1241
+ const exprStr = typeof expr === "function" ? "" : expr ?? "";
1242
+ return acc + str + String(exprStr);
1243
+ }, "");
1244
+ const subs = {};
1245
+ let base = raw;
1246
+ let match;
1247
+ SUB_RE.lastIndex = 0;
1248
+ while ((match = SUB_RE.exec(raw)) !== null) {
1249
+ const name = match[1] ?? match[2];
1250
+ const rawInner = match[3].replace(COMMENT_RE, "");
1251
+ let inner = "";
1252
+ for (const line of rawInner.split("\n")) {
1253
+ const t2 = line.trim();
1254
+ if (t2) inner += (inner ? " " : "") + t2;
1255
+ }
1256
+ inner = inner.replace(/\s+/g, " ").trim();
1257
+ subs[name] = inner;
1258
+ base = base.replace(match[0], "");
1259
+ }
1260
+ const rawBase = base.replace(COMMENT_RE, "");
1261
+ let cleanBase = "";
1262
+ for (const line of rawBase.split("\n")) {
1263
+ const t2 = line.trim();
1264
+ if (t2) cleanBase += (cleanBase ? " " : "") + t2;
1265
+ }
1266
+ cleanBase = cleanBase.replace(/\s+/g, " ").trim();
1267
+ return { base: cleanBase, subs, hasSubs: Object.keys(subs).length > 0 };
1268
+ }
1269
+ var _parsedTemplateCache = /* @__PURE__ */ new Map();
1270
+ function parseTemplate(strings, exprs) {
1271
+ const raw = strings.raw.reduce((acc, str, i) => {
1272
+ const expr = exprs[i];
1273
+ const exprStr = typeof expr === "function" ? "" : expr ?? "";
1274
+ return acc + str + String(exprStr);
1275
+ }, "");
1276
+ const cached = _parsedTemplateCache.get(raw);
1277
+ if (cached) return cached;
1278
+ let result;
1279
+ try {
1280
+ const binding = getNativeBinding();
1281
+ if (binding?.parseTemplate) ;
1282
+ } catch {
1283
+ }
1284
+ result = parseTemplateFallback(strings, exprs);
1285
+ _parsedTemplateCache.set(raw, result);
1286
+ return result;
1287
+ }
1288
+ function makeTag(tag) {
1289
+ return ((stringsOrConfig, ...exprs) => {
1290
+ if (!Array.isArray(stringsOrConfig) && typeof stringsOrConfig === "object" && stringsOrConfig !== null && !("raw" in stringsOrConfig)) {
1291
+ return createComponent(tag, stringsOrConfig);
1292
+ }
1293
+ const parsed = parseTemplate(stringsOrConfig, exprs);
1294
+ const component = createComponent(tag, parsed.base);
1295
+ if (parsed.hasSubs) {
1296
+ for (const [name, classes] of Object.entries(parsed.subs)) {
1297
+ const SubComp = React3.forwardRef(
1298
+ ({ children, className }, ref) => React3.createElement("span", {
1299
+ ref,
1300
+ className: className ? `${classes} ${className}` : classes
1301
+ }, children)
1302
+ );
1303
+ SubComp.displayName = `tw.${typeof tag === "string" ? tag : "component"}.${name}`;
1304
+ component[name] = SubComp;
1305
+ }
1306
+ }
1307
+ return component;
1308
+ });
1309
+ }
1310
+ var HTML_TAGS = [
1311
+ "div",
1312
+ "section",
1313
+ "article",
1314
+ "aside",
1315
+ "header",
1316
+ "footer",
1317
+ "main",
1318
+ "nav",
1319
+ "figure",
1320
+ "figcaption",
1321
+ "details",
1322
+ "summary",
1323
+ "h1",
1324
+ "h2",
1325
+ "h3",
1326
+ "h4",
1327
+ "h5",
1328
+ "h6",
1329
+ "p",
1330
+ "span",
1331
+ "strong",
1332
+ "em",
1333
+ "b",
1334
+ "i",
1335
+ "s",
1336
+ "u",
1337
+ "small",
1338
+ "mark",
1339
+ "abbr",
1340
+ "cite",
1341
+ "code",
1342
+ "kbd",
1343
+ "samp",
1344
+ "var",
1345
+ "time",
1346
+ "address",
1347
+ "blockquote",
1348
+ "q",
1349
+ "del",
1350
+ "ins",
1351
+ "sub",
1352
+ "sup",
1353
+ "ul",
1354
+ "ol",
1355
+ "li",
1356
+ "dl",
1357
+ "dt",
1358
+ "dd",
1359
+ "table",
1360
+ "thead",
1361
+ "tbody",
1362
+ "tfoot",
1363
+ "tr",
1364
+ "th",
1365
+ "td",
1366
+ "caption",
1367
+ "colgroup",
1368
+ "col",
1369
+ "img",
1370
+ "picture",
1371
+ "video",
1372
+ "audio",
1373
+ "source",
1374
+ "track",
1375
+ "canvas",
1376
+ "svg",
1377
+ "path",
1378
+ "circle",
1379
+ "rect",
1380
+ "line",
1381
+ "polyline",
1382
+ "polygon",
1383
+ "g",
1384
+ "defs",
1385
+ "use",
1386
+ "symbol",
1387
+ "form",
1388
+ "input",
1389
+ "textarea",
1390
+ "select",
1391
+ "option",
1392
+ "optgroup",
1393
+ "button",
1394
+ "label",
1395
+ "fieldset",
1396
+ "legend",
1397
+ "output",
1398
+ "progress",
1399
+ "meter",
1400
+ "datalist",
1401
+ "a",
1402
+ "area",
1403
+ "map",
1404
+ "iframe",
1405
+ "embed",
1406
+ "object",
1407
+ "pre",
1408
+ "hr",
1409
+ "br",
1410
+ "wbr",
1411
+ "dialog",
1412
+ "menu",
1413
+ "template",
1414
+ "slot"
1415
+ ];
1416
+ function makeServerTag(tag) {
1417
+ const baseFactory = makeTag(tag);
1418
+ if (typeof window !== "undefined" && true) {
1419
+ return ((stringsOrConfig, ...exprs) => {
1420
+ const tagName = typeof tag === "string" ? tag : tag.displayName ?? "Component";
1421
+ console.warn(
1422
+ `[tailwind-styled-v4] tw.server.${tagName} rendered in browser. Ensure withTailwindStyled or Vite plugin is configured.`
1423
+ );
1424
+ return baseFactory(stringsOrConfig, ...exprs);
1425
+ });
1426
+ }
1427
+ return baseFactory;
1428
+ }
1429
+ var serverFactories = {};
1430
+ for (const tag of HTML_TAGS) {
1431
+ serverFactories[tag] = makeServerTag(tag);
1432
+ }
1433
+ var server = serverFactories;
1434
+ var tagFactories = {};
1435
+ for (const tag of HTML_TAGS) {
1436
+ tagFactories[tag] = makeTag(tag);
1437
+ }
1438
+ function twCallable(component) {
1439
+ return makeTag(component);
1440
+ }
1441
+ var tw = Object.assign(twCallable, tagFactories, {
1442
+ server
1443
+ });
1444
+
1445
+ // packages/domain/core/src/twTheme.ts
1446
+ function cssVar(varName, fallback) {
1447
+ const name = varName.startsWith("--") ? varName : `--${varName}`;
1448
+ return fallback ? `var(${name}, ${fallback})` : `var(${name})`;
1449
+ }
1450
+ function twVar(property, varName, fallback) {
1451
+ const ref = fallback ? `var(--${varName},${fallback})` : `var(--${varName})`;
1452
+ return `${property}-[${ref}]`;
1453
+ }
1454
+ var t = {
1455
+ /** Background color from CSS variable: t.bg("color-primary") → "bg-[var(--color-primary)]" */
1456
+ bg: (v, fb) => twVar("bg", v, fb),
1457
+ /** Text color from CSS variable */
1458
+ text: (v, fb) => twVar("text", v, fb),
1459
+ /** Border color from CSS variable */
1460
+ border: (v, fb) => twVar("border", v, fb),
1461
+ /** Ring color from CSS variable */
1462
+ ring: (v, fb) => twVar("ring", v, fb),
1463
+ /** Outline color from CSS variable */
1464
+ outline: (v, fb) => twVar("outline", v, fb),
1465
+ /** Fill color from CSS variable (SVG) */
1466
+ fill: (v, fb) => twVar("fill", v, fb),
1467
+ /** Stroke color from CSS variable (SVG) */
1468
+ stroke: (v, fb) => twVar("stroke", v, fb),
1469
+ /** Font family from CSS variable */
1470
+ font: (v, fb) => twVar("font", v, fb),
1471
+ /** Shadow from CSS variable */
1472
+ shadow: (v, fb) => twVar("shadow", v, fb),
1473
+ /** Any arbitrary property from CSS variable */
1474
+ var: (property, v, fb) => twVar(property, v, fb)
1475
+ };
1476
+ function createTheme(tokenMap) {
1477
+ const resolved = {};
1478
+ for (const group in tokenMap) {
1479
+ resolved[group] = {};
1480
+ const tokens = tokenMap[group];
1481
+ for (const name in tokens) {
1482
+ const varName = tokens[name];
1483
+ const prefix = getGroupPrefix(group);
1484
+ resolved[group][name] = prefix ? twVar(prefix, varName) : cssVar(varName);
1485
+ }
1486
+ }
1487
+ return resolved;
1488
+ }
1489
+ function getGroupPrefix(group) {
1490
+ const map = {
1491
+ colors: "bg",
1492
+ // default to bg; user can use t.text() for text colors
1493
+ fonts: "font",
1494
+ spacing: "p",
1495
+ shadows: "shadow"
1496
+ };
1497
+ return map[group] ?? "";
1498
+ }
1499
+ var v4Tokens = {
1500
+ /** bg-[var(--color-background)] */
1501
+ bg: twVar("bg", "color-background"),
1502
+ /** text-[var(--color-foreground)] */
1503
+ text: twVar("text", "color-foreground"),
1504
+ /** font-[var(--font-sans)] */
1505
+ fontSans: twVar("font", "font-sans"),
1506
+ /** font-[var(--font-mono)] */
1507
+ fontMono: twVar("font", "font-mono")
1508
+ };
1509
+
1510
+ export { applyTokenSet, cn, tokenRef as containerRef, createComponent, createStyledSystem, createTheme, createTwMerge, createUseTokens, cssVar, cv, cx, cxm, generateContainerCss, generateStateCss, generateTokenCssString, getAllSubComponents, getContainerRegistry, getStateRegistry, getSubComponent, getToken, getTokens, liveToken, mergeWithRules, processContainer, processState, registerSubComponent, resolveStyledClassName, server, setToken, setTokens, styled, subscribeTokens, t, tokenRef, tokenVar, tw, twMerge, twVar, v4Tokens, withSubComponents };
1511
+ //# sourceMappingURL=index.browser.mjs.map
1512
+ //# sourceMappingURL=index.browser.mjs.map