@bamboocss/shared 1.11.1 → 1.11.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.
package/dist/index.mjs CHANGED
@@ -1,793 +1,440 @@
1
- // src/arbitrary-value.ts
2
- var getArbitraryValue = (_value) => {
3
- if (!_value || typeof _value !== "string") return _value;
4
- const value = _value.trim();
5
- if (value[0] === "[" && value[value.length - 1] === "]") {
6
- const innerValue = value.slice(1, -1);
7
- let bracketCount = 0;
8
- for (let i = 0; i < innerValue.length; i++) {
9
- if (innerValue[i] === "[") {
10
- bracketCount++;
11
- } else if (innerValue[i] === "]") {
12
- if (bracketCount === 0) {
13
- return value;
14
- }
15
- bracketCount--;
16
- }
17
- }
18
- if (bracketCount === 0) {
19
- return innerValue.trim();
20
- }
21
- }
22
- return value;
1
+ import { A as isObjectOrArray, C as filterBaseConditions, D as isBoolean, E as memo, M as isSymbol, O as isFunction, S as toHash, T as compact, _ as mergeProps, a as getPatternStyles, b as withoutImportant, c as isCssUnit, d as createCss, f as createMergeCss, g as walkObject, h as mapObject, i as getSlotRecipes, j as isString, k as isObject, l as isCssFunction, m as toResponsiveObject, n as splitProps, o as patternFns, p as normalizeStyleObject, r as getSlotCompoundVariant, s as isCssVar, t as uniq, u as hypenateProperty, v as isImportant, w as isBaseCondition, x as withoutSpace, y as markImportant } from "./uniq-DRfJ796t.mjs";
2
+ import { astish } from "./astish.mjs";
3
+ //#region src/arbitrary-value.ts
4
+ const getArbitraryValue = (_value) => {
5
+ if (!_value || typeof _value !== "string") return _value;
6
+ const value = _value.trim();
7
+ if (value[0] === "[" && value[value.length - 1] === "]") {
8
+ const innerValue = value.slice(1, -1);
9
+ let bracketCount = 0;
10
+ for (let i = 0; i < innerValue.length; i++) if (innerValue[i] === "[") bracketCount++;
11
+ else if (innerValue[i] === "]") {
12
+ if (bracketCount === 0) return value;
13
+ bracketCount--;
14
+ }
15
+ if (bracketCount === 0) return innerValue.trim();
16
+ }
17
+ return value;
23
18
  };
24
-
25
- // src/assert.ts
26
- var isString = (v) => typeof v === "string";
27
- var isBoolean = (v) => typeof v === "boolean";
28
- var isFunction = (v) => typeof v === "function";
29
- function isObject(value) {
30
- return typeof value === "object" && value != null && !Array.isArray(value);
31
- }
32
- var isSymbol = (v) => typeof v === "symbol";
33
- var isObjectOrArray = (obj) => typeof obj === "object" && obj !== null;
34
-
35
- // src/assign.ts
19
+ //#endregion
20
+ //#region src/assign.ts
36
21
  function assign(target, ...sources) {
37
- for (const source of sources) {
38
- for (const key in source) {
39
- if (!target?.hasOwnProperty?.(key)) {
40
- target[key] = source[key];
41
- }
42
- }
43
- }
44
- return target;
22
+ for (const source of sources) for (const key in source) if (!target?.hasOwnProperty?.(key)) target[key] = source[key];
23
+ return target;
45
24
  }
46
-
47
- // src/astish.ts
48
- var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
49
- var ruleClean = /\/\*[^]*?\*\/| +/g;
50
- var ruleNewline = /\n+/g;
51
- var empty = " ";
52
- var astish = (val, tree = [{}]) => {
53
- if (!val) return tree[0];
54
- let block, left;
55
- while (block = newRule.exec(val.replace(ruleClean, ""))) {
56
- if (block[4]) tree.shift();
57
- else if (block[3]) {
58
- left = block[3].replace(ruleNewline, empty).trim();
59
- if (!left.includes("&") && !left.startsWith("@")) left = "& " + left;
60
- tree.unshift(tree[0][left] = tree[0][left] || {});
61
- } else tree[0][block[1]] = block[2].replace(ruleNewline, empty).trim();
62
- }
63
- return tree[0];
64
- };
65
-
66
- // src/cache-map.ts
25
+ //#endregion
26
+ //#region src/cache-map.ts
67
27
  var CacheMap = class {
68
- cache;
69
- keysInUse;
70
- maxCacheSize;
71
- constructor(maxCacheSize = 1e3) {
72
- this.maxCacheSize = maxCacheSize;
73
- this.cache = /* @__PURE__ */ new Map();
74
- this.keysInUse = [];
75
- }
76
- get(key) {
77
- if (!this.cache.has(key)) {
78
- return void 0;
79
- }
80
- this.updateKeyUsage(key);
81
- return this.cache.get(key);
82
- }
83
- set(key, value) {
84
- if (!this.cache.has(key) && this.cache.size === this.maxCacheSize) {
85
- this.evictLeastRecentlyUsed();
86
- }
87
- this.cache.set(key, value);
88
- this.updateKeyUsage(key);
89
- return this;
90
- }
91
- delete(key) {
92
- const result = this.cache.delete(key);
93
- if (result) {
94
- const index = this.keysInUse.indexOf(key);
95
- if (index !== -1) {
96
- this.keysInUse.splice(index, 1);
97
- }
98
- }
99
- return result;
100
- }
101
- updateKeyUsage(key) {
102
- const index = this.keysInUse.indexOf(key);
103
- if (index !== -1) {
104
- this.keysInUse.splice(index, 1);
105
- }
106
- this.keysInUse.push(key);
107
- }
108
- evictLeastRecentlyUsed() {
109
- const keyToEvict = this.keysInUse.shift();
110
- if (keyToEvict !== void 0) {
111
- this.cache.delete(keyToEvict);
112
- }
113
- }
114
- clear() {
115
- this.cache.clear();
116
- this.keysInUse = [];
117
- }
118
- has(key) {
119
- return this.cache.has(key);
120
- }
121
- get size() {
122
- return this.cache.size;
123
- }
124
- forEach(callback2, thisArg) {
125
- this.cache.forEach(callback2, thisArg);
126
- }
127
- keys() {
128
- return this.cache.keys();
129
- }
130
- values() {
131
- return this.cache.values();
132
- }
133
- entries() {
134
- return this.cache.entries();
135
- }
136
- getOrInsert(key, defaultValue) {
137
- if (this.cache.has(key)) {
138
- this.updateKeyUsage(key);
139
- return this.cache.get(key);
140
- }
141
- this.set(key, defaultValue);
142
- return defaultValue;
143
- }
144
- getOrInsertComputed(key, callback2) {
145
- if (this.cache.has(key)) {
146
- this.updateKeyUsage(key);
147
- return this.cache.get(key);
148
- }
149
- const value = callback2(key);
150
- this.set(key, value);
151
- return value;
152
- }
153
- [Symbol.iterator]() {
154
- return this.cache[Symbol.iterator]();
155
- }
156
- [Symbol.toStringTag] = "CacheMap";
157
- toJSON = () => {
158
- return this.cache;
159
- };
28
+ cache;
29
+ keysInUse;
30
+ maxCacheSize;
31
+ constructor(maxCacheSize = 1e3) {
32
+ this.maxCacheSize = maxCacheSize;
33
+ this.cache = /* @__PURE__ */ new Map();
34
+ this.keysInUse = [];
35
+ }
36
+ get(key) {
37
+ if (!this.cache.has(key)) return;
38
+ this.updateKeyUsage(key);
39
+ return this.cache.get(key);
40
+ }
41
+ set(key, value) {
42
+ if (!this.cache.has(key) && this.cache.size === this.maxCacheSize) this.evictLeastRecentlyUsed();
43
+ this.cache.set(key, value);
44
+ this.updateKeyUsage(key);
45
+ return this;
46
+ }
47
+ delete(key) {
48
+ const result = this.cache.delete(key);
49
+ if (result) {
50
+ const index = this.keysInUse.indexOf(key);
51
+ if (index !== -1) this.keysInUse.splice(index, 1);
52
+ }
53
+ return result;
54
+ }
55
+ updateKeyUsage(key) {
56
+ const index = this.keysInUse.indexOf(key);
57
+ if (index !== -1) this.keysInUse.splice(index, 1);
58
+ this.keysInUse.push(key);
59
+ }
60
+ evictLeastRecentlyUsed() {
61
+ const keyToEvict = this.keysInUse.shift();
62
+ if (keyToEvict !== void 0) this.cache.delete(keyToEvict);
63
+ }
64
+ clear() {
65
+ this.cache.clear();
66
+ this.keysInUse = [];
67
+ }
68
+ has(key) {
69
+ return this.cache.has(key);
70
+ }
71
+ get size() {
72
+ return this.cache.size;
73
+ }
74
+ forEach(callback, thisArg) {
75
+ this.cache.forEach(callback, thisArg);
76
+ }
77
+ keys() {
78
+ return this.cache.keys();
79
+ }
80
+ values() {
81
+ return this.cache.values();
82
+ }
83
+ entries() {
84
+ return this.cache.entries();
85
+ }
86
+ getOrInsert(key, defaultValue) {
87
+ if (this.cache.has(key)) {
88
+ this.updateKeyUsage(key);
89
+ return this.cache.get(key);
90
+ }
91
+ this.set(key, defaultValue);
92
+ return defaultValue;
93
+ }
94
+ getOrInsertComputed(key, callback) {
95
+ if (this.cache.has(key)) {
96
+ this.updateKeyUsage(key);
97
+ return this.cache.get(key);
98
+ }
99
+ const value = callback(key);
100
+ this.set(key, value);
101
+ return value;
102
+ }
103
+ [Symbol.iterator]() {
104
+ return this.cache[Symbol.iterator]();
105
+ }
106
+ [Symbol.toStringTag] = "CacheMap";
107
+ toJSON = () => {
108
+ return this.cache;
109
+ };
160
110
  };
161
-
162
- // src/calc.ts
163
- function isCssVar(value) {
164
- return isObject(value) && "ref" in value;
111
+ //#endregion
112
+ //#region src/calc.ts
113
+ function isCssVar$1(value) {
114
+ return isObject(value) && "ref" in value;
165
115
  }
166
116
  function getRef(operand) {
167
- return isCssVar(operand) ? operand.ref : operand.toString();
168
- }
169
- var calcRegex = /calc/g;
170
- var toExpression = (operator, ...operands) => operands.map(getRef).join(` ${operator} `).replace(calcRegex, "");
171
- var multiply = (...operands) => `calc(${toExpression("*", ...operands)})`;
172
- var calc = {
173
- negate(x) {
174
- const value = getRef(x);
175
- if (value != null && !Number.isNaN(parseFloat(value))) {
176
- return String(value).startsWith("-") ? String(value).slice(1) : `-${value}`;
177
- }
178
- return multiply(value, -1);
179
- }
180
- };
181
-
182
- // src/memo.ts
183
- var memo = (fn) => {
184
- const cache = /* @__PURE__ */ new Map();
185
- const get = (...args) => {
186
- const key = JSON.stringify(args);
187
- if (cache.has(key)) {
188
- return cache.get(key);
189
- }
190
- const result = fn(...args);
191
- cache.set(key, result);
192
- return result;
193
- };
194
- return get;
195
- };
196
-
197
- // src/camelcase-property.ts
198
- var regex = /-(\w|$)/g;
199
- var callback = (_dashChar, char) => char.toUpperCase();
200
- var camelCaseProperty = memo((property) => {
201
- if (property.startsWith("--")) return property;
202
- let str = property.toLowerCase();
203
- str = str.startsWith("-ms-") ? str.substring(1) : str;
204
- return str.replace(regex, callback);
117
+ return isCssVar$1(operand) ? operand.ref : operand.toString();
118
+ }
119
+ const calcRegex = /calc/g;
120
+ const toExpression = (operator, ...operands) => operands.map(getRef).join(` ${operator} `).replace(calcRegex, "");
121
+ const multiply = (...operands) => `calc(${toExpression("*", ...operands)})`;
122
+ const calc = { negate(x) {
123
+ const value = getRef(x);
124
+ if (value != null && !Number.isNaN(parseFloat(value))) return String(value).startsWith("-") ? String(value).slice(1) : `-${value}`;
125
+ return multiply(value, -1);
126
+ } };
127
+ //#endregion
128
+ //#region src/camelcase-property.ts
129
+ const regex = /-(\w|$)/g;
130
+ const callback = (_dashChar, char) => char.toUpperCase();
131
+ const camelCaseProperty = memo((property) => {
132
+ if (property.startsWith("--")) return property;
133
+ let str = property.toLowerCase();
134
+ str = str.startsWith("-ms-") ? str.substring(1) : str;
135
+ return str.replace(regex, callback);
205
136
  });
206
-
207
- // src/capitalize.ts
208
- var capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
209
- var camelCaseRegex = /([a-z])([A-Z])/g;
210
- var dashCase = (s) => s.replace(camelCaseRegex, "$1-$2").toLowerCase();
211
- var uncapitalize = (s) => s.charAt(0).toLowerCase() + s.slice(1);
212
-
213
- // src/compact.ts
214
- function compact(value) {
215
- return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0));
216
- }
217
-
218
- // src/condition.ts
219
- var isBaseCondition = (v) => v === "base";
220
- function filterBaseConditions(c) {
221
- return c.slice().filter((v) => !isBaseCondition(v));
222
- }
223
-
224
- // src/hash.ts
225
- function toChar(code) {
226
- return String.fromCharCode(code + (code > 25 ? 39 : 97));
227
- }
228
- function toName(code) {
229
- let name = "";
230
- let x;
231
- for (x = Math.abs(code); x > 52; x = x / 52 | 0) name = toChar(x % 52) + name;
232
- return toChar(x % 52) + name;
233
- }
234
- function toPhash(h, x) {
235
- let i = x.length;
236
- while (i) h = h * 33 ^ x.charCodeAt(--i);
237
- return h;
238
- }
239
- function toHash(value) {
240
- return toName(toPhash(5381, value) >>> 0);
241
- }
242
-
243
- // src/important.ts
244
- var importantRegex = /\s*!(important)?/i;
245
- function isImportant(value) {
246
- return typeof value === "string" ? importantRegex.test(value) : false;
247
- }
248
- function withoutImportant(value) {
249
- return typeof value === "string" ? value.replace(importantRegex, "").trim() : value;
250
- }
251
- function withoutSpace(str) {
252
- return typeof str === "string" ? str.replaceAll(" ", "_") : str;
253
- }
254
- function markImportant(obj) {
255
- if (typeof obj !== "object" || obj === null) {
256
- return obj;
257
- }
258
- const result = Array.isArray(obj) ? [] : {};
259
- const stack = [{ obj, result }];
260
- while (stack.length > 0) {
261
- const { obj: obj2, result: result2 } = stack.pop();
262
- for (const [key, value] of Object.entries(obj2)) {
263
- if (typeof value === "string" || typeof value === "number") {
264
- result2[key] = `${value} !important`;
265
- } else if (typeof value === "object" && value !== null) {
266
- const next = Array.isArray(value) ? [] : {};
267
- result2[key] = next;
268
- stack.push({ obj: value, result: next });
269
- } else {
270
- result2[key] = value;
271
- }
272
- }
273
- }
274
- return result;
275
- }
276
-
277
- // src/merge-props.ts
278
- var MERGE_OMIT = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
279
- function mergeProps(...sources) {
280
- return sources.reduce((prev, obj) => {
281
- if (!obj) return prev;
282
- Object.keys(obj).forEach((key) => {
283
- if (MERGE_OMIT.has(key)) return;
284
- const prevValue = prev[key];
285
- const value = obj[key];
286
- if (isObject(prevValue) && isObject(value)) {
287
- prev[key] = mergeProps(prevValue, value);
288
- } else {
289
- prev[key] = value;
290
- }
291
- });
292
- return prev;
293
- }, {});
294
- }
295
-
296
- // src/walk-object.ts
297
- var isNotNullish = (element) => element != null;
298
- function walkObject(target, predicate, options = {}) {
299
- const { stop, getKey } = options;
300
- function inner(value, path = []) {
301
- if (isObjectOrArray(value)) {
302
- const result = {};
303
- for (const [prop, child] of Object.entries(value)) {
304
- const key = getKey?.(prop, child) ?? prop;
305
- const childPath = [...path, key];
306
- if (stop?.(value, childPath)) {
307
- return predicate(value, path);
308
- }
309
- const next = inner(child, childPath);
310
- if (isNotNullish(next)) {
311
- result[key] = next;
312
- }
313
- }
314
- return result;
315
- }
316
- return predicate(value, path);
317
- }
318
- return inner(target);
319
- }
320
- function mapObject(obj, fn) {
321
- if (Array.isArray(obj)) return obj.map((value) => fn(value));
322
- if (!isObject(obj)) return fn(obj);
323
- return walkObject(obj, (value) => fn(value));
324
- }
325
-
326
- // src/normalize-style-object.ts
327
- function toResponsiveObject(values, breakpoints) {
328
- return values.reduce(
329
- (acc, current, index) => {
330
- const key = breakpoints[index];
331
- if (current != null) {
332
- acc[key] = current;
333
- }
334
- return acc;
335
- },
336
- {}
337
- );
338
- }
339
- function normalizeStyleObject(styles, context, shorthand = true) {
340
- const { utility, conditions } = context;
341
- const { hasShorthand, resolveShorthand } = utility;
342
- return walkObject(
343
- styles,
344
- (value) => {
345
- return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;
346
- },
347
- {
348
- stop: (value) => Array.isArray(value),
349
- getKey: shorthand ? (prop) => hasShorthand ? resolveShorthand(prop) : prop : void 0
350
- }
351
- );
352
- }
353
-
354
- // src/classname.ts
355
- var fallbackCondition = {
356
- shift: (v) => v,
357
- finalize: (v) => v,
358
- breakpoints: { keys: [] }
359
- };
360
- var sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\n\s]+/g, " ") : value;
361
- var ENTRY_SEP = "]___[";
362
- var COND_SEP = "<___>";
363
- function createCss(context) {
364
- const { utility, hash, grouped, conditions: conds = fallbackCondition } = context;
365
- const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");
366
- const hashFn = (conditions, className) => {
367
- let result;
368
- if (hash) {
369
- const baseArray = [...conds.finalize(conditions), className];
370
- result = formatClassName(utility.toHash(baseArray, toHash));
371
- } else {
372
- const baseArray = [...conds.finalize(conditions), formatClassName(className)];
373
- result = baseArray.join(":");
374
- }
375
- return result;
376
- };
377
- if (grouped) {
378
- return memo(({ base, ...styles } = {}) => {
379
- const styleObject = Object.assign(styles, base);
380
- const normalizedObject = normalizeStyleObject(styleObject, context);
381
- const hashes = [];
382
- walkObject(normalizedObject, (value, paths) => {
383
- if (value == null) return;
384
- const [prop, ...allConditions] = conds.shift(paths);
385
- const conditions = filterBaseConditions(allConditions);
386
- const parts = [`${prop}${ENTRY_SEP}value:${value}`];
387
- if (conditions.length) {
388
- parts.push(`cond:${conditions.join(COND_SEP)}`);
389
- }
390
- hashes.push(parts.join(ENTRY_SEP));
391
- });
392
- if (hashes.length === 0) return "";
393
- hashes.sort();
394
- const groupId = hashes.join("|");
395
- const shortHash = utility.toHash(["grouped", groupId], toHash);
396
- return formatClassName(shortHash);
397
- });
398
- }
399
- return memo(({ base, ...styles } = {}) => {
400
- const styleObject = Object.assign(styles, base);
401
- const normalizedObject = normalizeStyleObject(styleObject, context);
402
- const classNames = /* @__PURE__ */ new Set();
403
- walkObject(normalizedObject, (value, paths) => {
404
- if (value == null) return;
405
- const important = isImportant(value);
406
- const [prop, ...allConditions] = conds.shift(paths);
407
- const conditions = filterBaseConditions(allConditions);
408
- const transformed = utility.transform(prop, withoutImportant(sanitize(value)));
409
- let className = hashFn(conditions, transformed.className);
410
- if (important) className = `${className}!`;
411
- classNames.add(className);
412
- });
413
- return Array.from(classNames).join(" ");
414
- });
415
- }
416
- function compactStyles(...styles) {
417
- return styles.flat().filter((style) => isObject(style) && Object.keys(compact(style)).length > 0);
418
- }
419
- function createMergeCss(context) {
420
- function resolve(styles) {
421
- const allStyles = compactStyles(...styles);
422
- if (allStyles.length === 1) return allStyles;
423
- return allStyles.map((style) => normalizeStyleObject(style, context));
424
- }
425
- function mergeCss(...styles) {
426
- return mergeProps(...resolve(styles));
427
- }
428
- function assignCss(...styles) {
429
- return Object.assign({}, ...resolve(styles));
430
- }
431
- return { mergeCss: memo(mergeCss), assignCss };
432
- }
433
-
434
- // src/css-var.ts
435
- var escRegex = /[^a-zA-Z0-9_\u0081-\uffff-]/g;
436
- function esc(string) {
437
- return `${string}`.replace(escRegex, (s) => `\\${s}`);
438
- }
439
- var dashCaseRegex = /[A-Z]/g;
440
- function dashCase2(string) {
441
- return string.replace(dashCaseRegex, (match) => `-${match.toLowerCase()}`);
137
+ //#endregion
138
+ //#region src/capitalize.ts
139
+ const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
140
+ const camelCaseRegex = /([a-z])([A-Z])/g;
141
+ const dashCase = (s) => s.replace(camelCaseRegex, "$1-$2").toLowerCase();
142
+ const uncapitalize = (s) => s.charAt(0).toLowerCase() + s.slice(1);
143
+ //#endregion
144
+ //#region src/css-var.ts
145
+ const escRegex = /[^a-zA-Z0-9_\u0081-\uffff-]/g;
146
+ function esc$1(string) {
147
+ return `${string}`.replace(escRegex, (s) => `\\${s}`);
148
+ }
149
+ const dashCaseRegex = /[A-Z]/g;
150
+ function dashCase$1(string) {
151
+ return string.replace(dashCaseRegex, (match) => `-${match.toLowerCase()}`);
442
152
  }
443
153
  function cssVar(name, options = {}) {
444
- const { fallback = "", prefix = "", hash } = options;
445
- const variable = hash ? ["-", prefix, toHash(name)].filter(Boolean).join("-") : dashCase2(["-", prefix, esc(name)].filter(Boolean).join("-"));
446
- const result = {
447
- var: variable,
448
- ref: `var(${variable}${fallback ? `, ${fallback}` : ""})`
449
- };
450
- return result;
451
- }
452
-
453
- // src/deep-set.ts
454
- var deepSet = (target, path, value) => {
455
- const isValueObject = isObject(value);
456
- if (!path.length && isValueObject) {
457
- return mergeProps(target, value);
458
- }
459
- let current = target;
460
- for (let i = 0; i < path.length; i++) {
461
- const key = path[i];
462
- current[key] ||= {};
463
- if (i === path.length - 1) {
464
- if (isValueObject && isObject(current[key])) {
465
- current[key] = mergeProps(current[key], value);
466
- } else {
467
- current[key] = value;
468
- }
469
- } else {
470
- current = current[key];
471
- }
472
- }
473
- return target;
154
+ const { fallback = "", prefix = "", hash } = options;
155
+ const variable = hash ? [
156
+ "-",
157
+ prefix,
158
+ toHash(name)
159
+ ].filter(Boolean).join("-") : dashCase$1([
160
+ "-",
161
+ prefix,
162
+ esc$1(name)
163
+ ].filter(Boolean).join("-"));
164
+ return {
165
+ var: variable,
166
+ ref: `var(${variable}${fallback ? `, ${fallback}` : ""})`
167
+ };
168
+ }
169
+ //#endregion
170
+ //#region src/deep-set.ts
171
+ const deepSet = (target, path, value) => {
172
+ const isValueObject = isObject(value);
173
+ if (!path.length && isValueObject) return mergeProps(target, value);
174
+ let current = target;
175
+ for (let i = 0; i < path.length; i++) {
176
+ const key = path[i];
177
+ current[key] ||= {};
178
+ if (i === path.length - 1) if (isValueObject && isObject(current[key])) current[key] = mergeProps(current[key], value);
179
+ else current[key] = value;
180
+ else current = current[key];
181
+ }
182
+ return target;
474
183
  };
475
-
476
- // src/entries.ts
477
- function fromEntries(entries2) {
478
- const result = {};
479
- entries2.forEach((kv) => {
480
- result[kv[0]] = kv[1];
481
- });
482
- return result;
184
+ //#endregion
185
+ //#region src/entries.ts
186
+ function fromEntries(entries) {
187
+ const result = {};
188
+ entries.forEach((kv) => {
189
+ result[kv[0]] = kv[1];
190
+ });
191
+ return result;
483
192
  }
484
193
  function entries(obj) {
485
- const result = [];
486
- for (const key in obj) {
487
- result.push([key, obj[key]]);
488
- }
489
- return result;
194
+ const result = [];
195
+ for (const key in obj) result.push([key, obj[key]]);
196
+ return result;
490
197
  }
491
198
  function mapEntries(obj, f) {
492
- const result = {};
493
- for (const key in obj) {
494
- const kv = f(key, obj[key]);
495
- result[kv[0]] = kv[1];
496
- }
497
- return result;
498
- }
499
-
500
- // src/error.ts
199
+ const result = {};
200
+ for (const key in obj) {
201
+ const kv = f(key, obj[key]);
202
+ result[kv[0]] = kv[1];
203
+ }
204
+ return result;
205
+ }
206
+ //#endregion
207
+ //#region src/error.ts
501
208
  var BambooError = class extends Error {
502
- code;
503
- hint;
504
- constructor(code, message, opts) {
505
- super(message, { cause: opts?.cause });
506
- this.code = `ERR_BAMBOO_${code}`;
507
- this.hint = opts?.hint;
508
- }
209
+ code;
210
+ hint;
211
+ constructor(code, message, opts) {
212
+ super(message, { cause: opts?.cause });
213
+ this.code = `ERR_BAMBOO_${code}`;
214
+ this.hint = opts?.hint;
215
+ }
509
216
  };
510
-
511
- // src/esc.ts
512
- var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|^-|[^\x80-\uFFFF\w-]/g;
513
- var fcssescape = function(ch, asCodePoint) {
514
- if (!asCodePoint) return "\\" + ch;
515
- if (ch === "\0") return "\uFFFD";
516
- if (ch === "-" && ch.length === 1) return "\\-";
517
- return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16);
217
+ //#endregion
218
+ //#region src/esc.ts
219
+ const rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|^-|[^\x80-\uFFFF\w-]/g;
220
+ const fcssescape = function(ch, asCodePoint) {
221
+ if (!asCodePoint) return "\\" + ch;
222
+ if (ch === "\0") return "";
223
+ if (ch === "-" && ch.length === 1) return "\\-";
224
+ return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16);
518
225
  };
