@symbo.ls/scratch 3.2.3 → 3.2.7

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
package/dist/cjs/set.js CHANGED
@@ -1,13 +1,8 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
6
  var __export = (target, all) => {
12
7
  for (var name in all)
13
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -20,435 +15,7 @@ var __copyProps = (to, from, except, desc) => {
20
15
  }
21
16
  return to;
22
17
  };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
- mod
30
- ));
31
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
-
33
- // ../utils/dist/cjs/index.js
34
- var require_cjs = __commonJS({
35
- "../utils/dist/cjs/index.js"(exports, module2) {
36
- "use strict";
37
- var __defProp3 = Object.defineProperty;
38
- var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
39
- var __getOwnPropNames2 = Object.getOwnPropertyNames;
40
- var __hasOwnProp3 = Object.prototype.hasOwnProperty;
41
- var __export2 = (target, all) => {
42
- for (var name in all)
43
- __defProp3(target, name, { get: all[name], enumerable: true });
44
- };
45
- var __copyProps2 = (to, from, except, desc) => {
46
- if (from && typeof from === "object" || typeof from === "function") {
47
- for (let key of __getOwnPropNames2(from))
48
- if (!__hasOwnProp3.call(to, key) && key !== except)
49
- __defProp3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
50
- }
51
- return to;
52
- };
53
- var __toCommonJS2 = (mod) => __copyProps2(__defProp3({}, "__esModule", { value: true }), mod);
54
- var index_exports = {};
55
- __export2(index_exports, {
56
- arrayzeValue: () => arrayzeValue3,
57
- copyJavaScriptToClipboard: () => copyJavaScriptToClipboard,
58
- copyStringToClipboard: () => copyStringToClipboard,
59
- fibonacciNumberByIndex: () => fibonacciNumberByIndex,
60
- findClosestNumber: () => findClosestNumber,
61
- findClosestNumberInFactory: () => findClosestNumberInFactory,
62
- formatDate: () => formatDate,
63
- isPhoto: () => isPhoto,
64
- loadCssFile: () => loadCssFile,
65
- loadJavascript: () => loadJavascript,
66
- loadJavascriptFile: () => loadJavascriptFile,
67
- loadJavascriptFileEmbedSync: () => loadJavascriptFileEmbedSync,
68
- loadJavascriptFileSync: () => loadJavascriptFileSync,
69
- loadRemoteCSS: () => loadRemoteCSS,
70
- loadRemoteScript: () => loadRemoteScript,
71
- removeChars: () => removeChars,
72
- toCamelCase: () => toCamelCase2,
73
- toDashCase: () => toDashCase2,
74
- toDescriptionCase: () => toDescriptionCase,
75
- toTitleCase: () => toTitleCase,
76
- toggleFullscreen: () => toggleFullscreen
77
- });
78
- module2.exports = __toCommonJS2(index_exports);
79
- var window22 = globalThis;
80
- var document22 = window22.document;
81
- var isObject2 = (arg) => {
82
- if (arg === null) return false;
83
- return typeof arg === "object" && arg.constructor === Object;
84
- };
85
- var isString2 = (arg) => typeof arg === "string";
86
- var isNumber2 = (arg) => typeof arg === "number";
87
- var isArray2 = (arg) => Array.isArray(arg);
88
- var STATE_METHODS3 = [
89
- "update",
90
- "parse",
91
- "clean",
92
- "create",
93
- "destroy",
94
- "add",
95
- "toggle",
96
- "remove",
97
- "apply",
98
- "set",
99
- "reset",
100
- "replace",
101
- "quietReplace",
102
- "quietUpdate",
103
- "applyReplace",
104
- "applyFunction",
105
- "keys",
106
- "values",
107
- "ref",
108
- "rootUpdate",
109
- "parentUpdate",
110
- "parent",
111
- "__element",
112
- "__depends",
113
- "__ref",
114
- "__children",
115
- "root",
116
- "setByPath",
117
- "setPathCollection",
118
- "removeByPath",
119
- "removePathCollection",
120
- "getByPath"
121
- ];
122
- var PROPS_METHODS3 = ["update", "__element"];
123
- var METHODS3 = [
124
- "set",
125
- "reset",
126
- "update",
127
- "remove",
128
- "updateContent",
129
- "removeContent",
130
- "lookup",
131
- "lookdown",
132
- "lookdownAll",
133
- "getRef",
134
- "getPath",
135
- "setNodeStyles",
136
- "spotByPath",
137
- "keys",
138
- "parse",
139
- "setProps",
140
- "parseDeep",
141
- "variables",
142
- "if",
143
- "log",
144
- "verbose",
145
- "warn",
146
- "error",
147
- "call",
148
- "nextElement",
149
- "previousElement"
150
- ];
151
- var METHODS_EXL3 = [
152
- ...["node", "context", "extends", "__element", "__ref"],
153
- ...METHODS3,
154
- ...STATE_METHODS3,
155
- ...PROPS_METHODS3
156
- ];
157
- var isMobile2 = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
158
- var STATE_METHODS22 = [
159
- "update",
160
- "parse",
161
- "clean",
162
- "create",
163
- "destroy",
164
- "add",
165
- "toggle",
166
- "remove",
167
- "apply",
168
- "set",
169
- "reset",
170
- "replace",
171
- "quietReplace",
172
- "quietUpdate",
173
- "applyReplace",
174
- "applyFunction",
175
- "keys",
176
- "values",
177
- "ref",
178
- "rootUpdate",
179
- "parentUpdate",
180
- "parent",
181
- "__element",
182
- "__depends",
183
- "__ref",
184
- "__children",
185
- "root",
186
- "setByPath",
187
- "setPathCollection",
188
- "removeByPath",
189
- "removePathCollection",
190
- "getByPath"
191
- ];
192
- var PROPS_METHODS22 = ["update", "__element"];
193
- var METHODS22 = [
194
- "set",
195
- "reset",
196
- "update",
197
- "remove",
198
- "updateContent",
199
- "removeContent",
200
- "lookup",
201
- "lookdown",
202
- "lookdownAll",
203
- "getRef",
204
- "getPath",
205
- "setNodeStyles",
206
- "spotByPath",
207
- "keys",
208
- "parse",
209
- "setProps",
210
- "parseDeep",
211
- "variables",
212
- "if",
213
- "log",
214
- "verbose",
215
- "warn",
216
- "error",
217
- "call",
218
- "nextElement",
219
- "previousElement"
220
- ];
221
- var METHODS_EXL22 = [
222
- ...["node", "context", "extends", "__element", "__ref"],
223
- ...METHODS22,
224
- ...STATE_METHODS22,
225
- ...PROPS_METHODS22
226
- ];
227
- var window32 = globalThis;
228
- var document32 = window32.document;
229
- async function toggleFullscreen(opts) {
230
- if (!document.fullscreenElement) {
231
- try {
232
- await (this.node || document).requestFullscreen();
233
- } catch (err) {
234
- console.warn(`Error attempting to enable fullscreen mode: ${err.message} (${err.name})`);
235
- }
236
- } else {
237
- await document.exitFullscreen();
238
- }
239
- }
240
- var findClosestNumber = (number, arr) => {
241
- return (isArray2(arr) ? arr : Object.values(arr)).reduce((prev, curr) => {
242
- return Math.abs(curr - number) < Math.abs(prev - number) ? curr : prev;
243
- });
244
- };
245
- var findClosestNumberInFactory = (val, factory) => {
246
- val = parseFloat(val);
247
- if (isObject2(factory)) factory = Object.values(factory);
248
- return findClosestNumber(val, factory);
249
- };
250
- var formatDate = (timestamp) => {
251
- if (!timestamp) return "";
252
- const d = new Date(timestamp);
253
- const ye = new Intl.DateTimeFormat("en", { year: "numeric" }).format(d);
254
- const mo = new Intl.DateTimeFormat("en", { month: "short" }).format(d);
255
- const da = new Intl.DateTimeFormat("en", { day: "2-digit" }).format(d);
256
- return `${da} ${mo}, ${ye}`;
257
- };
258
- var fibonacciNumberByIndex = function fibonacciNumberByIndex2(n) {
259
- const fib = [0, 1];
260
- for (let i = 2; i <= n; i++) {
261
- fib[i] = fib[i - 1] + fib[i - 2];
262
- }
263
- return fib[n];
264
- };
265
- var loadJavascriptFile = (FILE_URL, async = false, doc = document, type = "text/javascript") => {
266
- return new Promise((resolve, reject) => {
267
- try {
268
- const scriptEle = doc.createElement("script");
269
- scriptEle.type = type;
270
- scriptEle.async = async;
271
- scriptEle.src = FILE_URL;
272
- scriptEle.addEventListener("load", (ev) => {
273
- resolve({
274
- status: true
275
- });
276
- });
277
- scriptEle.addEventListener("error", (ev) => {
278
- reject(
279
- new Error({
280
- status: false,
281
- message: `Failed to load the script ${FILE_URL}`
282
- })
283
- );
284
- });
285
- doc.body.appendChild(scriptEle);
286
- } catch (error) {
287
- reject(error);
288
- }
289
- });
290
- };
291
- var loadJavascriptFileSync = (fileUrl, doc = document, type = "text/javascript") => {
292
- return new Promise((resolve, reject) => {
293
- const scriptEle = doc.createElement("script");
294
- scriptEle.type = type;
295
- scriptEle.src = fileUrl;
296
- const blocker = doc.createElement("div");
297
- blocker.style.cssText = "position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(255,255,255,0.8);z-index:9999;";
298
- doc.body.appendChild(blocker);
299
- scriptEle.onload = () => {
300
- console.log(`Successfully loaded: ${fileUrl}`);
301
- doc.body.removeChild(blocker);
302
- resolve();
303
- };
304
- scriptEle.onerror = () => {
305
- doc.body.removeChild(blocker);
306
- reject(new Error(`Failed to load: ${fileUrl}`));
307
- };
308
- doc.body.appendChild(scriptEle);
309
- });
310
- };
311
- var loadJavascriptFileEmbedSync = (FILE_URL, doc = document, fallback, type = "text/javascript") => {
312
- const xhr = new window.XMLHttpRequest();
313
- xhr.open("GET", FILE_URL, false);
314
- xhr.send();
315
- if (xhr.status === 200) {
316
- const scriptEle = doc.createElement("script");
317
- scriptEle.type = type;
318
- scriptEle.text = xhr.responseText;
319
- doc.body.appendChild(scriptEle);
320
- if (typeof fallback === "function") fallback();
321
- } else {
322
- throw new Error(`Failed to load the script ${FILE_URL}`);
323
- }
324
- };
325
- var loadCssFile = (FILE_URL, async = false, doc = document, type = "text/javascript") => {
326
- return new Promise((resolve, reject) => {
327
- try {
328
- const linkElem = doc.createElement("link");
329
- linkElem.rel = "stylesheet";
330
- linkElem.href = FILE_URL;
331
- linkElem.addEventListener("load", (ev) => {
332
- resolve({
333
- status: true
334
- });
335
- });
336
- doc.head.appendChild(linkElem);
337
- } catch (error) {
338
- reject(error);
339
- }
340
- });
341
- };
342
- var loadJavascript = (body, async = false, doc = document, type = "text/javascript", id = "smbls-script") => {
343
- try {
344
- const scriptEle = doc.createElement("script");
345
- scriptEle.type = type;
346
- scriptEle.async = async;
347
- scriptEle.id = id;
348
- scriptEle.innerHTML = body;
349
- doc.body.appendChild(scriptEle);
350
- } catch (error) {
351
- console.warn(error);
352
- }
353
- };
354
- function loadRemoteScript(url, options = {}) {
355
- const { window: window4 = globalThis } = options;
356
- const { document: document4 = window4.document } = options;
357
- return new Promise((resolve, reject) => {
358
- const existingScript = document4.querySelector(`script[src="${url}"]`);
359
- if (existingScript) {
360
- return resolve(existingScript);
361
- }
362
- const script = document4.createElement("script");
363
- script.src = url;
364
- script.async = options.async === true;
365
- script.type = options.type || "text/javascript";
366
- if (options.id) script.id = options.id;
367
- if (options.integrity) script.integrity = options.integrity;
368
- if (options.crossOrigin) script.crossOrigin = options.crossOrigin;
369
- script.onload = () => {
370
- script.onerror = script.onload = null;
371
- resolve(script);
372
- };
373
- script.onerror = () => {
374
- script.onerror = script.onload = null;
375
- reject(new Error(`Failed to load script: ${url}`));
376
- };
377
- document4.head.appendChild(script);
378
- });
379
- }
380
- async function loadRemoteCSS(url, options = {}) {
381
- const { window: window4 = globalThis } = options;
382
- const { document: document4 = window4.document } = options;
383
- return new Promise((resolve, reject) => {
384
- const existingLink = document4.querySelector(`link[href="${url}"]`);
385
- if (existingLink) {
386
- return resolve(existingLink);
387
- }
388
- const link = document4.createElement("link");
389
- link.href = url;
390
- link.rel = options.rel || "stylesheet";
391
- link.type = "text/css";
392
- link.media = options.media || "all";
393
- if (options.id) link.id = options.id;
394
- if (options.integrity) link.integrity = options.integrity;
395
- if (options.crossOrigin) link.crossOrigin = options.crossOrigin;
396
- link.onload = () => {
397
- link.onerror = link.onload = null;
398
- resolve(link);
399
- };
400
- link.onerror = () => {
401
- link.onerror = link.onload = null;
402
- reject(new Error(`Failed to load stylesheet: ${url}`));
403
- };
404
- document4.head.appendChild(link);
405
- });
406
- }
407
- var isPhoto = (format) => ["jpeg", "gif", "jpg", "png", "tiff", "woff"].includes(format);
408
- var copyStringToClipboard = async (str) => {
409
- try {
410
- await navigator.clipboard.writeText(str);
411
- } catch (err) {
412
- console.warn("Failed to copy text: ", err);
413
- }
414
- };
415
- var copyJavaScriptToClipboard = async (jsCode) => {
416
- try {
417
- const blob = new Blob([jsCode], { type: "text/javascript" });
418
- const clipboardItem = new window.ClipboardItem({ "text/plain": blob });
419
- await navigator.clipboard.write([clipboardItem]);
420
- console.log("JavaScript code copied to clipboard as text/javascript");
421
- } catch (err) {
422
- console.error("Failed to copy JavaScript code: ", err);
423
- }
424
- };
425
- var removeChars = (str) => {
426
- return str.replace(/[^a-zA-Z0-9_]/g, "");
427
- };
428
- var toCamelCase2 = (str) => {
429
- return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
430
- return index === 0 ? word.toLowerCase() : word.toUpperCase();
431
- }).replaceAll(/\s+/g, "");
432
- };
433
- var toTitleCase = (str) => str && str.replace(/\w\S*/g, (txt) => {
434
- return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
435
- });
436
- var toDashCase2 = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
437
- var toDescriptionCase = (str = "") => {
438
- if (typeof str !== "string") return;
439
- const result = str.replace(/([A-Z])/g, " $1");
440
- return result.charAt(0).toUpperCase() + result.slice(1);
441
- };
442
- var arrayzeValue3 = (val) => {
443
- if (isArray2(val)) return val;
444
- if (isString2(val)) return val.split(" ");
445
- if (isObject2(val)) return Object.values(val);
446
- if (isNumber2(val)) return [val];
447
- };
448
- }
449
- });
450
-
451
- // src/set.js
452
19
  var set_exports = {};
