@projectwallace/css-analyzer 9.2.1 → 9.4.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.
@@ -1,2869 +0,0 @@
1
- var Rr = Object.defineProperty;
2
- var yi = (r) => {
3
- throw TypeError(r);
4
- };
5
- var vr = (r, e, t) => e in r ? Rr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
6
- var m = (r, e, t) => vr(r, typeof e != "symbol" ? e + "" : e, t), Ci = (r, e, t) => e.has(r) || yi("Cannot " + t);
7
- var A = (r, e, t) => (Ci(r, e, "read from private field"), t ? t.call(r) : e.get(r)), Y = (r, e, t) => e.has(r) ? yi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), q = (r, e, t, s) => (Ci(r, e, "write to private field"), s ? s.call(r, t) : e.set(r, t), t);
8
- var Zt = (r, e, t, s) => ({
9
- set _(i) {
10
- q(r, e, i, t);
11
- },
12
- get _() {
13
- return A(r, e, s);
14
- }
15
- });
16
- import { walk as z, SUPPORTS_QUERY as Bi, BREAK as Q, MEDIA_TYPE as Tr, MEDIA_FEATURE as Gi, str_equals as ge, DIMENSION as kt, NUMBER as xs, IDENTIFIER as _e, SELECTOR as me, NTH_SELECTOR as Sr, PSEUDO_ELEMENT_SELECTOR as Qe, TYPE_SELECTOR as ms, PSEUDO_CLASS_SELECTOR as Le, ATTRIBUTE_SELECTOR as wt, SKIP as P, str_starts_with as Wi, COMBINATOR as ls, SELECTOR_LIST as ks, NTH_OF_SELECTOR as Or, CLASS_SELECTOR as Nr, ID_SELECTOR as Lr, FUNCTION as ws, OPERATOR as Re, is_custom as As, is_vendor_prefixed as Es, parse as Ur, AT_RULE as Ir, BLOCK as Hr, DECLARATION as Jt, LAYER_NAME as Pr, CONTAINER_QUERY as Dr, STYLE_RULE as Fr, HASH as Mr, URL as zr } from "@projectwallace/css-parser";
17
- function qr(r, e) {
18
- z(r, function(t) {
19
- if (t.type === Bi) {
20
- const i = (t.prelude || t.value || "").toString().toLowerCase().replaceAll(/\s+/g, "");
21
- if (i.includes("-webkit-appearance:none"))
22
- return e("-webkit-appearance: none"), Q;
23
- if (i.includes("-moz-appearance:meterbar"))
24
- return e("-moz-appearance: meterbar"), Q;
25
- }
26
- });
27
- }
28
- function Kr(r, e) {
29
- z(r, function(t) {
30
- if (t.type === Tr) {
31
- const s = t.text || "";
32
- if (s.startsWith("\\0"))
33
- return e("\\0"), Q;
34
- if (s.includes("\\9"))
35
- return e("\\9"), Q;
36
- }
37
- if (t.type === Gi) {
38
- const s = t.name || "";
39
- if (ge("-moz-images-in-menus", s))
40
- return e("-moz-images-in-menus"), Q;
41
- if (ge("min--moz-device-pixel-ratio", s))
42
- return e("min--moz-device-pixel-ratio"), Q;
43
- if (ge("-ms-high-contrast", s))
44
- return e("-ms-high-contrast"), Q;
45
- if (ge("min-resolution", s) && t.has_children) {
46
- for (const i of t)
47
- if (i.type === kt && i.value === 1e-3 && ge("dpcm", i.unit || ""))
48
- return e("min-resolution: .001dpcm"), Q;
49
- }
50
- if (ge("-webkit-min-device-pixel-ratio", s) && t.has_children) {
51
- for (const i of t)
52
- if (i.type === xs && (i.value === 0 || i.value === 1e4))
53
- return e("-webkit-min-device-pixel-ratio"), Q;
54
- }
55
- if (t.has_children) {
56
- for (const i of t)
57
- if (i.type === _e && i.text === "\\0")
58
- return e("\\0"), Q;
59
- }
60
- }
61
- });
62
- }
63
- class W {
64
- constructor(e) {
65
- m(this, "set");
66
- this.set = new Set(e);
67
- }
68
- has(e) {
69
- return this.set.has(e.toLowerCase());
70
- }
71
- }
72
- function Yi(r) {
73
- return r.replaceAll(/(?:^['"])|(?:['"]$)/g, "");
74
- }
75
- function $r(r, e) {
76
- return e >= 65 && e <= 90 && (e = e | 32), r === e;
77
- }
78
- function os(r, e) {
79
- if (r === e) return !0;
80
- let t = e.length, s = t - r.length;
81
- if (s < 0)
82
- return !1;
83
- for (let i = t - 1; i >= s; i--)
84
- if ($r(r.charCodeAt(i - s), e.charCodeAt(i)) === !1)
85
- return !1;
86
- return !0;
87
- }
88
- const Br = new W(["nth-child", "where", "not", "is", "has", "nth-last-child", "matches", "-webkit-any", "-moz-any"]);
89
- function Gr(r, e) {
90
- z(r, function(t) {
91
- if ((t.type === Qe || t.type === Le || t.type === ms) && t.is_vendor_prefixed) {
92
- let s = "";
93
- t.type === Le ? s = ":" : t.type === Qe && (s = "::"), e(s + (t.name || t.text));
94
- }
95
- });
96
- }
97
- function Wr(r, e) {
98
- function t(s) {
99
- var n, l;
100
- let i = s.clone();
101
- return i.value ? "[" + ((n = i.name) == null ? void 0 : n.toLowerCase()) + i.attr_operator + '"' + Yi(i.value.toString()) + '"]' : "[" + ((l = i.name) == null ? void 0 : l.toLowerCase()) + "]";
102
- }
103
- z(r, function(s) {
104
- if (s.type === wt) {
105
- const i = s.name || "";
106
- (ge("role", i) || Wi(i, "aria-")) && e(t(s));
107
- }
108
- });
109
- }
110
- function Yr(r, e) {
111
- z(r, function(t) {
112
- t.type === Le && t.name && e(t.name);
113
- });
114
- }
115
- function Qr(r, e) {
116
- z(r, function(t) {
117
- t.type === Qe && t.name && e(t.name);
118
- });
119
- }
120
- function as(r) {
121
- let e = 0;
122
- function t(s, i) {
123
- z(s, function(n) {
124
- n.type === me && i.push(as(n));
125
- });
126
- }
127
- return z(r, function(s) {
128
- const i = s.type;
129
- if (i !== me) {
130
- if (i === Sr) {
131
- s.text && s.text.trim() && e++;
132
- return;
133
- }
134
- if (e++, (i === Qe || i === ms || i === Le) && s.is_vendor_prefixed && e++, i === wt)
135
- return s.value && e++, P;
136
- if (i === Le) {
137
- const n = s.name || "";
138
- if (Br.has(n.toLowerCase())) {
139
- const l = [];
140
- if (s.has_children)
141
- for (const a of s)
142
- a.type === me ? l.push(as(a)) : t(a, l);
143
- if (l.length > 0) {
144
- for (const a of l)
145
- e += a;
146
- return P;
147
- }
148
- }
149
- }
150
- }
151
- }), e;
152
- }
153
- function Vr(r, e) {
154
- z(r, function(t) {
155
- var s;
156
- t.type === ls && e({
157
- name: ((s = t.name) == null ? void 0 : s.trim()) === "" ? " " : t.name,
158
- loc: {
159
- offset: t.start,
160
- line: t.line,
161
- column: t.column,
162
- length: 1
163
- }
164
- });
165
- });
166
- }
167
- let ys = 1, $ = 2, At = 4, ve = 8, ke = 16, y = new Uint8Array(128);
168
- for (let r = 48; r <= 57; r++)
169
- y[r] = $;
170
- for (let r = 48; r <= 57; r++)
171
- y[r] |= At;
172
- for (let r = 65; r <= 70; r++)
173
- y[r] = At;
174
- for (let r = 97; r <= 102; r++)
175
- y[r] = At;
176
- for (let r = 65; r <= 90; r++)
177
- y[r] |= ys;
178
- for (let r = 97; r <= 122; r++)
179
- y[r] |= ys;
180
- y[32] = ve;
181
- y[9] = ve;
182
- y[10] = ke;
183
- y[13] = ke;
184
- y[12] = ke;
185
- function jr(r) {
186
- return r < 128 && (y[r] & $) !== 0;
187
- }
188
- function pe(r) {
189
- return r < 128 && (y[r] & At) !== 0;
190
- }
191
- function Xr(r) {
192
- return r < 128 && (y[r] & ys) !== 0;
193
- }
194
- function bi(r) {
195
- return r < 128 && (y[r] & ve) !== 0;
196
- }
197
- function ne(r) {
198
- return r < 128 && (y[r] & ke) !== 0;
199
- }
200
- function Ke(r) {
201
- return r >= 128 || r === 95 ? !0 : Xr(r);
202
- }
203
- function at(r) {
204
- return r === 45 ? !0 : Ke(r) || jr(r);
205
- }
206
- const ae = 1, ct = 2, Zr = 3, Qi = 4, Vi = 5, Ri = 6, xe = 9, _t = 10, ji = 11, Xi = 12, hs = 13, Jr = 14, en = 15, Zi = 16, tn = 17, $e = 18, cs = 19, Ji = 20, er = 21, tr = 22, sn = 23, rn = 24, _s = 26, vi = 27, nn = 123, ln = 125, on = 58, an = 59, hn = 44, cn = 91, _n = 93, Ti = 40, un = 41, Si = 47, Oi = 42, fn = 34, pn = 39, es = 46, dn = 60, gn = 33, K = 45, xn = 62, mn = 64, kn = 35, ts = 92, Me = 43, wn = 37, An = 101, En = 69, yn = 117, Cn = 85, bn = 63, Ni = 13, Li = 10;
207
- class sr {
208
- constructor(e, t) {
209
- m(this, "source");
210
- m(this, "pos");
211
- m(this, "line");
212
- m(this, "column");
213
- m(this, "on_comment");
214
- // Current token properties (avoiding object allocation)
215
- m(this, "token_type");
216
- m(this, "token_start");
217
- m(this, "token_end");
218
- m(this, "token_line");
219
- m(this, "token_column");
220
- this.source = e, this.pos = 0, this.line = 1, this.column = 1, this.on_comment = t, this.token_type = _s, this.token_start = 0, this.token_end = 0, this.token_line = 1, this.token_column = 1;
221
- }
222
- // Fast token advancing without object allocation (for internal parser use)
223
- next_token_fast(e = !1) {
224
- if (e)
225
- for (; this.pos < this.source.length; ) {
226
- let l = this.source.charCodeAt(this.pos);
227
- if (l >= 128 || (y[l] & (ve | ke)) === 0) break;
228
- this.advance();
229
- }
230
- if (this.pos >= this.source.length)
231
- return this.make_token(_s, this.pos, this.pos);
232
- let t = this.source.charCodeAt(this.pos), s = this.pos, i = this.line, n = this.column;
233
- switch (t) {
234
- case nn:
235
- return this.advance(), this.make_token(sn, s, this.pos, i, n);
236
- case ln:
237
- return this.advance(), this.make_token(rn, s, this.pos, i, n);
238
- case on:
239
- return this.advance(), this.make_token(Zi, s, this.pos, i, n);
240
- case an:
241
- return this.advance(), this.make_token(tn, s, this.pos, i, n);
242
- case hn:
243
- return this.advance(), this.make_token($e, s, this.pos, i, n);
244
- case cn:
245
- return this.advance(), this.make_token(cs, s, this.pos, i, n);
246
- case _n:
247
- return this.advance(), this.make_token(Ji, s, this.pos, i, n);
248
- case Ti:
249
- return this.advance(), this.make_token(er, s, this.pos, i, n);
250
- case un:
251
- return this.advance(), this.make_token(tr, s, this.pos, i, n);
252
- }
253
- if (t < 128 && (y[t] & (ve | ke)) !== 0)
254
- return this.consume_whitespace(i, n);
255
- if (t === Si && this.peek() === Oi) {
256
- let l = s, a = i, h = n;
257
- for (this.advance(2); this.pos < this.source.length - 1; ) {
258
- if (this.source.charCodeAt(this.pos) === Oi && this.peek() === Si) {
259
- this.advance(2);
260
- break;
261
- }
262
- this.advance();
263
- }
264
- let o = this.pos;
265
- return this.on_comment && this.on_comment({
266
- start: l,
267
- end: o,
268
- length: o - l,
269
- line: a,
270
- column: h
271
- }), this.next_token_fast(e);
272
- }
273
- if (t === fn || t === pn)
274
- return this.consume_string(t, i, n);
275
- if (t < 128 && (y[t] & $) !== 0)
276
- return this.consume_number(i, n);
277
- if (t === es) {
278
- let l = this.peek();
279
- if (l < 128 && (y[l] & $) !== 0)
280
- return this.consume_number(i, n);
281
- }
282
- if (t === dn && this.pos + 3 < this.source.length && this.peek() === gn && this.peek(2) === K && this.peek(3) === K)
283
- return this.advance(4), this.make_token(Jr, s, this.pos, i, n);
284
- if (t === K && this.pos + 2 < this.source.length && this.peek() === K && this.peek(2) === xn)
285
- return this.advance(3), this.make_token(en, s, this.pos, i, n);
286
- if (t === mn)
287
- return this.consume_at_keyword(i, n);
288
- if (t === kn)
289
- return this.consume_hash(i, n);
290
- if (Ke(t))
291
- return this.consume_ident_or_function(i, n);
292
- if (t === K) {
293
- let l = this.peek();
294
- if (Ke(l) || l === K)
295
- return this.consume_ident_or_function(i, n);
296
- }
297
- if (t === ts) {
298
- let l = this.peek();
299
- if (l !== 0 && !ne(l))
300
- return this.consume_ident_or_function(i, n);
301
- }
302
- if (t === K || t === Me) {
303
- let l = this.peek();
304
- if (l < 128 && (y[l] & $) !== 0)
305
- return this.consume_number(i, n);
306
- if (l === es) {
307
- let h = this.peek(2);
308
- if (h < 128 && (y[h] & $) !== 0)
309
- return this.consume_number(i, n);
310
- }
311
- }
312
- return this.advance(), this.make_token(xe, s, this.pos, i, n);
313
- }
314
- consume_whitespace(e, t) {
315
- let s = this.pos;
316
- for (; this.pos < this.source.length; ) {
317
- let i = this.source.charCodeAt(this.pos);
318
- if (i >= 128 || (y[i] & (ve | ke)) === 0) break;
319
- this.advance();
320
- }
321
- return this.make_token(hs, s, this.pos, e, t);
322
- }
323
- consume_string(e, t, s) {
324
- let i = this.pos;
325
- for (this.advance(); this.pos < this.source.length; ) {
326
- let n = this.source.charCodeAt(this.pos);
327
- if (n === e)
328
- return this.advance(), this.make_token(Vi, i, this.pos, t, s);
329
- if (ne(n))
330
- return this.make_token(Ri, i, this.pos, t, s);
331
- if (n === ts) {
332
- if (this.advance(), this.pos < this.source.length) {
333
- let l = this.source.charCodeAt(this.pos);
334
- pe(l) ? this.consume_hex_escape() : ne(l) ? this.advance() : this.advance();
335
- }
336
- continue;
337
- }
338
- this.advance();
339
- }
340
- return this.make_token(Ri, i, this.pos, t, s);
341
- }
342
- consume_hex_escape() {
343
- let e = 0;
344
- for (; e < 6 && this.pos < this.source.length; ) {
345
- let t = this.source.charCodeAt(this.pos);
346
- if (!pe(t)) break;
347
- this.advance(), e++;
348
- }
349
- if (this.pos < this.source.length) {
350
- let t = this.source.charCodeAt(this.pos);
351
- (bi(t) || ne(t)) && this.advance();
352
- }
353
- }
354
- consume_number(e, t) {
355
- let s = this.pos, i = this.source.charCodeAt(this.pos);
356
- for ((i === Me || i === K) && this.advance(); this.pos < this.source.length; ) {
357
- let n = this.source.charCodeAt(this.pos);
358
- if (n >= 128 || (y[n] & $) === 0) break;
359
- this.advance();
360
- }
361
- if (this.pos < this.source.length && this.source.charCodeAt(this.pos) === es && this.pos + 1 < this.source.length) {
362
- let n = this.peek();
363
- if (n < 128 && (y[n] & $) !== 0)
364
- for (this.advance(); this.pos < this.source.length; ) {
365
- let l = this.source.charCodeAt(this.pos);
366
- if (l >= 128 || (y[l] & $) === 0) break;
367
- this.advance();
368
- }
369
- }
370
- if (this.pos < this.source.length) {
371
- let n = this.source.charCodeAt(this.pos);
372
- if (n === An || n === En) {
373
- let l = this.peek(), a = l < 128 && (y[l] & $) !== 0, h = this.peek(2), o = h < 128 && (y[h] & $) !== 0;
374
- if (a || (l === Me || l === K) && o) {
375
- if (this.advance(), this.pos < this.source.length) {
376
- let u = this.source.charCodeAt(this.pos);
377
- (u === Me || u === K) && this.advance();
378
- }
379
- for (; this.pos < this.source.length; ) {
380
- let u = this.source.charCodeAt(this.pos);
381
- if (u >= 128 || (y[u] & $) === 0) break;
382
- this.advance();
383
- }
384
- }
385
- }
386
- }
387
- if (this.pos < this.source.length) {
388
- let n = this.source.charCodeAt(this.pos);
389
- if (n === wn)
390
- return this.advance(), this.make_token(ji, s, this.pos, e, t);
391
- if (Ke(n) || n === K && Ke(this.peek())) {
392
- for (; this.pos < this.source.length && at(this.source.charCodeAt(this.pos)); )
393
- this.advance();
394
- return this.make_token(Xi, s, this.pos, e, t);
395
- }
396
- }
397
- return this.make_token(_t, s, this.pos, e, t);
398
- }
399
- consume_ident_or_function(e, t) {
400
- let s = this.pos;
401
- for (; this.pos < this.source.length; ) {
402
- let i = this.source.charCodeAt(this.pos);
403
- if (i === ts) {
404
- if (this.pos + 1 >= this.source.length) break;
405
- let n = this.peek();
406
- if (ne(n)) break;
407
- if (this.advance(), pe(n)) {
408
- this.advance();
409
- for (let l = 0; l < 5 && this.pos < this.source.length && pe(this.source.charCodeAt(this.pos)); l++)
410
- this.advance();
411
- if (this.pos < this.source.length) {
412
- let l = this.source.charCodeAt(this.pos);
413
- (bi(l) || ne(l)) && this.advance();
414
- }
415
- } else
416
- this.advance();
417
- } else if (at(i))
418
- this.advance();
419
- else
420
- break;
421
- }
422
- if (this.pos - s === 1) {
423
- let i = this.source.charCodeAt(s);
424
- if ((i === yn || i === Cn) && this.pos < this.source.length && this.source.charCodeAt(this.pos) === Me)
425
- return this.consume_unicode_range(s, e, t);
426
- }
427
- return this.pos < this.source.length && this.source.charCodeAt(this.pos) === Ti ? (this.advance(), this.make_token(ct, s, this.pos, e, t)) : this.make_token(ae, s, this.pos, e, t);
428
- }
429
- consume_unicode_range(e, t, s) {
430
- this.advance();
431
- let i = 0, n = !1;
432
- for (; this.pos < this.source.length && i < 6; ) {
433
- let l = this.source.charCodeAt(this.pos);
434
- if (pe(l)) {
435
- if (n)
436
- break;
437
- this.advance(), i++;
438
- } else if (l === bn)
439
- this.advance(), i++, n = !0;
440
- else
441
- break;
442
- }
443
- if (n)
444
- return this.make_token(vi, e, this.pos, t, s);
445
- if (this.pos < this.source.length && this.source.charCodeAt(this.pos) === K && this.pos + 1 < this.source.length && pe(this.source.charCodeAt(this.pos + 1))) {
446
- this.advance();
447
- let l = 0;
448
- for (; this.pos < this.source.length && l < 6; ) {
449
- let a = this.source.charCodeAt(this.pos);
450
- if (pe(a))
451
- this.advance(), l++;
452
- else
453
- break;
454
- }
455
- }
456
- return this.make_token(vi, e, this.pos, t, s);
457
- }
458
- consume_at_keyword(e, t) {
459
- let s = this.pos;
460
- for (this.advance(); this.pos < this.source.length && at(this.source.charCodeAt(this.pos)); )
461
- this.advance();
462
- return this.make_token(Zr, s, this.pos, e, t);
463
- }
464
- consume_hash(e, t) {
465
- let s = this.pos;
466
- for (this.advance(); this.pos < this.source.length && at(this.source.charCodeAt(this.pos)); )
467
- this.advance();
468
- return this.make_token(Qi, s, this.pos, e, t);
469
- }
470
- advance(e = 1) {
471
- if (e === 1) {
472
- if (this.pos >= this.source.length) return;
473
- let t = this.source.charCodeAt(this.pos);
474
- this.pos++, ne(t) ? (t === Ni && this.pos < this.source.length && this.source.charCodeAt(this.pos) === Li && this.pos++, this.line++, this.column = 1) : this.column++;
475
- return;
476
- }
477
- for (let t = 0; t < e && !(this.pos >= this.source.length); t++) {
478
- let s = this.source.charCodeAt(this.pos);
479
- this.pos++, ne(s) ? (s === Ni && this.pos < this.source.length && this.source.charCodeAt(this.pos) === Li && (this.pos++, t++), this.line++, this.column = 1) : this.column++;
480
- }
481
- }
482
- peek(e = 1) {
483
- let t = this.pos + e;
484
- return t >= this.source.length ? 0 : this.source.charCodeAt(t);
485
- }
486
- make_token(e, t, s, i = this.line, n = this.column) {
487
- return this.token_type = e, this.token_start = t, this.token_end = s, this.token_line = i, this.token_column = n, e;
488
- }
489
- // Public API: returns Token object for backwards compatibility
490
- next_token(e = !1) {
491
- return this.next_token_fast(e), {
492
- type: this.token_type,
493
- start: this.token_start,
494
- end: this.token_end,
495
- line: this.token_line,
496
- column: this.token_column
497
- };
498
- }
499
- /**
500
- * Save complete lexer state for backtracking
501
- * @returns Object containing all lexer state
502
- */
503
- save_position() {
504
- return {
505
- pos: this.pos,
506
- line: this.line,
507
- column: this.column,
508
- token_type: this.token_type,
509
- token_start: this.token_start,
510
- token_end: this.token_end,
511
- token_line: this.token_line,
512
- token_column: this.token_column
513
- };
514
- }
515
- /**
516
- * Restore lexer state from saved position
517
- * @param saved The saved position to restore
518
- */
519
- restore_position(e) {
520
- this.pos = e.pos, this.line = e.line, this.column = e.column, this.token_type = e.token_type, this.token_start = e.token_start, this.token_end = e.token_end, this.token_line = e.token_line, this.token_column = e.token_column;
521
- }
522
- }
523
- let ht = 36;
524
- const Rn = 1, ut = 2, Be = 3, J = 4, Cs = 5, ir = 6, ft = 7, rr = 10, us = 11, Ge = 12, nr = 13, vn = 14, lr = 15, fs = 16, Tn = 17, or = 18, Sn = 19, Et = 20, ps = 21, ar = 22, hr = 23, We = 24, Te = 25, Ve = 26, pt = 27, ds = 28, cr = 29, Ye = 30, le = 31, _r = 56, On = 32, ur = 33, Nn = 34, Ln = 35, Un = 36, In = 37, Hn = 38, Pn = 39, fr = 40, Dn = 50, Fn = 1, Mn = 2, Ui = 4, zn = 8, qn = 32, pr = 64, Kn = 128, gs = 0, dr = 1, gr = 2, xr = 3, mr = 4, kr = 5, wr = 6, Ce = 0, Ar = 1, Er = 2, oe = class oe {
525
- constructor(e = 1024) {
526
- m(this, "buffer");
527
- m(this, "view");
528
- m(this, "capacity");
529
- // Number of nodes that can fit
530
- m(this, "count");
531
- // Number of nodes currently allocated
532
- m(this, "growth_count");
533
- // Number of times the arena has grown
534
- m(this, "overflow_lengths");
535
- this.capacity = e, this.count = 1, this.growth_count = 0, this.buffer = new ArrayBuffer(e * ht), this.view = new DataView(this.buffer), this.overflow_lengths = /* @__PURE__ */ new Map();
536
- }
537
- // Calculate recommended initial capacity based on CSS source size
538
- static capacity_for_source(e) {
539
- let t = e / 1024, s = Math.ceil(t * oe.NODES_PER_KB), i = Math.ceil(s * oe.CAPACITY_BUFFER);
540
- return Math.max(16, i);
541
- }
542
- // Get the number of nodes currently in the arena
543
- get_count() {
544
- return this.count;
545
- }
546
- // Get the capacity (max nodes without reallocation)
547
- get_capacity() {
548
- return this.capacity;
549
- }
550
- // Get the number of times the arena has grown
551
- get_growth_count() {
552
- return this.growth_count;
553
- }
554
- // Calculate byte offset for a node
555
- node_offset(e) {
556
- return e * ht;
557
- }
558
- // Read node type
559
- get_type(e) {
560
- return this.view.getUint8(this.node_offset(e));
561
- }
562
- // Read node flags
563
- get_flags(e) {
564
- return this.view.getUint8(this.node_offset(e) + 1);
565
- }
566
- // Read start offset in source
567
- get_start_offset(e) {
568
- return this.view.getUint32(this.node_offset(e) + 12, !0);
569
- }
570
- // Read length in source
571
- get_length(e) {
572
- if (this.has_flag(e, Ui)) {
573
- const t = this.overflow_lengths.get(e);
574
- if (t !== void 0)
575
- return t;
576
- }
577
- return this.view.getUint16(this.node_offset(e) + 2, !0);
578
- }
579
- // Read content start offset (stored as delta from startOffset)
580
- get_content_start(e) {
581
- const t = this.get_start_offset(e), s = this.view.getUint16(this.node_offset(e) + 16, !0);
582
- return t + s;
583
- }
584
- // Read content length
585
- get_content_length(e) {
586
- return this.view.getUint16(this.node_offset(e) + 20, !0);
587
- }
588
- // Read attribute operator (for NODE_SELECTOR_ATTRIBUTE)
589
- get_attr_operator(e) {
590
- return this.view.getUint8(this.node_offset(e) + 32);
591
- }
592
- // Read attribute flags (for NODE_SELECTOR_ATTRIBUTE)
593
- get_attr_flags(e) {
594
- return this.view.getUint8(this.node_offset(e) + 33);
595
- }
596
- // Read first child index (0 = no children)
597
- get_first_child(e) {
598
- return this.view.getUint32(this.node_offset(e) + 4, !0);
599
- }
600
- // Read next sibling index (0 = no sibling)
601
- get_next_sibling(e) {
602
- return this.view.getUint32(this.node_offset(e) + 8, !0);
603
- }
604
- // Read start line
605
- get_start_line(e) {
606
- return this.view.getUint32(this.node_offset(e) + 24, !0);
607
- }
608
- // Read start column
609
- get_start_column(e) {
610
- return this.view.getUint32(this.node_offset(e) + 28, !0);
611
- }
612
- // Read value start offset (stored as delta from startOffset, declaration value / at-rule prelude)
613
- get_value_start(e) {
614
- const t = this.get_start_offset(e), s = this.view.getUint16(this.node_offset(e) + 18, !0);
615
- return t + s;
616
- }
617
- // Read value length
618
- get_value_length(e) {
619
- return this.view.getUint16(this.node_offset(e) + 22, !0);
620
- }
621
- // --- Write Methods ---
622
- // Write node type
623
- set_type(e, t) {
624
- this.view.setUint8(this.node_offset(e), t);
625
- }
626
- // Write node flags
627
- set_flags(e, t) {
628
- this.view.setUint8(this.node_offset(e) + 1, t);
629
- }
630
- // Write length in source
631
- set_length(e, t) {
632
- t > 65535 ? (this.view.setUint16(this.node_offset(e) + 2, 65535, !0), this.set_flag(e, Ui), this.overflow_lengths.set(e, t)) : this.view.setUint16(this.node_offset(e) + 2, t, !0);
633
- }
634
- // Write content start delta (offset from startOffset)
635
- set_content_start_delta(e, t) {
636
- this.view.setUint16(this.node_offset(e) + 16, t, !0);
637
- }
638
- // Write content length
639
- set_content_length(e, t) {
640
- this.view.setUint16(this.node_offset(e) + 20, t, !0);
641
- }
642
- // Write attribute operator (for NODE_SELECTOR_ATTRIBUTE)
643
- set_attr_operator(e, t) {
644
- this.view.setUint8(this.node_offset(e) + 32, t);
645
- }
646
- // Write attribute flags (for NODE_SELECTOR_ATTRIBUTE)
647
- set_attr_flags(e, t) {
648
- this.view.setUint8(this.node_offset(e) + 33, t);
649
- }
650
- // Write first child index
651
- set_first_child(e, t) {
652
- this.view.setUint32(this.node_offset(e) + 4, t, !0);
653
- }
654
- // Write next sibling index
655
- set_next_sibling(e, t) {
656
- this.view.setUint32(this.node_offset(e) + 8, t, !0);
657
- }
658
- // Write value start delta (offset from startOffset, declaration value / at-rule prelude)
659
- set_value_start_delta(e, t) {
660
- this.view.setUint16(this.node_offset(e) + 18, t, !0);
661
- }
662
- // Write value length
663
- set_value_length(e, t) {
664
- this.view.setUint16(this.node_offset(e) + 22, t, !0);
665
- }
666
- // --- Node Creation ---
667
- // Grow the arena by 1.3x when capacity is exceeded
668
- grow() {
669
- this.growth_count++;
670
- let e = Math.ceil(this.capacity * oe.GROWTH_FACTOR), t = new ArrayBuffer(e * ht);
671
- new Uint8Array(t).set(new Uint8Array(this.buffer)), this.buffer = t, this.view = new DataView(t), this.capacity = e;
672
- }
673
- // Allocate and initialize a new node with core properties
674
- // Automatically grows the arena if capacity is exceeded
675
- create_node(e, t, s, i, n) {
676
- this.count >= this.capacity && this.grow();
677
- const l = this.count;
678
- this.count++;
679
- const a = l * ht;
680
- return this.view.setUint8(a, e), this.view.setUint32(a + 12, t, !0), this.view.setUint32(a + 24, i, !0), this.view.setUint32(a + 28, n, !0), this.set_length(l, s), l;
681
- }
682
- // --- Tree Building Helpers ---
683
- // Link multiple child nodes to a parent
684
- // Children are linked as siblings in the order provided
685
- append_children(e, t) {
686
- if (t.length === 0) return;
687
- const s = this.node_offset(e);
688
- this.view.setUint32(s + 4, t[0], !0);
689
- for (let i = 0; i < t.length - 1; i++)
690
- this.set_next_sibling(t[i], t[i + 1]);
691
- }
692
- // Check if a node has any children
693
- has_children(e) {
694
- return this.get_first_child(e) !== 0;
695
- }
696
- // Check if a node has a next sibling
697
- has_next_sibling(e) {
698
- return this.get_next_sibling(e) !== 0;
699
- }
700
- // --- Flag Management Helpers ---
701
- // Set a specific flag bit (doesn't clear other flags)
702
- set_flag(e, t) {
703
- let s = this.get_flags(e);
704
- this.set_flags(e, s | t);
705
- }
706
- // Clear a specific flag bit (doesn't affect other flags)
707
- clear_flag(e, t) {
708
- let s = this.get_flags(e);
709
- this.set_flags(e, s & ~t);
710
- }
711
- // Check if a specific flag is set
712
- has_flag(e, t) {
713
- return (this.get_flags(e) & t) !== 0;
714
- }
715
- };
716
- // Stores actual lengths for nodes > 65535 chars
717
- // Growth multiplier when capacity is exceeded
718
- m(oe, "GROWTH_FACTOR", 1.3), // Estimated nodes per KB of CSS (based on real-world data)
719
- // Increased from 270 to 325 to account for VALUE wrapper nodes
720
- // (~20% of nodes are declarations, +1 VALUE node per declaration = +20% nodes)
721
- m(oe, "NODES_PER_KB", 325), // Buffer to avoid frequent growth (15%)
722
- m(oe, "CAPACITY_BUFFER", 1.2);
723
- let gt = oe;
724
- const $n = 32, Bn = 9, Gn = 10, Wn = 13, Yn = 12, Ue = 47, j = 42, M = 45, Qn = 39, Vn = 34, ie = 43, yr = 46, dt = 126, Cr = 62, jn = 38, de = 61, ze = 124, Ii = 36, Hi = 94, Xn = 58;
725
- function re(r) {
726
- return r === $n || r === Bn || r === Gn || r === Wn || r === Yn;
727
- }
728
- function Zn(r) {
729
- return r === Cr || r === ie || r === dt;
730
- }
731
- function ss(r) {
732
- return r >= 48 && r <= 57;
733
- }
734
- function V(r, e) {
735
- if (r.length !== e.length)
736
- return !1;
737
- for (let t = 0; t < r.length; t++) {
738
- let s = r.charCodeAt(t), i = e.charCodeAt(t);
739
- if (i |= 32, s !== i)
740
- return !1;
741
- }
742
- return !0;
743
- }
744
- function Jn(r, e) {
745
- if (r.length < e.length)
746
- return !1;
747
- for (let t = 0; t < e.length; t++) {
748
- let s = r.charCodeAt(t), i = e.charCodeAt(t);
749
- if (s >= 65 && s <= 90 && (s |= 32), s !== i)
750
- return !1;
751
- }
752
- return !0;
753
- }
754
- function el(r, e) {
755
- if (e.length === 0)
756
- return -1;
757
- if (e.length === 1) {
758
- const t = e.charCodeAt(0);
759
- for (let s = 0; s < r.length; s++) {
760
- let i = r.charCodeAt(s);
761
- if (i >= 65 && i <= 90 && (i |= 32), i === t)
762
- return s;
763
- }
764
- return -1;
765
- }
766
- for (let t = 0; t <= r.length - e.length; t++) {
767
- let s = !0;
768
- for (let i = 0; i < e.length; i++) {
769
- let n = r.charCodeAt(t + i), l = e.charCodeAt(i);
770
- if (n >= 65 && n <= 90 && (n |= 32), n !== l) {
771
- s = !1;
772
- break;
773
- }
774
- }
775
- if (s)
776
- return t;
777
- }
778
- return -1;
779
- }
780
- function qe(r, e, t) {
781
- if ((e === void 0 || t === void 0) && (e = 0, t = r.length), r.charCodeAt(e) !== M || r.charCodeAt(e + 1) === M || t - e < 3)
782
- return !1;
783
- for (let i = e + 2; i < t; i++)
784
- if (r.charCodeAt(i) === M)
785
- return !0;
786
- return !1;
787
- }
788
- function tl(r, e, t) {
789
- for (; e < t && re(r.charCodeAt(e)); )
790
- e++;
791
- return e;
792
- }
793
- function be(r, e, t) {
794
- for (; e < t; ) {
795
- let s = r.charCodeAt(e);
796
- if (re(s)) {
797
- e++;
798
- continue;
799
- }
800
- if (s === Ue && e + 1 < t && r.charCodeAt(e + 1) === j) {
801
- for (e += 2; e < t; ) {
802
- if (r.charCodeAt(e) === j && e + 1 < t && r.charCodeAt(e + 1) === Ue) {
803
- e += 2;
804
- break;
805
- }
806
- e++;
807
- }
808
- continue;
809
- }
810
- break;
811
- }
812
- return e;
813
- }
814
- function sl(r, e, t) {
815
- for (; e > t; ) {
816
- let s = r.charCodeAt(e - 1);
817
- if (re(s)) {
818
- e--;
819
- continue;
820
- }
821
- if (e >= 2 && s === Ue && r.charCodeAt(e - 2) === j) {
822
- for (e -= 2; e > t; ) {
823
- if (e >= 2 && r.charCodeAt(e - 2) === Ue && r.charCodeAt(e - 1) === j) {
824
- e -= 2;
825
- break;
826
- }
827
- e--;
828
- }
829
- continue;
830
- }
831
- break;
832
- }
833
- return e;
834
- }
835
- function is(r) {
836
- let e = 0;
837
- for (let n = 0; n < r.length; n++) {
838
- let l = r.charCodeAt(n);
839
- if (l === 101 || l === 69) {
840
- if (n + 1 < r.length) {
841
- let a = r.charCodeAt(n + 1);
842
- if (ss(a)) {
843
- e = n + 1;
844
- continue;
845
- }
846
- if ((a === 43 || a === 45) && n + 2 < r.length) {
847
- let h = r.charCodeAt(n + 2);
848
- if (ss(h)) {
849
- e = n + 1;
850
- continue;
851
- }
852
- }
853
- }
854
- break;
855
- }
856
- if (ss(l) || l === yr || l === M || l === ie)
857
- e = n + 1;
858
- else
859
- break;
860
- }
861
- let t = r.substring(0, e), s = r.substring(e);
862
- return { value: t ? parseFloat(t) : 0, unit: s };
863
- }
864
- const il = {
865
- [Rn]: "StyleSheet",
866
- [ut]: "Rule",
867
- [Be]: "Atrule",
868
- [J]: "Declaration",
869
- [Cs]: "Selector",
870
- [ir]: "Comment",
871
- [ft]: "Block",
872
- [rr]: "Identifier",
873
- [us]: "Number",
874
- [Ge]: "Dimension",
875
- [nr]: "String",
876
- [vn]: "Hash",
877
- [lr]: "Function",
878
- [fs]: "Operator",
879
- [Tn]: "Parentheses",
880
- [or]: "Url",
881
- [Sn]: "UnicodeRange",
882
- [Dn]: "Value",
883
- [Et]: "SelectorList",
884
- [ps]: "TypeSelector",
885
- [ar]: "ClassSelector",
886
- [hr]: "IdSelector",
887
- [We]: "AttributeSelector",
888
- [Te]: "PseudoClassSelector",
889
- [Ve]: "PseudoElementSelector",
890
- [pt]: "Combinator",
891
- [ds]: "UniversalSelector",
892
- [cr]: "NestingSelector",
893
- [Ye]: "Nth",
894
- [le]: "NthOf",
895
- [_r]: "Lang",
896
- [On]: "MediaQuery",
897
- [ur]: "Feature",
898
- [Nn]: "MediaType",
899
- [Ln]: "ContainerQuery",
900
- [Un]: "SupportsQuery",
901
- [In]: "Layer",
902
- [Hn]: "Operator",
903
- [Pn]: "MediaFeatureRange",
904
- [fr]: "AtrulePrelude"
905
- }, rl = {
906
- [gs]: null,
907
- [dr]: "=",
908
- [gr]: "~=",
909
- [xr]: "|=",
910
- [mr]: "^=",
911
- [kr]: "$=",
912
- [wr]: "*="
913
- }, nl = {
914
- [Ce]: null,
915
- [Ar]: "i",
916
- [Er]: "s"
917
- };
918
- class je {
919
- constructor(e, t, s) {
920
- m(this, "arena");
921
- m(this, "source");
922
- m(this, "index");
923
- this.arena = e, this.source = t, this.index = s;
924
- }
925
- /**
926
- * @internal
927
- * Get the arena (for internal/advanced use only)
928
- */
929
- __get_arena() {
930
- return this.arena;
931
- }
932
- get_content() {
933
- let e = this.arena.get_content_start(this.index), t = this.arena.get_content_length(this.index);
934
- return t === 0 ? "" : this.source.substring(e, e + t);
935
- }
936
- /** Get node type as number (for performance) */
937
- get type() {
938
- return this.arena.get_type(this.index);
939
- }
940
- /** Get node type as human-readable string */
941
- get type_name() {
942
- return il[this.type] || "unknown";
943
- }
944
- /** Get the full text of this node from source */
945
- get text() {
946
- let e = this.arena.get_start_offset(this.index), t = this.arena.get_length(this.index);
947
- return this.source.substring(e, e + t);
948
- }
949
- /** Get the "content" text (at-rule name for at-rules, layer name for import layers) */
950
- get name() {
951
- let { type: e } = this;
952
- if (!(e === J || e === fs || e === Cs))
953
- return this.get_content();
954
- }
955
- /**
956
- * Alias for name (for declarations: "color" in "color: blue")
957
- * More semantic than `name` for declaration nodes
958
- */
959
- get property() {
960
- let { type: e } = this;
961
- if (!(e !== J && e !== ur))
962
- return this.get_content();
963
- }
964
- /**
965
- * Get the value text (for declarations: "blue" in "color: blue")
966
- * For dimension/number nodes: returns the numeric value as a number
967
- * For string nodes: returns the string content without quotes
968
- * For URL nodes with quoted string: returns the string with quotes (consistent with STRING node)
969
- * For URL nodes with unquoted URL: returns the URL content without quotes
970
- */
971
- get value() {
972
- let { type: e, text: t, first_child: s } = this;
973
- if (e === J && s)
974
- return s;
975
- if (e === Ge)
976
- return is(t).value;
977
- if (e === us)
978
- return Number.parseFloat(t);
979
- if (e === or) {
980
- if ((s == null ? void 0 : s.type) === nr)
981
- return s.text;
982
- if (Jn(t, "url(")) {
983
- let l = t.indexOf("("), a = t.lastIndexOf(")");
984
- if (l !== -1 && a !== -1 && a > l)
985
- return t.substring(l + 1, a).trim();
986
- } else if (t.startsWith('"') || t.startsWith("'"))
987
- return t;
988
- }
989
- if (e === fs)
990
- return this.get_content();
991
- let i = this.arena.get_value_start(this.index), n = this.arena.get_value_length(this.index);
992
- return n === 0 ? null : this.source.substring(i, i + n);
993
- }
994
- /** Get the numeric value for NUMBER and DIMENSION nodes, or null for other node types */
995
- get value_as_number() {
996
- let { text: e, type: t } = this;
997
- return t === us ? Number.parseFloat(e) : t === Ge ? is(e).value : null;
998
- }
999
- /**
1000
- * Get the prelude node:
1001
- * - For at-rules: AT_RULE_PRELUDE wrapper containing structured prelude children (media queries, layer names, etc.)
1002
- * - For style rules: SELECTOR_LIST or SELECTOR node
1003
- * Returns null if no prelude exists
1004
- */
1005
- get prelude() {
1006
- if (this.type === Be) {
1007
- let e = this.first_child;
1008
- return e && e.type === fr ? e : null;
1009
- }
1010
- if (this.type === ut)
1011
- return this.first_child;
1012
- }
1013
- /**
1014
- * Get the attribute operator (for attribute selectors: =, ~=, |=, ^=, $=, *=)
1015
- * Returns one of the ATTR_OPERATOR_* constants
1016
- */
1017
- get attr_operator() {
1018
- if (this.type === We)
1019
- return this.arena.get_attr_operator(this.index);
1020
- }
1021
- /**
1022
- * Get the attribute flags (for attribute selectors: i, s)
1023
- * Returns one of the ATTR_FLAG_* constants
1024
- */
1025
- get attr_flags() {
1026
- if (this.type === We)
1027
- return this.arena.get_attr_flags(this.index);
1028
- }
1029
- /** Get the unit for dimension nodes (e.g., "px" from "100px", "%" from "50%") */
1030
- get unit() {
1031
- if (this.type === Ge)
1032
- return is(this.text).unit;
1033
- }
1034
- /** Check if this declaration has !important */
1035
- get is_important() {
1036
- if (this.type === J)
1037
- return this.arena.has_flag(this.index, Fn);
1038
- }
1039
- /** Check if this declaration has a browser hack prefix */
1040
- get is_browserhack() {
1041
- if (this.type === J)
1042
- return this.arena.has_flag(this.index, Kn);
1043
- }
1044
- /** Check if this has a vendor prefix (computed on-demand) */
1045
- get is_vendor_prefixed() {
1046
- switch (this.type) {
1047
- case J:
1048
- return qe(this.get_content());
1049
- case Te:
1050
- case Ve:
1051
- return qe(this.get_content());
1052
- case Be:
1053
- return qe(this.get_content());
1054
- case lr:
1055
- return qe(this.get_content());
1056
- case rr:
1057
- return qe(this.text);
1058
- default:
1059
- return !1;
1060
- }
1061
- }
1062
- /** Check if this node has an error */
1063
- get has_error() {
1064
- return this.arena.has_flag(this.index, Mn);
1065
- }
1066
- /** Check if this node has a prelude (at-rules and style rules) */
1067
- get has_prelude() {
1068
- let { type: e } = this;
1069
- return e === Be ? this.arena.get_value_length(this.index) > 0 : e === ut ? this.first_child !== null : !1;
1070
- }
1071
- /** Check if this rule has a block { } */
1072
- get has_block() {
1073
- return this.arena.has_flag(this.index, zn);
1074
- }
1075
- /** Check if this style rule has declarations */
1076
- get has_declarations() {
1077
- return this.arena.has_flag(this.index, qn);
1078
- }
1079
- /** Get the block node (for style rules and at-rules with blocks) */
1080
- get block() {
1081
- let { type: e } = this;
1082
- if (e === ut) {
1083
- let t = this.first_child;
1084
- if (!t) return null;
1085
- let s = t.next_sibling;
1086
- return (s == null ? void 0 : s.type) === ft ? s : null;
1087
- }
1088
- if (e === Be) {
1089
- let t = this.first_child;
1090
- for (; t; ) {
1091
- if (t.type === ft && !t.next_sibling)
1092
- return t;
1093
- t = t.next_sibling;
1094
- }
1095
- return null;
1096
- }
1097
- return null;
1098
- }
1099
- /** Check if this block is empty (no declarations or rules, only comments allowed) */
1100
- get is_empty() {
1101
- if (this.type !== ft) return;
1102
- let e = this.first_child;
1103
- for (; e; ) {
1104
- if (e.type !== ir)
1105
- return !1;
1106
- e = e.next_sibling;
1107
- }
1108
- return !0;
1109
- }
1110
- /** Get start line number */
1111
- get line() {
1112
- return this.arena.get_start_line(this.index);
1113
- }
1114
- /** Get start column number */
1115
- get column() {
1116
- return this.arena.get_start_column(this.index);
1117
- }
1118
- /** Get start offset in source */
1119
- get start() {
1120
- return this.arena.get_start_offset(this.index);
1121
- }
1122
- /** Get length in source */
1123
- get length() {
1124
- return this.arena.get_length(this.index);
1125
- }
1126
- /**
1127
- * Get end offset in source
1128
- * End is not stored, must be calculated
1129
- */
1130
- get end() {
1131
- return this.start + this.length;
1132
- }
1133
- // --- Tree Traversal ---
1134
- /** Get first child node */
1135
- get first_child() {
1136
- let e = this.arena.get_first_child(this.index);
1137
- return e === 0 ? null : new je(this.arena, this.source, e);
1138
- }
1139
- /** Get next sibling node */
1140
- get next_sibling() {
1141
- let e = this.arena.get_next_sibling(this.index);
1142
- return e === 0 ? null : new je(this.arena, this.source, e);
1143
- }
1144
- /** Check if this node has a next sibling */
1145
- get has_next() {
1146
- return this.arena.get_next_sibling(this.index) !== 0;
1147
- }
1148
- /**
1149
- * Check if this node has children
1150
- * For pseudo-class/pseudo-element functions, returns true if FLAG_HAS_PARENS is set
1151
- * This allows formatters to distinguish :lang() from :hover
1152
- */
1153
- get has_children() {
1154
- let { type: e } = this;
1155
- return (e === Te || e === Ve) && this.arena.has_flag(this.index, pr) ? !0 : this.arena.has_children(this.index);
1156
- }
1157
- /** Get all children as an array */
1158
- get children() {
1159
- let e = [], t = this.first_child;
1160
- for (; t; )
1161
- e.push(t), t = t.next_sibling;
1162
- return e;
1163
- }
1164
- /** Make CSSNode iterable over its children */
1165
- *[Symbol.iterator]() {
1166
- let e = this.first_child;
1167
- for (; e; )
1168
- yield e, e = e.next_sibling;
1169
- }
1170
- // --- An+B Expression Helpers (for NODE_SELECTOR_NTH) ---
1171
- /** Get the 'a' coefficient from An+B expression (e.g., "2n" from "2n+1", "odd" from "odd") */
1172
- get nth_a() {
1173
- let { type: e, arena: t, index: s } = this;
1174
- if (e !== Ye && e !== le) return;
1175
- let i = t.get_content_length(s);
1176
- if (i === 0) return;
1177
- let n = t.get_content_start(s);
1178
- return this.source.substring(n, n + i);
1179
- }
1180
- /** Get the 'b' coefficient from An+B expression (e.g., "+1" from "2n+1") */
1181
- get nth_b() {
1182
- let { type: e, arena: t, index: s, source: i } = this;
1183
- if (e !== Ye && e !== le) return;
1184
- let n = t.get_value_length(s);
1185
- if (n === 0) return;
1186
- let l = t.get_value_start(s), a = i.substring(l, l + n), h = l - 1;
1187
- for (; h >= 0; ) {
1188
- let o = i.charCodeAt(h);
1189
- if (re(o)) {
1190
- h--;
1191
- continue;
1192
- }
1193
- o === M ? a = "-" + a : o === ie && (a = "+" + a);
1194
- break;
1195
- }
1196
- return a;
1197
- }
1198
- // --- Pseudo-Class Nth-Of Helpers (for NODE_SELECTOR_NTH_OF) ---
1199
- /** Get the An+B formula node from :nth-child(2n+1 of .foo) */
1200
- get nth() {
1201
- if (this.type === le)
1202
- return this.first_child ?? void 0;
1203
- }
1204
- /** Get the selector list from :nth-child(2n+1 of .foo) */
1205
- get selector() {
1206
- if (this.type !== le) return;
1207
- let e = this.first_child;
1208
- return (e == null ? void 0 : e.next_sibling) ?? void 0;
1209
- }
1210
- // --- Pseudo-Class Selector List Helper ---
1211
- /**
1212
- * Get selector list from pseudo-class functions
1213
- * Works for :is(.a), :not(.b), :has(.c), :where(.d), :nth-child(2n of .e)
1214
- */
1215
- get selector_list() {
1216
- if (this.type !== Te) return;
1217
- let e = this.first_child;
1218
- if (e) {
1219
- if (e.type === Et)
1220
- return e;
1221
- if (e.type === le)
1222
- return e.selector;
1223
- }
1224
- }
1225
- // --- Node Cloning ---
1226
- /**
1227
- * Clone this node as a mutable plain JavaScript object with children as arrays.
1228
- * See API.md for examples.
1229
- *
1230
- * @param options - Cloning configuration
1231
- * @param options.deep - Recursively clone children (default: true)
1232
- * @param options.locations - Include line/column/start/length (default: false)
1233
- */
1234
- clone(e = {}) {
1235
- const { deep: t = !0, locations: s = !1 } = e;
1236
- let { type: i, name: n, property: l, value: a, unit: h } = this, o = {
1237
- type: i,
1238
- type_name: this.type_name,
1239
- text: this.text
1240
- };
1241
- if (n && (o.name = n), l && (o.property = l), a && (o.value = a, h && (o.unit = h)), i === J) {
1242
- let { is_important: d, is_browserhack: f } = this;
1243
- d && (o.is_important = !0), f && (o.is_browserhack = !0);
1244
- }
1245
- let { is_vendor_prefixed: u, has_error: p } = this;
1246
- if (u && (o.is_vendor_prefixed = !0), p && (o.has_error = !0), i === We && (o.attr_operator = rl[this.attr_operator], o.attr_flags = nl[this.attr_flags]), (i === Ye || i === le) && (o.nth_a = this.nth_a, o.nth_b = this.nth_b), s && (o.line = this.line, o.column = this.column, o.start = this.start, o.length = this.length, o.end = this.end), t && i !== J) {
1247
- o.children = [];
1248
- for (let d of this.children)
1249
- o.children.push(d.clone({ deep: !0, locations: s }));
1250
- }
1251
- return o;
1252
- }
1253
- }
1254
- class Pi {
1255
- constructor(e, t) {
1256
- m(this, "lexer");
1257
- m(this, "arena");
1258
- m(this, "source");
1259
- m(this, "expr_end");
1260
- this.arena = e, this.source = t, this.lexer = new sr(t), this.expr_end = 0;
1261
- }
1262
- /**
1263
- * Parse An+B expression
1264
- * Examples: odd, even, 3, n, -n, 2n, 2n+1, -3n-5
1265
- */
1266
- parse_anplusb(e, t, s = 1) {
1267
- this.expr_end = t, this.lexer.pos = e, this.lexer.line = s;
1268
- let i = null, n = e, l = e, a = e, h = e;
1269
- const o = e;
1270
- if (this.skip_whitespace(), this.lexer.pos >= this.expr_end)
1271
- return null;
1272
- if (this.lexer.next_token_fast(!0), this.lexer.token_type === ae) {
1273
- const u = this.source.substring(this.lexer.token_start, this.lexer.token_end);
1274
- if (V("odd", u) || V("even", u))
1275
- return n = this.lexer.token_start, l = this.lexer.token_end, this.create_anplusb_node(o, n, l, 0, 0);
1276
- const p = this.source.charCodeAt(this.lexer.token_start), d = this.lexer.token_end > this.lexer.token_start + 1 ? this.source.charCodeAt(this.lexer.token_start + 1) : 0;
1277
- return p === M && d === 110 ? this.lexer.token_end > this.lexer.token_start + 2 && this.source.charCodeAt(this.lexer.token_start + 2) === M ? (n = this.lexer.token_start, l = this.lexer.token_start + 2, i = this.source.substring(this.lexer.token_start + 2, this.lexer.token_end), a = this.lexer.token_start + 2, h = this.lexer.token_end, this.create_anplusb_node(o, n, l, a, h)) : (n = this.lexer.token_start, l = this.lexer.token_start + 2, i = this.parse_b_part(), i !== null && (a = this.lexer.token_start, h = this.lexer.token_end), this.create_anplusb_node(o, n, l, i !== null ? a : 0, i !== null ? h : 0)) : p === 110 ? this.lexer.token_end > this.lexer.token_start + 1 && this.source.charCodeAt(this.lexer.token_start + 1) === M ? (n = this.lexer.token_start, l = this.lexer.token_start + 1, i = this.source.substring(this.lexer.token_start + 1, this.lexer.token_end), a = this.lexer.token_start + 1, h = this.lexer.token_end, this.create_anplusb_node(o, n, l, a, h)) : (n = this.lexer.token_start, l = this.lexer.token_start + 1, i = this.parse_b_part(), i !== null && (a = this.lexer.token_start, h = this.lexer.token_end), this.create_anplusb_node(o, n, l, i !== null ? a : 0, i !== null ? h : 0)) : null;
1278
- }
1279
- if (this.lexer.token_type === xe && this.source.charCodeAt(this.lexer.token_start) === ie) {
1280
- const u = this.lexer.save_position();
1281
- if (this.lexer.next_token_fast(!0), this.lexer.token_type === ae && this.source.substring(this.lexer.token_start, this.lexer.token_end).charCodeAt(0) === 110)
1282
- return n = u.pos - 1, l = this.lexer.token_start + 1, this.lexer.token_end > this.lexer.token_start + 1 && this.source.charCodeAt(this.lexer.token_start + 1) === M ? (i = this.source.substring(this.lexer.token_start + 1, this.lexer.token_end), a = this.lexer.token_start + 1, h = this.lexer.token_end, this.create_anplusb_node(o, n, l, a, h)) : (i = this.parse_b_part(), i !== null && (a = this.lexer.token_start, h = this.lexer.token_end), this.create_anplusb_node(o, n, l, i !== null ? a : 0, i !== null ? h : 0));
1283
- this.lexer.restore_position(u);
1284
- }
1285
- if (this.lexer.token_type === Xi) {
1286
- const u = this.source.substring(this.lexer.token_start, this.lexer.token_end), p = el(u, "n");
1287
- if (p !== -1) {
1288
- if (n = this.lexer.token_start, l = this.lexer.token_start + p + 1, p + 1 < u.length) {
1289
- const d = u.substring(p + 1);
1290
- if (d.charCodeAt(0) === M)
1291
- return i = d, a = this.lexer.token_start + p + 1, h = this.lexer.token_end, this.create_anplusb_node(o, n, l, a, h);
1292
- }
1293
- return i = this.parse_b_part(), i !== null && (a = this.lexer.token_start, h = this.lexer.token_end), this.create_anplusb_node(o, n, l, a, h);
1294
- }
1295
- }
1296
- return this.lexer.token_type === _t ? (i = this.source.substring(this.lexer.token_start, this.lexer.token_end), a = this.lexer.token_start, h = this.lexer.token_end, this.create_anplusb_node(o, 0, 0, a, h)) : null;
1297
- }
1298
- /**
1299
- * Parse the b part after 'n'
1300
- * Handles: +5, -3, whitespace variations
1301
- */
1302
- parse_b_part() {
1303
- if (this.skip_whitespace(), this.lexer.pos >= this.expr_end)
1304
- return null;
1305
- if (this.lexer.next_token_fast(!0), this.lexer.token_type === xe) {
1306
- const e = this.source.charCodeAt(this.lexer.token_start);
1307
- if (e === ie || e === M) {
1308
- const t = e === M ? "-" : "";
1309
- if (this.skip_whitespace(), this.lexer.next_token_fast(!0), this.lexer.token_type === _t) {
1310
- let s = this.source.substring(this.lexer.token_start, this.lexer.token_end);
1311
- return s.charCodeAt(0) === ie && (s = s.substring(1)), t === "-" ? t + s : s;
1312
- }
1313
- }
1314
- }
1315
- if (this.lexer.token_type === _t) {
1316
- let e = this.source.substring(this.lexer.token_start, this.lexer.token_end);
1317
- const t = e.charCodeAt(0);
1318
- if (t === ie || t === M)
1319
- return t === ie && (e = e.substring(1)), e;
1320
- }
1321
- return null;
1322
- }
1323
- skip_whitespace() {
1324
- this.lexer.pos = be(this.source, this.lexer.pos, this.expr_end);
1325
- }
1326
- create_anplusb_node(e, t, s, i, n) {
1327
- const l = this.arena.create_node(Ye, e, this.lexer.pos - e, this.lexer.line, 1);
1328
- return s > t && (this.arena.set_content_start_delta(l, t - e), this.arena.set_content_length(l, s - t)), n > i && (this.arena.set_value_start_delta(l, i - e), this.arena.set_value_length(l, n - i)), l;
1329
- }
1330
- }
1331
- class ll {
1332
- constructor(e, t) {
1333
- m(this, "lexer");
1334
- m(this, "arena");
1335
- m(this, "source");
1336
- m(this, "selector_end");
1337
- this.arena = e, this.source = t, this.lexer = new sr(t), this.selector_end = 0;
1338
- }
1339
- // Parse a selector range into selector nodes (standalone use)
1340
- // Always returns a NODE_SELECTOR_LIST with selector components as children
1341
- parse_selector(e, t, s = 1, i = 1, n = !0) {
1342
- return this.selector_end = t, this.lexer.pos = e, this.lexer.line = s, this.lexer.column = i, this.parse_selector_list(n);
1343
- }
1344
- // Parse comma-separated selectors
1345
- parse_selector_list(e = !0) {
1346
- let t = [], s = this.lexer.pos, i = this.lexer.line, n = this.lexer.column;
1347
- for (; this.lexer.pos < this.selector_end; ) {
1348
- let l = this.lexer.pos, a = this.lexer.line, h = this.lexer.column, o = this.parse_complex_selector(e);
1349
- if (o !== null) {
1350
- let p = this.arena.create_node(
1351
- Cs,
1352
- l,
1353
- this.lexer.pos - l,
1354
- a,
1355
- h
1356
- );
1357
- this.arena.set_content_start_delta(p, 0), this.arena.set_content_length(p, this.lexer.pos - l);
1358
- let d = o, f = this.arena.get_next_sibling(d);
1359
- for (; f !== 0; )
1360
- d = f, f = this.arena.get_next_sibling(d);
1361
- this.arena.set_first_child(p, o), t.push(p);
1362
- }
1363
- if (this.skip_whitespace(), this.lexer.pos >= this.selector_end) break;
1364
- if (this.lexer.next_token_fast(!1), this.lexer.token_type === $e) {
1365
- this.skip_whitespace();
1366
- continue;
1367
- } else
1368
- break;
1369
- }
1370
- if (t.length >= 1) {
1371
- let l = this.arena.create_node(Et, s, this.lexer.pos - s, i, n);
1372
- return this.arena.append_children(l, t), l;
1373
- }
1374
- return null;
1375
- }
1376
- // Parse a complex selector (with combinators)
1377
- // e.g., "div.class > p + span"
1378
- // Also supports CSS Nesting relaxed syntax: "> a", "~ span", etc.
1379
- parse_complex_selector(e = !0) {
1380
- let t = [];
1381
- if (this.skip_whitespace(), e && this.lexer.pos < this.selector_end) {
1382
- const s = this.lexer.save_position();
1383
- if (this.lexer.next_token_fast(!1), this.lexer.token_type === xe) {
1384
- let n = this.source.charCodeAt(this.lexer.token_start);
1385
- if (n === Cr || n === ie || n === dt) {
1386
- let l = this.create_node_at(
1387
- pt,
1388
- this.lexer.token_start,
1389
- this.lexer.token_end,
1390
- this.lexer.token_line,
1391
- this.lexer.token_column
1392
- );
1393
- t.push(l), this.skip_whitespace();
1394
- } else
1395
- this.lexer.restore_position(s);
1396
- } else
1397
- this.lexer.restore_position(s);
1398
- }
1399
- for (; this.lexer.pos < this.selector_end; ) {
1400
- let s = this.parse_compound_selector();
1401
- if (s !== null)
1402
- t.push(s);
1403
- else
1404
- break;
1405
- let i = this.try_parse_combinator();
1406
- if (i !== null) {
1407
- t.push(i), this.skip_whitespace();
1408
- continue;
1409
- }
1410
- const n = this.lexer.save_position();
1411
- if (this.skip_whitespace(), this.lexer.pos >= this.selector_end) {
1412
- this.lexer.restore_position(n);
1413
- break;
1414
- }
1415
- if (this.lexer.next_token_fast(!1), this.lexer.token_type === $e || this.lexer.pos >= this.selector_end) {
1416
- this.lexer.restore_position(n);
1417
- break;
1418
- }
1419
- this.lexer.restore_position(n);
1420
- break;
1421
- }
1422
- if (t.length === 0) return null;
1423
- for (let s = 0; s < t.length - 1; s++) {
1424
- let i = t[s];
1425
- for (; this.arena.get_next_sibling(i) !== 0; )
1426
- i = this.arena.get_next_sibling(i);
1427
- this.arena.set_next_sibling(i, t[s + 1]);
1428
- }
1429
- return t[0];
1430
- }
1431
- // Parse a compound selector (no combinators)
1432
- // e.g., "div.class#id[attr]:hover"
1433
- parse_compound_selector() {
1434
- let e = [];
1435
- for (; this.lexer.pos < this.selector_end; ) {
1436
- const t = this.lexer.save_position();
1437
- if (this.lexer.next_token_fast(!1), this.lexer.token_start >= this.selector_end || this.lexer.token_type === _s) break;
1438
- let i = this.parse_simple_selector();
1439
- if (i !== null)
1440
- e.push(i);
1441
- else {
1442
- this.lexer.restore_position(t);
1443
- break;
1444
- }
1445
- }
1446
- if (e.length === 0) return null;
1447
- for (let t = 0; t < e.length - 1; t++)
1448
- this.arena.set_next_sibling(e[t], e[t + 1]);
1449
- return e[0];
1450
- }
1451
- // Parse a simple selector (single component)
1452
- parse_simple_selector() {
1453
- let e = this.lexer.token_type, t = this.lexer.token_start, s = this.lexer.token_end;
1454
- switch (e) {
1455
- case ae:
1456
- return this.parse_type_or_namespace_selector(t, s);
1457
- case Qi:
1458
- return this.create_node(hr, t, s);
1459
- case xe:
1460
- let i = this.source.charCodeAt(t);
1461
- return i === yr ? this.parse_class_selector(t) : i === j ? this.parse_universal_or_namespace_selector(t, s) : i === jn ? this.create_node(cr, t, s) : i === ze ? this.parse_empty_namespace_selector(t) : null;
1462
- case cs:
1463
- return this.parse_attribute_selector(t);
1464
- case Zi:
1465
- return this.parse_pseudo(t);
1466
- case ct:
1467
- return this.parse_pseudo_function(t, s);
1468
- case ji:
1469
- return this.create_node(Ge, t, s);
1470
- case hs:
1471
- case $e:
1472
- return null;
1473
- default:
1474
- return null;
1475
- }
1476
- }
1477
- // Parse the local part after | in a namespace selector (E or *)
1478
- // Returns the node type (TYPE or UNIVERSAL) or null if invalid
1479
- parse_namespace_local_part(e, t, s) {
1480
- const i = this.lexer.save_position();
1481
- this.lexer.next_token_fast(!1);
1482
- let n;
1483
- if (this.lexer.token_type === ae)
1484
- n = ps;
1485
- else if (this.lexer.token_type === xe && this.source.charCodeAt(this.lexer.token_start) === j)
1486
- n = ds;
1487
- else
1488
- return this.lexer.restore_position(i), null;
1489
- let l = this.create_node(n, e, this.lexer.token_end);
1490
- return this.arena.set_content_start_delta(l, t - e), this.arena.set_content_length(l, s), l;
1491
- }
1492
- // Parse type selector or namespace selector (ns|E or ns|*)
1493
- // Called when we've seen an IDENT token
1494
- parse_type_or_namespace_selector(e, t) {
1495
- const s = this.lexer.save_position();
1496
- if (this.skip_whitespace(), this.lexer.pos < this.selector_end && this.source.charCodeAt(this.lexer.pos) === ze) {
1497
- this.lexer.pos++;
1498
- let i = this.parse_namespace_local_part(e, e, t - e);
1499
- if (i !== null) return i;
1500
- this.lexer.pos = t;
1501
- } else
1502
- this.lexer.restore_position(s);
1503
- return this.create_node(ps, e, t);
1504
- }
1505
- // Parse universal selector or namespace selector (*|E or *|*)
1506
- // Called when we've seen a * DELIM token
1507
- parse_universal_or_namespace_selector(e, t) {
1508
- const s = this.lexer.save_position();
1509
- if (this.skip_whitespace(), this.lexer.pos < this.selector_end && this.source.charCodeAt(this.lexer.pos) === ze) {
1510
- this.lexer.pos++;
1511
- let i = this.parse_namespace_local_part(e, e, t - e);
1512
- if (i !== null) return i;
1513
- this.lexer.pos = t;
1514
- } else
1515
- this.lexer.restore_position(s);
1516
- return this.create_node(ds, e, t);
1517
- }
1518
- // Parse empty namespace selector (|E or |*)
1519
- // Called when we've seen a | DELIM token at the start
1520
- parse_empty_namespace_selector(e) {
1521
- return this.parse_namespace_local_part(e, e, 1);
1522
- }
1523
- // Parse combinator (>, +, ~, or descendant space)
1524
- try_parse_combinator() {
1525
- let e = this.lexer.pos, t = this.lexer.line, s = this.lexer.column, i = this.lexer.pos < this.selector_end;
1526
- if (this.skip_whitespace(), i = i && this.lexer.pos > e, this.lexer.pos >= this.selector_end)
1527
- return this.lexer.pos = e, this.lexer.line = t, this.lexer.column = s, null;
1528
- if (this.lexer.next_token_fast(!1), this.lexer.token_type === xe) {
1529
- let n = this.source.charCodeAt(this.lexer.token_start);
1530
- if (Zn(n))
1531
- return this.create_node_at(pt, this.lexer.token_start, this.lexer.token_end, this.lexer.token_line, this.lexer.token_column);
1532
- }
1533
- return i ? (this.lexer.pos = e, this.lexer.line = t, this.lexer.column = s, this.skip_whitespace(), this.create_node_at(pt, e, this.lexer.pos, t, s)) : (this.lexer.pos = e, this.lexer.line = t, this.lexer.column = s, null);
1534
- }
1535
- // Parse class selector (.classname)
1536
- parse_class_selector(e) {
1537
- const t = this.lexer.save_position();
1538
- return this.lexer.next_token_fast(!1), this.lexer.token_type !== ae ? (this.lexer.restore_position(t), null) : this.create_node(ar, e, this.lexer.token_end);
1539
- }
1540
- // Parse attribute selector ([attr], [attr=value], etc.)
1541
- parse_attribute_selector(e) {
1542
- let t = 1, s = this.lexer.token_end, i = e + 1, n = i;
1543
- for (; this.lexer.pos < this.selector_end && t > 0; ) {
1544
- this.lexer.next_token_fast(!1);
1545
- let a = this.lexer.token_type;
1546
- if (a === cs)
1547
- t++;
1548
- else if (a === Ji && (t--, t === 0)) {
1549
- n = this.lexer.token_start, s = this.lexer.token_end;
1550
- break;
1551
- }
1552
- }
1553
- let l = this.create_node(We, e, s);
1554
- return this.parse_attribute_content(l, i, n), l;
1555
- }
1556
- // Parse attribute content to extract name, operator, and value
1557
- parse_attribute_content(e, t, s) {
1558
- if (t = be(this.source, t, s), s = sl(this.source, s, t), t >= s) return;
1559
- let i = t, n = t, l = -1, a = -1, h = -1;
1560
- for (; n < s; ) {
1561
- let f = this.source.charCodeAt(n);
1562
- if (re(f) || f === de || f === dt || f === ze || f === Hi || f === Ii || f === j)
1563
- break;
1564
- n++;
1565
- }
1566
- n > i && (this.arena.set_content_start_delta(e, i - this.arena.get_start_offset(e)), this.arena.set_content_length(e, n - i));
1567
- let o = be(this.source, n, s);
1568
- if (o >= s) {
1569
- this.arena.set_attr_operator(e, gs), this.arena.set_attr_flags(e, Ce);
1570
- return;
1571
- }
1572
- let u = this.source.charCodeAt(o), p = o + 1 < s ? this.source.charCodeAt(o + 1) : 0;
1573
- if (u === de)
1574
- l = o + 1, this.arena.set_attr_operator(e, dr);
1575
- else if (u === dt && p === de)
1576
- l = o + 2, this.arena.set_attr_operator(e, gr);
1577
- else if (u === ze && p === de)
1578
- l = o + 2, this.arena.set_attr_operator(e, xr);
1579
- else if (u === Hi && p === de)
1580
- l = o + 2, this.arena.set_attr_operator(e, mr);
1581
- else if (u === Ii && p === de)
1582
- l = o + 2, this.arena.set_attr_operator(e, kr);
1583
- else if (u === j && p === de)
1584
- l = o + 2, this.arena.set_attr_operator(e, wr);
1585
- else {
1586
- this.arena.set_attr_operator(e, gs), this.arena.set_attr_flags(e, Ce);
1587
- return;
1588
- }
1589
- if (o = be(this.source, l, s), o >= s) {
1590
- this.arena.set_attr_flags(e, Ce);
1591
- return;
1592
- }
1593
- a = o;
1594
- let d = this.source.charCodeAt(o);
1595
- if (d === Qn || d === Vn) {
1596
- let f = d;
1597
- for (a = o, o++; o < s; ) {
1598
- let L = this.source.charCodeAt(o);
1599
- if (L === f) {
1600
- o++;
1601
- break;
1602
- }
1603
- L === 92 ? o += 2 : o++;
1604
- }
1605
- h = o;
1606
- } else {
1607
- for (; o < s; ) {
1608
- let f = this.source.charCodeAt(o);
1609
- if (re(f))
1610
- break;
1611
- o++;
1612
- }
1613
- h = o;
1614
- }
1615
- if (h > a && (this.arena.set_value_start_delta(e, a - this.arena.get_start_offset(e)), this.arena.set_value_length(e, h - a)), o = be(this.source, h, s), o < s) {
1616
- let f = this.source.charCodeAt(o);
1617
- f === 105 || f === 73 ? this.arena.set_attr_flags(e, Ar) : f === 115 || f === 83 ? this.arena.set_attr_flags(e, Er) : this.arena.set_attr_flags(e, Ce);
1618
- } else
1619
- this.arena.set_attr_flags(e, Ce);
1620
- }
1621
- // Parse pseudo-class or pseudo-element (:hover, ::before)
1622
- parse_pseudo(e) {
1623
- const t = this.lexer.save_position(), s = this.lexer.save_position();
1624
- this.skip_whitespace();
1625
- let i = !1;
1626
- this.lexer.pos < this.selector_end && this.source.charCodeAt(this.lexer.pos) === Xn ? (i = !0, this.lexer.pos++) : this.lexer.restore_position(s), this.lexer.next_token_fast(!1);
1627
- let n = this.lexer.token_type;
1628
- if (n === ae) {
1629
- let l = this.create_node(i ? Ve : Te, e, this.lexer.token_end);
1630
- return this.arena.set_content_start_delta(l, this.lexer.token_start - e), this.arena.set_content_length(l, this.lexer.token_end - this.lexer.token_start), l;
1631
- } else if (n === ct)
1632
- return this.parse_pseudo_function_after_colon(e, i);
1633
- return this.lexer.restore_position(t), null;
1634
- }
1635
- // Parse pseudo-class function (:nth-child(), :is(), etc.)
1636
- parse_pseudo_function(e, t) {
1637
- return null;
1638
- }
1639
- // Parse pseudo-class function after we've seen the colon
1640
- parse_pseudo_function_after_colon(e, t) {
1641
- let s = this.lexer.token_start, i = this.lexer.token_end - 1, n = this.lexer.pos, l = n, a = 1, h = this.lexer.token_end;
1642
- for (; this.lexer.pos < this.selector_end && a > 0; ) {
1643
- this.lexer.next_token_fast(!1);
1644
- let u = this.lexer.token_type;
1645
- if (u === er || u === ct)
1646
- a++;
1647
- else if (u === tr && (a--, a === 0)) {
1648
- l = this.lexer.token_start, h = this.lexer.token_end;
1649
- break;
1650
- }
1651
- }
1652
- let o = this.create_node(t ? Ve : Te, e, h);
1653
- if (this.arena.set_content_start_delta(o, s - e), this.arena.set_content_length(o, i - s), this.arena.set_flag(o, pr), l > n) {
1654
- let u = this.source.substring(s, i);
1655
- if (this.is_nth_pseudo(u)) {
1656
- let p = this.parse_nth_expression(n, l);
1657
- p !== null && this.arena.set_first_child(o, p);
1658
- } else if (V("lang", u))
1659
- this.parse_lang_identifiers(n, l, o);
1660
- else {
1661
- let p = this.selector_end;
1662
- const d = this.lexer.save_position();
1663
- let f = V("has", u), L = this.parse_selector(n, l, this.lexer.line, this.lexer.column, f);
1664
- this.selector_end = p, this.lexer.restore_position(d), L !== null && this.arena.set_first_child(o, L);
1665
- }
1666
- }
1667
- return o;
1668
- }
1669
- // Check if pseudo-class name is an nth-* pseudo
1670
- is_nth_pseudo(e) {
1671
- return V("nth-child", e) || V("nth-last-child", e) || V("nth-of-type", e) || V("nth-last-of-type", e) || V("nth-col", e) || V("nth-last-col", e);
1672
- }
1673
- // Parse :lang() content - comma-separated language identifiers
1674
- // Accepts both quoted strings: :lang("en", "fr") and unquoted: :lang(en, fr)
1675
- parse_lang_identifiers(e, t, s) {
1676
- let i = this.selector_end;
1677
- const n = this.lexer.save_position();
1678
- this.lexer.pos = e, this.selector_end = t;
1679
- let l = null, a = null;
1680
- for (; this.lexer.pos < t; ) {
1681
- this.lexer.next_token_fast(!1);
1682
- let h = this.lexer.token_type, o = this.lexer.token_start, u = this.lexer.token_end;
1683
- if (h !== hs && h !== $e) {
1684
- if (h === Vi || h === ae) {
1685
- let p = this.create_node(_r, o, u);
1686
- l === null && (l = p), a !== null && this.arena.set_next_sibling(a, p), a = p;
1687
- }
1688
- if (this.lexer.pos >= t)
1689
- break;
1690
- }
1691
- }
1692
- l !== null && this.arena.set_first_child(s, l), this.selector_end = i, this.lexer.restore_position(n);
1693
- }
1694
- // Parse An+B expression for nth-* pseudo-classes
1695
- // Handles both simple An+B and "An+B of S" syntax
1696
- parse_nth_expression(e, t) {
1697
- let s = this.find_of_keyword(e, t);
1698
- if (s !== -1) {
1699
- let n = new Pi(this.arena, this.source).parse_anplusb(e, s, this.lexer.line), l = s + 2;
1700
- l = tl(this.source, l, t);
1701
- let a = this.selector_end;
1702
- const h = this.lexer.save_position();
1703
- this.selector_end = t, this.lexer.pos = l;
1704
- let o = this.parse_selector_list();
1705
- this.selector_end = a, this.lexer.restore_position(h);
1706
- let u = this.arena.create_node(le, e, t - e, this.lexer.line, 1);
1707
- return n !== null && o !== null ? (this.arena.set_first_child(u, n), this.arena.set_next_sibling(n, o)) : n !== null && this.arena.set_first_child(u, n), u;
1708
- } else
1709
- return new Pi(this.arena, this.source).parse_anplusb(e, t, this.lexer.line);
1710
- }
1711
- // Find the position of standalone "of" keyword (case-insensitive)
1712
- find_of_keyword(e, t) {
1713
- let s = e;
1714
- for (; s < t - 1 && (s = be(this.source, s, t), !(s >= t - 1)); ) {
1715
- let i = this.source.charCodeAt(s), n = this.source.charCodeAt(s + 1);
1716
- if ((i === 111 || i === 79) && (n === 102 || n === 70)) {
1717
- let l = s === e || re(this.source.charCodeAt(s - 1)), a = s + 2 >= t || re(this.source.charCodeAt(s + 2));
1718
- if (l && a)
1719
- return s;
1720
- }
1721
- s++;
1722
- }
1723
- return -1;
1724
- }
1725
- create_node(e, t, s) {
1726
- let i = this.arena.create_node(e, t, s - t, this.lexer.token_line, this.lexer.token_column);
1727
- return this.arena.set_content_start_delta(i, 0), this.arena.set_content_length(i, s - t), i;
1728
- }
1729
- create_node_at(e, t, s, i, n) {
1730
- let l = this.arena.create_node(e, t, s - t, i, n);
1731
- return this.arena.set_content_start_delta(l, 0), this.arena.set_content_length(l, s - t), l;
1732
- }
1733
- // Helper to skip whitespace and comments, updating line/column
1734
- skip_whitespace() {
1735
- for (; this.lexer.pos < this.selector_end; ) {
1736
- let e = this.source.charCodeAt(this.lexer.pos);
1737
- if (re(e)) {
1738
- this.lexer.advance();
1739
- continue;
1740
- }
1741
- if (e === Ue && this.lexer.pos + 1 < this.selector_end && this.source.charCodeAt(this.lexer.pos + 1) === j) {
1742
- for (this.lexer.advance(2); this.lexer.pos < this.selector_end; ) {
1743
- if (this.source.charCodeAt(this.lexer.pos) === j && this.lexer.pos + 1 < this.selector_end && this.source.charCodeAt(this.lexer.pos + 1) === Ue) {
1744
- this.lexer.advance(2);
1745
- break;
1746
- }
1747
- this.lexer.advance();
1748
- }
1749
- continue;
1750
- }
1751
- break;
1752
- }
1753
- }
1754
- }
1755
- function ol(r) {
1756
- const e = new gt(gt.capacity_for_source(r.length)), s = new ll(e, r).parse_selector(0, r.length);
1757
- if (s === null) {
1758
- const i = e.create_node(Et, 0, 0, 1, 1);
1759
- return new je(e, r, i);
1760
- }
1761
- return new je(e, r, s);
1762
- }
1763
- function al(r, e) {
1764
- return r[0] === e[0] ? r[1] === e[1] ? r[2] - e[2] : r[1] - e[1] : r[0] - e[0];
1765
- }
1766
- function Di(r) {
1767
- return r.sort(al).at(-1);
1768
- }
1769
- const xt = (r) => {
1770
- var n, l, a, h, o;
1771
- let e = 0, t = 0, s = 0, i = r.first_child;
1772
- for (; i; ) {
1773
- switch (i.type) {
1774
- case Lr:
1775
- e += 1;
1776
- break;
1777
- case wt:
1778
- case Nr:
1779
- t += 1;
1780
- break;
1781
- case Le:
1782
- switch ((n = i.name) == null ? void 0 : n.toLowerCase()) {
1783
- // "The specificity of a :where() pseudo-class is replaced by zero."
1784
- case "where":
1785
- break;
1786
- case "-webkit-any":
1787
- case "any":
1788
- i.first_child && (t += 1);
1789
- break;
1790
- // "The specificity of an :is(), :not(), or :has() pseudo-class is replaced by the specificity of the most specific complex selector in its selector list argument."
1791
- case "-moz-any":
1792
- case "is":
1793
- case "matches":
1794
- case "not":
1795
- case "has":
1796
- if (i.has_children) {
1797
- const f = i.first_child;
1798
- if ((f == null ? void 0 : f.type) === ks) {
1799
- const L = Di(Fi(f));
1800
- e += L[0], t += L[1], s += L[2];
1801
- }
1802
- }
1803
- break;
1804
- // "The specificity of an :nth-child() or :nth-last-child() selector is the specificity of the pseudo class itself (counting as one pseudo-class selector) plus the specificity of the most specific complex selector in its selector list argument"
1805
- case "nth-child":
1806
- case "nth-last-child":
1807
- t += 1;
1808
- const p = i.first_child;
1809
- if ((p == null ? void 0 : p.type) === Or && p.selector) {
1810
- const f = Di(Fi(p.selector));
1811
- e += f[0], t += f[1], s += f[2];
1812
- }
1813
- break;
1814
- // "The specificity of :host is that of a pseudo-class. The specificity of :host() is that of a pseudo-class, plus the specificity of its argument."
1815
- // "The specificity of :host-context() is that of a pseudo-class, plus the specificity of its argument."
1816
- case "host-context":
1817
- case "host":
1818
- t += 1;
1819
- const d = (l = i.first_child) == null ? void 0 : l.first_child;
1820
- if ((d == null ? void 0 : d.type) === me) {
1821
- let f = d.first_child;
1822
- for (; f && f.type !== ls; ) {
1823
- const L = xt({
1824
- first_child: f
1825
- });
1826
- e += L[0] ?? 0, t += L[1] ?? 0, s += L[2] ?? 0, f = f.next_sibling;
1827
- }
1828
- }
1829
- break;
1830
- // Improper use of Pseudo-Class Selectors instead of a Pseudo-Element
1831
- // @ref https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements#index
1832
- case "after":
1833
- case "before":
1834
- case "first-letter":
1835
- case "first-line":
1836
- s += 1;
1837
- break;
1838
- default:
1839
- t += 1;
1840
- break;
1841
- }
1842
- break;
1843
- case Qe:
1844
- switch ((a = i.name) == null ? void 0 : a.toLowerCase()) {
1845
- // "The specificity of ::slotted() is that of a pseudo-element, plus the specificity of its argument."
1846
- case "slotted":
1847
- s += 1;
1848
- const p = (h = i.first_child) == null ? void 0 : h.first_child;
1849
- if ((p == null ? void 0 : p.type) === me) {
1850
- let d = p.first_child;
1851
- for (; d && d.type !== ls; ) {
1852
- const f = xt({
1853
- first_child: d
1854
- });
1855
- e += f[0] ?? 0, t += f[1] ?? 0, s += f[2] ?? 0, d = d.next_sibling;
1856
- }
1857
- }
1858
- break;
1859
- case "view-transition-group":
1860
- case "view-transition-image-pair":
1861
- case "view-transition-old":
1862
- case "view-transition-new":
1863
- if (((o = i.first_child) == null ? void 0 : o.text) === "*")
1864
- break;
1865
- s += 1;
1866
- break;
1867
- default:
1868
- s += 1;
1869
- break;
1870
- }
1871
- break;
1872
- case ms:
1873
- let u = i.name ?? "";
1874
- u.includes("|") && (u = u.split("|")[1] ?? ""), u !== "*" && (s += 1);
1875
- break;
1876
- }
1877
- i = i.next_sibling;
1878
- }
1879
- return [e, t, s];
1880
- }, hl = (r) => {
1881
- if (typeof r == "string")
1882
- try {
1883
- return ol(r);
1884
- } catch (e) {
1885
- const t = e instanceof Error ? e.message : String(e);
1886
- throw new TypeError(`Could not convert passed in source '${r}' to SelectorList: ${t}`);
1887
- }
1888
- if (r instanceof Object) {
1889
- if (r.type === ks)
1890
- return r;
1891
- throw new TypeError("Passed in source is an Object but no AST / AST of the type SelectorList");
1892
- }
1893
- throw new TypeError("Passed in source is not a String nor an Object. I don't know what to do with it.");
1894
- }, Fi = (r) => {
1895
- if (!r)
1896
- return [];
1897
- const e = hl(r), t = [];
1898
- let s = e.first_child;
1899
- for (; s; )
1900
- t.push(xt(s)), s = s.next_sibling;
1901
- return t;
1902
- }, cl = new W([
1903
- // CSS Named Colors
1904
- // Spec: https://drafts.csswg.org/css-color/#named-colors
1905
- // Heuristic: popular names first for quick finding in set.has()
1906
- // See: https://docs.google.com/spreadsheets/d/1OU8ahxC5oYU8VRryQs9BzHToaXcOntVlh6KUHjm15G4/edit#gid=2096495459
1907
- "white",
1908
- "black",
1909
- "red",
1910
- "gray",
1911
- "silver",
1912
- "grey",
1913
- "green",
1914
- "orange",
1915
- "blue",
1916
- "dimgray",
1917
- "whitesmoke",
1918
- "lightgray",
1919
- "lightgrey",
1920
- "yellow",
1921
- "gold",
1922
- "pink",
1923
- "gainsboro",
1924
- "magenta",
1925
- "purple",
1926
- "darkgray",
1927
- "navy",
1928
- "darkred",
1929
- "teal",
1930
- "maroon",
1931
- "darkgrey",
1932
- "tomato",
1933
- "darkorange",
1934
- "brown",
1935
- "crimson",
1936
- "lightyellow",
1937
- "slategray",
1938
- "salmon",
1939
- "lightgreen",
1940
- "lightblue",
1941
- "orangered",
1942
- "aliceblue",
1943
- "dodgerblue",
1944
- "lime",
1945
- "darkblue",
1946
- "darkgoldenrod",
1947
- "skyblue",
1948
- "royalblue",
1949
- "darkgreen",
1950
- "ivory",
1951
- "olive",
1952
- "aqua",
1953
- "turquoise",
1954
- "cyan",
1955
- "khaki",
1956
- "beige",
1957
- "snow",
1958
- "ghostwhite",
1959
- "limegreen",
1960
- "coral",
1961
- "dimgrey",
1962
- "hotpink",
1963
- "midnightblue",
1964
- "firebrick",
1965
- "indigo",
1966
- "wheat",
1967
- "mediumblue",
1968
- "lightpink",
1969
- "plum",
1970
- "azure",
1971
- "violet",
1972
- "lavender",
1973
- "deepskyblue",
1974
- "darkslategrey",
1975
- "goldenrod",
1976
- "cornflowerblue",
1977
- "lightskyblue",
1978
- "indianred",
1979
- "yellowgreen",
1980
- "saddlebrown",
1981
- "palegreen",
1982
- "bisque",
1983
- "tan",
1984
- "antiquewhite",
1985
- "steelblue",
1986
- "forestgreen",
1987
- "fuchsia",
1988
- "mediumaquamarine",
1989
- "seagreen",
1990
- "sienna",
1991
- "deeppink",
1992
- "mediumseagreen",
1993
- "peru",
1994
- "greenyellow",
1995
- "lightgoldenrodyellow",
1996
- "orchid",
1997
- "cadetblue",
1998
- "navajowhite",
1999
- "lightsteelblue",
2000
- "slategrey",
2001
- "linen",
2002
- "lightseagreen",
2003
- "darkcyan",
2004
- "lightcoral",
2005
- "aquamarine",
2006
- "blueviolet",
2007
- "cornsilk",
2008
- "lightsalmon",
2009
- "chocolate",
2010
- "lightslategray",
2011
- "floralwhite",
2012
- "darkturquoise",
2013
- "darkslategray",
2014
- "rebeccapurple",
2015
- "burlywood",
2016
- "chartreuse",
2017
- "lightcyan",
2018
- "lemonchiffon",
2019
- "palevioletred",
2020
- "darkslateblue",
2021
- "mediumpurple",
2022
- "lawngreen",
2023
- "slateblue",
2024
- "darkseagreen",
2025
- "blanchedalmond",
2026
- "mistyrose",
2027
- "darkolivegreen",
2028
- "seashell",
2029
- "olivedrab",
2030
- "peachpuff",
2031
- "darkviolet",
2032
- "powderblue",
2033
- "darkmagenta",
2034
- "lightslategrey",
2035
- "honeydew",
2036
- "palegoldenrod",
2037
- "darkkhaki",
2038
- "oldlace",
2039
- "mintcream",
2040
- "sandybrown",
2041
- "mediumturquoise",
2042
- "papayawhip",
2043
- "paleturquoise",
2044
- "mediumvioletred",
2045
- "thistle",
2046
- "springgreen",
2047
- "moccasin",
2048
- "rosybrown",
2049
- "lavenderblush",
2050
- "mediumslateblue",
2051
- "darkorchid",
2052
- "mediumorchid",
2053
- "darksalmon",
2054
- "mediumspringgreen"
2055
- ]), _l = new W([
2056
- // CSS System Colors
2057
- // Spec: https://drafts.csswg.org/css-color/#css-system-colors
2058
- "accentcolor",
2059
- "accentcolortext",
2060
- "activetext",
2061
- "buttonborder",
2062
- "buttonface",
2063
- "buttontext",
2064
- "canvas",
2065
- "canvastext",
2066
- "field",
2067
- "fieldtext",
2068
- "graytext",
2069
- "highlight",
2070
- "highlighttext",
2071
- "linktext",
2072
- "mark",
2073
- "marktext",
2074
- "selecteditem",
2075
- "selecteditemtext",
2076
- "visitedtext"
2077
- ]), ul = new W(["rgba", "rgb", "hsla", "hsl", "oklch", "color", "hwb", "lch", "lab", "oklab"]), fl = new W(["transparent", "currentcolor"]), mt = new W([
2078
- "auto",
2079
- "none",
2080
- // for `text-shadow`, `box-shadow` and `background`
2081
- "inherit",
2082
- "initial",
2083
- "unset",
2084
- "revert",
2085
- "revert-layer"
2086
- ]);
2087
- function pl(r) {
2088
- for (let e of r.children)
2089
- if (!(e.type === xs && e.value === 0) && !(e.type === kt && e.value === 0))
2090
- return !1;
2091
- return !0;
2092
- }
2093
- const rs = new W(["caption", "icon", "menu", "message-box", "small-caption", "status-bar"]), dl = new W([
2094
- /* <absolute-size> values */
2095
- "xx-small",
2096
- "x-small",
2097
- "small",
2098
- "medium",
2099
- "large",
2100
- "x-large",
2101
- "xx-large",
2102
- "xxx-large",
2103
- /* <relative-size> values */
2104
- "smaller",
2105
- "larger"
2106
- ]), gl = 44, Mi = 47;
2107
- function xl(r, e) {
2108
- var a;
2109
- let t = [void 0, void 0], s, i;
2110
- if (r.first_child.type === ws && ((a = r.first_child.name) == null ? void 0 : a.toLowerCase()) === "var")
2111
- return null;
2112
- let n;
2113
- for (let h of r.children) {
2114
- let o = h.next_sibling;
2115
- if (h.type === _e && mt.has(h.name) && e({
2116
- type: "keyword",
2117
- value: h.name
2118
- }), o && o.type === Re && o.text.charCodeAt(0) === Mi) {
2119
- s = h.text, n = h;
2120
- continue;
2121
- }
2122
- if ((n == null ? void 0 : n.type) === Re && n.text.charCodeAt(0) === Mi) {
2123
- i = h.text, n = h;
2124
- continue;
2125
- }
2126
- if ((o == null ? void 0 : o.type) === Re && o.text.charCodeAt(0) === gl && !t[0]) {
2127
- t[0] = h, !s && n && (s = n.text), n = h;
2128
- continue;
2129
- }
2130
- if (h.next_sibling === null) {
2131
- t[1] = h, !s && !t[0] && n && (s = n.text), n = h;
2132
- continue;
2133
- }
2134
- if (h.type === xs) {
2135
- n = h;
2136
- continue;
2137
- }
2138
- if (h.type === _e) {
2139
- let u = h.name;
2140
- if (u && dl.has(u)) {
2141
- s = u, n = h;
2142
- continue;
2143
- }
2144
- }
2145
- n = h;
2146
- }
2147
- let l = t[0] || t[1] ? r.text.substring(
2148
- ((t == null ? void 0 : t[0]) || (t == null ? void 0 : t[1]) || { start: r.start }).start - r.start,
2149
- // Either the node we detected as the last node, or the end of the whole value
2150
- // It's never 0 because the first node is always a font-size or font-style
2151
- t[1] ? t[1].end - r.start : r.text.length
2152
- ) : null;
2153
- return {
2154
- font_size: s,
2155
- line_height: i,
2156
- font_family: l
2157
- };
2158
- }
2159
- const ml = new W(["linear", "ease", "ease-in", "ease-out", "ease-in-out", "step-start", "step-end"]), kl = new W(["cubic-bezier", "steps"]);
2160
- function wl(r, e) {
2161
- let t = !1;
2162
- for (let s of r) {
2163
- let i = s.type, n = s.name;
2164
- i === Re ? t = !1 : i === kt && t === !1 ? (t = !0, e({
2165
- type: "duration",
2166
- value: s
2167
- })) : i === _e && n ? ml.has(n) ? e({
2168
- type: "fn",
2169
- value: s
2170
- }) : mt.has(n) && e({
2171
- type: "keyword",
2172
- value: s
2173
- }) : i === ws && n && kl.has(n) && e({
2174
- type: "fn",
2175
- value: s
2176
- });
2177
- }
2178
- }
2179
- function Al(r, e) {
2180
- z(r, function(t) {
2181
- t.is_vendor_prefixed && e(t.name || t.text);
2182
- });
2183
- }
2184
- var he, ee, te, Se;
2185
- class _ {
2186
- constructor(e = !1) {
2187
- Y(this, he);
2188
- Y(this, ee);
2189
- Y(this, te, []);
2190
- Y(this, Se);
2191
- q(this, he, /* @__PURE__ */ new Map()), q(this, ee, 0), e && q(this, te, []), q(this, Se, e);
2192
- }
2193
- p(e, t) {
2194
- let s = A(this, ee);
2195
- if (A(this, Se)) {
2196
- let i = s * 4;
2197
- A(this, te)[i] = t.line, A(this, te)[i + 1] = t.column, A(this, te)[i + 2] = t.offset, A(this, te)[i + 3] = t.length;
2198
- }
2199
- if (A(this, he).has(e)) {
2200
- A(this, he).get(e).push(s), Zt(this, ee)._++;
2201
- return;
2202
- }
2203
- A(this, he).set(e, [s]), Zt(this, ee)._++;
2204
- }
2205
- size() {
2206
- return A(this, ee);
2207
- }
2208
- c() {
2209
- let e = /* @__PURE__ */ new Map(), t = {}, s = A(this, Se), i = A(this, he), n = A(this, te), l = i.size;
2210
- i.forEach((h, o) => {
2211
- if (s) {
2212
- let u = h.map(function(p) {
2213
- let d = p * 4;
2214
- return {
2215
- line: n[d],
2216
- column: n[d + 1],
2217
- offset: n[d + 2],
2218
- length: n[d + 3]
2219
- };
2220
- });
2221
- e.set(o, u);
2222
- } else
2223
- t[o] = h.length;
2224
- });
2225
- let a = A(this, ee);
2226
- return s ? {
2227
- total: a,
2228
- totalUnique: l,
2229
- unique: t,
2230
- uniquenessRatio: a === 0 ? 0 : l / a,
2231
- uniqueWithLocations: Object.fromEntries(e)
2232
- } : {
2233
- total: a,
2234
- totalUnique: l,
2235
- unique: t,
2236
- uniquenessRatio: a === 0 ? 0 : l / a,
2237
- uniqueWithLocations: void 0
2238
- };
2239
- }
2240
- }
2241
- he = new WeakMap(), ee = new WeakMap(), te = new WeakMap(), Se = new WeakMap();
2242
- var Oe, ce, Xe;
2243
- class ns {
2244
- constructor(e) {
2245
- Y(this, Oe);
2246
- Y(this, ce);
2247
- Y(this, Xe);
2248
- q(this, Oe, new _(e)), q(this, ce, /* @__PURE__ */ new Map()), q(this, Xe, e);
2249
- }
2250
- /**
2251
- * Add an item to this #list's context
2252
- * @param item Item to push
2253
- * @param context Context to push Item to
2254
- * @param node_location
2255
- */
2256
- push(e, t, s) {
2257
- A(this, Oe).p(e, s), A(this, ce).has(t) || A(this, ce).set(t, new _(A(this, Xe))), A(this, ce).get(t).p(e, s);
2258
- }
2259
- count() {
2260
- let e = /* @__PURE__ */ new Map();
2261
- for (let [t, s] of A(this, ce).entries())
2262
- e.set(t, s.c());
2263
- return Object.assign(A(this, Oe).c(), {
2264
- itemsPerContext: Object.fromEntries(e)
2265
- });
2266
- }
2267
- }
2268
- Oe = new WeakMap(), ce = new WeakMap(), Xe = new WeakMap();
2269
- function El(r) {
2270
- let e = /* @__PURE__ */ new Map(), t = -1, s = 0, i = 0, n = r.length;
2271
- for (let l = 0; l < n; l++) {
2272
- let a = r[l], h = (e.get(a) || 0) + 1;
2273
- e.set(a, h), h > t && (t = h, s = 0, i = 0), h >= t && (s++, i += a);
2274
- }
2275
- return i / s;
2276
- }
2277
- var se, Ne;
2278
- class I {
2279
- constructor() {
2280
- Y(this, se);
2281
- Y(this, Ne);
2282
- q(this, se, []), q(this, Ne, 0);
2283
- }
2284
- /**
2285
- * Add a new Integer at the end of this AggregateCollection
2286
- * @param item - The item to add
2287
- */
2288
- push(e) {
2289
- A(this, se).push(e), q(this, Ne, A(this, Ne) + e);
2290
- }
2291
- size() {
2292
- return A(this, se).length;
2293
- }
2294
- aggregate() {
2295
- let e = A(this, se).length;
2296
- if (e === 0)
2297
- return {
2298
- min: 0,
2299
- max: 0,
2300
- mean: 0,
2301
- mode: 0,
2302
- range: 0,
2303
- sum: 0
2304
- };
2305
- let t = A(this, se).slice().sort((a, h) => a - h), s = t[0], i = t[e - 1], n = El(t), l = A(this, Ne);
2306
- return {
2307
- min: s,
2308
- max: i,
2309
- mean: l / e,
2310
- mode: n,
2311
- range: i - s,
2312
- sum: l
2313
- };
2314
- }
2315
- toArray() {
2316
- return A(this, se);
2317
- }
2318
- }
2319
- se = new WeakMap(), Ne = new WeakMap();
2320
- function yl(r) {
2321
- let e = 5, t = r.indexOf(";"), s = r.indexOf(",");
2322
- return t === -1 || s !== -1 && s < t ? r.substring(e, s) : r.substring(e, t);
2323
- }
2324
- function zi(r) {
2325
- let e = r.children;
2326
- if (e) {
2327
- let t = e.at(-1);
2328
- return !!(t && t.type === _e && os("\\9", t.text));
2329
- }
2330
- return !1;
2331
- }
2332
- const Cl = /* @__PURE__ */ new Set([
2333
- "margin",
2334
- "margin-block",
2335
- "margin-inline",
2336
- "margin-top",
2337
- "margin-block-start",
2338
- "margin-block-end",
2339
- "margin-inline-end",
2340
- "margin-inline-end",
2341
- "margin-right",
2342
- "margin-bottom",
2343
- "margin-left",
2344
- "padding",
2345
- "padding-block",
2346
- "padding-inline",
2347
- "padding-top",
2348
- "padding-right",
2349
- "padding-bottom",
2350
- "padding-left",
2351
- "padding-block-start",
2352
- "padding-block-end",
2353
- "padding-inline-start",
2354
- "padding-inline-end"
2355
- ]), bl = new W([
2356
- "border-radius",
2357
- "border-top-left-radius",
2358
- "border-top-right-radius",
2359
- "border-bottom-right-radius",
2360
- "border-bottom-left-radius",
2361
- "border-start-start-radius",
2362
- "border-start-end-radius",
2363
- "border-end-end-radius",
2364
- "border-end-start-radius"
2365
- ]);
2366
- function Rl(r) {
2367
- if (As(r) || Es(r)) return !1;
2368
- let e = r.charCodeAt(0);
2369
- return e === 47 || // /
2370
- e === 42 || // *
2371
- e === 95 || // _
2372
- e === 43 || // +
2373
- e === 38 || // &
2374
- e === 36 || // $
2375
- e === 35;
2376
- }
2377
- function qi(r) {
2378
- return As(r) ? r : Es(r) ? r.slice(r.indexOf("-", 2) + 1).toLowerCase() : Rl(r) ? r.slice(1).toLowerCase() : r.toLowerCase();
2379
- }
2380
- function Sl(r) {
2381
- return Es(r);
2382
- }
2383
- function H(r, e) {
2384
- return e === 0 ? 0 : r / e;
2385
- }
2386
- function Ol(r, e = {}) {
2387
- return e.useLocations === !0 ? Ki(r, e, !0) : Ki(r, e, !1);
2388
- }
2389
- function Ki(r, e, t) {
2390
- let s = Date.now(), i = (r.match(/\n/g) || []).length + 1, n = 0, l = 0, a = 0, h = {
2391
- total: 0,
2392
- unique: /* @__PURE__ */ new Map()
2393
- }, o = Date.now(), u = Ur(r, {
2394
- on_comment({ length: c }) {
2395
- n++, l += c;
2396
- }
2397
- }), p = Date.now(), d = new _(t), f = new I(), L = [], bs = new _(t), Ze = new _(t), Rs = new _(t), vs = new _(t), Ts = new _(t), Ss = new _(t), Os = new _(t), yt = new _(t), Ns = new _(t), Ct = new _(t), bt = new _(t), Ls = new _(t), Je = new _(t), Us = new _(t), Is = new _(t), Rt = new I(), Hs = new _(t), vt = 0, Tt = 0, St = new I(), Ot = new I(), Nt = new I(), Ps = new _(t), Ds = new _(t), Fs = new _(t), Lt = new I(), Ms = new _(t), Ut = new _(t), zs = /* @__PURE__ */ new Set(), It = new _(t), ue, fe, qs = new I(), Ks = new I(), $s = new I(), Bs = new _(t), et = new I(), Gs = new _(t), Ws = [], Ht = new _(t), Pt = new _(t), Ys = new _(t), Qs = new _(t), Vs = new _(t), js = new _(t), Dt = new I(), Xs = new _(t), Zs = /* @__PURE__ */ new Set(), Ie = 0, Js = new I(), tt = 0, Ft = 0, Mt = new _(t), zt = new I(), ei = new _(t), He = new _(t), qt = new _(t), Kt = new _(t), st = new _(t), Pe = new I(), $t = new I(), ti = new _(t), Bt = new _(t), it = new _(t), si = new _(t), ii = new _(t), ri = new _(t), Gt = new _(t), rt = new _(t), nt = new _(t), Wt = new _(t), lt = new _(t), we = new ns(t), Ae = new _(t), ni = new ns(t), li = new _(t), De = new _(t), oi = new ns(t), ai = new _(t);
2398
- function k(c) {
2399
- return {
2400
- line: c.line,
2401
- column: c.column,
2402
- offset: c.start,
2403
- length: c.length
2404
- };
2405
- }
2406
- let Ee = -1;
2407
- z(u, (c, F) => {
2408
- var mi, ki, wi, Ai, Ei;
2409
- Ee >= 0 && F <= Ee && (Ee = -1);
2410
- let Xt = Ee >= 0 && F > Ee;
2411
- if (c.type === Ir) {
2412
- let v = k(c);
2413
- Rt.push(F), Hs.p(F, v);
2414
- let C = qi(c.name ?? "");
2415
- if (d.p(C, v), C === "font-face") {
2416
- let w = /* @__PURE__ */ Object.create(null);
2417
- t && bs.p(c.start, k(c));
2418
- let g = c.children.find((E) => E.type === Hr);
2419
- for (let E of (g == null ? void 0 : g.children) || [])
2420
- E.type === Jt && E.value && (w[E.property] = E.value.text);
2421
- f.push(1), L.push(w);
2422
- }
2423
- if (c.prelude === null || c.prelude === void 0)
2424
- C === "layer" && (Ze.p("<anonymous>", k(c)), f.push(2));
2425
- else {
2426
- let w = 1;
2427
- if (C === "media")
2428
- vs.p(c.prelude.text, k(c)), Kr(c.prelude, (g) => {
2429
- Ts.p(g, k(c)), w++;
2430
- });
2431
- else if (C === "supports")
2432
- yt.p(c.prelude.text, k(c)), qr(c.prelude, (g) => {
2433
- Ns.p(g, k(c)), w++;
2434
- });
2435
- else if (C.endsWith("keyframes")) {
2436
- let g = c.prelude.text;
2437
- Ct.p(g, k(c)), c.is_vendor_prefixed && (bt.p(`@${(mi = c.name) == null ? void 0 : mi.toLowerCase()} ${c.prelude.text}`, k(c)), w++), Ee = F;
2438
- } else if (C === "layer")
2439
- for (let g of c.prelude.text.split(",").map((E) => E.trim()))
2440
- Ze.p(g, k(c));
2441
- else if (C === "import") {
2442
- if (Rs.p(c.prelude.text, k(c)), c.prelude.has_children)
2443
- for (let g of c.prelude)
2444
- g.type === Bi && typeof g.value == "string" ? yt.p(g.value, k(g)) : g.type === Pr && typeof g.value == "string" && Ze.p(g.value, k(g));
2445
- } else C === "container" ? (Ls.p(c.prelude.text, k(c)), ((ki = c.prelude.first_child) == null ? void 0 : ki.type) === Dr && ((wi = c.prelude.first_child.first_child) == null ? void 0 : wi.type) === _e && Je.p(c.prelude.first_child.first_child.text, k(c))) : C === "property" ? Us.p(c.prelude.text, k(c)) : C === "charset" ? Os.p(c.prelude.text.toLowerCase(), k(c)) : C === "scope" && Is.p(c.prelude.text, k(c));
2446
- f.push(w);
2447
- }
2448
- } else if (c.type === Fr)
2449
- if (Xt && c.prelude) {
2450
- if (c.prelude.type === ks && c.prelude.children.length > 0)
2451
- for (let v of c.prelude.children)
2452
- Ut.p(v.text, k(v));
2453
- } else {
2454
- vt++, (Ai = c.block) != null && Ai.is_empty && Tt++;
2455
- let v = 0, C = 0, w = k(c);
2456
- if (c.prelude)
2457
- for (const g of c.prelude.children)
2458
- g.type === me && v++;
2459
- if (c.block)
2460
- for (const g of c.block.children)
2461
- g.type === Jt && C++;
2462
- St.push(v + C), Ps.p(v + C, w), Ot.push(v), Ds.p(v, w), Nt.push(C), Fs.p(C, w), Lt.push(F), Ms.p(F, w);
2463
- }
2464
- else if (c.type === me) {
2465
- if (Xt)
2466
- return P;
2467
- let v = k(c);
2468
- Dt.push(F > 0 ? F - 1 : 0), Xs.p(F > 0 ? F - 1 : 0, v), zs.add(c.text);
2469
- let C = as(c);
2470
- et.push(C), Gs.p(C, v), Gr(c, (U) => {
2471
- It.p(U.toLowerCase(), v);
2472
- }), Wr(c, (U) => {
2473
- Pt.p(U, v);
2474
- }), Yr(c, (U) => {
2475
- Ys.p(U.toLowerCase(), v);
2476
- }), Qr(c, (U) => {
2477
- Qs.p(U.toLowerCase(), v);
2478
- }), z(c, (U) => {
2479
- var G;
2480
- U.type === wt && Vs.p(((G = U.name) == null ? void 0 : G.toLowerCase()) ?? "", v);
2481
- }), Vr(c, (U) => {
2482
- let G = U.name.trim() === "" ? " " : U.name;
2483
- js.p(G, U.loc);
2484
- });
2485
- let w = xt(c), [g, E, B] = w;
2486
- return Bs.p(w.toString(), v), qs.push(g), Ks.push(E), $s.push(B), ue === void 0 && (ue = w), fe === void 0 && (fe = w), fe !== void 0 && $i(fe, w) < 0 && (fe = w), ue !== void 0 && $i(ue, w) > 0 && (ue = w), Ws.push(w), g > 0 && Ht.p(c.text, v), P;
2487
- } else if (c.type === Jt) {
2488
- Ie++, Zs.add(c.text);
2489
- let v = k(c), C = F > 0 ? F - 1 : 0;
2490
- zt.push(C), ei.p(C, v);
2491
- let w = 1;
2492
- c.is_important && (w++, c.text.toLowerCase().includes("!important") || Bt.p("!ie", k(c.value)), Xt && (Ft++, w++)), Js.push(w);
2493
- let { is_important: g, property: E, is_browserhack: B, is_vendor_prefixed: U } = c;
2494
- if (!E) return;
2495
- let G = k(c);
2496
- G.length = E.length;
2497
- let T = qi(E);
2498
- He.p(T, G), g && tt++, U ? (Pe.push(2), Kt.p(E, G)) : As(E) ? (st.p(E, G), Pe.push(g ? 3 : 2), g && Mt.p(E, G)) : B ? (qt.p(E.charAt(0), G), Pe.push(2)) : Pe.push(1);
2499
- {
2500
- let D = c.value, { text: N } = D, b = k(D), ot = 1;
2501
- if (mt.has(N)) {
2502
- De.p(N.toLowerCase(), b), $t.push(ot), T === "display" && it.p(N.toLowerCase(), b);
2503
- return;
2504
- }
2505
- if (Al(D, (x) => {
2506
- ti.p(x.toLowerCase(), b), ot++;
2507
- }), zi(D) && (Bt.p("\\9", b), N = N.slice(0, -2), ot++), $t.push(ot), Cl.has(T))
2508
- pl(D) && ai.p(T, b);
2509
- else if (T === "display")
2510
- /var\(/i.test(N) ? it.p(N, b) : it.p(N.toLowerCase(), b);
2511
- else {
2512
- if (T === "z-index")
2513
- return si.p(N, b), P;
2514
- if (T === "font") {
2515
- if (!rs.has(N)) {
2516
- let x = xl(D, function(Z) {
2517
- Z.type === "keyword" && De.p(Z.value.toLowerCase(), b);
2518
- });
2519
- if (!x)
2520
- return P;
2521
- let { font_size: X, line_height: O, font_family: S } = x;
2522
- S && Gt.p(S, b), X && rt.p(X.toLowerCase(), b), O && nt.p(O.toLowerCase(), b);
2523
- }
2524
- } else if (T === "font-size") {
2525
- if (!rs.has(N)) {
2526
- let x = N.toLowerCase();
2527
- x.includes("var(") ? rt.p(N, b) : rt.p(x, b);
2528
- }
2529
- } else {
2530
- if (T === "font-family")
2531
- return rs.has(N) || Gt.p(N, b), P;
2532
- if (T === "line-height") {
2533
- let x = N.toLowerCase();
2534
- x.includes("var(") ? nt.p(N, b) : nt.p(x, b);
2535
- } else {
2536
- if (T === "transition" || T === "animation")
2537
- return wl(D.children, function(x) {
2538
- x.type === "fn" ? Wt.p(x.value.text.toLowerCase(), b) : x.type === "duration" ? lt.p(x.value.text.toLowerCase(), b) : x.type === "keyword" && De.p(x.value.text.toLowerCase(), b);
2539
- }), P;
2540
- if (T === "animation-duration" || T === "transition-duration") {
2541
- for (let x of D.children)
2542
- if (x.type !== Re) {
2543
- let X = x.text;
2544
- /var\(/i.test(X) ? lt.p(X, b) : lt.p(X.toLowerCase(), b);
2545
- }
2546
- } else if (T === "transition-timing-function" || T === "animation-timing-function")
2547
- for (let x of D.children)
2548
- x.type !== Re && Wt.p(x.text, b);
2549
- else T === "container-name" ? Je.p(N, b) : T === "container" ? ((Ei = D.first_child) == null ? void 0 : Ei.type) === _e && Je.p(D.first_child.text, b) : bl.has(T) ? oi.push(N, E, b) : T === "text-shadow" ? ii.p(N, b) : T === "box-shadow" && ri.p(N, b);
2550
- }
2551
- }
2552
- }
2553
- let br = zi(D);
2554
- z(D, (x) => {
2555
- var X;
2556
- switch (x.type) {
2557
- case kt: {
2558
- let O = ((X = x.unit) == null ? void 0 : X.toLowerCase()) ?? "", S = k(x);
2559
- return ni.push(O, E, S), P;
2560
- }
2561
- case Mr: {
2562
- let O = x.text;
2563
- if (!O || !O.startsWith("#"))
2564
- return P;
2565
- let S = O.toLowerCase();
2566
- br && !S.endsWith("\\9") && (S = S + "\\9");
2567
- let Z = S.length - 1;
2568
- os("\\9", S) && (Z = Z - 2);
2569
- let Fe = k(x);
2570
- return we.push(S, E, Fe), Ae.p("hex" + Z, Fe), P;
2571
- }
2572
- case _e: {
2573
- let O = x.text, S = k(x);
2574
- if (T === "font" || T === "font-family")
2575
- return P;
2576
- mt.has(O) && De.p(O.toLowerCase(), S);
2577
- let Z = O.length;
2578
- if (Z > 20 || Z < 3)
2579
- return P;
2580
- if (fl.has(O)) {
2581
- let Fe = O.toLowerCase();
2582
- we.push(Fe, E, S), Ae.p(Fe, S);
2583
- return;
2584
- }
2585
- if (cl.has(O)) {
2586
- we.push(O.toLowerCase(), E, S), Ae.p("named", S);
2587
- return;
2588
- }
2589
- if (_l.has(O)) {
2590
- we.push(O.toLowerCase(), E, S), Ae.p("system", S);
2591
- return;
2592
- }
2593
- return P;
2594
- }
2595
- case ws: {
2596
- let O = x.name, S = k(x);
2597
- if (ul.has(O)) {
2598
- we.push(x.text, E, S), Ae.p(O.toLowerCase(), S);
2599
- return;
2600
- }
2601
- if (os("gradient", O)) {
2602
- li.p(x.text, S);
2603
- return;
2604
- }
2605
- }
2606
- }
2607
- });
2608
- }
2609
- } else if (c.type === zr) {
2610
- let { value: v } = c, C = Yi(v || "");
2611
- if (Wi(C, "data:")) {
2612
- let w = C.length, g = yl(C);
2613
- h.total++, a += w;
2614
- let E = {
2615
- line: c.line,
2616
- column: c.column,
2617
- offset: c.start,
2618
- length: c.length
2619
- };
2620
- if (h.unique.has(g)) {
2621
- let B = h.unique.get(g);
2622
- B.count++, B.size += w, h.unique.set(g, B), t && B.uniqueWithLocations && B.uniqueWithLocations.push(E);
2623
- } else {
2624
- let B = {
2625
- count: 1,
2626
- size: w,
2627
- uniqueWithLocations: t ? [E] : void 0
2628
- };
2629
- h.unique.set(g, B);
2630
- }
2631
- }
2632
- } else if (c.type === Gi)
2633
- return c.name && Ss.p(c.name.toLowerCase(), k(c)), P;
2634
- });
2635
- let hi = Zs.size, ye = et.size(), Yt = qs.aggregate(), Qt = Ks.aggregate(), Vt = $s.aggregate(), ci = zs.size, R = Object.assign, _i = r.length, jt = L.length, ui = f.aggregate(), fi = et.aggregate(), pi = Js.aggregate(), di = Pe.aggregate(), gi = $t.aggregate(), xi = d.c();
2636
- return {
2637
- stylesheet: {
2638
- sourceLinesOfCode: xi.total + ye + Ie + Ut.size(),
2639
- linesOfCode: i,
2640
- size: _i,
2641
- complexity: ui.sum + fi.sum + pi.sum + di.sum + gi.sum,
2642
- comments: {
2643
- total: n,
2644
- size: l
2645
- },
2646
- embeddedContent: {
2647
- size: {
2648
- total: a,
2649
- ratio: H(a, _i)
2650
- },
2651
- types: {
2652
- total: h.total,
2653
- totalUnique: h.unique.size,
2654
- uniquenessRatio: H(h.unique.size, h.total),
2655
- unique: Object.fromEntries(h.unique)
2656
- }
2657
- }
2658
- },
2659
- atrules: R(xi, {
2660
- fontface: R(
2661
- {
2662
- total: jt,
2663
- totalUnique: jt,
2664
- unique: L,
2665
- uniquenessRatio: jt === 0 ? 0 : 1
2666
- },
2667
- t ? {
2668
- uniqueWithLocations: bs.c().uniqueWithLocations
2669
- } : {}
2670
- ),
2671
- import: Rs.c(),
2672
- media: R(vs.c(), {
2673
- browserhacks: Ts.c(),
2674
- features: Ss.c()
2675
- }),
2676
- charset: Os.c(),
2677
- supports: R(yt.c(), {
2678
- browserhacks: Ns.c()
2679
- }),
2680
- keyframes: R(Ct.c(), {
2681
- prefixed: R(bt.c(), {
2682
- ratio: H(bt.size(), Ct.size())
2683
- })
2684
- }),
2685
- container: R(Ls.c(), {
2686
- names: Je.c()
2687
- }),
2688
- layer: Ze.c(),
2689
- property: Us.c(),
2690
- scope: Is.c(),
2691
- complexity: ui,
2692
- nesting: R(
2693
- Rt.aggregate(),
2694
- {
2695
- items: Rt.toArray()
2696
- },
2697
- Hs.c()
2698
- )
2699
- }),
2700
- rules: {
2701
- total: vt,
2702
- empty: {
2703
- total: Tt,
2704
- ratio: H(Tt, vt)
2705
- },
2706
- sizes: R(
2707
- St.aggregate(),
2708
- {
2709
- items: St.toArray()
2710
- },
2711
- Ps.c()
2712
- ),
2713
- nesting: R(
2714
- Lt.aggregate(),
2715
- {
2716
- items: Lt.toArray()
2717
- },
2718
- Ms.c()
2719
- ),
2720
- selectors: R(
2721
- Ot.aggregate(),
2722
- {
2723
- items: Ot.toArray()
2724
- },
2725
- Ds.c()
2726
- ),
2727
- declarations: R(
2728
- Nt.aggregate(),
2729
- {
2730
- items: Nt.toArray()
2731
- },
2732
- Fs.c()
2733
- )
2734
- },
2735
- selectors: {
2736
- total: ye,
2737
- totalUnique: ci,
2738
- uniquenessRatio: H(ci, ye),
2739
- specificity: R(
2740
- {
2741
- /** @type Specificity */
2742
- min: fe === void 0 ? [0, 0, 0] : fe,
2743
- /** @type Specificity */
2744
- max: ue === void 0 ? [0, 0, 0] : ue,
2745
- /** @type Specificity */
2746
- sum: [Yt.sum, Qt.sum, Vt.sum],
2747
- /** @type Specificity */
2748
- mean: [Yt.mean, Qt.mean, Vt.mean],
2749
- /** @type Specificity */
2750
- mode: [Yt.mode, Qt.mode, Vt.mode],
2751
- /** @type Specificity */
2752
- items: Ws
2753
- },
2754
- Bs.c()
2755
- ),
2756
- complexity: R(fi, Gs.c(), {
2757
- items: et.toArray()
2758
- }),
2759
- nesting: R(
2760
- Dt.aggregate(),
2761
- {
2762
- items: Dt.toArray()
2763
- },
2764
- Xs.c()
2765
- ),
2766
- id: R(Ht.c(), {
2767
- ratio: H(Ht.size(), ye)
2768
- }),
2769
- pseudoClasses: Ys.c(),
2770
- pseudoElements: Qs.c(),
2771
- accessibility: R(Pt.c(), {
2772
- ratio: H(Pt.size(), ye)
2773
- }),
2774
- attributes: Vs.c(),
2775
- keyframes: Ut.c(),
2776
- prefixed: R(It.c(), {
2777
- ratio: H(It.size(), ye)
2778
- }),
2779
- combinators: js.c()
2780
- },
2781
- declarations: {
2782
- total: Ie,
2783
- totalUnique: hi,
2784
- uniquenessRatio: H(hi, Ie),
2785
- importants: {
2786
- total: tt,
2787
- ratio: H(tt, Ie),
2788
- inKeyframes: {
2789
- total: Ft,
2790
- ratio: H(Ft, tt)
2791
- }
2792
- },
2793
- complexity: pi,
2794
- nesting: R(
2795
- zt.aggregate(),
2796
- {
2797
- items: zt.toArray()
2798
- },
2799
- ei.c()
2800
- )
2801
- },
2802
- properties: R(He.c(), {
2803
- prefixed: R(Kt.c(), {
2804
- ratio: H(Kt.size(), He.size())
2805
- }),
2806
- custom: R(st.c(), {
2807
- ratio: H(st.size(), He.size()),
2808
- importants: R(Mt.c(), {
2809
- ratio: H(Mt.size(), st.size())
2810
- })
2811
- }),
2812
- browserhacks: R(qt.c(), {
2813
- ratio: H(qt.size(), He.size())
2814
- }),
2815
- complexity: di
2816
- }),
2817
- values: {
2818
- colors: R(we.count(), {
2819
- formats: Ae.c()
2820
- }),
2821
- gradients: li.c(),
2822
- fontFamilies: Gt.c(),
2823
- fontSizes: rt.c(),
2824
- lineHeights: nt.c(),
2825
- zindexes: si.c(),
2826
- textShadows: ii.c(),
2827
- boxShadows: ri.c(),
2828
- borderRadiuses: oi.count(),
2829
- animations: {
2830
- durations: lt.c(),
2831
- timingFunctions: Wt.c()
2832
- },
2833
- prefixes: ti.c(),
2834
- browserhacks: Bt.c(),
2835
- units: ni.count(),
2836
- complexity: gi,
2837
- keywords: De.c(),
2838
- resets: ai.c(),
2839
- displays: it.c()
2840
- },
2841
- __meta__: {
2842
- parseTime: p - o,
2843
- analyzeTime: Date.now() - p,
2844
- total: Date.now() - s
2845
- }
2846
- };
2847
- }
2848
- function $i(r, e) {
2849
- return r[0] === e[0] ? r[1] === e[1] ? e[2] - r[2] : e[1] - r[1] : e[0] - r[0];
2850
- }
2851
- export {
2852
- W as KeywordSet,
2853
- Ol as analyze,
2854
- Fi as calculateSpecificity,
2855
- ul as colorFunctions,
2856
- fl as colorKeywords,
2857
- $i as compareSpecificity,
2858
- mt as cssKeywords,
2859
- Sl as hasVendorPrefix,
2860
- Wr as isAccessibilitySelector,
2861
- Kr as isMediaBrowserhack,
2862
- Rl as isPropertyHack,
2863
- Gr as isSelectorPrefixed,
2864
- qr as isSupportsBrowserhack,
2865
- Al as isValuePrefixed,
2866
- cl as namedColors,
2867
- as as selectorComplexity,
2868
- _l as systemColors
2869
- };