519
- var esc2 = (sel) => {
520
- return (sel + "").replace(rcssescape, fcssescape);
226
+ const esc = (sel) => {
227
+ return (sel + "").replace(rcssescape, fcssescape);
521
228
  };
522
-
523
- // src/flatten.ts
229
+ //#endregion
230
+ //#region src/flatten.ts
524
231
  function filterDefault(path) {
525
- if (path[0] === "DEFAULT") return path;
526
- return path.filter((item) => item !== "DEFAULT");
232
+ if (path[0] === "DEFAULT") return path;
233
+ return path.filter((item) => item !== "DEFAULT");
527
234
  }
528
235
  function flatten(values, stop) {
529
- const result = {};
530
- walkObject(
531
- values,
532
- (token, paths) => {
533
- paths = filterDefault(paths);
534
- if (token) {
535
- result[paths.join(".")] = token.value;
536
- }
537
- },
538
- {
539
- stop: stop ?? ((v) => {
540
- return isObject(v) && "value" in v;
541
- })
542
- }
543
- );
544
- return result;
545
- }
546
-
547
- // src/get-or-create-set.ts
236
+ const result = {};
237
+ walkObject(values, (token, paths) => {
238
+ paths = filterDefault(paths);
239
+ if (token) result[paths.join(".")] = token.value;
240
+ }, { stop: stop ?? ((v) => {
241
+ return isObject(v) && "value" in v;
242
+ }) });
243
+ return result;
244
+ }
245
+ //#endregion
246
+ //#region src/get-or-create-set.ts
548
247
  function getOrCreateSet(map, key) {
549
- let set = map.get(key);
550
- if (!set) {
551
- map.set(key, /* @__PURE__ */ new Set());
552
- set = map.get(key);
553
- }
554
- return set;
555
- }
556
-
557
- // src/hypenate-property.ts
558
- var wordRegex = /([A-Z])/g;
559
- var msRegex = /^ms-/;
560
- var hypenateProperty = memo((property) => {
561
- if (property.startsWith("--")) return property;
562
- return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();
563
- });
564
-
565
- // src/is-css-function.ts
566
- var fns = ["min", "max", "clamp", "calc"];
567
- var fnRegExp = new RegExp(`^(${fns.join("|")})\\(.*\\)`);
568
- var isCssFunction = (v) => typeof v === "string" && fnRegExp.test(v);
569
-
570
- // src/is-css-unit.ts
571
- var lengthUnits = "cm,mm,Q,in,pc,pt,px,em,ex,ch,rem,lh,rlh,vw,vh,vmin,vmax,vb,vi,svw,svh,lvw,lvh,dvw,dvh,cqw,cqh,cqi,cqb,cqmin,cqmax,%";
572
- var lengthUnitsPattern = `(?:${lengthUnits.split(",").join("|")})`;
573
- var lengthRegExp = new RegExp(`^[+-]?[0-9]*.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`);
574
- var isCssUnit = (v) => typeof v === "string" && lengthRegExp.test(v);
575
-
576
- // src/is-css-var.ts
577
- var isCssVar2 = (v) => typeof v === "string" && /^var\(--.+\)$/.test(v);
578
-
579
- // src/merge-anything.ts
580
- var MERGE_OMIT2 = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
248
+ let set = map.get(key);
249
+ if (!set) {
250
+ map.set(key, /* @__PURE__ */ new Set());
251
+ set = map.get(key);
252
+ }
253
+ return set;
254
+ }
255
+ //#endregion
256
+ //#region src/merge-anything.ts
257
+ /**
258
+ * Credits: https://github.com/mesqueeb/merge-anything
259
+ */
260
+ const MERGE_OMIT$1 = new Set([
261
+ "__proto__",
262
+ "constructor",
263
+ "prototype"
264
+ ]);
581
265
  function concatArrays(originVal, newVal) {
582
- if (Array.isArray(originVal) && Array.isArray(newVal)) {
583
- return originVal.concat(newVal);
584
- }
585
- return newVal;
266
+ if (Array.isArray(originVal) && Array.isArray(newVal)) return originVal.concat(newVal);
267
+ return newVal;
586
268
  }
