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