@projectwallace/css-analyzer 7.6.0 → 7.6.2

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