587
269
  function assignProp(carry, key, newVal, originalObject) {
588
- const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
589
- if (propType === "enumerable") carry[key] = newVal;
590
- if (propType === "nonenumerable") {
591
- Object.defineProperty(carry, key, {
592
- value: newVal,
593
- enumerable: false,
594
- writable: true,
595
- configurable: true
596
- });
597
- }
270
+ const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
271
+ if (propType === "enumerable") carry[key] = newVal;
272
+ if (propType === "nonenumerable") Object.defineProperty(carry, key, {
273
+ value: newVal,
274
+ enumerable: false,
275
+ writable: true,
276
+ configurable: true
277
+ });
598
278
  }
599
279
  function mergeRecursively(origin, newComer, compareFn) {
600
- if (!isObject(newComer)) return newComer;
601
- let newObject = {};
602
- if (isObject(origin)) {
603
- const props2 = Object.getOwnPropertyNames(origin);
604
- const symbols2 = Object.getOwnPropertySymbols(origin);
605
- newObject = [...props2, ...symbols2].reduce(
606
- (carry, key) => {
607
- if (isString(key) && MERGE_OMIT2.has(key)) return carry;
608
- const targetVal = origin[key];
609
- if (!isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key) || isSymbol(key) && !Object.getOwnPropertySymbols(newComer).includes(key)) {
610
- assignProp(carry, key, targetVal, origin);
611
- }
612
- return carry;
613
- },
614
- {}
615
- );
616
- }
617
- const props = Object.getOwnPropertyNames(newComer);
618
- const symbols = Object.getOwnPropertySymbols(newComer);
619
- const result = [...props, ...symbols].reduce((carry, key) => {
620
- if (isString(key) && MERGE_OMIT2.has(key)) return carry;
621
- let newVal = newComer[key];
622
- const targetVal = isObject(origin) ? origin[key] : void 0;
623
- if (targetVal !== void 0 && isObject(newVal)) {
624
- newVal = mergeRecursively(targetVal, newVal, compareFn);
625
- }
626
- const propToAssign = compareFn ? compareFn(targetVal, newVal, key) : newVal;
627
- assignProp(carry, key, propToAssign, newComer);
628
- return carry;
629
- }, newObject);
630
- return result;
280
+ if (!isObject(newComer)) return newComer;
281
+ let newObject = {};
282
+ if (isObject(origin)) {
283
+ const props = Object.getOwnPropertyNames(origin);
284
+ const symbols = Object.getOwnPropertySymbols(origin);
285
+ newObject = [...props, ...symbols].reduce((carry, key) => {
286
+ if (isString(key) && MERGE_OMIT$1.has(key)) return carry;
287
+ const targetVal = origin[key];
288
+ if (!isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key) || isSymbol(key) && !Object.getOwnPropertySymbols(newComer).includes(key)) assignProp(carry, key, targetVal, origin);
289
+ return carry;
290
+ }, {});
291
+ }
292
+ const props = Object.getOwnPropertyNames(newComer);
293
+ const symbols = Object.getOwnPropertySymbols(newComer);
294
+ return [...props, ...symbols].reduce((carry, key) => {
295
+ if (isString(key) && MERGE_OMIT$1.has(key)) return carry;
296
+ let newVal = newComer[key];
297
+ const targetVal = isObject(origin) ? origin[key] : void 0;
298
+ if (targetVal !== void 0 && isObject(newVal)) newVal = mergeRecursively(targetVal, newVal, compareFn);
299
+ assignProp(carry, key, compareFn ? compareFn(targetVal, newVal, key) : newVal, newComer);
300
+ return carry;
301
+ }, newObject);
631
302
  }
