@pequity/squirrel 11.0.0 → 11.0.2

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.
@@ -1,234 +1,389 @@
1
1
  "use strict";
2
- var y = /\s+/g, a = (t) => typeof t != "string" || !t ? t : t.replace(y, " ").trim(), u = (...t) => {
3
- let r = [], n = (e) => {
4
- if (!e && e !== 0 && e !== 0n) return;
5
- if (Array.isArray(e)) {
6
- for (let s = 0, o = e.length; s < o; s++) n(e[s]);
2
+ var SPACE_REGEX = /\s+/g;
3
+ var removeExtraSpaces = (str) => {
4
+ if (typeof str !== "string" || !str) return str;
5
+ return str.replace(SPACE_REGEX, " ").trim();
6
+ };
7
+ var cx = (...classnames) => {
8
+ const classList = [];
9
+ const buildClassString = (input) => {
10
+ if (!input && input !== 0 && input !== 0n) return;
11
+ if (Array.isArray(input)) {
12
+ for (let i = 0, len = input.length; i < len; i++) buildClassString(input[i]);
7
13
  return;
8
14
  }
9
- let f2 = typeof e;
10
- if (f2 === "string" || f2 === "number" || f2 === "bigint") {
11
- if (f2 === "number" && e !== e) return;
12
- r.push(String(e));
13
- } else if (f2 === "object") {
14
- let s = Object.keys(e);
15
- for (let o = 0, i2 = s.length; o < i2; o++) {
16
- let l = s[o];
17
- e[l] && r.push(l);
15
+ const type = typeof input;
16
+ if (type === "string" || type === "number" || type === "bigint") {
17
+ if (type === "number" && input !== input) return;
18
+ classList.push(String(input));
19
+ } else if (type === "object") {
20
+ const keys = Object.keys(input);
21
+ for (let i = 0, len = keys.length; i < len; i++) {
22
+ const key = keys[i];
23
+ if (input[key]) classList.push(key);
18
24
  }
19
25
  }
20
26
  };
21
- for (let e = 0, f2 = t.length; e < f2; e++) {
22
- let s = t[e];
23
- s != null && n(s);
27
+ for (let i = 0, len = classnames.length; i < len; i++) {
28
+ const c = classnames[i];
29
+ if (c !== null && c !== void 0) buildClassString(c);
24
30
  }
25
- return r.length > 0 ? a(r.join(" ")) : void 0;
26
- }, h = (t) => t === false ? "false" : t === true ? "true" : t === 0 ? "0" : t, x = (t) => {
27
- if (!t || typeof t != "object") return true;
28
- for (let r in t) return false;
31
+ return classList.length > 0 ? removeExtraSpaces(classList.join(" ")) : void 0;
32
+ };
33
+ var falsyToString = (value) => value === false ? "false" : value === true ? "true" : value === 0 ? "0" : value;
34
+ var isEmptyObject = (obj) => {
35
+ if (!obj || typeof obj !== "object") return true;
36
+ for (const _ in obj) return false;
29
37
  return true;
30
- }, k = (t, r) => {
31
- if (t === r) return true;
32
- if (!t || !r) return false;
33
- let n = Object.keys(t), e = Object.keys(r);
34
- if (n.length !== e.length) return false;
35
- for (let f2 = 0; f2 < n.length; f2++) {
36
- let s = n[f2];
37
- if (!e.includes(s) || t[s] !== r[s]) return false;
38
+ };
39
+ var isEqual = (obj1, obj2) => {
40
+ if (obj1 === obj2) return true;
41
+ if (!obj1 || !obj2) return false;
42
+ const keys1 = Object.keys(obj1);
43
+ const keys2 = Object.keys(obj2);
44
+ if (keys1.length !== keys2.length) return false;
45
+ for (let i = 0; i < keys1.length; i++) {
46
+ const key = keys1[i];
47
+ if (!keys2.includes(key)) return false;
48
+ if (obj1[key] !== obj2[key]) return false;
38
49
  }
39
50
  return true;
40
- }, d = (t, r) => {
41
- for (let n in r) if (Object.prototype.hasOwnProperty.call(r, n)) {
42
- let e = r[n];
43
- n in t ? t[n] = u(t[n], e) : t[n] = e;
51
+ };
52
+ var joinObjects = (obj1, obj2) => {
53
+ for (const key in obj2) {
54
+ if (Object.prototype.hasOwnProperty.call(obj2, key)) {
55
+ const val2 = obj2[key];
56
+ if (key in obj1) {
57
+ obj1[key] = cx(obj1[key], val2);
58
+ } else {
59
+ obj1[key] = val2;
60
+ }
61
+ }
44
62
  }
45
- return t;
46
- }, c = (t, r) => {
47
- for (let n = 0; n < t.length; n++) {
48
- let e = t[n];
49
- Array.isArray(e) ? c(e, r) : e && r.push(e);
63
+ return obj1;
64
+ };
65
+ var flat = (arr, target) => {
66
+ for (let i = 0; i < arr.length; i++) {
67
+ const el = arr[i];
68
+ if (Array.isArray(el)) flat(el, target);
69
+ else if (el) target.push(el);
70
+ }
71
+ };
72
+ var flatMergeArrays = (...arrays) => {
73
+ const result = [];
74
+ flat(arrays, result);
75
+ const filtered = [];
76
+ for (let i = 0; i < result.length; i++) {
77
+ if (result[i]) filtered.push(result[i]);
50
78
  }
79
+ return filtered;
51
80
  };
52
- var g = (...t) => {
53
- let r = [];
54
- c(t, r);
55
- let n = [];
56
- for (let e = 0; e < r.length; e++) r[e] && n.push(r[e]);
57
- return n;
58
- }, p = (t, r) => {
59
- let n = {};
60
- for (let e in t) {
61
- let f2 = t[e];
62
- if (e in r) {
63
- let s = r[e];
64
- Array.isArray(f2) || Array.isArray(s) ? n[e] = g(s, f2) : typeof f2 == "object" && typeof s == "object" && f2 && s ? n[e] = p(f2, s) : n[e] = s + " " + f2;
65
- } else n[e] = f2;
81
+ var mergeObjects = (obj1, obj2) => {
82
+ const result = {};
83
+ for (const key in obj1) {
84
+ const val1 = obj1[key];
85
+ if (key in obj2) {
86
+ const val2 = obj2[key];
87
+ if (Array.isArray(val1) || Array.isArray(val2)) {
88
+ result[key] = flatMergeArrays(val2, val1);
89
+ } else if (typeof val1 === "object" && typeof val2 === "object" && val1 && val2) {
90
+ result[key] = mergeObjects(val1, val2);
91
+ } else {
92
+ result[key] = val2 + " " + val1;
93
+ }
94
+ } else {
95
+ result[key] = val1;
96
+ }
97
+ }
98
+ for (const key in obj2) {
99
+ if (!(key in obj1)) {
100
+ result[key] = obj2[key];
101
+ }
66
102
  }
67
- for (let e in r) e in t || (n[e] = r[e]);
68
- return n;
103
+ return result;
69
104
  };
70
- var Q = { twMerge: true, twMergeConfig: {}, responsiveVariants: false };
71
- function ne() {
72
- let b = null, w = {}, A = false;
73
- return { get cachedTwMerge() {
74
- return b;
75
- }, set cachedTwMerge(u2) {
76
- b = u2;
77
- }, get cachedTwMergeConfig() {
78
- return w;
79
- }, set cachedTwMergeConfig(u2) {
80
- w = u2;
81
- }, get didTwMergeConfigChange() {
82
- return A;
83
- }, set didTwMergeConfigChange(u2) {
84
- A = u2;
85
- }, reset() {
86
- b = null, w = {}, A = false;
87
- } };
105
+ var defaultConfig = {
106
+ twMerge: true,
107
+ twMergeConfig: {}
108
+ };
109
+ function createState() {
110
+ let cachedTwMerge = null;
111
+ let cachedTwMergeConfig = {};
112
+ let didTwMergeConfigChange = false;
113
+ return {
114
+ get cachedTwMerge() {
115
+ return cachedTwMerge;
116
+ },
117
+ set cachedTwMerge(value) {
118
+ cachedTwMerge = value;
119
+ },
120
+ get cachedTwMergeConfig() {
121
+ return cachedTwMergeConfig;
122
+ },
123
+ set cachedTwMergeConfig(value) {
124
+ cachedTwMergeConfig = value;
125
+ },
126
+ get didTwMergeConfigChange() {
127
+ return didTwMergeConfigChange;
128
+ },
129
+ set didTwMergeConfigChange(value) {
130
+ didTwMergeConfigChange = value;
131
+ },
132
+ reset() {
133
+ cachedTwMerge = null;
134
+ cachedTwMergeConfig = {};
135
+ didTwMergeConfigChange = false;
136
+ }
137
+ };
88
138
  }
89
- var S = ne();
90
- var le = (b$1) => {
91
- let w = (u$1, $) => {
92
- let { extend: c$1 = null, slots: M = {}, variants: q = {}, compoundVariants: L = [], compoundSlots: v = [], defaultVariants: U = {} } = u$1, d$1 = { ...Q, ...$ }, x$1 = c$1?.base ? u(c$1.base, u$1?.base) : u$1?.base, p$1 = c$1?.variants && !x(c$1.variants) ? p(q, c$1.variants) : q, E = c$1?.defaultVariants && !x(c$1.defaultVariants) ? { ...c$1.defaultVariants, ...U } : U;
93
- !x(d$1.twMergeConfig) && !k(d$1.twMergeConfig, S.cachedTwMergeConfig) && (S.didTwMergeConfigChange = true, S.cachedTwMergeConfig = d$1.twMergeConfig);
94
- let N = x(c$1?.slots), O = x(M) ? {} : { base: u(u$1?.base, N && c$1?.base), ...M }, j$1 = N ? O : d({ ...c$1?.slots }, x(O) ? { base: u$1?.base } : O), T2 = x(c$1?.compoundVariants) ? L : g(c$1?.compoundVariants, L), y2 = (h$1) => {
95
- if (x(p$1) && x(M) && N) return b$1(x$1, h$1?.class, h$1?.className)(d$1);
96
- if (T2 && !Array.isArray(T2)) throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof T2}`);
97
- if (v && !Array.isArray(v)) throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof v}`);
98
- let Y = (t, e, n = [], a$1) => {
99
- let r = n;
100
- if (typeof e == "string") {
101
- let i2 = a(e).split(" ");
102
- for (let l = 0; l < i2.length; l++) r.push(`${t}:${i2[l]}`);
103
- } else if (Array.isArray(e)) for (let s = 0; s < e.length; s++) r.push(`${t}:${e[s]}`);
104
- else if (typeof e == "object" && typeof a$1 == "string" && a$1 in e) {
105
- let s = e[a$1];
106
- if (s && typeof s == "string") {
107
- let l = a(s).split(" "), f2 = [];
108
- for (let o = 0; o < l.length; o++) f2.push(`${t}:${l[o]}`);
109
- r[a$1] = r[a$1] ? r[a$1].concat(f2) : f2;
110
- } else if (Array.isArray(s) && s.length > 0) {
111
- let i2 = [];
112
- for (let l = 0; l < s.length; l++) i2.push(`${t}:${s[l]}`);
113
- r[a$1] = i2;
114
- }
139
+ var state = createState();
140
+ var getTailwindVariants = (cn2) => {
141
+ const tv2 = (options, configProp) => {
142
+ const {
143
+ extend = null,
144
+ slots: slotProps = {},
145
+ variants: variantsProps = {},
146
+ compoundVariants: compoundVariantsProps = [],
147
+ compoundSlots = [],
148
+ defaultVariants: defaultVariantsProps = {}
149
+ } = options;
150
+ const config = { ...defaultConfig, ...configProp };
151
+ const base = extend?.base ? cx(extend.base, options?.base) : options?.base;
152
+ const variants = extend?.variants && !isEmptyObject(extend.variants) ? mergeObjects(variantsProps, extend.variants) : variantsProps;
153
+ const defaultVariants = extend?.defaultVariants && !isEmptyObject(extend.defaultVariants) ? { ...extend.defaultVariants, ...defaultVariantsProps } : defaultVariantsProps;
154
+ if (!isEmptyObject(config.twMergeConfig) && !isEqual(config.twMergeConfig, state.cachedTwMergeConfig)) {
155
+ state.didTwMergeConfigChange = true;
156
+ state.cachedTwMergeConfig = config.twMergeConfig;
157
+ }
158
+ const isExtendedSlotsEmpty = isEmptyObject(extend?.slots);
159
+ const componentSlots = !isEmptyObject(slotProps) ? {
160
+ // add "base" to the slots object
161
+ base: cx(options?.base, isExtendedSlotsEmpty && extend?.base),
162
+ ...slotProps
163
+ } : {};
164
+ const slots = isExtendedSlotsEmpty ? componentSlots : joinObjects(
165
+ { ...extend?.slots },
166
+ isEmptyObject(componentSlots) ? { base: options?.base } : componentSlots
167
+ );
168
+ const compoundVariants = isEmptyObject(extend?.compoundVariants) ? compoundVariantsProps : flatMergeArrays(extend?.compoundVariants, compoundVariantsProps);
169
+ const component = (props) => {
170
+ if (isEmptyObject(variants) && isEmptyObject(slotProps) && isExtendedSlotsEmpty) {
171
+ return cn2(base, props?.class, props?.className)(config);
172
+ }
173
+ if (compoundVariants && !Array.isArray(compoundVariants)) {
174
+ throw new TypeError(
175
+ `The "compoundVariants" prop must be an array. Received: ${typeof compoundVariants}`
176
+ );
177
+ }
178
+ if (compoundSlots && !Array.isArray(compoundSlots)) {
179
+ throw new TypeError(
180
+ `The "compoundSlots" prop must be an array. Received: ${typeof compoundSlots}`
181
+ );
182
+ }
183
+ const getVariantValue = (variant, vrs = variants, _slotKey = null, slotProps2 = null) => {
184
+ const variantObj = vrs[variant];
185
+ if (!variantObj || isEmptyObject(variantObj)) {
186
+ return null;
115
187
  }
116
- return r;
117
- }, W = (t, e = p$1, n = null, a2 = null) => {
118
- let r = e[t];
119
- if (!r || x(r)) return null;
120
- let s = a2?.[t] ?? h$1?.[t];
121
- if (s === null) return null;
122
- let i2 = h(s), l = Array.isArray(d$1.responsiveVariants) && d$1.responsiveVariants.length > 0 || d$1.responsiveVariants === true, f2 = E?.[t], o = [];
123
- if (typeof i2 == "object" && l) for (let [C2, H] of Object.entries(i2)) {
124
- let te = r[H];
125
- if (C2 === "initial") {
126
- f2 = H;
127
- continue;
128
- }
129
- Array.isArray(d$1.responsiveVariants) && !d$1.responsiveVariants.includes(C2) || (o = Y(C2, te, o, n));
188
+ const variantProp = slotProps2?.[variant] ?? props?.[variant];
189
+ if (variantProp === null) return null;
190
+ const variantKey = falsyToString(variantProp);
191
+ if (typeof variantKey === "object") {
192
+ return null;
130
193
  }
131
- let V = i2 != null && typeof i2 != "object" ? i2 : h(f2), m = r[V || "false"];
132
- return typeof o == "object" && typeof n == "string" && o[n] ? d(o, m) : o.length > 0 ? (o.push(m), n === "base" ? o.join(" ") : o) : m;
133
- }, Z = () => {
134
- if (!p$1) return null;
135
- let t = Object.keys(p$1), e = [];
136
- for (let n = 0; n < t.length; n++) {
137
- let a2 = W(t[n], p$1);
138
- a2 && e.push(a2);
194
+ const defaultVariantProp = defaultVariants?.[variant];
195
+ const key = variantKey != null ? variantKey : falsyToString(defaultVariantProp);
196
+ const value = variantObj[key || "false"];
197
+ return value;
198
+ };
199
+ const getVariantClassNames = () => {
200
+ if (!variants) return null;
201
+ const keys = Object.keys(variants);
202
+ const result = [];
203
+ for (let i = 0; i < keys.length; i++) {
204
+ const value = getVariantValue(keys[i], variants);
205
+ if (value) result.push(value);
139
206
  }
140
- return e;
141
- }, _ = (t, e) => {
142
- if (!p$1 || typeof p$1 != "object") return null;
143
- let n = [];
144
- for (let a2 in p$1) {
145
- let r = W(a2, p$1, t, e), s = t === "base" && typeof r == "string" ? r : r && r[t];
146
- s && n.push(s);
207
+ return result;
208
+ };
209
+ const getVariantClassNamesBySlotKey = (slotKey, slotProps2) => {
210
+ if (!variants || typeof variants !== "object") return null;
211
+ const result = [];
212
+ for (const variant in variants) {
213
+ const variantValue = getVariantValue(variant, variants, slotKey, slotProps2);
214
+ const value = slotKey === "base" && typeof variantValue === "string" ? variantValue : variantValue && variantValue[slotKey];
215
+ if (value) result.push(value);
147
216
  }
148
- return n;
149
- }, z = {};
150
- for (let t in h$1) {
151
- let e = h$1[t];
152
- e !== void 0 && (z[t] = e);
217
+ return result;
218
+ };
219
+ const propsWithoutUndefined = {};
220
+ for (const prop in props) {
221
+ const value = props[prop];
222
+ if (value !== void 0) propsWithoutUndefined[prop] = value;
153
223
  }
154
- let D = (t, e) => {
155
- let n = typeof h$1?.[t] == "object" ? { [t]: h$1[t]?.initial } : {};
156
- return { ...E, ...z, ...n, ...e };
157
- }, G = (t = [], e) => {
158
- let n = [], a2 = t.length;
159
- for (let r = 0; r < a2; r++) {
160
- let { class: s, className: i2, ...l } = t[r], f2 = true, o = D(null, e);
161
- for (let V in l) {
162
- let m = l[V], C2 = o[V];
163
- if (Array.isArray(m)) {
164
- if (!m.includes(C2)) {
165
- f2 = false;
224
+ const getCompleteProps = (key, slotProps2) => {
225
+ const initialProp = typeof props?.[key] === "object" ? {
226
+ [key]: props[key]?.initial
227
+ } : {};
228
+ return {
229
+ ...defaultVariants,
230
+ ...propsWithoutUndefined,
231
+ ...initialProp,
232
+ ...slotProps2
233
+ };
234
+ };
235
+ const getCompoundVariantsValue = (cv = [], slotProps2) => {
236
+ const result = [];
237
+ const cvLength = cv.length;
238
+ for (let i = 0; i < cvLength; i++) {
239
+ const { class: tvClass, className: tvClassName, ...compoundVariantOptions } = cv[i];
240
+ let isValid = true;
241
+ const completeProps = getCompleteProps(null, slotProps2);
242
+ for (const key in compoundVariantOptions) {
243
+ const value = compoundVariantOptions[key];
244
+ const completePropsValue = completeProps[key];
245
+ if (Array.isArray(value)) {
246
+ if (!value.includes(completePropsValue)) {
247
+ isValid = false;
166
248
  break;
167
249
  }
168
250
  } else {
169
- if ((m == null || m === false) && (C2 == null || C2 === false)) continue;
170
- if (C2 !== m) {
171
- f2 = false;
251
+ if ((value == null || value === false) && (completePropsValue == null || completePropsValue === false))
252
+ continue;
253
+ if (completePropsValue !== value) {
254
+ isValid = false;
172
255
  break;
173
256
  }
174
257
  }
175
258
  }
176
- f2 && (s && n.push(s), i2 && n.push(i2));
259
+ if (isValid) {
260
+ if (tvClass) result.push(tvClass);
261
+ if (tvClassName) result.push(tvClassName);
262
+ }
177
263
  }
178
- return n;
179
- }, K = (t) => {
180
- let e = G(T2, t);
181
- if (!Array.isArray(e)) return e;
182
- let n = {}, a2 = b$1;
183
- for (let r = 0; r < e.length; r++) {
184
- let s = e[r];
185
- if (typeof s == "string") n.base = a2(n.base, s)(d$1);
186
- else if (typeof s == "object") for (let i2 in s) n[i2] = a2(n[i2], s[i2])(d$1);
264
+ return result;
265
+ };
266
+ const getCompoundVariantClassNamesBySlot = (slotProps2) => {
267
+ const compoundClassNames = getCompoundVariantsValue(compoundVariants, slotProps2);
268
+ if (!Array.isArray(compoundClassNames)) return compoundClassNames;
269
+ const result = {};
270
+ const cnFn = cn2;
271
+ for (let i = 0; i < compoundClassNames.length; i++) {
272
+ const className = compoundClassNames[i];
273
+ if (typeof className === "string") {
274
+ result.base = cnFn(result.base, className)(config);
275
+ } else if (typeof className === "object") {
276
+ for (const slot in className) {
277
+ result[slot] = cnFn(result[slot], className[slot])(config);
278
+ }
279
+ }
187
280
  }
188
- return n;
189
- }, ee = (t) => {
190
- if (v.length < 1) return null;
191
- let e = {}, n = D(null, t);
192
- for (let a2 = 0; a2 < v.length; a2++) {
193
- let { slots: r = [], class: s, className: i2, ...l } = v[a2];
194
- if (!x(l)) {
195
- let f2 = true;
196
- for (let o in l) {
197
- let V = n[o], m = l[o];
198
- if (V === void 0 || (Array.isArray(m) ? !m.includes(V) : m !== V)) {
199
- f2 = false;
281
+ return result;
282
+ };
283
+ const getCompoundSlotClassNameBySlot = (slotProps2) => {
284
+ if (compoundSlots.length < 1) return null;
285
+ const result = {};
286
+ const completeProps = getCompleteProps(null, slotProps2);
287
+ for (let i = 0; i < compoundSlots.length; i++) {
288
+ const {
289
+ slots: slots2 = [],
290
+ class: slotClass,
291
+ className: slotClassName,
292
+ ...slotVariants
293
+ } = compoundSlots[i];
294
+ if (!isEmptyObject(slotVariants)) {
295
+ let isValid = true;
296
+ for (const key in slotVariants) {
297
+ const completePropsValue = completeProps[key];
298
+ const slotVariantValue = slotVariants[key];
299
+ if (completePropsValue === void 0 || (Array.isArray(slotVariantValue) ? !slotVariantValue.includes(completePropsValue) : slotVariantValue !== completePropsValue)) {
300
+ isValid = false;
200
301
  break;
201
302
  }
202
303
  }
203
- if (!f2) continue;
304
+ if (!isValid) continue;
204
305
  }
205
- for (let f2 = 0; f2 < r.length; f2++) {
206
- let o = r[f2];
207
- e[o] || (e[o] = []), e[o].push([s, i2]);
306
+ for (let j = 0; j < slots2.length; j++) {
307
+ const slotName = slots2[j];
308
+ if (!result[slotName]) result[slotName] = [];
309
+ result[slotName].push([slotClass, slotClassName]);
208
310
  }
209
311
  }
210
- return e;
312
+ return result;
211
313
  };
212
- if (!x(M) || !N) {
213
- let t = {};
214
- if (typeof j$1 == "object" && !x(j$1)) {
215
- let e = b$1;
216
- for (let n in j$1) t[n] = (a2) => {
217
- let r = K(a2), s = ee(a2);
218
- return e(j$1[n], _(n, a2), r ? r[n] : void 0, s ? s[n] : void 0, a2?.class, a2?.className)(d$1);
219
- };
314
+ if (!isEmptyObject(slotProps) || !isExtendedSlotsEmpty) {
315
+ const slotsFns = {};
316
+ if (typeof slots === "object" && !isEmptyObject(slots)) {
317
+ const cnFn = cn2;
318
+ for (const slotKey in slots) {
319
+ slotsFns[slotKey] = (slotProps2) => {
320
+ const compoundVariantClasses = getCompoundVariantClassNamesBySlot(slotProps2);
321
+ const compoundSlotClasses = getCompoundSlotClassNameBySlot(slotProps2);
322
+ return cnFn(
323
+ slots[slotKey],
324
+ getVariantClassNamesBySlotKey(slotKey, slotProps2),
325
+ compoundVariantClasses ? compoundVariantClasses[slotKey] : void 0,
326
+ compoundSlotClasses ? compoundSlotClasses[slotKey] : void 0,
327
+ slotProps2?.class,
328
+ slotProps2?.className
329
+ )(config);
330
+ };
331
+ }
220
332
  }
221
- return t;
333
+ return slotsFns;
222
334
  }
223
- return b$1(x$1, Z(), G(T2), h$1?.class, h$1?.className)(d$1);
224
- }, X = () => {
225
- if (!(!p$1 || typeof p$1 != "object")) return Object.keys(p$1);
335
+ return cn2(
336
+ base,
337
+ getVariantClassNames(),
338
+ getCompoundVariantsValue(compoundVariants),
339
+ props?.class,
340
+ props?.className
341
+ )(config);
226
342
  };
227
- return y2.variantKeys = X(), y2.extend = c$1, y2.base = x$1, y2.slots = j$1, y2.variants = p$1, y2.defaultVariants = E, y2.compoundSlots = v, y2.compoundVariants = T2, y2;
343
+ const getVariantKeys = () => {
344
+ if (!variants || typeof variants !== "object") return;
345
+ return Object.keys(variants);
346
+ };
347
+ component.variantKeys = getVariantKeys();
348
+ component.extend = extend;
349
+ component.base = base;
350
+ component.slots = slots;
351
+ component.variants = variants;
352
+ component.defaultVariants = defaultVariants;
353
+ component.compoundSlots = compoundSlots;
354
+ component.compoundVariants = compoundVariants;
355
+ return component;
356
+ };
357
+ const createTV2 = (configProp) => {
358
+ return (options, config) => tv2(options, config ? mergeObjects(configProp, config) : configProp);
228
359
  };
229
- return { tv: w, createTV: (u2) => ($, c2) => w($, c2 ? p(u2, c2) : u2) };
360
+ return {
361
+ tv: tv2,
362
+ createTV: createTV2
363
+ };
364
+ };
365
+ const concatArrays = (array1, array2) => {
366
+ const combinedArray = new Array(array1.length + array2.length);
367
+ for (let i = 0; i < array1.length; i++) {
368
+ combinedArray[i] = array1[i];
369
+ }
370
+ for (let i = 0; i < array2.length; i++) {
371
+ combinedArray[array1.length + i] = array2[i];
372
+ }
373
+ return combinedArray;
230
374
  };
375
+ const createClassValidatorObject = (classGroupId, validator) => ({
376
+ classGroupId,
377
+ validator
378
+ });
379
+ const createClassPartObject = (nextPart = /* @__PURE__ */ new Map(), validators = null, classGroupId) => ({
380
+ nextPart,
381
+ validators,
382
+ classGroupId
383
+ });
231
384
  const CLASS_PART_SEPARATOR = "-";
385
+ const EMPTY_CONFLICTS = [];
386
+ const ARBITRARY_PROPERTY_PREFIX = "arbitrary..";
232
387
  const createClassGroupUtils = (config) => {
233
388
  const classMap = createClassMap(config);
234
389
  const {
@@ -236,103 +391,134 @@ const createClassGroupUtils = (config) => {
236
391
  conflictingClassGroupModifiers
237
392
  } = config;
238
393
  const getClassGroupId = (className) => {
239
- const classParts = className.split(CLASS_PART_SEPARATOR);
240
- if (classParts[0] === "" && classParts.length !== 1) {
241
- classParts.shift();
394
+ if (className.startsWith("[") && className.endsWith("]")) {
395
+ return getGroupIdForArbitraryProperty(className);
242
396
  }
243
- return getGroupRecursive(classParts, classMap) || getGroupIdForArbitraryProperty(className);
397
+ const classParts = className.split(CLASS_PART_SEPARATOR);
398
+ const startIndex = classParts[0] === "" && classParts.length > 1 ? 1 : 0;
399
+ return getGroupRecursive(classParts, startIndex, classMap);
244
400
  };
245
401
  const getConflictingClassGroupIds = (classGroupId, hasPostfixModifier) => {
246
- const conflicts = conflictingClassGroups[classGroupId] || [];
247
- if (hasPostfixModifier && conflictingClassGroupModifiers[classGroupId]) {
248
- return [...conflicts, ...conflictingClassGroupModifiers[classGroupId]];
402
+ if (hasPostfixModifier) {
403
+ const modifierConflicts = conflictingClassGroupModifiers[classGroupId];
404
+ const baseConflicts = conflictingClassGroups[classGroupId];
405
+ if (modifierConflicts) {
406
+ if (baseConflicts) {
407
+ return concatArrays(baseConflicts, modifierConflicts);
408
+ }
409
+ return modifierConflicts;
410
+ }
411
+ return baseConflicts || EMPTY_CONFLICTS;
249
412
  }
250
- return conflicts;
413
+ return conflictingClassGroups[classGroupId] || EMPTY_CONFLICTS;
251
414
  };
252
415
  return {
253
416
  getClassGroupId,
254
417
  getConflictingClassGroupIds
255
418
  };
256
419
  };
257
- const getGroupRecursive = (classParts, classPartObject) => {
258
- if (classParts.length === 0) {
420
+ const getGroupRecursive = (classParts, startIndex, classPartObject) => {
421
+ const classPathsLength = classParts.length - startIndex;
422
+ if (classPathsLength === 0) {
259
423
  return classPartObject.classGroupId;
260
424
  }
261
- const currentClassPart = classParts[0];
425
+ const currentClassPart = classParts[startIndex];
262
426
  const nextClassPartObject = classPartObject.nextPart.get(currentClassPart);
263
- const classGroupFromNextClassPart = nextClassPartObject ? getGroupRecursive(classParts.slice(1), nextClassPartObject) : void 0;
264
- if (classGroupFromNextClassPart) {
265
- return classGroupFromNextClassPart;
427
+ if (nextClassPartObject) {
428
+ const result = getGroupRecursive(classParts, startIndex + 1, nextClassPartObject);
429
+ if (result) return result;
266
430
  }
267
- if (classPartObject.validators.length === 0) {
431
+ const validators = classPartObject.validators;
432
+ if (validators === null) {
268
433
  return void 0;
269
434
  }
270
- const classRest = classParts.join(CLASS_PART_SEPARATOR);
271
- return classPartObject.validators.find(({
272
- validator
273
- }) => validator(classRest))?.classGroupId;
274
- };
275
- const arbitraryPropertyRegex = /^\[(.+)\]$/;
276
- const getGroupIdForArbitraryProperty = (className) => {
277
- if (arbitraryPropertyRegex.test(className)) {
278
- const arbitraryPropertyClassName = arbitraryPropertyRegex.exec(className)[1];
279
- const property = arbitraryPropertyClassName?.substring(0, arbitraryPropertyClassName.indexOf(":"));
280
- if (property) {
281
- return "arbitrary.." + property;
435
+ const classRest = startIndex === 0 ? classParts.join(CLASS_PART_SEPARATOR) : classParts.slice(startIndex).join(CLASS_PART_SEPARATOR);
436
+ const validatorsLength = validators.length;
437
+ for (let i = 0; i < validatorsLength; i++) {
438
+ const validatorObj = validators[i];
439
+ if (validatorObj.validator(classRest)) {
440
+ return validatorObj.classGroupId;
282
441
  }
283
442
  }
443
+ return void 0;
284
444
  };
445
+ const getGroupIdForArbitraryProperty = (className) => className.slice(1, -1).indexOf(":") === -1 ? void 0 : (() => {
446
+ const content = className.slice(1, -1);
447
+ const colonIndex = content.indexOf(":");
448
+ const property = content.slice(0, colonIndex);
449
+ return property ? ARBITRARY_PROPERTY_PREFIX + property : void 0;
450
+ })();
285
451
  const createClassMap = (config) => {
286
452
  const {
287
453
  theme,
288
454
  classGroups
289
455
  } = config;
290
- const classMap = {
291
- nextPart: /* @__PURE__ */ new Map(),
292
- validators: []
293
- };
456
+ return processClassGroups(classGroups, theme);
457
+ };
458
+ const processClassGroups = (classGroups, theme) => {
459
+ const classMap = createClassPartObject();
294
460
  for (const classGroupId in classGroups) {
295
- processClassesRecursively(classGroups[classGroupId], classMap, classGroupId, theme);
461
+ const group = classGroups[classGroupId];
462
+ processClassesRecursively(group, classMap, classGroupId, theme);
296
463
  }
297
464
  return classMap;
298
465
  };
299
466
  const processClassesRecursively = (classGroup, classPartObject, classGroupId, theme) => {
300
- classGroup.forEach((classDefinition) => {
301
- if (typeof classDefinition === "string") {
302
- const classPartObjectToEdit = classDefinition === "" ? classPartObject : getPart(classPartObject, classDefinition);
303
- classPartObjectToEdit.classGroupId = classGroupId;
304
- return;
305
- }
306
- if (typeof classDefinition === "function") {
307
- if (isThemeGetter(classDefinition)) {
308
- processClassesRecursively(classDefinition(theme), classPartObject, classGroupId, theme);
309
- return;
310
- }
311
- classPartObject.validators.push({
312
- validator: classDefinition,
313
- classGroupId
314
- });
315
- return;
316
- }
317
- Object.entries(classDefinition).forEach(([key, classGroup2]) => {
318
- processClassesRecursively(classGroup2, getPart(classPartObject, key), classGroupId, theme);
319
- });
320
- });
467
+ const len = classGroup.length;
468
+ for (let i = 0; i < len; i++) {
469
+ const classDefinition = classGroup[i];
470
+ processClassDefinition(classDefinition, classPartObject, classGroupId, theme);
471
+ }
472
+ };
473
+ const processClassDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
474
+ if (typeof classDefinition === "string") {
475
+ processStringDefinition(classDefinition, classPartObject, classGroupId);
476
+ return;
477
+ }
478
+ if (typeof classDefinition === "function") {
479
+ processFunctionDefinition(classDefinition, classPartObject, classGroupId, theme);
480
+ return;
481
+ }
482
+ processObjectDefinition(classDefinition, classPartObject, classGroupId, theme);
483
+ };
484
+ const processStringDefinition = (classDefinition, classPartObject, classGroupId) => {
485
+ const classPartObjectToEdit = classDefinition === "" ? classPartObject : getPart(classPartObject, classDefinition);
486
+ classPartObjectToEdit.classGroupId = classGroupId;
487
+ };
488
+ const processFunctionDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
489
+ if (isThemeGetter(classDefinition)) {
490
+ processClassesRecursively(classDefinition(theme), classPartObject, classGroupId, theme);
491
+ return;
492
+ }
493
+ if (classPartObject.validators === null) {
494
+ classPartObject.validators = [];
495
+ }
496
+ classPartObject.validators.push(createClassValidatorObject(classGroupId, classDefinition));
497
+ };
498
+ const processObjectDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
499
+ const entries = Object.entries(classDefinition);
500
+ const len = entries.length;
501
+ for (let i = 0; i < len; i++) {
502
+ const [key, value] = entries[i];
503
+ processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
504
+ }
321
505
  };
322
506
  const getPart = (classPartObject, path) => {
323
- let currentClassPartObject = classPartObject;
324
- path.split(CLASS_PART_SEPARATOR).forEach((pathPart) => {
325
- if (!currentClassPartObject.nextPart.has(pathPart)) {
326
- currentClassPartObject.nextPart.set(pathPart, {
327
- nextPart: /* @__PURE__ */ new Map(),
328
- validators: []
329
- });
507
+ let current = classPartObject;
508
+ const parts = path.split(CLASS_PART_SEPARATOR);
509
+ const len = parts.length;
510
+ for (let i = 0; i < len; i++) {
511
+ const part = parts[i];
512
+ let next = current.nextPart.get(part);
513
+ if (!next) {
514
+ next = createClassPartObject();
515
+ current.nextPart.set(part, next);
330
516
  }
331
- currentClassPartObject = currentClassPartObject.nextPart.get(pathPart);
332
- });
333
- return currentClassPartObject;
517
+ current = next;
518
+ }
519
+ return current;
334
520
  };
335
- const isThemeGetter = (func) => func.isThemeGetter;
521
+ const isThemeGetter = (func) => "isThemeGetter" in func && func.isThemeGetter === true;
336
522
  const createLruCache = (maxCacheSize) => {
337
523
  if (maxCacheSize < 1) {
338
524
  return {
@@ -342,31 +528,31 @@ const createLruCache = (maxCacheSize) => {
342
528
  };
343
529
  }
344
530
  let cacheSize = 0;
345
- let cache = /* @__PURE__ */ new Map();
346
- let previousCache = /* @__PURE__ */ new Map();
531
+ let cache = /* @__PURE__ */ Object.create(null);
532
+ let previousCache = /* @__PURE__ */ Object.create(null);
347
533
  const update = (key, value) => {
348
- cache.set(key, value);
534
+ cache[key] = value;
349
535
  cacheSize++;
350
536
  if (cacheSize > maxCacheSize) {
351
537
  cacheSize = 0;
352
538
  previousCache = cache;
353
- cache = /* @__PURE__ */ new Map();
539
+ cache = /* @__PURE__ */ Object.create(null);
354
540
  }
355
541
  };
356
542
  return {
357
543
  get(key) {
358
- let value = cache.get(key);
544
+ let value = cache[key];
359
545
  if (value !== void 0) {
360
546
  return value;
361
547
  }
362
- if ((value = previousCache.get(key)) !== void 0) {
548
+ if ((value = previousCache[key]) !== void 0) {
363
549
  update(key, value);
364
550
  return value;
365
551
  }
366
552
  },
367
553
  set(key, value) {
368
- if (cache.has(key)) {
369
- cache.set(key, value);
554
+ if (key in cache) {
555
+ cache[key] = value;
370
556
  } else {
371
557
  update(key, value);
372
558
  }
@@ -375,7 +561,14 @@ const createLruCache = (maxCacheSize) => {
375
561
  };
376
562
  const IMPORTANT_MODIFIER = "!";
377
563
  const MODIFIER_SEPARATOR = ":";
378
- const MODIFIER_SEPARATOR_LENGTH = MODIFIER_SEPARATOR.length;
564
+ const EMPTY_MODIFIERS = [];
565
+ const createResultObject = (modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition, isExternal) => ({
566
+ modifiers,
567
+ hasImportantModifier,
568
+ baseClassName,
569
+ maybePostfixModifierPosition,
570
+ isExternal
571
+ });
379
572
  const createParseClassName = (config) => {
380
573
  const {
381
574
  prefix,
@@ -387,12 +580,13 @@ const createParseClassName = (config) => {
387
580
  let parenDepth = 0;
388
581
  let modifierStart = 0;
389
582
  let postfixModifierPosition;
390
- for (let index = 0; index < className.length; index++) {
391
- let currentCharacter = className[index];
583
+ const len = className.length;
584
+ for (let index = 0; index < len; index++) {
585
+ const currentCharacter = className[index];
392
586
  if (bracketDepth === 0 && parenDepth === 0) {
393
587
  if (currentCharacter === MODIFIER_SEPARATOR) {
394
588
  modifiers.push(className.slice(modifierStart, index));
395
- modifierStart = index + MODIFIER_SEPARATOR_LENGTH;
589
+ modifierStart = index + 1;
396
590
  continue;
397
591
  }
398
592
  if (currentCharacter === "/") {
@@ -400,37 +594,34 @@ const createParseClassName = (config) => {
400
594
  continue;
401
595
  }
402
596
  }
403
- if (currentCharacter === "[") {
404
- bracketDepth++;
405
- } else if (currentCharacter === "]") {
406
- bracketDepth--;
407
- } else if (currentCharacter === "(") {
408
- parenDepth++;
409
- } else if (currentCharacter === ")") {
410
- parenDepth--;
411
- }
597
+ if (currentCharacter === "[") bracketDepth++;
598
+ else if (currentCharacter === "]") bracketDepth--;
599
+ else if (currentCharacter === "(") parenDepth++;
600
+ else if (currentCharacter === ")") parenDepth--;
601
+ }
602
+ const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.slice(modifierStart);
603
+ let baseClassName = baseClassNameWithImportantModifier;
604
+ let hasImportantModifier = false;
605
+ if (baseClassNameWithImportantModifier.endsWith(IMPORTANT_MODIFIER)) {
606
+ baseClassName = baseClassNameWithImportantModifier.slice(0, -1);
607
+ hasImportantModifier = true;
608
+ } else if (
609
+ /**
610
+ * In Tailwind CSS v3 the important modifier was at the start of the base class name. This is still supported for legacy reasons.
611
+ * @see https://github.com/dcastil/tailwind-merge/issues/513#issuecomment-2614029864
612
+ */
613
+ baseClassNameWithImportantModifier.startsWith(IMPORTANT_MODIFIER)
614
+ ) {
615
+ baseClassName = baseClassNameWithImportantModifier.slice(1);
616
+ hasImportantModifier = true;
412
617
  }
413
- const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.substring(modifierStart);
414
- const baseClassName = stripImportantModifier(baseClassNameWithImportantModifier);
415
- const hasImportantModifier = baseClassName !== baseClassNameWithImportantModifier;
416
618
  const maybePostfixModifierPosition = postfixModifierPosition && postfixModifierPosition > modifierStart ? postfixModifierPosition - modifierStart : void 0;
417
- return {
418
- modifiers,
419
- hasImportantModifier,
420
- baseClassName,
421
- maybePostfixModifierPosition
422
- };
619
+ return createResultObject(modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition);
423
620
  };
424
621
  if (prefix) {
425
622
  const fullPrefix = prefix + MODIFIER_SEPARATOR;
426
623
  const parseClassNameOriginal = parseClassName;
427
- parseClassName = (className) => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.substring(fullPrefix.length)) : {
428
- isExternal: true,
429
- modifiers: [],
430
- hasImportantModifier: false,
431
- baseClassName: className,
432
- maybePostfixModifierPosition: void 0
433
- };
624
+ parseClassName = (className) => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.slice(fullPrefix.length)) : createResultObject(EMPTY_MODIFIERS, false, className, void 0, true);
434
625
  }
435
626
  if (experimentalParseClassName) {
436
627
  const parseClassNameOriginal = parseClassName;
@@ -441,36 +632,35 @@ const createParseClassName = (config) => {
441
632
  }
442
633
  return parseClassName;
443
634
  };
444
- const stripImportantModifier = (baseClassName) => {
445
- if (baseClassName.endsWith(IMPORTANT_MODIFIER)) {
446
- return baseClassName.substring(0, baseClassName.length - 1);
447
- }
448
- if (baseClassName.startsWith(IMPORTANT_MODIFIER)) {
449
- return baseClassName.substring(1);
450
- }
451
- return baseClassName;
452
- };
453
635
  const createSortModifiers = (config) => {
454
- const orderSensitiveModifiers = Object.fromEntries(config.orderSensitiveModifiers.map((modifier) => [modifier, true]));
455
- const sortModifiers = (modifiers) => {
456
- if (modifiers.length <= 1) {
457
- return modifiers;
458
- }
459
- const sortedModifiers = [];
460
- let unsortedModifiers = [];
461
- modifiers.forEach((modifier) => {
462
- const isPositionSensitive = modifier[0] === "[" || orderSensitiveModifiers[modifier];
463
- if (isPositionSensitive) {
464
- sortedModifiers.push(...unsortedModifiers.sort(), modifier);
465
- unsortedModifiers = [];
636
+ const modifierWeights = /* @__PURE__ */ new Map();
637
+ config.orderSensitiveModifiers.forEach((mod, index) => {
638
+ modifierWeights.set(mod, 1e6 + index);
639
+ });
640
+ return (modifiers) => {
641
+ const result = [];
642
+ let currentSegment = [];
643
+ for (let i = 0; i < modifiers.length; i++) {
644
+ const modifier = modifiers[i];
645
+ const isArbitrary = modifier[0] === "[";
646
+ const isOrderSensitive = modifierWeights.has(modifier);
647
+ if (isArbitrary || isOrderSensitive) {
648
+ if (currentSegment.length > 0) {
649
+ currentSegment.sort();
650
+ result.push(...currentSegment);
651
+ currentSegment = [];
652
+ }
653
+ result.push(modifier);
466
654
  } else {
467
- unsortedModifiers.push(modifier);
655
+ currentSegment.push(modifier);
468
656
  }
469
- });
470
- sortedModifiers.push(...unsortedModifiers.sort());
471
- return sortedModifiers;
657
+ }
658
+ if (currentSegment.length > 0) {
659
+ currentSegment.sort();
660
+ result.push(...currentSegment);
661
+ }
662
+ return result;
472
663
  };
473
- return sortModifiers;
474
664
  };
475
665
  const createConfigUtils = (config) => ({
476
666
  cache: createLruCache(config.cacheSize),
@@ -516,29 +706,29 @@ const mergeClassList = (classList, configUtils) => {
516
706
  }
517
707
  hasPostfixModifier = false;
518
708
  }
519
- const variantModifier = sortModifiers(modifiers).join(":");
709
+ const variantModifier = modifiers.length === 0 ? "" : modifiers.length === 1 ? modifiers[0] : sortModifiers(modifiers).join(":");
520
710
  const modifierId = hasImportantModifier ? variantModifier + IMPORTANT_MODIFIER : variantModifier;
521
711
  const classId = modifierId + classGroupId;
522
- if (classGroupsInConflict.includes(classId)) {
712
+ if (classGroupsInConflict.indexOf(classId) > -1) {
523
713
  continue;
524
714
  }
525
715
  classGroupsInConflict.push(classId);
526
716
  const conflictGroups = getConflictingClassGroupIds(classGroupId, hasPostfixModifier);
527
- for (let i2 = 0; i2 < conflictGroups.length; ++i2) {
528
- const group = conflictGroups[i2];
717
+ for (let i = 0; i < conflictGroups.length; ++i) {
718
+ const group = conflictGroups[i];
529
719
  classGroupsInConflict.push(modifierId + group);
530
720
  }
531
721
  result = originalClassName + (result.length > 0 ? " " + result : result);
532
722
  }
533
723
  return result;
534
724
  };
535
- function twJoin() {
725
+ const twJoin = (...classLists) => {
536
726
  let index = 0;
537
727
  let argument;
538
728
  let resolvedValue;
539
729
  let string = "";
540
- while (index < arguments.length) {
541
- if (argument = arguments[index++]) {
730
+ while (index < classLists.length) {
731
+ if (argument = classLists[index++]) {
542
732
  if (resolvedValue = toValue(argument)) {
543
733
  string && (string += " ");
544
734
  string += resolvedValue;
@@ -546,16 +736,16 @@ function twJoin() {
546
736
  }
547
737
  }
548
738
  return string;
549
- }
739
+ };
550
740
  const toValue = (mix) => {
551
741
  if (typeof mix === "string") {
552
742
  return mix;
553
743
  }
554
744
  let resolvedValue;
555
745
  let string = "";
556
- for (let k2 = 0; k2 < mix.length; k2++) {
557
- if (mix[k2]) {
558
- if (resolvedValue = toValue(mix[k2])) {
746
+ for (let k = 0; k < mix.length; k++) {
747
+ if (mix[k]) {
748
+ if (resolvedValue = toValue(mix[k])) {
559
749
  string && (string += " ");
560
750
  string += resolvedValue;
561
751
  }
@@ -563,20 +753,20 @@ const toValue = (mix) => {
563
753
  }
564
754
  return string;
565
755
  };
566
- function createTailwindMerge(createConfigFirst, ...createConfigRest) {
756
+ const createTailwindMerge = (createConfigFirst, ...createConfigRest) => {
567
757
  let configUtils;
568
758
  let cacheGet;
569
759
  let cacheSet;
570
- let functionToCall = initTailwindMerge;
571
- function initTailwindMerge(classList) {
760
+ let functionToCall;
761
+ const initTailwindMerge = (classList) => {
572
762
  const config = createConfigRest.reduce((previousConfig, createConfigCurrent) => createConfigCurrent(previousConfig), createConfigFirst());
573
763
  configUtils = createConfigUtils(config);
574
764
  cacheGet = configUtils.cache.get;
575
765
  cacheSet = configUtils.cache.set;
576
766
  functionToCall = tailwindMerge;
577
767
  return tailwindMerge(classList);
578
- }
579
- function tailwindMerge(classList) {
768
+ };
769
+ const tailwindMerge = (classList) => {
580
770
  const cachedResult = cacheGet(classList);
581
771
  if (cachedResult) {
582
772
  return cachedResult;
@@ -584,13 +774,13 @@ function createTailwindMerge(createConfigFirst, ...createConfigRest) {
584
774
  const result = mergeClassList(classList, configUtils);
585
775
  cacheSet(classList, result);
586
776
  return result;
587
- }
588
- return function callTailwindMerge() {
589
- return functionToCall(twJoin.apply(null, arguments));
590
777
  };
591
- }
778
+ functionToCall = initTailwindMerge;
779
+ return (...args) => functionToCall(twJoin(...args));
780
+ };
781
+ const fallbackThemeArr = [];
592
782
  const fromTheme = (key) => {
593
- const themeGetter = (theme) => theme[key] || [];
783
+ const themeGetter = (theme) => theme[key] || fallbackThemeArr;
594
784
  themeGetter.isThemeGetter = true;
595
785
  return themeGetter;
596
786
  };
@@ -3227,13 +3417,37 @@ const mergeArrayProperties = (baseObject, mergeObject, key) => {
3227
3417
  };
3228
3418
  const extendTailwindMerge = (configExtension, ...createConfig) => typeof configExtension === "function" ? createTailwindMerge(getDefaultConfig, configExtension, ...createConfig) : createTailwindMerge(() => mergeConfigs(getDefaultConfig(), configExtension), ...createConfig);
3229
3419
  const twMerge = /* @__PURE__ */ createTailwindMerge(getDefaultConfig);
3230
- var f = (e) => x(e) ? twMerge : extendTailwindMerge({ ...e, extend: { theme: e.theme, classGroups: e.classGroups, conflictingClassGroupModifiers: e.conflictingClassGroupModifiers, conflictingClassGroups: e.conflictingClassGroups, ...e.extend } }), i = (...e) => (a2) => {
3231
- let t = u(e);
3232
- return !t || !a2.twMerge ? t : ((!S.cachedTwMerge || S.didTwMergeConfigChange) && (S.didTwMergeConfigChange = false, S.cachedTwMerge = f(S.cachedTwMergeConfig)), S.cachedTwMerge(t) || void 0);
3420
+ var createTwMerge = (cachedTwMergeConfig) => {
3421
+ return isEmptyObject(cachedTwMergeConfig) ? twMerge : extendTailwindMerge({
3422
+ ...cachedTwMergeConfig,
3423
+ extend: {
3424
+ theme: cachedTwMergeConfig.theme,
3425
+ classGroups: cachedTwMergeConfig.classGroups,
3426
+ conflictingClassGroupModifiers: cachedTwMergeConfig.conflictingClassGroupModifiers,
3427
+ conflictingClassGroups: cachedTwMergeConfig.conflictingClassGroups,
3428
+ ...cachedTwMergeConfig.extend
3429
+ }
3430
+ });
3431
+ };
3432
+ var executeMerge = (classnames, config) => {
3433
+ const base = cx(classnames);
3434
+ if (!base || !(config?.twMerge ?? true)) return base;
3435
+ if (!state.cachedTwMerge || state.didTwMergeConfigChange) {
3436
+ state.didTwMergeConfigChange = false;
3437
+ state.cachedTwMerge = createTwMerge(state.cachedTwMergeConfig);
3438
+ }
3439
+ return state.cachedTwMerge(base) || void 0;
3440
+ };
3441
+ var cn = (...classnames) => {
3442
+ return executeMerge(classnames, {});
3443
+ };
3444
+ var cnMerge = (...classnames) => {
3445
+ return (config) => executeMerge(classnames, config);
3233
3446
  };
3234
- var { createTV: C, tv: T } = le(i);
3235
- exports.C = C;
3236
- exports.Q = Q;
3237
- exports.T = T;
3238
- exports.i = i;
3239
- exports.u = u;
3447
+ var { createTV, tv } = getTailwindVariants(cnMerge);
3448
+ exports.cn = cn;
3449
+ exports.cnMerge = cnMerge;
3450
+ exports.createTV = createTV;
3451
+ exports.cx = cx;
3452
+ exports.defaultConfig = defaultConfig;
3453
+ exports.tv = tv;