@symbo.ls/scratch 3.2.3 → 3.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/cjs/factory.js +23 -494
  2. package/dist/cjs/index.js +11 -2742
  3. package/dist/cjs/set.js +66 -2060
  4. package/dist/esm/factory.js +43 -0
  5. package/dist/esm/index.js +12 -0
  6. package/dist/esm/set.js +148 -0
  7. package/dist/iife/index.js +2580 -0
  8. package/package.json +25 -15
  9. package/src/set.js +22 -7
  10. package/src/system/color.js +48 -11
  11. package/src/system/font.js +19 -5
  12. package/src/system/reset.js +12 -3
  13. package/src/system/shadow.js +20 -13
  14. package/src/system/spacing.js +63 -56
  15. package/src/system/theme.js +4 -3
  16. package/src/system/timing.js +1 -1
  17. package/src/transforms/index.js +212 -95
  18. package/src/utils/color.js +79 -0
  19. package/src/utils/font.js +54 -14
  20. package/src/utils/sequence.js +94 -39
  21. package/src/utils/sprite.js +2 -2
  22. package/src/utils/unit.js +69 -2
  23. package/src/utils/var.js +1 -2
  24. package/dist/cjs/defaultConfig/animation.js +0 -26
  25. package/dist/cjs/defaultConfig/cases.js +0 -26
  26. package/dist/cjs/defaultConfig/class.js +0 -27
  27. package/dist/cjs/defaultConfig/color.js +0 -28
  28. package/dist/cjs/defaultConfig/document.js +0 -26
  29. package/dist/cjs/defaultConfig/font-family.js +0 -34
  30. package/dist/cjs/defaultConfig/font.js +0 -26
  31. package/dist/cjs/defaultConfig/grid.js +0 -27
  32. package/dist/cjs/defaultConfig/icons.js +0 -28
  33. package/dist/cjs/defaultConfig/index.js +0 -222
  34. package/dist/cjs/defaultConfig/media.js +0 -31
  35. package/dist/cjs/defaultConfig/responsive.js +0 -52
  36. package/dist/cjs/defaultConfig/sequence.js +0 -51
  37. package/dist/cjs/defaultConfig/shadow.js +0 -26
  38. package/dist/cjs/defaultConfig/spacing.js +0 -87
  39. package/dist/cjs/defaultConfig/svg.js +0 -28
  40. package/dist/cjs/defaultConfig/templates.js +0 -26
  41. package/dist/cjs/defaultConfig/theme.js +0 -26
  42. package/dist/cjs/defaultConfig/timing.js +0 -68
  43. package/dist/cjs/defaultConfig/typography.js +0 -72
  44. package/dist/cjs/defaultConfig/unit.js +0 -28
  45. package/dist/cjs/package.json +0 -4
  46. package/dist/cjs/system/color.js +0 -1175
  47. package/dist/cjs/system/document.js +0 -987
  48. package/dist/cjs/system/font.js +0 -1009
  49. package/dist/cjs/system/index.js +0 -2227
  50. package/dist/cjs/system/reset.js +0 -1099
  51. package/dist/cjs/system/shadow.js +0 -1384
  52. package/dist/cjs/system/spacing.js +0 -1338
  53. package/dist/cjs/system/svg.js +0 -1086
  54. package/dist/cjs/system/theme.js +0 -1276
  55. package/dist/cjs/system/timing.js +0 -1213
  56. package/dist/cjs/system/typography.js +0 -1311
  57. package/dist/cjs/tests/index.js +0 -30
  58. package/dist/cjs/transforms/index.js +0 -1613
  59. package/dist/cjs/utils/color.js +0 -333
  60. package/dist/cjs/utils/font.js +0 -69
  61. package/dist/cjs/utils/index.js +0 -1548
  62. package/dist/cjs/utils/sequence.js +0 -1198
  63. package/dist/cjs/utils/sprite.js +0 -579
  64. package/dist/cjs/utils/theme.js +0 -31
  65. package/dist/cjs/utils/unit.js +0 -28
  66. package/dist/cjs/utils/var.js +0 -1040