632
303
  function mergeAndConcat(object, ...otherObjects) {
633
- return otherObjects.reduce((result, newComer) => {
634
- return mergeRecursively(result, newComer, concatArrays);
635
- }, object);
636
- }
637
-
638
- // src/merge-with.ts
639
- var MERGE_OMIT3 = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
304
+ return otherObjects.reduce((result, newComer) => {
305
+ return mergeRecursively(result, newComer, concatArrays);
306
+ }, object);
307
+ }
308
+ //#endregion
309
+ //#region src/merge-with.ts
310
+ const MERGE_OMIT = new Set([
311
+ "__proto__",
312
+ "constructor",
313
+ "prototype"
314
+ ]);
640
315
  function mergeWith(target, ...sources) {
641
- const customizer = sources.pop();
642
- for (const source of sources) {
643
- for (const key in source) {
644
- if (isString(key) && MERGE_OMIT3.has(key)) continue;
645
- const merged = customizer(target[key], source[key]);
646
- if (merged === void 0) {
647
- if (isObject(target[key]) && isObject(source[key])) {
648
- target[key] = mergeWith({}, target[key], source[key], customizer);
649
- } else {
650
- target[key] = source[key];
651
- }
652
- } else {
653
- target[key] = merged;
654
- }
655
- }
656
- }
657
- return target;
658
- }
659
-
660
- // src/traverse.ts
661
- var defaultOptions = {
662
- separator: ".",
663
- maxDepth: Infinity
664
- };
665
- function traverse(obj, callback2, options = defaultOptions) {
666
- const maxDepth = options.maxDepth ?? defaultOptions.maxDepth;
667
- const separator = options.separator ?? defaultOptions.separator;
668
- const stack = [{ value: obj, path: "", paths: [], depth: -1, parent: null, key: "" }];
669
- while (stack.length > 0) {
670
- const currentItem = stack.pop();
671
- if (currentItem.parent !== null) {
672
- callback2(currentItem);
673
- }
674
- if (options.stop?.(currentItem)) {
675
- continue;
676
- }
677
- if (isObjectOrArray(currentItem.value) && currentItem.depth < maxDepth) {
678
- const keys = Object.keys(currentItem.value);
679
- for (let i = keys.length - 1; i >= 0; i--) {
680
- const key = keys[i];
681
- const value = currentItem.value[key];
682
- const path = currentItem.path ? currentItem.path + separator + key : key;
683
- const paths = currentItem.paths.concat(key);
684
- stack.push({
685
- value,
686
- path,
687
- paths,
688
- depth: currentItem.depth + 1,
689
- parent: currentItem.value,
690
- key
691
- });
692
- }
693
- }
694
- }
695
- }
696
-
697
- // src/omit.ts
698
- var omit = (obj, paths) => {
699
- const result = { ...obj };
700
- traverse(result, ({ path, parent, key }) => {
701
- if (paths.includes(path)) {
702
- delete parent[key];
703
- }
704
- });
705
- return result;
706
- };
707
-
708
- // src/bamboo-config-name.ts
709
- var BAMBOO_CONFIG_NAME = "__bamboo.config__";
710
-
711
- // src/pattern-fns.ts
712
- var patternFns = {
713
- map: mapObject,
714
- isCssFunction,
715
- isCssVar: isCssVar2,
716
- isCssUnit
316
+ const customizer = sources.pop();
317
+ for (const source of sources) for (const key in source) {
318
+ if (isString(key) && MERGE_OMIT.has(key)) continue;
319
+ const merged = customizer(target[key], source[key]);
320
+ if (merged === void 0) if (isObject(target[key]) && isObject(source[key])) target[key] = mergeWith({}, target[key], source[key], customizer);
321
+ else target[key] = source[key];
322
+ else target[key] = merged;
323
+ }
324
+ return target;
325
+ }
326
+ //#endregion
327
+ //#region src/traverse.ts
328
+ const defaultOptions = {
329
+ separator: ".",
330
+ maxDepth: Infinity
717
331
  };