453
20
  __export(set_exports, {
454
21
  VALUE_TRANSFORMERS: () => VALUE_TRANSFORMERS,
@@ -457,1598 +24,27 @@ __export(set_exports, {
457
24
  setValue: () => setValue
458
25
  });
459
26
  module.exports = __toCommonJS(set_exports);
460
-
461
- // ../../../domql/packages/utils/dist/esm/globals.js
462
- var window2 = globalThis;
463
- var document2 = window2.document;
464
-
465
- // ../../../domql/packages/utils/dist/esm/node.js
466
- var isDOMNode = (obj) => {
467
- return typeof window2 !== "undefined" && (obj instanceof window2.Node || obj instanceof window2.Window || obj === window2 || obj === document);
468
- };
469
-
470
- // ../../../domql/packages/utils/dist/esm/types.js
471
- var isObject = (arg) => {
472
- if (arg === null) return false;
473
- return typeof arg === "object" && arg.constructor === Object;
474
- };
475
- var isString = (arg) => typeof arg === "string";
476
- var isNumber = (arg) => typeof arg === "number";
477
- var isFunction = (arg) => typeof arg === "function";
478
- var isNull = (arg) => arg === null;
479
- var isArray = (arg) => Array.isArray(arg);
480
- var isObjectLike = (arg) => {
481
- if (arg === null) return false;
482
- return typeof arg === "object";
483
- };
484
- var isUndefined = (arg) => {
485
- return arg === void 0;
486
- };
487
-
488
- // ../../../domql/packages/utils/dist/esm/array.js
489
- var unstackArrayOfObjects = (arr, exclude = []) => {
490
- return arr.reduce(
491
- (a, c) => deepMerge(a, deepClone(c, { exclude }), exclude),
492
- {}
493
- );
494
- };
495
-
496
- // ../../../domql/packages/utils/dist/esm/keys.js
497
- var STATE_METHODS = [
498
- "update",
499
- "parse",
500
- "clean",
501
- "create",
502
- "destroy",
503
- "add",
504
- "toggle",
505
- "remove",
506
- "apply",
507
- "set",
508
- "reset",
509
- "replace",
510
- "quietReplace",
511
- "quietUpdate",
512
- "applyReplace",
513
- "applyFunction",
514
- "keys",
515
- "values",
516
- "ref",
517
- "rootUpdate",
518
- "parentUpdate",
519
- "parent",
520
- "__element",
521
- "__depends",
522
- "__ref",
523
- "__children",
524
- "root",
525
- "setByPath",
526
- "setPathCollection",
527
- "removeByPath",
528
- "removePathCollection",
529
- "getByPath"
530
- ];
531
- var PROPS_METHODS = ["update", "__element"];
532
- var METHODS = [
533
- "set",
534
- "reset",
535
- "update",
536
- "remove",
537
- "updateContent",
538
- "removeContent",
539
- "lookup",
540
- "lookdown",
541
- "lookdownAll",
542
- "getRef",
543
- "getPath",
544
- "setNodeStyles",
545
- "spotByPath",
546
- "keys",
547
- "parse",
548
- "setProps",
549
- "parseDeep",
550
- "variables",
551
- "if",
552
- "log",
553
- "verbose",
554
- "warn",
555
- "error",
556
- "call",
557
- "nextElement",
558
- "previousElement"
559
- ];
560
- var METHODS_EXL = [
561
- ...["node", "context", "extends", "__element", "__ref"],
562
- ...METHODS,
563
- ...STATE_METHODS,
564
- ...PROPS_METHODS
565
- ];
566
-
567
- // ../../../domql/packages/utils/dist/esm/object.js
568
- var __defProp2 = Object.defineProperty;
569
- var __defProps = Object.defineProperties;
570
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
571
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
572
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
573
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
574
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
575
- var __spreadValues = (a, b) => {
576
- for (var prop in b || (b = {}))
577
- if (__hasOwnProp2.call(b, prop))
578
- __defNormalProp(a, prop, b[prop]);
579
- if (__getOwnPropSymbols)
580
- for (var prop of __getOwnPropSymbols(b)) {
581
- if (__propIsEnum.call(b, prop))
582
- __defNormalProp(a, prop, b[prop]);
583
- }
584
- return a;
585
- };
586
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
587
- var merge = (element, obj, excludeFrom = []) => {
588
- for (const e in obj) {
589
- const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(obj, e);
590
- if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__")) {
591
- continue;
592
- }
593
- const elementProp = element[e];
594
- const objProp = obj[e];
595
- if (elementProp === void 0) {
596
- element[e] = objProp;
597
- }
598
- }
599
- return element;
600
- };
601
- var deepMerge = (element, extend, excludeFrom = METHODS_EXL) => {
602
- for (const e in extend) {
603
- const hasOwnProperty2 = Object.prototype.hasOwnProperty.call(extend, e);
604
- if (!hasOwnProperty2 || excludeFrom.includes(e) || e.startsWith("__")) {
605
- continue;
606
- }
607
- const elementProp = element[e];
608
- const extendProp = extend[e];
609
- if (isObjectLike(elementProp) && isObjectLike(extendProp)) {
610
- deepMerge(elementProp, extendProp, excludeFrom);
611
- } else if (elementProp === void 0) {
612
- element[e] = extendProp;
613
- }
614
- }
615
- return element;
616
- };
617
- var deepClone = (obj, options = {}) => {
618
- const {
619
- exclude = [],
620
- cleanUndefined = false,
621
- cleanNull = false,
622
- window: targetWindow,
623
- visited = /* @__PURE__ */ new WeakMap(),
624
- handleExtends = false
625
- } = options;
626
- const contentWindow = targetWindow || window2 || globalThis;
627
- if (!isObjectLike(obj) || isDOMNode(obj)) {
628
- return obj;
629
- }
630
- if (visited.has(obj)) {
631
- return visited.get(obj);
632
- }
633
- const clone2 = contentWindow ? isArray(obj) ? new contentWindow.Array() : new contentWindow.Object() : isArray(obj) ? [] : {};
634
- visited.set(obj, clone2);
635
- for (const key in obj) {
636
- if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
637
- if (exclude.includes(key) || key.startsWith("__") || key === "__proto__") {
638
- continue;
639
- }
640
- const value = obj[key];
641
- if (cleanUndefined && isUndefined(value) || cleanNull && isNull(value)) {
642
- continue;
643
- }
644
- if (isDOMNode(value)) {
645
- clone2[key] = value;
646
- continue;
647
- }
648
- if (handleExtends && key === "extends" && isArray(value)) {
649
- clone2[key] = unstackArrayOfObjects(value, exclude);
650
- continue;
651
- }
652
- if (isFunction(value) && options.window) {
653
- clone2[key] = contentWindow.eval("(" + value.toString() + ")");
654
- continue;
655
- }
656
- if (isObjectLike(value)) {
657
- clone2[key] = deepClone(value, __spreadProps(__spreadValues({}, options), {
658
- visited
659
- }));
660
- } else {
661
- clone2[key] = value;
662
- }
663
- }
664
- return clone2;
665
- };
666
- var overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new WeakMap()) => {
667
- const excl = opts.exclude || [];
668
- const forcedExclude = opts.preventForce ? [] : ["node", "window"];
669
- if (!isObjectLike(obj) || !isObjectLike(params) || isDOMNode(obj) || isDOMNode(params)) {
670
- return params;
671
- }
672
- if (visited.has(obj)) return visited.get(obj);
673
- visited.set(obj, obj);
674
- for (const e in params) {
675
- if (!Object.hasOwnProperty.call(params, e)) continue;
676
- if (excl.includes(e) || forcedExclude && e.startsWith("__")) continue;
677
- const objProp = obj[e];
678
- const paramsProp = params[e];
679
- if (isDOMNode(paramsProp)) {
680
- obj[e] = paramsProp;
681
- } else if (isObjectLike(objProp) && isObjectLike(paramsProp)) {
682
- obj[e] = overwriteDeep(objProp, paramsProp, opts, visited);
683
- } else if (paramsProp !== void 0) {
684
- obj[e] = paramsProp;
685
- }
686
- }
687
- return obj;
688
- };
689
-
690
- // ../../../domql/packages/utils/dist/esm/env.js
691
- var NODE_ENV = "development";
692
- var isProduction = (env = NODE_ENV) => env === "production";
693
- var isNotProduction = (env = NODE_ENV) => !isProduction(env);
694
-
695
- // ../../../domql/packages/utils/dist/esm/cookie.js
696
- var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
697
-
698
- // ../../../domql/packages/event/dist/esm/keys.js
699
- var STATE_METHODS2 = [
700
- "update",
701
- "parse",
702
- "clean",
703
- "create",
704
- "destroy",
705
- "add",
706
- "toggle",
707
- "remove",
708
- "apply",
709
- "set",
710
- "reset",
711
- "replace",
712
- "quietReplace",
713
- "quietUpdate",
714
- "applyReplace",
715
- "applyFunction",
716
- "keys",
717
- "values",
718
- "ref",
719
- "rootUpdate",
720
- "parentUpdate",
721
- "parent",
722
- "__element",
723
- "__depends",
724
- "__ref",
725
- "__children",
726
- "root",
727
- "setByPath",
728
- "setPathCollection",
729
- "removeByPath",
730
- "removePathCollection",
731
- "getByPath"
732
- ];
733
- var PROPS_METHODS2 = ["update", "__element"];
734
- var METHODS2 = [
735
- "set",
736
- "reset",
737
- "update",
738
- "remove",
739
- "updateContent",
740
- "removeContent",
741
- "lookup",
742
- "lookdown",
743
- "lookdownAll",
744
- "getRef",
745
- "getPath",
746
- "setNodeStyles",
747
- "spotByPath",
748
- "keys",
749
- "parse",
750
- "setProps",
751
- "parseDeep",
752
- "variables",
753
- "if",
754
- "log",
755
- "verbose",
756
- "warn",
757
- "error",
758
- "call",
759
- "nextElement",
760
- "previousElement"
761
- ];
762
- var METHODS_EXL2 = [
763
- ...["node", "context", "extends", "__element", "__ref"],
764
- ...METHODS2,
765
- ...STATE_METHODS2,
766
- ...PROPS_METHODS2
767
- ];
768
-
769
- // ../../../domql/packages/event/dist/esm/globals.js
770
- var window3 = globalThis;
771
- var document3 = window3.document;
772
-
773
- // src/defaultConfig/index.js
774
- var defaultConfig_exports = {};
775
- __export(defaultConfig_exports, {
776
- ANIMATION: () => ANIMATION,
777
- BREAKPOINTS: () => BREAKPOINTS,
778
- CASES: () => CASES,
779
- CLASS: () => CLASS,
780
- COLOR: () => COLOR,
781
- DEVICES: () => DEVICES,
782
- DOCUMENT: () => DOCUMENT,
783
- FONT: () => FONT,
784
- FONT_FACE: () => FONT_FACE,
785
- FONT_FAMILY: () => FONT_FAMILY,
786
- FONT_FAMILY_TYPES: () => FONT_FAMILY_TYPES,
787
- GRADIENT: () => GRADIENT,
788
- GRID: () => GRID,
789
- ICONS: () => ICONS,
790
- MEDIA: () => MEDIA,
791
- RESET: () => RESET,
792
- SEMANTIC_ICONS: () => SEMANTIC_ICONS,
793
- SEQUENCE: () => SEQUENCE,
794
- SHADOW: () => SHADOW,
795
- SPACING: () => SPACING,
796
- SVG: () => SVG,
797
- SVG_DATA: () => SVG_DATA,
798
- TEMPLATES: () => TEMPLATES,
799
- THEME: () => THEME,
800
- TIMING: () => TIMING,
801
- TYPOGRAPHY: () => TYPOGRAPHY,
802
- UNIT: () => UNIT
803
- });
804
-
805
- // src/defaultConfig/sequence.js
806
- var SEQUENCE = {
807
- "minor-second": 1.067,
808
- "major-second": 1.125,
809
- "minor-third": 1.2,
810
- "major-third": 1.25,
811
- "perfect-fourth": 1.333,
812
- "augmented-fourth": 1.414,
813
- "perfect-fifth": 1.5,
814
- "minor-sixth": 1.6,
815
- phi: 1.618,
816
- // golden-ratio
817
- "major-sixth": 1.667,
818
- "square-root-3": 1.732,
819
- // theodorus
820
- "minor-seventh": 1.778,
821
- "major-seventh": 1.875,
822
- octave: 2,
823
- "square-root-5": 2.23,
824
- // pythagoras
825
- "major-tenth": 2.5,
826
- "major-eleventh": 2.667,
827
- "major-twelfth": 3,
828
- pi: 3.14,
829
- // archimedes
830
- "double-octave": 4
831
- };
832
-
833
- // src/defaultConfig/unit.js
834
- var UNIT = {
835
- default: "em"
836
- };
837
-
838
- // src/defaultConfig/typography.js
839
- var defaultProps = {
840
- browserDefault: 16,
841
- base: 16,
842
- type: "font-size",
843
- ratio: SEQUENCE["minor-third"],
844
- range: [-3, 12],
845
- h1Matches: 6,
846
- lineHeight: 1.5,
847
- subSequence: true,
848
- mediaRegenerate: false,
849
- unit: "em",
850
- templates: {},
851
- sequence: {},
852
- scales: {},
853
- vars: {}
854
- };
855
- var TYPOGRAPHY = defaultProps;
856
-
857
- // src/defaultConfig/font.js
858
- var FONT = {};
859
-
860
- // src/defaultConfig/font-family.js
861
- var FONT_FAMILY = {};
862
- var FONT_FAMILY_TYPES = {
863
- "sans-serif": "Helvetica, Arial, sans-serif, --system-default",
864
- serif: "Times New Roman, Georgia, serif, --system-default",
865
- monospace: "Courier New, monospace, --system-default"
866
- };
867
- var FONT_FACE = {};
868
-
869
- // src/defaultConfig/media.js
870
- var MEDIA = {
871
- tv: "(min-width: 2780px)",
872
- light: "(prefers-color-scheme: light)",
873
- dark: "(prefers-color-scheme: dark)",
874
- print: "print"
875
- };
876
-
877
- // src/defaultConfig/spacing.js
878
- var defaultProps2 = {
879
- base: TYPOGRAPHY.base,
880
- type: "spacing",
881
- ratio: SEQUENCE.phi,
882
- range: [-5, 15],
883
- subSequence: true,
884
- mediaRegenerate: false,
885
- unit: "em",
886
- sequence: {},
887
- scales: {},
888
- vars: {}
889
- };
890
- var SPACING = defaultProps2;
891
-
892
- // src/defaultConfig/color.js
893
- var COLOR = {};
894
- var GRADIENT = {};
895
-
896
- // src/defaultConfig/theme.js
897
- var THEME = {};
898
-
899
- // src/defaultConfig/shadow.js
900
- var SHADOW = {};
901
-
902
- // src/defaultConfig/icons.js
903
- var ICONS = {};
904
- var SEMANTIC_ICONS = {};
905
-
906
- // src/defaultConfig/timing.js
907
- var defaultProps3 = {
908
- default: 150,
909
- base: 150,
910
- type: "timing",
911
- ratio: SEQUENCE["perfect-fourth"],
912
- range: [-3, 12],
913
- mediaRegenerate: false,
914
- unit: "ms",
915
- sequence: {},
916
- scales: {},
917
- vars: {}
918
- };
919
- var TIMING = defaultProps3;
920
-
921
- // src/defaultConfig/document.js
922
- var DOCUMENT = {};
923
-
924
- // src/defaultConfig/responsive.js
925
- var BREAKPOINTS = {
926
- screenL: 1920,
927
- screenM: 1680,
928
- screenS: 1440,
929
- tabletL: 1366,
930
- tabletM: 1280,
931
- tabletS: 1024,
932
- mobileL: 768,
933
- mobileM: 560,
934
- mobileS: 480,
935
- mobileXS: 375
936
- };
937
- var DEVICES = {
938
- screenXXL: [2560, 1440],
939
- screenXL: [2240, 1260],
940
- screenL: [1920, 1024],
941
- screenM: [1680, 1024],
942
- screenS: [1440, 720],
943
- tabletL: [1366, 926],
944
- tabletM: [1280, 768],
945
- tabletS: [1024, 768],
946
- mobileL: [768, 375],
947
- mobileM: [560, 768],
948
- mobileS: [480, 768],
949
- mobileXS: [375, 768]
950
- };
951
-
952
- // src/defaultConfig/cases.js
953
- var CASES = {};
954
-
955
- // src/defaultConfig/animation.js
956
- var ANIMATION = {};
957
-
958
- // src/defaultConfig/svg.js
959
- var SVG = {};
960
- var SVG_DATA = {};
961
-
962
- // src/defaultConfig/templates.js
963
- var TEMPLATES = {};
964
-
965
- // src/defaultConfig/grid.js
966
- var defaultProps4 = {};
967
- var GRID = defaultProps4;
968
-
969
- // src/defaultConfig/class.js
970
- var defaultProps5 = {};
971
- var CLASS = defaultProps5;
972
-
973
- // src/defaultConfig/index.js
974
- var RESET = {};
975
-
976
- // src/factory.js
977
- var CSS_VARS = {};
978
- var CONFIG = {
979
- verbose: false,
980
- useVariable: true,
981
- useReset: true,
982
- CSS_VARS,
983
- ...void 0 || defaultConfig_exports
984
- };
985
- var cachedConfig = deepClone(CONFIG);
986
- var FACTORY = {
987
- active: "0",
988
- 0: CONFIG
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/unit.js
1001
- var isScalingUnit = (unit) => {
1002
- return unit === "em" || unit === "rem" || unit === "vw" || unit === "vh" || unit === "vmax" || unit === "vmin";
1003
- };
1004
-
1005
- // src/utils/color.js
1006
- var colorStringToRgbaArray = (color) => {
1007
- if (color === "") return [0, 0, 0, 0];
1008
- if (color.toLowerCase() === "transparent") return [0, 0, 0, 0];
1009
- if (color[0] === "#") {
1010
- if (color.length < 7) {
1011
- color = "#" + color[1] + color[1] + color[2] + color[2] + color[3] + color[3] + (color.length > 4 ? color[4] + color[4] : "");
1012
- }
1013
- return [
1014
- parseInt(color.substr(1, 2), 16),
1015
- parseInt(color.substr(3, 2), 16),
1016
- parseInt(color.substr(5, 2), 16),
1017
- color.length > 7 ? parseInt(color.substr(7, 2), 16) / 255 : 1
1018
- ];
1019
- }
1020
- if (color.indexOf("rgb") === -1) {
1021
- if (document2 && window2) {
1022
- const elem = document2.body.appendChild(document2.createElement("fictum"));
1023
- const flag = "rgb(1, 2, 3)";
1024
- elem.style.color = flag;
1025
- if (elem.style.color !== flag) {
1026
- document2.body.removeChild(elem);
1027
- return;
1028
- }
1029
- elem.style.color = color;
1030
- if (elem.style.color === flag || elem.style.color === "") {
1031
- document2.body.removeChild(elem);
1032
- return [0, 0, 0, 0];
1033
- }
1034
- color = window2.getComputedStyle(elem).color;
1035
- document2.body.removeChild(elem);
1036
- }
1037
- }
1038
- if (color.indexOf("rgb") === 0) {
1039
- if (color.indexOf("rgba") === -1) color = `${color}, 1`;
1040
- return color.match(/[\.\d]+/g).map((a) => +a);
1041
- }
1042
- return [0, 0, 0, 0];
1043
- };
1044
- var hexToRgbArray = (hex, alpha = 1) => {
1045
- const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
1046
- return [r, g, b];
1047
- };
1048
- var rgbArrayToHex = ([r, g, b]) => {
1049
- return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
1050
- };
1051
- var rgbToHSL = (r, g, b) => {
1052
- const a = Math.max(r, g, b);
1053
- const n = a - Math.min(r, g, b);
1054
- const f = 1 - Math.abs(a + a - n - 1);
1055
- const h = n && (a == r ? (g - b) / n : a == g ? 2 + (b - r) / n : 4 + (r - g) / n);
1056
- return [60 * (h < 0 ? h + 6 : h), f ? n / f : 0, (a + a - n) / 2];
1057
- };
1058
- 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)];
1059
- var getColorShade = (col, amt) => {
1060
- const num = parseInt(col, 16);
1061
- let r = (num >> 16) + amt;
1062
- if (r > 255) r = 255;
1063
- else if (r < 0) r = 0;
1064
- let b = (num >> 8 & 255) + amt;
1065
- if (b > 255) b = 255;
1066
- else if (b < 0) b = 0;
1067
- let g = (num & 255) + amt;
1068
- if (g > 255) g = 255;
1069
- else if (g < 0) g = 0;
1070
- return ((g | b << 8 | r << 16) + 16777216).toString(16).slice(1);
1071
- };
1072
- var getRgbTone = (rgb, tone) => {
1073
- if (isString(rgb) && rgb.includes("rgb"))
1074
- rgb = colorStringToRgbaArray(rgb).join(", ");
1075
- if (isString(rgb)) rgb = rgb.split(",").map((v) => parseFloat(v.trim()));
1076
- if (isNumber(tone)) tone += "";
1077
- const toHex = rgbArrayToHex(rgb);
1078
- const abs = tone.slice(0, 1);
1079
- if (abs === "-" || abs === "+") {
1080
- const colorShade = getColorShade(toHex, parseFloat(tone));
1081
- return hexToRgbArray(colorShade).join(", ");
1082
- } else {
1083
- const [r, g, b] = rgb;
1084
- const hsl = rgbToHSL(r, g, b);
1085
- const [h, s, l] = hsl;
1086
- const newRgb = hslToRgb(h, s, parseFloat(tone) / 100 * 255);
1087
- return newRgb;
1088
- }
1089
- };
1090
-
1091
- // src/utils/font.js
1092
- var getDefaultOrFirstKey = (LIBRARY, key) => {
1093
- if (LIBRARY[key]) return LIBRARY[key].value;
1094
- if (LIBRARY.default) return LIBRARY[LIBRARY.default].value;
1095
- const hasValue = Object.keys(LIBRARY)[0];
1096
- return hasValue && LIBRARY[hasValue] && LIBRARY[hasValue].value;
1097
- };
1098
- var getFontFormat = (url) => url.split(/[#?]/)[0].split(".").pop().trim();
1099
- var setCustomFont = (name, url, weight) => `
1100
- font-family: '${name}';
1101
- font-style: normal;
1102
- ${weight && `font-weight: ${weight};`}
1103
- src: url('${url}') format('${getFontFormat(url)}');`;
1104
- var setCustomFontMedia = (name, url, weight) => `@font-face {
1105
- ${setCustomFont(name, url, weight)}
1106
- }`;
1107
- var getFontFaceEach = (name, weights) => {
1108
- const keys = Object.keys(weights);
1109
- return keys.map((key) => {
1110
- const { url, fontWeight } = weights[key];
1111
- return setCustomFont(name, url, fontWeight);
1112
- });
1113
- };
1114
-
1115
- // src/utils/sequence.js
1116
- var import_utils5 = __toESM(require_cjs(), 1);
1117
- var numToLetterMap = {
1118
- "-6": "U",
1119
- "-5": "V",
1120
- "-4": "W",
1121
- "-3": "X",
1122
- "-2": "Y",
1123
- "-1": "Z",
1124
- 0: "A",
1125
- 1: "B",
1126
- 2: "C",
1127
- 3: "D",
1128
- 4: "E",
1129
- 5: "F",
1130
- 6: "G",
1131
- 7: "H",
1132
- 8: "I",
1133
- 9: "J",
1134
- 10: "K",
1135
- 11: "L",
1136
- 12: "M",
1137
- 13: "N",
1138
- 14: "O",
1139
- 15: "P",
1140
- 16: "Q",
1141
- 17: "R",
1142
- 18: "S",
1143
- 19: "T"
1144
- };
1145
- var setSequenceValue = (props, sequenceProps) => {
1146
- const { key, variable, value, scaling, index, scalingVariable } = props;
1147
- sequenceProps.sequence[key] = {
1148
- key,
1149
- decimal: ~~(value * 100) / 100,
1150
- val: ~~value,
1151
- scaling,
1152
- index,
1153
- scalingVariable,
1154
- variable
1155
- };
1156
- sequenceProps.scales[key] = scaling;
1157
- sequenceProps.vars[variable] = scaling + sequenceProps.unit;
1158
- };
1159
- var setScalingVar = (key, sequenceProps) => {
1160
- const { base, type, unit } = sequenceProps;
1161
- const defaultVal = (isScalingUnit(unit) ? 1 : base) + unit;
1162
- if (key === 0) return defaultVal;
1163
- const prefix = "--" + (type && type.replace(".", "-"));
1164
- const ratioVar = `${prefix}-ratio`;
1165
- if (key > 0) {
1166
- const prevLetterKey = numToLetterMap[key - 1];
1167
- return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
1168
- }
1169
- if (key < 0) {
1170
- const nextLetterKey = numToLetterMap[key + 1];
1171
- return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
1172
- }
1173
- };
1174
- var setSubScalingVar = (index, arr, variable, sequenceProps) => {
1175
- const { type } = sequenceProps;
1176
- const skipMiddle = index === 2 && arr.length === 2;
1177
- const indexMapWithLength = skipMiddle ? index + 1 : index;
1178
- const prefix = "--" + (type && type.replace(".", "-"));
1179
- const subRatioVarPrefix = `${prefix}-sub-ratio-`;
1180
- return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
1181
- };
1182
- var getSubratioDifference = (base, ratio) => {
1183
- const diff = base * ratio - base;
1184
- const subRatio = diff / 1.618;
1185
- const first = base * ratio - subRatio;
1186
- const second = base + subRatio;
1187
- const middle = (first + second) / 2;
1188
- return [first, middle, second];
1189
- };
1190
- var getSubratio = (base, ratio) => {
1191
- return getSubratioDifference(base, ratio).map((v) => v / base);
1192
- };
1193
- var generateSubSequence = (props, sequenceProps) => {
1194
- const { key, base, value, ratio, variable, index } = props;
1195
- const next = value * ratio;
1196
- const diffRounded = ~~next - ~~value;
1197
- let arr;
1198
- const [first, middle, second] = getSubratioDifference(value, ratio);
1199
- if (diffRounded > 16) arr = [first, middle, second];
1200
- else arr = [first, second];
1201
- arr.forEach((v, k) => {
1202
- const scaling = ~~(v / base * 1e3) / 1e3;
1203
- const newVar = variable + (k + 1);
1204
- const newIndex = index + (k + 1) / 10;
1205
- const scalingVariable = setSubScalingVar(k + 1, arr, variable, sequenceProps);
1206
- const props2 = {
1207
- key: key + (k + 1),
1208
- variable: newVar,
1209
- value: v,
1210
- scaling,
1211
- scalingVariable,
1212
- index: newIndex
1213
- };
1214
- setSequenceValue(props2, sequenceProps);
1215
- });
1216
- };
1217
- var switchSequenceOnNegative = (key, base, ratio) => {
1218
- return base * Math.pow(ratio, key);
1219
- };
1220
- var generateSequence = (sequenceProps) => {
1221
- const { type, base, ratio, range, subSequence } = sequenceProps;
1222
- const n = Math.abs(range[0]) + Math.abs(range[1]);
1223
- const prefix = "--" + (type && type.replace(".", "-")) + "-";
1224
- for (let i = 0; i <= n; i++) {
1225
- const key = range[1] - i;
1226
- const letterKey = numToLetterMap[key];
1227
- const value = switchSequenceOnNegative(key, base, ratio);
1228
- const scaling = ~~(value / base * 100) / 100;
1229
- const variable = prefix + letterKey;
1230
- const scalingVariable = setScalingVar(key, sequenceProps);
1231
- const props = {
1232
- key: letterKey,
1233
- variable,
1234
- value,
1235
- base,
1236
- scaling,
1237
- scalingVariable,
1238
- ratio,
1239
- index: key
1240
- };
1241
- setSequenceValue(props, sequenceProps);
1242
- if (subSequence) generateSubSequence(props, sequenceProps);
1243
- }
1244
- return sequenceProps;
1245
- };
1246
- var getSequenceValue = (value = "A", sequenceProps) => {
1247
- const CONFIG2 = getActiveConfig();
1248
- const { UNIT: UNIT2 } = CONFIG2;
1249
- const {
1250
- sequence,
1251
- unit = UNIT2.default,
1252
- useVariable
1253
- } = sequenceProps;
1254
- if (isString(value) && value.slice(0, 2) === "--") return `var(${value})`;
1255
- const prefix = `--${(0, import_utils5.toDashCase)(sequenceProps.type.replace(".", "-"))}-`;
1256
- const startsWithDashOrLetterRegex = /^-?[a-zA-Z]/i;
1257
- const startsWithDashOrLetter = startsWithDashOrLetterRegex.test(value);
1258
- if (value === "none" || value === "auto" || value === "unset" || value === "inherit" || value === "fit-content" || value === "min-content" || value === "max-content" || value.includes("calc") || value.includes("var") || !startsWithDashOrLetter) return value;
1259
- const letterVal = value.toUpperCase();
1260
- const isNegative = letterVal.slice(0, 1) === "-" ? "-" : "";
1261
- let absValue = isNegative ? letterVal.slice(1) : letterVal;
1262
- let mediaName = "";
1263
- if (absValue.includes("_")) {
1264
- mediaName = "_" + absValue.split("_")[1].toLowerCase();
1265
- absValue = absValue.split("_")[0];
1266
- }
1267
- const varValue = (v) => startsWithDashOrLetterRegex.test(v) ? `var(${prefix}${v}${mediaName})` : v;
1268
- if (absValue.includes("+")) {
1269
- const [first, second] = absValue.split("+");
1270
- const joint = `${varValue(first)} + ${varValue(second)}`;
1271
- return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
1272
- } else if (absValue.includes("*")) {
1273
- const [first, second] = absValue.split("*");
1274
- const joint = `${varValue(first)} * ${varValue(second)}`;
1275
- return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
1276
- } else if (absValue.includes("-")) {
1277
- const [first, second] = absValue.split("-");
1278
- const joint = `${varValue(first)} - ${varValue(second)}`;
1279
- return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`;
1280
- }
1281
- if (!sequence[absValue] && absValue.length === 2) {
1282
- if (CONFIG2.verbose) console.warn(absValue, "- value is not found because `subSequence` is set to false");
1283
- absValue = absValue.slice(0, 1);
1284
- }
1285
- if (useVariable || CONFIG2.useVariable) {
1286
- const varValue2 = `var(${prefix}${absValue}${mediaName})`;
1287
- return isNegative ? `calc(${varValue2} * -1)` : varValue2;
1288
- }
1289
- const sequenceItem = sequence ? sequence[absValue] : null;
1290
- if (!sequenceItem) return console.warn("can't find", sequence, absValue);
1291
- if (unit === "ms" || unit === "s") {
1292
- return isNegative + sequenceItem.val + unit;
1293
- }
1294
- return isNegative + sequenceItem.scaling + unit;
1295
- };
1296
- var getSequenceValuePropertyPair = (value, propertyName, sequenceProps) => {
1297
- if (typeof value !== "string") {
1298
- const CONFIG2 = getActiveConfig();
1299
- if (CONFIG2.verbose) console.warn(propertyName, value, "is not a string");
1300
- return { [propertyName]: value };
1301
- }
1302
- if (value === "-" || value === "") return {};
1303
- return { [propertyName]: getSequenceValue(value, sequenceProps) };
1304
- };
1305
- var findHeadingLetter = (h1Matches, index) => numToLetterMap[h1Matches - index];
1306
- var findHeadings = (propertyNames) => {
1307
- const { h1Matches, sequence } = propertyNames;
1308
- return new Array(6).fill(null).map((_, i) => {
1309
- const findLetter = findHeadingLetter(h1Matches, i);
1310
- return sequence[findLetter];
1311
- });
1312
- };
1313
-
1314
- // src/utils/var.js
1315
- var applySequenceGlobalVars = (vars, obj, options) => {
1316
- const CONFIG2 = getActiveConfig();
1317
- const { UNIT: UNIT2 } = CONFIG2;
1318
- const unit = obj.unit || UNIT2.default;
1319
- const { base, ratio, type } = obj;
1320
- const prefix = "--" + (type && type.replace(".", "-"));
1321
- vars[`${prefix}-base`] = base;
1322
- vars[`${prefix}-unit`] = unit;
1323
- const ratioVar = `${prefix}-ratio`;
1324
- vars[ratioVar] = ratio;
1325
- const [first, middle, second] = getSubratio(base, ratio);
1326
- vars[`${prefix}-sub-ratio-1`] = `calc(var(${prefix}-ratio) * ${first / ratio})`;
1327
- vars[`${prefix}-sub-ratio-2`] = `calc(var(${prefix}-ratio) * ${middle / ratio})`;
1328
- vars[`${prefix}-sub-ratio-3`] = `calc(var(${prefix}-ratio) * ${second / ratio})`;
1329
- };
1330
- var applySequenceVars = (FACTORY2, options = {}) => {
1331
- const CONFIG2 = getActiveConfig();
1332
- const { UNIT: UNIT2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
1333
- const unit = FACTORY2.unit || UNIT2.default;
1334
- const { mediaRegenerate, sequence, scales } = FACTORY2;
1335
- if (!mediaRegenerate) {
1336
- applySequenceGlobalVars(CSS_VARS2, FACTORY2, options);
1337
- }
1338
- for (const key in sequence) {
1339
- const item = sequence[key];
1340
- const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
1341
- if (!mediaRegenerate) {
1342
- CSS_VARS2[item.variable + "_default"] = value;
1343
- CSS_VARS2[item.variable] = item.scalingVariable;
1344
- continue;
1345
- }
1346
- if (options.useDefault === false) {
1347
- CSS_VARS2[item.variable] = value;
1348
- } else {
1349
- CSS_VARS2[item.variable + "_default"] = value;
1350
- CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
1351
- }
1352
- }
1353
- };
1354
- var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
1355
- const CONFIG2 = getActiveConfig();
1356
- const { UNIT: UNIT2, MEDIA: MEDIA2, CSS_VARS: CSS_VARS2 } = CONFIG2;
1357
- const mediaName = media.slice(1);
1358
- const unit = FACTORY2.unit || UNIT2.default;
1359
- const { mediaRegenerate } = FACTORY2;
1360
- const { sequence, scales } = FACTORY2[media];
1361
- const query = MEDIA2[mediaName];
1362
- if (!query && CONFIG2.verbose) console.warn("Can't find media query ", query);
1363
- if (!mediaRegenerate) {
1364
- let underMediaQuery = CSS_VARS2[`@media ${query}`];
1365
- if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
1366
- applySequenceGlobalVars(underMediaQuery, FACTORY2[media], options);
1367
- return;
1368
- }
1369
- for (const key in sequence) {
1370
- const item = sequence[key];
1371
- const value = (isScalingUnit(unit) ? scales[key] : sequence[key].val) + unit;
1372
- if (!query && CONFIG2.verbose) console.warn("Can't find query ", query);
1373
- let underMediaQuery = CSS_VARS2[`@media ${query}`];
1374
- if (!underMediaQuery) underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
1375
- underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
1376
- CSS_VARS2[item.variable + "_" + mediaName] = value;
1377
- }
1378
- };
1379
-
1380
- // src/utils/sprite.js
1381
- var isDev = isNotProduction();
1382
- var parseRootAttributes = (htmlString) => {
1383
- const val = htmlString.default || htmlString;
1384
- if (!isString(val)) {
1385
- if (isDev) console.warn("parseRootAttributes:", val, "is not a string");
1386
- return;
1387
- }
1388
- const match = val.match(/<svg\s+(.*?)>/);
1389
- if (!match || !match[1]) {
1390
- return {};
1391
- }
1392
- const attrString = match[1];
1393
- const attrs = attrString.match(
1394
- /(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/gm
1395
- );
1396
- return attrs.reduce((acc, attr) => {
1397
- const [key, value] = attr.split("=");
1398
- acc[key] = value.replace(/['"]/g, "");
1399
- return acc;
1400
- }, {});
1401
- };
1402
- var replaceIdsAndUrls = (code, key) => {
1403
- const idRegex = /id="([^"]*)"/;
1404
- const urlRegex = /url\(#([^)]*)\)/g;
1405
- const matches = code.match(/id="([^"]*)"/g);
1406
- let replacedCode = code;
1407
- if (isArray(matches)) {
1408
- matches.forEach(() => {
1409
- const randomKey = Math.floor(Math.random() * 1e5);
1410
- replacedCode = code.replace(idRegex, `id="${key}-${randomKey}"`).replace(urlRegex, `url(#${key}-${randomKey})`);
1411
- });
1412
- }
1413
- return replacedCode;
1414
- };
1415
- var convertSvgToSymbol = (key, code) => {
1416
- const extractAttrs = parseRootAttributes(code);
1417
- const { width, height } = extractAttrs;
1418
- const viewBox = extractAttrs.viewBox || `0 0 ${width || 24} ${height || 24}`;
1419
- const xmlns = "http://www.w3.org/2000/svg";
1420
- const replacedCode = replaceIdsAndUrls(code, key);
1421
- let symbol = replacedCode.replace(
1422
- "<svg",
1423
- `<symbol id="${key}" xmlns="${xmlns}" viewBox="${viewBox}"`
1424
- );
1425
- symbol = symbol.replace(/width="[^"]*"/, "");
1426
- symbol = symbol.replace(/height="[^"]*"/, "");
1427
- symbol = symbol.replace("</svg", "</symbol");
1428
- return symbol;
1429
- };
1430
-
1431
- // src/system/color.js
1432
- var getColor = (value, key, config) => {
1433
- const CONFIG2 = config || getActiveConfig();
1434
- if (!isString(value)) {
1435
- if (CONFIG2.verbose) console.warn(value, "- type for color is not valid");
1436
- return;
1437
- }
1438
- if (value.slice(0, 2) === "--") return `var(${value})`;
1439
- if (key && value[key]) value = value[key];
1440
- const [name, alpha, tone] = isArray(value) ? value : value.split(" ");
1441
- const { COLOR: COLOR2, GRADIENT: GRADIENT2 } = CONFIG2;
1442
- let val = COLOR2[name] || GRADIENT2[name];
1443
- if (!val) {
1444
- if (CONFIG2.verbose) console.warn("Can't find color ", name);
1445
- return value;
1446
- }
1447
- if (key) {
1448
- if (val[key]) val = val[key];
1449
- else if (CONFIG2.verbose) console.warn(value, " - does not have ", key);
1450
- }
1451
- let rgb = val.rgb;
1452
- if (!rgb) {
1453
- return CONFIG2.useVariable ? `var(${val.var})` : val.value;
1454
- }
1455
- if (tone && !val[tone]) {
1456
- rgb = getRgbTone(rgb, tone);
1457
- val[tone] = { rgb, var: `${val.var}-${tone}` };
1458
- }
1459
- if (val[tone]) rgb = val[tone].rgb;
1460
- if (alpha) return `rgba(${rgb}, ${alpha})`;
1461
- return CONFIG2.useVariable ? `var(${val.var})` : `rgb(${rgb})`;
1462
- };
1463
- var setColor = (val, key, suffix) => {
1464
- const CONFIG2 = getActiveConfig();
1465
- if (isString(val) && val.slice(0, 2) === "--") {
1466
- val = getColor(val.slice(2));
1467
- if (!(val.includes("rgb") || val.includes("var") || val.includes("#"))) {
1468
- if (CONFIG2.verbose) console.warn(val, "- referred but does not exist");
1469
- val = val.split(" ")[0];
1470
- }
1471
- }
1472
- if (isArray(val)) {
1473
- return {
1474
- "@light": setColor(val[0], key, "light"),
1475
- "@dark": setColor(val[1], key, "dark")
1476
- };
1477
- }
1478
- if (isObject(val)) {
1479
- const obj = {};
1480
- for (const variant in val) {
1481
- obj[variant] = setColor(
1482
- val[variant],
1483
- key,
1484
- variant.slice(0, 1) === "@" ? variant.slice(1) : variant
1485
- );
1486
- }
1487
- return obj;
1488
- }
1489
- const CSSVar = `--color-${key}` + (suffix ? `-${suffix}` : "");
1490
- const colorArr = colorStringToRgbaArray(val.value || val);
1491
- const [r, g, b, a = 1] = colorArr;
1492
- const alpha = parseFloat(a.toFixed(2));
1493
- const rgb = `${r}, ${g}, ${b}`;
1494
- const value = `rgba(${rgb}, ${alpha})`;
1495
- if (CONFIG2.useVariable) {
1496
- CONFIG2.CSS_VARS[CSSVar] = value;
1497
- }
1498
- return {
1499
- var: CSSVar,
1500
- rgb,
1501
- alpha,
1502
- value
1503
- };
1504
- };
1505
- var setGradient = (val, key, suffix) => {
1506
- const CONFIG2 = getActiveConfig();
1507
- if (isString(val) && val.slice(0, 2) === "--") val = getColor(val.slice(2));
1508
- if (isArray(val)) {
1509
- return {
1510
- "@light": setGradient(val[0], key, "light"),
1511
- "@dark": setGradient(val[0], key, "dark")
1512
- };
1513
- }
1514
- if (isObject(val)) {
1515
- const obj = {};
1516
- for (const variant in val) obj[variant] = setGradient(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
1517
- return obj;
1518
- }
1519
- const CSSVar = `--gradient-${key}` + (suffix ? `-${suffix}` : "");
1520
- if (CONFIG2.useVariable) {
1521
- CONFIG2.CSS_VARS[CSSVar] = val.value || val;
1522
- }
1523
- return {
1524
- var: CSSVar,
1525
- value: val.value || val
1526
- };
1527
- };
1528
-
1529
- // src/system/theme.js
1530
- var setThemeValue = (theme) => {
1531
- const value = {};
1532
- const { state, media, helpers, ...rest } = theme;
1533
- const keys = Object.keys(rest);
1534
- keys.map((key) => {
1535
- const conditions = ["color", "Color", "background", "border"];
1536
- const isColor = conditions.some((k) => key.includes(k));
1537
- return value[key] = isColor ? getColor(theme[key]) : theme[key];
1538
- });
1539
- return value;
1540
- };
1541
- var getThemeValue = (theme) => {
1542
- if (theme.value) return theme.value;
1543
- theme.value = setThemeValue(theme);
1544
- return theme.value;
1545
- };
1546
- var getTheme = (value, modifier) => {
1547
- const CONFIG2 = getActiveConfig();
1548
- if (CONFIG2.useVariable) return getMediaTheme(value, modifier);
1549
- const { THEME: THEME2 } = CONFIG2;
1550
- if (isString(value)) {
1551
- const [theme, subtheme] = value.split(" ");
1552
- const isOurTheme = THEME2[theme];
1553
- if (isOurTheme) {
1554
- if (!subtheme && !modifier) return getThemeValue(isOurTheme);
1555
- value = [theme, subtheme || modifier];
1556
- }
1557
- }
1558
- if (isObjectLike(value) && value[1]) {
1559
- const themeName = value[0];
1560
- const subThemeName = value[1];
1561
- const { helpers, media, state } = THEME2[themeName];
1562
- if (media && media[subThemeName]) return getThemeValue(media[subThemeName]);
1563
- if (helpers && helpers[subThemeName]) return getThemeValue(helpers[subThemeName]);
1564
- if (state && state[subThemeName]) return getThemeValue(state[subThemeName]);
1565
- } else if (isObject(value)) return setThemeValue(value);
1566
- };
1567
- var setInverseTheme = (theme, variant, value) => {
1568
- if (isObject(variant)) {
1569
- theme.variants.inverse.value = setThemeValue(variant);
1570
- } else if (variant === true) {
1571
- const { color, background } = value;
1572
- theme.variants.inverse = {
1573
- value: {
1574
- color: background,
1575
- background: color
1576
- }
1577
- };
1578
- }
1579
- };
1580
- var setPseudo = (theme, key, variant, themeValue) => {
1581
- const result = getTheme(variant);
1582
- themeValue[`&:${key}`] = result;
1583
- if (isObject(variant) && !variant.value) variant.value = result;
1584
- };
1585
- var setSelectors = (theme, value) => {
1586
- const { state } = theme;
1587
- if (!state) return;
1588
- const keys = Object.keys(state);
1589
- keys.map((key) => {
1590
- const variant = state[key];
1591
- setPseudo(theme, key, variant, value);
1592
- return theme;
1593
- });
1594
- return theme;
1595
- };
1596
- var setPrefersScheme = (theme, key, variant, themeValue) => {
1597
- const result = getTheme(variant);
1598
- themeValue[`@media (prefers-color-scheme: ${key})`] = result;
1599
- if (isObject(variant) && !variant.value) variant.value = result;
1600
- };
1601
- var setMedia = (theme, value) => {
1602
- const { media } = theme;
1603
- if (!media) return;
1604
- const keys = Object.keys(media);
1605
- keys.map((key) => {
1606
- const variant = media[key];
1607
- if (key === "dark" || key === "light") setPrefersScheme(theme, key, variant, value);
1608
- if (key === "inverse") setInverseTheme(theme, variant, value);
1609
- return theme;
1610
- });
1611
- return theme;
1612
- };
1613
- var setHelpers = (theme, value) => {
1614
- const CONFIG2 = getActiveConfig();
1615
- const { helpers } = theme;
1616
- if (!helpers) return;
1617
- const keys = Object.keys(helpers);
1618
- keys.map((key) => {
1619
- const helper = helpers[key];
1620
- if (isString(helper)) helpers[key] = CONFIG2.THEME[helper];
1621
- else getThemeValue(helpers[key]);
1622
- return theme;
1623
- });
1624
- return theme;
1625
- };
1626
- var setTheme = (val, key) => {
1627
- const CONFIG2 = getActiveConfig();
1628
- if (CONFIG2.useVariable) return setMediaTheme(val, key);
1629
- const { state, media, helpers } = val;
1630
- const value = setThemeValue(val, key);
1631
- const CSSvar = `--theme-${key}`;
1632
- setSelectors(val, value);
1633
- setMedia(val, value);
1634
- setHelpers(val, value);
1635
- return { var: CSSvar, value, state, media, helpers };
1636
- };
1637
- var setMediaTheme = (val, key, suffix, prefers) => {
1638
- const CONFIG2 = getActiveConfig();
1639
- const { CSS_VARS: CSS_VARS2 } = CONFIG2;
1640
- const theme = { value: val };
1641
- if (isObjectLike(val)) {
1642
- for (const param in val) {
1643
- const symb = param.slice(0, 1);
1644
- const value = val[param];
1645
- if (symb === "@" || symb === ":" || symb === ".") {
1646
- const hasPrefers = symb === "@" && param;
1647
- theme[param] = setMediaTheme(value, key, param, prefers || hasPrefers);
1648
- } else {
1649
- const color = getColor(value, prefers);
1650
- const metaSuffixes = [...new Set([prefers, suffix].filter((v) => v).map((v) => v.slice(1)))];
1651
- const varmetaSuffixName = metaSuffixes.length ? "-" + metaSuffixes.join("-") : "";
1652
- const CSSVar = `--theme-${key}${varmetaSuffixName}-${param}`;
1653
- if (CONFIG2.useVariable) {
1654
- CSS_VARS2[CSSVar] = color;
1655
- theme[param] = `var(${CSSVar})`;
1656
- } else {
1657
- theme[param] = color;
1658
- }
1659
- theme[`.${param}`] = { [param]: theme[param] };
1660
- }
1661
- }
1662
- if (theme.background || theme.color || theme.backgroundColor) {
1663
- theme[".inversed"] = {
1664
- color: theme.background || theme.backgroundColor,
1665
- background: theme.color
1666
- };
1667
- }
1668
- }
1669
- if (isString(val) && val.slice(0, 2) === "--") {
1670
- const { THEME: THEME2 } = CONFIG2;
1671
- const value = THEME2[val.slice(2)];
1672
- const getReferenced = getMediaTheme(value, prefers);
1673
- return getReferenced;
1674
- }
1675
- return theme;
1676
- };
1677
- var recursiveTheme = (val) => {
1678
- const CONFIG2 = getActiveConfig();
1679
- const obj = {};
1680
- for (const param in val) {
1681
- const symb = param.slice(0, 1);
1682
- if (isObjectLike(val[param])) {
1683
- if (symb === "@") {
1684
- const query = CONFIG2.MEDIA[param.slice(1)];
1685
- const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
1686
- obj[media] = recursiveTheme(val[param]);
1687
- } else if (symb === ":") {
1688
- obj[`&${param}`] = recursiveTheme(val[param]);
1689
- }
1690
- } else obj[param] = val[param];
1691
- }
1692
- return obj;
1693
- };
1694
- var findModifierFromArray = (val, modifierArray) => {
1695
- const currentMod = modifierArray.shift();
1696
- if (val[currentMod]) return findModifierFromArray(val[currentMod], modifierArray);
27
+ var import_factory = require("./factory.js");
28
+ var import_system = require("./system");
29
+ var import_utils = require("@domql/utils");
30
+ const setCases = (val, key) => {
31
+ if ((0, import_utils.isFunction)(val)) return val();
1697
32
  return val;
1698
33
  };
1699
- var findModifier = (val, modifier) => {
1700
- if (isArray(modifier)) return findModifierFromArray(val, modifier);
1701
- else if (isString(modifier) && val[modifier]) return val[modifier];
1702
- else return val;
1703
- };
1704
- var getMediaTheme = (value, modifier) => {
1705
- const activeConfig = getActiveConfig();
1706
- if (isString(value) && value.slice(0, 2) === "--") {
1707
- value = getMediaTheme(value.slice(2));
1708
- }
1709
- if (!value || !isString(value)) {
1710
- if (activeConfig.verbose) {
1711
- console.warn(`${value} - Theme is not a string`);
1712
- }
1713
- return;
1714
- }
1715
- const [themeName, ...themeModifiers] = isArray(value) ? value : value.split(" ");
1716
- let themeValue = activeConfig.THEME[themeName];
1717
- if (themeValue && (themeModifiers || modifier)) {
1718
- themeValue = findModifier(themeValue, themeModifiers.length ? themeModifiers : modifier);
1719
- }
1720
- const resolvedTheme = recursiveTheme(themeValue);
1721
- return resolvedTheme;
1722
- };
1723
-
1724
- // src/system/font.js
1725
- var import_utils12 = __toESM(require_cjs(), 1);
1726
- var setFont = (val, key) => {
1727
- const CSSvar = `--font-${key}`;
1728
- if (!val || isArray(val) && !val[0]) return;
1729
- const fontFace = val[0] ? getFontFaceEach(key, val) : setCustomFontMedia(key, val.url);
1730
- return { var: CSSvar, value: val, fontFace };
1731
- };
1732
- var setFontFamily = (val, key) => {
1733
- const CONFIG2 = getActiveConfig();
1734
- const { FONT_FAMILY: FONT_FAMILY2, FONT_FAMILY_TYPES: FONT_FAMILY_TYPES2 } = CONFIG2;
1735
- let { value, type } = val;
1736
- if (val.isDefault) FONT_FAMILY2.default = key;
1737
- if (isObject(value)) value = (0, import_utils12.arrayzeValue)(value);
1738
- const CSSvar = `--font-family-${key}`;
1739
- const str = `${value.join(", ")}, ${FONT_FAMILY_TYPES2[type]}`;
1740
- return { var: CSSvar, value: str, arr: value, type };
1741
- };
1742
-
1743
- // src/system/typography.js
1744
- var runThroughMedia = (FACTORY2) => {
1745
- const CONFIG2 = getActiveConfig();
1746
- const { TYPOGRAPHY: TYPOGRAPHY2, MEDIA: MEDIA2 } = CONFIG2;
1747
- for (const prop in FACTORY2) {
1748
- const isPropMedia = prop.slice(0, 1) === "@";
1749
- const mediaValue = FACTORY2[prop];
1750
- if (!isPropMedia) continue;
1751
- const { mediaRegenerate } = FACTORY2;
1752
- const mediaName = prop.slice(1);
1753
- const { type, base, ratio, range, subSequence, h1Matches, unit } = FACTORY2;
1754
- merge(mediaValue, {
1755
- type,
1756
- base,
1757
- ratio,
1758
- range,
1759
- subSequence,
1760
- h1Matches,
1761
- unit
1762
- });
1763
- const query = MEDIA2[mediaName];
1764
- const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
1765
- TYPOGRAPHY2.templates[media] = {
1766
- fontSize: mediaValue.base / TYPOGRAPHY2.browserDefault + unit
1767
- };
1768
- if (!mediaRegenerate) {
1769
- applyMediaSequenceVars(FACTORY2, prop);
1770
- continue;
1771
- }
1772
- merge(mediaValue, {
1773
- sequence: {},
1774
- scales: {},
1775
- templates: {},
1776
- vars: {}
1777
- });
1778
- generateSequence(mediaValue);
1779
- applyMediaSequenceVars(FACTORY2, prop);
1780
- }
1781
- };
1782
- var applyHeadings = (props) => {
1783
- var _a, _b;
1784
- const CONFIG2 = getActiveConfig();
1785
- if (props.h1Matches) {
1786
- const unit = props.unit;
1787
- const HEADINGS = findHeadings(props);
1788
- const { templates } = props;
1789
- for (const k in HEADINGS) {
1790
- const headerName = `h${parseInt(k) + 1}`;
1791
- const headerStyle = templates[headerName];
1792
- templates[headerName] = {
1793
- fontSize: CONFIG2.useVariable ? `var(${(_a = HEADINGS[k]) == null ? void 0 : _a.variable})` : `${(_b = HEADINGS[k]) == null ? void 0 : _b.scaling}${unit}`,
1794
- margin: headerStyle ? headerStyle.margin : 0,
1795
- lineHeight: headerStyle ? headerStyle.lineHeight : props.lineHeight,
1796
- letterSpacing: headerStyle ? headerStyle.letterSpacing : props.letterSpacing,
1797
- fontWeight: headerStyle ? headerStyle.fontWeight : 900 - k * 100
1798
- };
1799
- }
1800
- }
1801
- };
1802
- var applyTypographySequence = () => {
1803
- const CONFIG2 = getActiveConfig();
1804
- const { TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
1805
- generateSequence(TYPOGRAPHY2);
1806
- applyHeadings(TYPOGRAPHY2);
1807
- applySequenceVars(TYPOGRAPHY2);
1808
- runThroughMedia(TYPOGRAPHY2);
1809
- };
1810
-
1811
- // src/system/spacing.js
1812
- var import_utils16 = __toESM(require_cjs(), 1);
1813
- var runThroughMedia2 = (FACTORY2) => {
1814
- for (const prop in FACTORY2) {
1815
- const mediaProps = FACTORY2[prop];
1816
- const isMediaName = prop.slice(0, 1) === "@";
1817
- if (!isMediaName) continue;
1818
- const {
1819
- type,
1820
- base,
1821
- ratio,
1822
- range,
1823
- subSequence,
1824
- h1Matches,
1825
- unit
1826
- } = FACTORY2;
1827
- merge(mediaProps, {
1828
- type,
1829
- base,
1830
- ratio,
1831
- range,
1832
- subSequence,
1833
- h1Matches,
1834
- unit,
1835
- sequence: {},
1836
- scales: {},
1837
- templates: {},
1838
- vars: {}
1839
- });
1840
- generateSequence(mediaProps);
1841
- applyMediaSequenceVars(FACTORY2, prop);
1842
- }
1843
- };
1844
- var applySpacingSequence = () => {
1845
- const CONFIG2 = getActiveConfig();
1846
- const { SPACING: SPACING2 } = CONFIG2;
1847
- generateSequence(SPACING2);
1848
- applySequenceVars(SPACING2);
1849
- runThroughMedia2(SPACING2);
1850
- };
1851
- var getSequence = (sequenceProps) => {
1852
- const CONFIG2 = getActiveConfig();
1853
- const { SPACING: SPACING2 } = CONFIG2;
1854
- if (!sequenceProps) return SPACING2;
1855
- const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
1856
- return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
1857
- };
1858
- var getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
1859
- const sequence = getSequence(sequenceProps);
1860
- if (isString(value) && (value.includes("calc") || value.includes("var"))) {
1861
- return { [propertyName]: value };
1862
- }
1863
- const stack = (0, import_utils16.arrayzeValue)(value);
1864
- if (!isArray(stack)) return;
1865
- if (stack.length > 1) {
1866
- let suffix = "";
1867
- if (propertyName === "borderWidth") {
1868
- propertyName = "border";
1869
- suffix = "Width";
1870
- }
1871
- const directions = {
1872
- 2: ["Block", "Inline"],
1873
- 3: ["BlockStart", "Inline", "BlockEnd"],
1874
- 4: ["BlockStart", "InlineEnd", "BlockEnd", "InlineStart"]
1875
- };
1876
- const wrapSequenceValueByDirection = (direction, i) => getSequenceValuePropertyPair(
1877
- stack[i],
1878
- propertyName + direction + suffix,
1879
- sequence
1880
- );
1881
- return directions[stack.length].map((dir, key) => wrapSequenceValueByDirection(dir, key));
1882
- }
1883
- return getSequenceValuePropertyPair(
1884
- value,
1885
- propertyName,
1886
- sequence
1887
- );
1888
- };
1889
-
1890
- // src/system/shadow.js
1891
- var setShadow = (value, key, suffix, prefers) => {
1892
- const CONFIG2 = getActiveConfig();
1893
- if (isArray(value)) {
1894
- return {
1895
- "@light": setShadow(value[0], key, "light"),
1896
- "@dark": setShadow(value[1], key, "dark")
1897
- };
1898
- }
1899
- if (isObject(value)) {
1900
- const obj = {};
1901
- for (const variant in value) {
1902
- obj[variant] = setShadow(
1903
- value[variant],
1904
- key,
1905
- variant.startsWith("@") ? variant.slice(1) : variant
1906
- );
1907
- }
1908
- return obj;
1909
- }
1910
- if (isString(value) && value.includes(",")) {
1911
- value = value.split(",").map((v) => {
1912
- v = v.trim();
1913
- if (v.startsWith("--")) return `var(${v})`;
1914
- if (getColor(v).length > 2) return getColor(v);
1915
- if (v.includes("px") || v.slice(-2) === "em") return v;
1916
- const arr = v.split(" ");
1917
- if (!arr.length) return v;
1918
- return arr.map((v2) => getSpacingByKey(v2, "shadow").shadow).join(" ");
1919
- }).join(" ");
1920
- }
1921
- const CSSVar = `--shadow-${key}` + (suffix ? `-${suffix}` : "");
1922
- if (CONFIG2.useVariable) {
1923
- CONFIG2.CSS_VARS[CSSVar] = value;
1924
- }
1925
- return {
1926
- var: CSSVar,
1927
- value
1928
- };
1929
- };
1930
-
1931
- // src/system/timing.js
1932
- var import_utils20 = __toESM(require_cjs(), 1);
1933
- var applyTimingSequence = () => {
1934
- const CONFIG2 = getActiveConfig();
1935
- const { TIMING: TIMING2 } = CONFIG2;
1936
- generateSequence(TIMING2);
1937
- applySequenceVars(TIMING2);
1938
- };
1939
-
1940
- // src/system/document.js
1941
- var applyDocument = () => {
1942
- const CONFIG2 = getActiveConfig();
1943
- const { DOCUMENT: DOCUMENT2, FONT_FAMILY: FONT_FAMILY2, THEME: THEME2, TYPOGRAPHY: TYPOGRAPHY2 } = CONFIG2;
1944
- return merge(DOCUMENT2, {
1945
- theme: THEME2.document,
1946
- fontFamily: getDefaultOrFirstKey(FONT_FAMILY2),
1947
- fontSize: TYPOGRAPHY2.base,
1948
- lineHeight: TYPOGRAPHY2.lineHeight
1949
- });
1950
- };
1951
-
1952
- // src/system/svg.js
1953
- var setSVG = (val, key) => {
1954
- const CONFIG2 = getActiveConfig();
1955
- if (!val) {
1956
- if (CONFIG2.verbose) console.warn("setSVG: val is not defined", key);
1957
- return;
1958
- }
1959
- if (CONFIG2.useSvgSprite) {
1960
- return convertSvgToSymbol(key, val);
1961
- }
1962
- return val;
1963
- };
1964
- var setSvgIcon = (val, key) => {
1965
- var _a;
1966
- const CONFIG2 = getActiveConfig();
1967
- if (CONFIG2.useIconSprite && !((_a = CONFIG2.SEMANTIC_ICONS) == null ? void 0 : _a[key])) {
1968
- return setSVG(val, key);
1969
- }
1970
- return val;
1971
- };
1972
-
1973
- // src/system/reset.js
1974
- var applyReset = (reset = {}) => {
1975
- const CONFIG2 = getActiveConfig();
1976
- const { RESET: RESET2, TYPOGRAPHY: TYPOGRAPHY2, DOCUMENT: DOCUMENT2 } = CONFIG2;
1977
- if (RESET2) {
1978
- if (RESET2[":root"]) {
1979
- const configReset = RESET2;
1980
- const configTemplates = TYPOGRAPHY2.templates;
1981
- configReset.body = {
1982
- ...CONFIG2.useDocumentTheme ? getMediaTheme("document", `@${CONFIG2.globalTheme}`) : {},
1983
- ...configTemplates.body
1984
- };
1985
- configReset.h1 = configTemplates.h1;
1986
- configReset.h2 = configTemplates.h2;
1987
- configReset.h3 = configTemplates.h3;
1988
- configReset.h4 = configTemplates.h4;
1989
- configReset.h5 = configTemplates.h5;
1990
- configReset.h6 = configTemplates.h6;
1991
- }
1992
- const { body, ...templates } = TYPOGRAPHY2.templates;
1993
- const globalTheme = CONFIG2.useDocumentTheme ? getMediaTheme("document", `@${CONFIG2.globalTheme}`) : {};
1994
- if (RESET2.html) overwriteDeep(RESET2.html, globalTheme);
1995
- return deepMerge(merge(RESET2, reset), {
1996
- html: {
1997
- position: "absolute",
1998
- // overflow: 'hidden',
1999
- width: "100%",
2000
- height: "100%",
2001
- top: "0",
2002
- left: "0",
2003
- margin: "0",
2004
- WebkitFontSmoothing: "subpixel-antialiased",
2005
- scrollBehavior: "smooth",
2006
- ...globalTheme,
2007
- fontSize: TYPOGRAPHY2.browserDefault + "px",
2008
- fontFamily: DOCUMENT2.fontFamily,
2009
- lineHeight: DOCUMENT2.lineHeight
2010
- },
2011
- body: {
2012
- boxSizing: "border-box",
2013
- height: "100%",
2014
- margin: 0,
2015
- fontFamily: DOCUMENT2.fontFamily,
2016
- fontSize: TYPOGRAPHY2.base / TYPOGRAPHY2.browserDefault + CONFIG2.UNIT.default,
2017
- ...templates,
2018
- ...body
2019
- },
2020
- // form elements
2021
- fieldset: {
2022
- border: 0,
2023
- padding: 0,
2024
- margin: 0
2025
- },
2026
- "select, input": {
2027
- fontFamily: DOCUMENT2.fontFamily
2028
- }
2029
- });
2030
- }
2031
- };
2032
-
2033
- // src/set.js
2034
- var setCases = (val, key) => {
2035
- if (isFunction(val)) return val();
2036
- return val;
2037
- };
2038
- var setSameValue = (val, key) => val;
2039
- var VALUE_TRANSFORMERS = {
2040
- color: setColor,
2041
- gradient: setGradient,
2042
- font: setFont,
2043
- font_family: setFontFamily,
2044
- theme: setTheme,
2045
- icons: setSvgIcon,
34
+ const setSameValue = (val, key) => val;
35
+ const VALUE_TRANSFORMERS = {
36
+ color: import_system.setColor,
37
+ gradient: import_system.setGradient,
38
+ font: import_system.setFont,
39
+ font_family: import_system.setFontFamily,
40
+ theme: import_system.setTheme,
41
+ icons: import_system.setSvgIcon,
2046
42
  semantic_icons: setSameValue,
2047
- svg: setSVG,
43
+ svg: import_system.setSVG,
2048
44
  svg_data: setSameValue,
2049
45
  typography: setSameValue,
2050
46
  cases: setCases,
2051
- shadow: setShadow,
47
+ shadow: import_system.setShadow,
2052
48
  spacing: setSameValue,
2053
49
  media: setSameValue,
2054
50
  grid: setSameValue,
@@ -2058,37 +54,37 @@ var VALUE_TRANSFORMERS = {
2058
54
  unit: setSameValue,
2059
55
  animation: setSameValue
2060
56
  };
2061
- var setValue = (FACTORY_NAME, value, key) => {
2062
- const CONFIG2 = getActiveConfig();
57
+ const setValue = (FACTORY_NAME, value, key) => {
58
+ const CONFIG = (0, import_factory.getActiveConfig)();
2063
59
  const factoryName = FACTORY_NAME.toLowerCase();
2064
- const FACTORY2 = CONFIG2[FACTORY_NAME];
60
+ const FACTORY2 = CONFIG[FACTORY_NAME];
2065
61
  if (VALUE_TRANSFORMERS[factoryName]) {
2066
62
  try {
2067
63
  const result = VALUE_TRANSFORMERS[factoryName](value, key);
2068
64
  FACTORY2[key] = result;
2069
65
  return FACTORY2;
2070
66
  } catch (error) {
2071
- if (CONFIG2.verbose) console.warn("Error setting", factoryName, "value", value, key, error);
67
+ if (CONFIG.verbose) console.warn("Error setting", factoryName, "value", value, key, error);
2072
68
  }
2073
69
  }
2074
- if (CONFIG2.verbose) console.warn("Can not find", factoryName, "method in scratch");
70
+ if (CONFIG.verbose) console.warn("Can not find", factoryName, "method in scratch");
2075
71
  };
2076
- var setEach = (factoryName, props) => {
2077
- const CONFIG2 = getActiveConfig();
72
+ const setEach = (factoryName, props) => {
73
+ const CONFIG = (0, import_factory.getActiveConfig)();
2078
74
  const FACTORY_NAME = factoryName.toUpperCase();
2079
75
  const keys = Object.keys(props);
2080
76
  keys.forEach((key) => {
2081
77
  try {
2082
78
  return setValue(FACTORY_NAME, props[key], key);
2083
79
  } catch (error) {
2084
- if (CONFIG2.verbose) console.warn("Error setting", FACTORY_NAME, "value", props[key], key, error);
80
+ if (CONFIG.verbose) console.warn("Error setting", FACTORY_NAME, "value", props[key], key, error);
2085
81
  }
2086
82
  });
2087
- return CONFIG2[FACTORY_NAME];
83
+ return CONFIG[FACTORY_NAME];
2088
84
  };
2089
- var SET_OPTIONS = {};
2090
- var set = (recivedConfig, options = SET_OPTIONS) => {
2091
- let CONFIG2 = getActiveConfig();
85
+ const SET_OPTIONS = {};
86
+ const set = (recivedConfig, options = SET_OPTIONS) => {
87
+ let CONFIG = (0, import_factory.getActiveConfig)();
2092
88
  const {
2093
89
  version,
2094
90
  verbose,
@@ -2100,49 +96,59 @@ var set = (recivedConfig, options = SET_OPTIONS) => {
2100
96
  globalTheme,
2101
97
  useDocumentTheme,
2102
98
  useDefaultConfig,
2103
- SEMANTIC_ICONS: SEMANTIC_ICONS2,
99
+ SEMANTIC_ICONS,
2104
100
  ...config
2105
101
  } = recivedConfig;
2106
102
  if (options.newConfig) {
2107
- CONFIG2 = setActiveConfig(options.newConfig);
2108
- }
2109
- if (verbose !== void 0) CONFIG2.verbose = verbose;
2110
- if (useVariable !== void 0) CONFIG2.useVariable = useVariable;
2111
- if (useReset !== void 0) CONFIG2.useReset = useReset;
2112
- if (useFontImport !== void 0) CONFIG2.useFontImport = useFontImport;
2113
- if (useSvgSprite !== void 0) CONFIG2.useSvgSprite = useSvgSprite;
2114
- if (useIconSprite !== void 0) CONFIG2.useIconSprite = useIconSprite;
2115
- if (useDocumentTheme !== void 0) CONFIG2.useDocumentTheme = useDocumentTheme;
2116
- if (globalTheme !== void 0) CONFIG2.globalTheme = globalTheme;
2117
- if (useDefaultConfig !== void 0) CONFIG2.useDefaultConfig = useDefaultConfig;
2118
- if (SEMANTIC_ICONS2 !== void 0) CONFIG2.SEMANTIC_ICONS = SEMANTIC_ICONS2;
2119
- if (CONFIG2.verbose) console.log(CONFIG2);
2120
- if (!CONFIG2.__svg_cache) CONFIG2.__svg_cache = {};
103
+ CONFIG = (0, import_factory.setActiveConfig)(options.newConfig);
104
+ }
105
+ if (verbose !== void 0) CONFIG.verbose = verbose;
106
+ if (useVariable !== void 0) CONFIG.useVariable = useVariable;
107
+ if (useReset !== void 0) CONFIG.useReset = useReset;
108
+ if (useFontImport !== void 0) CONFIG.useFontImport = useFontImport;
109
+ if (useSvgSprite !== void 0) CONFIG.useSvgSprite = useSvgSprite;
110
+ if (useIconSprite !== void 0) CONFIG.useIconSprite = useIconSprite;
111
+ if (useDocumentTheme !== void 0) CONFIG.useDocumentTheme = useDocumentTheme;
112
+ if (globalTheme !== void 0) CONFIG.globalTheme = globalTheme;
113
+ if (useDefaultConfig !== void 0) CONFIG.useDefaultConfig = useDefaultConfig;
114
+ if (SEMANTIC_ICONS !== void 0) CONFIG.SEMANTIC_ICONS = SEMANTIC_ICONS;
115
+ if (CONFIG.verbose) console.log(CONFIG);
116
+ if (!CONFIG.__svg_cache) CONFIG.__svg_cache = {};
2121
117
  const keys = Object.keys(config);
2122
- keys.map((key) => setEach(key, config[key]));
2123
- if (config.TYPOGRAPHY) {
118
+ const keySet = new Set(keys);
119
+ keys.forEach((key) => {
120
+ const lower = key.toLowerCase();
121
+ if (lower !== key && keySet.has(lower)) {
122
+ (0, import_utils.deepMerge)(config[lower], config[key]);
123
+ }
124
+ });
125
+ keys.map((key) => {
126
+ const lower = key.toLowerCase();
127
+ if (lower !== key && keySet.has(lower)) return;
128
+ return setEach(key, config[key]);
129
+ });
130
+ if (config.TYPOGRAPHY || config.typography) {
2124
131
  try {
2125
- applyTypographySequence();
132
+ (0, import_system.applyTypographySequence)();
2126
133
  } catch (e) {
2127
- if (CONFIG2.verbose) console.warn("Error applying typography sequence", e);
134
+ if (CONFIG.verbose) console.warn("Error applying typography sequence", e);
2128
135
  }
2129
136
  }
2130
- if (config.SPACING) {
137
+ if (config.SPACING || config.spacing) {
2131
138
  try {
2132
- applySpacingSequence();
139
+ (0, import_system.applySpacingSequence)();
2133
140
  } catch (e) {
2134
- if (CONFIG2.verbose) console.warn("Error applying typography sequence", e);
141
+ if (CONFIG.verbose) console.warn("Error applying spacing sequence", e);
2135
142
  }
2136
143
  }
2137
- if (config.TIMING) {
144
+ if (config.TIMING || config.timing) {
2138
145
  try {
2139
- applyTimingSequence();
146
+ (0, import_system.applyTimingSequence)();
2140
147
  } catch (e) {
2141
- if (CONFIG2.verbose) console.warn("Error applying typography sequence", e);
148
+ if (CONFIG.verbose) console.warn("Error applying timing sequence", e);
2142
149
  }
2143
150
  }
2144
- applyDocument();
2145
- applyReset();
2146
- return CONFIG2;
151
+ (0, import_system.applyDocument)();
152
+ (0, import_system.applyReset)();
153
+ return CONFIG;
2147
154
  };
2148
- // @preserve-env