@symbo.ls/scratch 2.9.4 → 2.9.10-0

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 (2) hide show
  1. package/dist/index.js +1531 -0
  2. package/package.json +5 -4
package/dist/index.js ADDED
@@ -0,0 +1,1531 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // ../../node_modules/@domql/globals/index.js
8
+ var window2 = globalThis;
9
+ var document2 = window2.document;
10
+
11
+ // ../../node_modules/@domql/utils/types.js
12
+ var isObject = (arg) => {
13
+ if (arg === null)
14
+ return false;
15
+ return typeof arg === "object" && arg.constructor === Object;
16
+ };
17
+ var isString = (arg) => typeof arg === "string";
18
+ var isNumber = (arg) => typeof arg === "number";
19
+ var isFunction = (arg) => typeof arg === "function";
20
+ var isBoolean = (arg) => arg === true || arg === false;
21
+ var isNull = (arg) => arg === null;
22
+ var isArray = (arg) => Array.isArray(arg);
23
+ var isObjectLike = (arg) => {
24
+ if (arg === null)
25
+ return false;
26
+ return typeof arg === "object";
27
+ };
28
+ var isDefined = (arg) => {
29
+ return isObject(arg) || isObjectLike(arg) || isString(arg) || isNumber(arg) || isFunction(arg) || isArray(arg) || isObjectLike(arg) || isBoolean(arg) || isNull(arg);
30
+ };
31
+
32
+ // ../../node_modules/@domql/utils/object.js
33
+ var merge = (element, obj) => {
34
+ for (const e in obj) {
35
+ const elementProp = element[e];
36
+ const objProp = obj[e];
37
+ if (elementProp === void 0) {
38
+ element[e] = objProp;
39
+ }
40
+ }
41
+ return element;
42
+ };
43
+ var deepMerge = (element, extend) => {
44
+ for (const e in extend) {
45
+ const elementProp = element[e];
46
+ const extendProp = extend[e];
47
+ if (e === "parent" || e === "props")
48
+ continue;
49
+ if (elementProp === void 0) {
50
+ element[e] = extendProp;
51
+ } else if (isObjectLike(elementProp) && isObject(extendProp)) {
52
+ deepMerge(elementProp, extendProp);
53
+ }
54
+ }
55
+ return element;
56
+ };
57
+ var deepClone = (obj) => {
58
+ if (isArray(obj)) {
59
+ return obj.map(deepClone);
60
+ }
61
+ const o = {};
62
+ for (const prop in obj) {
63
+ let objProp = obj[prop];
64
+ if (prop === "extend" && isArray(objProp)) {
65
+ objProp = mergeArray(objProp);
66
+ }
67
+ if (isArray(objProp)) {
68
+ o[prop] = objProp.map(deepClone);
69
+ } else if (isObject(objProp)) {
70
+ o[prop] = deepClone(objProp);
71
+ } else
72
+ o[prop] = objProp;
73
+ }
74
+ return o;
75
+ };
76
+ var mergeArray = (arr) => {
77
+ return arr.reduce((a, c) => deepMerge(a, deepClone(c)), {});
78
+ };
79
+
80
+ // ../../node_modules/@domql/utils/node.js
81
+ var createID = function* () {
82
+ let index = 1;
83
+ while (index < index + 1) {
84
+ yield index++;
85
+ }
86
+ }();
87
+
88
+ // src/defaultConfig/index.js
89
+ var defaultConfig_exports = {};
90
+ __export(defaultConfig_exports, {
91
+ ANIMATION: () => ANIMATION,
92
+ BREAKPOINTS: () => BREAKPOINTS,
93
+ CASES: () => CASES,
94
+ COLOR: () => COLOR,
95
+ DEVICES: () => DEVICES,
96
+ DOCUMENT: () => DOCUMENT,
97
+ FONT: () => FONT,
98
+ FONT_FACE: () => FONT_FACE,
99
+ FONT_FAMILY: () => FONT_FAMILY,
100
+ FONT_FAMILY_TYPES: () => FONT_FAMILY_TYPES,
101
+ GRADIENT: () => GRADIENT,
102
+ ICONS: () => ICONS,
103
+ MEDIA: () => MEDIA,
104
+ RESET: () => RESET,
105
+ SEQUENCE: () => SEQUENCE,
106
+ SPACING: () => SPACING,
107
+ THEME: () => THEME,
108
+ TIMING: () => TIMING,
109
+ TYPOGRAPHY: () => TYPOGRAPHY,
110
+ UNIT: () => UNIT
111
+ });
112
+
113
+ // src/defaultConfig/sequence.js
114
+ var SEQUENCE = {
115
+ "minor-second": 1.067,
116
+ "major-second": 1.125,
117
+ "minor-third": 1.2,
118
+ "major-third": 1.25,
119
+ "perfect-fourth": 1.333,
120
+ "augmented-fourth": 1.414,
121
+ "perfect-fifth": 1.5,
122
+ "minor-sixth": 1.6,
123
+ phi: 1.618,
124
+ // golden-ratio
125
+ "major-sixth": 1.667,
126
+ "square-root-3": 1.732,
127
+ // theodorus
128
+ "minor-seventh": 1.778,
129
+ "major-seventh": 1.875,
130
+ octave: 2,
131
+ "square-root-5": 2.23,
132
+ // pythagoras
133
+ "major-tenth": 2.5,
134
+ "major-eleventh": 2.667,
135
+ "major-twelfth": 3,
136
+ pi: 3.14,
137
+ // archimedes
138
+ "double-octave": 4
139
+ };
140
+
141
+ // src/defaultConfig/unit.js
142
+ var UNIT = {
143
+ default: "em"
144
+ };
145
+
146
+ // src/defaultConfig/typography.js
147
+ var defaultProps = {
148
+ browserDefault: 16,
149
+ base: 16,
150
+ type: "font-size",
151
+ ratio: SEQUENCE["minor-third"],
152
+ range: [-3, 12],
153
+ h1Matches: 6,
154
+ lineHeight: 1.5,
155
+ unit: "em",
156
+ styles: {},
157
+ sequence: {},
158
+ scales: {},
159
+ vars: {}
160
+ };
161
+ var TYPOGRAPHY = defaultProps;
162
+
163
+ // src/defaultConfig/font.js
164
+ var FONT = {};
165
+
166
+ // src/utils/object.js
167
+ var isString2 = (arg) => typeof arg === "string";
168
+ var isArray2 = (arg) => Array.isArray(arg);
169
+ var isObject2 = (arg) => {
170
+ if (arg === null)
171
+ return false;
172
+ return typeof arg === "object" && arg.constructor === Object;
173
+ };
174
+ var isObjectLike2 = (arg) => {
175
+ if (arg === null)
176
+ return false;
177
+ return typeof arg === "object";
178
+ };
179
+ var merge2 = (obj, original) => {
180
+ for (const e in original) {
181
+ const objProp = obj[e];
182
+ const originalProp = original[e];
183
+ if (objProp === void 0) {
184
+ obj[e] = originalProp;
185
+ }
186
+ }
187
+ return obj;
188
+ };
189
+ var deepMerge2 = (obj, obj2) => {
190
+ for (const e in obj2) {
191
+ const objProp = obj[e];
192
+ const obj2Prop = obj2[e];
193
+ if (objProp === void 0) {
194
+ obj[e] = obj2Prop;
195
+ } else if (isObjectLike2(objProp) && isObject2(obj2Prop)) {
196
+ deepMerge2(objProp, obj2Prop);
197
+ }
198
+ }
199
+ return obj;
200
+ };
201
+ var arrayze = (val) => {
202
+ if (isString2(val))
203
+ return val.split(" ");
204
+ if (isObject2(val))
205
+ return Object.keys(val).map((v) => val[v]);
206
+ if (isArray2(val))
207
+ return val;
208
+ };
209
+ var isFunction2 = (arg) => typeof arg === "function";
210
+
211
+ // src/utils/color.js
212
+ var ENV = "development";
213
+ var colorStringToRgbaArray = (color) => {
214
+ if (color === "")
215
+ return;
216
+ if (color.toLowerCase() === "transparent")
217
+ return [0, 0, 0, 0];
218
+ if (color[0] === "#") {
219
+ if (color.length < 7) {
220
+ color = "#" + color[1] + color[1] + color[2] + color[2] + color[3] + color[3] + (color.length > 4 ? color[4] + color[4] : "");
221
+ }
222
+ return [
223
+ parseInt(color.substr(1, 2), 16),
224
+ parseInt(color.substr(3, 2), 16),
225
+ parseInt(color.substr(5, 2), 16),
226
+ color.length > 7 ? parseInt(color.substr(7, 2), 16) / 255 : 1
227
+ ];
228
+ }
229
+ if (color.indexOf("rgb") === -1) {
230
+ const elem = document.body.appendChild(document.createElement("fictum"));
231
+ const flag = "rgb(1, 2, 3)";
232
+ elem.style.color = flag;
233
+ if (elem.style.color !== flag)
234
+ return;
235
+ elem.style.color = color;
236
+ if (elem.style.color === flag || elem.style.color === "")
237
+ return;
238
+ color = window.getComputedStyle(elem).color;
239
+ document.body.removeChild(elem);
240
+ }
241
+ if (color.indexOf("rgb") === 0) {
242
+ if (color.indexOf("rgba") === -1)
243
+ color = `${color}, 1`;
244
+ return color.match(/[\.\d]+/g).map((a) => +a);
245
+ }
246
+ };
247
+ var mixTwoColors = (colorA, colorB, range = 0.5) => {
248
+ colorA = colorStringToRgbaArray(colorA);
249
+ colorB = colorStringToRgbaArray(colorB);
250
+ return mixTwoRgba(colorA, colorB, range);
251
+ };
252
+ var hexToRgb = (hex, alpha = 1) => {
253
+ const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
254
+ return `rgb(${r},${g},${b})`;
255
+ };
256
+ var hexToRgbArray = (hex, alpha = 1) => {
257
+ const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
258
+ return [r, g, b];
259
+ };
260
+ var rgbToHex = (r, g, b) => {
261
+ return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
262
+ };
263
+ var rgbArrayToHex = ([r, g, b]) => {
264
+ return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
265
+ };
266
+ var hexToRgba = (hex, alpha = 1) => {
267
+ const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
268
+ return `rgba(${r},${g},${b},${alpha})`;
269
+ };
270
+ var mixTwoRgb = (colorA, colorB, range = 0.5) => {
271
+ const arr = [];
272
+ for (let i = 0; i < 3; i++) {
273
+ arr[i] = ~~(colorA[i] + (colorB[i] - colorA[i]) * range);
274
+ }
275
+ return `rgb(${arr})`;
276
+ };
277
+ var changeLightness = (delta, hsl) => {
278
+ const [hue, saturation, lightness] = hsl;
279
+ const newLightness = Math.max(
280
+ 0,
281
+ Math.min(100, lightness + parseFloat(delta))
282
+ );
283
+ return [hue, saturation, newLightness];
284
+ };
285
+ var rgbToHSL = (r, g, b) => {
286
+ const a = Math.max(r, g, b);
287
+ const n = a - Math.min(r, g, b);
288
+ const f = 1 - Math.abs(a + a - n - 1);
289
+ const h = n && (a == r ? (g - b) / n : a == g ? 2 + (b - r) / n : 4 + (r - g) / n);
290
+ return [60 * (h < 0 ? h + 6 : h), f ? n / f : 0, (a + a - n) / 2];
291
+ };
292
+ var hslToRgb = (h, s, l, a = s * Math.min(l, 1 - l), f = (n, k = (n + h / 30) % 12) => l - a * Math.max(
293
+ Math.min(k - 3, 9 - k, 1),
294
+ -1
295
+ )) => [f(0), f(8), f(4)];
296
+ var getColorShade = (col, amt) => {
297
+ const num = parseInt(col, 16);
298
+ let r = (num >> 16) + amt;
299
+ if (r > 255)
300
+ r = 255;
301
+ else if (r < 0)
302
+ r = 0;
303
+ let b = (num >> 8 & 255) + amt;
304
+ if (b > 255)
305
+ b = 255;
306
+ else if (b < 0)
307
+ b = 0;
308
+ let g = (num & 255) + amt;
309
+ if (g > 255)
310
+ g = 255;
311
+ else if (g < 0)
312
+ g = 0;
313
+ return (g | b << 8 | r << 16).toString(16);
314
+ };
315
+ var mixTwoRgba = (colorA, colorB, range = 0.5) => {
316
+ const arr = [];
317
+ for (let i = 0; i < 4; i++) {
318
+ const round = i === 3 ? (x) => x : Math.round;
319
+ arr[i] = round(
320
+ colorA[i] + (colorB[i] - colorA[i]) * range
321
+ );
322
+ }
323
+ return `rgba(${arr})`;
324
+ };
325
+ var opacify = (color, opacity) => {
326
+ const arr = colorStringToRgbaArray(color);
327
+ if (!arr) {
328
+ if (ENV === "test" || ENV === "development")
329
+ console.warn(color + "color is not rgba");
330
+ return;
331
+ }
332
+ arr[3] = opacity;
333
+ return `rgba(${arr})`;
334
+ };
335
+
336
+ // src/utils/font.js
337
+ var getDefaultOrFirstKey = (LIBRARY, key) => {
338
+ if (LIBRARY[key])
339
+ return LIBRARY[key].value;
340
+ if (LIBRARY.default)
341
+ return LIBRARY[LIBRARY.default].value;
342
+ const hasValue = Object.keys(LIBRARY)[0];
343
+ return hasValue && LIBRARY[hasValue] && LIBRARY[hasValue].value;
344
+ };
345
+ var getFontFormat = (url) => url.split(/[#?]/)[0].split(".").pop().trim();
346
+ var setInCustomFontMedia = (str) => `@font-face { ${str} }`;
347
+ var setCustomFont = (name, url, weight) => `
348
+ font-family: '${name}';
349
+ font-style: normal;
350
+ ${weight && `font-weight: ${weight};`}
351
+ src: url('${url}') format('${getFontFormat(url)}');`;
352
+ var setCustomFontMedia = (name, url, weight) => `@font-face {
353
+ ${setCustomFont(name, url, weight)}
354
+ }`;
355
+ var getFontFaceEach = (name, weights) => {
356
+ const keys = Object.keys(weights);
357
+ return keys.map((key) => {
358
+ const { url, fontWeight } = weights[key];
359
+ return setCustomFont(name, url, fontWeight);
360
+ });
361
+ };
362
+ var getFontFace = (LIBRARY) => {
363
+ const keys = Object.keys(LIBRARY);
364
+ return keys.map((key) => getFontFaceEach(key, LIBRARY[key].value));
365
+ };
366
+ var getFontFaceEachString = (name, weights) => {
367
+ const isArr = weights[0];
368
+ if (isArr)
369
+ return getFontFaceEach(name, weights).map(setInCustomFontMedia);
370
+ return setCustomFontMedia(name, weights.url);
371
+ };
372
+ var getFontFaceString = (LIBRARY) => {
373
+ const keys = Object.keys(LIBRARY);
374
+ return keys.map((key) => getFontFaceEachString(key, LIBRARY[key].value));
375
+ };
376
+
377
+ // ../../node_modules/@symbo.ls/utils/src/index.js
378
+ var toCamelCase = (str) => {
379
+ return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
380
+ return index === 0 ? word.toLowerCase() : word.toUpperCase();
381
+ }).replace(/\s+/g, "");
382
+ };
383
+ var toDashCase = (val) => val.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? "-" : "") + match.toLowerCase()).replace(".", "-");
384
+
385
+ // src/utils/sequence.js
386
+ var numToLetterMap = {
387
+ "-6": "U",
388
+ "-5": "V",
389
+ "-4": "W",
390
+ "-3": "X",
391
+ "-2": "Y",
392
+ "-1": "Z",
393
+ 0: "A",
394
+ 1: "B",
395
+ 2: "C",
396
+ 3: "D",
397
+ 4: "E",
398
+ 5: "F",
399
+ 6: "G",
400
+ 7: "H",
401
+ 8: "I",
402
+ 9: "J",
403
+ 10: "K",
404
+ 11: "L",
405
+ 12: "M",
406
+ 13: "N",
407
+ 14: "O",
408
+ 15: "P",
409
+ 16: "Q",
410
+ 17: "R",
411
+ 18: "S",
412
+ 19: "T"
413
+ };
414
+ var setSequenceValue = (props, sequenceProps) => {
415
+ const { key, variable, value, scaling, index } = props;
416
+ sequenceProps.sequence[key] = {
417
+ key,
418
+ decimal: ~~(value * 100) / 100,
419
+ val: ~~value,
420
+ scaling,
421
+ index,
422
+ variable
423
+ };
424
+ sequenceProps.scales[key] = scaling;
425
+ sequenceProps.vars[variable] = scaling + sequenceProps.unit;
426
+ };
427
+ var generateSubSequence = (props, sequenceProps) => {
428
+ const { key, base, value, ratio, variable, index } = props;
429
+ const next = value * ratio;
430
+ const diff = next - value;
431
+ const smallscale = diff / 1.618;
432
+ const valueRounded = ~~value;
433
+ const nextRounded = ~~next;
434
+ const diffRounded = nextRounded - valueRounded;
435
+ let arr = [];
436
+ const first = next - smallscale;
437
+ const second = value + smallscale;
438
+ const middle = (first + second) / 2;
439
+ if (diffRounded > 16)
440
+ arr = [first, middle, second];
441
+ else
442
+ arr = [first, second];
443
+ arr.map((v, k) => {
444
+ const scaling = ~~(v / base * 1e3) / 1e3;
445
+ const newVar = variable + (k + 1);
446
+ const props2 = {
447
+ key: key + (k + 1),
448
+ variable: newVar,
449
+ value: v,
450
+ scaling,
451
+ index: index + (k + 1) / 10
452
+ };
453
+ return setSequenceValue(props2, sequenceProps);
454
+ });
455
+ };
456
+ var switchSequenceOnNegative = (key, base, ratio) => {
457
+ return base * Math.pow(ratio, key);
458
+ };
459
+ var generateSequence = (sequenceProps) => {
460
+ const { type, base, ratio, range, subSequence } = sequenceProps;
461
+ const n = Math.abs(range[0]) + Math.abs(range[1]);
462
+ const prefix = "--" + (type && type.replace(".", "-")) + "-";
463
+ for (let i = 0; i <= n; i++) {
464
+ const key = range[1] - i;
465
+ const letterKey = numToLetterMap[key];
466
+ const value = switchSequenceOnNegative(key, base, ratio);
467
+ const scaling = ~~(value / base * 100) / 100;
468
+ const variable = prefix + letterKey;
469
+ const props = {
470
+ key: letterKey,
471
+ variable,
472
+ value,
473
+ base,
474
+ scaling,
475
+ ratio,
476
+ index: key
477
+ };
478
+ setSequenceValue(props, sequenceProps);
479
+ if (subSequence)
480
+ generateSubSequence(props, sequenceProps);
481
+ }
482
+ return sequenceProps;
483
+ };
484
+ var getSequenceValue = (value = "A", sequenceProps) => {
485
+ const CONFIG2 = getActiveConfig();
486
+ const { UNIT: UNIT2 } = CONFIG2;
487
+ const {
488
+ sequence,
489
+ unit = UNIT2.default,
490
+ useVariable
491
+ } = sequenceProps;
492
+ if (isString(value) && value.slice(0, 2) === "--")
493
+ return `var(${value})`;
494
+ const prefix = `--${toDashCase(sequenceProps.type.replace(".", "-"))}-`;
495
+ const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
496
+ const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
497
+ if (value === "none" || value === "auto" || value === "unset" || value === "inherit" || value === "fit-content" || value === "min-content" || value === "max-content" || value.includes("calc") || !startsWithDashOrLetter)
498
+ return value;
499
+ const letterVal = value.toUpperCase();
500
+ const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
501
+ let absValue = isNegative ? letterVal.slice(1) : letterVal;
502
+ let mediaName = "";
503
+ if (absValue.includes("-")) {
504
+ mediaName = "-" + absValue.split("-")[1].toLowerCase();
505
+ absValue = absValue.split("-")[0];
506
+ }
507
+ const varValue = (v) => `var(${prefix}${v}${mediaName})`;
508
+ if (absValue.includes("+")) {
509
+ const args = absValue.split("+");
510
+ const [first, second] = args;
511
+ const joint = `${varValue(first)} + ${varValue(second)}`;
512
+ return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
513
+ } else if (absValue.includes("-")) {
514
+ const args = absValue.split("-");
515
+ const [first, second] = args;
516
+ const joint = `${varValue(first)} - ${varValue(second)}`;
517
+ return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
518
+ }
519
+ if (!sequence[absValue] && absValue.length === 2) {
520
+ if (CONFIG2.verbose)
521
+ console.warn(absValue, "- value is not found because `subSequence` is set to false");
522
+ absValue = absValue.slice(0, 1);
523
+ }
524
+ if (useVariable || CONFIG2.useVariable) {
525
+ const varValue2 = `var(${prefix}${absValue}${mediaName})`;
526
+ return isNegative ? `calc(${varValue2} * -1)` : varValue2;
527
+ }
528
+ const sequenceItem = sequence ? sequence[absValue] : null;
529
+ if (!sequenceItem)
530
+ return console.warn("can't find", sequence, absValue);
531
+ if (unit === "ms" || unit === "s") {
532
+ return isNegative + sequenceItem.val + unit;
533
+ }
534
+ return isNegative + sequenceItem.scaling + unit;
535
+ };
536
+ var getSequenceValuePropertyPair = (value, propertyName, sequenceProps) => {
537
+ if (typeof value !== "string") {
538
+ console.warn(propertyName, value, "is not a string");
539
+ return {};
540
+ }
541
+ if (value === "-" || value === "")
542
+ return {};
543
+ return { [propertyName]: getSequenceValue(value, sequenceProps) };
544
+ };
545
+ var findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
546
+ var findHeadings = (propertyNames) => {
547
+ const { h1Matches, sequence } = propertyNames;
548
+ return new Array(6).fill(null).map((_, i) => {
549
+ const findLetter = findHeadingLetter(h1Matches, i);
550
+ return sequence[findLetter];
551
+ });
552
+ };
553
+
554
+ // src/utils/var.js
555
+ var setVariables = (result, key) => {
556
+ const CONFIG2 = getActiveConfig();
557
+ const { CSS_VARS: CSS_VARS2 } = CONFIG2;
558
+ if (isObjectLike(result.value)) {
559
+ } else {
560
+ CSS_VARS2[result.var] = result.value;
561
+ }
562
+ };
563
+ var applySequenceVars = (props, mediaName, options = {}) => {
564
+ const CONFIG2 = getActiveConfig();
565
+ const { UNIT: UNIT2, MEDIA: MEDIA2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
566
+ const unit = props.unit || UNIT2.default;
567
+ const { sequence, scales } = props;
568
+ for (const key in sequence) {
569
+ const item = sequence[key];
570
+ const value = (props.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
571
+ if (mediaName) {
572
+ const query = MEDIA2[mediaName];
573
+ if (!query) {
574
+ if (CONFIG2.verbose)
575
+ console.warn("Can't find query ", query);
576
+ }
577
+ let underMediaQuery = CSS_VARS2[`@media ${query}`];
578
+ if (!underMediaQuery)
579
+ underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
580
+ underMediaQuery[item.variable] = `var(${item.variable + "-" + mediaName})`;
581
+ CSS_VARS2[item.variable + "-" + mediaName] = value;
582
+ } else {
583
+ if (options.useDefault === false) {
584
+ CSS_VARS2[item.variable] = value;
585
+ } else {
586
+ CSS_VARS2[item.variable + "-default"] = value;
587
+ CSS_VARS2[item.variable] = `var(${item.variable + "-default"})`;
588
+ }
589
+ }
590
+ }
591
+ };
592
+
593
+ // src/defaultConfig/font-family.js
594
+ var FONT_FAMILY = {};
595
+ var FONT_FAMILY_TYPES = {
596
+ serif: "Helvetica, Arial, sans-serif, --system-default",
597
+ "sans-serif": "Times New Roman, Georgia, serif, --system-default",
598
+ monospace: "Courier New, monospace, --system-default"
599
+ };
600
+ var FONT_FACE = getFontFace(FONT_FAMILY);
601
+
602
+ // src/defaultConfig/media.js
603
+ var MEDIA = {
604
+ tv: "(min-width: 2780px)",
605
+ screenL: "(max-width: 1920px)",
606
+ screenM: "(max-width: 1680px)",
607
+ screenS: "(max-width: 1440px)",
608
+ tabletL: "(max-width: 1366px)",
609
+ tabletM: "(max-width: 1280px)",
610
+ tabletS: "(max-width: 1024px)",
611
+ mobileL: "(max-width: 768px)",
612
+ mobileM: "(max-width: 560px)",
613
+ mobileS: "(max-width: 480px)",
614
+ mobileXS: "(max-width: 375px)",
615
+ light: "(prefers-color-scheme: light)",
616
+ dark: "(prefers-color-scheme: dark)",
617
+ print: "print"
618
+ };
619
+
620
+ // src/defaultConfig/spacing.js
621
+ var defaultProps2 = {
622
+ base: TYPOGRAPHY.base,
623
+ type: "spacing",
624
+ ratio: SEQUENCE.phi,
625
+ range: [-5, 15],
626
+ subSequence: true,
627
+ unit: "em",
628
+ sequence: {},
629
+ scales: {},
630
+ vars: {}
631
+ };
632
+ var SPACING = defaultProps2;
633
+
634
+ // src/defaultConfig/color.js
635
+ var COLOR = {};
636
+ var GRADIENT = {};
637
+
638
+ // src/defaultConfig/theme.js
639
+ var THEME = {};
640
+
641
+ // src/defaultConfig/icons.js
642
+ var ICONS = {};
643
+
644
+ // src/defaultConfig/timing.js
645
+ var defaultProps3 = {
646
+ default: 150,
647
+ base: 150,
648
+ type: "timing",
649
+ ratio: SEQUENCE["perfect-fourth"],
650
+ range: [-3, 12],
651
+ unit: "ms",
652
+ sequence: {},
653
+ scales: {},
654
+ vars: {}
655
+ };
656
+ var TIMING = defaultProps3;
657
+
658
+ // src/defaultConfig/document.js
659
+ var DOCUMENT = {};
660
+
661
+ // src/defaultConfig/responsive.js
662
+ var BREAKPOINTS = {
663
+ screenL: 1920,
664
+ screenM: 1680,
665
+ screenS: 1440,
666
+ tabletL: 1366,
667
+ tabletM: 1280,
668
+ tabletS: 1024,
669
+ mobileL: 768,
670
+ mobileM: 560,
671
+ mobileS: 480,
672
+ mobileXS: 375
673
+ };
674
+ var DEVICES = {
675
+ screenL: [1920, 1024],
676
+ screenM: [1680, 1024],
677
+ screenS: [1440, 978],
678
+ tabletL: [1366, 926],
679
+ tabletM: [1280, 768],
680
+ tabletS: [1024, 768],
681
+ mobileL: [768, 375],
682
+ mobileM: [560, 768],
683
+ mobileS: [480, 768],
684
+ mobileXS: [375, 768]
685
+ };
686
+
687
+ // src/defaultConfig/cases.js
688
+ var CASES = {};
689
+
690
+ // src/defaultConfig/animation.js
691
+ var ANIMATION = {};
692
+
693
+ // src/defaultConfig/index.js
694
+ var RESET = {};
695
+
696
+ // src/factory.js
697
+ var CSS_VARS = {};
698
+ var CONFIG = {
699
+ verbose: false,
700
+ useVariable: true,
701
+ useReset: true,
702
+ CSS_VARS,
703
+ ...defaultConfig_exports
704
+ };
705
+ var cachedConfig = deepClone(CONFIG);
706
+ var FACTORY = {
707
+ active: "0",
708
+ 0: CONFIG
709
+ };
710
+ var activateConfig = (def) => {
711
+ if (isDefined(def)) {
712
+ FACTORY.active = def;
713
+ }
714
+ return FACTORY[def || FACTORY.active];
715
+ };
716
+ var getActiveConfig = (def) => {
717
+ if (isDefined(def) && !FACTORY[def]) {
718
+ FACTORY[def] = deepClone(cachedConfig);
719
+ return FACTORY[def];
720
+ }
721
+ return FACTORY[def || FACTORY.active];
722
+ };
723
+
724
+ // src/system/color.js
725
+ var getColor = (value, key) => {
726
+ const CONFIG2 = getActiveConfig();
727
+ if (!isString(value)) {
728
+ if (CONFIG2.verbose)
729
+ console.warn(value, "- type for color is not valid");
730
+ return;
731
+ }
732
+ if (value.slice(0, 2) === "--")
733
+ return `var(${value})`;
734
+ if (key && value[key])
735
+ value = value[key];
736
+ const [name, alpha, tone] = isArray(value) ? value : value.split(" ");
737
+ const { COLOR: COLOR2, GRADIENT: GRADIENT2 } = CONFIG2;
738
+ let val = COLOR2[name] || GRADIENT2[name];
739
+ if (!val) {
740
+ if (CONFIG2.verbose)
741
+ console.warn("Can't find color ", name);
742
+ return value;
743
+ }
744
+ if (key) {
745
+ if (val[key])
746
+ val = val[key];
747
+ else if (CONFIG2.verbose)
748
+ console.warn(value, " - does not have ", key);
749
+ }
750
+ let rgb = val.rgb;
751
+ if (rgb) {
752
+ if (tone) {
753
+ if (!val[tone]) {
754
+ const toHex = rgbArrayToHex(rgb.split(", ").map((v) => parseFloat(v)));
755
+ if (tone.slice(0, 1) === "-" || tone.slice(0, 1) === "+") {
756
+ rgb = hexToRgbArray(getColorShade(toHex, parseFloat(tone))).join(", ");
757
+ } else {
758
+ const [r, g, b] = [...rgb.split(", ").map((v) => parseInt(v))];
759
+ const hsl = rgbToHSL(r, g, b);
760
+ const [h, s, l] = hsl;
761
+ const newRgb = hslToRgb(h, s, parseFloat(tone) / 100 * 255);
762
+ rgb = newRgb;
763
+ }
764
+ val[tone] = { rgb, var: `${val.var}-${tone}` };
765
+ } else
766
+ rgb = val[tone].rgb;
767
+ }
768
+ if (alpha)
769
+ return `rgba(${rgb}, ${alpha})`;
770
+ return CONFIG2.useVariable ? `var(${val.var})` : `rgb(${rgb})`;
771
+ } else
772
+ return CONFIG2.useVariable ? `var(${val.var})` : val.value;
773
+ };
774
+ var getMediaColor = (value, property, globalTheme) => {
775
+ const CONFIG2 = getActiveConfig();
776
+ if (!globalTheme)
777
+ globalTheme = CONFIG2.globalTheme;
778
+ if (!isString(value)) {
779
+ if (CONFIG2.verbose)
780
+ console.warn(value, "- type for color is not valid");
781
+ return;
782
+ }
783
+ if (value.slice(0, 2) === "--")
784
+ return { [property]: `var(${value})` };
785
+ const [name] = isArray(value) ? value : value.split(" ");
786
+ const { COLOR: COLOR2, GRADIENT: GRADIENT2 } = CONFIG2;
787
+ const val = COLOR2[name] || GRADIENT2[name];
788
+ const isObj = isObject(val);
789
+ if (isObj && val.value)
790
+ return { [property]: getColor(value, globalTheme) };
791
+ else if (isObj) {
792
+ if (globalTheme)
793
+ return { [property]: getColor(value, `@${globalTheme}`) };
794
+ else {
795
+ const obj = {};
796
+ for (const mediaName in val) {
797
+ const query = CONFIG2.MEDIA[mediaName.slice(1)];
798
+ const media = `@media screen and ${query}`;
799
+ obj[media] = { [property]: getColor(value, mediaName) };
800
+ }
801
+ return obj;
802
+ }
803
+ } else {
804
+ if (CONFIG2.verbose)
805
+ console.warn("Can't find color", value);
806
+ return { [property]: value };
807
+ }
808
+ };
809
+ var setColor = (val, key, suffix) => {
810
+ const CONFIG2 = getActiveConfig();
811
+ if (isString(val) && val.slice(0, 2) === "--")
812
+ val = getColor(val.slice(2));
813
+ if (isArray(val)) {
814
+ return {
815
+ "@light": setColor(val[0], key, "light"),
816
+ "@dark": setColor(val[1], key, "dark")
817
+ };
818
+ }
819
+ if (isObject(val)) {
820
+ const obj = {};
821
+ for (const variant in val)
822
+ obj[variant] = setColor(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
823
+ return obj;
824
+ }
825
+ const CSSVar = `--color-${key}` + (suffix ? `-${suffix}` : "");
826
+ const [r, g, b, a = 1] = colorStringToRgbaArray(val.value || val);
827
+ const alpha = parseFloat(a.toFixed(2));
828
+ const rgb = `${r}, ${g}, ${b}`;
829
+ const value = `rgba(${rgb}, ${alpha})`;
830
+ if (CONFIG2.useVariable) {
831
+ CONFIG2.CSS_VARS[CSSVar] = value;
832
+ }
833
+ return {
834
+ var: CSSVar,
835
+ rgb,
836
+ alpha,
837
+ value
838
+ };
839
+ };
840
+ var setGradient = (val, key, suffix) => {
841
+ const CONFIG2 = getActiveConfig();
842
+ if (isString(val) && val.slice(0, 2) === "--")
843
+ val = getColor(val.slice(2));
844
+ if (isArray(val)) {
845
+ return {
846
+ "@light": setGradient(val[0], key, "light"),
847
+ "@dark": setGradient(val[0], key, "dark")
848
+ };
849
+ }
850
+ if (isObject(val)) {
851
+ const obj = {};
852
+ for (const variant in val)
853
+ obj[variant] = setGradient(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
854
+ return obj;
855
+ }
856
+ const CSSVar = `--gradient-${key}` + (suffix ? `-${suffix}` : "");
857
+ if (CONFIG2.useVariable) {
858
+ CONFIG2.CSS_VARS[CSSVar] = val.value || val;
859
+ }
860
+ return {
861
+ var: CSSVar,
862
+ value: val.value || val
863
+ };
864
+ };
865
+
866
+ // src/system/theme.js
867
+ var setThemeValue = (theme) => {
868
+ const value = {};
869
+ const { state, media, helpers, ...rest } = theme;
870
+ const keys = Object.keys(rest);
871
+ keys.map((key) => {
872
+ const conditions = ["color", "Color", "background", "border"];
873
+ const isColor = conditions.some((k) => key.includes(k));
874
+ return value[key] = isColor ? getColor(theme[key]) : theme[key];
875
+ });
876
+ return value;
877
+ };
878
+ var getThemeValue = (theme) => {
879
+ if (theme.value)
880
+ return theme.value;
881
+ theme.value = setThemeValue(theme);
882
+ return theme.value;
883
+ };
884
+ var getTheme = (value, modifier) => {
885
+ const CONFIG2 = getActiveConfig();
886
+ if (CONFIG2.useVariable)
887
+ return getMediaTheme(value, modifier);
888
+ const { THEME: THEME2 } = CONFIG2;
889
+ if (isString(value)) {
890
+ const [theme, subtheme] = value.split(" ");
891
+ const isOurTheme = THEME2[theme];
892
+ if (isOurTheme) {
893
+ if (!subtheme && !modifier)
894
+ return getThemeValue(isOurTheme);
895
+ value = [theme, subtheme || modifier];
896
+ }
897
+ }
898
+ if (isObjectLike(value) && value[1]) {
899
+ const themeName = value[0];
900
+ const subThemeName = value[1];
901
+ const { helpers, media, state } = THEME2[themeName];
902
+ if (media && media[subThemeName])
903
+ return getThemeValue(media[subThemeName]);
904
+ if (helpers && helpers[subThemeName])
905
+ return getThemeValue(helpers[subThemeName]);
906
+ if (state && state[subThemeName])
907
+ return getThemeValue(state[subThemeName]);
908
+ } else if (isObject(value))
909
+ return setThemeValue(value);
910
+ };
911
+ var setInverseTheme = (theme, variant, value) => {
912
+ if (isObject(variant)) {
913
+ theme.variants.inverse.value = setThemeValue(variant);
914
+ } else if (variant === true) {
915
+ const { color, background } = value;
916
+ theme.variants.inverse = {
917
+ value: {
918
+ color: background,
919
+ background: color
920
+ }
921
+ };
922
+ }
923
+ };
924
+ var setPseudo = (theme, key, variant, themeValue) => {
925
+ const result = getTheme(variant);
926
+ themeValue[`&:${key}`] = result;
927
+ if (isObject(variant) && !variant.value)
928
+ variant.value = result;
929
+ };
930
+ var setSelectors = (theme, value) => {
931
+ const { state } = theme;
932
+ if (!state)
933
+ return;
934
+ const keys = Object.keys(state);
935
+ keys.map((key) => {
936
+ const variant = state[key];
937
+ setPseudo(theme, key, variant, value);
938
+ return theme;
939
+ });
940
+ return theme;
941
+ };
942
+ var setPrefersScheme = (theme, key, variant, themeValue) => {
943
+ const result = getTheme(variant);
944
+ themeValue[`@media (prefers-color-scheme: ${key})`] = result;
945
+ if (isObject(variant) && !variant.value)
946
+ variant.value = result;
947
+ };
948
+ var setMedia = (theme, value) => {
949
+ const { media } = theme;
950
+ if (!media)
951
+ return;
952
+ const keys = Object.keys(media);
953
+ keys.map((key) => {
954
+ const variant = media[key];
955
+ if (key === "dark" || key === "light")
956
+ setPrefersScheme(theme, key, variant, value);
957
+ if (key === "inverse")
958
+ setInverseTheme(theme, variant, value);
959
+ return theme;
960
+ });
961
+ return theme;
962
+ };
963
+ var setHelpers = (theme, value) => {
964
+ const CONFIG2 = getActiveConfig();
965
+ const { helpers } = theme;
966
+ if (!helpers)
967
+ return;
968
+ const keys = Object.keys(helpers);
969
+ keys.map((key) => {
970
+ const helper = helpers[key];
971
+ if (isString(helper))
972
+ helpers[key] = CONFIG2.THEME[helper];
973
+ else
974
+ getThemeValue(helpers[key]);
975
+ return theme;
976
+ });
977
+ return theme;
978
+ };
979
+ var setTheme = (val, key) => {
980
+ const CONFIG2 = getActiveConfig();
981
+ if (CONFIG2.useVariable)
982
+ return setMediaTheme(val, key);
983
+ const { state, media, helpers } = val;
984
+ const value = setThemeValue(val, key);
985
+ const CSSvar = `--theme-${key}`;
986
+ setSelectors(val, value);
987
+ setMedia(val, value);
988
+ setHelpers(val, value);
989
+ return { var: CSSvar, value, state, media, helpers };
990
+ };
991
+ var setMediaTheme = (val, key, suffix, prefers) => {
992
+ const CONFIG2 = getActiveConfig();
993
+ const { CSS_VARS: CSS_VARS2 } = CONFIG2;
994
+ const theme = { value: val };
995
+ if (isObjectLike(val)) {
996
+ for (const param in val) {
997
+ const symb = param.slice(0, 1);
998
+ const value = val[param];
999
+ if (symb === "@" || symb === ":" || symb === ".") {
1000
+ const hasPrefers = symb === "@" && param;
1001
+ theme[param] = setMediaTheme(value, key, param, prefers || hasPrefers);
1002
+ } else {
1003
+ const color = getColor(value, prefers);
1004
+ const metaSuffixes = [...new Set([prefers, suffix].filter((v) => v).map((v) => v.slice(1)))];
1005
+ const varmetaSuffixName = metaSuffixes.length ? "-" + metaSuffixes.join("-") : "";
1006
+ const CSSVar = `--theme-${key}${varmetaSuffixName}-${param}`;
1007
+ if (CONFIG2.useVariable) {
1008
+ CSS_VARS2[CSSVar] = color;
1009
+ theme[param] = `var(${CSSVar})`;
1010
+ } else {
1011
+ theme[param] = color;
1012
+ }
1013
+ theme[`.${param}`] = { [param]: theme[param] };
1014
+ }
1015
+ }
1016
+ if (theme["background"] || theme["color"] || theme["backgroundColor"]) {
1017
+ theme[".inversed"] = {
1018
+ color: theme["background"] || theme["backgroundColor"],
1019
+ background: theme["color"]
1020
+ };
1021
+ }
1022
+ }
1023
+ if (isString(val) && val.slice(0, 2) === "--") {
1024
+ const { THEME: THEME2 } = CONFIG2;
1025
+ const value = THEME2[val.slice(2)];
1026
+ const getReferenced = getMediaTheme(value);
1027
+ return getReferenced;
1028
+ }
1029
+ return theme;
1030
+ };
1031
+ var recursiveTheme = (val) => {
1032
+ const CONFIG2 = getActiveConfig();
1033
+ const obj = {};
1034
+ for (const param in val) {
1035
+ const symb = param.slice(0, 1);
1036
+ if (isObjectLike(val[param])) {
1037
+ if (symb === "@") {
1038
+ const query = CONFIG2.MEDIA[param.slice(1)];
1039
+ const media = `@media screen and ${query}`;
1040
+ obj[media] = recursiveTheme(val[param]);
1041
+ } else if (symb === ":") {
1042
+ obj[`&${param}`] = recursiveTheme(val[param]);
1043
+ }
1044
+ } else
1045
+ obj[param] = val[param];
1046
+ }
1047
+ return obj;
1048
+ };
1049
+ var findModifierFromArray = (val, modifierArray) => {
1050
+ const currentMod = modifierArray.shift();
1051
+ if (val[currentMod])
1052
+ return findModifierFromArray(val[currentMod], modifierArray);
1053
+ return val;
1054
+ };
1055
+ var findModifier = (val, modifier) => {
1056
+ if (isArray(modifier))
1057
+ return findModifierFromArray(val, modifier);
1058
+ else if (isString(modifier) && val[modifier])
1059
+ return val[modifier];
1060
+ else
1061
+ return val;
1062
+ };
1063
+ var getMediaTheme = (val, mod) => {
1064
+ const CONFIG2 = getActiveConfig();
1065
+ if (isString(val) && val.slice(0, 2) === "--")
1066
+ val = getMediaTheme(val.slice(2));
1067
+ if (!val || !isString(val)) {
1068
+ if (CONFIG2.verbose)
1069
+ console.warn(val, "- theme is not string");
1070
+ return;
1071
+ }
1072
+ const [name, ...modifier] = isArray(val) ? val : val.split(" ");
1073
+ let value = CONFIG2.THEME[name];
1074
+ if (value && (modifier || mod)) {
1075
+ value = findModifier(value, modifier.length ? modifier : mod);
1076
+ }
1077
+ const r = recursiveTheme(value);
1078
+ return r;
1079
+ };
1080
+
1081
+ // src/system/font.js
1082
+ var setFont = (val, key) => {
1083
+ const CSSvar = `--font-${key}`;
1084
+ const fontFace = val[0] ? getFontFaceEach(key, val) : setCustomFontMedia(key, val.url);
1085
+ return { var: CSSvar, value: val, fontFace };
1086
+ };
1087
+ var getFontFamily = (key, factory) => {
1088
+ const CONFIG2 = getActiveConfig();
1089
+ const { FONT_FAMILY: FONT_FAMILY2 } = CONFIG2;
1090
+ return getDefaultOrFirstKey(factory || FONT_FAMILY2, key);
1091
+ };
1092
+ var setFontFamily = (val, key) => {
1093
+ const CONFIG2 = getActiveConfig();
1094
+ const { FONT_FAMILY: FONT_FAMILY2, FONT_FAMILY_TYPES: FONT_FAMILY_TYPES2 } = CONFIG2;
1095
+ let { value, type } = val;
1096
+ if (val.isDefault)
1097
+ FONT_FAMILY2.default = key;
1098
+ if (isObject(value))
1099
+ value = arrayze(value);
1100
+ const CSSvar = `--font-family-${key}`;
1101
+ const str = `${value.join(", ")}, ${FONT_FAMILY_TYPES2[type]}`;
1102
+ return { var: CSSvar, value: str, arr: value, type };
1103
+ };
1104
+
1105
+ // src/system/typography.js
1106
+ var runThroughMedia = (props) => {
1107
+ const CONFIG2 = getActiveConfig();
1108
+ const { TYPOGRAPHY: TYPOGRAPHY2, MEDIA: MEDIA2 } = CONFIG2;
1109
+ for (const prop in props) {
1110
+ const mediaProps = props[prop];
1111
+ if (prop.slice(0, 1) === "@") {
1112
+ const { type, base, ratio, range, subSequence, h1Matches, unit } = props;
1113
+ merge2(mediaProps, {
1114
+ type,
1115
+ base,
1116
+ ratio,
1117
+ range,
1118
+ subSequence,
1119
+ h1Matches,
1120
+ unit,
1121
+ sequence: {},
1122
+ scales: {},
1123
+ styles: {},
1124
+ vars: {}
1125
+ });
1126
+ generateSequence(mediaProps);
1127
+ const mediaName = prop.slice(1);
1128
+ applySequenceVars(mediaProps, mediaName);
1129
+ const query = MEDIA2[mediaName];
1130
+ TYPOGRAPHY2.styles[`@media screen and ${query}`] = {
1131
+ fontSize: mediaProps.base / TYPOGRAPHY2.browserDefault + unit
1132
+ };
1133
+ }
1134
+ }
1135
+ };
1136
+ var applyHeadings = (props) => {
1137
+ const CONFIG2 = getActiveConfig();
1138
+ if (props.h1Matches) {
1139
+ const unit = props.unit;
1140
+ const HEADINGS = findHeadings(props);
1141
+ const { styles } = props;
1142
+ for (const k in HEADINGS) {
1143
+ const headerName = `h${parseInt(k) + 1}`;
1144
+ const headerStyle = styles[headerName];
1145
+ styles[headerName] = {
1146
+ fontSize: CONFIG2.useVariable ? `var(${HEADINGS[k].variable})` : `${HEADINGS[k].scaling}${unit}`,
1147
+ margin: headerStyle ? headerStyle.margin : 0,
1148
+ lineHeight: headerStyle ? headerStyle.lineHeight : props.lineHeight,
1149
+ letterSpacing: headerStyle ? headerStyle.letterSpacing : props.letterSpacing,
1150
+ fontWeight: headerStyle ? headerStyle.fontWeight : 900 - k * 100
1151
+ };
1152
+ }
1153
+ }
1154
+ };
1155
+ var applyTypographySequence = () => {
1156
+ const CONFIG2 = getActiveConfig();
1157
+ const { TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
1158
+ generateSequence(TYPOGRAPHY2);
1159
+ applyHeadings(TYPOGRAPHY2);
1160
+ applySequenceVars(TYPOGRAPHY2);
1161
+ runThroughMedia(TYPOGRAPHY2);
1162
+ };
1163
+ var getFontSizeByKey = (value) => {
1164
+ const CONFIG2 = getActiveConfig();
1165
+ const { TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
1166
+ return getSequenceValuePropertyPair(
1167
+ value,
1168
+ "fontSize",
1169
+ TYPOGRAPHY2
1170
+ );
1171
+ };
1172
+
1173
+ // src/system/spacing.js
1174
+ var runThroughMedia2 = (sequenceProps) => {
1175
+ for (const prop in sequenceProps) {
1176
+ const mediaProps = sequenceProps[prop];
1177
+ if (prop.slice(0, 1) === "@") {
1178
+ const { type, base, ratio, range, subSequence, h1Matches, unit } = sequenceProps;
1179
+ merge2(mediaProps, {
1180
+ type,
1181
+ base,
1182
+ ratio,
1183
+ range,
1184
+ subSequence,
1185
+ h1Matches,
1186
+ unit,
1187
+ sequence: {},
1188
+ scales: {},
1189
+ styles: {},
1190
+ vars: {}
1191
+ });
1192
+ generateSequence(mediaProps);
1193
+ const mediaName = prop.slice(1);
1194
+ applySequenceVars(mediaProps, mediaName);
1195
+ }
1196
+ }
1197
+ };
1198
+ var applySpacingSequence = () => {
1199
+ const CONFIG2 = getActiveConfig();
1200
+ const { SPACING: SPACING2 } = CONFIG2;
1201
+ generateSequence(SPACING2);
1202
+ applySequenceVars(SPACING2);
1203
+ runThroughMedia2(SPACING2);
1204
+ };
1205
+ var getSequence = (sequenceProps) => {
1206
+ const CONFIG2 = getActiveConfig();
1207
+ const { SPACING: SPACING2 } = CONFIG2;
1208
+ if (!sequenceProps)
1209
+ return SPACING2;
1210
+ const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
1211
+ return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
1212
+ };
1213
+ var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
1214
+ const sequence = getSequence(sequenceProps);
1215
+ const stack = arrayze(value);
1216
+ if (!stack)
1217
+ return;
1218
+ if (isString(value) && value.includes("calc")) {
1219
+ return { [propertyName]: value };
1220
+ }
1221
+ if (stack.length > 1) {
1222
+ let suffix = "";
1223
+ if (propertyName === "borderWidth") {
1224
+ propertyName = "border";
1225
+ suffix = "Width";
1226
+ }
1227
+ const directions = {
1228
+ 2: ["Block", "Inline"],
1229
+ 3: ["BlockStart", "Inline", "BlockEnd"],
1230
+ 4: ["BlockStart", "InlineEnd", "BlockEnd", "InlineStart"]
1231
+ };
1232
+ const wrapSequenceValueByDirection = (direction, i) => getSequenceValuePropertyPair(
1233
+ stack[i],
1234
+ propertyName + direction + suffix,
1235
+ sequence
1236
+ );
1237
+ return directions[stack.length].map((dir, key) => wrapSequenceValueByDirection(dir, key));
1238
+ }
1239
+ return getSequenceValuePropertyPair(
1240
+ value,
1241
+ propertyName,
1242
+ sequence
1243
+ );
1244
+ };
1245
+ var getSpacingBasedOnRatio = (props, propertyName, val) => {
1246
+ const CONFIG2 = getActiveConfig();
1247
+ const { SPACING: SPACING2 } = CONFIG2;
1248
+ const { spacingRatio, unit } = props;
1249
+ const value = val || props[propertyName];
1250
+ if (spacingRatio) {
1251
+ let sequenceProps = SPACING2[spacingRatio];
1252
+ if (!sequenceProps) {
1253
+ const { type, base, range, subSequence } = SPACING2;
1254
+ sequenceProps = SPACING2[spacingRatio] = merge2({
1255
+ ratio: spacingRatio,
1256
+ type: type + "-" + spacingRatio,
1257
+ unit,
1258
+ sequence: {},
1259
+ scales: {},
1260
+ styles: {},
1261
+ vars: {}
1262
+ }, {
1263
+ base,
1264
+ range,
1265
+ subSequence,
1266
+ ratio: SPACING2.ratio,
1267
+ unit: SPACING2.unit
1268
+ });
1269
+ }
1270
+ applySequenceVars(sequenceProps, null, { useDefault: false });
1271
+ return getSpacingByKey(value, propertyName, sequenceProps);
1272
+ }
1273
+ return getSpacingByKey(value, propertyName);
1274
+ };
1275
+
1276
+ // src/system/timing.js
1277
+ var applyTimingSequence = () => {
1278
+ const CONFIG2 = getActiveConfig();
1279
+ const { TIMING: TIMING2 } = CONFIG2;
1280
+ generateSequence(TIMING2);
1281
+ applySequenceVars(TIMING2);
1282
+ };
1283
+ var getTimingFunction = (value) => {
1284
+ const CONFIG2 = getActiveConfig();
1285
+ const { TIMING: TIMING2 } = CONFIG2;
1286
+ return TIMING2[value] || TIMING2[toCamelCase(value)] || value;
1287
+ };
1288
+ var getTimingByKey = (value, property = "timing") => {
1289
+ const CONFIG2 = getActiveConfig();
1290
+ const { TIMING: TIMING2 } = CONFIG2;
1291
+ return getSequenceValuePropertyPair(
1292
+ value,
1293
+ property,
1294
+ TIMING2
1295
+ );
1296
+ };
1297
+
1298
+ // src/system/document.js
1299
+ var applyDocument = () => {
1300
+ const CONFIG2 = getActiveConfig();
1301
+ const { DOCUMENT: DOCUMENT2, FONT_FAMILY: FONT_FAMILY2, THEME: THEME2, TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
1302
+ return merge2(DOCUMENT2, {
1303
+ theme: THEME2.document,
1304
+ fontFamily: getDefaultOrFirstKey(FONT_FAMILY2),
1305
+ fontSize: TYPOGRAPHY2.base,
1306
+ lineHeight: TYPOGRAPHY2.lineHeight
1307
+ });
1308
+ };
1309
+
1310
+ // src/system/reset.js
1311
+ var applyReset = (reset = {}) => {
1312
+ const CONFIG2 = getActiveConfig();
1313
+ const { CSS_VARS: CSS_VARS2, RESET: RESET2, TYPOGRAPHY: TYPOGRAPHY2, DOCUMENT: DOCUMENT2 } = CONFIG2;
1314
+ if (RESET2) {
1315
+ if (RESET2[":root"]) {
1316
+ const configReset = RESET2;
1317
+ const configStyles = TYPOGRAPHY2.styles;
1318
+ configReset.body = {
1319
+ ...getMediaTheme("document", `@${CONFIG2.globalTheme}`),
1320
+ ...configStyles.body
1321
+ };
1322
+ configReset.h1 = configStyles.h1;
1323
+ configReset.h2 = configStyles.h2;
1324
+ configReset.h3 = configStyles.h3;
1325
+ configReset.h4 = configStyles.h4;
1326
+ configReset.h5 = configStyles.h5;
1327
+ configReset.h6 = configStyles.h6;
1328
+ }
1329
+ const { body, ...styles } = TYPOGRAPHY2.styles;
1330
+ return deepMerge(merge(RESET2, reset), {
1331
+ html: {
1332
+ position: "absolute",
1333
+ overflow: "hidden",
1334
+ width: "100%",
1335
+ height: "100%",
1336
+ top: "0",
1337
+ left: "0",
1338
+ margin: "0",
1339
+ WebkitFontSmoothing: "antialiased",
1340
+ transform: "translate3d(0, 0, 1px)",
1341
+ scrollBehavior: "smooth",
1342
+ fontSize: TYPOGRAPHY2.browserDefault + "px",
1343
+ fontFamily: DOCUMENT2.fontFamily,
1344
+ lineHeight: DOCUMENT2.lineHeight
1345
+ },
1346
+ body: {
1347
+ boxSizing: "border-box",
1348
+ height: "100%",
1349
+ margin: 0,
1350
+ fontFamily: DOCUMENT2.fontFamily,
1351
+ fontSize: TYPOGRAPHY2.base / TYPOGRAPHY2.browserDefault + CONFIG2.UNIT.default,
1352
+ ...getMediaTheme("document", `@${CONFIG2.globalTheme}`),
1353
+ ...styles,
1354
+ ...body
1355
+ },
1356
+ // form elements
1357
+ fieldset: {
1358
+ border: 0,
1359
+ padding: 0,
1360
+ margin: 0
1361
+ },
1362
+ "select, input": {
1363
+ fontFamily: DOCUMENT2.fontFamily
1364
+ }
1365
+ });
1366
+ }
1367
+ };
1368
+
1369
+ // src/set.js
1370
+ var setCases = (val, key) => {
1371
+ if (isFunction2(val))
1372
+ return val();
1373
+ return val;
1374
+ };
1375
+ var setSameValue = (val, key) => val;
1376
+ var SETTERS = {
1377
+ color: setColor,
1378
+ gradient: setGradient,
1379
+ font: setFont,
1380
+ font_family: setFontFamily,
1381
+ theme: setTheme,
1382
+ typography: setSameValue,
1383
+ cases: setCases,
1384
+ spacing: setSameValue,
1385
+ media: setSameValue,
1386
+ timing: setSameValue,
1387
+ icons: setSameValue,
1388
+ reset: setSameValue,
1389
+ unit: setSameValue,
1390
+ animation: setSameValue
1391
+ };
1392
+ var setValue = (FACTORY_NAME, value, key) => {
1393
+ const CONFIG2 = getActiveConfig();
1394
+ const factoryName = FACTORY_NAME.toLowerCase();
1395
+ const FACTORY2 = CONFIG2[FACTORY_NAME];
1396
+ if (SETTERS[factoryName]) {
1397
+ const result = SETTERS[factoryName](value, key);
1398
+ FACTORY2[key] = result;
1399
+ return FACTORY2;
1400
+ }
1401
+ if (CONFIG2.verbose)
1402
+ console.warn("Can not find", factoryName, "method in scratch");
1403
+ };
1404
+ var setEach = (factoryName, props) => {
1405
+ const CONFIG2 = getActiveConfig();
1406
+ const FACTORY_NAME = factoryName.toUpperCase();
1407
+ const keys = Object.keys(props);
1408
+ keys.map((key) => setValue(FACTORY_NAME, props[key], key));
1409
+ return CONFIG2[FACTORY_NAME];
1410
+ };
1411
+ var SET_OPTIONS = {};
1412
+ var set = (recivedConfig, options = SET_OPTIONS) => {
1413
+ let CONFIG2 = getActiveConfig();
1414
+ const { version, verbose, useVariable, useReset, globalTheme, ...config } = recivedConfig;
1415
+ if (options.newConfig) {
1416
+ FACTORY["active"] = options.newConfig;
1417
+ CONFIG2 = getActiveConfig(options.newConfig);
1418
+ }
1419
+ if (verbose !== void 0)
1420
+ CONFIG2.verbose = verbose;
1421
+ if (useVariable !== void 0)
1422
+ CONFIG2.useVariable = useVariable;
1423
+ if (useReset !== void 0)
1424
+ CONFIG2.useReset = useReset;
1425
+ if (globalTheme !== void 0)
1426
+ CONFIG2.globalTheme = globalTheme;
1427
+ if (CONFIG2.verbose)
1428
+ console.log(CONFIG2);
1429
+ const keys = Object.keys(config);
1430
+ keys.map((key) => setEach(key, config[key]));
1431
+ applyTypographySequence();
1432
+ applySpacingSequence();
1433
+ applyTimingSequence();
1434
+ applyDocument();
1435
+ applyReset();
1436
+ return CONFIG2;
1437
+ };
1438
+ export {
1439
+ ANIMATION,
1440
+ BREAKPOINTS,
1441
+ CASES,
1442
+ COLOR,
1443
+ CONFIG,
1444
+ CSS_VARS,
1445
+ DEVICES,
1446
+ DOCUMENT,
1447
+ FACTORY,
1448
+ FONT,
1449
+ FONT_FACE,
1450
+ FONT_FAMILY,
1451
+ FONT_FAMILY_TYPES,
1452
+ GRADIENT,
1453
+ ICONS,
1454
+ MEDIA,
1455
+ RESET,
1456
+ SEQUENCE,
1457
+ SETTERS,
1458
+ SPACING,
1459
+ THEME,
1460
+ TIMING,
1461
+ TYPOGRAPHY,
1462
+ UNIT,
1463
+ activateConfig,
1464
+ applyDocument,
1465
+ applyHeadings,
1466
+ applyReset,
1467
+ applySequenceVars,
1468
+ applySpacingSequence,
1469
+ applyTimingSequence,
1470
+ applyTypographySequence,
1471
+ arrayze,
1472
+ changeLightness,
1473
+ colorStringToRgbaArray,
1474
+ deepMerge2 as deepMerge,
1475
+ findHeadingLetter,
1476
+ findHeadings,
1477
+ generateSequence,
1478
+ generateSubSequence,
1479
+ getActiveConfig,
1480
+ getColor,
1481
+ getColorShade,
1482
+ getDefaultOrFirstKey,
1483
+ getFontFace,
1484
+ getFontFaceEach,
1485
+ getFontFaceEachString,
1486
+ getFontFaceString,
1487
+ getFontFamily,
1488
+ getFontFormat,
1489
+ getFontSizeByKey,
1490
+ getMediaColor,
1491
+ getMediaTheme,
1492
+ getSequenceValue,
1493
+ getSequenceValuePropertyPair,
1494
+ getSpacingBasedOnRatio,
1495
+ getSpacingByKey,
1496
+ getTheme,
1497
+ getTimingByKey,
1498
+ getTimingFunction,
1499
+ hexToRgb,
1500
+ hexToRgbArray,
1501
+ hexToRgba,
1502
+ hslToRgb,
1503
+ isArray2 as isArray,
1504
+ isFunction2 as isFunction,
1505
+ isObject2 as isObject,
1506
+ isObjectLike2 as isObjectLike,
1507
+ isString2 as isString,
1508
+ merge2 as merge,
1509
+ mixTwoColors,
1510
+ mixTwoRgb,
1511
+ mixTwoRgba,
1512
+ numToLetterMap,
1513
+ opacify,
1514
+ rgbArrayToHex,
1515
+ rgbToHSL,
1516
+ rgbToHex,
1517
+ runThroughMedia,
1518
+ set,
1519
+ setColor,
1520
+ setCustomFont,
1521
+ setCustomFontMedia,
1522
+ setEach,
1523
+ setFont,
1524
+ setFontFamily,
1525
+ setGradient,
1526
+ setInCustomFontMedia,
1527
+ setMediaTheme,
1528
+ setTheme,
1529
+ setValue,
1530
+ setVariables
1531
+ };