@@ -0,0 +1,2580 @@
1
+ "use strict";
2
+ var SmblsScratch = (() => {
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.js
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ ANIMATION: () => ANIMATION,
25
+ BREAKPOINTS: () => BREAKPOINTS,
26
+ CASES: () => CASES,
27
+ CLASS: () => CLASS,
28
+ COLOR: () => COLOR,
29
+ CONFIG: () => CONFIG,
30
+ CSS_NATIVE_COLOR_REGEX: () => CSS_NATIVE_COLOR_REGEX,
31
+ CSS_UNITS: () => CSS_UNITS,
32
+ CSS_VARS: () => CSS_VARS,
33
+ DEVICES: () => DEVICES,
34
+ DOCUMENT: () => DOCUMENT,
35
+ FACTORY: () => FACTORY,
36
+ FONT: () => FONT,
37
+ FONT_FACE: () => FONT_FACE,
38
+ FONT_FAMILY: () => FONT_FAMILY,
39
+ FONT_FAMILY_TYPES: () => FONT_FAMILY_TYPES,
40
+ GRADIENT: () => GRADIENT,
41
+ GRID: () => GRID,
42
+ ICONS: () => ICONS,
43
+ MEDIA: () => MEDIA,
44
+ RESET: () => RESET,
45
+ SEMANTIC_ICONS: () => SEMANTIC_ICONS,
46
+ SEQUENCE: () => SEQUENCE,
47
+ SHADOW: () => SHADOW,
48
+ SPACING: () => SPACING,
49
+ SVG: () => SVG,
50
+ SVG_DATA: () => SVG_DATA,
51
+ TEMPLATES: () => TEMPLATES,
52
+ THEME: () => THEME,
53
+ TIMING: () => TIMING,
54
+ TYPOGRAPHY: () => TYPOGRAPHY,
55
+ UNIT: () => UNIT,
56
+ VALUE_TRANSFORMERS: () => VALUE_TRANSFORMERS,
57
+ activateConfig: () => activateConfig,
58
+ appendSVGSprite: () => appendSVGSprite,
59
+ appendSvgIconsSprite: () => appendSvgIconsSprite,
60
+ applyDocument: () => applyDocument,
61
+ applyHeadings: () => applyHeadings,
62
+ applyMediaSequenceVars: () => applyMediaSequenceVars,
63
+ applyReset: () => applyReset,
64
+ applySequenceGlobalVars: () => applySequenceGlobalVars,
65
+ applySequenceVars: () => applySequenceVars,
66
+ applySpacingSequence: () => applySpacingSequence,
67
+ applyTimingSequence: () => applyTimingSequence,
68
+ applyTypographySequence: () => applyTypographySequence,
69
+ changeLightness: () => changeLightness,
70
+ checkIfBoxSize: () => checkIfBoxSize,
71
+ colorStringToRgbaArray: () => colorStringToRgbaArray,
72
+ convertSvgToSymbol: () => convertSvgToSymbol,
73
+ findHeadingLetter: () => findHeadingLetter,
74
+ findHeadings: () => findHeadings,
75
+ generateSequence: () => generateSequence,
76
+ generateSequencePosition: () => generateSequencePosition,
77
+ generateSprite: () => generateSprite,
78
+ generateSubSequence: () => generateSubSequence,
79
+ getActiveConfig: () => getActiveConfig,
80
+ getColor: () => getColor,
81
+ getColorShade: () => getColorShade,
82
+ getDefaultOrFirstKey: () => getDefaultOrFirstKey,
83
+ getFnPrefixAndValue: () => getFnPrefixAndValue,
84
+ getFontFace: () => getFontFace,
85
+ getFontFaceEach: () => getFontFaceEach,
86
+ getFontFaceEachString: () => getFontFaceEachString,
87
+ getFontFaceString: () => getFontFaceString,
88
+ getFontFamily: () => getFontFamily,
89
+ getFontFormat: () => getFontFormat,
90
+ getFontSizeByKey: () => getFontSizeByKey,
91
+ getMediaColor: () => getMediaColor,
92
+ getMediaTheme: () => getMediaTheme,
93
+ getRgbTone: () => getRgbTone,
94
+ getSequenceValue: () => getSequenceValue,
95
+ getSequenceValueBySymbols: () => getSequenceValueBySymbols,
96
+ getSequenceValuePropertyPair: () => getSequenceValuePropertyPair,
97
+ getShadow: () => getShadow,
98
+ getSpacingBasedOnRatio: () => getSpacingBasedOnRatio,
99
+ getSpacingByKey: () => getSpacingByKey,
100
+ getSubratio: () => getSubratio,
101
+ getSubratioDifference: () => getSubratioDifference,
102
+ getTheme: () => getTheme,
103
+ getTimingByKey: () => getTimingByKey,
104
+ getTimingFunction: () => getTimingFunction,
105
+ hexToRgb: () => hexToRgb,
106
+ hexToRgbArray: () => hexToRgbArray,
107
+ hexToRgba: () => hexToRgba,
108
+ hslToRgb: () => hslToRgb,
109
+ isCSSVar: () => isCSSVar,
110
+ isGoogleFontsUrl: () => isGoogleFontsUrl,
111
+ isResolvedColor: () => isResolvedColor,
112
+ isScalingUnit: () => isScalingUnit,
113
+ mixTwoColors: () => mixTwoColors,
114
+ mixTwoRgb: () => mixTwoRgb,
115
+ mixTwoRgba: () => mixTwoRgba,
116
+ numToLetterMap: () => numToLetterMap,
117
+ opacify: () => opacify,
118
+ parseColorToken: () => parseColorToken,
119
+ resolveColorsInGradient: () => resolveColorsInGradient,
120
+ returnSubThemeOrDefault: () => returnSubThemeOrDefault,
121
+ rgbArrayToHex: () => rgbArrayToHex,
122
+ rgbToHSL: () => rgbToHSL,
123
+ rgbToHex: () => rgbToHex,
124
+ runThroughMedia: () => runThroughMedia,
125
+ scratchSystem: () => system_exports,
126
+ scratchUtils: () => utils_exports,
127
+ set: () => set,
128
+ setActiveConfig: () => setActiveConfig,
129
+ setColor: () => setColor,
130
+ setCustomFont: () => setCustomFont,
131
+ setCustomFontMedia: () => setCustomFontMedia,
132
+ setEach: () => setEach,
133
+ setFont: () => setFont,
134
+ setFontFamily: () => setFontFamily,
135
+ setFontImport: () => setFontImport,
136
+ setGradient: () => setGradient,
137
+ setInCustomFontMedia: () => setInCustomFontMedia,
138
+ setMediaTheme: () => setMediaTheme,
139
+ setSVG: () => setSVG,
140
+ setScalingVar: () => setScalingVar,
141
+ setShadow: () => setShadow,
142
+ setSubScalingVar: () => setSubScalingVar,
143
+ setSvgIcon: () => setSvgIcon,
144
+ setTheme: () => setTheme,
145
+ setValue: () => setValue,
146
+ setVariables: () => setVariables,
147
+ splitSpacedValue: () => splitSpacedValue,
148
+ splitTopLevelCommas: () => splitTopLevelCommas,
149
+ splitTransition: () => splitTransition,
150
+ transformBackgroundImage: () => transformBackgroundImage,
151
+ transformBorder: () => transformBorder,
152
+ transformBorderRadius: () => transformBorderRadius,
153
+ transformBoxShadow: () => transformBoxShadow,
154
+ transformDuration: () => transformDuration,
155
+ transformShadow: () => transformShadow,
156
+ transformSize: () => transformSize,
157
+ transformSizeRatio: () => transformSizeRatio,
158
+ transformTextStroke: () => transformTextStroke,
159
+ transformTransition: () => transformTransition,
160
+ transfromGap: () => transfromGap
161
+ });
162
+
163
+ // src/utils/index.js
164
+ var utils_exports = {};
165
+ __export(utils_exports, {
166
+ CSS_NATIVE_COLOR_REGEX: () => CSS_NATIVE_COLOR_REGEX,
167
+ CSS_UNITS: () => CSS_UNITS,
168
+ applyMediaSequenceVars: () => applyMediaSequenceVars,
169
+ applySequenceGlobalVars: () => applySequenceGlobalVars,
170
+ applySequenceVars: () => applySequenceVars,
171
+ changeLightness: () => changeLightness,
172
+ colorStringToRgbaArray: () => colorStringToRgbaArray,
173
+ convertSvgToSymbol: () => convertSvgToSymbol,
174
+ findHeadingLetter: () => findHeadingLetter,
175
+ findHeadings: () => findHeadings,
176
+ generateSequence: () => generateSequence,
177
+ generateSequencePosition: () => generateSequencePosition,
178
+ generateSprite: () => generateSprite,
179
+ generateSubSequence: () => generateSubSequence,
180
+ getColorShade: () => getColorShade,
181
+ getDefaultOrFirstKey: () => getDefaultOrFirstKey,
182
+ getFnPrefixAndValue: () => getFnPrefixAndValue,
183
+ getFontFace: () => getFontFace,
184
+ getFontFaceEach: () => getFontFaceEach,
185
+ getFontFaceEachString: () => getFontFaceEachString,
186
+ getFontFaceString: () => getFontFaceString,
187
+ getFontFormat: () => getFontFormat,
188
+ getRgbTone: () => getRgbTone,
189
+ getSequenceValue: () => getSequenceValue,
190
+ getSequenceValueBySymbols: () => getSequenceValueBySymbols,
191
+ getSequenceValuePropertyPair: () => getSequenceValuePropertyPair,
192
+ getSubratio: () => getSubratio,
193
+ getSubratioDifference: () => getSubratioDifference,
194
+ hexToRgb: () => hexToRgb,
195
+ hexToRgbArray: () => hexToRgbArray,
196
+ hexToRgba: () => hexToRgba,
197
+ hslToRgb: () => hslToRgb,
198
+ isCSSVar: () => isCSSVar,
199
+ isGoogleFontsUrl: () => isGoogleFontsUrl,
200
+ isResolvedColor: () => isResolvedColor,
201
+ isScalingUnit: () => isScalingUnit,
202
+ mixTwoColors: () => mixTwoColors,
203
+ mixTwoRgb: () => mixTwoRgb,
204
+ mixTwoRgba: () => mixTwoRgba,
205
+ numToLetterMap: () => numToLetterMap,
206
+ opacify: () => opacify,
207
+ parseColorToken: () => parseColorToken,
208
+ returnSubThemeOrDefault: () => returnSubThemeOrDefault,
209
+ rgbArrayToHex: () => rgbArrayToHex,
210
+ rgbToHSL: () => rgbToHSL,
211
+ rgbToHex: () => rgbToHex,
212
+ setCustomFont: () => setCustomFont,
213
+ setCustomFontMedia: () => setCustomFontMedia,
214
+ setFontImport: () => setFontImport,
215
+ setInCustomFontMedia: () => setInCustomFontMedia,
216
+ setScalingVar: () => setScalingVar,
217
+ setSubScalingVar: () => setSubScalingVar,
218
+ setVariables: () => setVariables,
219
+ splitTopLevelCommas: () => splitTopLevelCommas
220
+ });
221
+
222
+ // src/utils/unit.js
223
+ var isScalingUnit = (unit) => {
224
+ return unit === "em" || unit === "rem" || unit === "vw" || unit === "vh" || unit === "vmax" || unit === "vmin";
225
+ };
226
+ var CSS_UNITS = [
227
+ // Absolute
228
+ "px",
229
+ "cm",
230
+ "mm",
231
+ "in",
232
+ "pt",
233
+ "pc",
234
+ // Font-relative
235
+ "em",
236
+ "rem",
237
+ "ex",
238
+ "cap",
239
+ "ch",
240
+ "ic",
241
+ "lh",
242
+ "rlh",
243
+ // Viewport-relative
244
+ "%",
245
+ "vw",
246
+ "vh",
247
+ "vmin",
248
+ "vmax",
249
+ "svw",
250
+ "svh",
251
+ "lvw",
252
+ "lvh",
253
+ "dvw",
254
+ "dvh",
255
+ // Container query units
256
+ "cqw",
257
+ "cqh",
258
+ "cqi",
259
+ "cqb",
260
+ "cqmin",
261
+ "cqmax",
262
+ // Angle
263
+ "deg",
264
+ "rad",
265
+ "grad",
266
+ "turn",
267
+ // Time
268
+ "s",
269
+ "ms",
270
+ // Resolution
271
+ "dpi",
272
+ "dpcm",
273
+ "dppx",
274
+ // Grid fractional
275
+ "fr",
276
+ "auto"
277
+ ];
278
+
279
+ // ../utils/dist/esm/globals.js
280
+ var window2 = globalThis;
281
+ var document2 = window2.document;
282
+
283
+ // ../utils/dist/esm/node.js
284
+ var isDOMNode = (obj) => {
285
+ return typeof window2 !== "undefined" && (obj instanceof window2.Node || obj instanceof window2.Window || obj === window2 || obj === document);
286
+ };
287
+
288
+ // ../utils/dist/esm/types.js
289
+ var isObject = (arg) => {
290
+ if (arg === null) return false;
291
+ return typeof arg === "object" && arg.constructor === Object;
292
+ };
293
+ var isString = (arg) => typeof arg === "string";
294
+ var isNumber = (arg) => typeof arg === "number";
295
+ var isFunction = (arg) => typeof arg === "function";
296
+ var isArray = (arg) => Array.isArray(arg);
297
+ var isObjectLike = (arg) => {
298
+ if (arg === null) return false;
299
+ return typeof arg === "object";
300
+ };
301
+ var isDefined = (arg) => arg !== void 0;
302
+
303
+ // ../utils/dist/esm/array.js
304
+ var unstackArrayOfObjects = (arr, exclude = []) => {
305
+ return arr.reduce(
306
+ (a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
307
+ {}
308
+ );
309
+ };
310
+
311
+ // ../utils/dist/esm/keys.js
312
+ var STATE_METHODS = /* @__PURE__ */ new Set([
313
+ "update",
314
+ "parse",
315
+ "clean",
316
+ "create",
317
+ "destroy",
318
+ "add",
319
+ "toggle",
320
+ "remove",
321
+ "apply",
322
+ "set",
323
+ "reset",
324
+ "replace",
325
+ "quietReplace",
326
+ "quietUpdate",
327
+ "applyReplace",
328
+ "applyFunction",
329
+ "keys",
330
+ "values",
331
+ "ref",
332
+ "rootUpdate",
333
+ "parentUpdate",
334
+ "parent",
335
+ "__element",
336
+ "__depends",
337
+ "__ref",
338
+ "__children",
339
+ "root",
340
+ "setByPath",
341
+ "setPathCollection",
342
+ "removeByPath",
343
+ "removePathCollection",
344
+ "getByPath"
345
+ ]);
346
+ var PROPS_METHODS = /* @__PURE__ */ new Set(["update", "__element"]);
347
+ var METHODS = /* @__PURE__ */ new Set([
348
+ "set",
349
+ "reset",
350
+ "update",
351
+ "remove",
352
+ "updateContent",
353
+ "removeContent",
354
+ "lookup",
355
+ "lookdown",
356
+ "lookdownAll",
357
+ "getRef",
358
+ "getPath",
359
+ "setNodeStyles",
360
+ "spotByPath",
361
+ "keys",
362
+ "parse",
363
+ "setProps",
364
+ "parseDeep",
365
+ "variables",
366
+ "if",
367
+ "log",
368
+ "verbose",
369
+ "warn",
370
+ "error",
371
+ "call",
372
+ "nextElement",
373
+ "previousElement",
374
+ "getRootState",
375
+ "getRoot",
376
+ "getRootData",
377
+ "getRootContext",
378
+ "getContext",
379
+ "getChildren"
380
+ ]);
381
+ var METHODS_EXL = /* @__PURE__ */ new Set([
382
+ "node",
383
+ "context",
384
+ "extends",
385
+ "__element",
386
+ "__ref",
387
+ ...METHODS,
388
+ ...STATE_METHODS,
389
+ ...PROPS_METHODS
390
+ ]);
391
+
392
+ // ../utils/dist/esm/object.js
393
+ var _startsWithDunder = (e) => e.charCodeAt(0) === 95 && e.charCodeAt(1) === 95;
394
+ var exec = (param, element, state, context) => {
395
+ if (isFunction(param)) {
396
+ if (!element) return;
397
+ const result = param.call(
398
+ element,
399
+ element,
400
+ state || element.state,
401
+ context || element.context
402
+ );
403
+ if (result && typeof result.then === "function") {
404
+ let resolved;
405
+ result.then((value) => {
406
+ resolved = value;
407
+ });
408
+ return resolved;
409
+ }
410
+ return result;
411
+ }
412
+ return param;
413
+ };
414
+ var merge = (element, obj, excludeFrom = []) => {
415
+ const useSet = excludeFrom instanceof Set;
416
+ for (const e in obj) {
417
+ if (!Object.prototype.hasOwnProperty.call(obj, e)) continue;
418
+ if (_startsWithDunder(e)) continue;
419
+ if (useSet ? excludeFrom.has(e) : excludeFrom.includes(e)) continue;
420
+ if (element[e] === void 0) {
421
+ element[e] = obj[e];
422
+ }
423
+ }
424
+ return element;
425
+ };
426
+ var deepMerge = (element, extend, excludeFrom = METHODS_EXL) => {
427
+ const useSet = excludeFrom instanceof Set;
428
+ for (const e in extend) {
429
+ if (!Object.prototype.hasOwnProperty.call(extend, e)) continue;
430
+ if (_startsWithDunder(e)) continue;
431
+ if (useSet ? excludeFrom.has(e) : excludeFrom.includes(e)) continue;
432
+ const elementProp = element[e];
433
+ const extendProp = extend[e];
434
+ if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
435
+ deepMerge(elementProp, extendProp, excludeFrom);
436
+ } else if (elementProp === void 0) {
437
+ element[e] = extendProp;
438
+ }
439
+ }
440
+ return element;
441
+ };
442
+ var deepClone = (obj, options = {}) => {
443
+ const {
444
+ exclude = [],
445
+ cleanUndefined = false,
446
+ cleanNull = false,
447
+ window: targetWindow,
448
+ visited = /* @__PURE__ */ new WeakMap(),
449
+ handleExtends = false
450
+ } = options;
451
+ const contentWindow = targetWindow || window2 || globalThis;
452
+ if (!isObjectLike(obj) || isDOMNode(obj)) {
453
+ return obj;
454
+ }
455
+ if (visited.has(obj)) {
456
+ return visited.get(obj);
457
+ }
458
+ const isArr = isArray(obj);
459
+ const clone2 = isArr ? [] : {};
460
+ visited.set(obj, clone2);
461
+ const excludeSet = exclude instanceof Set ? exclude : exclude.length > 3 ? new Set(exclude) : null;
462
+ for (const key in obj) {
463
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
464
+ if (_startsWithDunder(key) || key === "__proto__") continue;
465
+ if (excludeSet ? excludeSet.has(key) : exclude.includes(key)) continue;
466
+ const value = obj[key];
467
+ if (cleanUndefined && value === void 0) continue;
468
+ if (cleanNull && value === null) continue;
469
+ if (isDOMNode(value)) {
470
+ clone2[key] = value;
471
+ continue;
472
+ }
473
+ if (handleExtends && key === "extends" && isArray(value)) {
474
+ clone2[key] = unstackArrayOfObjects(value, exclude);
475
+ continue;
476
+ }
477
+ if (isFunction(value) && options.window) {
478
+ clone2[key] = contentWindow.eval("(" + value.toString() + ")");
479
+ continue;
480
+ }
481
+ if (isObjectLike(value)) {
482
+ clone2[key] = deepClone(value, {
483
+ ...options,
484
+ visited
485
+ });
486
+ } else {
487
+ clone2[key] = value;
488
+ }
489
+ }
490
+ return clone2;
491
+ };
492
+ var overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new WeakMap()) => {
493
+ if (!isObjectLike(obj) || !isObjectLike(params) || isDOMNode(obj) || isDOMNode(params)) {
494
+ return params;
495
+ }
496
+ if (visited.has(obj)) return visited.get(obj);
497
+ visited.set(obj, obj);
498
+ const excl = opts.exclude;
499
+ const exclSet = excl ? excl instanceof Set ? excl : new Set(excl) : null;
500
+ const forcedExclude = !opts.preventForce;
501
+ for (const e in params) {
502
+ if (!Object.prototype.hasOwnProperty.call(params, e)) continue;
503
+ if (exclSet && exclSet.has(e) || forcedExclude && _startsWithDunder(e)) continue;
504
+ const objProp = obj[e];
505
+ const paramsProp = params[e];
506
+ if (isDOMNode(paramsProp)) {
507
+ obj[e] = paramsProp;
508
+ } else if (isObjectLike(objProp) && isObjectLike(paramsProp)) {
509
+ obj[e] = overwriteDeep(objProp, paramsProp, opts, visited);
510
+ } else if (paramsProp !== void 0) {
511
+ obj[e] = paramsProp;
512
+ }
513
+ }
514
+ return obj;
515
+ };
516
+
517
+ // ../utils/dist/esm/env.js
518
+ var NODE_ENV = process.env.NODE_ENV;
519
+ var isProduction = (env = NODE_ENV) => env === "production";
520
+ var isNotProduction = (env = NODE_ENV) => !isProduction(env);
521
+
522
+ // src/utils/color.js
523
+ var colorStringToRgbaArray = (color) => {
524
+ if (color === "") return [0, 0, 0, 0];
525
+ if (color.toLowerCase() === "transparent") return [0, 0, 0, 0];
526
+ if (color[0] === "#") {
527
+ if (color.length < 7) {
528
+ color = "#" + color[1] + color[1] + color[2] + color[2] + color[3] + color[3] + (color.length > 4 ? color[4] + color[4] : "");
529
+ }
530
+ return [
531
+ parseInt(color.substr(1, 2), 16),
532
+ parseInt(color.substr(3, 2), 16),
533
+ parseInt(color.substr(5, 2), 16),
534
+ color.length > 7 ? parseInt(color.substr(7, 2), 16) / 255 : 1
535
+ ];
536
+ }
537
+ if (color.indexOf("rgb") === -1) {
538
+ if (document2 && window2) {
539
+ const elem = document2.body.appendChild(document2.createElement("fictum"));
540
+ const flag = "rgb(1, 2, 3)";
541
+ elem.style.color = flag;
542
+ if (elem.style.color !== flag) {
543
+ document2.body.removeChild(elem);
544
+ return;
545
+ }
546
+ elem.style.color = color;
547
+ if (elem.style.color === flag || elem.style.color === "") {
548
+ document2.body.removeChild(elem);
549
+ return [0, 0, 0, 0];
550
+ }
551
+ color = window2.getComputedStyle(elem).color;
552
+ document2.body.removeChild(elem);
553
+ }
554
+ }
555
+ if (color.indexOf("rgb") === 0) {
556
+ if (color.indexOf("rgba") === -1) color = `${color}, 1`;
557
+ return color.match(/[\.\d]+/g).map((a) => +a);
558
+ }
559
+ return [0, 0, 0, 0];
560
+ };
561
+ var mixTwoColors = (colorA, colorB, range = 0.5) => {
562
+ colorA = colorStringToRgbaArray(colorA);
563
+ colorB = colorStringToRgbaArray(colorB);
564
+ return mixTwoRgba(colorA, colorB, range);
565
+ };
566
+ var hexToRgb = (hex, alpha = 1) => {
567
+ const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
568
+ return `rgb(${r},${g},${b})`;
569
+ };
570
+ var hexToRgbArray = (hex, alpha = 1) => {
571
+ const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
572
+ return [r, g, b];
573
+ };
574
+ var rgbToHex = (r, g, b) => {
575
+ return "#" + (1 << 24 | r << 16 | g << 8 | b).toString(16).slice(1);
576
+ };
577
+ var rgbArrayToHex = ([r, g, b]) => {
578
+ return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
579
+ };
580
+ var hexToRgba = (hex, alpha = 1) => {
581
+ const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
582
+ return `rgba(${r},${g},${b},${alpha})`;
583
+ };
584
+ var mixTwoRgb = (colorA, colorB, range = 0.5) => {
585
+ const arr = [];
586
+ for (let i = 0; i < 3; i++) {
587
+ arr[i] = ~~(colorA[i] + (colorB[i] - colorA[i]) * range);
588
+ }
589
+ return `rgb(${arr})`;
590
+ };
591
+ var changeLightness = (delta, hsl) => {
592
+ const [hue, saturation, lightness] = hsl;
593
+ const newLightness = Math.max(0, Math.min(100, lightness + parseFloat(delta)));
594
+ return [hue, saturation, newLightness];
595
+ };
596
+ var rgbToHSL = (r, g, b) => {
597
+ const a = Math.max(r, g, b);
598
+ const n = a - Math.min(r, g, b);
599
+ const f = 1 - Math.abs(a + a - n - 1);
600
+ const h = n && (a == r ? (g - b) / n : a == g ? 2 + (b - r) / n : 4 + (r - g) / n);
601
+ return [60 * (h < 0 ? h + 6 : h), f ? n / f : 0, (a + a - n) / 2];
602
+ };
603
+ var hslToRgb = (h, s, l, a = s * Math.min(l, 1 - l), f = (n, k = (n + h / 30) % 12) => l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)) => [f(0), f(8), f(4)];
604
+ var getColorShade = (col, amt) => {
605
+ const num = parseInt(col, 16);
606
+ let r = (num >> 16) + amt;
607
+ if (r > 255) r = 255;
608
+ else if (r < 0) r = 0;
609
+ let b = (num >> 8 & 255) + amt;
610
+ if (b > 255) b = 255;
611
+ else if (b < 0) b = 0;
612
+ let g = (num & 255) + amt;
613
+ if (g > 255) g = 255;
614
+ else if (g < 0) g = 0;
615
+ return ((g | b << 8 | r << 16) + 16777216).toString(16).slice(1);
616
+ };
617
+ var mixTwoRgba = (colorA, colorB, range = 0.5) => {
618
+ const arr = [];
619
+ for (let i = 0; i < 4; i++) {
620
+ const round = i === 3 ? (x) => x : Math.round;
621
+ arr[i] = round(colorA[i] + (colorB[i] - colorA[i]) * range);
622
+ }
623
+ return `rgba(${arr})`;
624
+ };
625
+ var opacify = (color, opacity) => {
626
+ const arr = colorStringToRgbaArray(color);
627
+ if (!arr) {
628
+ if (isNotProduction()) console.warn(color + " color is not rgba");
629
+ return;
630
+ }
631
+ arr[3] = opacity;
632
+ return `rgba(${arr})`;
633
+ };
634
+ var isCSSVar = (v) => v.charCodeAt(0) === 45 && v.charCodeAt(1) === 45;
635
+ var CSS_NATIVE_COLOR_REGEX = /(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/;
636
+ var COLOR_TOKEN_REGEX = /^([a-zA-Z]\w*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/;
637
+ var parseColorToken = (value) => {
638
+ if (!isString(value)) return null;
639
+ if (CSS_NATIVE_COLOR_REGEX.test(value)) return { passthrough: value };
640
+ if (isCSSVar(value)) return { cssVar: value };
641
+ const match = value.match(COLOR_TOKEN_REGEX);
642
+ if (!match) return null;
643
+ const [, name, alphaDigits, rawTone] = match;
644
+ const alpha = alphaDigits !== void 0 ? `0.${alphaDigits}` : void 0;
645
+ const tone = rawTone && rawTone[0] === "=" ? rawTone.slice(1) : rawTone;
646
+ return { name, alpha, tone };
647
+ };
648
+ var isResolvedColor = (result) => {
649
+ return isString(result) && (result.includes("rgb") || result.includes("var(") || result.includes("#"));
650
+ };
651
+ var splitTopLevelCommas = (value) => {
652
+ const result = [];
653
+ let current = "";
654
+ let depth = 0;
655
+ for (const char of value) {
656
+ if (char === "(") depth += 1;
657
+ else if (char === ")" && depth > 0) depth -= 1;
658
+ if (char === "," && depth === 0) {
659
+ result.push(current);
660
+ current = "";
661
+ continue;
662
+ }
663
+ current += char;
664
+ }
665
+ if (current.length || !result.length) result.push(current);
666
+ return result;
667
+ };
668
+ var getRgbTone = (rgb, tone) => {
669
+ if (isString(rgb) && rgb.includes("rgb"))
670
+ rgb = colorStringToRgbaArray(rgb).join(", ");
671
+ if (isString(rgb)) rgb = rgb.split(",").map((v) => parseFloat(v.trim()));
672
+ if (isNumber(tone)) tone += "";
673
+ const toHex = rgbArrayToHex(rgb);
674
+ const abs = tone.slice(0, 1);
675
+ if (abs === "-" || abs === "+") {
676
+ const colorShade = getColorShade(toHex, parseFloat(tone));
677
+ return hexToRgbArray(colorShade).join(", ");
678
+ } else {
679
+ const [r, g, b] = rgb;
680
+ const hsl = rgbToHSL(r, g, b);
681
+ const [h, s, l] = hsl;
682
+ const newRgb = hslToRgb(h, s, parseFloat(tone) / 100 * 255);
683
+ return newRgb;
684
+ }
685
+ };
686
+
687
+ // src/utils/theme.js
688
+ var returnSubThemeOrDefault = (orig, theme) => {
689
+ if (!orig) return;
690
+ if (orig.themes && orig.themes[theme]) return orig.themes[theme];
691
+ if (orig[theme]) return [orig, orig[theme]];
692
+ return orig;
693
+ };
694
+
695
+ // src/utils/font.js
696
+ var getDefaultOrFirstKey = (LIBRARY, key) => {
697
+ if (LIBRARY[key]) return LIBRARY[key].value;
698
+ if (LIBRARY.default) return LIBRARY[LIBRARY.default].value;
699
+ const hasValue = Object.keys(LIBRARY)[0];
700
+ return hasValue && LIBRARY[hasValue] && LIBRARY[hasValue].value;
701
+ };
702
+ var getFontFormat = (url) => {
703
+ const ext = url.split(/[#?]/)[0].split(".").pop().trim();
704
+ if (["woff2", "woff", "ttf", "otf", "eot"].includes(ext)) return ext;
705
+ return null;
706
+ };
707
+ var isGoogleFontsUrl = (url) => url && (url.includes("fonts.googleapis.com") || url.includes("fonts.gstatic.com"));
708
+ var setFontImport = (url) => `@import url('${url}');`;
709
+ var setInCustomFontMedia = (str) => `@font-face { ${str} }`;
710
+ var setCustomFont = (name, url, weight, options = {}) => {
711
+ const format = getFontFormat(url);
712
+ const formatStr = format ? ` format('${format}')` : "";
713
+ return `
714
+ font-family: '${name}';
715
+ font-style: normal;${weight ? `
716
+ font-weight: ${weight};` : ""}${options.fontStretch ? `
717
+ font-stretch: ${options.fontStretch};` : ""}${options.fontDisplay ? `
718
+ font-display: ${options.fontDisplay};` : ""}
719
+ src: url('${url}')${formatStr};`;
720
+ };
721
+ var setCustomFontMedia = (name, url, weight, options) => `@font-face {${setCustomFont(name, url, weight, options)}
722
+ }`;
723
+ var getFontFaceEach = (name, weights) => {
724
+ const keys = Object.keys(weights);
725
+ return keys.map((key) => {
726
+ const { url, fontWeight } = weights[key];
727
+ return setCustomFont(name, url, fontWeight);
728
+ });
729
+ };
730
+ var getFontFace = (LIBRARY) => {
731
+ const keys = Object.keys(LIBRARY);
732
+ return keys.map((key) => getFontFaceEach(key, LIBRARY[key].value));
733
+ };
734
+ var getFontFaceEachString = (name, weights) => {
735
+ if (weights && weights.isVariable) {
736
+ if (isGoogleFontsUrl(weights.url)) {
737
+ return setFontImport(weights.url);
738
+ }
739
+ return setCustomFontMedia(name, weights.url, weights.fontWeight, {
740
+ fontStretch: weights.fontStretch,
741
+ fontDisplay: weights.fontDisplay || "swap"
742
+ });
743
+ }
744
+ const isArr = weights[0];
745
+ if (isArr) return getFontFaceEach(name, weights).map(setInCustomFontMedia);
746
+ return setCustomFontMedia(name, weights.url);
747
+ };
748
+ var getFontFaceString = (LIBRARY) => {
749
+ const keys = Object.keys(LIBRARY);
750
+ return keys.map((key) => getFontFaceEachString(key, LIBRARY[key].value));
751
+ };
752
+
753
+ // ../smbls-utils/dist/esm/index.js
754
+ var toCamelCase = (str) => {
755
+ return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
756
+ return index === 0 ? word.toLowerCase() : word.toUpperCase();
757
+ }).replaceAll(/\s+/g, "");
758
+ };
759
+ var toDashCase = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
760
+ var arrayzeValue = (val) => {
761
+ if (isArray(val)) return val;
762
+ if (isString(val)) return val.split(" ");
763
+ if (isObject(val)) return Object.values(val);
764
+ if (isNumber(val)) return [val];
765
+ };
766
+
767
+ // src/defaultConfig/index.js
768
+ var defaultConfig_exports = {};
769
+ __export(defaultConfig_exports, {
770
+ ANIMATION: () => ANIMATION,
771
+ BREAKPOINTS: () => BREAKPOINTS,
772
+ CASES: () => CASES,
773
+ CLASS: () => CLASS,
774
+ COLOR: () => COLOR,
775
+ DEVICES: () => DEVICES,
776
+ DOCUMENT: () => DOCUMENT,
777
+ FONT: () => FONT,
778
+ FONT_FACE: () => FONT_FACE,
779
+ FONT_FAMILY: () => FONT_FAMILY,
780
+ FONT_FAMILY_TYPES: () => FONT_FAMILY_TYPES,
781
+ GRADIENT: () => GRADIENT,
782
+ GRID: () => GRID,
783
+ ICONS: () => ICONS,
784
+ MEDIA: () => MEDIA,
785
+ RESET: () => RESET,
786
+ SEMANTIC_ICONS: () => SEMANTIC_ICONS,
787
+ SEQUENCE: () => SEQUENCE,
788
+ SHADOW: () => SHADOW,
789
+ SPACING: () => SPACING,
790
+ SVG: () => SVG,
791
+ SVG_DATA: () => SVG_DATA,
792
+ TEMPLATES: () => TEMPLATES,
793
+ THEME: () => THEME,
794
+ TIMING: () => TIMING,
795
+ TYPOGRAPHY: () => TYPOGRAPHY,
796
+ UNIT: () => UNIT
797
+ });
798
+
799
+ // src/defaultConfig/sequence.js
800
+ var SEQUENCE = {
801
+ "minor-second": 1.067,
802
+ "major-second": 1.125,
803
+ "minor-third": 1.2,
804
+ "major-third": 1.25,
805
+ "perfect-fourth": 1.333,
806
+ "augmented-fourth": 1.414,
807
+ "perfect-fifth": 1.5,
808
+ "minor-sixth": 1.6,
809
+ phi: 1.618,
810
+ // golden-ratio
811
+ "major-sixth": 1.667,
812
+ "square-root-3": 1.732,
813
+ // theodorus
814
+ "minor-seventh": 1.778,
815
+ "major-seventh": 1.875,
816
+ octave: 2,
817
+ "square-root-5": 2.23,
818
+ // pythagoras
819
+ "major-tenth": 2.5,
820
+ "major-eleventh": 2.667,
821
+ "major-twelfth": 3,
822
+ pi: 3.14,
823
+ // archimedes
824
+ "double-octave": 4
825
+ };
826
+
827
+ // src/defaultConfig/unit.js
828
+ var UNIT = {
829
+ default: "em"
830
+ };
831
+
832
+ // src/defaultConfig/typography.js
833
+ var defaultProps = {
834
+ browserDefault: 16,
835
+ base: 16,
836
+ type: "font-size",
837
+ ratio: SEQUENCE["minor-third"],
838
+ range: [-3, 12],
839
+ h1Matches: 6,
840
+ lineHeight: 1.5,
841
+ subSequence: true,
842
+ mediaRegenerate: false,
843
+ unit: "em",
844
+ templates: {},
845
+ sequence: {},
846
+ scales: {},
847
+ vars: {}
848
+ };
849
+ var TYPOGRAPHY = defaultProps;
850
+
851
+ // src/defaultConfig/font.js
852
+ var FONT = {};
853
+
854
+ // src/defaultConfig/font-family.js
855
+ var FONT_FAMILY = {};
856
+ var FONT_FAMILY_TYPES = {
857
+ "sans-serif": "Helvetica, Arial, sans-serif, --system-default",
858
+ serif: "Times New Roman, Georgia, serif, --system-default",
859
+ monospace: "Courier New, monospace, --system-default"
860
+ };
861
+ var FONT_FACE = {};
862
+
863
+ // src/defaultConfig/media.js
864
+ var MEDIA = {
865
+ tv: "(min-width: 2780px)",
866
+ light: "(prefers-color-scheme: light)",
867
+ dark: "(prefers-color-scheme: dark)",
868
+ print: "print"
869
+ };
870
+
871
+ // src/defaultConfig/spacing.js
872
+ var defaultProps2 = {
873
+ base: TYPOGRAPHY.base,
874
+ type: "spacing",
875
+ ratio: SEQUENCE.phi,
876
+ range: [-5, 15],
877
+ subSequence: true,
878
+ mediaRegenerate: false,
879
+ unit: "em",
880
+ sequence: {},
881
+ scales: {},
882
+ vars: {}
883
+ };
884
+ var SPACING = defaultProps2;
885
+
886
+ // src/defaultConfig/color.js
887
+ var COLOR = {};
888
+ var GRADIENT = {};
889
+
890
+ // src/defaultConfig/theme.js
891
+ var THEME = {};
892
+
893
+ // src/defaultConfig/shadow.js
894
+ var SHADOW = {};
895
+
896
+ // src/defaultConfig/icons.js
897
+ var ICONS = {};
898
+ var SEMANTIC_ICONS = {};
899
+
900
+ // src/defaultConfig/timing.js
901
+ var defaultProps3 = {
902
+ default: 150,
903
+ base: 150,
904
+ type: "timing",
905
+ ratio: SEQUENCE["perfect-fourth"],
906
+ range: [-3, 12],
907
+ mediaRegenerate: false,
908
+ unit: "ms",
909
+ sequence: {},
910
+ scales: {},
911
+ vars: {}
912
+ };
913
+ var TIMING = defaultProps3;
914
+
915
+ // src/defaultConfig/document.js
916
+ var DOCUMENT = {};
917
+
918
+ // src/defaultConfig/responsive.js
919
+ var BREAKPOINTS = {
920
+ screenL: 1920,
921
+ screenM: 1680,
922
+ screenS: 1440,
923
+ tabletL: 1366,
924
+ tabletM: 1280,
925
+ tabletS: 1024,
926
+ mobileL: 768,
927
+ mobileM: 560,
928
+ mobileS: 480,
929
+ mobileXS: 375
930
+ };
931
+ var DEVICES = {
932
+ screenXXL: [2560, 1440],
933
+ screenXL: [2240, 1260],
934
+ screenL: [1920, 1024],
935
+ screenM: [1680, 1024],
936
+ screenS: [1440, 720],
937
+ tabletL: [1366, 926],
938
+ tabletM: [1280, 768],
939
+ tabletS: [1024, 768],
940
+ mobileL: [768, 375],
941
+ mobileM: [560, 768],
942
+ mobileS: [480, 768],
943
+ mobileXS: [375, 768]
944
+ };
945
+
946
+ // src/defaultConfig/cases.js
947
+ var CASES = {};
948
+
949
+ // src/defaultConfig/animation.js
950
+ var ANIMATION = {};
951
+
952
+ // src/defaultConfig/svg.js
953
+ var SVG = {};
954
+ var SVG_DATA = {};
955
+
956
+ // src/defaultConfig/templates.js
957
+ var TEMPLATES = {};
958
+
959
+ // src/defaultConfig/grid.js
960
+ var defaultProps4 = {};
961
+ var GRID = defaultProps4;
962
+
963
+ // src/defaultConfig/class.js
964
+ var defaultProps5 = {};
965
+ var CLASS = defaultProps5;
966
+
967
+ // src/defaultConfig/index.js
968
+ var RESET = {};
969
+
970
+ // src/factory.js
971
+ var CSS_VARS = {};
972
+ var CONFIG = {
973
+ verbose: false,
974
+ useVariable: true,
975
+ useReset: true,
976
+ CSS_VARS,
977
+ ...void 0 || defaultConfig_exports
978
+ };
979
+ var cachedConfig = deepClone(CONFIG);
980
+ var FACTORY = {
981
+ active: "0",
982
+ 0: CONFIG
983
+ };
984
+ var activateConfig = (def) => {
985
+ if (isDefined(def)) {
986
+ FACTORY.active = def;
987
+ }
988
+ return FACTORY[def || FACTORY.active];
989
+ };
990
+ var getActiveConfig = (def) => {
991
+ return FACTORY[def || FACTORY.active] || CONFIG;
992
+ };
993
+ var setActiveConfig = (newConfig) => {
994
+ if (!isObject(newConfig)) return;
995
+ FACTORY.active = "1";
996
+ FACTORY["1"] = deepMerge(newConfig, deepClone(cachedConfig));
997
+ return newConfig;
998
+ };
999
+
1000
+ // src/utils/sequence.js
1001
+ var numToLetterMap = {
1002
+ "-6": "U",
1003
+ "-5": "V",
1004
+ "-4": "W",
1005
+ "-3": "X",
1006
+ "-2": "Y",
1007
+ "-1": "Z",
1008
+ 0: "A",
1009
+ 1: "B",
1010
+ 2: "C",
1011
+ 3: "D",
1012
+ 4: "E",
1013
+ 5: "F",
1014
+ 6: "G",
1015
+ 7: "H",
1016
+ 8: "I",
1017
+ 9: "J",
1018
+ 10: "K",
1019
+ 11: "L",
1020
+ 12: "M",
1021
+ 13: "N",
1022
+ 14: "O",
1023
+ 15: "P",
1024
+ 16: "Q",
1025
+ 17: "R",
1026
+ 18: "S",
1027
+ 19: "T"
1028
+ };
1029
+ var setSequenceValue = (props, sequenceProps) => {
1030
+ const { key, variable, value, scaling, index, scalingVariable } = props;
1031
+ sequenceProps.sequence[key] = {
1032
+ key,
1033
+ decimal: ~~(value * 100) / 100,
1034
+ val: ~~value,
1035
+ scaling,
1036
+ index,
1037
+ scalingVariable,
1038
+ variable
1039
+ };
1040
+ sequenceProps.scales[key] = scaling;
1041
+ sequenceProps.vars[variable] = scaling + sequenceProps.unit;
1042
+ };
1043
+ var getFnPrefixAndValue = (val) => {
1044
+ if (!val.includes("(")) return val;
1045
+ const prefix = val.split("(")[0];
1046
+ const value = val.slice(val.indexOf("(") + 1, val.lastIndexOf(")"));
1047
+ return [prefix, value];
1048
+ };
1049
+ var setScalingVar = (key, sequenceProps) => {
1050
+ const { base, type, unit } = sequenceProps;
1051
+ const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
1052
+ if (key === 0) return defaultVal;
1053
+ const prefix = "--" + (type && type.replace(".", "-"));
1054
+ const ratioVar = `${prefix}-ratio`;
1055
+ if (key > 0) {
1056
+ const prevLetterKey = numToLetterMap[key - 1];
1057
+ return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
1058
+ }
1059
+ if (key < 0) {
1060
+ const nextLetterKey = numToLetterMap[key + 1];
1061
+ return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
1062
+ }
1063
+ };
1064
+ var setSubScalingVar = (index, arr, variable, sequenceProps) => {
1065
+ const { type } = sequenceProps;
1066
+ const skipMiddle = index === 2 && arr.length === 2;
1067
+ const indexMapWithLength = skipMiddle ? index + 1 : index;
1068
+ const prefix = "--" + (type && type.replace(".", "-"));
1069
+ const subRatioVarPrefix = `${prefix}-sub-ratio-`;
1070
+ return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
1071
+ };
1072
+ var getSubratioDifference = (base, ratio) => {
1073
+ const diff = base * ratio - base;
1074
+ const subRatio = diff / 1.618;
1075
+ const first = base * ratio - subRatio;
1076
+ const second = base + subRatio;
1077
+ const middle = (first + second) / 2;
1078
+ return [first, middle, second];
1079
+ };
1080
+ var getSubratio = (base, ratio) => {
1081
+ return getSubratioDifference(base, ratio).map((v) => v / base);
1082
+ };
1083
+ var generateSubSequence = (props, sequenceProps) => {
1084
+ const { key, base, value, ratio, variable, index } = props;
1085
+ const next = value * ratio;
1086
+ const diffRounded = ~~next - ~~value;
1087
+ let arr;
1088
+ const [first, middle, second] = getSubratioDifference(value, ratio);
1089
+ if (diffRounded > 16) arr = [first, middle, second];
1090
+ else arr = [first, second];
1091
+ arr.forEach((v, k) => {
1092
+ const scaling = ~~(v / base * 1e3) / 1e3;
1093
+ const newVar = variable + (k + 1);
1094
+ const newIndex = index + (k + 1) / 10;
1095
+ const scalingVariable = setSubScalingVar(
1096
+ k + 1,
1097
+ arr,
1098
+ variable,
1099
+ sequenceProps
1100
+ );
1101
+ const props2 = {
1102
+ key: key + (k + 1),
1103
+ variable: newVar,
1104
+ value: v,
1105
+ scaling,
1106
+ scalingVariable,
1107
+ index: newIndex
1108
+ };
1109
+ setSequenceValue(props2, sequenceProps);
1110
+ });
1111
+ };
1112
+ var switchSequenceOnNegative = (key, base, ratio) => {
1113
+ return base * Math.pow(ratio, key);
1114
+ };
1115
+ var generateSequence = (sequenceProps) => {
1116
+ const { type, base, ratio, range, subSequence } = sequenceProps;
1117
+ const n = Math.abs(range[0]) + Math.abs(range[1]);
1118
+ const prefix = "--" + (type && type.replace(".", "-")) + "-";
1119
+ for (let i = 0; i <= n; i++) {
1120
+ const key = range[1] - i;
1121
+ const letterKey = numToLetterMap[key];
1122
+ const value = switchSequenceOnNegative(key, base, ratio);
1123
+ const scaling = ~~(value / base * 100) / 100;
1124
+ const variable = prefix + letterKey;
1125
+ const scalingVariable = setScalingVar(key, sequenceProps);
1126
+ const props = {
1127
+ key: letterKey,
1128
+ variable,
1129
+ value,
1130
+ base,
1131
+ scaling,
1132
+ scalingVariable,
1133
+ ratio,
1134
+ index: key
1135
+ };
1136
+ setSequenceValue(props, sequenceProps);
1137
+ if (subSequence) generateSubSequence(props, sequenceProps);
1138
+ }
1139
+ return sequenceProps;
1140
+ };
1141
+ var generateSequencePosition = (sequenceProps, position = 0) => {
1142
+ const { type, base, ratio, subSequence } = sequenceProps;
1143
+ const letterKey = isString(position) ? position : numToLetterMap[position];
1144
+ const index = isString(position) ? Object.entries(numToLetterMap).find(
1145
+ ([, value2]) => value2 === position
1146
+ )?.[0] : position;
1147
+ if (!letterKey) {
1148
+ console.warn(`Position ${position} is out of range in numToLetterMap`);
1149
+ return null;
1150
+ }
1151
+ const result = {
1152
+ sequence: {},
1153
+ scales: {},
1154
+ vars: {},
1155
+ ...sequenceProps
1156
+ };
1157
+ const value = base * Math.pow(ratio, index);
1158
+ const scaling = ~~(value / base * 100) / 100;
1159
+ const prefix = "--" + (type && type.replace(".", "-")) + "-";
1160
+ const variable = prefix + letterKey;
1161
+ const scalingVariable = setScalingVar(index, sequenceProps);
1162
+ const props = {
1163
+ key: letterKey,
1164
+ variable,
1165
+ value,
1166
+ base,
1167
+ scaling,
1168
+ scalingVariable,
1169
+ ratio,
1170
+ index
1171
+ };
1172
+ setSequenceValue(props, result);
1173
+ if (subSequence) {
1174
+ generateSubSequence(props, result);
1175
+ }
1176
+ return result;
1177
+ };
1178
+ var getSequenceValue = (value = "A", sequenceProps) => {
1179
+ const CONFIG2 = getActiveConfig();
1180
+ const { UNIT: UNIT2 } = CONFIG2;
1181
+ if (isString(value) && isCSSVar(value)) return `var(${value})`;
1182
+ const { sequence, unit = UNIT2.default, useVariable } = sequenceProps;
1183
+ const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
1184
+ const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
1185
+ const hasUnits = CSS_UNITS.some((unit2) => value.includes(unit2));
1186
+ if (hasUnits || !startsWithDashOrLetter) return value;
1187
+ const skipArr = [
1188
+ "none",
1189
+ "auto",
1190
+ "max-content",
1191
+ "min-content",
1192
+ "fit-content",
1193
+ "inherit",
1194
+ "initial",
1195
+ "unset",
1196
+ "revert",
1197
+ "revert-layer"
1198
+ ];
1199
+ if (skipArr.includes(value)) return value;
1200
+ const prefix = `--${toDashCase(sequenceProps.type.replace(".", "-"))}-`;
1201
+ const letterVal = value.toUpperCase();
1202
+ const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
1203
+ let absValue = isNegative ? letterVal.slice(1) : letterVal;
1204
+ let mediaName = "";
1205
+ if (absValue.includes("_")) {
1206
+ mediaName = "_" + absValue.split("_")[1].toLowerCase();
1207
+ absValue = absValue.split("_")[0];
1208
+ }
1209
+ const varValue = (v) => startsWithDashOrLetterRegex.test(v) ? `var(${prefix}${v}${mediaName})` : v;
1210
+ if (absValue.includes("+")) {
1211
+ const [first, second] = absValue.split("+");
1212
+ const joint = `${varValue(first)} + ${varValue(second)}`;
1213
+ return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
1214
+ } else if (absValue.includes("*")) {
1215
+ const [first, second] = absValue.split("*");
1216
+ const joint = `${varValue(first)} * ${varValue(second)}`;
1217
+ return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
1218
+ } else if (absValue.includes("-")) {
1219
+ const [first, second] = absValue.split("-");
1220
+ const joint = `${varValue(first)} - ${varValue(second)}`;
1221
+ return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
1222
+ }
1223
+ if (!sequence[absValue] && absValue.length === 2) {
1224
+ if (CONFIG2.verbose)
1225
+ console.warn(
1226
+ absValue,
1227
+ "- value is not found because `subSequence` is set to false"
1228
+ );
1229
+ absValue = absValue.slice(0, 1);
1230
+ }
1231
+ if (useVariable || CONFIG2.useVariable) {
1232
+ const varValue2 = `var(${prefix}${absValue}${mediaName})`;
1233
+ return isNegative ? `calc(${varValue2} * -1)` : varValue2;
1234
+ }
1235
+ const sequenceItem = sequence ? sequence[absValue] : null;
1236
+ if (!sequenceItem) return console.warn("can't find", sequence, absValue);
1237
+ if (unit === "ms" || unit === "s") {
1238
+ return isNegative + sequenceItem.val + unit;
1239
+ }
1240
+ return isNegative + sequenceItem.scaling + unit;
1241
+ };
1242
+ var getSequenceValueBySymbols = (value, sequenceProps) => {
1243
+ const mathArr = ["+", "-", "*", "/", ","].filter(
1244
+ (v) => value.includes(v + " ")
1245
+ );
1246
+ if (!mathArr.length) return value;
1247
+ return mathArr.map((symbol) => {
1248
+ const valuesArr = value.split(symbol + " ").map((v) => v.trim());
1249
+ const transformedValues = valuesArr.map((v) => {
1250
+ return getSequenceValue(v, sequenceProps);
1251
+ });
1252
+ return transformedValues.join(" " + symbol + " ");
1253
+ }).join("");
1254
+ };
1255
+ var getSequenceValuePropertyPair = (value, propertyName, sequenceProps, fnPrefix) => {
1256
+ if (typeof value !== "string") {
1257
+ const CONFIG2 = getActiveConfig();
1258
+ if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
1259
+ return { [propertyName]: value };
1260
+ }
1261
+ if (value === "-" || value === "") return {};
1262
+ if (!fnPrefix && value.includes("(")) {
1263
+ const fnArr = getFnPrefixAndValue(value);
1264
+ fnPrefix = fnArr[0];
1265
+ value = fnArr[1];
1266
+ }
1267
+ const mathArr = ["+", "-", "*", "/", ","].filter(
1268
+ (v) => value.includes(v + " ")
1269
+ );
1270
+ if (mathArr.length) {
1271
+ value = getSequenceValueBySymbols(value, sequenceProps);
1272
+ } else value = getSequenceValue(value, sequenceProps);
1273
+ return { [propertyName]: fnPrefix ? `${fnPrefix}(${value})` : value };
1274
+ };
1275
+ var findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
1276
+ var findHeadings = (propertyNames) => {
1277
+ const { h1Matches, sequence } = propertyNames;
1278
+ return new Array(6).fill(null).map((_, i) => {
1279
+ const findLetter = findHeadingLetter(h1Matches, i);
1280
+ return sequence[findLetter];
1281
+ });
1282
+ };
1283
+
1284
+ // src/utils/var.js
1285
+ var setVariables = (result, key) => {
1286
+ const CONFIG2 = getActiveConfig();
1287
+ const { CSS_VARS: CSS_VARS2 } = CONFIG2;
1288
+ if (isObjectLike(result.value)) {
1289
+ } else {
1290
+ CSS_VARS2[result.var] = result.value;
1291
+ }
1292
+ };
1293
+ var applySequenceGlobalVars = (vars, obj, options) => {
1294
+ const CONFIG2 = getActiveConfig();
1295
+ const { UNIT: UNIT2 } = CONFIG2;
1296
+ const unit = obj.unit || UNIT2.default;
1297
+ const { base, ratio, type } = obj;
1298
+ const prefix = "--" + (type && type.replace(".", "-"));
1299
+ vars[`${prefix}-base`] = base;
1300
+ vars[`${prefix}-unit`] = unit;
1301
+ const ratioVar = `${prefix}-ratio`;
1302
+ vars[ratioVar] = ratio;
1303
+ const [first, middle, second] = getSubratio(base, ratio);
1304
+ vars[`${prefix}-sub-ratio-1`] = `calc(var(${prefix}-ratio) * ${first / ratio})`;
1305
+ vars[`${prefix}-sub-ratio-2`] = `calc(var(${prefix}-ratio) * ${middle / ratio})`;
1306
+ vars[`${prefix}-sub-ratio-3`] = `calc(var(${prefix}-ratio) * ${second / ratio})`;
1307
+ };
1308
+ var applySequenceVars = (FACTORY2, options = {}) => {
1309
+ const CONFIG2 = getActiveConfig();
1310
+ const { UNIT: UNIT2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
1311
+ const unit = FACTORY2.unit || UNIT2.default;
1312
+ const { mediaRegenerate, sequence, scales } = FACTORY2;
1313
+ if (!mediaRegenerate) {
1314
+ applySequenceGlobalVars(CSS_VARS2, FACTORY2, options);
1315
+ }
1316
+ for (const key in sequence) {
1317
+ const item = sequence[key];
1318
+ const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
1319
+ if (!mediaRegenerate) {
1320
+ CSS_VARS2[item.variable + "_default"] = value;
1321
+ CSS_VARS2[item.variable] = item.scalingVariable;
1322
+ continue;
1323
+ }
1324
+ if (options.useDefault === false) {
1325
+ CSS_VARS2[item.variable] = value;
1326
+ } else {
1327
+ CSS_VARS2[item.variable + "_default"] = value;
1328
+ CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
1329
+ }
1330
+ }
1331
+ };
1332
+ var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
1333
+ const CONFIG2 = getActiveConfig();
1334
+ const { UNIT: UNIT2, MEDIA: MEDIA2, CSS_VARS: CSS_VARS2 } = CONFIG2;
1335
+ const mediaName = media.slice(1);
1336
+ const unit = FACTORY2.unit || UNIT2.default;
1337
+ const { mediaRegenerate } = FACTORY2;
1338
+ const { sequence, scales } = FACTORY2[media];
1339
+ const query = MEDIA2[mediaName];
1340
+ if (!query && CONFIG2.verbose) console.warn("Can't find media query ", query);
1341
+ if (!mediaRegenerate) {
1342
+ let underMediaQuery = CSS_VARS2[`@media ${query}`];
1343
+ if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
1344
+ applySequenceGlobalVars(underMediaQuery, FACTORY2[media], options);
1345
+ return;
1346
+ }
1347
+ for (const key in sequence) {
1348
+ const item = sequence[key];
1349
+ const value = (isScalingUnit(unit) ? scales[key] : sequence[key].val) + unit;
1350
+ if (!query && CONFIG2.verbose) console.warn("Can't find query ", query);
1351
+ let underMediaQuery = CSS_VARS2[`@media ${query}`];
1352
+ if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
1353
+ underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
1354
+ CSS_VARS2[item.variable + "_" + mediaName] = value;
1355
+ }
1356
+ };
1357
+
1358
+ // src/utils/sprite.js
1359
+ var isDev = isNotProduction();
1360
+ var generateSprite = (icons) => {
1361
+ const CONFIG2 = getActiveConfig();
1362
+ let sprite = "";
1363
+ for (const key in icons) {
1364
+ if (CONFIG2.__svg_cache[key]) continue;
1365
+ else CONFIG2.__svg_cache[key] = true;
1366
+ sprite += icons[key];
1367
+ }
1368
+ return sprite;
1369
+ };
1370
+ var parseRootAttributes = (htmlString) => {
1371
+ const val = htmlString.default || htmlString;
1372
+ if (!isString(val)) {
1373
+ if (isDev) console.warn("parseRootAttributes:", val, "is not a string");
1374
+ return;
1375
+ }
1376
+ const match = val.match(/<svg\s+(.*?)>/);
1377
+ if (!match || !match[1]) {
1378
+ return {};
1379
+ }
1380
+ const attrString = match[1];
1381
+ const attrs = attrString.match(
1382
+ /(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm
1383
+ );
1384
+ return attrs.reduce((acc, attr) => {
1385
+ const [key, value] = attr.split("=");
1386
+ acc[key] = value.replace(/['"]/g, "");
1387
+ return acc;
1388
+ }, {});
1389
+ };
1390
+ var replaceIdsAndUrls = (code, key) => {
1391
+ const idRegex = /id="([^"]*)"/;
1392
+ const urlRegex = /url\(#([^)]*)\)/g;
1393
+ const matches = code.match(/id="([^"]*)"/g);
1394
+ let replacedCode = code;
1395
+ if (isArray(matches)) {
1396
+ matches.forEach(() => {
1397
+ const randomKey = Math.floor(Math.random() * 1e5);
1398
+ replacedCode = code.replace(idRegex, `id="${key}-${randomKey}"`).replace(urlRegex, `url(#${key}-${randomKey})`);
1399
+ });
1400
+ }
1401
+ return replacedCode;
1402
+ };
1403
+ var convertSvgToSymbol = (key, code) => {
1404
+ const extractAttrs = parseRootAttributes(code);
1405
+ const { width, height } = extractAttrs;
1406
+ const viewBox = extractAttrs.viewBox || `0 0 ${width || 24} ${height || 24}`;
1407
+ const xmlns = "http://www.w3.org/2000/svg";
1408
+ const replacedCode = replaceIdsAndUrls(code, key);
1409
+ let symbol = replacedCode.replace(
1410
+ "<svg",
1411
+ `<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
1412
+ );
1413
+ symbol = symbol.replace(/width="[^"]*"/, "");
1414
+ symbol = symbol.replace(/height="[^"]*"/, "");
1415
+ symbol = symbol.replace("</svg", "</symbol");
1416
+ return symbol;
1417
+ };
1418
+
1419
+ // src/system/index.js
1420
+ var system_exports = {};
1421
+ __export(system_exports, {
1422
+ appendSVGSprite: () => appendSVGSprite,
1423
+ appendSvgIconsSprite: () => appendSvgIconsSprite,
1424
+ applyDocument: () => applyDocument,
1425
+ applyHeadings: () => applyHeadings,
1426
+ applyReset: () => applyReset,
1427
+ applySpacingSequence: () => applySpacingSequence,
1428
+ applyTimingSequence: () => applyTimingSequence,
1429
+ applyTypographySequence: () => applyTypographySequence,
1430
+ checkIfBoxSize: () => checkIfBoxSize,
1431
+ getColor: () => getColor,
1432
+ getFontFamily: () => getFontFamily,
1433
+ getFontSizeByKey: () => getFontSizeByKey,
1434
+ getMediaColor: () => getMediaColor,
1435
+ getMediaTheme: () => getMediaTheme,
1436
+ getShadow: () => getShadow,
1437
+ getSpacingBasedOnRatio: () => getSpacingBasedOnRatio,
1438
+ getSpacingByKey: () => getSpacingByKey,
1439
+ getTheme: () => getTheme,
1440
+ getTimingByKey: () => getTimingByKey,
1441
+ getTimingFunction: () => getTimingFunction,
1442
+ runThroughMedia: () => runThroughMedia,
1443
+ setColor: () => setColor,
1444
+ setFont: () => setFont,
1445
+ setFontFamily: () => setFontFamily,
1446
+ setGradient: () => setGradient,
1447
+ setMediaTheme: () => setMediaTheme,
1448
+ setSVG: () => setSVG,
1449
+ setShadow: () => setShadow,
1450
+ setSvgIcon: () => setSvgIcon,
1451
+ setTheme: () => setTheme,
1452
+ splitSpacedValue: () => splitSpacedValue
1453
+ });
1454
+
1455
+ // src/system/color.js
1456
+ var getColor = (value, key, config) => {
1457
+ const CONFIG2 = config || getActiveConfig();
1458
+ if (!isString(value)) {
1459
+ if (CONFIG2.verbose) console.warn(value, "- type for color is not valid");
1460
+ return;
1461
+ }
1462
+ if (isCSSVar(value)) return `var(${value})`;
1463
+ if (key && value[key]) value = value[key];
1464
+ let name, alpha, tone;
1465
+ if (isArray(value)) {
1466
+ [name, alpha, tone] = value;
1467
+ } else {
1468
+ const parsed = parseColorToken(value);
1469
+ if (!parsed) return value;
1470
+ if (parsed.passthrough) return parsed.passthrough;
1471
+ if (parsed.cssVar) return `var(${parsed.cssVar})`;
1472
+ name = parsed.name;
1473
+ alpha = parsed.alpha;
1474
+ tone = parsed.tone;
1475
+ }
1476
+ const { COLOR: COLOR2, GRADIENT: GRADIENT2 } = CONFIG2;
1477
+ let val = COLOR2[name] || GRADIENT2[name];
1478
+ if (!val) {
1479
+ if (CONFIG2.verbose) console.warn("Can't find color ", name);
1480
+ return value;
1481
+ }
1482
+ if (key) {
1483
+ if (val[key]) val = val[key];
1484
+ else if (CONFIG2.verbose) console.warn(value, " - does not have ", key);
1485
+ }
1486
+ let rgb = val.rgb;
1487
+ if (!rgb) {
1488
+ return CONFIG2.useVariable ? `var(${val.var})` : val.value;
1489
+ }
1490
+ if (tone && !val[tone]) {
1491
+ rgb = getRgbTone(rgb, tone);
1492
+ val[tone] = { rgb, var: `${val.var}-${tone}` };
1493
+ }
1494
+ if (val[tone]) rgb = val[tone].rgb;
1495
+ if (alpha) return `rgba(${rgb}, ${alpha})`;
1496
+ if (tone) return `rgba(${rgb}, 1)`;
1497
+ return CONFIG2.useVariable ? `var(${val.var})` : `rgb(${rgb})`;
1498
+ };
1499
+ var getMediaColor = (value, globalTheme, config) => {
1500
+ const CONFIG2 = config || getActiveConfig();
1501
+ if (!globalTheme) globalTheme = CONFIG2.globalTheme === "auto" ? null : CONFIG2.globalTheme;
1502
+ if (!isString(value)) {
1503
+ if (CONFIG2.verbose) console.warn(value, "- type for color is not valid");
1504
+ return;
1505
+ }
1506
+ if (isCSSVar(value)) return `var(${value})`;
1507
+ let name;
1508
+ if (isArray(value)) {
1509
+ name = value[0];
1510
+ } else {
1511
+ const parsed = parseColorToken(value);
1512
+ if (!parsed) return value;
1513
+ if (parsed.passthrough) return parsed.passthrough;
1514
+ if (parsed.cssVar) return `var(${parsed.cssVar})`;
1515
+ name = parsed.name;
1516
+ }
1517
+ const { COLOR: COLOR2, GRADIENT: GRADIENT2 } = CONFIG2;
1518
+ const val = COLOR2[name] || GRADIENT2[name];
1519
+ const isObj = isObject(val);
1520
+ if (isObj && val.value) return getColor(value, `@${globalTheme}`, config);
1521
+ else if (isObj) {
1522
+ if (globalTheme) return getColor(value, `@${globalTheme}`, config);
1523
+ else {
1524
+ const obj = {};
1525
+ for (const mediaName in val) {
1526
+ const query = CONFIG2.MEDIA[mediaName.slice(1)];
1527
+ const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
1528
+ obj[media] = getColor(value, mediaName, config);
1529
+ }
1530
+ return obj;
1531
+ }
1532
+ } else {
1533
+ if (CONFIG2.verbose) console.warn("Can't find color", value);
1534
+ return value;
1535
+ }
1536
+ };
1537
+ var setColor = (val, key, suffix) => {
1538
+ const CONFIG2 = getActiveConfig();
1539
+ if (isString(val) && isCSSVar(val)) {
1540
+ const rawRef = val.slice(2);
1541
+ val = getColor(rawRef);
1542
+ if (!(val.includes("rgb") || val.includes("var") || val.includes("#"))) {
1543
+ const parts = rawRef.split(" ");
1544
+ const refColor = CONFIG2.COLOR[parts[0]];
1545
+ if (refColor && refColor.value) {
1546
+ if (parts[1] !== void 0) {
1547
+ val = `rgba(${refColor.rgb}, ${parts[1]})`;
1548
+ } else {
1549
+ val = refColor.value;
1550
+ }
1551
+ } else {
1552
+ if (CONFIG2.verbose) console.warn(val, "- referred but does not exist");
1553
+ val = parts[0];
1554
+ }
1555
+ }
1556
+ }
1557
+ if (isArray(val)) {
1558
+ return {
1559
+ "@light": setColor(val[0], key, "light"),
1560
+ "@dark": setColor(val[1], key, "dark")
1561
+ };
1562
+ }
1563
+ if (isObject(val)) {
1564
+ const obj = {};
1565
+ for (const variant in val) {
1566
+ obj[variant] = setColor(
1567
+ val[variant],
1568
+ key,
1569
+ variant.slice(0, 1) === "@" ? variant.slice(1) : variant
1570
+ );
1571
+ }
1572
+ return obj;
1573
+ }
1574
+ const CSSVar = `--color-${key}` + (suffix ? `-${suffix}` : "");
1575
+ const colorArr = colorStringToRgbaArray(val.value || val);
1576
+ const [r, g, b, a = 1] = colorArr;
1577
+ const alpha = parseFloat(a.toFixed(2));
1578
+ const rgb = `${r}, ${g}, ${b}`;
1579
+ const value = `rgba(${rgb}, ${alpha})`;
1580
+ if (CONFIG2.useVariable) {
1581
+ CONFIG2.CSS_VARS[CSSVar] = value;
1582
+ }
1583
+ return {
1584
+ var: CSSVar,
1585
+ rgb,
1586
+ alpha,
1587
+ value
1588
+ };
1589
+ };
1590
+ var setGradient = (val, key, suffix) => {
1591
+ const CONFIG2 = getActiveConfig();
1592
+ if (isString(val) && isCSSVar(val)) val = getColor(val.slice(2));
1593
+ if (isArray(val)) {
1594
+ return {
1595
+ "@light": setGradient(val[0], key, "light"),
1596
+ "@dark": setGradient(val[0], key, "dark")
1597
+ };
1598
+ }
1599
+ if (isObject(val)) {
1600
+ const obj = {};
1601
+ for (const variant in val) obj[variant] = setGradient(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
1602
+ return obj;
1603
+ }
1604
+ const CSSVar = `--gradient-${key}` + (suffix ? `-${suffix}` : "");
1605
+ if (CONFIG2.useVariable) {
1606
+ CONFIG2.CSS_VARS[CSSVar] = val.value || val;
1607
+ }
1608
+ return {
1609
+ var: CSSVar,
1610
+ value: val.value || val
1611
+ };
1612
+ };
1613
+
1614
+ // src/system/theme.js
1615
+ var setThemeValue = (theme) => {
1616
+ const value = {};
1617
+ const { state, media, helpers, ...rest } = theme;
1618
+ const keys = Object.keys(rest);
1619
+ keys.map((key) => {
1620
+ const conditions = ["color", "Color", "background", "border"];
1621
+ const isColor = conditions.some((k) => key.includes(k));
1622
+ return value[key] = isColor ? getColor(theme[key]) : theme[key];
1623
+ });
1624
+ return value;
1625
+ };
1626
+ var getThemeValue = (theme) => {
1627
+ if (theme.value) return theme.value;
1628
+ theme.value = setThemeValue(theme);
1629
+ return theme.value;
1630
+ };
1631
+ var getTheme = (value, modifier) => {
1632
+ const CONFIG2 = getActiveConfig();
1633
+ if (CONFIG2.useVariable) return getMediaTheme(value, modifier);
1634
+ const { THEME: THEME2 } = CONFIG2;
1635
+ if (isString(value)) {
1636
+ const [theme, subtheme] = value.split(" ");
1637
+ const isOurTheme = THEME2[theme];
1638
+ if (isOurTheme) {
1639
+ if (!subtheme && !modifier) return getThemeValue(isOurTheme);
1640
+ value = [theme, subtheme || modifier];
1641
+ }
1642
+ }
1643
+ if (isObjectLike(value) && value[1]) {
1644
+ const themeName = value[0];
1645
+ const subThemeName = value[1];
1646
+ const { helpers, media, state } = THEME2[themeName];
1647
+ if (media && media[subThemeName]) return getThemeValue(media[subThemeName]);
1648
+ if (helpers && helpers[subThemeName]) return getThemeValue(helpers[subThemeName]);
1649
+ if (state && state[subThemeName]) return getThemeValue(state[subThemeName]);
1650
+ } else if (isObject(value)) return setThemeValue(value);
1651
+ };
1652
+ var setInverseTheme = (theme, variant, value) => {
1653
+ if (isObject(variant)) {
1654
+ theme.variants.inverse.value = setThemeValue(variant);
1655
+ } else if (variant === true) {
1656
+ const { color, background } = value;
1657
+ theme.variants.inverse = {
1658
+ value: {
1659
+ color: background,
1660
+ background: color
1661
+ }
1662
+ };
1663
+ }
1664
+ };
1665
+ var setPseudo = (theme, key, variant, themeValue) => {
1666
+ const result = getTheme(variant);
1667
+ themeValue[`&:${key}`] = result;
1668
+ if (isObject(variant) && !variant.value) variant.value = result;
1669
+ };
1670
+ var setSelectors = (theme, value) => {
1671
+ const { state } = theme;
1672
+ if (!state) return;
1673
+ const keys = Object.keys(state);
1674
+ keys.map((key) => {
1675
+ const variant = state[key];
1676
+ setPseudo(theme, key, variant, value);
1677
+ return theme;
1678
+ });
1679
+ return theme;
1680
+ };
1681
+ var setPrefersScheme = (theme, key, variant, themeValue) => {
1682
+ const result = getTheme(variant);
1683
+ themeValue[`@media (prefers-color-scheme: ${key})`] = result;
1684
+ if (isObject(variant) && !variant.value) variant.value = result;
1685
+ };
1686
+ var setMedia = (theme, value) => {
1687
+ const { media } = theme;
1688
+ if (!media) return;
1689
+ const keys = Object.keys(media);
1690
+ keys.map((key) => {
1691
+ const variant = media[key];
1692
+ if (key === "dark" || key === "light") setPrefersScheme(theme, key, variant, value);
1693
+ if (key === "inverse") setInverseTheme(theme, variant, value);
1694
+ return theme;
1695
+ });
1696
+ return theme;
1697
+ };
1698
+ var setHelpers = (theme, value) => {
1699
+ const CONFIG2 = getActiveConfig();
1700
+ const { helpers } = theme;
1701
+ if (!helpers) return;
1702
+ const keys = Object.keys(helpers);
1703
+ keys.map((key) => {
1704
+ const helper = helpers[key];
1705
+ if (isString(helper)) helpers[key] = CONFIG2.THEME[helper];
1706
+ else getThemeValue(helpers[key]);
1707
+ return theme;
1708
+ });
1709
+ return theme;
1710
+ };
1711
+ var setTheme = (val, key) => {
1712
+ const CONFIG2 = getActiveConfig();
1713
+ if (CONFIG2.useVariable) return setMediaTheme(val, key);
1714
+ const { state, media, helpers } = val;
1715
+ const value = setThemeValue(val, key);
1716
+ const CSSvar = `--theme-${key}`;
1717
+ setSelectors(val, value);
1718
+ setMedia(val, value);
1719
+ setHelpers(val, value);
1720
+ return { var: CSSvar, value, state, media, helpers };
1721
+ };
1722
+ var setMediaTheme = (val, key, suffix, prefers) => {
1723
+ const CONFIG2 = getActiveConfig();
1724
+ const { CSS_VARS: CSS_VARS2 } = CONFIG2;
1725
+ const theme = { value: val };
1726
+ if (isObjectLike(val)) {
1727
+ for (const param in val) {
1728
+ const symb = param.slice(0, 1);
1729
+ const value = val[param];
1730
+ if (symb === "@" || symb === ":" || symb === ".") {
1731
+ const hasPrefers = symb === "@" && param;
1732
+ theme[param] = setMediaTheme(value, key, param, prefers || hasPrefers);
1733
+ } else {
1734
+ const color = getColor(value, prefers);
1735
+ const metaSuffixes = [...new Set([prefers, suffix].filter((v) => v).map((v) => v.slice(1)))];
1736
+ const varmetaSuffixName = metaSuffixes.length ? "-" + metaSuffixes.join("-") : "";
1737
+ const CSSVar = `--theme-${key}${varmetaSuffixName}-${param}`;
1738
+ if (CONFIG2.useVariable) {
1739
+ CSS_VARS2[CSSVar] = color;
1740
+ theme[param] = `var(${CSSVar})`;
1741
+ } else {
1742
+ theme[param] = color;
1743
+ }
1744
+ theme[`.${param}`] = { [param]: theme[param] };
1745
+ }
1746
+ }
1747
+ if (theme.background || theme.color || theme.backgroundColor) {
1748
+ theme[".inversed"] = {
1749
+ color: theme.background || theme.backgroundColor,
1750
+ background: theme.color
1751
+ };
1752
+ }
1753
+ }
1754
+ if (isString(val) && isCSSVar(val)) {
1755
+ const { THEME: THEME2 } = CONFIG2;
1756
+ const value = THEME2[val.slice(2)];
1757
+ const getReferenced = getMediaTheme(value, prefers);
1758
+ return getReferenced;
1759
+ }
1760
+ return theme;
1761
+ };
1762
+ var recursiveTheme = (val) => {
1763
+ const CONFIG2 = getActiveConfig();
1764
+ const obj = {};
1765
+ for (const param in val) {
1766
+ const symb = param.slice(0, 1);
1767
+ if (isObjectLike(val[param])) {
1768
+ if (symb === "@") {
1769
+ const query = CONFIG2.MEDIA[param.slice(1)];
1770
+ const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
1771
+ obj[media] = recursiveTheme(val[param]);
1772
+ } else if (symb === ":") {
1773
+ obj[`&${param}`] = recursiveTheme(val[param]);
1774
+ }
1775
+ } else obj[param] = val[param];
1776
+ }
1777
+ return obj;
1778
+ };
1779
+ var findModifierFromArray = (val, modifierArray) => {
1780
+ const currentMod = modifierArray.shift();
1781
+ if (val[currentMod]) return findModifierFromArray(val[currentMod], modifierArray);
1782
+ return val;
1783
+ };
1784
+ var findModifier = (val, modifier) => {
1785
+ if (isArray(modifier)) return findModifierFromArray(val, modifier);
1786
+ else if (isString(modifier) && val[modifier]) return val[modifier];
1787
+ else return val;
1788
+ };
1789
+ var getMediaTheme = (value, modifier) => {
1790
+ const activeConfig = getActiveConfig();
1791
+ if (isString(value) && isCSSVar(value)) {
1792
+ value = getMediaTheme(value.slice(2));
1793
+ }
1794
+ if (!value || !isString(value)) {
1795
+ if (activeConfig.verbose) {
1796
+ console.warn(`${value} - Theme is not a string`);
1797
+ }
1798
+ return;
1799
+ }
1800
+ const [themeName, ...themeModifiers] = isArray(value) ? value : value.split(" ");
1801
+ let themeValue = activeConfig.THEME[themeName];
1802
+ if (themeValue && (themeModifiers || modifier)) {
1803
+ themeValue = findModifier(themeValue, themeModifiers.length ? themeModifiers : modifier);
1804
+ }
1805
+ const resolvedTheme = recursiveTheme(themeValue);
1806
+ return resolvedTheme;
1807
+ };
1808
+
1809
+ // src/system/font.js
1810
+ var setFont = (val, key) => {
1811
+ const CSSvar = `--font-${key}`;
1812
+ if (!val || isArray(val) && !val[0]) return;
1813
+ let fontFace;
1814
+ if (val.isVariable) {
1815
+ if (isGoogleFontsUrl(val.url)) {
1816
+ fontFace = setFontImport(val.url);
1817
+ } else {
1818
+ fontFace = setCustomFontMedia(key, val.url, val.fontWeight, {
1819
+ fontStretch: val.fontStretch,
1820
+ fontDisplay: val.fontDisplay || "swap"
1821
+ });
1822
+ }
1823
+ } else if (val[0]) {
1824
+ fontFace = getFontFaceEach(key, val);
1825
+ } else {
1826
+ fontFace = setCustomFontMedia(key, val.url);
1827
+ }
1828
+ return { var: CSSvar, value: val, fontFace };
1829
+ };
1830
+ var getFontFamily = (key, factory) => {
1831
+ const CONFIG2 = getActiveConfig();
1832
+ const { FONT_FAMILY: FONT_FAMILY2 } = CONFIG2;
1833
+ return getDefaultOrFirstKey(factory || FONT_FAMILY2, key);
1834
+ };
1835
+ var setFontFamily = (val, key) => {
1836
+ const CONFIG2 = getActiveConfig();
1837
+ const { FONT_FAMILY: FONT_FAMILY2, FONT_FAMILY_TYPES: FONT_FAMILY_TYPES2 } = CONFIG2;
1838
+ let { value, type } = val;
1839
+ if (val.isDefault) FONT_FAMILY2.default = key;
1840
+ if (isObject(value)) value = arrayzeValue(value);
1841
+ const CSSvar = `--font-family-${key}`;
1842
+ const str = `${value.join(", ")}, ${FONT_FAMILY_TYPES2[type]}`;
1843
+ return { var: CSSvar, value: str, arr: value, type };
1844
+ };
1845
+
1846
+ // src/system/typography.js
1847
+ var runThroughMedia = (FACTORY2) => {
1848
+ const CONFIG2 = getActiveConfig();
1849
+ const { TYPOGRAPHY: TYPOGRAPHY2, MEDIA: MEDIA2 } = CONFIG2;
1850
+ for (const prop in FACTORY2) {
1851
+ const isPropMedia = prop.slice(0, 1) === "@";
1852
+ const mediaValue = FACTORY2[prop];
1853
+ if (!isPropMedia) continue;
1854
+ const { mediaRegenerate } = FACTORY2;
1855
+ const mediaName = prop.slice(1);
1856
+ const { type, base, ratio, range, subSequence, h1Matches, unit } = FACTORY2;
1857
+ merge(mediaValue, {
1858
+ type,
1859
+ base,
1860
+ ratio,
1861
+ range,
1862
+ subSequence,
1863
+ h1Matches,
1864
+ unit
1865
+ });
1866
+ const query = MEDIA2[mediaName];
1867
+ const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
1868
+ TYPOGRAPHY2.templates[media] = {
1869
+ fontSize: mediaValue.base / TYPOGRAPHY2.browserDefault + unit
1870
+ };
1871
+ if (!mediaRegenerate) {
1872
+ applyMediaSequenceVars(FACTORY2, prop);
1873
+ continue;
1874
+ }
1875
+ merge(mediaValue, {
1876
+ sequence: {},
1877
+ scales: {},
1878
+ templates: {},
1879
+ vars: {}
1880
+ });
1881
+ generateSequence(mediaValue);
1882
+ applyMediaSequenceVars(FACTORY2, prop);
1883
+ }
1884
+ };
1885
+ var applyHeadings = (props) => {
1886
+ const CONFIG2 = getActiveConfig();
1887
+ if (props.h1Matches) {
1888
+ const unit = props.unit;
1889
+ const HEADINGS = findHeadings(props);
1890
+ const { templates } = props;
1891
+ for (const k in HEADINGS) {
1892
+ const headerName = `h${parseInt(k) + 1}`;
1893
+ const headerStyle = templates[headerName];
1894
+ templates[headerName] = {
1895
+ fontSize: CONFIG2.useVariable ? `var(${HEADINGS[k]?.variable})` : `${HEADINGS[k]?.scaling}${unit}`,
1896
+ margin: headerStyle ? headerStyle.margin : 0,
1897
+ lineHeight: headerStyle ? headerStyle.lineHeight : props.lineHeight,
1898
+ letterSpacing: headerStyle ? headerStyle.letterSpacing : props.letterSpacing,
1899
+ fontWeight: headerStyle ? headerStyle.fontWeight : 900 - k * 100
1900
+ };
1901
+ }
1902
+ }
1903
+ };
1904
+ var applyTypographySequence = () => {
1905
+ const CONFIG2 = getActiveConfig();
1906
+ const { TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
1907
+ generateSequence(TYPOGRAPHY2);
1908
+ applyHeadings(TYPOGRAPHY2);
1909
+ applySequenceVars(TYPOGRAPHY2);
1910
+ runThroughMedia(TYPOGRAPHY2);
1911
+ };
1912
+ var getFontSizeByKey = (value) => {
1913
+ const CONFIG2 = getActiveConfig();
1914
+ const { TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
1915
+ return getSequenceValuePropertyPair(value, "fontSize", TYPOGRAPHY2);
1916
+ };
1917
+
1918
+ // src/system/spacing.js
1919
+ var runThroughMedia2 = (FACTORY2) => {
1920
+ for (const prop in FACTORY2) {
1921
+ const mediaProps = FACTORY2[prop];
1922
+ const isMediaName = prop.slice(0, 1) === "@";
1923
+ if (!isMediaName) continue;
1924
+ const { type, base, ratio, range, subSequence, h1Matches, unit } = FACTORY2;
1925
+ merge(mediaProps, {
1926
+ type,
1927
+ base,
1928
+ ratio,
1929
+ range,
1930
+ subSequence,
1931
+ h1Matches,
1932
+ unit,
1933
+ sequence: {},
1934
+ scales: {},
1935
+ templates: {},
1936
+ vars: {}
1937
+ });
1938
+ generateSequence(mediaProps);
1939
+ applyMediaSequenceVars(FACTORY2, prop);
1940
+ }
1941
+ };
1942
+ var checkIfBoxSize = (propertyName) => {
1943
+ const prop = propertyName.toLowerCase();
1944
+ const includesWidth = prop.includes("width") || prop.includes("height");
1945
+ const includesBorder = prop.includes("border") || prop.includes("outline");
1946
+ return includesWidth && !includesBorder;
1947
+ };
1948
+ var applySpacingSequence = () => {
1949
+ const CONFIG2 = getActiveConfig();
1950
+ const { SPACING: SPACING2 } = CONFIG2;
1951
+ generateSequence(SPACING2);
1952
+ applySequenceVars(SPACING2);
1953
+ runThroughMedia2(SPACING2);
1954
+ };
1955
+ var getSequence = (sequenceProps) => {
1956
+ const CONFIG2 = getActiveConfig();
1957
+ const { SPACING: SPACING2 } = CONFIG2;
1958
+ if (!sequenceProps || !sequenceProps.sequence) return SPACING2;
1959
+ const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
1960
+ return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
1961
+ };
1962
+ var getSpacingByKey = (value, propertyName = "padding", sequenceProps, fnPrefix) => {
1963
+ const sequence = getSequence(sequenceProps);
1964
+ if (isString(value)) {
1965
+ if (!fnPrefix && value.includes("(")) {
1966
+ const fnArray = getFnPrefixAndValue(value);
1967
+ fnPrefix = fnArray[0];
1968
+ value = fnArray[1];
1969
+ }
1970
+ }
1971
+ const stack = fnPrefix ? [value] : arrayzeValue(value);
1972
+ if (!isArray(stack)) return;
1973
+ if (stack.length > 1) {
1974
+ let suffix = "";
1975
+ if (propertyName === "borderWidth") {
1976
+ propertyName = "border";
1977
+ suffix = "Width";
1978
+ }
1979
+ const directions = {
1980
+ 2: ["Block", "Inline"],
1981
+ 3: ["BlockStart", "Inline", "BlockEnd"],
1982
+ 4: ["BlockStart", "InlineEnd", "BlockEnd", "InlineStart"]
1983
+ };
1984
+ const wrapSequenceValueByDirection = (direction, i) => getSequenceValuePropertyPair(
1985
+ stack[i],
1986
+ propertyName + direction + suffix,
1987
+ sequence,
1988
+ fnPrefix
1989
+ );
1990
+ return directions[stack.length].map(
1991
+ (dir, key) => wrapSequenceValueByDirection(dir, key)
1992
+ );
1993
+ }
1994
+ return getSequenceValuePropertyPair(value, propertyName, sequence, fnPrefix);
1995
+ };
1996
+ var getSpacingBasedOnRatio = (props, propertyName, val, fnPrefix) => {
1997
+ const CONFIG2 = getActiveConfig();
1998
+ const { SPACING: SPACING2 } = CONFIG2;
1999
+ let value = val || props[propertyName];
2000
+ if (!fnPrefix && isString(value) && value.includes("(")) {
2001
+ const fnArr = getFnPrefixAndValue(value);
2002
+ fnPrefix = fnArr[0];
2003
+ value = fnArr[1];
2004
+ }
2005
+ if (props.spacingRatio) {
2006
+ const sequenceProps = applyCustomSequence(props);
2007
+ return getSpacingByKey(value, propertyName, sequenceProps, fnPrefix);
2008
+ }
2009
+ return getSpacingByKey(value, propertyName, SPACING2, fnPrefix);
2010
+ };
2011
+ var splitSpacedValue = (val) => {
2012
+ const addDefault = (v) => {
2013
+ const isSymbol = ["+", "-", "*", "/"].includes(v);
2014
+ const hasUnits = CSS_UNITS.some((unit) => val.includes(unit));
2015
+ if (isSymbol || hasUnits) return v;
2016
+ const isSingleLetter = v.length < 3 && /[A-Z]/.test(v);
2017
+ if (isSingleLetter) return v + "_default";
2018
+ return v;
2019
+ };
2020
+ return val.split(",").map((v) => v.trim()).map(addDefault).join(",").split(" ").map(addDefault).join(" ");
2021
+ };
2022
+
2023
+ // src/system/shadow.js
2024
+ var setShadow = (value, key, suffix, prefers) => {
2025
+ const CONFIG2 = getActiveConfig();
2026
+ if (isArray(value)) {
2027
+ return {
2028
+ "@light": setShadow(value[0], key, "light"),
2029
+ "@dark": setShadow(value[1], key, "dark")
2030
+ };
2031
+ }
2032
+ if (isObject(value)) {
2033
+ const obj = {};
2034
+ for (const variant in value) {
2035
+ obj[variant] = setShadow(
2036
+ value[variant],
2037
+ key,
2038
+ variant.startsWith("@") ? variant.slice(1) : variant
2039
+ );
2040
+ }
2041
+ return obj;
2042
+ }
2043
+ if (isString(value) && !CSS_NATIVE_COLOR_REGEX.test(value)) {
2044
+ value = splitTopLevelCommas(value).map((shadow) => {
2045
+ shadow = shadow.trim();
2046
+ return shadow.split(/\s+/).map((v) => {
2047
+ v = v.trim();
2048
+ if (!v) return "";
2049
+ if (v.startsWith("--")) return `var(${v})`;
2050
+ const color = getColor(v);
2051
+ if (isResolvedColor(color)) return color;
2052
+ if (/^\d/.test(v) || v === "0" || v.includes("px") || v.slice(-2) === "em") return v;
2053
+ if (v === "inset" || v === "none") return v;
2054
+ const spacing = getSpacingByKey(v, "shadow");
2055
+ if (spacing && spacing.shadow) return spacing.shadow;
2056
+ return v;
2057
+ }).join(" ");
2058
+ }).join(", ");
2059
+ }
2060
+ const CSSVar = `--shadow-${key}` + (suffix ? `-${suffix}` : "");
2061
+ if (CONFIG2.useVariable) {
2062
+ CONFIG2.CSS_VARS[CSSVar] = value;
2063
+ }
2064
+ return {
2065
+ var: CSSVar,
2066
+ value
2067
+ };
2068
+ };
2069
+ var getShadow = (value, globalTheme) => {
2070
+ const CONFIG2 = getActiveConfig();
2071
+ if (!globalTheme) globalTheme = CONFIG2.globalTheme;
2072
+ if (!isString(value)) {
2073
+ if (CONFIG2.verbose) console.warn(value, "- type for color is not valid");
2074
+ return;
2075
+ }
2076
+ if (isCSSVar(value)) return `var(${value})`;
2077
+ const [name] = isArray(value) ? value : value.split(" ");
2078
+ const { SHADOW: SHADOW2 } = CONFIG2;
2079
+ const val = SHADOW2[name];
2080
+ const isObj = isObject(val);
2081
+ if (!val) {
2082
+ if (CONFIG2.verbose) console.warn("Can't find color ", name);
2083
+ return value;
2084
+ }
2085
+ if (globalTheme) {
2086
+ if (val[globalTheme]) return val[globalTheme].value;
2087
+ else if (CONFIG2.verbose) console.warn(value, " - does not have ", globalTheme);
2088
+ }
2089
+ if (isObj && val.value) return val.value;
2090
+ if (isObj) {
2091
+ const obj = {};
2092
+ for (const mediaName in val) {
2093
+ const query = CONFIG2.MEDIA[mediaName.slice(1)];
2094
+ const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
2095
+ obj[media] = val.value;
2096
+ }
2097
+ return obj;
2098
+ }
2099
+ if (CONFIG2.verbose) console.warn("Can't find color", value);
2100
+ return value;
2101
+ };
2102
+
2103
+ // src/system/timing.js
2104
+ var applyTimingSequence = () => {
2105
+ const CONFIG2 = getActiveConfig();
2106
+ const { TIMING: TIMING2 } = CONFIG2;
2107
+ generateSequence(TIMING2);
2108
+ applySequenceVars(TIMING2);
2109
+ };
2110
+ var getTimingFunction = (value) => {
2111
+ const CONFIG2 = getActiveConfig();
2112
+ const { TIMING: TIMING2 } = CONFIG2;
2113
+ return TIMING2[value] || TIMING2[toCamelCase(value)] || value;
2114
+ };
2115
+ var getTimingByKey = (value, property = "timing") => {
2116
+ const CONFIG2 = getActiveConfig();
2117
+ const { TIMING: TIMING2 } = CONFIG2;
2118
+ return getSequenceValuePropertyPair(
2119
+ value,
2120
+ property,
2121
+ TIMING2
2122
+ );
2123
+ };
2124
+
2125
+ // src/system/document.js
2126
+ var applyDocument = () => {
2127
+ const CONFIG2 = getActiveConfig();
2128
+ const { DOCUMENT: DOCUMENT2, FONT_FAMILY: FONT_FAMILY2, THEME: THEME2, TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
2129
+ return merge(DOCUMENT2, {
2130
+ theme: THEME2.document,
2131
+ fontFamily: getDefaultOrFirstKey(FONT_FAMILY2),
2132
+ fontSize: TYPOGRAPHY2.base,
2133
+ lineHeight: TYPOGRAPHY2.lineHeight
2134
+ });
2135
+ };
2136
+
2137
+ // src/system/svg.js
2138
+ var DEF_OPTIONS = {
2139
+ document: document2
2140
+ };
2141
+ var setSVG = (val, key) => {
2142
+ const CONFIG2 = getActiveConfig();
2143
+ if (!val) {
2144
+ if (CONFIG2.verbose) console.warn("setSVG: val is not defined", key);
2145
+ return;
2146
+ }
2147
+ if (CONFIG2.useSvgSprite) {
2148
+ return convertSvgToSymbol(key, val);
2149
+ }
2150
+ return val;
2151
+ };
2152
+ var appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
2153
+ const CONFIG2 = getActiveConfig();
2154
+ const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.SVG;
2155
+ for (const key in LIBRARY) lib[key] = CONFIG2.SVG[key];
2156
+ appendSVG(lib, options);
2157
+ };
2158
+ var setSvgIcon = (val, key) => {
2159
+ const CONFIG2 = getActiveConfig();
2160
+ if (CONFIG2.useIconSprite && !CONFIG2.SEMANTIC_ICONS?.[key]) {
2161
+ return setSVG(val, key);
2162
+ }
2163
+ return val;
2164
+ };
2165
+ var appendSvgIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
2166
+ const CONFIG2 = getActiveConfig();
2167
+ const lib = Object.keys(LIBRARY).length ? {} : CONFIG2.ICONS;
2168
+ for (const key in LIBRARY) lib[key] = CONFIG2.ICONS[key];
2169
+ appendSVG(lib, options);
2170
+ };
2171
+ var createSVGSpriteElement = (options = { isRoot: true }) => {
2172
+ if (!document2 || !document2.createElementNS) return;
2173
+ const svgElem = document2.createElementNS("http://www.w3.org/2000/svg", "svg");
2174
+ if (options.isRoot) {
2175
+ svgElem.setAttribute("aria-hidden", "true");
2176
+ svgElem.setAttribute("width", "0");
2177
+ svgElem.setAttribute("height", "0");
2178
+ svgElem.setAttribute("style", "position:absolute");
2179
+ svgElem.setAttribute("id", "svgSprite");
2180
+ }
2181
+ return svgElem;
2182
+ };
2183
+ var appendSVG = (lib, options = DEF_OPTIONS) => {
2184
+ const CONFIG2 = getActiveConfig();
2185
+ const doc = options.document || document2;
2186
+ if (!doc || !doc.documentElement) {
2187
+ if (CONFIG2.verbose) {
2188
+ console.warn("To append SVG sprites it should be run in browser environment");
2189
+ }
2190
+ return generateSprite(lib);
2191
+ }
2192
+ const exists = doc.querySelector("#svgSprite");
2193
+ const SVGsprite = generateSprite(lib);
2194
+ if (exists) {
2195
+ const tempSVG = createSVGSpriteElement({ isRoot: false });
2196
+ tempSVG.innerHTML = SVGsprite;
2197
+ exists.append(...tempSVG.children);
2198
+ } else {
2199
+ const svgSpriteDOM = createSVGSpriteElement();
2200
+ if (svgSpriteDOM && svgSpriteDOM.nodeType) {
2201
+ svgSpriteDOM.innerHTML = SVGsprite;
2202
+ doc.body.prepend(svgSpriteDOM);
2203
+ }
2204
+ }
2205
+ };
2206
+
2207
+ // src/system/reset.js
2208
+ var applyReset = (reset = {}) => {
2209
+ const CONFIG2 = getActiveConfig();
2210
+ const { RESET: RESET2, TYPOGRAPHY: TYPOGRAPHY2, DOCUMENT: DOCUMENT2 } = CONFIG2;
2211
+ if (RESET2) {
2212
+ if (RESET2[":root"]) {
2213
+ const configReset = RESET2;
2214
+ const configTemplates = TYPOGRAPHY2.templates;
2215
+ configReset.body = {
2216
+ ...CONFIG2.useDocumentTheme ? getMediaTheme("document", `@${CONFIG2.globalTheme}`) : {},
2217
+ ...configTemplates.body
2218
+ };
2219
+ configReset.h1 = configTemplates.h1;
2220
+ configReset.h2 = configTemplates.h2;
2221
+ configReset.h3 = configTemplates.h3;
2222
+ configReset.h4 = configTemplates.h4;
2223
+ configReset.h5 = configTemplates.h5;
2224
+ configReset.h6 = configTemplates.h6;
2225
+ }
2226
+ const { body, ...templates } = TYPOGRAPHY2.templates;
2227
+ const globalTheme = CONFIG2.useDocumentTheme ? getMediaTheme("document", `@${CONFIG2.globalTheme}`) : {};
2228
+ if (RESET2.html) overwriteDeep(RESET2.html, globalTheme);
2229
+ return deepMerge(merge(RESET2, reset), {
2230
+ html: {
2231
+ position: "absolute",
2232
+ // overflow: 'hidden',
2233
+ width: "100%",
2234
+ height: "100%",
2235
+ top: "0",
2236
+ left: "0",
2237
+ margin: "0",
2238
+ WebkitFontSmoothing: "subpixel-antialiased",
2239
+ scrollBehavior: "smooth",
2240
+ ...globalTheme,
2241
+ fontSize: TYPOGRAPHY2.browserDefault + "px",
2242
+ fontFamily: DOCUMENT2.fontFamily,
2243
+ lineHeight: DOCUMENT2.lineHeight
2244
+ },
2245
+ body: {
2246
+ boxSizing: "border-box",
2247
+ height: "100%",
2248
+ margin: 0,
2249
+ fontFamily: DOCUMENT2.fontFamily,
2250
+ fontSize: TYPOGRAPHY2.base / TYPOGRAPHY2.browserDefault + CONFIG2.UNIT.default,
2251
+ ...templates,
2252
+ ...body
2253
+ },
2254
+ a: {
2255
+ color: "currentColor"
2256
+ },
2257
+ // form elements
2258
+ fieldset: {
2259
+ border: 0,
2260
+ padding: 0,
2261
+ margin: 0
2262
+ },
2263
+ "select, input": {
2264
+ fontFamily: DOCUMENT2.fontFamily
2265
+ }
2266
+ });
2267
+ }
2268
+ };
2269
+
2270
+ // src/transforms/index.js
2271
+ var BORDER_STYLES = /* @__PURE__ */ new Set([
2272
+ "none",
2273
+ "hidden",
2274
+ "dotted",
2275
+ "dashed",
2276
+ "solid",
2277
+ "double",
2278
+ "groove",
2279
+ "ridge",
2280
+ "inset",
2281
+ "outset",
2282
+ "initial"
2283
+ ]);
2284
+ var GRADIENT_KEYWORDS = /* @__PURE__ */ new Set([
2285
+ "to",
2286
+ "top",
2287
+ "bottom",
2288
+ "left",
2289
+ "right",
2290
+ "center",
2291
+ "at",
2292
+ "circle",
2293
+ "ellipse",
2294
+ "closest-side",
2295
+ "farthest-side",
2296
+ "closest-corner",
2297
+ "farthest-corner"
2298
+ ]);
2299
+ var isBorderStyle = (str) => BORDER_STYLES.has(str);
2300
+ var transformBorder = (border) => {
2301
+ const str = border + "";
2302
+ if (CSS_NATIVE_COLOR_REGEX.test(str)) return str;
2303
+ const trimmed = str.trim();
2304
+ if (trimmed === "none" || trimmed === "0" || trimmed === "initial" || trimmed === "inherit" || trimmed === "unset") return str;
2305
+ const tokens = str.split(/\s+/);
2306
+ return tokens.map((v) => {
2307
+ v = v.trim();
2308
+ if (!v) return "";
2309
+ if (isCSSVar(v)) return `var(${v})`;
2310
+ if (isBorderStyle(v)) return v;
2311
+ if (/^\d/.test(v) || v === "0") return v;
2312
+ const color = getColor(v);
2313
+ if (isResolvedColor(color)) return color;
2314
+ const spacing = getSpacingByKey(v, "border");
2315
+ if (spacing && spacing.border) return spacing.border;
2316
+ return v;
2317
+ }).join(" ");
2318
+ };
2319
+ var transformTextStroke = (stroke) => {
2320
+ if (CSS_NATIVE_COLOR_REGEX.test(stroke)) return stroke;
2321
+ return stroke.split(/\s+/).map((v) => {
2322
+ v = v.trim();
2323
+ if (!v) return "";
2324
+ if (isCSSVar(v)) return `var(${v})`;
2325
+ if (/^\d/.test(v) || v.includes("px") || v === "0") return v;
2326
+ const color = getColor(v);
2327
+ if (isResolvedColor(color)) return color;
2328
+ return v;
2329
+ }).join(" ");
2330
+ };
2331
+ var transformShadow = (sh, globalTheme) => getShadow(sh, globalTheme);
2332
+ var transformBoxShadow = (shadows, globalTheme) => {
2333
+ if (CSS_NATIVE_COLOR_REGEX.test(shadows)) return shadows;
2334
+ return splitTopLevelCommas(shadows).map((shadow) => {
2335
+ shadow = shadow.trim();
2336
+ if (!shadow) return "";
2337
+ return shadow.split(/\s+/).map((v) => {
2338
+ v = v.trim();
2339
+ if (!v) return "";
2340
+ if (isCSSVar(v)) return `var(${v})`;
2341
+ if (v === "inset" || v === "none") return v;
2342
+ const color = getColor(v);
2343
+ if (isResolvedColor(color)) {
2344
+ const mediaColor = getMediaColor(v, globalTheme);
2345
+ if (isObject(mediaColor))
2346
+ return Object.values(mediaColor).filter(
2347
+ (c) => c.includes(": " + globalTheme)
2348
+ )[0];
2349
+ return mediaColor;
2350
+ }
2351
+ if (/^\d/.test(v) || v === "0" || v.includes("px") || v.slice(-2) === "em") return v;
2352
+ const spacing = getSpacingByKey(v, "shadow");
2353
+ if (spacing && spacing.shadow) return spacing.shadow;
2354
+ return v;
2355
+ }).join(" ");
2356
+ }).join(", ");
2357
+ };
2358
+ var resolveColorsInGradient = (gradient, globalTheme) => {
2359
+ const parenStart = gradient.indexOf("(");
2360
+ if (parenStart === -1) return gradient;
2361
+ const prefix = gradient.slice(0, parenStart + 1);
2362
+ const inner = gradient.slice(parenStart + 1, gradient.lastIndexOf(")"));
2363
+ const suffix = ")";
2364
+ const segments = splitTopLevelCommas(inner);
2365
+ const resolved = segments.map((segment) => {
2366
+ segment = segment.trim();
2367
+ const tokens = segment.split(/\s+/);
2368
+ return tokens.map((token) => {
2369
+ if (!token) return token;
2370
+ if (/^\d/.test(token) || token === "0") return token;
2371
+ if (GRADIENT_KEYWORDS.has(token)) return token;
2372
+ if (token === "transparent") return token;
2373
+ if (CSS_NATIVE_COLOR_REGEX.test(token)) return token;
2374
+ const color = getColor(token);
2375
+ if (isResolvedColor(color)) return color;
2376
+ return token;
2377
+ }).join(" ");
2378
+ });
2379
+ return prefix + resolved.join(", ") + suffix;
2380
+ };
2381
+ var transformBackgroundImage = (backgroundImage, globalTheme) => {
2382
+ const CONFIG2 = getActiveConfig();
2383
+ return backgroundImage.split(", ").map((v) => {
2384
+ if (isCSSVar(v)) return `var(${v})`;
2385
+ if (v.includes("url")) return v;
2386
+ if (v.includes("gradient")) return resolveColorsInGradient(v, globalTheme);
2387
+ else if (CONFIG2.GRADIENT[backgroundImage]) {
2388
+ return {
2389
+ backgroundImage: getMediaColor(
2390
+ backgroundImage,
2391
+ globalTheme || CONFIG2.globalTheme
2392
+ )
2393
+ };
2394
+ } else if (v.includes("/") || v.startsWith("http") || v.includes(".") && !parseColorToken(v))
2395
+ return `url(${v})`;
2396
+ return v;
2397
+ }).join(" ");
2398
+ };
2399
+ var transfromGap = (gap) => isString(gap) && gap.split(" ").map((v) => getSpacingByKey(v, "gap").gap).join(" ");
2400
+ var transformTransition = (transition) => {
2401
+ const arr = transition.split(" ");
2402
+ if (!arr.length) return transition;
2403
+ return arr.map((v) => {
2404
+ if (isCSSVar(v)) return `var(${v})`;
2405
+ if (v.length < 3 || v.includes("ms")) {
2406
+ const mapWithSequence = getTimingByKey(v);
2407
+ return mapWithSequence.timing || v;
2408
+ }
2409
+ if (getTimingFunction(v)) return getTimingFunction(v);
2410
+ return v;
2411
+ }).join(" ");
2412
+ };
2413
+ var transformDuration = (duration, props, propertyName) => {
2414
+ if (!isString(duration)) return;
2415
+ return duration.split(",").map((v) => getTimingByKey(v).timing || v).join(",");
2416
+ };
2417
+ var splitTransition = (transition) => {
2418
+ const arr = transition.split(",");
2419
+ if (!arr.length) return;
2420
+ return arr.map(transformTransition).join(",");
2421
+ };
2422
+ function transformSize(propertyName, val, props = {}, opts = {}) {
2423
+ let value = exec.call(this, val || props[propertyName]);
2424
+ if (value === void 0 || value === null) return;
2425
+ let fnPrefix;
2426
+ if (isString(value)) {
2427
+ if (value.includes("(")) {
2428
+ const fnArr = getFnPrefixAndValue(value);
2429
+ fnPrefix = fnArr[0];
2430
+ value = fnArr[1];
2431
+ }
2432
+ const shouldScaleBoxSize = props.scaleBoxSize;
2433
+ const isBoxSize = checkIfBoxSize(propertyName);
2434
+ if (!shouldScaleBoxSize && isBoxSize) {
2435
+ value = splitSpacedValue(value);
2436
+ }
2437
+ }
2438
+ return opts.ratio ? getSpacingBasedOnRatio(props, propertyName, value, fnPrefix) : getSpacingByKey(value, propertyName, void 0, fnPrefix);
2439
+ }
2440
+ var transformSizeRatio = (propertyName, val = null, props) => {
2441
+ return transformSize(propertyName, val, props, {
2442
+ ratio: true
2443
+ });
2444
+ };
2445
+ var transformBorderRadius = (radius, props, propertyName) => {
2446
+ if (!isString(radius)) return;
2447
+ return {
2448
+ borderRadius: radius.split(" ").map((v, k) => getSpacingBasedOnRatio(props, propertyName, v)[propertyName]).join(" ")
2449
+ };
2450
+ };
2451
+
2452
+ // src/set.js
2453
+ var setCases = (val, key) => {
2454
+ if (isFunction(val)) return val();
2455
+ return val;
2456
+ };
2457
+ var setSameValue = (val, key) => val;
2458
+ var VALUE_TRANSFORMERS = {
2459
+ color: setColor,
2460
+ gradient: setGradient,
2461
+ font: setFont,
2462
+ font_family: setFontFamily,
2463
+ theme: setTheme,
2464
+ icons: setSvgIcon,
2465
+ semantic_icons: setSameValue,
2466
+ svg: setSVG,
2467
+ svg_data: setSameValue,
2468
+ typography: setSameValue,
2469
+ cases: setCases,
2470
+ shadow: setShadow,
2471
+ spacing: setSameValue,
2472
+ media: setSameValue,
2473
+ grid: setSameValue,
2474
+ class: setSameValue,
2475
+ timing: setSameValue,
2476
+ reset: setSameValue,
2477
+ unit: setSameValue,
2478
+ animation: setSameValue
2479
+ };
2480
+ var setValue = (FACTORY_NAME, value, key) => {
2481
+ const CONFIG2 = getActiveConfig();
2482
+ const factoryName = FACTORY_NAME.toLowerCase();
2483
+ const FACTORY2 = CONFIG2[FACTORY_NAME];
2484
+ if (VALUE_TRANSFORMERS[factoryName]) {
2485
+ try {
2486
+ const result = VALUE_TRANSFORMERS[factoryName](value, key);
2487
+ FACTORY2[key] = result;
2488
+ return FACTORY2;
2489
+ } catch (error) {
2490
+ if (CONFIG2.verbose) console.warn("Error setting", factoryName, "value", value, key, error);
2491
+ }
2492
+ }
2493
+ if (CONFIG2.verbose) console.warn("Can not find", factoryName, "method in scratch");
2494
+ };
2495
+ var setEach = (factoryName, props) => {
2496
+ const CONFIG2 = getActiveConfig();
2497
+ const FACTORY_NAME = factoryName.toUpperCase();
2498
+ const keys = Object.keys(props);
2499
+ keys.forEach((key) => {
2500
+ try {
2501
+ return setValue(FACTORY_NAME, props[key], key);
2502
+ } catch (error) {
2503
+ if (CONFIG2.verbose) console.warn("Error setting", FACTORY_NAME, "value", props[key], key, error);
2504
+ }
2505
+ });
2506
+ return CONFIG2[FACTORY_NAME];
2507
+ };
2508
+ var SET_OPTIONS = {};
2509
+ var set = (recivedConfig, options = SET_OPTIONS) => {
2510
+ let CONFIG2 = getActiveConfig();
2511
+ const {
2512
+ version,
2513
+ verbose,
2514
+ useVariable,
2515
+ useReset,
2516
+ useSvgSprite,
2517
+ useFontImport,
2518
+ useIconSprite,
2519
+ globalTheme,
2520
+ useDocumentTheme,
2521
+ useDefaultConfig,
2522
+ SEMANTIC_ICONS: SEMANTIC_ICONS2,
2523
+ ...config
2524
+ } = recivedConfig;
2525
+ if (options.newConfig) {
2526
+ CONFIG2 = setActiveConfig(options.newConfig);
2527
+ }
2528
+ if (verbose !== void 0) CONFIG2.verbose = verbose;
2529
+ if (useVariable !== void 0) CONFIG2.useVariable = useVariable;
2530
+ if (useReset !== void 0) CONFIG2.useReset = useReset;
2531
+ if (useFontImport !== void 0) CONFIG2.useFontImport = useFontImport;
2532
+ if (useSvgSprite !== void 0) CONFIG2.useSvgSprite = useSvgSprite;
2533
+ if (useIconSprite !== void 0) CONFIG2.useIconSprite = useIconSprite;
2534
+ if (useDocumentTheme !== void 0) CONFIG2.useDocumentTheme = useDocumentTheme;
2535
+ if (globalTheme !== void 0) CONFIG2.globalTheme = globalTheme;
2536
+ if (useDefaultConfig !== void 0) CONFIG2.useDefaultConfig = useDefaultConfig;
2537
+ if (SEMANTIC_ICONS2 !== void 0) CONFIG2.SEMANTIC_ICONS = SEMANTIC_ICONS2;
2538
+ if (CONFIG2.verbose) console.log(CONFIG2);
2539
+ if (!CONFIG2.__svg_cache) CONFIG2.__svg_cache = {};
2540
+ const keys = Object.keys(config);
2541
+ const keySet = new Set(keys);
2542
+ keys.forEach((key) => {
2543
+ const lower = key.toLowerCase();
2544
+ if (lower !== key && keySet.has(lower)) {
2545
+ deepMerge(config[lower], config[key]);
2546
+ }
2547
+ });
2548
+ keys.map((key) => {
2549
+ const lower = key.toLowerCase();
2550
+ if (lower !== key && keySet.has(lower)) return;
2551
+ return setEach(key, config[key]);
2552
+ });
2553
+ if (config.TYPOGRAPHY || config.typography) {
2554
+ try {
2555
+ applyTypographySequence();
2556
+ } catch (e) {
2557
+ if (CONFIG2.verbose) console.warn("Error applying typography sequence", e);
2558
+ }
2559
+ }
2560
+ if (config.SPACING || config.spacing) {
2561
+ try {
2562
+ applySpacingSequence();
2563
+ } catch (e) {
2564
+ if (CONFIG2.verbose) console.warn("Error applying spacing sequence", e);
2565
+ }
2566
+ }
2567
+ if (config.TIMING || config.timing) {
2568
+ try {
2569
+ applyTimingSequence();
2570
+ } catch (e) {
2571
+ if (CONFIG2.verbose) console.warn("Error applying timing sequence", e);
2572
+ }
2573
+ }
2574
+ applyDocument();
2575
+ applyReset();
2576
+ return CONFIG2;
2577
+ };
2578
+ return __toCommonJS(index_exports);
2579
+ })();
2580
+ // @preserve-env