718
- var getPatternStyles = (pattern, styles) => {
719
- if (!pattern?.defaultValues) return styles;
720
- const defaults = typeof pattern.defaultValues === "function" ? pattern.defaultValues(styles) : pattern.defaultValues;
721
- return Object.assign({}, defaults, compact(styles));
332
+ function traverse(obj, callback, options = defaultOptions) {
333
+ const maxDepth = options.maxDepth ?? defaultOptions.maxDepth;
334
+ const separator = options.separator ?? defaultOptions.separator;
335
+ const stack = [{
336
+ value: obj,
337
+ path: "",
338
+ paths: [],
339
+ depth: -1,
340
+ parent: null,
341
+ key: ""
342
+ }];
343
+ while (stack.length > 0) {
344
+ const currentItem = stack.pop();
345
+ if (currentItem.parent !== null) callback(currentItem);
346
+ if (options.stop?.(currentItem)) continue;
347
+ if (isObjectOrArray(currentItem.value) && currentItem.depth < maxDepth) {
348
+ const keys = Object.keys(currentItem.value);
349
+ for (let i = keys.length - 1; i >= 0; i--) {
350
+ const key = keys[i];
351
+ const value = currentItem.value[key];
352
+ const path = currentItem.path ? currentItem.path + separator + key : key;
353
+ const paths = currentItem.paths.concat(key);
354
+ stack.push({
355
+ value,
356
+ path,
357
+ paths,
358
+ depth: currentItem.depth + 1,
359
+ parent: currentItem.value,
360
+ key
361
+ });
362
+ }
363
+ }
364
+ }
365
+ }
366
+ //#endregion
367
+ //#region src/omit.ts
368
+ const omit = (obj, paths) => {
369
+ const result = { ...obj };
370
+ traverse(result, ({ path, parent, key }) => {
371
+ if (paths.includes(path)) delete parent[key];
372
+ });
373
+ return result;
722
374
  };
723
-
724
- // src/split.ts
375
+ //#endregion
376
+ //#region src/bamboo-config-name.ts
377
+ const BAMBOO_CONFIG_NAME = "__bamboo.config__";
378
+ //#endregion
379
+ //#region src/split.ts
725
380
  function splitBy(value, separator = ",") {
726
- const result = [];
727
- let current = "";
728
- let depth = 0;
729
- for (let i = 0; i < value.length; i++) {
730
- const char = value[i];
731
- if (char === "(") {
732
- depth++;
733
- } else if (char === ")") {
734
- depth--;
735
- } else if (char === separator && depth === 0) {
736
- result.push(current);
737
- current = "";
738
- continue;
739
- }
740
- current += char;
741
- }
742
- result.push(current);
743
- return result;
381
+ const result = [];
382
+ let current = "";
383
+ let depth = 0;
384
+ for (let i = 0; i < value.length; i++) {
385
+ const char = value[i];
386
+ if (char === "(") depth++;
387
+ else if (char === ")") depth--;
388
+ else if (char === separator && depth === 0) {
389
+ result.push(current);
390
+ current = "";
391
+ continue;
392
+ }
393
+ current += char;
394
+ }
395
+ result.push(current);
396
+ return result;
744
397
  }
745
398
  function splitDotPath(path) {
746
- return path.split(".").reduce((acc, curr) => {
747
- const last = acc[acc.length - 1];
748
- if (last != null && !isNaN(Number(last)) && !isNaN(Number(curr))) {
749
- acc[acc.length - 1] = `${last}.${curr}`;
750
- } else {
751
- acc.push(curr);
752
- }
753
- return acc;
754
- }, []);
399
+ return path.split(".").reduce((acc, curr) => {
400
+ const last = acc[acc.length - 1];
401
+ if (last != null && !isNaN(Number(last)) && !isNaN(Number(curr))) acc[acc.length - 1] = `${last}.${curr}`;
402
+ else acc.push(curr);
403
+ return acc;
404
+ }, []);
755
405
  }
756
406
  function getNegativePath(path) {
757
- return path.slice(0, -1).concat(`-${path.at(-1)}`);
407
+ return path.slice(0, -1).concat(`-${path.at(-1)}`);
758
408
  }
759
409
  function getDotPath(obj, path, fallback) {
760
- if (typeof path !== "string") return fallback;
761
- const idx = path.indexOf(".");
762
- if (idx === -1) {
763
- return obj?.[path] ?? fallback;
764
- }
765
- const key = path.slice(0, idx);
766
- const nextPath = path.slice(idx + 1);
767
- const checkValue = obj?.[key]?.[nextPath];
768
- if (checkValue) {
769
- return checkValue;
770
- }
771
- return getDotPath(obj?.[key], nextPath, fallback) ?? fallback;
772
- }
773
-
774
- // src/pick.ts
775
- var pick = (obj, paths) => {
776
- const result = {};
777
- traverse(obj, ({ path, value }) => {
778
- if (paths.includes(path)) {
779
- const pathParts = splitDotPath(path);
780
- deepSet(result, pathParts, value);
781
- }
782
- });
783
- return result;
410
+ if (typeof path !== "string") return fallback;
411
+ const idx = path.indexOf(".");
412
+ if (idx === -1) return obj?.[path] ?? fallback;
413
+ const key = path.slice(0, idx);
414
+ const nextPath = path.slice(idx + 1);
415
+ const checkValue = obj?.[key]?.[nextPath];
416
+ if (checkValue) return checkValue;
417
+ return getDotPath(obj?.[key], nextPath, fallback) ?? fallback;
418
+ }
419
+ //#endregion
420
+ //#region src/pick.ts
421
+ const pick = (obj, paths) => {
422
+ const result = {};
423
+ traverse(obj, ({ path, value }) => {
424
+ if (paths.includes(path)) deepSet(result, splitDotPath(path), value);
425
+ });
426
+ return result;
784
427
  };
785
-
786
- // src/property-priority.ts
787
- var longHandPhysical = /* @__PURE__ */ new Set();
788
- var longHandLogical = /* @__PURE__ */ new Set();
789
- var shorthandsOfLonghands = /* @__PURE__ */ new Set();
790
- var shorthandsOfShorthands = /* @__PURE__ */ new Set();
428
+ //#endregion
429
+ //#region src/property-priority.ts
430
+ /**
431
+ * Slightly modified from https://github.com/facebook/stylex/blob/main/packages/%40stylexjs/babel-plugin/src/shared/utils/property-priorities.js
432
+ * License: MIT
433
+ */
434
+ const longHandPhysical = /* @__PURE__ */ new Set();
435
+ const longHandLogical = /* @__PURE__ */ new Set();
436
+ const shorthandsOfLonghands = /* @__PURE__ */ new Set();
437
+ const shorthandsOfShorthands = /* @__PURE__ */ new Set();
791
438
  longHandLogical.add("backgroundBlendMode");
792
439
  longHandLogical.add("isolation");
793
440
  longHandLogical.add("mixBlendMode");
@@ -1236,226 +883,81 @@ longHandLogical.add("mathShift");
1236
883
  longHandLogical.add("mathStyle");
1237
884
  longHandLogical.add("touchAction");
1238
885
  function getPropertyPriority(key) {
1239
- if (key === "all") return 0;
1240
- if (key.startsWith("--")) return 1;
1241
- if (longHandPhysical.has(key)) return 4e3;
1242
- if (longHandLogical.has(key)) return 3e3;
1243
- if (shorthandsOfLonghands.has(key)) return 2e3;
1244
- if (shorthandsOfShorthands.has(key)) return 1e3;
1245
- return 3e3;
1246
- }
1247
-
1248
- // src/regex.ts
1249
- var createRegex = (item) => {
1250
- const regex2 = item.map((item2) => typeof item2 === "string" ? `^${item2}$` : item2.source).join("|");
1251
- return new RegExp(regex2);
1252
- };
1253
-
1254
- // src/serialize.ts
1255
- var stringifyJson = (config) => {
1256
- return JSON.stringify(config, (_key, value) => {
1257
- if (typeof value === "function") return value.toString();
1258
- return value;
1259
- });
886
+ if (key === "all") return 0;
887
+ if (key.startsWith("--")) return 1;
888
+ if (longHandPhysical.has(key)) return 4e3;
889
+ if (longHandLogical.has(key)) return 3e3;
890
+ if (shorthandsOfLonghands.has(key)) return 2e3;
891
+ if (shorthandsOfShorthands.has(key)) return 1e3;
892
+ return 3e3;
893
+ }
894
+ //#endregion
895
+ //#region src/regex.ts
896
+ const createRegex = (item) => {
897
+ const regex = item.map((item) => typeof item === "string" ? `^${item}$` : item.source).join("|");
898
+ return new RegExp(regex);
1260
899
  };
1261
- var parseJson = (config) => {
1262
- return JSON.parse(config);
900
+ //#endregion
901
+ //#region src/serialize.ts
902
+ const stringifyJson = (config) => {
903
+ return JSON.stringify(config, (_key, value) => {
904
+ if (typeof value === "function") return value.toString();
905
+ return value;
906
+ });
1263
907
  };
1264
-
1265
- // src/slot.ts
1266
- var getSlotRecipes = (recipe = {}) => {
1267
- const init = (slot) => ({
1268
- className: [recipe.className, slot].filter(Boolean).join("__"),
1269
- base: recipe.base?.[slot] ?? {},
1270
- variants: {},
1271
- defaultVariants: recipe.defaultVariants ?? {},
1272
- compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []
1273
- });
1274
- const slots = recipe.slots ?? [];
1275
- const recipeParts = slots.map((slot) => [slot, init(slot)]);
1276
- for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) {
1277
- for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) {
1278
- recipeParts.forEach(([slot, slotRecipe]) => {
1279
- slotRecipe.variants[variantsKey] ??= {};
1280
- slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};
1281
- });
1282
- }
1283
- }
1284
- return Object.fromEntries(recipeParts);
908
+ const parseJson = (config) => {
909
+ return JSON.parse(config);
1285
910
  };
