@projectwallace/css-analyzer 7.5.1 → 7.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,181 +1,188 @@
1
- import ei from "css-tree/parser";
2
- import v from "css-tree/walker";
3
- import { calculateForAST as ti } from "@bramus/specificity/core";
4
- function He(r, t) {
5
- return t >= 65 && t <= 90 && (t = t | 32), r === t;
1
+ var pi = Object.defineProperty;
2
+ var Zt = (i) => {
3
+ throw TypeError(i);
4
+ };
5
+ var hi = (i, e, r) => e in i ? pi(i, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[e] = r;
6
+ var $t = (i, e, r) => hi(i, typeof e != "symbol" ? e + "" : e, r), Jt = (i, e, r) => e.has(i) || Zt("Cannot " + r);
7
+ var h = (i, e, r) => (Jt(i, e, "read from private field"), r ? r.call(i) : e.get(i)), F = (i, e, r) => e.has(i) ? Zt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, r), L = (i, e, r, t) => (Jt(i, e, "write to private field"), t ? t.call(i, r) : e.set(i, r), r);
8
+ var Ye = (i, e, r, t) => ({
9
+ set _(o) {
10
+ L(i, e, o, r);
11
+ },
12
+ get _() {
13
+ return h(i, e, t);
14
+ }
15
+ });
16
+ import mi from "css-tree/parser";
17
+ import C from "css-tree/walker";
18
+ import { calculateForAST as gi } from "@bramus/specificity/core";
19
+ import { walk as li } from "css-tree";
20
+ function Je(i, e) {
21
+ return e >= 65 && e <= 90 && (e = e | 32), i === e;
6
22
  }
7
- function S(r, t) {
8
- if (r === t) return !0;
9
- let s = r.length;
10
- if (s !== t.length) return !1;
11
- for (let e = 0; e < s; e++)
12
- if (He(r.charCodeAt(e), t.charCodeAt(e)) === !1)
23
+ function q(i, e) {
24
+ if (i === e) return !0;
25
+ let r = i.length;
26
+ if (r !== e.length) return !1;
27
+ for (let t = 0; t < r; t++)
28
+ if (Je(i.charCodeAt(t), e.charCodeAt(t)) === !1)
13
29
  return !1;
14
30
  return !0;
15
31
  }
16
- function O(r, t) {
17
- if (r === t) return !0;
18
- let s = t.length, e = s - r.length;
19
- if (e < 0)
32
+ function E(i, e) {
33
+ if (i === e) return !0;
34
+ let r = e.length, t = r - i.length;
35
+ if (t < 0)
20
36
  return !1;
21
- for (let n = s - 1; n >= e; n--)
22
- if (He(r.charCodeAt(n - e), t.charCodeAt(n)) === !1)
37
+ for (let o = r - 1; o >= t; o--)
38
+ if (Je(i.charCodeAt(o - t), e.charCodeAt(o)) === !1)
23
39
  return !1;
24
40
  return !0;
25
41
  }
26
- function We(r, t) {
27
- if (r === t) return !0;
28
- let s = r.length;
29
- if (t.length < s) return !1;
30
- for (let e = 0; e < s; e++)
31
- if (He(r.charCodeAt(e), t.charCodeAt(e)) === !1)
42
+ function Xe(i, e) {
43
+ if (i === e) return !0;
44
+ let r = i.length;
45
+ if (e.length < r) return !1;
46
+ for (let t = 0; t < r; t++)
47
+ if (Je(i.charCodeAt(t), e.charCodeAt(t)) === !1)
32
48
  return !1;
33
49
  return !0;
34
50
  }
35
- const Te = "Atrule", ii = "MediaQuery", Me = "Rule", Ke = "Selector", Nt = "TypeSelector", G = "PseudoClassSelector", jt = "AttributeSelector", Bt = "PseudoElementSelector", Ve = "Declaration", ri = "Value", R = "Identifier", si = "Nth", li = "Combinator", Yt = "Number", Ne = "Dimension", W = "Operator", ni = "Hash", ai = "Url", je = "Function";
36
- function Ut(r, t, s) {
37
- let e = r.value.children.first;
38
- return S(t, r.property) && e.type === R && S(s, e.name);
51
+ const Ge = "Atrule", di = "MediaQuery", Qe = "Rule", yi = "Selector", wi = "Value", T = "Identifier", ki = "Nth", bi = "Combinator", si = "Number", et = "Dimension", Z = "Operator", xi = "Hash", Ci = "Url", tt = "Function";
52
+ function Xt(i, e, r) {
53
+ let t = i.value.children.first;
54
+ return q(e, i.property) && t.type === T && q(r, t.name);
39
55
  }
40
- function oi(r) {
41
- let t = !1;
42
- return v(r, function(s) {
43
- if (s.type === Ve && (Ut(s, "-webkit-appearance", "none") || Ut(s, "-moz-appearance", "meterbar")))
44
- return t = !0, this.break;
45
- }), t;
56
+ function vi(i) {
57
+ let e = !1;
58
+ return li(i, function(r) {
59
+ if (r.type === "Declaration" && (Xt(r, "-webkit-appearance", "none") || Xt(r, "-moz-appearance", "meterbar")))
60
+ return e = !0, this.break;
61
+ }), e;
46
62
  }
47
- function ui(r) {
48
- let t = !1;
49
- return v(r, function(s) {
50
- let e = s.name, n = s.value;
51
- if (s.type === ii && s.mediaType !== null) {
52
- if (We("\\0", s.mediaType) || O("\\9 ", s.mediaType))
53
- return t = !0, this.break;
54
- } else if (s.type === "Feature" && s.kind === "media") {
63
+ function Si(i) {
64
+ let e = !1;
65
+ return li(i, function(r) {
66
+ let { mediaType: t, name: o, value: n, type: y, kind: k } = r;
67
+ if (y === di && t !== null) {
68
+ if (Xe("\\0", t) || E("\\9 ", t))
69
+ return e = !0, this.break;
70
+ } else if (y === "Feature" && k === "media") {
55
71
  if (n && n.unit && n.unit === "\\0")
56
- return t = !0, this.break;
57
- if (S("-moz-images-in-menus", e) || S("min--moz-device-pixel-ratio", e) || S("-ms-high-contrast", e))
58
- return t = !0, this.break;
59
- if (S("min-resolution", e) && n && S(".001", n.value) && S("dpcm", n.unit))
60
- return t = !0, this.break;
61
- if (S("-webkit-min-device-pixel-ratio", e) && n && n.value && (S("0", n.value) || S("10000", n.value)))
62
- return t = !0, this.break;
72
+ return e = !0, this.break;
73
+ if (q("-moz-images-in-menus", o) || q("min--moz-device-pixel-ratio", o) || q("-ms-high-contrast", o))
74
+ return e = !0, this.break;
75
+ if (q("min-resolution", o) && n && q(".001", n.value) && q("dpcm", n.unit))
76
+ return e = !0, this.break;
77
+ if (q("-webkit-min-device-pixel-ratio", o) && n && n.value && (q("0", n.value) || q("10000", n.value)))
78
+ return e = !0, this.break;
63
79
  }
64
- }), t;
80
+ }), e;
65
81
  }
66
- const Vt = 45;
67
- function E(r) {
68
- return r.charCodeAt(0) === Vt && r.charCodeAt(1) !== Vt && r.indexOf("-", 2) !== -1;
82
+ const ei = 45;
83
+ function W(i) {
84
+ return i.charCodeAt(0) === ei && i.charCodeAt(1) !== ei && i.indexOf("-", 2) !== -1;
69
85
  }
70
- class A {
71
- /** @param {string[]} items */
72
- constructor(t) {
73
- this.set = new Set(t);
86
+ class O {
87
+ constructor(e) {
88
+ $t(this, "set");
89
+ this.set = new Set(e);
74
90
  }
75
- /** @param {string} item */
76
- has(t) {
77
- return this.set.has(t.toLowerCase());
91
+ has(e) {
92
+ return this.set.has(e.toLowerCase());
78
93
  }
79
94
  }
80
- function Gt(r, t) {
81
- let s = [];
82
- return v(r, {
83
- visit: Ke,
84
- enter: function(e) {
85
- s.push(t(e));
95
+ function ni(i, e) {
96
+ let r = [];
97
+ return C(i, {
98
+ visit: "Selector",
99
+ enter: function(t) {
100
+ r.push(e(t));
86
101
  }
87
- }), s;
102
+ }), r;
88
103
  }
89
- const Qt = new A([
90
- "nth-child",
91
- "where",
92
- "not",
93
- "is",
94
- "has",
95
- "nth-last-child",
96
- "matches",
97
- "-webkit-any",
98
- "-moz-any"
99
- ]);
100
- function Zt(r) {
101
- let t = !1;
102
- return v(r, function(s) {
103
- if (s.type === jt) {
104
- let e = s.name.name;
105
- if (S("role", e) || We("aria-", e))
106
- return t = !0, this.break;
107
- } else if (s.type === G && Qt.has(s.name)) {
108
- let e = Gt(s, Zt);
109
- for (let n of e)
110
- if (n === !0) {
111
- t = !0;
104
+ const ai = new O(["nth-child", "where", "not", "is", "has", "nth-last-child", "matches", "-webkit-any", "-moz-any"]);
105
+ function oi(i) {
106
+ let e = !1;
107
+ return C(i, function(r) {
108
+ if (r.type === "AttributeSelector") {
109
+ let t = r.name.name;
110
+ if (q("role", t) || Xe("aria-", t))
111
+ return e = !0, C.break;
112
+ } else if (r.type === "PseudoClassSelector" && ai.has(r.name)) {
113
+ let t = ni(r, oi);
114
+ for (let o of t)
115
+ if (o === !0) {
116
+ e = !0;
112
117
  break;
113
118
  }
114
- return this.skip;
119
+ return C.skip;
115
120
  }
116
- }), t;
121
+ }), e;
117
122
  }
118
- function ci(r) {
119
- let t = !1;
120
- return v(r, function(s) {
121
- let e = s.type;
122
- if ((e === Bt || e === Nt || e === G) && E(s.name))
123
- return t = !0, this.break;
124
- }), t;
123
+ function zi(i) {
124
+ let e = !1;
125
+ return C(i, function(r) {
126
+ let t = r.type;
127
+ if ((t === "PseudoElementSelector" || t === "TypeSelector" || t === "PseudoClassSelector") && W(r.name))
128
+ return e = !0, C.break;
129
+ }), e;
125
130
  }
126
- function fi(r) {
127
- let t = [];
128
- return v(r, function(s) {
129
- s.type === G && t.push(s.name);
130
- }), t.length === 0 ? !1 : t;
131
+ function qi(i) {
132
+ let e = [];
133
+ return C(i, function(r) {
134
+ r.type === "PseudoClassSelector" && e.push(r.name);
135
+ }), e.length === 0 ? !1 : e;
131
136
  }
132
- function Jt(r) {
133
- let t = 0;
134
- return v(r, function(s) {
135
- let e = s.type;
136
- if (!(e === Ke || e === si)) {
137
- if (t++, (e === Bt || e === Nt || e === G) && E(s.name) && t++, e === jt)
138
- return s.value && t++, this.skip;
139
- if (e === G && Qt.has(s.name)) {
140
- let n = Gt(s, Jt);
141
- if (n.length === 0) return;
142
- for (let a of n)
143
- t += a;
144
- return this.skip;
137
+ function ui(i) {
138
+ let e = 0;
139
+ return C(i, function(r) {
140
+ let t = r.type;
141
+ if (!(t === "Selector" || t === ki)) {
142
+ if (e++, (t === "PseudoElementSelector" || t === "TypeSelector" || t === "PseudoClassSelector") && W(r.name) && e++, t === "AttributeSelector")
143
+ return r.value && e++, C.skip;
144
+ if (t === "PseudoClassSelector" && ai.has(r.name)) {
145
+ let o = ni(r, ui);
146
+ if (o.length === 0) return;
147
+ for (let n of o)
148
+ e += n;
149
+ return C.skip;
145
150
  }
146
151
  }
147
- }), t;
152
+ }), e;
148
153
  }
149
- function pi(r, t) {
150
- v(r, function(s, e) {
151
- if (s.type === li) {
152
- let n = s.loc, a = s.name;
153
- if (n === null) {
154
- let y = e.prev.data.loc.end, b = {
154
+ function Ai(i, e) {
155
+ C(i, function(r, t) {
156
+ if (r.type === bi) {
157
+ let o = r.loc, n = r.name;
158
+ if (o === null) {
159
+ let y = t.prev.data.loc.end, k = {
155
160
  offset: y.offset,
156
161
  line: y.line,
157
162
  column: y.column
158
163
  };
159
- t({
160
- name: a,
164
+ e({
165
+ name: n,
166
+ // @ts-expect-error TODO: fix this
161
167
  loc: {
162
- start: b,
168
+ start: k,
163
169
  end: {
164
- offset: b.offset + 1,
165
- line: b.line,
166
- column: b.column + 1
170
+ offset: k.offset + 1,
171
+ line: k.line,
172
+ column: k.column + 1
167
173
  }
168
174
  }
169
175
  });
170
176
  } else
171
- t({
172
- name: a,
173
- loc: n
177
+ e({
178
+ name: n,
179
+ // @ts-expect-error TODO: fix this
180
+ loc: o
174
181
  });
175
182
  }
176
183
  });
177
184
  }
178
- const hi = new A([
185
+ const Pi = new O([
179
186
  // CSS Named Colors
180
187
  // Spec: https://drafts.csswg.org/css-color/#named-colors
181
188
  // Heuristic: popular names first for quick finding in set.has()
@@ -328,7 +335,7 @@ const hi = new A([
328
335
  "mediumorchid",
329
336
  "darksalmon",
330
337
  "mediumspringgreen"
331
- ]), mi = new A([
338
+ ]), Li = new O([
332
339
  // CSS System Colors
333
340
  // Spec: https://drafts.csswg.org/css-color/#css-system-colors
334
341
  "accentcolor",
@@ -350,21 +357,7 @@ const hi = new A([
350
357
  "selecteditem",
351
358
  "selecteditemtext",
352
359
  "visitedtext"
353
- ]), gi = new A([
354
- "rgba",
355
- "rgb",
356
- "hsla",
357
- "hsl",
358
- "oklch",
359
- "color",
360
- "hwb",
361
- "lch",
362
- "lab",
363
- "oklab"
364
- ]), di = new A([
365
- "transparent",
366
- "currentcolor"
367
- ]), ie = new A([
360
+ ]), Oi = new O(["rgba", "rgb", "hsla", "hsl", "oklch", "color", "hwb", "lch", "lab", "oklab"]), Ri = new O(["transparent", "currentcolor"]), he = new O([
368
361
  "auto",
369
362
  "none",
370
363
  // for `text-shadow`, `box-shadow` and `background`
@@ -374,29 +367,22 @@ const hi = new A([
374
367
  "revert",
375
368
  "revert-layer"
376
369
  ]);
377
- function te(r) {
378
- let t = r.children, s = t.size;
379
- if (!t || s > 1 || s === 0) return !1;
380
- let e = t.first;
381
- return e.type === R && ie.has(e.name);
370
+ function pe(i) {
371
+ let e = i.children, r = e.size;
372
+ if (!e || r > 1 || r === 0) return !1;
373
+ let t = e.first;
374
+ return t.type === T && he.has(t.name);
382
375
  }
383
- function Ht(r) {
384
- return parseFloat(r) === 0;
376
+ function ti(i) {
377
+ return parseFloat(i) === 0;
385
378
  }
386
- function yi(r) {
387
- for (let t of r.children.toArray())
388
- if (!(t.type === Yt && Ht(t.value)) && !(t.type === Ne && Ht(t.value)))
379
+ function Di(i) {
380
+ for (let e of i.children.toArray())
381
+ if (!(e.type === si && ti(e.value)) && !(e.type === et && ti(e.value)))
389
382
  return !1;
390
383
  return !0;
391
384
  }
392
- const wi = new A([
393
- "caption",
394
- "icon",
395
- "menu",
396
- "message-box",
397
- "small-caption",
398
- "status-bar"
399
- ]), ki = new A([
385
+ const Fi = new O(["caption", "icon", "menu", "message-box", "small-caption", "status-bar"]), Ei = new O([
400
386
  /* <absolute-size> values */
401
387
  "xx-small",
402
388
  "x-small",
@@ -409,223 +395,206 @@ const wi = new A([
409
395
  /* <relative-size> values */
410
396
  "smaller",
411
397
  "larger"
412
- ]), bi = 44, Wt = 47;
413
- function Ie(r) {
414
- let t = r.children.first;
415
- return t === null ? !1 : t.type === R && wi.has(t.name);
398
+ ]), _i = 44, ii = 47;
399
+ function Ze(i) {
400
+ let e = i.children.first;
401
+ return e === null ? !1 : e.type === T && Fi.has(e.name);
416
402
  }
417
- function xi(r, t, s) {
418
- var b;
419
- let e = [,], n, a;
420
- if (r.children.first.type === "Function" && r.children.first.name.toLowerCase() === "var")
403
+ function Mi(i, e, r) {
404
+ var k;
405
+ let t = [void 0, void 0], o, n;
406
+ if (i.children.first.type === "Function" && i.children.first.name.toLowerCase() === "var")
421
407
  return null;
422
- r.children.forEach(function(w, _) {
423
- let k = _.prev ? _.prev.data : void 0, P = _.next ? _.next.data : void 0;
424
- if (w.type === R && ie.has(w.name) && s({
408
+ i.children.forEach(function(b, A) {
409
+ let x = A.prev ? A.prev.data : void 0, R = A.next ? A.next.data : void 0;
410
+ if (b.type === T && he.has(b.name) && r({
425
411
  type: "keyword",
426
- value: w.name
427
- }), P && P.type === W && P.value.charCodeAt(0) === Wt) {
428
- n = t(w);
412
+ value: b.name
413
+ }), R && R.type === Z && R.value.charCodeAt(0) === ii) {
414
+ o = e(b);
429
415
  return;
430
416
  }
431
- if (k && k.type === W && k.value.charCodeAt(0) === Wt) {
432
- a = t(w);
417
+ if (x && x.type === Z && x.value.charCodeAt(0) === ii) {
418
+ n = e(b);
433
419
  return;
434
420
  }
435
- if (P && P.type === W && P.value.charCodeAt(0) === bi && !e[0]) {
436
- e[0] = w, !n && k && (n = t(k));
421
+ if (R && R.type === Z && R.value.charCodeAt(0) === _i && !t[0]) {
422
+ t[0] = b, !o && x && (o = e(x));
437
423
  return;
438
424
  }
439
- if (w.type !== Yt) {
440
- if (_.next === null) {
441
- e[1] = w, !n && !e[0] && k && (n = t(k));
425
+ if (b.type !== si) {
426
+ if (A.next === null) {
427
+ t[1] = b, !o && !t[0] && x && (o = e(x));
442
428
  return;
443
429
  }
444
- if (w.type === R) {
445
- let D = w.name;
446
- if (ki.has(D)) {
447
- n = D;
430
+ if (b.type === T) {
431
+ let U = b.name;
432
+ if (Ei.has(U)) {
433
+ o = U;
448
434
  return;
449
435
  }
450
436
  }
451
437
  }
452
438
  });
453
- let y = e[0] || e[1] ? t({
439
+ let y = t[0] || t[1] ? e({
454
440
  loc: {
441
+ // @ts-expect-error TODO: fix this
455
442
  start: {
456
- offset: (e[0] || e[1]).loc.start.offset
443
+ // @ts-expect-error TODO: fix this
444
+ offset: (t[0] || t[1]).loc.start.offset
457
445
  },
446
+ // @ts-expect-error TODO: fix this
458
447
  end: {
459
448
  // Either the node we detected as the last node, or the end of the whole value
460
449
  // It's never 0 because the first node is always a font-size or font-style
461
- offset: ((b = e[1]) == null ? void 0 : b.loc.end.offset) || r.loc.end.offset
450
+ offset: ((k = t[1]) == null ? void 0 : k.loc.end.offset) || i.loc.end.offset
462
451
  }
463
452
  }
464
453
  }) : null;
465
454
  return {
466
- font_size: n,
467
- line_height: a,
455
+ font_size: o,
456
+ line_height: n,
468
457
  font_family: y
469
458
  };
470
459
  }
471
- const Ci = new A([
472
- "linear",
473
- "ease",
474
- "ease-in",
475
- "ease-out",
476
- "ease-in-out",
477
- "step-start",
478
- "step-end"
479
- ]), zi = new A([
480
- "cubic-bezier",
481
- "steps"
482
- ]);
483
- function Si(r, t) {
484
- let s = !1;
485
- for (let e of r) {
486
- let n = e.type, a = e.name;
487
- n === W ? s = !1 : n === Ne && s === !1 ? (s = !0, t({
460
+ const Ii = new O(["linear", "ease", "ease-in", "ease-out", "ease-in-out", "step-start", "step-end"]), Ti = new O(["cubic-bezier", "steps"]);
461
+ function Ui(i, e) {
462
+ let r = !1;
463
+ for (let t of i) {
464
+ let o = t.type, n = t.name;
465
+ o === Z ? r = !1 : o === et && r === !1 ? (r = !0, e({
488
466
  type: "duration",
489
- value: e
490
- })) : n === R ? Ci.has(a) ? t({
467
+ value: t
468
+ })) : o === T ? Ii.has(n) ? e({
491
469
  type: "fn",
492
- value: e
493
- }) : ie.has(a) && t({
470
+ value: t
471
+ }) : he.has(n) && e({
494
472
  type: "keyword",
495
- value: e
496
- }) : n === je && zi.has(a) && t({
473
+ value: t
474
+ }) : o === tt && Ti.has(n) && e({
497
475
  type: "fn",
498
- value: e
476
+ value: t
499
477
  });
500
478
  }
501
479
  }
502
- function Xt(r) {
503
- let t = r.children;
504
- if (!t)
480
+ function ci(i) {
481
+ let e = i.children;
482
+ if (!e)
505
483
  return !1;
506
- for (let s of t) {
507
- let { type: e, name: n } = s;
508
- if (e === R && E(n) || e === je && (E(n) || Xt(s)))
484
+ for (let r of e) {
485
+ let { type: t, name: o } = r;
486
+ if (t === T && W(o) || t === tt && (W(o) || ci(r)))
509
487
  return !0;
510
488
  }
511
489
  return !1;
512
490
  }
513
- class o {
514
- /** @param {boolean} useLocations */
515
- constructor(t = !1) {
516
- this._items = /* @__PURE__ */ new Map(), this._total = 0, t && (this._nodes = []), this._useLocations = t;
491
+ var H, _, M, $;
492
+ class u {
493
+ constructor(e = !1) {
494
+ F(this, H);
495
+ F(this, _);
496
+ F(this, M, []);
497
+ F(this, $);
498
+ L(this, H, /* @__PURE__ */ new Map()), L(this, _, 0), e && L(this, M, []), L(this, $, e);
517
499
  }
518
- /**
519
- * @param {string | number} item
520
- * @param {import('css-tree').CssLocation} node_location
521
- */
522
- p(t, s) {
523
- let e = this._total;
524
- if (this._useLocations) {
525
- let n = s.start, a = n.offset, y = e * 4;
526
- this._nodes[y] = n.line, this._nodes[y + 1] = n.column, this._nodes[y + 2] = a, this._nodes[y + 3] = s.end.offset - a;
500
+ p(e, r) {
501
+ let t = h(this, _);
502
+ if (h(this, $)) {
503
+ let o = r.start, n = o.offset, y = t * 4;
504
+ h(this, M)[y] = o.line, h(this, M)[y + 1] = o.column, h(this, M)[y + 2] = n, h(this, M)[y + 3] = r.end.offset - n;
527
505
  }
528
- if (this._items.has(t)) {
529
- this._items.get(t).push(e), this._total++;
506
+ if (h(this, H).has(e)) {
507
+ h(this, H).get(e).push(t), Ye(this, _)._++;
530
508
  return;
531
509
  }
532
- this._items.set(t, [e]), this._total++;
510
+ h(this, H).set(e, [t]), Ye(this, _)._++;
533
511
  }
534
512
  size() {
535
- return this._total;
513
+ return h(this, _);
536
514
  }
537
- /**
538
- * @typedef CssLocation
539
- * @property {number} line
540
- * @property {number} column
541
- * @property {number} offset
542
- * @property {number} length
543
- *
544
- * @returns {{
545
- * total: number;
546
- * totalUnique: number;
547
- * uniquenessRatio: number;
548
- * unique: Record<string, number>;
549
- * } & ({
550
- * uniqueWithLocations: Record<string, CssLocation[]>
551
- * } | {
552
- * uniqueWithLocations?: undefined
553
- * })}
554
- */
555
515
  c() {
556
- let t = /* @__PURE__ */ new Map(), s = {}, e = this._useLocations, n = this._items, a = this._nodes, y = n.size;
557
- n.forEach((_, k) => {
558
- if (e) {
559
- let P = _.map(function(D) {
560
- let T = D * 4;
516
+ let e = /* @__PURE__ */ new Map(), r = {}, t = h(this, $), o = h(this, H), n = h(this, M), y = o.size;
517
+ o.forEach((A, x) => {
518
+ if (t) {
519
+ let R = A.map(function(U) {
520
+ let N = U * 4;
561
521
  return {
562
- line: a[T],
563
- column: a[T + 1],
564
- offset: a[T + 2],
565
- length: a[T + 3]
522
+ line: n[N],
523
+ column: n[N + 1],
524
+ offset: n[N + 2],
525
+ length: n[N + 3]
566
526
  };
567
527
  });
568
- t.set(k, P);
528
+ e.set(x, R);
569
529
  } else
570
- s[k] = _.length;
530
+ r[x] = A.length;
571
531
  });
572
- let b = this._total, w = {
573
- total: b,
532
+ let k = h(this, _);
533
+ return {
534
+ total: k,
574
535
  totalUnique: y,
575
- unique: s,
576
- uniquenessRatio: b === 0 ? 0 : y / b
536
+ unique: r,
537
+ uniquenessRatio: k === 0 ? 0 : y / k,
538
+ uniqueWithLocations: t ? Object.fromEntries(e) : void 0
577
539
  };
578
- return e && (w.uniqueWithLocations = Object.fromEntries(t)), w;
579
540
  }
580
541
  }
581
- class Ue {
582
- /** @param {boolean} useLocations */
583
- constructor(t) {
584
- this._list = new o(t), this._contexts = /* @__PURE__ */ new Map(), this._useLocations = t;
542
+ H = new WeakMap(), _ = new WeakMap(), M = new WeakMap(), $ = new WeakMap();
543
+ var J, K, se;
544
+ class $e {
545
+ constructor(e) {
546
+ F(this, J);
547
+ F(this, K);
548
+ F(this, se);
549
+ L(this, J, new u(e)), L(this, K, /* @__PURE__ */ new Map()), L(this, se, e);
585
550
  }
586
551
  /**
587
- * Add an item to this _list's context
588
- * @param {string} item Item to push
589
- * @param {string} context Context to push Item to
590
- * @param {import('css-tree').CssLocation} node_location
552
+ * Add an item to this #list's context
553
+ * @param item Item to push
554
+ * @param context Context to push Item to
555
+ * @param node_location
591
556
  */
592
- push(t, s, e) {
593
- this._list.p(t, e), this._contexts.has(s) || this._contexts.set(s, new o(this._useLocations)), this._contexts.get(s).p(t, e);
557
+ push(e, r, t) {
558
+ h(this, J).p(e, t), h(this, K).has(r) || h(this, K).set(r, new u(h(this, se))), h(this, K).get(r).p(e, t);
594
559
  }
595
560
  count() {
596
- let t = /* @__PURE__ */ new Map();
597
- for (let [s, e] of this._contexts.entries())
598
- t.set(s, e.c());
599
- return Object.assign(this._list.c(), {
600
- itemsPerContext: Object.fromEntries(t)
561
+ let e = /* @__PURE__ */ new Map();
562
+ for (let [r, t] of h(this, K).entries())
563
+ e.set(r, t.c());
564
+ return Object.assign(h(this, J).c(), {
565
+ itemsPerContext: Object.fromEntries(e)
601
566
  });
602
567
  }
603
568
  }
604
- function _i(r) {
605
- let t = /* @__PURE__ */ new Map(), s = -1, e = 0, n = 0, a = r.length;
606
- for (let y = 0; y < a; y++) {
607
- let b = r[y], w = (t.get(b) || 0) + 1;
608
- t.set(b, w), w > s && (s = w, e = 0, n = 0), w >= s && (e++, n += b);
569
+ J = new WeakMap(), K = new WeakMap(), se = new WeakMap();
570
+ function Vi(i) {
571
+ let e = /* @__PURE__ */ new Map(), r = -1, t = 0, o = 0, n = i.length;
572
+ for (let y = 0; y < n; y++) {
573
+ let k = i[y], b = (e.get(k) || 0) + 1;
574
+ e.set(k, b), b > r && (r = b, t = 0, o = 0), b >= r && (t++, o += k);
609
575
  }
610
- return n / e;
576
+ return o / t;
611
577
  }
612
- class C {
578
+ var I, X;
579
+ class S {
613
580
  constructor() {
614
- this._items = [], this._sum = 0;
581
+ F(this, I);
582
+ F(this, X);
583
+ L(this, I, []), L(this, X, 0);
615
584
  }
616
585
  /**
617
586
  * Add a new Integer at the end of this AggregateCollection
618
- * @param {number} item - The item to add
587
+ * @param item - The item to add
619
588
  */
620
- push(t) {
621
- this._items.push(t), this._sum += t;
589
+ push(e) {
590
+ h(this, I).push(e), L(this, X, h(this, X) + e);
622
591
  }
623
592
  size() {
624
- return this._items.length;
593
+ return h(this, I).length;
625
594
  }
626
595
  aggregate() {
627
- let t = this._items.length;
628
- if (t === 0)
596
+ let e = h(this, I).length;
597
+ if (e === 0)
629
598
  return {
630
599
  min: 0,
631
600
  max: 0,
@@ -634,50 +603,54 @@ class C {
634
603
  range: 0,
635
604
  sum: 0
636
605
  };
637
- let s = this._items.slice().sort((b, w) => b - w), e = s[0], n = s[t - 1], a = _i(s), y = this._sum;
606
+ let r = h(this, I).slice().sort((k, b) => k - b), t = r[0], o = r[e - 1], n = Vi(r), y = h(this, X);
638
607
  return {
639
- min: e,
640
- max: n,
641
- mean: y / t,
642
- mode: a,
643
- range: n - e,
608
+ min: t,
609
+ max: o,
610
+ mean: y / e,
611
+ mode: n,
612
+ range: o - t,
644
613
  sum: y
645
614
  };
646
615
  }
647
- /**
648
- * @returns {number[]} All _items in this collection
649
- */
650
616
  toArray() {
651
- return this._items;
617
+ return h(this, I);
652
618
  }
653
619
  }
654
- function qi(r) {
655
- if (Be(r) || E(r)) return !1;
656
- let t = r.charCodeAt(0);
657
- return t === 47 || t === 42 || t === 95 || t === 43 || t === 38 || t === 36 || t === 35;
620
+ I = new WeakMap(), X = new WeakMap();
621
+ function Hi(i) {
622
+ if (it(i) || W(i)) return !1;
623
+ let e = i.charCodeAt(0);
624
+ return e === 47 || // /
625
+ e === 42 || // *
626
+ e === 95 || // _
627
+ e === 43 || // +
628
+ e === 38 || // &
629
+ e === 36 || // $
630
+ e === 35;
658
631
  }
659
- function Be(r) {
660
- return r.length < 3 ? !1 : r.charCodeAt(0) === 45 && r.charCodeAt(1) === 45;
632
+ function it(i) {
633
+ return i.length < 3 ? !1 : i.charCodeAt(0) === 45 && i.charCodeAt(1) === 45;
661
634
  }
662
- function m(r, t) {
663
- return Be(t) ? !1 : O(r, t);
635
+ function m(i, e) {
636
+ return it(e) ? !1 : E(i, e);
664
637
  }
665
- function vi(r) {
666
- return E(r) ? r.slice(r.indexOf("-", 2) + 1) : r;
638
+ function Ki(i) {
639
+ return W(i) ? i.slice(i.indexOf("-", 2) + 1) : i;
667
640
  }
668
- function Ai(r) {
669
- let t = 5, s = r.indexOf(";"), e = r.indexOf(",");
670
- return s === -1 || e !== -1 && e < s ? r.substring(t, e) : r.substring(t, s);
641
+ function Wi(i) {
642
+ let e = 5, r = i.indexOf(";"), t = i.indexOf(",");
643
+ return r === -1 || t !== -1 && t < r ? i.substring(e, t) : i.substring(e, r);
671
644
  }
672
- function Pi(r) {
673
- let t = r.children;
674
- if (t) {
675
- let s = t.last;
676
- return s && s.type === R && O("\\9", s.name);
645
+ function Ni(i) {
646
+ let e = i.children;
647
+ if (e) {
648
+ let r = e.last;
649
+ return !!(r && r.type === T && E("\\9", r.name));
677
650
  }
678
651
  return !1;
679
652
  }
680
- let Li = new A([
653
+ let ji = new O([
681
654
  "border-radius",
682
655
  "border-top-left-radius",
683
656
  "border-top-right-radius",
@@ -688,234 +661,233 @@ let Li = new A([
688
661
  "border-end-end-radius",
689
662
  "border-end-start-radius"
690
663
  ]);
691
- function z(r, t) {
692
- return t === 0 ? 0 : r / t;
664
+ function z(i, e) {
665
+ return e === 0 ? 0 : i / e;
693
666
  }
694
- let Oi = {
667
+ let Bi = {
695
668
  useLocations: !1
696
669
  };
697
- function Ei(r, t = {}) {
698
- let e = Object.assign({}, Oi, t).useLocations === !0, n = Date.now();
699
- function a(i) {
700
- return y(i).trim();
670
+ function Ji(i, e = {}) {
671
+ let t = Object.assign({}, Bi, e).useLocations === !0, o = Date.now();
672
+ function n(l) {
673
+ return y(l).trim();
701
674
  }
702
- function y(i) {
703
- let Y = i.loc;
704
- return r.substring(Y.start.offset, Y.end.offset);
675
+ function y(l) {
676
+ let le = l.loc;
677
+ return i.substring(le.start.offset, le.end.offset);
705
678
  }
706
- let b = 0, w = 0, _ = 0, k = {
679
+ let k = 0, b = 0, A = 0, x = {
707
680
  total: 0,
708
681
  /** @type {Map<string, { size: number, count: number } & ({ uniqueWithLocations?: undefined } | ({ uniqueWithLocations: { offset: number, line: number, column: number, length: number }[] })) }>} */
709
682
  unique: /* @__PURE__ */ new Map()
710
- }, P = Date.now(), D = ei(r, {
683
+ }, R = Date.now(), U = mi(i, {
711
684
  parseCustomProperty: !0,
712
685
  // To find font-families, colors, etc.
713
686
  positions: !0,
714
687
  // So we can use stringifyNode()
715
- /** @param {string} comment */
716
- onComment: function(i) {
717
- b++, w += i.length;
688
+ onComment: function(l) {
689
+ k++, b += l.length;
718
690
  }
719
- }), T = Date.now(), $t = D.loc.end.line - D.loc.start.line + 1, Ye = new o(e), re = new C(), se = [], Ge = new o(e), le = new o(e), Qe = new o(e), Ze = new o(e), Je = new o(e), Xe = new o(e), $e = new o(e), ne = new o(e), et = new o(e), ae = new o(e), oe = new o(e), tt = new o(e), Q = new o(e), it = new o(e), ue = new C(), rt = new o(e), ce = 0, fe = 0, pe = new C(), he = new C(), me = new C(), st = new o(e), lt = new o(e), nt = new o(e), ge = new C(), at = new o(e), de = new o(e), ot = /* @__PURE__ */ new Set(), ye = new o(e), M, I, ut = new C(), ct = new C(), ft = new C(), pt = new o(e), Z = new C(), ht = new o(e), mt = [], we = new o(e), ke = new o(e), gt = new o(e), dt = new o(e), be = new C(), yt = new o(e), wt = /* @__PURE__ */ new Set(), K = 0, kt = new C(), J = 0, xe = 0, Ce = new o(e), ze = new C(), bt = new o(e), N = new o(e), Se = new o(e), _e = new o(e), X = new o(e), j = new C(), qe = new C(), xt = new o(e), ve = new o(e), Ct = new o(e), zt = new o(e), St = new o(e), Ae = new o(e), Pe = new o(e), Le = new o(e), $ = new o(e), ee = new o(e), U = new Ue(e), V = new o(e), Oe = new Ue(e), _t = new o(e), B = new o(e), qt = new Ue(e), vt = new o(e), L = 0;
720
- v(D, {
721
- enter(i) {
722
- var Y, Mt;
723
- switch (i.type) {
724
- case Te: {
725
- Ye.p(i.name, i.loc), ue.push(L), rt.p(L, i.loc);
726
- let p = i.name;
727
- if (p === "font-face") {
728
- let g = {};
729
- e && Ge.p(i.loc.start.offset, i.loc), i.block.children.forEach((c) => {
730
- c.type === Ve && (g[c.property] = a(c.value));
731
- }), se.push(g), re.push(1);
691
+ }), N = Date.now(), fi = U.loc.end.line - U.loc.start.line + 1, rt = new u(t), me = new S(), ge = [], lt = new u(t), de = new u(t), st = new u(t), nt = new u(t), at = new u(t), ot = new u(t), ut = new u(t), ye = new u(t), ct = new u(t), we = new u(t), ke = new u(t), ft = new u(t), ne = new u(t), pt = new u(t), be = new S(), ht = new u(t), xe = 0, Ce = 0, ve = new S(), Se = new S(), ze = new S(), mt = new u(t), gt = new u(t), dt = new u(t), qe = new S(), yt = new u(t), Ae = new u(t), wt = /* @__PURE__ */ new Set(), Pe = new u(t), j, B, kt = new S(), bt = new S(), xt = new S(), Ct = new u(t), ae = new S(), vt = new u(t), St = [], Le = new u(t), Oe = new u(t), zt = new u(t), qt = new u(t), Re = new S(), At = new u(t), Pt = /* @__PURE__ */ new Set(), ee = 0, Lt = new S(), oe = 0, De = 0, Fe = new u(t), Ee = new S(), Ot = new u(t), te = new u(t), _e = new u(t), Me = new u(t), ue = new u(t), ie = new S(), Ie = new S(), Rt = new u(t), Te = new u(t), Dt = new u(t), Ft = new u(t), Et = new u(t), Ue = new u(t), Ve = new u(t), He = new u(t), ce = new u(t), fe = new u(t), Y = new $e(t), G = new u(t), Ke = new $e(t), _t = new u(t), re = new u(t), Mt = new $e(t), It = new u(t), D = 0;
692
+ C(U, {
693
+ enter(l) {
694
+ var le, Yt, Gt;
695
+ switch (l.type) {
696
+ case Ge: {
697
+ rt.p(l.name, l.loc), be.push(D), ht.p(D, l.loc);
698
+ let s = l.name;
699
+ if (s === "font-face") {
700
+ let a = /* @__PURE__ */ Object.create(null);
701
+ t && lt.p(l.loc.start.offset, l.loc), (le = l.block) == null || le.children.forEach((c) => {
702
+ c.type === "Declaration" && (a[c.property] = n(c.value));
703
+ }), ge.push(a), me.push(1);
732
704
  break;
733
705
  }
734
- let l = 1;
735
- if (i.prelude !== null) {
736
- let g = i.prelude, c = g && a(i.prelude), f = g.loc;
737
- if (p === "media")
738
- Ze.p(c, f), ui(g) && (Je.p(c, f), l++);
739
- else if (p === "supports")
740
- ne.p(c, f), oi(g) && (et.p(c, f), l++);
741
- else if (O("keyframes", p)) {
742
- let u = "@" + p + " " + c;
743
- E(p) && (oe.p(u, f), l++), ae.p(u, f);
744
- } else if (p === "import")
745
- v(i, function(u) {
746
- if (u.type === "Condition" && u.kind === "supports") {
747
- let h = a(u);
748
- return ne.p(h, u.loc), this.break;
706
+ let g = 1;
707
+ if (l.prelude !== null) {
708
+ let a = l.prelude, c = a && n(l.prelude), p = a.loc;
709
+ if (s === "media")
710
+ nt.p(c, p), Si(a) && (at.p(c, p), g++);
711
+ else if (s === "supports")
712
+ ye.p(c, p), vi(a) && (ct.p(c, p), g++);
713
+ else if (E("keyframes", s)) {
714
+ let d = "@" + s + " " + c;
715
+ W(s) && (ke.p(d, p), g++), we.p(d, p);
716
+ } else if (s === "import")
717
+ C(l, (d) => {
718
+ if (d.type === "Condition" && d.kind === "supports") {
719
+ let f = n(d);
720
+ return ye.p(f, d.loc), C.break;
749
721
  }
750
- }), Qe.p(c, f);
751
- else if (p === "charset")
752
- $e.p(c, f);
753
- else if (p === "container") {
754
- if (tt.p(c, f), ((Y = g.children.first) == null ? void 0 : Y.type) === "Identifier") {
755
- let u = g.children.first.name;
756
- Q.p(u, f);
722
+ }), st.p(c, p);
723
+ else if (s === "charset")
724
+ ut.p(c, p);
725
+ else if (s === "container") {
726
+ if (ft.p(c, p), a.type === "AtrulePrelude" && ((Yt = a.children.first) == null ? void 0 : Yt.type) === "Identifier") {
727
+ let d = a.children.first.name;
728
+ ne.p(d, p);
757
729
  }
758
- } else p === "property" && it.p(c, f);
730
+ } else s === "property" && pt.p(c, p);
759
731
  } else
760
- p === "layer" && (le.p("<anonymous>", i.loc), l++);
761
- re.push(l);
732
+ s === "layer" && (de.p("<anonymous>", l.loc), g++);
733
+ me.push(g);
762
734
  break;
763
735
  }
736
+ // @ts-expect-error Oudated css-tree types
764
737
  case "Layer": {
765
- i.name !== null && le.p(i.name, i.loc);
738
+ l.name !== null && de.p(l.name, l.loc);
766
739
  break;
767
740
  }
741
+ // @ts-expect-error Oudated css-tree types
768
742
  case "Feature": {
769
- Xe.p(i.name, i.loc);
743
+ ot.p(l.name, l.loc);
770
744
  break;
771
745
  }
772
- case Me: {
773
- let p = i.prelude, l = i.block, g = p.children, c = l.children, f = g ? g.size : 0, u = c ? c.size : 0;
774
- pe.push(f + u), st.p(f + u, i.loc), he.push(f), lt.p(f, p.loc), me.push(u), nt.p(u, l.loc), ge.push(L), at.p(L, i.loc), ce++, u === 0 && fe++;
746
+ case Qe: {
747
+ let s = l.prelude, g = l.block, a = s.children, c = g.children, p = a ? a.size : 0, d = c ? c.size : 0;
748
+ ve.push(p + d), mt.p(p + d, l.loc), Se.push(p), gt.p(p, s.loc), ze.push(d), dt.p(d, g.loc), qe.push(D), yt.p(D, l.loc), xe++, d === 0 && Ce++;
775
749
  break;
776
750
  }
777
- case Ke: {
778
- let p = a(i);
779
- if (this.atrule && O("keyframes", this.atrule.name))
780
- return de.p(p, i.loc), this.skip;
781
- Zt(i) && ke.p(p, i.loc);
782
- let l = fi(i);
783
- if (l !== !1)
784
- for (let x of l)
785
- gt.p(x, i.loc);
786
- let g = Jt(i);
787
- ci(i) && ye.p(p, i.loc), ot.add(p), Z.push(g), ht.p(g, i.loc), be.push(L - 1), yt.p(L - 1, i.loc);
788
- let c = ti(i).toArray(), [f, u, h] = c;
789
- return pt.p(c.toString(), i.loc), ut.push(f), ct.push(u), ft.push(h), M === void 0 && (M = c), I === void 0 && (I = c), I !== void 0 && Kt(I, c) < 0 && (I = c), M !== void 0 && Kt(M, c) > 0 && (M = c), mt.push(c), f > 0 && we.p(p, i.loc), pi(i, function(q) {
790
- dt.p(q.name, q.loc);
751
+ case yi: {
752
+ let s = n(l);
753
+ if (this.atrule && E("keyframes", this.atrule.name))
754
+ return Ae.p(s, l.loc), this.skip;
755
+ oi(l) && Oe.p(s, l.loc);
756
+ let g = qi(l);
757
+ if (g !== !1)
758
+ for (let v of g)
759
+ zt.p(v, l.loc);
760
+ let a = ui(l);
761
+ zi(l) && Pe.p(s, l.loc), wt.add(s), ae.push(a), vt.p(a, l.loc), Re.push(D - 1), At.p(D - 1, l.loc);
762
+ let c = gi(l).toArray(), [p, d, f] = c;
763
+ return Ct.p(c.toString(), l.loc), kt.push(p), bt.push(d), xt.push(f), j === void 0 && (j = c), B === void 0 && (B = c), B !== void 0 && ri(B, c) < 0 && (B = c), j !== void 0 && ri(j, c) > 0 && (j = c), St.push(c), p > 0 && Le.p(s, l.loc), Ai(l, function(P) {
764
+ qt.p(P.name, P.loc);
791
765
  }), this.skip;
792
766
  }
793
- case Ne: {
767
+ case et: {
794
768
  if (!this.declaration)
795
769
  break;
796
- let p = i.unit;
797
- return O("\\9", p) ? Oe.push(p.substring(0, p.length - 2), this.declaration.property, i.loc) : Oe.push(p, this.declaration.property, i.loc), this.skip;
770
+ let s = l.unit;
771
+ return E("\\9", s) ? Ke.push(s.substring(0, s.length - 2), this.declaration.property, l.loc) : Ke.push(s, this.declaration.property, l.loc), this.skip;
798
772
  }
799
- case ai: {
800
- if (We("data:", i.value)) {
801
- let p = i.value, l = p.length, g = Ai(p);
802
- k.total++, _ += l;
773
+ case Ci: {
774
+ if (Xe("data:", l.value)) {
775
+ let s = l.value, g = s.length, a = Wi(s);
776
+ x.total++, A += g;
803
777
  let c = {
804
- /** @type {number} */
805
- line: i.loc.start.line,
806
- /** @type {number} */
807
- column: i.loc.start.column,
808
- /** @type {number} */
809
- offset: i.loc.start.offset,
810
- /** @type {number} */
811
- length: i.loc.end.offset - i.loc.start.offset
778
+ line: l.loc.start.line,
779
+ column: l.loc.start.column,
780
+ offset: l.loc.start.offset,
781
+ length: l.loc.end.offset - l.loc.start.offset
812
782
  };
813
- if (k.unique.has(g)) {
814
- let f = k.unique.get(g);
815
- f.count++, f.size += l, k.unique.set(g, f), e && f.uniqueWithLocations.push(c);
783
+ if (x.unique.has(a)) {
784
+ let p = x.unique.get(a);
785
+ p.count++, p.size += g, x.unique.set(a, p), t && p.uniqueWithLocations.push(c);
816
786
  } else {
817
- let f = {
787
+ let p = {
818
788
  count: 1,
819
- size: l
789
+ size: g,
790
+ uniqueWithLocations: t ? [c] : void 0
820
791
  };
821
- e && (f.uniqueWithLocations = [c]), k.unique.set(g, f);
792
+ x.unique.set(a, p);
822
793
  }
823
794
  }
824
795
  break;
825
796
  }
826
- case ri: {
827
- if (te(i)) {
828
- qe.push(1), B.p(a(i), i.loc);
797
+ case wi: {
798
+ let s = l.loc;
799
+ if (pe(l)) {
800
+ Ie.push(1), re.p(n(l), s);
829
801
  break;
830
802
  }
831
- let p = this.declaration, { property: l, important: g } = p, c = 1;
832
- Xt(i) && (xt.p(a(i), i.loc), c++), typeof g == "string" && (ve.p(y(i) + "!" + g, i.loc), c++), Pi(i) && (ve.p(a(i), i.loc), c++);
833
- let f = i.children, u = i.loc;
834
- if (qe.push(c), m("margin", l) || m("margin-block", l) || m("margin-inline", l) || m("margin-top", l) || m("margin-right", l) || m("margin-bottom", l) || m("margin-left", l) || m("padding", l) || m("padding-block", l) || m("padding-inline", l) || m("padding-top", l) || m("padding-right", l) || m("padding-bottom", l) || m("padding-left", l))
835
- yi(i) && vt.p(l, p.loc);
803
+ let g = this.declaration, { property: a, important: c } = g, p = 1;
804
+ ci(l) && (Rt.p(n(l), s), p++), typeof c == "string" && (Te.p(y(l) + "!" + c, s), p++), Ni(l) && (Te.p(n(l), s), p++);
805
+ let d = l.children;
806
+ if (Ie.push(p), m("margin", a) || m("margin-block", a) || m("margin-inline", a) || m("margin-top", a) || m("margin-right", a) || m("margin-bottom", a) || m("margin-left", a) || m("padding", a) || m("padding-block", a) || m("padding-inline", a) || m("padding-top", a) || m("padding-right", a) || m("padding-bottom", a) || m("padding-left", a))
807
+ Di(l) && It.p(a, g.loc);
836
808
  else {
837
- if (m("z-index", l))
838
- return Ct.p(a(i), u), this.skip;
839
- if (m("font", l)) {
840
- if (Ie(i)) return;
841
- let h = xi(i, a, function(It) {
842
- It.type === "keyword" && B.p(It.value, u);
809
+ if (m("z-index", a))
810
+ return Dt.p(n(l), s), this.skip;
811
+ if (m("font", a)) {
812
+ if (Ze(l)) return;
813
+ let f = Mi(l, n, function(Qt) {
814
+ Qt.type === "keyword" && re.p(Qt.value, s);
843
815
  });
844
- if (!h)
816
+ if (!f)
845
817
  return this.skip;
846
- let { font_size: x, line_height: q, font_family: F } = h;
847
- F && Ae.p(F, u), x && Pe.p(x, u), q && Le.p(q, u);
818
+ let { font_size: v, line_height: P, font_family: V } = f;
819
+ V && Ue.p(V, s), v && Ve.p(v, s), P && He.p(P, s);
848
820
  break;
849
- } else if (m("font-size", l)) {
850
- Ie(i) || Pe.p(a(i), u);
821
+ } else if (m("font-size", a)) {
822
+ Ze(l) || Ve.p(n(l), s);
851
823
  break;
852
- } else if (m("font-family", l)) {
853
- Ie(i) || Ae.p(a(i), u);
824
+ } else if (m("font-family", a)) {
825
+ Ze(l) || Ue.p(n(l), s);
854
826
  break;
855
- } else if (m("line-height", l))
856
- Le.p(a(i), u);
857
- else if (m("transition", l) || m("animation", l)) {
858
- Si(f, function(h) {
859
- h.type === "fn" ? $.p(a(h.value), u) : h.type === "duration" ? ee.p(a(h.value), u) : h.type === "keyword" && B.p(a(h.value), u);
827
+ } else if (m("line-height", a))
828
+ He.p(n(l), s);
829
+ else if (m("transition", a) || m("animation", a)) {
830
+ Ui(d, function(f) {
831
+ f.type === "fn" ? ce.p(n(f.value), s) : f.type === "duration" ? fe.p(n(f.value), s) : f.type === "keyword" && re.p(n(f.value), s);
860
832
  });
861
833
  break;
862
- } else if (m("animation-duration", l) || m("transition-duration", l)) {
863
- f && f.size > 1 ? f.forEach((h) => {
864
- h.type !== W && ee.p(a(h), u);
865
- }) : ee.p(a(i), u);
834
+ } else if (m("animation-duration", a) || m("transition-duration", a)) {
835
+ d && d.size > 1 ? d.forEach((f) => {
836
+ f.type !== Z && fe.p(n(f), s);
837
+ }) : fe.p(n(l), s);
866
838
  break;
867
- } else if (m("transition-timing-function", l) || m("animation-timing-function", l)) {
868
- f && f.size > 1 ? f.forEach((h) => {
869
- h.type !== W && $.p(a(h), u);
870
- }) : $.p(a(i), u);
839
+ } else if (m("transition-timing-function", a) || m("animation-timing-function", a)) {
840
+ d && d.size > 1 ? d.forEach((f) => {
841
+ f.type !== Z && ce.p(n(f), s);
842
+ }) : ce.p(n(l), s);
871
843
  break;
872
- } else if (m("container-name", l))
873
- Q.p(a(i), u);
874
- else if (m("container", l))
875
- ((Mt = f.first) == null ? void 0 : Mt.type) === "Identifier" && Q.p(f.first.name, u);
876
- else if (Li.has(vi(l))) {
877
- te(i) || qt.push(a(i), l, u);
844
+ } else if (m("container-name", a))
845
+ ne.p(n(l), s);
846
+ else if (m("container", a))
847
+ ((Gt = d.first) == null ? void 0 : Gt.type) === "Identifier" && ne.p(d.first.name, s);
848
+ else if (ji.has(Ki(a))) {
849
+ pe(l) || Mt.push(n(l), a, s);
878
850
  break;
879
- } else m("text-shadow", l) ? te(i) || zt.p(a(i), u) : m("box-shadow", l) && (te(i) || St.p(a(i), u));
851
+ } else m("text-shadow", a) ? pe(l) || Ft.p(n(l), s) : m("box-shadow", a) && (pe(l) || Et.p(n(l), s));
880
852
  }
881
- v(i, function(h) {
882
- let x = h.name;
883
- switch (h.type) {
884
- case ni: {
885
- let q = h.value.length;
886
- return O("\\9", h.value) && (q = q - 2), U.push("#" + h.value, l, u), V.p("hex" + q, u), this.skip;
853
+ C(l, function(f) {
854
+ let v = f.name;
855
+ switch (f.type) {
856
+ case xi: {
857
+ let P = f.value.length;
858
+ return E("\\9", f.value) && (P = P - 2), Y.push("#" + f.value, a, s), G.p("hex" + P, s), C.skip;
887
859
  }
888
- case R: {
889
- ie.has(x) && B.p(x, u);
890
- let q = x.length;
891
- if (q > 20 || q < 3)
892
- return this.skip;
893
- if (di.has(x)) {
894
- let F = a(h);
895
- U.push(F, l, u), V.p(x.toLowerCase(), u);
860
+ case T: {
861
+ he.has(v) && re.p(v, s);
862
+ let P = v.length;
863
+ if (P > 20 || P < 3)
864
+ return C.skip;
865
+ if (Ri.has(v)) {
866
+ let V = n(f);
867
+ Y.push(V, a, s), G.p(v.toLowerCase(), s);
896
868
  return;
897
869
  }
898
- if (hi.has(x)) {
899
- let F = a(h);
900
- U.push(F, l, u), V.p("named", u);
870
+ if (Pi.has(v)) {
871
+ let V = n(f);
872
+ Y.push(V, a, s), G.p("named", s);
901
873
  return;
902
874
  }
903
- if (mi.has(x)) {
904
- let F = a(h);
905
- U.push(F, l, u), V.p("system", u);
875
+ if (Li.has(v)) {
876
+ let V = n(f);
877
+ Y.push(V, a, s), G.p("system", s);
906
878
  return;
907
879
  }
908
- return this.skip;
880
+ return C.skip;
909
881
  }
910
- case je: {
911
- if (S("var", x))
912
- return this.skip;
913
- if (gi.has(x)) {
914
- U.push(a(h), l, h.loc), V.p(x.toLowerCase(), h.loc);
882
+ case tt: {
883
+ if (q("var", v))
884
+ return C.skip;
885
+ if (Oi.has(v)) {
886
+ Y.push(n(f), a, f.loc), G.p(v.toLowerCase(), f.loc);
915
887
  return;
916
888
  }
917
- if (O("gradient", x)) {
918
- _t.p(a(h), h.loc);
889
+ if (E("gradient", v)) {
890
+ _t.p(n(f), f.loc);
919
891
  return;
920
892
  }
921
893
  }
@@ -923,299 +895,263 @@ function Ei(r, t = {}) {
923
895
  });
924
896
  break;
925
897
  }
926
- case Ve: {
898
+ case "Declaration": {
927
899
  if (this.atrulePrelude !== null)
928
900
  return this.skip;
929
- K++;
930
- let p = 1;
931
- wt.add(a(i)), ze.push(L - 1), bt.p(L - 1, i.loc), i.important === !0 && (J++, p++, this.atrule && O("keyframes", this.atrule.name) && (xe++, p++)), kt.push(p);
932
- let { property: l, loc: { start: g } } = i, c = {
901
+ ee++;
902
+ let s = 1;
903
+ Pt.add(n(l)), Ee.push(D - 1), Ot.p(D - 1, l.loc), l.important === !0 && (oe++, s++, this.atrule && E("keyframes", this.atrule.name) && (De++, s++)), Lt.push(s);
904
+ let {
905
+ property: g,
906
+ // @ts-expect-error TODO: fix this
907
+ loc: { start: a }
908
+ } = l, c = {
933
909
  start: {
934
- line: g.line,
935
- column: g.column,
936
- offset: g.offset
910
+ line: a.line,
911
+ column: a.column,
912
+ offset: a.offset
937
913
  },
938
914
  end: {
939
- offset: g.offset + l.length
915
+ offset: a.offset + g.length
940
916
  }
941
917
  };
942
- N.p(l, c), E(l) ? (_e.p(l, c), j.push(2)) : qi(l) ? (Se.p(l, c), j.push(2)) : Be(l) ? (X.p(l, c), j.push(i.important ? 3 : 2), i.important === !0 && Ce.p(l, c)) : j.push(1);
918
+ te.p(g, c), W(g) ? (Me.p(g, c), ie.push(2)) : Hi(g) ? (_e.p(g, c), ie.push(2)) : it(g) ? (ue.p(g, c), ie.push(l.important ? 3 : 2), l.important === !0 && Fe.p(g, c)) : ie.push(1);
943
919
  break;
944
920
  }
945
921
  }
946
- (i.type === Me || i.type === Te) && L++;
922
+ (l.type === Qe || l.type === Ge) && D++;
947
923
  },
948
- leave(i) {
949
- (i.type === Me || i.type === Te) && L--;
924
+ leave(l) {
925
+ (l.type === Qe || l.type === Ge) && D--;
950
926
  }
951
927
  });
952
- let At = wt.size, H = Z.size(), Re = ut.aggregate(), De = ct.aggregate(), Fe = ft.aggregate(), Pt = ot.size, d = Object.assign, Lt = r.length, Ee = se.length, Ot = re.aggregate(), Rt = Z.aggregate(), Dt = kt.aggregate(), Ft = j.aggregate(), Et = qe.aggregate(), Tt = Ye.c();
928
+ let Tt = Pt.size, Q = ae.size(), We = kt.aggregate(), Ne = bt.aggregate(), je = xt.aggregate(), Ut = wt.size, w = Object.assign, Vt = i.length, Be = ge.length, Ht = me.aggregate(), Kt = ae.aggregate(), Wt = Lt.aggregate(), Nt = ie.aggregate(), jt = Ie.aggregate(), Bt = rt.c();
953
929
  return {
954
930
  stylesheet: {
955
- sourceLinesOfCode: Tt.total + H + K + de.size(),
956
- linesOfCode: $t,
957
- size: Lt,
958
- complexity: Ot.sum + Rt.sum + Dt.sum + Ft.sum + Et.sum,
931
+ sourceLinesOfCode: Bt.total + Q + ee + Ae.size(),
932
+ linesOfCode: fi,
933
+ size: Vt,
934
+ complexity: Ht.sum + Kt.sum + Wt.sum + Nt.sum + jt.sum,
959
935
  comments: {
960
- total: b,
961
- size: w
936
+ total: k,
937
+ size: b
962
938
  },
963
939
  embeddedContent: {
964
940
  size: {
965
- total: _,
966
- ratio: z(_, Lt)
941
+ total: A,
942
+ ratio: z(A, Vt)
967
943
  },
968
944
  types: {
969
- total: k.total,
970
- totalUnique: k.unique.size,
971
- uniquenessRatio: z(k.unique.size, k.total),
972
- unique: Object.fromEntries(k.unique)
945
+ total: x.total,
946
+ totalUnique: x.unique.size,
947
+ uniquenessRatio: z(x.unique.size, x.total),
948
+ unique: Object.fromEntries(x.unique)
973
949
  }
974
950
  }
975
951
  },
976
- atrules: d(
977
- Tt,
978
- {
979
- fontface: d({
980
- total: Ee,
981
- totalUnique: Ee,
982
- unique: se,
983
- uniquenessRatio: Ee === 0 ? 0 : 1
984
- }, e ? {
985
- uniqueWithLocations: Ge.c().uniqueWithLocations
986
- } : {}),
987
- import: Qe.c(),
988
- media: d(
989
- Ze.c(),
990
- {
991
- browserhacks: Je.c(),
992
- features: Xe.c()
993
- }
994
- ),
995
- charset: $e.c(),
996
- supports: d(
997
- ne.c(),
998
- {
999
- browserhacks: et.c()
1000
- }
1001
- ),
1002
- keyframes: d(
1003
- ae.c(),
1004
- {
1005
- prefixed: d(
1006
- oe.c(),
1007
- {
1008
- ratio: z(oe.size(), ae.size())
1009
- }
1010
- )
1011
- }
1012
- ),
1013
- container: d(
1014
- tt.c(),
1015
- {
1016
- names: Q.c()
1017
- }
1018
- ),
1019
- layer: le.c(),
1020
- property: it.c(),
1021
- complexity: Ot,
1022
- nesting: d(
1023
- ue.aggregate(),
1024
- {
1025
- items: ue.toArray()
1026
- },
1027
- rt.c()
1028
- )
1029
- }
1030
- ),
952
+ atrules: w(Bt, {
953
+ fontface: w(
954
+ {
955
+ total: Be,
956
+ totalUnique: Be,
957
+ unique: ge,
958
+ uniquenessRatio: Be === 0 ? 0 : 1
959
+ },
960
+ t ? {
961
+ uniqueWithLocations: lt.c().uniqueWithLocations
962
+ } : {}
963
+ ),
964
+ import: st.c(),
965
+ media: w(nt.c(), {
966
+ browserhacks: at.c(),
967
+ features: ot.c()
968
+ }),
969
+ charset: ut.c(),
970
+ supports: w(ye.c(), {
971
+ browserhacks: ct.c()
972
+ }),
973
+ keyframes: w(we.c(), {
974
+ prefixed: w(ke.c(), {
975
+ ratio: z(ke.size(), we.size())
976
+ })
977
+ }),
978
+ container: w(ft.c(), {
979
+ names: ne.c()
980
+ }),
981
+ layer: de.c(),
982
+ property: pt.c(),
983
+ complexity: Ht,
984
+ nesting: w(
985
+ be.aggregate(),
986
+ {
987
+ items: be.toArray()
988
+ },
989
+ ht.c()
990
+ )
991
+ }),
1031
992
  rules: {
1032
- total: ce,
993
+ total: xe,
1033
994
  empty: {
1034
- total: fe,
1035
- ratio: z(fe, ce)
995
+ total: Ce,
996
+ ratio: z(Ce, xe)
1036
997
  },
1037
- sizes: d(
1038
- pe.aggregate(),
998
+ sizes: w(
999
+ ve.aggregate(),
1039
1000
  {
1040
- items: pe.toArray()
1001
+ items: ve.toArray()
1041
1002
  },
1042
- st.c()
1003
+ mt.c()
1043
1004
  ),
1044
- nesting: d(
1045
- ge.aggregate(),
1005
+ nesting: w(
1006
+ qe.aggregate(),
1046
1007
  {
1047
- items: ge.toArray()
1008
+ items: qe.toArray()
1048
1009
  },
1049
- at.c()
1010
+ yt.c()
1050
1011
  ),
1051
- selectors: d(
1052
- he.aggregate(),
1012
+ selectors: w(
1013
+ Se.aggregate(),
1053
1014
  {
1054
- items: he.toArray()
1015
+ items: Se.toArray()
1055
1016
  },
1056
- lt.c()
1017
+ gt.c()
1057
1018
  ),
1058
- declarations: d(
1059
- me.aggregate(),
1019
+ declarations: w(
1020
+ ze.aggregate(),
1060
1021
  {
1061
- items: me.toArray()
1022
+ items: ze.toArray()
1062
1023
  },
1063
- nt.c()
1024
+ dt.c()
1064
1025
  )
1065
1026
  },
1066
1027
  selectors: {
1067
- total: H,
1068
- totalUnique: Pt,
1069
- uniquenessRatio: z(Pt, H),
1070
- specificity: d(
1028
+ total: Q,
1029
+ totalUnique: Ut,
1030
+ uniquenessRatio: z(Ut, Q),
1031
+ specificity: w(
1071
1032
  {
1072
1033
  /** @type Specificity */
1073
- min: I === void 0 ? [0, 0, 0] : I,
1034
+ min: B === void 0 ? [0, 0, 0] : B,
1074
1035
  /** @type Specificity */
1075
- max: M === void 0 ? [0, 0, 0] : M,
1036
+ max: j === void 0 ? [0, 0, 0] : j,
1076
1037
  /** @type Specificity */
1077
- sum: [Re.sum, De.sum, Fe.sum],
1038
+ sum: [We.sum, Ne.sum, je.sum],
1078
1039
  /** @type Specificity */
1079
- mean: [Re.mean, De.mean, Fe.mean],
1040
+ mean: [We.mean, Ne.mean, je.mean],
1080
1041
  /** @type Specificity */
1081
- mode: [Re.mode, De.mode, Fe.mode],
1042
+ mode: [We.mode, Ne.mode, je.mode],
1082
1043
  /** @type Specificity */
1083
- items: mt
1044
+ items: St
1084
1045
  },
1085
- pt.c()
1046
+ Ct.c()
1086
1047
  ),
1087
- complexity: d(
1088
- Rt,
1089
- ht.c(),
1048
+ complexity: w(Kt, vt.c(), {
1049
+ items: ae.toArray()
1050
+ }),
1051
+ nesting: w(
1052
+ Re.aggregate(),
1090
1053
  {
1091
- items: Z.toArray()
1092
- }
1093
- ),
1094
- nesting: d(
1095
- be.aggregate(),
1096
- {
1097
- items: be.toArray()
1054
+ items: Re.toArray()
1098
1055
  },
1099
- yt.c()
1100
- ),
1101
- id: d(
1102
- we.c(),
1103
- {
1104
- ratio: z(we.size(), H)
1105
- }
1106
- ),
1107
- pseudoClasses: gt.c(),
1108
- accessibility: d(
1109
- ke.c(),
1110
- {
1111
- ratio: z(ke.size(), H)
1112
- }
1056
+ At.c()
1113
1057
  ),
1114
- keyframes: de.c(),
1115
- prefixed: d(
1116
- ye.c(),
1117
- {
1118
- ratio: z(ye.size(), H)
1119
- }
1120
- ),
1121
- combinators: dt.c()
1058
+ id: w(Le.c(), {
1059
+ ratio: z(Le.size(), Q)
1060
+ }),
1061
+ pseudoClasses: zt.c(),
1062
+ accessibility: w(Oe.c(), {
1063
+ ratio: z(Oe.size(), Q)
1064
+ }),
1065
+ keyframes: Ae.c(),
1066
+ prefixed: w(Pe.c(), {
1067
+ ratio: z(Pe.size(), Q)
1068
+ }),
1069
+ combinators: qt.c()
1122
1070
  },
1123
1071
  declarations: {
1124
- total: K,
1125
- totalUnique: At,
1126
- uniquenessRatio: z(At, K),
1072
+ total: ee,
1073
+ totalUnique: Tt,
1074
+ uniquenessRatio: z(Tt, ee),
1127
1075
  importants: {
1128
- total: J,
1129
- ratio: z(J, K),
1076
+ total: oe,
1077
+ ratio: z(oe, ee),
1130
1078
  inKeyframes: {
1131
- total: xe,
1132
- ratio: z(xe, J)
1079
+ total: De,
1080
+ ratio: z(De, oe)
1133
1081
  }
1134
1082
  },
1135
- complexity: Dt,
1136
- nesting: d(
1137
- ze.aggregate(),
1083
+ complexity: Wt,
1084
+ nesting: w(
1085
+ Ee.aggregate(),
1138
1086
  {
1139
- items: ze.toArray()
1087
+ items: Ee.toArray()
1140
1088
  },
1141
- bt.c()
1089
+ Ot.c()
1142
1090
  )
1143
1091
  },
1144
- properties: d(
1145
- N.c(),
1146
- {
1147
- prefixed: d(
1148
- _e.c(),
1149
- {
1150
- ratio: z(_e.size(), N.size())
1151
- }
1152
- ),
1153
- custom: d(
1154
- X.c(),
1155
- {
1156
- ratio: z(X.size(), N.size()),
1157
- importants: d(
1158
- Ce.c(),
1159
- {
1160
- ratio: z(Ce.size(), X.size())
1161
- }
1162
- )
1163
- }
1164
- ),
1165
- browserhacks: d(
1166
- Se.c(),
1167
- {
1168
- ratio: z(Se.size(), N.size())
1169
- }
1170
- ),
1171
- complexity: Ft
1172
- }
1173
- ),
1092
+ properties: w(te.c(), {
1093
+ prefixed: w(Me.c(), {
1094
+ ratio: z(Me.size(), te.size())
1095
+ }),
1096
+ custom: w(ue.c(), {
1097
+ ratio: z(ue.size(), te.size()),
1098
+ importants: w(Fe.c(), {
1099
+ ratio: z(Fe.size(), ue.size())
1100
+ })
1101
+ }),
1102
+ browserhacks: w(_e.c(), {
1103
+ ratio: z(_e.size(), te.size())
1104
+ }),
1105
+ complexity: Nt
1106
+ }),
1174
1107
  values: {
1175
- colors: d(
1176
- U.count(),
1177
- {
1178
- formats: V.c()
1179
- }
1180
- ),
1108
+ colors: w(Y.count(), {
1109
+ formats: G.c()
1110
+ }),
1181
1111
  gradients: _t.c(),
1182
- fontFamilies: Ae.c(),
1183
- fontSizes: Pe.c(),
1184
- lineHeights: Le.c(),
1185
- zindexes: Ct.c(),
1186
- textShadows: zt.c(),
1187
- boxShadows: St.c(),
1188
- borderRadiuses: qt.count(),
1112
+ fontFamilies: Ue.c(),
1113
+ fontSizes: Ve.c(),
1114
+ lineHeights: He.c(),
1115
+ zindexes: Dt.c(),
1116
+ textShadows: Ft.c(),
1117
+ boxShadows: Et.c(),
1118
+ borderRadiuses: Mt.count(),
1189
1119
  animations: {
1190
- durations: ee.c(),
1191
- timingFunctions: $.c()
1120
+ durations: fe.c(),
1121
+ timingFunctions: ce.c()
1192
1122
  },
1193
- prefixes: xt.c(),
1194
- browserhacks: ve.c(),
1195
- units: Oe.count(),
1196
- complexity: Et,
1197
- keywords: B.c(),
1198
- resets: vt.c()
1123
+ prefixes: Rt.c(),
1124
+ browserhacks: Te.c(),
1125
+ units: Ke.count(),
1126
+ complexity: jt,
1127
+ keywords: re.c(),
1128
+ resets: It.c()
1199
1129
  },
1200
1130
  __meta__: {
1201
- parseTime: T - P,
1202
- analyzeTime: Date.now() - T,
1203
- total: Date.now() - n
1131
+ parseTime: N - R,
1132
+ analyzeTime: Date.now() - N,
1133
+ total: Date.now() - o
1204
1134
  }
1205
1135
  };
1206
1136
  }
1207
- function Kt(r, t) {
1208
- return r[0] === t[0] ? r[1] === t[1] ? t[2] - r[2] : t[1] - r[1] : t[0] - r[0];
1137
+ function ri(i, e) {
1138
+ return i[0] === e[0] ? i[1] === e[1] ? e[2] - i[2] : e[1] - i[1] : e[0] - i[0];
1209
1139
  }
1210
1140
  export {
1211
- Ei as analyze,
1212
- Kt as compareSpecificity,
1213
- E as hasVendorPrefix,
1214
- Zt as isAccessibilitySelector,
1215
- ui as isMediaBrowserhack,
1216
- qi as isPropertyHack,
1217
- ci as isSelectorPrefixed,
1218
- oi as isSupportsBrowserhack,
1219
- Xt as isValuePrefixed,
1220
- Jt as selectorComplexity
1141
+ O as KeywordSet,
1142
+ Ji as analyze,
1143
+ Oi as colorFunctions,
1144
+ Ri as colorKeywords,
1145
+ ri as compareSpecificity,
1146
+ he as cssKeywords,
1147
+ W as hasVendorPrefix,
1148
+ oi as isAccessibilitySelector,
1149
+ Si as isMediaBrowserhack,
1150
+ Hi as isPropertyHack,
1151
+ zi as isSelectorPrefixed,
1152
+ vi as isSupportsBrowserhack,
1153
+ ci as isValuePrefixed,
1154
+ Pi as namedColors,
1155
+ ui as selectorComplexity,
1156
+ Li as systemColors
1221
1157
  };