@projectwallace/css-analyzer 6.0.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1131 @@
1
+ import Dt from "css-tree/parser";
2
+ import A from "css-tree/walker";
3
+ import { calculateForAST as Ft } from "@bramus/specificity/core";
4
+ function Re(i, t) {
5
+ return t >= 65 && t <= 90 && (t = t | 32), i === t;
6
+ }
7
+ function z(i, t) {
8
+ if (i === t) return !0;
9
+ let r = i.length;
10
+ if (r !== t.length) return !1;
11
+ for (let e = 0; e < r; e++)
12
+ if (Re(i.charCodeAt(e), t.charCodeAt(e)) === !1)
13
+ return !1;
14
+ return !0;
15
+ }
16
+ function L(i, t) {
17
+ if (i === t) return !0;
18
+ let r = t.length, e = r - i.length;
19
+ if (e < 0)
20
+ return !1;
21
+ for (let n = r - 1; n >= e; n--)
22
+ if (Re(i.charCodeAt(n - e), t.charCodeAt(n)) === !1)
23
+ return !1;
24
+ return !0;
25
+ }
26
+ function Ee(i, t) {
27
+ if (i === t) return !0;
28
+ let r = i.length;
29
+ if (t.length < r) return !1;
30
+ for (let e = 0; e < r; e++)
31
+ if (Re(i.charCodeAt(e), t.charCodeAt(e)) === !1)
32
+ return !1;
33
+ return !0;
34
+ }
35
+ const Mt = "Atrule", Ut = "MediaQuery", Tt = "MediaFeature", It = "Rule", De = "Selector", zt = "TypeSelector", Y = "PseudoClassSelector", St = "AttributeSelector", vt = "PseudoElementSelector", Oe = "Declaration", Ht = "Value", P = "Identifier", Vt = "Nth", Wt = "Combinator", Kt = "Number", qt = "Dimension", H = "Operator", jt = "Hash", Bt = "Url", Fe = "Function";
36
+ function kt(i, t, r) {
37
+ let e = i.value.children.first;
38
+ return z(t, i.property) && e.type === P && z(r, e.name);
39
+ }
40
+ function Yt(i) {
41
+ let t = !1;
42
+ return A(i, function(r) {
43
+ if (r.type === Oe && (kt(r, "-webkit-appearance", "none") || kt(r, "-moz-appearance", "meterbar")))
44
+ return t = !0, this.break;
45
+ }), t;
46
+ }
47
+ function Gt(i) {
48
+ let t = !1;
49
+ return A(i, function(r) {
50
+ let e = r.children, n = r.name, l = r.value;
51
+ if (r.type === Ut && e.size === 1 && e.first.type === P) {
52
+ let d = e.first.name;
53
+ if (Ee("\\0", d) || L("\\9 ", d))
54
+ return t = !0, this.break;
55
+ } else if (r.type === Tt) {
56
+ if (l && l.unit && l.unit === "\\0")
57
+ return t = !0, this.break;
58
+ if (z("-moz-images-in-menus", n) || z("min--moz-device-pixel-ratio", n) || z("-ms-high-contrast", n))
59
+ return t = !0, this.break;
60
+ if (z("min-resolution", n) && l && z(".001", l.value) && z("dpcm", l.unit))
61
+ return t = !0, this.break;
62
+ if (z("-webkit-min-device-pixel-ratio", n) && l && l.value && (z("0", l.value) || z("10000", l.value)))
63
+ return t = !0, this.break;
64
+ }
65
+ }), t;
66
+ }
67
+ const xt = 45;
68
+ function R(i) {
69
+ return i.charCodeAt(0) === xt && i.charCodeAt(1) !== xt && i.indexOf("-", 2) !== -1;
70
+ }
71
+ class q {
72
+ /** @param {string[]} items */
73
+ constructor(t) {
74
+ this.set = new Set(t);
75
+ }
76
+ /** @param {string} item */
77
+ has(t) {
78
+ return this.set.has(t.toLowerCase());
79
+ }
80
+ }
81
+ function At(i, t) {
82
+ let r = [];
83
+ return A(i, {
84
+ visit: De,
85
+ enter: function(e) {
86
+ r.push(t(e));
87
+ }
88
+ }), r;
89
+ }
90
+ const Pt = new q([
91
+ "nth-child",
92
+ "where",
93
+ "not",
94
+ "is",
95
+ "has",
96
+ "nth-last-child",
97
+ "matches",
98
+ "-webkit-any",
99
+ "-moz-any"
100
+ ]);
101
+ function Lt(i) {
102
+ let t = !1;
103
+ return A(i, function(r) {
104
+ if (r.type === St) {
105
+ let e = r.name.name;
106
+ if (z("role", e) || Ee("aria-", e))
107
+ return t = !0, this.break;
108
+ } else if (r.type === Y && Pt.has(r.name)) {
109
+ let e = At(r, Lt);
110
+ for (let n of e)
111
+ if (n === !0) {
112
+ t = !0;
113
+ break;
114
+ }
115
+ return this.skip;
116
+ }
117
+ }), t;
118
+ }
119
+ function Qt(i) {
120
+ let t = !1;
121
+ return A(i, function(r) {
122
+ let e = r.type;
123
+ if ((e === vt || e === zt || e === Y) && R(r.name))
124
+ return t = !0, this.break;
125
+ }), t;
126
+ }
127
+ function Zt(i) {
128
+ let t = [];
129
+ return A(i, function(r) {
130
+ r.type === Y && t.push(r.name);
131
+ }), t.length === 0 ? !1 : t;
132
+ }
133
+ function Ot(i) {
134
+ let t = 0;
135
+ return A(i, function(r) {
136
+ let e = r.type;
137
+ if (!(e === De || e === Vt)) {
138
+ if (t++, (e === vt || e === zt || e === Y) && R(r.name) && t++, e === St)
139
+ return r.value && t++, this.skip;
140
+ if (e === Y && Pt.has(r.name)) {
141
+ let n = At(r, Ot);
142
+ if (n.length === 0) return;
143
+ for (let l of n)
144
+ t += l;
145
+ return this.skip;
146
+ }
147
+ }
148
+ }), t;
149
+ }
150
+ function Jt(i, t) {
151
+ A(i, function(r, e) {
152
+ if (r.type === Wt) {
153
+ let n = r.loc, l = r.name;
154
+ if (n === null) {
155
+ let d = e.prev.data.loc.end, m = {
156
+ offset: d.offset,
157
+ line: d.line,
158
+ column: d.column
159
+ };
160
+ t({
161
+ name: l,
162
+ loc: {
163
+ start: m,
164
+ end: {
165
+ offset: m.offset + 1,
166
+ line: m.line,
167
+ column: m.column + 1
168
+ }
169
+ }
170
+ });
171
+ } else
172
+ t({
173
+ name: l,
174
+ loc: n
175
+ });
176
+ }
177
+ });
178
+ }
179
+ const Xt = new q([
180
+ // CSS Named Colors
181
+ // Spec: https://drafts.csswg.org/css-color/#named-colors
182
+ // Heuristic: popular names first for quick finding in set.has()
183
+ // See: https://docs.google.com/spreadsheets/d/1OU8ahxC5oYU8VRryQs9BzHToaXcOntVlh6KUHjm15G4/edit#gid=2096495459
184
+ "white",
185
+ "black",
186
+ "red",
187
+ "gray",
188
+ "silver",
189
+ "grey",
190
+ "green",
191
+ "orange",
192
+ "blue",
193
+ "dimgray",
194
+ "whitesmoke",
195
+ "lightgray",
196
+ "lightgrey",
197
+ "yellow",
198
+ "gold",
199
+ "pink",
200
+ "gainsboro",
201
+ "magenta",
202
+ "purple",
203
+ "darkgray",
204
+ "navy",
205
+ "darkred",
206
+ "teal",
207
+ "maroon",
208
+ "darkgrey",
209
+ "tomato",
210
+ "darkorange",
211
+ "brown",
212
+ "crimson",
213
+ "lightyellow",
214
+ "slategray",
215
+ "salmon",
216
+ "lightgreen",
217
+ "lightblue",
218
+ "orangered",
219
+ "aliceblue",
220
+ "dodgerblue",
221
+ "lime",
222
+ "darkblue",
223
+ "darkgoldenrod",
224
+ "skyblue",
225
+ "royalblue",
226
+ "darkgreen",
227
+ "ivory",
228
+ "olive",
229
+ "aqua",
230
+ "turquoise",
231
+ "cyan",
232
+ "khaki",
233
+ "beige",
234
+ "snow",
235
+ "ghostwhite",
236
+ "limegreen",
237
+ "coral",
238
+ "dimgrey",
239
+ "hotpink",
240
+ "midnightblue",
241
+ "firebrick",
242
+ "indigo",
243
+ "wheat",
244
+ "mediumblue",
245
+ "lightpink",
246
+ "plum",
247
+ "azure",
248
+ "violet",
249
+ "lavender",
250
+ "deepskyblue",
251
+ "darkslategrey",
252
+ "goldenrod",
253
+ "cornflowerblue",
254
+ "lightskyblue",
255
+ "indianred",
256
+ "yellowgreen",
257
+ "saddlebrown",
258
+ "palegreen",
259
+ "bisque",
260
+ "tan",
261
+ "antiquewhite",
262
+ "steelblue",
263
+ "forestgreen",
264
+ "fuchsia",
265
+ "mediumaquamarine",
266
+ "seagreen",
267
+ "sienna",
268
+ "deeppink",
269
+ "mediumseagreen",
270
+ "peru",
271
+ "greenyellow",
272
+ "lightgoldenrodyellow",
273
+ "orchid",
274
+ "cadetblue",
275
+ "navajowhite",
276
+ "lightsteelblue",
277
+ "slategrey",
278
+ "linen",
279
+ "lightseagreen",
280
+ "darkcyan",
281
+ "lightcoral",
282
+ "aquamarine",
283
+ "blueviolet",
284
+ "cornsilk",
285
+ "lightsalmon",
286
+ "chocolate",
287
+ "lightslategray",
288
+ "floralwhite",
289
+ "darkturquoise",
290
+ "darkslategray",
291
+ "rebeccapurple",
292
+ "burlywood",
293
+ "chartreuse",
294
+ "lightcyan",
295
+ "lemonchiffon",
296
+ "palevioletred",
297
+ "darkslateblue",
298
+ "mediumpurple",
299
+ "lawngreen",
300
+ "slateblue",
301
+ "darkseagreen",
302
+ "blanchedalmond",
303
+ "mistyrose",
304
+ "darkolivegreen",
305
+ "seashell",
306
+ "olivedrab",
307
+ "peachpuff",
308
+ "darkviolet",
309
+ "powderblue",
310
+ "darkmagenta",
311
+ "lightslategrey",
312
+ "honeydew",
313
+ "palegoldenrod",
314
+ "darkkhaki",
315
+ "oldlace",
316
+ "mintcream",
317
+ "sandybrown",
318
+ "mediumturquoise",
319
+ "papayawhip",
320
+ "paleturquoise",
321
+ "mediumvioletred",
322
+ "thistle",
323
+ "springgreen",
324
+ "moccasin",
325
+ "rosybrown",
326
+ "lavenderblush",
327
+ "mediumslateblue",
328
+ "darkorchid",
329
+ "mediumorchid",
330
+ "darksalmon",
331
+ "mediumspringgreen"
332
+ ]), $t = new q([
333
+ // CSS System Colors
334
+ // Spec: https://drafts.csswg.org/css-color/#css-system-colors
335
+ "accentcolor",
336
+ "accentcolortext",
337
+ "activetext",
338
+ "buttonborder",
339
+ "buttonface",
340
+ "buttontext",
341
+ "canvas",
342
+ "canvastext",
343
+ "field",
344
+ "fieldtext",
345
+ "graytext",
346
+ "highlight",
347
+ "highlighttext",
348
+ "linktext",
349
+ "mark",
350
+ "marktext",
351
+ "selecteditem",
352
+ "selecteditemtext",
353
+ "visitedtext"
354
+ ]), Nt = new q([
355
+ "rgba",
356
+ "rgb",
357
+ "hsla",
358
+ "hsl",
359
+ "oklch",
360
+ "color",
361
+ "hwb",
362
+ "lch",
363
+ "lab",
364
+ "oklab"
365
+ ]), ei = new q([
366
+ "transparent",
367
+ "currentcolor"
368
+ ]), N = new q([
369
+ "auto",
370
+ "none",
371
+ // for `text-shadow`, `box-shadow` and `background`
372
+ "inherit",
373
+ "initial",
374
+ "unset",
375
+ "revert",
376
+ "revert-layer"
377
+ ]);
378
+ function $(i) {
379
+ let t = i.children, r = t.size;
380
+ if (!t || r > 1 || r === 0) return !1;
381
+ let e = t.first;
382
+ return e.type === P && N.has(e.name);
383
+ }
384
+ const ti = new q([
385
+ "caption",
386
+ "icon",
387
+ "menu",
388
+ "message-box",
389
+ "small-caption",
390
+ "status-bar"
391
+ ]), ii = new q([
392
+ /* <absolute-size> values */
393
+ "xx-small",
394
+ "x-small",
395
+ "small",
396
+ "medium",
397
+ "large",
398
+ "x-large",
399
+ "xx-large",
400
+ "xxx-large",
401
+ /* <relative-size> values */
402
+ "smaller",
403
+ "larger"
404
+ ]), ri = 44, Ct = 47;
405
+ function Pe(i) {
406
+ let t = i.children.first;
407
+ return t === null ? !1 : t.type === P && ti.has(t.name);
408
+ }
409
+ function si(i, t, r) {
410
+ let e = Array.from({ length: 2 }), n, l;
411
+ i.children.forEach(function(m, b) {
412
+ let C = b.prev ? b.prev.data : void 0, y = b.next ? b.next.data : void 0;
413
+ if (m.type === P && N.has(m.name) && r({
414
+ type: "keyword",
415
+ value: m.name
416
+ }), y && y.type === H && y.value.charCodeAt(0) === Ct) {
417
+ n = t(m);
418
+ return;
419
+ }
420
+ if (C && C.type === H && C.value.charCodeAt(0) === Ct) {
421
+ l = t(m);
422
+ return;
423
+ }
424
+ if (y && y.type === H && y.value.charCodeAt(0) === ri && !e[0]) {
425
+ e[0] = m, !n && C && (n = t(C));
426
+ return;
427
+ }
428
+ if (m.type !== Kt) {
429
+ if (b.next === null) {
430
+ e[1] = m, !n && !e[0] && C && (n = t(C));
431
+ return;
432
+ }
433
+ if (m.type === P) {
434
+ let M = m.name;
435
+ if (ii.has(M)) {
436
+ n = M;
437
+ return;
438
+ }
439
+ }
440
+ }
441
+ });
442
+ let d = e[0] || e[1] ? t({
443
+ loc: {
444
+ start: {
445
+ offset: (e[0] || e[1]).loc.start.offset
446
+ },
447
+ end: {
448
+ offset: e[1].loc.end.offset
449
+ }
450
+ }
451
+ }) : null;
452
+ return {
453
+ font_size: n,
454
+ line_height: l,
455
+ font_family: d
456
+ };
457
+ }
458
+ const li = new q([
459
+ "linear",
460
+ "ease",
461
+ "ease-in",
462
+ "ease-out",
463
+ "ease-in-out",
464
+ "step-start",
465
+ "step-end"
466
+ ]), ni = new q([
467
+ "cubic-bezier",
468
+ "steps"
469
+ ]);
470
+ function ai(i, t) {
471
+ let r = !1;
472
+ for (let e of i) {
473
+ let n = e.type, l = e.name;
474
+ n === H ? r = !1 : n === qt && r === !1 ? (r = !0, t({
475
+ type: "duration",
476
+ value: e
477
+ })) : n === P ? li.has(l) ? t({
478
+ type: "fn",
479
+ value: e
480
+ }) : N.has(l) && t({
481
+ type: "keyword",
482
+ value: e
483
+ }) : n === Fe && ni.has(l) && t({
484
+ type: "fn",
485
+ value: e
486
+ });
487
+ }
488
+ }
489
+ function Rt(i) {
490
+ let t = i.children;
491
+ if (!t)
492
+ return !1;
493
+ for (let r of t) {
494
+ let { type: e, name: n } = r;
495
+ if (e === P && R(n) || e === Fe && (R(n) || Rt(r)))
496
+ return !0;
497
+ }
498
+ return !1;
499
+ }
500
+ class o {
501
+ /** @param {boolean} useLocations */
502
+ constructor(t = !1) {
503
+ this._items = /* @__PURE__ */ new Map(), this._total = 0, t && (this._nodes = []), this._useLocations = t;
504
+ }
505
+ /**
506
+ * @param {string | number} item
507
+ * @param {import('css-tree').CssLocation} node_location
508
+ */
509
+ p(t, r) {
510
+ let e = this._total;
511
+ if (this._useLocations) {
512
+ let n = r.start, l = n.offset, d = e * 4;
513
+ this._nodes[d] = n.line, this._nodes[d + 1] = n.column, this._nodes[d + 2] = l, this._nodes[d + 3] = r.end.offset - l;
514
+ }
515
+ if (this._items.has(t)) {
516
+ this._items.get(t).push(e), this._total++;
517
+ return;
518
+ }
519
+ this._items.set(t, [e]), this._total++;
520
+ }
521
+ size() {
522
+ return this._total;
523
+ }
524
+ /**
525
+ * @typedef CssLocation
526
+ * @property {number} line
527
+ * @property {number} column
528
+ * @property {number} offset
529
+ * @property {number} length
530
+ *
531
+ * @returns {{
532
+ * total: number;
533
+ * totalUnique: number;
534
+ * uniquenessRatio: number;
535
+ * unique: Record<string, number>;
536
+ * } & ({
537
+ * uniqueWithLocations: Record<string, CssLocation[]>
538
+ * } | {
539
+ * uniqueWithLocations?: undefined
540
+ * })}
541
+ */
542
+ c() {
543
+ let t = /* @__PURE__ */ new Map(), r = {}, e = this._useLocations, n = this._items, l = this._nodes, d = n.size;
544
+ n.forEach((C, y) => {
545
+ if (e) {
546
+ let M = C.map(function(V) {
547
+ let E = V * 4;
548
+ return {
549
+ line: l[E],
550
+ column: l[E + 1],
551
+ offset: l[E + 2],
552
+ length: l[E + 3]
553
+ };
554
+ });
555
+ t.set(y, M);
556
+ } else
557
+ r[y] = C.length;
558
+ });
559
+ let m = this._total, b = {
560
+ total: m,
561
+ totalUnique: d,
562
+ unique: r,
563
+ uniquenessRatio: m === 0 ? 0 : d / m
564
+ };
565
+ return e && (b.uniqueWithLocations = Object.fromEntries(t)), b;
566
+ }
567
+ }
568
+ class Le {
569
+ /** @param {boolean} useLocations */
570
+ constructor(t) {
571
+ this._list = new o(t), this._contexts = /* @__PURE__ */ new Map(), this._useLocations = t;
572
+ }
573
+ /**
574
+ * Add an item to this _list's context
575
+ * @param {string} item Item to push
576
+ * @param {string} context Context to push Item to
577
+ * @param {import('css-tree').CssLocation} node_location
578
+ */
579
+ push(t, r, e) {
580
+ this._list.p(t, e), this._contexts.has(r) || this._contexts.set(r, new o(this._useLocations)), this._contexts.get(r).p(t, e);
581
+ }
582
+ count() {
583
+ let t = /* @__PURE__ */ new Map();
584
+ for (let [r, e] of this._contexts.entries())
585
+ t.set(r, e.c());
586
+ return Object.assign(this._list.c(), {
587
+ itemsPerContext: Object.fromEntries(t)
588
+ });
589
+ }
590
+ }
591
+ function oi(i) {
592
+ let t = /* @__PURE__ */ new Map(), r = -1, e = 0, n = 0, l = i.length;
593
+ for (let d = 0; d < l; d++) {
594
+ let m = i[d], b = (t.get(m) || 0) + 1;
595
+ t.set(m, b), b > r && (r = b, e = 0, n = 0), b >= r && (e++, n += m);
596
+ }
597
+ return n / e;
598
+ }
599
+ class v {
600
+ constructor() {
601
+ this._items = [], this._sum = 0;
602
+ }
603
+ /**
604
+ * Add a new Integer at the end of this AggregateCollection
605
+ * @param {number} item - The item to add
606
+ */
607
+ push(t) {
608
+ this._items.push(t), this._sum += t;
609
+ }
610
+ size() {
611
+ return this._items.length;
612
+ }
613
+ aggregate() {
614
+ let t = this._items.length;
615
+ if (t === 0)
616
+ return {
617
+ min: 0,
618
+ max: 0,
619
+ mean: 0,
620
+ mode: 0,
621
+ range: 0,
622
+ sum: 0
623
+ };
624
+ let r = this._items.slice().sort((m, b) => m - b), e = r[0], n = r[t - 1], l = oi(r), d = this._sum;
625
+ return {
626
+ min: e,
627
+ max: n,
628
+ mean: d / t,
629
+ mode: l,
630
+ range: n - e,
631
+ sum: d
632
+ };
633
+ }
634
+ /**
635
+ * @returns {number[]} All _items in this collection
636
+ */
637
+ toArray() {
638
+ return this._items;
639
+ }
640
+ }
641
+ function ui(i) {
642
+ if (Me(i) || R(i)) return !1;
643
+ let t = i.charCodeAt(0);
644
+ return t === 47 || t === 42 || t === 95 || t === 43 || t === 38 || t === 36 || t === 35;
645
+ }
646
+ function Me(i) {
647
+ return i.length < 3 ? !1 : i.charCodeAt(0) === 45 && i.charCodeAt(1) === 45;
648
+ }
649
+ function _(i, t) {
650
+ return Me(t) ? !1 : L(i, t);
651
+ }
652
+ function ci(i) {
653
+ return R(i) ? i.slice(i.indexOf("-", 2) + 1) : i;
654
+ }
655
+ function fi(i) {
656
+ let t = 5, r = i.indexOf(";"), e = i.indexOf(",");
657
+ return r === -1 || e !== -1 && e < r ? i.substring(t, e) : i.substring(t, r);
658
+ }
659
+ function pi(i) {
660
+ let t = i.children;
661
+ if (t) {
662
+ let r = t.last;
663
+ return r && r.type === P && L("\\9", r.name);
664
+ }
665
+ return !1;
666
+ }
667
+ let hi = new q([
668
+ "border-radius",
669
+ "border-top-left-radius",
670
+ "border-top-right-radius",
671
+ "border-bottom-right-radius",
672
+ "border-bottom-left-radius",
673
+ "border-start-start-radius",
674
+ "border-start-end-radius",
675
+ "border-end-end-radius",
676
+ "border-end-start-radius"
677
+ ]);
678
+ function x(i, t) {
679
+ return t === 0 ? 0 : i / t;
680
+ }
681
+ let mi = {
682
+ useLocations: !1
683
+ };
684
+ function wi(i, t = {}) {
685
+ let e = Object.assign({}, mi, t).useLocations === !0, n = Date.now();
686
+ function l(s) {
687
+ return d(s).trim();
688
+ }
689
+ function d(s) {
690
+ let f = s.loc;
691
+ return i.substring(f.start.offset, f.end.offset);
692
+ }
693
+ let m = 0, b = 0, C = 0, y = {
694
+ total: 0,
695
+ /** @type {Map<string, { size: number, count: number } & ({ uniqueWithLocations?: undefined } | ({ uniqueWithLocations: { offset: number, line: number, column: number, length: number }[] })) }>} */
696
+ unique: /* @__PURE__ */ new Map()
697
+ }, M = Date.now(), V = Dt(i, {
698
+ parseCustomProperty: !0,
699
+ // To find font-families, colors, etc.
700
+ positions: !0,
701
+ // So we can use stringifyNode()
702
+ /** @param {string} comment */
703
+ onComment: function(s) {
704
+ m++, b += s.length;
705
+ }
706
+ }), E = Date.now(), Et = V.loc.end.line - V.loc.start.line + 1, ee = 0, te = new v(), ie = [], Ue = new o(e), re = new o(e), Te = new o(e), Ie = new o(e), He = new o(e), Ve = new o(e), We = new o(e), Ke = new o(e), se = new o(e), le = new o(e), je = new o(e), Be = new o(e), ne = 0, ae = 0, oe = new v(), ue = new v(), ce = new v(), Ye = new o(e), Ge = new o(e), Qe = new o(e), fe = new o(e), Ze = /* @__PURE__ */ new Set(), pe = new o(e), D, F, Je = new v(), Xe = new v(), $e = new v(), Ne = new o(e), G = new v(), et = new o(e), tt = [], he = new o(e), me = new o(e), it = new o(e), rt = new o(e), st = /* @__PURE__ */ new Set(), W = 0, lt = new v(), Q = 0, de = 0, ge = new o(e), K = new o(e), ye = new o(e), we = new o(e), Z = new o(e), j = new v(), be = new v(), nt = new o(e), ke = new o(e), at = new o(e), ot = new o(e), ut = new o(e), xe = new o(e), Ce = new o(e), _e = new o(e), J = new o(e), X = new o(e), U = new Le(e), T = new o(e), ze = new Le(e), ct = new o(e), B = new o(e), ft = new Le(e);
707
+ A(V, function(s) {
708
+ switch (s.type) {
709
+ case Mt: {
710
+ ee++;
711
+ let f = s.name;
712
+ if (f === "font-face") {
713
+ let g = {};
714
+ e && Ue.p(s.loc.start.offset, s.loc), s.block.children.forEach((u) => {
715
+ u.type === Oe && (g[u.property] = l(u.value));
716
+ }), ie.push(g), te.push(1);
717
+ break;
718
+ }
719
+ let a = 1;
720
+ if (s.prelude !== null) {
721
+ let g = s.prelude, u = g && l(s.prelude), p = g.loc;
722
+ if (f === "media")
723
+ Ie.p(u, p), Gt(g) && (He.p(u, p), a++);
724
+ else if (f === "supports")
725
+ We.p(u, p), Yt(g) && (Ke.p(u, p), a++);
726
+ else if (L("keyframes", f)) {
727
+ let c = "@" + f + " " + u;
728
+ R(f) && (le.p(c, p), a++), se.p(c, p);
729
+ } else f === "import" ? Te.p(u, p) : f === "charset" ? Ve.p(u, p) : f === "container" ? je.p(u, p) : f === "layer" ? u.split(",").forEach((c) => re.p(c.trim(), p)) : f === "property" && Be.p(u, p);
730
+ } else
731
+ f === "layer" && (re.p("<anonymous>", s.loc), a++);
732
+ te.push(a);
733
+ break;
734
+ }
735
+ case It: {
736
+ let f = s.prelude, a = s.block, g = f.children, u = a.children, p = g ? g.size : 0, c = u ? u.size : 0;
737
+ oe.push(p + c), Ye.p(p + c, s.loc), ue.push(p), Ge.p(p, f.loc), ce.push(c), Qe.p(c, a.loc), ne++, c === 0 && ae++;
738
+ break;
739
+ }
740
+ case De: {
741
+ let f = l(s);
742
+ if (this.atrule && L("keyframes", this.atrule.name))
743
+ return fe.p(f, s.loc), this.skip;
744
+ Lt(s) && me.p(f, s.loc);
745
+ let a = Zt(s);
746
+ if (a !== !1)
747
+ for (let k of a)
748
+ it.p(k, s.loc);
749
+ let g = Ot(s);
750
+ Qt(s) && pe.p(f, s.loc), Ze.add(f), G.push(g), et.p(g, s.loc);
751
+ let u = Ft(s).toArray(), [p, c, h] = u;
752
+ return Ne.p(u.toString(), s.loc), Je.push(p), Xe.push(c), $e.push(h), D === void 0 && (D = u), F === void 0 && (F = u), F !== void 0 && _t(F, u) < 0 && (F = u), D !== void 0 && _t(D, u) > 0 && (D = u), tt.push(u), p > 0 && he.p(f, s.loc), Jt(s, function(S) {
753
+ rt.p(S.name, S.loc);
754
+ }), this.skip;
755
+ }
756
+ case qt: {
757
+ if (!this.declaration)
758
+ break;
759
+ let f = s.unit;
760
+ return L("\\9", f) ? ze.push(f.substring(0, f.length - 2), this.declaration.property, s.loc) : ze.push(f, this.declaration.property, s.loc), this.skip;
761
+ }
762
+ case Bt: {
763
+ if (Ee("data:", s.value)) {
764
+ let f = s.value, a = f.length, g = fi(f);
765
+ y.total++, C += a;
766
+ let u = {
767
+ /** @type {number} */
768
+ line: s.loc.start.line,
769
+ /** @type {number} */
770
+ column: s.loc.start.column,
771
+ /** @type {number} */
772
+ offset: s.loc.start.offset,
773
+ /** @type {number} */
774
+ length: s.loc.end.offset - s.loc.start.offset
775
+ };
776
+ if (y.unique.has(g)) {
777
+ let p = y.unique.get(g);
778
+ p.count++, p.size += a, y.unique.set(g, p), e && p.uniqueWithLocations.push(u);
779
+ } else {
780
+ let p = {
781
+ count: 1,
782
+ size: a
783
+ };
784
+ e && (p.uniqueWithLocations = [u]), y.unique.set(g, p);
785
+ }
786
+ }
787
+ break;
788
+ }
789
+ case Ht: {
790
+ if ($(s)) {
791
+ be.push(1), B.p(l(s), s.loc);
792
+ break;
793
+ }
794
+ let f = this.declaration, { property: a, important: g } = f, u = 1;
795
+ Rt(s) && (nt.p(l(s), s.loc), u++), typeof g == "string" && (ke.p(d(s) + "!" + g, s.loc), u++), pi(s) && (ke.p(l(s), s.loc), u++);
796
+ let p = s.children, c = s.loc;
797
+ if (be.push(u), _("z-index", a))
798
+ return at.p(l(s), c), this.skip;
799
+ if (_("font", a)) {
800
+ if (Pe(s)) return;
801
+ let { font_size: h, line_height: k, font_family: S } = si(s, l, function(O) {
802
+ O.type === "keyword" && B.p(O.value, c);
803
+ });
804
+ S && xe.p(S, c), h && Ce.p(h, c), k && _e.p(k, c);
805
+ break;
806
+ } else if (_("font-size", a)) {
807
+ Pe(s) || Ce.p(l(s), c);
808
+ break;
809
+ } else if (_("font-family", a)) {
810
+ Pe(s) || xe.p(l(s), c);
811
+ break;
812
+ } else if (_("line-height", a))
813
+ _e.p(l(s), c);
814
+ else if (_("transition", a) || _("animation", a)) {
815
+ ai(p, function(h) {
816
+ h.type === "fn" ? J.p(l(h.value), c) : h.type === "duration" ? X.p(l(h.value), c) : h.type === "keyword" && B.p(l(h.value), c);
817
+ });
818
+ break;
819
+ } else if (_("animation-duration", a) || _("transition-duration", a)) {
820
+ p && p.size > 1 ? p.forEach((h) => {
821
+ h.type !== H && X.p(l(h), c);
822
+ }) : X.p(l(s), c);
823
+ break;
824
+ } else if (_("transition-timing-function", a) || _("animation-timing-function", a)) {
825
+ p && p.size > 1 ? p.forEach((h) => {
826
+ h.type !== H && J.p(l(h), c);
827
+ }) : J.p(l(s), c);
828
+ break;
829
+ } else if (hi.has(ci(a))) {
830
+ $(s) || ft.push(l(s), a, c);
831
+ break;
832
+ } else _("text-shadow", a) ? $(s) || ot.p(l(s), c) : _("box-shadow", a) && ($(s) || ut.p(l(s), c));
833
+ A(s, function(h) {
834
+ let k = h.name;
835
+ switch (h.type) {
836
+ case jt: {
837
+ let S = h.value.length;
838
+ return L("\\9", h.value) && (S = S - 2), U.push("#" + h.value, a, c), T.p("hex" + S, c), this.skip;
839
+ }
840
+ case P: {
841
+ N.has(k) && B.p(k, c);
842
+ let S = k.length;
843
+ if (S > 20 || S < 3)
844
+ return this.skip;
845
+ if (ei.has(k)) {
846
+ let O = l(h);
847
+ U.push(O, a, c), T.p(k.toLowerCase(), c);
848
+ return;
849
+ }
850
+ if (Xt.has(k)) {
851
+ let O = l(h);
852
+ U.push(O, a, c), T.p("named", c);
853
+ return;
854
+ }
855
+ if ($t.has(k)) {
856
+ let O = l(h);
857
+ U.push(O, a, c), T.p("system", c);
858
+ return;
859
+ }
860
+ return this.skip;
861
+ }
862
+ case Fe: {
863
+ if (z("var", k))
864
+ return this.skip;
865
+ if (Nt.has(k)) {
866
+ U.push(l(h), a, h.loc), T.p(k.toLowerCase(), h.loc);
867
+ return;
868
+ }
869
+ if (L("gradient", k)) {
870
+ ct.p(l(h), h.loc);
871
+ return;
872
+ }
873
+ }
874
+ }
875
+ });
876
+ break;
877
+ }
878
+ case Oe: {
879
+ if (this.atrulePrelude !== null)
880
+ return this.skip;
881
+ W++;
882
+ let f = 1;
883
+ st.add(l(s)), s.important === !0 && (Q++, f++, this.atrule && L("keyframes", this.atrule.name) && (de++, f++)), lt.push(f);
884
+ let { property: a, loc: { start: g } } = s, u = {
885
+ start: {
886
+ line: g.line,
887
+ column: g.column,
888
+ offset: g.offset
889
+ },
890
+ end: {
891
+ offset: g.offset + a.length
892
+ }
893
+ };
894
+ K.p(a, u), R(a) ? (we.p(a, u), j.push(2)) : ui(a) ? (ye.p(a, u), j.push(2)) : Me(a) ? (Z.p(a, u), j.push(s.important ? 3 : 2), s.important === !0 && ge.p(a, u)) : j.push(1);
895
+ break;
896
+ }
897
+ }
898
+ });
899
+ let pt = st.size, I = G.size(), Se = Je.aggregate(), ve = Xe.aggregate(), qe = $e.aggregate(), ht = Ze.size, w = Object.assign, mt = i.length, Ae = ie.length, dt = te.aggregate(), gt = G.aggregate(), yt = lt.aggregate(), wt = j.aggregate(), bt = be.aggregate();
900
+ return {
901
+ stylesheet: {
902
+ sourceLinesOfCode: ee + I + W + fe.size(),
903
+ linesOfCode: Et,
904
+ size: mt,
905
+ complexity: dt.sum + gt.sum + yt.sum + wt.sum + bt.sum,
906
+ comments: {
907
+ total: m,
908
+ size: b
909
+ },
910
+ embeddedContent: {
911
+ size: {
912
+ total: C,
913
+ ratio: x(C, mt)
914
+ },
915
+ types: {
916
+ total: y.total,
917
+ totalUnique: y.unique.size,
918
+ uniquenessRatio: x(y.unique.size, y.total),
919
+ unique: Object.fromEntries(y.unique)
920
+ }
921
+ }
922
+ },
923
+ atrules: {
924
+ fontface: w({
925
+ total: Ae,
926
+ totalUnique: Ae,
927
+ unique: ie,
928
+ uniquenessRatio: Ae === 0 ? 0 : 1
929
+ }, e ? {
930
+ uniqueWithLocations: Ue.c().uniqueWithLocations
931
+ } : {}),
932
+ import: Te.c(),
933
+ media: w(
934
+ Ie.c(),
935
+ {
936
+ browserhacks: He.c()
937
+ }
938
+ ),
939
+ charset: Ve.c(),
940
+ supports: w(
941
+ We.c(),
942
+ {
943
+ browserhacks: Ke.c()
944
+ }
945
+ ),
946
+ keyframes: w(
947
+ se.c(),
948
+ {
949
+ prefixed: w(
950
+ le.c(),
951
+ {
952
+ ratio: x(le.size(), se.size())
953
+ }
954
+ )
955
+ }
956
+ ),
957
+ container: je.c(),
958
+ layer: re.c(),
959
+ property: Be.c(),
960
+ total: ee,
961
+ complexity: dt
962
+ },
963
+ rules: {
964
+ total: ne,
965
+ empty: {
966
+ total: ae,
967
+ ratio: x(ae, ne)
968
+ },
969
+ sizes: w(
970
+ oe.aggregate(),
971
+ {
972
+ items: oe.toArray()
973
+ },
974
+ Ye.c()
975
+ ),
976
+ selectors: w(
977
+ ue.aggregate(),
978
+ {
979
+ items: ue.toArray()
980
+ },
981
+ Ge.c()
982
+ ),
983
+ declarations: w(
984
+ ce.aggregate(),
985
+ {
986
+ items: ce.toArray()
987
+ },
988
+ Qe.c()
989
+ )
990
+ },
991
+ selectors: {
992
+ total: I,
993
+ totalUnique: ht,
994
+ uniquenessRatio: x(ht, I),
995
+ specificity: w(
996
+ {
997
+ /** @type Specificity */
998
+ min: F === void 0 ? [0, 0, 0] : F,
999
+ /** @type Specificity */
1000
+ max: D === void 0 ? [0, 0, 0] : D,
1001
+ /** @type Specificity */
1002
+ sum: [Se.sum, ve.sum, qe.sum],
1003
+ /** @type Specificity */
1004
+ mean: [Se.mean, ve.mean, qe.mean],
1005
+ /** @type Specificity */
1006
+ mode: [Se.mode, ve.mode, qe.mode],
1007
+ /** @type Specificity */
1008
+ items: tt
1009
+ },
1010
+ Ne.c()
1011
+ ),
1012
+ complexity: w(
1013
+ gt,
1014
+ et.c(),
1015
+ {
1016
+ items: G.toArray()
1017
+ }
1018
+ ),
1019
+ id: w(
1020
+ he.c(),
1021
+ {
1022
+ ratio: x(he.size(), I)
1023
+ }
1024
+ ),
1025
+ pseudoClasses: it.c(),
1026
+ accessibility: w(
1027
+ me.c(),
1028
+ {
1029
+ ratio: x(me.size(), I)
1030
+ }
1031
+ ),
1032
+ keyframes: fe.c(),
1033
+ prefixed: w(
1034
+ pe.c(),
1035
+ {
1036
+ ratio: x(pe.size(), I)
1037
+ }
1038
+ ),
1039
+ combinators: rt.c()
1040
+ },
1041
+ declarations: {
1042
+ total: W,
1043
+ totalUnique: pt,
1044
+ uniquenessRatio: x(pt, W),
1045
+ importants: {
1046
+ total: Q,
1047
+ ratio: x(Q, W),
1048
+ inKeyframes: {
1049
+ total: de,
1050
+ ratio: x(de, Q)
1051
+ }
1052
+ },
1053
+ complexity: yt
1054
+ },
1055
+ properties: w(
1056
+ K.c(),
1057
+ {
1058
+ prefixed: w(
1059
+ we.c(),
1060
+ {
1061
+ ratio: x(we.size(), K.size())
1062
+ }
1063
+ ),
1064
+ custom: w(
1065
+ Z.c(),
1066
+ {
1067
+ ratio: x(Z.size(), K.size()),
1068
+ importants: w(
1069
+ ge.c(),
1070
+ {
1071
+ ratio: x(ge.size(), Z.size())
1072
+ }
1073
+ )
1074
+ }
1075
+ ),
1076
+ browserhacks: w(
1077
+ ye.c(),
1078
+ {
1079
+ ratio: x(ye.size(), K.size())
1080
+ }
1081
+ ),
1082
+ complexity: wt
1083
+ }
1084
+ ),
1085
+ values: {
1086
+ colors: w(
1087
+ U.count(),
1088
+ {
1089
+ formats: T.c()
1090
+ }
1091
+ ),
1092
+ gradients: ct.c(),
1093
+ fontFamilies: xe.c(),
1094
+ fontSizes: Ce.c(),
1095
+ lineHeights: _e.c(),
1096
+ zindexes: at.c(),
1097
+ textShadows: ot.c(),
1098
+ boxShadows: ut.c(),
1099
+ borderRadiuses: ft.count(),
1100
+ animations: {
1101
+ durations: X.c(),
1102
+ timingFunctions: J.c()
1103
+ },
1104
+ prefixes: nt.c(),
1105
+ browserhacks: ke.c(),
1106
+ units: ze.count(),
1107
+ complexity: bt,
1108
+ keywords: B.c()
1109
+ },
1110
+ __meta__: {
1111
+ parseTime: E - M,
1112
+ analyzeTime: Date.now() - E,
1113
+ total: Date.now() - n
1114
+ }
1115
+ };
1116
+ }
1117
+ function _t(i, t) {
1118
+ return i[0] === t[0] ? i[1] === t[1] ? t[2] - i[2] : t[1] - i[1] : t[0] - i[0];
1119
+ }
1120
+ export {
1121
+ wi as analyze,
1122
+ _t as compareSpecificity,
1123
+ R as hasVendorPrefix,
1124
+ Lt as isAccessibilitySelector,
1125
+ Gt as isMediaBrowserhack,
1126
+ ui as isPropertyHack,
1127
+ Qt as isSelectorPrefixed,
1128
+ Yt as isSupportsBrowserhack,
1129
+ Rt as isValuePrefixed,
1130
+ Ot as selectorComplexity
1131
+ };