1286
- var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
1287
-
1288
- // src/split-props.ts
1289
- function splitProps(props, ...keys) {
1290
- const descriptors = Object.getOwnPropertyDescriptors(props);
1291
- const dKeys = Object.keys(descriptors);
1292
- const split = (k) => {
1293
- const clone = {};
1294
- for (let i = 0; i < k.length; i++) {
1295
- const key = k[i];
1296
- if (descriptors[key]) {
1297
- Object.defineProperty(clone, key, descriptors[key]);
1298
- delete descriptors[key];
1299
- }
1300
- }
1301
- return clone;
1302
- };
1303
- const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));
1304
- return keys.map(fn).concat(split(dKeys));
1305
- }
1306
-
1307
- // src/to-json.ts
911
+ //#endregion
912
+ //#region src/to-json.ts
1308
913
  function mapToJson(map) {
1309
- const obj = {};
1310
- map.forEach((value, key) => {
1311
- if (value instanceof Map) {
1312
- obj[key] = Object.fromEntries(value);
1313
- } else {
1314
- obj[key] = value;
1315
- }
1316
- });
1317
- return obj;
1318
- }
1319
-
1320
- // src/typegen.ts
914
+ const obj = {};
915
+ map.forEach((value, key) => {
916
+ if (value instanceof Map) obj[key] = Object.fromEntries(value);
917
+ else obj[key] = value;
918
+ });
919
+ return obj;
920
+ }
921
+ //#endregion
922
+ //#region src/typegen.ts
1321
923
  function unionType(values, opts = {}) {
1322
- const { fallback, stringify = JSON.stringify } = opts;
1323
- const arr = Array.from(values);
1324
- if (fallback != null && !arr.length) return fallback;
1325
- return arr.map((v) => stringify(v)).join(" | ");
1326
- }
1327
-
1328
- // src/uniq.ts
1329
- var uniq = (...items) => {
1330
- const set = items.reduce((acc, currItems) => {
1331
- if (currItems) {
1332
- currItems.forEach((item) => acc.add(item));
1333
- }
1334
- return acc;
1335
- }, /* @__PURE__ */ new Set([]));
1336
- return Array.from(set);
1337
- };
1338
-
1339
- // src/unit-conversion.ts
1340
- var BASE_FONT_SIZE = 16;
1341
- var UNIT_PX = "px";
1342
- var UNIT_EM = "em";
1343
- var UNIT_REM = "rem";
1344
- var DIGIT_REGEX = new RegExp(String.raw`-?\d+(?:\.\d+|\d*)`);
1345
- var UNIT_REGEX = new RegExp(`${UNIT_PX}|${UNIT_EM}|${UNIT_REM}`);
1346
- var VALUE_REGEX = new RegExp(`${DIGIT_REGEX.source}(${UNIT_REGEX.source})`);
924
+ const { fallback, stringify = JSON.stringify } = opts;
925
+ const arr = Array.from(values);
926
+ if (fallback != null && !arr.length) return fallback;
927
+ return arr.map((v) => stringify(v)).join(" | ");
928
+ }
929
+ //#endregion
930
+ //#region src/unit-conversion.ts
931
+ const BASE_FONT_SIZE = 16;
932
+ const UNIT_PX = "px";
933
+ const UNIT_EM = "em";
934
+ const UNIT_REM = "rem";
935
+ const DIGIT_REGEX = new RegExp(String.raw`-?\d+(?:\.\d+|\d*)`);
936
+ const UNIT_REGEX = new RegExp(`${UNIT_PX}|${UNIT_EM}|${UNIT_REM}`);
937
+ const VALUE_REGEX = new RegExp(`${DIGIT_REGEX.source}(${UNIT_REGEX.source})`);
1347
938
  function getUnit(value = "") {
1348
- const unit = value.match(VALUE_REGEX);
1349
- return unit?.[1];
939
+ return value.match(VALUE_REGEX)?.[1];
1350
940
  }
1351
941
  function toPx(value = "") {
1352
- if (typeof value === "number") {
1353
- return `${value}px`;
1354
- }
1355
- const unit = getUnit(value);
1356
- if (!unit) return value;
1357
- if (unit === UNIT_PX) {
1358
- return value;
1359
- }
1360
- if (unit === UNIT_EM || unit === UNIT_REM) {
1361
- return `${parseFloat(value) * BASE_FONT_SIZE}${UNIT_PX}`;
1362
- }
942
+ if (typeof value === "number") return `${value}px`;
943
+ const unit = getUnit(value);
944
+ if (!unit) return value;
945
+ if (unit === UNIT_PX) return value;
946
+ if (unit === UNIT_EM || unit === UNIT_REM) return `${parseFloat(value) * BASE_FONT_SIZE}${UNIT_PX}`;
1363
947
  }
1364
948
  function toEm(value = "", fontSize = BASE_FONT_SIZE) {
1365
- const unit = getUnit(value);
1366
- if (!unit) return value;
1367
- if (unit === UNIT_EM) {
1368
- return value;
1369
- }
1370
- if (unit === UNIT_PX) {
1371
- return `${parseFloat(value) / fontSize}${UNIT_EM}`;
1372
- }
1373
- if (unit === UNIT_REM) {
1374
- return `${parseFloat(value) * BASE_FONT_SIZE / fontSize}${UNIT_EM}`;
1375
- }
949
+ const unit = getUnit(value);
950
+ if (!unit) return value;
951
+ if (unit === UNIT_EM) return value;
952
+ if (unit === UNIT_PX) return `${parseFloat(value) / fontSize}${UNIT_EM}`;
953
+ if (unit === UNIT_REM) return `${parseFloat(value) * BASE_FONT_SIZE / fontSize}${UNIT_EM}`;
1376
954
  }
1377
955
  function toRem(value = "") {
1378
- const unit = getUnit(value);
1379
- if (!unit) return value;
1380
- if (unit === UNIT_REM) {
1381
- return value;
1382
- }
1383
- if (unit === UNIT_EM) {
1384
- return `${parseFloat(value)}${UNIT_REM}`;
1385
- }
1386
- if (unit === UNIT_PX) {
1387
- return `${parseFloat(value) / BASE_FONT_SIZE}${UNIT_REM}`;
1388
- }
1389
- }
1390
- export {
1391
- BAMBOO_CONFIG_NAME,
1392
- BambooError,
1393
- CacheMap,
1394
- assign,
1395
- astish,
1396
- calc,
1397
- camelCaseProperty,
1398
- capitalize,
1399
- compact,
1400
- createCss,
1401
- createMergeCss,
1402
- createRegex,
1403
- cssVar,
1404
- dashCase,
1405
- deepSet,
1406
- entries,
1407
- esc2 as esc,
1408
- filterBaseConditions,
1409
- flatten,
1410
- fromEntries,
1411
- getArbitraryValue,
1412
- getDotPath,
1413
- getNegativePath,
1414
- getOrCreateSet,
1415
- getPatternStyles,
1416
- getPropertyPriority,
1417
- getSlotCompoundVariant,
1418
- getSlotRecipes,
1419
- getUnit,
1420
- hypenateProperty,
1421
- isBaseCondition,
1422
- isBoolean,
1423
- isCssFunction,
1424
- isCssUnit,
1425
- isCssVar2 as isCssVar,
1426
- isFunction,
1427
- isImportant,
1428
- isObject,
1429
- isObjectOrArray,
1430
- isString,
1431
- isSymbol,
1432
- mapEntries,
1433
- mapObject,
1434
- mapToJson,
1435
- markImportant,
1436
- memo,
1437
- mergeAndConcat,
1438
- mergeProps,
1439
- mergeWith,
1440
- normalizeStyleObject,
1441
- omit,
1442
- parseJson,
1443
- patternFns,
1444
- pick,
1445
- splitBy,
1446
- splitDotPath,
1447
- splitProps,
1448
- stringifyJson,
1449
- toEm,
1450
- toHash,
1451
- toPx,
1452
- toRem,
1453
- toResponsiveObject,
1454
- traverse,
1455
- uncapitalize,
1456
- unionType,
1457
- uniq,
1458
- walkObject,
1459
- withoutImportant,
1460
- withoutSpace
1461
- };
956
+ const unit = getUnit(value);
957
+ if (!unit) return value;
958
+ if (unit === UNIT_REM) return value;
959
+ if (unit === UNIT_EM) return `${parseFloat(value)}${UNIT_REM}`;
960
+ if (unit === UNIT_PX) return `${parseFloat(value) / BASE_FONT_SIZE}${UNIT_REM}`;
961
+ }
962
+ //#endregion
963
+ export { BAMBOO_CONFIG_NAME, BambooError, CacheMap, assign, astish, calc, camelCaseProperty, capitalize, compact, createCss, createMergeCss, createRegex, cssVar, dashCase, deepSet, entries, esc, filterBaseConditions, flatten, fromEntries, getArbitraryValue, getDotPath, getNegativePath, getOrCreateSet, getPatternStyles, getPropertyPriority, getSlotCompoundVariant, getSlotRecipes, getUnit, hypenateProperty, isBaseCondition, isBoolean, isCssFunction, isCssUnit, isCssVar, isFunction, isImportant, isObject, isObjectOrArray, isString, isSymbol, mapEntries, mapObject, mapToJson, markImportant, memo, mergeAndConcat, mergeProps, mergeWith, normalizeStyleObject, omit, parseJson, patternFns, pick, splitBy, splitDotPath, splitProps, stringifyJson, toEm, toHash, toPx, toRem, toResponsiveObject, traverse, uncapitalize, unionType, uniq, walkObject, withoutImportant, withoutSpace };