@tbela99/css-parser 1.6.4 → 1.6.6

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.
package/dist/index.cjs CHANGED
@@ -3518,7 +3518,7 @@ var syntaxes = {
3518
3518
  syntax: "<number> | <percentage> | none"
3519
3519
  },
3520
3520
  "an+b": {
3521
- syntax: "odd | even | <integer> | <n-dimension> | '+'?† n | -n | <ndashdigit-dimension> | '+'?† <ndashdigit-ident> | <dashndashdigit-ident> | <n-dimension> <signed-integer> | '+'?† n <signed-integer> | -n <signed-integer> | <ndash-dimension> <signless-integer> | '+'?† n- <signless-integer> | -n- <signless-integer> | <n-dimension> ['+' | '-'] <signless-integer> | '+'?† n ['+' | '-'] <signless-integer> | -n ['+' | '-'] <signless-integer>"
3521
+ syntax: "odd | even | <integer> | <n-dimension> | '+'? n | -n | <ndashdigit-dimension> | '+'? <ndashdigit-ident> | <dashndashdigit-ident> | <n-dimension> <signed-integer> | '+'? n <signed-integer> | -n <signed-integer> | <ndash-dimension> <signless-integer> | '+'? n- <signless-integer> | -n- <signless-integer> | <n-dimension> ['+' | '-'] <signless-integer> | '+'? n ['+' | '-'] <signless-integer> | -n ['+' | '-'] <signless-integer>"
3522
3522
  },
3523
3523
  "anchor()": {
3524
3524
  syntax: "anchor( <anchor-name>? && <anchor-side>, <length-percentage>? )"
@@ -5551,6 +5551,9 @@ var atRules = {
5551
5551
  marks: {
5552
5552
  syntax: "none | [ crop || cross ]"
5553
5553
  },
5554
+ "page-margin-safety": {
5555
+ syntax: "none | clamp | add"
5556
+ },
5554
5557
  "page-orientation": {
5555
5558
  syntax: "upright | rotate-left | rotate-right"
5556
5559
  },
@@ -6432,6 +6435,11 @@ const anglePrecision = 3;
6432
6435
  * Color range definitions
6433
6436
  */
6434
6437
  const colorRange = {
6438
+ rgb: {
6439
+ r: [0, 255],
6440
+ g: [0, 255],
6441
+ b: [0, 255],
6442
+ },
6435
6443
  lab: {
6436
6444
  l: [0, 100],
6437
6445
  a: [-125, 125],
@@ -6901,13 +6909,6 @@ function equalsIgnoreCase(a, b) {
6901
6909
  }
6902
6910
 
6903
6911
  function getColorComponents(token) {
6904
- // if (token.typ === EnumToken.IdenTokenType) {
6905
- // if (isColor(token)) {
6906
- // parseColor(token);
6907
- // } else {
6908
- // return null;
6909
- // }
6910
- // }
6911
6912
  if (token.kin == exports.ColorType.HEX || token.kin == exports.ColorType.LIT) {
6912
6913
  if (equalsIgnoreCase("currentcolor", token.val)) {
6913
6914
  return null;
@@ -6931,25 +6932,12 @@ function getColorComponents(token) {
6931
6932
  ].includes(child.typ)) {
6932
6933
  continue;
6933
6934
  }
6934
- // if (child.typ === EnumToken.IdenTokenType && isColor(child)) {
6935
- // parseColor(child);
6936
- // }
6937
6935
  if (child.typ === exports.EnumToken.FunctionTokenType ||
6938
6936
  child.typ === exports.EnumToken.WildCardFunctionTokenType ||
6939
6937
  child.typ === exports.EnumToken.MathFunctionTokenType) {
6940
6938
  if ("var" == child.val.toLowerCase()) {
6941
6939
  return null;
6942
6940
  }
6943
- // else {
6944
- // for (const { value } of walkValues((child as FunctionToken).chi)) {
6945
- // if (
6946
- // value.typ == EnumToken.WildCardFunctionTokenDefType &&
6947
- // "var" === (value as FunctionToken).val.toLowerCase()
6948
- // ) {
6949
- // return null;
6950
- // }
6951
- // }
6952
- // }
6953
6941
  }
6954
6942
  if (child.typ == exports.EnumToken.ColorTokenType && equalsIgnoreCase("currentcolor", child.val)) {
6955
6943
  return null;
@@ -8245,7 +8233,10 @@ function color2HexToken(token) {
8245
8233
  if (value == null) {
8246
8234
  return null;
8247
8235
  }
8248
- return hexToken(value.reduce((acc, curr) => acc + srgb2rgb(curr + Number.EPSILON).toString(16).padStart(2, "0"), "#"));
8236
+ return hexToken(value.reduce((acc, curr) => acc +
8237
+ srgb2rgb(curr + Number.EPSILON)
8238
+ .toString(16)
8239
+ .padStart(2, "0"), "#"));
8249
8240
  }
8250
8241
  function oklab2HexToken(token) {
8251
8242
  let value = oklab2srgbvalues(token);
@@ -9094,7 +9085,7 @@ function la98rgb2a98rgb(r, g, b, a = null) {
9094
9085
  // convert an array of linear-light a98-rgb in the range 0.0-1.0
9095
9086
  // to gamma corrected form
9096
9087
  // negative values are also now accepted
9097
- return [r, b, g]
9088
+ return [r, g, b]
9098
9089
  .map(function (val) {
9099
9090
  let sign = val < 0 ? -1 : 1;
9100
9091
  let abs = Math.abs(val);
@@ -9230,6 +9221,9 @@ function colorMix(...args) {
9230
9221
  if (values == null) {
9231
9222
  return null;
9232
9223
  }
9224
+ if (colorSpace == "hwb") {
9225
+ colorSpace = "srgb";
9226
+ }
9233
9227
  switch (colorSpace) {
9234
9228
  case "srgb":
9235
9229
  break;
@@ -9259,17 +9253,17 @@ function colorMix(...args) {
9259
9253
  values = srgb2xyz_d65(values[0], values[1], values[2], values[3]);
9260
9254
  values = XYZ_D65_to_D50(values[0], values[1], values[2], values[3]);
9261
9255
  break;
9262
- case "rgb":
9263
- for (let j = 0; j < values.length; j++) {
9264
- values[j] = j == 3 ? values[j] : srgb2rgb(values[j]);
9265
- }
9266
- break;
9256
+ // case "rgb":
9257
+ // for (let j = 0; j < values.length; j++) {
9258
+ // values[j] = j == 3 ? values[j] : srgb2rgb(values[j]);
9259
+ // }
9260
+ // break;
9267
9261
  case "hsl":
9268
9262
  values = srgb2hslvalues(values[0], values[1], values[2], values[3]);
9269
9263
  break;
9270
- case "hwb":
9271
- values = srgb2hwb(values[0], values[1], values[2], values[3]);
9272
- break;
9264
+ // case "hwb":
9265
+ // values = srgb2hwb(values[0], values[1], values[2], values[3]);
9266
+ // break;
9273
9267
  case "lab":
9274
9268
  values = srgb2labvalues(values[0], values[1], values[2], values[3]);
9275
9269
  break;
@@ -9468,14 +9462,14 @@ function colorMix(...args) {
9468
9462
  kin: exports.ColorType.COLOR,
9469
9463
  cal: "col",
9470
9464
  };
9471
- case "rgb":
9465
+ // case "rgb":
9472
9466
  case "hsl":
9473
- case "hwb":
9467
+ // case "hwb":
9474
9468
  case "lab":
9475
9469
  case "lch":
9476
9470
  case "oklab":
9477
9471
  case "oklch":
9478
- if (colorSpace == "hsl" || colorSpace == "hwb") {
9472
+ if (colorSpace == "hsl") {
9479
9473
  // @ts-ignore
9480
9474
  if (values[2] < 0) {
9481
9475
  // @ts-ignore
@@ -9505,7 +9499,7 @@ function colorMix(...args) {
9505
9499
  }),
9506
9500
  kin: exports.ColorType[colorSpace.toUpperCase().replaceAll("-", "_")],
9507
9501
  };
9508
- if (colorSpace == "hsl" || colorSpace == "hwb") {
9502
+ if (colorSpace == "hsl") {
9509
9503
  // @ts-ignore
9510
9504
  result.chi[0] = { typ: exports.EnumToken.AngleTokenType, val: result.chi[0].val * 360 };
9511
9505
  // @ts-ignore
@@ -10039,6 +10033,7 @@ function simplify(a, b) {
10039
10033
  return g > 1 ? [a / g, b / g] : [a, b];
10040
10034
  }
10041
10035
 
10036
+ const numbers = new Set(["sin", "cos", "asin", "acos", "sign", "tan"]);
10042
10037
  /**
10043
10038
  * evaluate an array of tokens
10044
10039
  * @param tokens
@@ -10100,6 +10095,7 @@ function evaluate(tokens) {
10100
10095
  [LOCSRCID]: nodes[0][LOCSRCID],
10101
10096
  [LOCSTA]: nodes[0][LOCSTA],
10102
10097
  [LOCEND]: nodes[0][LOCEND],
10098
+ [PARENT]: nodes[0][PARENT],
10103
10099
  },
10104
10100
  ];
10105
10101
  }
@@ -10122,6 +10118,7 @@ function evaluate(tokens) {
10122
10118
  [LOCSRCID]: nodes[i][LOCSRCID],
10123
10119
  [LOCSTA]: nodes[i][LOCSTA],
10124
10120
  [LOCEND]: nodes[i + 1][LOCEND],
10121
+ [PARENT]: nodes[i + 1][PARENT],
10125
10122
  };
10126
10123
  }
10127
10124
  else {
@@ -10131,6 +10128,7 @@ function evaluate(tokens) {
10131
10128
  [LOCSRCID]: nodes[i + 1][LOCSRCID],
10132
10129
  [LOCSTA]: nodes[i + 1][LOCSTA],
10133
10130
  [LOCEND]: nodes[i + 1][LOCEND],
10131
+ [PARENT]: nodes[i + 1][PARENT],
10134
10132
  }, exports.EnumToken.Mul);
10135
10133
  }
10136
10134
  i++;
@@ -10151,12 +10149,14 @@ function evaluate(tokens) {
10151
10149
  [LOCSRCID]: token[LOCSRCID],
10152
10150
  [LOCSTA]: token[LOCSTA],
10153
10151
  [LOCEND]: token[LOCEND],
10152
+ [PARENT]: token[PARENT],
10154
10153
  }, {
10155
10154
  ...token,
10156
10155
  val: -token.val,
10157
10156
  [LOCSRCID]: token[LOCSRCID],
10158
10157
  [LOCSTA]: token[LOCSTA],
10159
10158
  [LOCEND]: token[LOCEND],
10159
+ [PARENT]: token[PARENT],
10160
10160
  });
10161
10161
  return acc;
10162
10162
  }
@@ -10167,6 +10167,7 @@ function evaluate(tokens) {
10167
10167
  [LOCSRCID]: token[LOCSRCID],
10168
10168
  [LOCSTA]: token[LOCSTA],
10169
10169
  [LOCEND]: token[LOCEND],
10170
+ [PARENT]: token[PARENT],
10170
10171
  });
10171
10172
  }
10172
10173
  acc.push(token);
@@ -10188,6 +10189,7 @@ function doEvaluate(l, r, op) {
10188
10189
  [LOCSRCID]: l[LOCSRCID],
10189
10190
  [LOCSTA]: l[LOCSTA],
10190
10191
  [LOCEND]: r?.[LOCEND] ?? l[LOCEND],
10192
+ [PARENT]: l[PARENT],
10191
10193
  };
10192
10194
  if (!isScalarToken(l) || !isScalarToken(r) || (l.typ == r.typ && "unit" in l && "unit" in r && l.unit != r.unit)) {
10193
10195
  return defaultReturn;
@@ -10221,9 +10223,22 @@ function doEvaluate(l, r, op) {
10221
10223
  r.typ == exports.EnumToken.NegativeInfinityTokenType) {
10222
10224
  return computeInfinity(l, r, op, defaultReturn);
10223
10225
  }
10226
+ if (l.typ == exports.EnumToken.FunctionTokenType || l.typ == exports.EnumToken.MathFunctionTokenType) {
10227
+ const val = evaluateFunc(l);
10228
+ if (val == null ||
10229
+ (val.length == 1 &&
10230
+ (val[0].typ == exports.EnumToken.MathFunctionTokenType || val[0].typ == exports.EnumToken.FunctionTokenType))) {
10231
+ return defaultReturn;
10232
+ }
10233
+ if (val.length == 1) {
10234
+ l = val[0];
10235
+ }
10236
+ }
10224
10237
  if (r.typ == exports.EnumToken.FunctionTokenType || r.typ == exports.EnumToken.MathFunctionTokenType) {
10225
10238
  const val = evaluateFunc(r);
10226
- if (val == null) {
10239
+ if (val == null ||
10240
+ (val.length == 1 &&
10241
+ (val[0].typ == exports.EnumToken.MathFunctionTokenType || val[0].typ == exports.EnumToken.FunctionTokenType))) {
10227
10242
  return defaultReturn;
10228
10243
  }
10229
10244
  if (val.length == 1) {
@@ -10260,6 +10275,7 @@ function doEvaluate(l, r, op) {
10260
10275
  [LOCSRCID]: l[LOCSRCID],
10261
10276
  [LOCSTA]: l[LOCSTA],
10262
10277
  [LOCEND]: l[LOCEND],
10278
+ [PARENT]: l[PARENT],
10263
10279
  },
10264
10280
  r: {
10265
10281
  typ: exports.EnumToken.NumberTokenType,
@@ -10267,6 +10283,7 @@ function doEvaluate(l, r, op) {
10267
10283
  [LOCSRCID]: r[LOCSRCID],
10268
10284
  [LOCSTA]: r[LOCSTA],
10269
10285
  [LOCEND]: r[LOCEND],
10286
+ [PARENT]: r[PARENT],
10270
10287
  },
10271
10288
  };
10272
10289
  }
@@ -10279,6 +10296,7 @@ function doEvaluate(l, r, op) {
10279
10296
  [LOCSRCID]: l[LOCSRCID],
10280
10297
  [LOCSTA]: l[LOCSTA],
10281
10298
  [LOCEND]: l[LOCEND],
10299
+ [PARENT]: l[PARENT],
10282
10300
  },
10283
10301
  r: {
10284
10302
  typ: exports.EnumToken.NumberTokenType,
@@ -10286,6 +10304,7 @@ function doEvaluate(l, r, op) {
10286
10304
  [LOCSRCID]: r[LOCSRCID],
10287
10305
  [LOCSTA]: r[LOCSTA],
10288
10306
  [LOCEND]: r[LOCEND],
10307
+ [PARENT]: r[PARENT],
10289
10308
  },
10290
10309
  };
10291
10310
  }
@@ -10312,6 +10331,7 @@ function doEvaluate(l, r, op) {
10312
10331
  [LOCSRCID]: l[LOCSRCID],
10313
10332
  [LOCSTA]: l[LOCSTA],
10314
10333
  [LOCEND]: r?.[LOCEND] ?? l[LOCEND],
10334
+ [PARENT]: l[PARENT],
10315
10335
  };
10316
10336
  if (token.typ == exports.EnumToken.IdenTokenType) {
10317
10337
  // @ts-ignore
@@ -10436,45 +10456,43 @@ function getValue$1(t) {
10436
10456
  function evaluateFunc(token) {
10437
10457
  const values = token.chi.slice();
10438
10458
  switch (token.val) {
10439
- case "abs":
10440
10459
  case "sin":
10441
10460
  case "cos":
10442
10461
  case "tan":
10462
+ for (let i = 0; i < values.length; i++) {
10463
+ if (values[i].typ == exports.EnumToken.NumberTokenType) {
10464
+ values[i] = Object.assign(values[i], { typ: exports.EnumToken.AngleTokenType, unit: "rad" });
10465
+ }
10466
+ else if (values[i].typ == exports.EnumToken.AngleTokenType && values[i].unit != "rad") {
10467
+ switch (values[i].unit) {
10468
+ case "deg":
10469
+ Object.assign(values[i], {
10470
+ unit: "rad",
10471
+ val: values[i].val * (Math.PI / 180),
10472
+ });
10473
+ break;
10474
+ case "grad":
10475
+ Object.assign(values[i], {
10476
+ unit: "rad",
10477
+ val: values[i].val * (Math.PI / 200),
10478
+ });
10479
+ break;
10480
+ case "turn":
10481
+ Object.assign(values[i], {
10482
+ unit: "rad",
10483
+ val: values[i].val * (2 * Math.PI),
10484
+ });
10485
+ break;
10486
+ }
10487
+ }
10488
+ }
10443
10489
  case "asin":
10444
10490
  case "acos":
10445
10491
  case "atan":
10492
+ case "abs":
10446
10493
  case "sign":
10447
10494
  case "sqrt":
10448
- case "exp": {
10449
- if (token.val == "tan" || token.val == "atan") {
10450
- for (let i = 0; i < values.length; i++) {
10451
- if (values[i].typ == exports.EnumToken.NumberTokenType) {
10452
- values[i] = Object.assign(values[i], { typ: exports.EnumToken.AngleTokenType, unit: "rad" });
10453
- }
10454
- else if (values[i].typ == exports.EnumToken.AngleTokenType && values[i].unit != "rad") {
10455
- switch (values[i].unit) {
10456
- case "deg":
10457
- Object.assign(values[i], {
10458
- unit: "rad",
10459
- val: values[i].val * (Math.PI / 180),
10460
- });
10461
- break;
10462
- case "grad":
10463
- Object.assign(values[i], {
10464
- unit: "rad",
10465
- val: values[i].val * (Math.PI / 200),
10466
- });
10467
- break;
10468
- case "turn":
10469
- Object.assign(values[i], {
10470
- unit: "rad",
10471
- val: values[i].val * (2 * Math.PI),
10472
- });
10473
- break;
10474
- }
10475
- }
10476
- }
10477
- }
10495
+ case "exp":
10478
10496
  const value = evaluate(values);
10479
10497
  // @ts-ignore
10480
10498
  let val = value[0].typ == exports.EnumToken.NumberTokenType ||
@@ -10484,7 +10502,7 @@ function evaluateFunc(token) {
10484
10502
  : // @ts-expect-error
10485
10503
  value[0].l.val / value[0].r.val;
10486
10504
  return [
10487
- token.val == "tan" || token.val == "atan"
10505
+ token.val == "asin" || token.val == "acos" || token.val == "atan"
10488
10506
  ? {
10489
10507
  typ: exports.EnumToken.AngleTokenType,
10490
10508
  val: Math[token.val](val),
@@ -10492,16 +10510,17 @@ function evaluateFunc(token) {
10492
10510
  [LOCSRCID]: value[0][LOCSRCID],
10493
10511
  [LOCSTA]: value[0][LOCSTA],
10494
10512
  [LOCEND]: value[0][LOCEND],
10513
+ [PARENT]: value[0][PARENT],
10495
10514
  }
10496
10515
  : {
10497
- typ: token.val == "sign" ? exports.EnumToken.NumberTokenType : value[0].typ,
10516
+ typ: numbers.has(token.val) ? exports.EnumToken.NumberTokenType : value[0].typ,
10498
10517
  val: Math[token.val](val),
10499
10518
  [LOCSRCID]: value[0][LOCSRCID],
10500
10519
  [LOCSTA]: value[0][LOCSTA],
10501
10520
  [LOCEND]: value[0][LOCEND],
10521
+ [PARENT]: value[0][PARENT],
10502
10522
  },
10503
10523
  ];
10504
- }
10505
10524
  case "hypot": {
10506
10525
  const chi = values.filter((t) => ![exports.EnumToken.WhitespaceTokenType, exports.EnumToken.CommentTokenType, exports.EnumToken.CommaTokenType].includes(t.typ));
10507
10526
  let all = [];
@@ -10521,6 +10540,7 @@ function evaluateFunc(token) {
10521
10540
  [LOCSRCID]: token[LOCSRCID],
10522
10541
  [LOCSTA]: token[LOCSTA],
10523
10542
  [LOCEND]: token[LOCEND],
10543
+ [PARENT]: token[PARENT],
10524
10544
  },
10525
10545
  ];
10526
10546
  }
@@ -10594,6 +10614,7 @@ function evaluateFunc(token) {
10594
10614
  [LOCSRCID]: token[LOCSRCID],
10595
10615
  [LOCSTA]: token[LOCSTA],
10596
10616
  [LOCEND]: token[LOCEND],
10617
+ [PARENT]: token[PARENT],
10597
10618
  },
10598
10619
  ];
10599
10620
  }
@@ -10608,6 +10629,7 @@ function evaluateFunc(token) {
10608
10629
  [LOCSRCID]: token[LOCSRCID],
10609
10630
  [LOCSTA]: token[LOCSTA],
10610
10631
  [LOCEND]: token[LOCEND],
10632
+ [PARENT]: token[PARENT],
10611
10633
  },
10612
10634
  ];
10613
10635
  }
@@ -10618,6 +10640,7 @@ function evaluateFunc(token) {
10618
10640
  [LOCSRCID]: token[LOCSRCID],
10619
10641
  [LOCSTA]: token[LOCSTA],
10620
10642
  [LOCEND]: token[LOCEND],
10643
+ [PARENT]: token[PARENT],
10621
10644
  },
10622
10645
  ];
10623
10646
  }
@@ -10657,6 +10680,7 @@ function evaluateFunc(token) {
10657
10680
  [LOCSRCID]: token[LOCSRCID],
10658
10681
  [LOCSTA]: token[LOCSTA],
10659
10682
  [LOCEND]: token[LOCEND],
10683
+ [PARENT]: token[PARENT],
10660
10684
  },
10661
10685
  ];
10662
10686
  }
@@ -10699,6 +10723,7 @@ function evaluateFunc(token) {
10699
10723
  [LOCSRCID]: token[LOCSRCID],
10700
10724
  [LOCSTA]: token[LOCSTA],
10701
10725
  [LOCEND]: token[LOCEND],
10726
+ [PARENT]: token[PARENT],
10702
10727
  },
10703
10728
  ];
10704
10729
  }
@@ -10726,6 +10751,7 @@ function inlineExpression$1(token) {
10726
10751
  [LOCSRCID]: token[LOCSRCID],
10727
10752
  [LOCSTA]: token[LOCSTA],
10728
10753
  [LOCEND]: token[LOCEND],
10754
+ [PARENT]: token[PARENT],
10729
10755
  });
10730
10756
  for (const child of inlineExpression$1(token.r)) {
10731
10757
  result.push(child);
@@ -10805,6 +10831,7 @@ function factorToken(token) {
10805
10831
  [LOCSRCID]: token[LOCSRCID],
10806
10832
  [LOCSTA]: token[LOCSTA],
10807
10833
  [LOCEND]: token[LOCEND],
10834
+ [PARENT]: token[PARENT],
10808
10835
  };
10809
10836
  // @ts-ignore
10810
10837
  delete token.val;
@@ -10846,6 +10873,7 @@ function factor(tokens, ops) {
10846
10873
  [LOCSRCID]: tokens[i - 1][LOCSRCID],
10847
10874
  [LOCSTA]: tokens[i - 1][LOCSTA],
10848
10875
  [LOCEND]: tokens[i + 1][LOCEND],
10876
+ [PARENT]: tokens[i + 1][PARENT],
10849
10877
  });
10850
10878
  i--;
10851
10879
  }
@@ -10891,20 +10919,20 @@ function parseRelativeColorComponents(relativeKeys, original, rExp, gExp, bExp,
10891
10919
  continue;
10892
10920
  }
10893
10921
  if (component.typ == exports.EnumToken.IdenTokenType) {
10894
- val = component.val.toLowerCase();
10922
+ val = component.val;
10895
10923
  if (
10896
10924
  // @ts-expect-error
10897
10925
  typeof Math[val.toUpperCase()] !== "number" &&
10898
- val != "in" &&
10899
- val != "hue" &&
10900
- val != "from" &&
10901
- val != "alpha" &&
10902
- val != "none" &&
10903
- val != "shorter" &&
10904
- val != "longer" &&
10905
- val != "increasing" &&
10906
- val != "decreasing" &&
10907
- !colorsFunc.includes(val) &&
10926
+ !equalsIgnoreCase(val, "in") &&
10927
+ !equalsIgnoreCase(val, "hue") &&
10928
+ !equalsIgnoreCase(val, "from") &&
10929
+ !equalsIgnoreCase(val, "alpha") &&
10930
+ !equalsIgnoreCase(val, "none") &&
10931
+ !equalsIgnoreCase(val, "shorter") &&
10932
+ !equalsIgnoreCase(val, "longer") &&
10933
+ !equalsIgnoreCase(val, "increasing") &&
10934
+ !equalsIgnoreCase(val, "decreasing") &&
10935
+ !colorsFunc.some((t) => equalsIgnoreCase(t, val)) &&
10908
10936
  !colorFuncColorSpace.includes(val) &&
10909
10937
  !validKeys.includes(val)) {
10910
10938
  return null;
@@ -12247,7 +12275,8 @@ function isMFValue(featureName, tokens, isMFRange) {
12247
12275
  return { valid: true, success: false, isValueAllowed: false };
12248
12276
  }
12249
12277
  featureName = featureName.toLowerCase();
12250
- if (!(featureName in config$3.mediaFeatures)) {
12278
+ // @ts-expect-error
12279
+ if (config$3.mediaFeatures[featureName] == null) {
12251
12280
  return { valid: false, success: false };
12252
12281
  }
12253
12282
  // @ts-expect-error
@@ -12291,8 +12320,7 @@ function isMFValue(featureName, tokens, isMFRange) {
12291
12320
  return {
12292
12321
  valid: true,
12293
12322
  success: (tokens.length == 1 &&
12294
- tokens[0].typ == exports.EnumToken.NumberTokenType &&
12295
- tokens[0].val.typ == exports.EnumToken.FractionTokenType) ||
12323
+ tokens[0].typ == exports.EnumToken.NumberTokenType) ||
12296
12324
  (tokens.length === 3 &&
12297
12325
  tokens[0].typ == exports.EnumToken.NumberTokenType &&
12298
12326
  typeof tokens[0].val === "number" &&
@@ -12808,7 +12836,8 @@ function matchAllSyntaxes(syntaxes, context, options) {
12808
12836
  for (let i = index; i < syntaxes.length; i++) {
12809
12837
  if (syntaxes[i].typ == ValidationTokenEnum.Whitespace ||
12810
12838
  syntaxes[i].isOptional ||
12811
- syntaxes[i].isRepeatable) {
12839
+ syntaxes[i].isRepeatable ||
12840
+ syntaxes[i].match?.min?.val === 0) {
12812
12841
  continue;
12813
12842
  }
12814
12843
  return {
@@ -14513,7 +14542,6 @@ function alpha(color, alpha) {
14513
14542
  }
14514
14543
  let components = getColorComponents(color);
14515
14544
  if (alpha.typ === exports.EnumToken.MathFunctionTokenType) {
14516
- const originalAlpha = cloneNode(alpha, true);
14517
14545
  for (const { value } of walkValues(alpha.chi, alpha)) {
14518
14546
  if (value.typ === exports.EnumToken.IdenTokenType) {
14519
14547
  if (equalsIgnoreCase(value.val, "alpha")) {
@@ -14525,22 +14553,22 @@ function alpha(color, alpha) {
14525
14553
  });
14526
14554
  // continue;
14527
14555
  }
14528
- else if (equalsIgnoreCase(value.val, "none")) {
14529
- Object.assign(value, {
14530
- typ: exports.EnumToken.NumberTokenType,
14531
- val: 0,
14532
- });
14533
- }
14556
+ // else if (equalsIgnoreCase((value as IdentToken).val, "none")) {
14557
+ // Object.assign(value, {
14558
+ // typ: EnumToken.NumberTokenType,
14559
+ // val: 0,
14560
+ // });
14561
+ // }
14534
14562
  }
14535
14563
  }
14536
14564
  const result = evaluate([alpha]);
14537
14565
  if (result.length == 1) {
14538
14566
  alpha = result[0];
14539
14567
  }
14540
- else {
14541
- // @ts-expect-error
14542
- alpha = originalAlpha;
14543
- }
14568
+ // else {
14569
+ // // @ts-expect-error
14570
+ // alpha = originalAlpha;
14571
+ // }
14544
14572
  }
14545
14573
  // console.error({ alpha });
14546
14574
  if (alpha.typ !== exports.EnumToken.IdenTokenType &&
@@ -14566,17 +14594,17 @@ function alpha(color, alpha) {
14566
14594
  return null;
14567
14595
  }
14568
14596
  if (alpha?.typ === exports.EnumToken.IdenTokenType) {
14569
- if (equalsIgnoreCase(alpha.val, "alpha")) {
14570
- alpha = components[3] ?? {
14571
- typ: exports.EnumToken.NumberTokenType,
14572
- val: 1,
14573
- };
14574
- }
14575
- else if (equalsIgnoreCase(alpha.val, "node")) {
14576
- alpha = {
14597
+ // if (equalsIgnoreCase((alpha as IdentToken).val, "alpha")) {
14598
+ // alpha = components[3] ?? {
14599
+ // typ: EnumToken.NumberTokenType,
14600
+ // val: 1,
14601
+ // };
14602
+ // } else
14603
+ if (equalsIgnoreCase(alpha.val, "none")) {
14604
+ Object.assign(alpha, {
14577
14605
  typ: exports.EnumToken.NumberTokenType,
14578
14606
  val: 0,
14579
- };
14607
+ });
14580
14608
  }
14581
14609
  }
14582
14610
  return makeColor(color.kin, components, alpha);
@@ -15297,12 +15325,12 @@ function getColorSpace(color) {
15297
15325
  // '\\'
15298
15326
  const REVERSE_SOLIDUS = 0x5c;
15299
15327
  const flexUnits = ["fr"];
15300
- const frequencyUnits = ["hz", "khz"];
15328
+ const frequencyUnits = ["Hz", "kHz"];
15301
15329
  const timeUnits = ["ms", "s"];
15302
15330
  const angleUnits = ["rad", "turn", "deg", "grad"];
15303
15331
  const resolutionUnits = ["dpi", "dpcm", "dppx", "x"];
15304
15332
  const dimensionUnits = [
15305
- "q",
15333
+ "Q",
15306
15334
  "cap",
15307
15335
  "ch",
15308
15336
  "cm",
@@ -16986,7 +17014,7 @@ function replaceAstNodes(tokens, root) {
16986
17014
  }
16987
17015
  class ComputePrefixFeature {
16988
17016
  get ordering() {
16989
- return 2;
17017
+ return 0;
16990
17018
  }
16991
17019
  get processMode() {
16992
17020
  return exports.FeatureWalkMode.Pre;
@@ -17430,10 +17458,10 @@ function replace(node, variableScope) {
17430
17458
  class InlineCssVariablesFeature {
17431
17459
  accept = new Set([exports.EnumToken.RuleNodeType, exports.EnumToken.AtRuleNodeType]);
17432
17460
  get ordering() {
17433
- return 0;
17461
+ return 2;
17434
17462
  }
17435
17463
  get processMode() {
17436
- return exports.FeatureWalkMode.Pre;
17464
+ return exports.FeatureWalkMode.Post;
17437
17465
  }
17438
17466
  static register(options) {
17439
17467
  if (options.inlineCssVariables) {
@@ -19683,8 +19711,8 @@ function matchType(val, properties) {
19683
19711
 
19684
19712
  const propertiesConfig = getConfig();
19685
19713
  class PropertyMap {
19686
- config;
19687
19714
  declarations;
19715
+ config;
19688
19716
  requiredCount;
19689
19717
  pattern;
19690
19718
  constructor(config) {
@@ -19698,7 +19726,7 @@ class PropertyMap {
19698
19726
  }
19699
19727
  add(declaration) {
19700
19728
  if (declaration.nam == this.config.shorthand) {
19701
- this.declarations = new Map();
19729
+ this.declarations.clear();
19702
19730
  this.declarations.set(declaration.nam, declaration);
19703
19731
  this.matchTypes(declaration);
19704
19732
  }
@@ -19714,23 +19742,17 @@ class PropertyMap {
19714
19742
  if (this.declarations.has(this.config.shorthand)) {
19715
19743
  const tokens = {};
19716
19744
  const values = [];
19717
- // @ts-ignore
19718
- this.declarations
19719
- .get(this.config.shorthand)
19720
- // @ts-ignore
19721
- .val.slice()
19722
- .reduce((acc, curr) => {
19745
+ const val = [[]];
19746
+ for (const curr of this.declarations.get(this.config.shorthand).val) { // @ts-ignore
19723
19747
  // @ts-ignore
19724
19748
  if (separator != null && separator.typ == curr.typ && separator.val == curr.val) {
19725
- acc.push([]);
19726
- return acc;
19749
+ val.push([]);
19750
+ continue;
19727
19751
  }
19728
19752
  // @ts-ignore
19729
- acc.at(-1).push(curr);
19730
- return acc;
19731
- }, [[]])
19732
- // @ts-ignore
19733
- .reduce((acc, list, current) => {
19753
+ val.at(-1).push(curr);
19754
+ }
19755
+ for (let current = 0; current < val.length; current++) {
19734
19756
  values.push(...this.pattern.reduce((acc, property) => {
19735
19757
  // let current: number = 0;
19736
19758
  const props = this.config.properties[property];
@@ -19745,9 +19767,7 @@ class PropertyMap {
19745
19767
  // @ts-ignore
19746
19768
  acc[i][PROPERTYNAME] == property ||
19747
19769
  matchType(acc[i], props)) {
19748
- if ("prefix" in props &&
19749
- props.previous != null &&
19750
- !(props.previous in tokens)) {
19770
+ if ("prefix" in props && props.previous != null && !(props.previous in tokens)) {
19751
19771
  return acc;
19752
19772
  }
19753
19773
  if (!(property in tokens)) {
@@ -19812,9 +19832,8 @@ class PropertyMap {
19812
19832
  }
19813
19833
  }
19814
19834
  return acc;
19815
- }, list));
19816
- return values;
19817
- }, []);
19835
+ }, val[current]));
19836
+ }
19818
19837
  if (values.length == 0) {
19819
19838
  this.declarations = Object.entries(tokens).reduce((acc, curr) => {
19820
19839
  acc.set(curr[0], {
@@ -19874,17 +19893,40 @@ class PropertyMap {
19874
19893
  }
19875
19894
  if (hasMapping) {
19876
19895
  const mapped = {};
19877
- for (const key of declarations.keys()) {
19878
- const value = declarations.get(key);
19896
+ let key;
19897
+ for (const value of declarations.values()) {
19898
+ key = value.nam;
19879
19899
  if (value instanceof PropertyMap) {
19880
19900
  for (const [k, v] of value.declarations) {
19881
- mapped[k] = v;
19901
+ if (k == value.config.shorthand) {
19902
+ for (const [key, val] of Object.entries(value.config.properties)) {
19903
+ mapped[key] = cloneNode(v);
19904
+ for (let i = 0; i < v.val.length; i++) {
19905
+ // @ts-ignore
19906
+ if (key == v.val[i][PROPERTYNAME]) {
19907
+ if (mapped[key].val.length > 0) {
19908
+ mapped[key].val.push({
19909
+ typ: exports.EnumToken.WhitespaceTokenType,
19910
+ });
19911
+ }
19912
+ mapped[key].val.push(v.val[i]);
19913
+ }
19914
+ }
19915
+ if (mapped[key].val.length == 0) {
19916
+ mapped[key].val.push(...parseString(value.config.properties[key].default[0]));
19917
+ }
19918
+ }
19919
+ }
19920
+ else {
19921
+ mapped[k] = v;
19922
+ }
19882
19923
  }
19883
19924
  }
19884
19925
  else {
19885
19926
  mapped[key] = value;
19886
19927
  }
19887
19928
  }
19929
+ // console.error(mapped);
19888
19930
  if (patterns.length === Object.keys(mapped).length) {
19889
19931
  declarations = new Map();
19890
19932
  for (const key of patterns) {
@@ -20340,8 +20382,6 @@ class PropertyMap {
20340
20382
  }
20341
20383
  return acc;
20342
20384
  }, []);
20343
- // console.error({hasMapping, shorthand: this.config.shorthand, requiredCount, isShorthand,
20344
- // declarations: declarations.values(), values});
20345
20385
  if (this.config.mapping != null) {
20346
20386
  const val = values.reduce((acc, curr) => acc +
20347
20387
  renderValue(curr, {
@@ -20378,6 +20418,7 @@ class PropertyMap {
20378
20418
  }
20379
20419
  }
20380
20420
  const iterators = [];
20421
+ // @ts-ignore
20381
20422
  return {
20382
20423
  // @ts-ignore
20383
20424
  next() {
@@ -20630,6 +20671,9 @@ function syncHash(input, length = 6, algo) {
20630
20671
  }
20631
20672
 
20632
20673
  const config = getConfig();
20674
+ /**
20675
+ * Represents a list of property declarations, compute shorthand and remove duplicate declarations.
20676
+ */
20633
20677
  class PropertyList {
20634
20678
  options = { removeDuplicateDeclarations: true, computeShorthand: true };
20635
20679
  declarations;
@@ -20704,28 +20748,35 @@ class PropertyList {
20704
20748
  // @ts-ignore
20705
20749
  shorthand = config.property[propertyName];
20706
20750
  }
20707
- // console.error({shortHandType, propertyName, config: config.map[propertyName], map: config.map[shorthand].properties[propertyName]});
20708
20751
  // @ts-ignore
20709
20752
  if (shortHandType == "map") {
20710
20753
  let owner = this;
20754
+ const mapName =
20711
20755
  // @ts-ignore
20712
- const mapName = config.map[propertyName]?.map ?? config.map[shorthand]?.properties?.[propertyName]?.map;
20756
+ config.map[propertyName]?.map ?? config.map[shorthand]?.properties?.[propertyName]?.map;
20713
20757
  if (typeof mapName === "string") {
20714
20758
  if (!this.declarations.has(mapName)) {
20715
20759
  // @ts-ignore
20716
20760
  this.declarations.set(mapName, new PropertyMap(config.map[mapName]));
20717
20761
  }
20718
20762
  owner = this.declarations.get(mapName);
20719
- // console.error({mapName});
20720
20763
  }
20721
- // @ts-ignore
20722
- if (!owner.declarations.has(shorthand)) {
20764
+ else if (!this.declarations.has(shorthand)) {
20723
20765
  // @ts-ignore
20724
- owner.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
20766
+ this.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
20767
+ }
20768
+ if (owner == this) {
20769
+ // @ts-ignore
20770
+ owner.declarations.get(shorthand).add(declaration);
20771
+ }
20772
+ else {
20773
+ if (!owner.declarations.has(shorthand)) {
20774
+ // @ts-ignore
20775
+ owner.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
20776
+ }
20777
+ // @ts-ignore
20778
+ owner.declarations.get(shorthand).add(declaration);
20725
20779
  }
20726
- // console.error({propertyName,mapName, owned: owner == this});
20727
- // @ts-ignore
20728
- owner.declarations.get(shorthand).add(declaration);
20729
20780
  }
20730
20781
  // @ts-ignore
20731
20782
  else if (shortHandType == "set") {
@@ -20812,7 +20863,7 @@ class PropertyList {
20812
20863
  [Symbol.iterator]() {
20813
20864
  let iterator = this.declarations.values();
20814
20865
  const iterators = [];
20815
- // console.error(this);
20866
+ // @ts-ignore
20816
20867
  return {
20817
20868
  next() {
20818
20869
  let value = iterator.next();
@@ -20843,7 +20894,7 @@ class ComputeShorthandFeature {
20843
20894
  exports.EnumToken.KeyframesRuleNodeType,
20844
20895
  ]);
20845
20896
  get ordering() {
20846
- return 10;
20897
+ return 5;
20847
20898
  }
20848
20899
  get processMode() {
20849
20900
  return exports.FeatureWalkMode.Post;
@@ -20862,7 +20913,6 @@ class ComputeShorthandFeature {
20862
20913
  const j = ast.chi.length;
20863
20914
  let k = 0;
20864
20915
  let l;
20865
- // let properties: PropertyList = new PropertyList(options);
20866
20916
  const rules = [];
20867
20917
  const declarations = [];
20868
20918
  // @ts-ignore
@@ -20883,7 +20933,6 @@ class ComputeShorthandFeature {
20883
20933
  if (node.typ == exports.EnumToken.DeclarationNodeType) {
20884
20934
  for (let m = k; m <= l; m++) {
20885
20935
  declarations.push(ast.chi[m]);
20886
- // properties.add(ast.chi![m]);
20887
20936
  }
20888
20937
  }
20889
20938
  else {
@@ -20893,7 +20942,6 @@ class ComputeShorthandFeature {
20893
20942
  }
20894
20943
  k = l;
20895
20944
  }
20896
- // console.error([...new PropertyList(options).add(declarations)]);
20897
20945
  if (declarations.length > 0) {
20898
20946
  ast.chi.length = 0;
20899
20947
  // @ts-expect-error
@@ -21004,7 +21052,7 @@ function trimWhiteSpaceTokens(tokens) {
21004
21052
  class ComputeCalcExpressionFeature {
21005
21053
  accept = new Set([exports.EnumToken.RuleNodeType, exports.EnumToken.AtRuleNodeType]);
21006
21054
  get ordering() {
21007
- return 1;
21055
+ return 3;
21008
21056
  }
21009
21057
  get processMode() {
21010
21058
  return exports.FeatureWalkMode.Post;
@@ -21016,7 +21064,8 @@ class ComputeCalcExpressionFeature {
21016
21064
  }
21017
21065
  }
21018
21066
  run(ast) {
21019
- if (!("chi" in ast)) {
21067
+ // @ts-ignore
21068
+ if (ast.chi == null) {
21020
21069
  return null;
21021
21070
  }
21022
21071
  for (const node of ast.chi) {
@@ -21029,8 +21078,12 @@ class ComputeCalcExpressionFeature {
21029
21078
  continue;
21030
21079
  }
21031
21080
  if (value.typ == exports.EnumToken.BinaryExpressionTokenType) {
21032
- // @ts-ignore
21033
- replaceNodeOrValue(parent, value, evaluate([value]));
21081
+ const result = evaluate([value]);
21082
+ try {
21083
+ // @ts-ignore
21084
+ replaceNodeOrValue(parent, value, result);
21085
+ }
21086
+ catch (e) { }
21034
21087
  continue;
21035
21088
  }
21036
21089
  if (value != null && tokensfuncSet.has(value.typ)) {
@@ -21048,7 +21101,7 @@ class ComputeCalcExpressionFeature {
21048
21101
  ? value.val
21049
21102
  : value.chi;
21050
21103
  const values = evaluate(cp);
21051
- // fix a + -b to a - b
21104
+ // fix a + -b into a - b
21052
21105
  for (const { value, parent: p } of walkValues(values)) {
21053
21106
  if (value.typ === exports.EnumToken.BinaryExpressionTokenType) {
21054
21107
  if (value.op === exports.EnumToken.Add &&
@@ -22314,7 +22367,7 @@ class TransformCssFeature {
22314
22367
  exports.EnumToken.KeyframesRuleNodeType,
22315
22368
  ]);
22316
22369
  get ordering() {
22317
- return 3;
22370
+ return 4;
22318
22371
  }
22319
22372
  get processMode() {
22320
22373
  return exports.FeatureWalkMode.Post;
@@ -22717,7 +22770,7 @@ function processNode(declarationNode, cache) {
22717
22770
  class ExpandIfFeature {
22718
22771
  accept = new Set([exports.EnumToken.DeclarationNodeType]);
22719
22772
  get ordering() {
22720
- return 4;
22773
+ return 1;
22721
22774
  }
22722
22775
  get processMode() {
22723
22776
  return exports.FeatureWalkMode.Pre;
@@ -23519,7 +23572,8 @@ function doMinify(ast, options = {}, recursive = false, errors, nestingContent,
23519
23572
  previous = node;
23520
23573
  nodeIndex = i;
23521
23574
  }
23522
- if (recursive && node != null && "chi" in node) {
23575
+ // @ts-ignore
23576
+ if (recursive && node != null && node.chi != null) {
23523
23577
  if (node.typ == exports.EnumToken.KeyframesAtRuleNodeType ||
23524
23578
  !node.chi.some((n) => n.typ == exports.EnumToken.DeclarationNodeType)) {
23525
23579
  if (!(node.typ == exports.EnumToken.AtRuleNodeType && node.nam != "font-face")) {
@@ -25352,6 +25406,7 @@ function doRender(data, options = {}, mapping) {
25352
25406
  removeEmpty: false,
25353
25407
  removeComments: false,
25354
25408
  }),
25409
+ minifyValues: true,
25355
25410
  sourcemap: false,
25356
25411
  convertColor: true,
25357
25412
  expandNestingRules: false,
@@ -25591,7 +25646,7 @@ function renderAstNode(data, options, sourcemaps, sourceLocation, linesMap, erro
25591
25646
  const indentSub = indents[level + 1];
25592
25647
  switch (data.typ) {
25593
25648
  case exports.EnumToken.DeclarationNodeType:
25594
- return `${data.nam}:${options.indent}${(options.minify
25649
+ return `${data.nam}:${options.indent}${(options.minifyValues
25595
25650
  ? filterValues(data.val)
25596
25651
  : data.val).reduce(reducer, "")}`;
25597
25652
  case exports.EnumToken.CommentNodeType:
@@ -25646,7 +25701,7 @@ function renderAstNode(data, options, sourcemaps, sourceLocation, linesMap, erro
25646
25701
  : node.val;
25647
25702
  }
25648
25703
  else if (node.typ == exports.EnumToken.DeclarationNodeType) {
25649
- str = `${node.nam}:${options.indent}${(options.minify
25704
+ str = `${node.nam}:${options.indent}${(options.minifyValues
25650
25705
  ? filterValues(node.val)
25651
25706
  : node.val)
25652
25707
  .reduce(reducer, "")
@@ -25714,9 +25769,10 @@ function renderAstNode(data, options, sourcemaps, sourceLocation, linesMap, erro
25714
25769
  function renderValue(token, options = {}, cache = Object.create(null), reducer, errors) {
25715
25770
  if (token.typ === exports.EnumToken.WhenElseFunctionTokenType &&
25716
25771
  equalsIgnoreCase(token.val, "supports")) {
25717
- options = { ...options, minify: false, convertColor: false };
25772
+ options = { ...options, minifyValues: false, minify: false, convertColor: false };
25718
25773
  reducer = null;
25719
25774
  }
25775
+ options.minifyValues ??= options.minify;
25720
25776
  if (reducer == null) {
25721
25777
  reducer = function (acc, curr) {
25722
25778
  if (curr.typ == exports.EnumToken.CommentTokenType && options.removeComments) {
@@ -25873,7 +25929,7 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
25873
25929
  ")");
25874
25930
  }
25875
25931
  case exports.EnumToken.UrlFunctionTokenType:
25876
- if (options.minify && token.typ === exports.EnumToken.UrlFunctionTokenType) {
25932
+ if (options.minifyValues && token.typ === exports.EnumToken.UrlFunctionTokenType) {
25877
25933
  if (token.chi[0]?.typ === exports.EnumToken.BadUrlTokenType) {
25878
25934
  return "url()";
25879
25935
  }
@@ -25894,7 +25950,7 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
25894
25950
  case exports.EnumToken.FunctionTokenType:
25895
25951
  case exports.EnumToken.MathFunctionTokenType:
25896
25952
  case exports.EnumToken.ImageFunctionTokenType:
25897
- if (options.minify && token.typ === exports.EnumToken.ImageFunctionTokenType) {
25953
+ if (options.minifyValues && token.typ === exports.EnumToken.ImageFunctionTokenType) {
25898
25954
  const slice = token.chi.slice();
25899
25955
  switch (token.val) {
25900
25956
  case "linear-gradient":
@@ -26380,37 +26436,7 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
26380
26436
  renderValue(curr, token.typ == exports.EnumToken.FunctionTokenType ? { minify: false } : options, cache, reducer), "") +
26381
26437
  ")");
26382
26438
  }
26383
- return (
26384
- /* options.minify && 'Pseudo-class-func' == token.typ && token.val.slice(0, 2) == '::' ? token.val.slice(1) :*/ (token.val ?? "") +
26385
- "(" +
26386
- token.chi.reduce(reducer, "") +
26387
- ")");
26388
- // case EnumToken.MatchExpressionTokenType:
26389
- // return (
26390
- // renderValue((token as MatchExpressionToken).l as Token, options, cache, reducer, errors) +
26391
- // renderValue((token as MatchExpressionToken).op, options, cache, reducer, errors) +
26392
- // renderValue((token as MatchExpressionToken).r, options, cache, reducer, errors) +
26393
- // ((token as MatchExpressionToken).attr ? " " + (token as MatchExpressionToken).attr : "")
26394
- // );
26395
- // case EnumToken.NameSpaceAttributeTokenType:
26396
- // return (
26397
- // ((token as NameSpaceAttributeToken).l == null
26398
- // ? ""
26399
- // : renderValue((token as NameSpaceAttributeToken).l as Token, options, cache, reducer, errors)) +
26400
- // "|" +
26401
- // renderValue((token as NameSpaceAttributeToken).r, options, cache, reducer, errors)
26402
- // );
26403
- // case EnumToken.ComposesSelectorNodeType:
26404
- // return (
26405
- // (token as ComposesSelectorToken).l.reduce(
26406
- // (acc: string, curr: Token) => acc + renderValue(curr, options, cache),
26407
- // "",
26408
- // ) +
26409
- // ((token as ComposesSelectorToken).r == null
26410
- // ? ""
26411
- // : " from " +
26412
- // renderValue((token as ComposesSelectorToken).r as Token, options, cache, reducer, errors))
26413
- // );
26439
+ return (token.val ?? "") + "(" + token.chi.reduce(reducer, "") + ")";
26414
26440
  case exports.EnumToken.BlockStartTokenType:
26415
26441
  return "{";
26416
26442
  case exports.EnumToken.BlockEndTokenType:
@@ -26559,7 +26585,11 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
26559
26585
  const perc = token.val.typ == exports.EnumToken.FractionTokenType
26560
26586
  ? renderValue(token.val, options, cache)
26561
26587
  : minifyNumber(token.val);
26562
- return options.minify && perc == "0" ? "0" : perc.includes("/") ? perc.replace("/", uni + "/") : perc + uni;
26588
+ return options.minifyValues && perc == "0"
26589
+ ? "0"
26590
+ : perc.includes("/")
26591
+ ? perc.replace("/", uni + "/")
26592
+ : perc + uni;
26563
26593
  case exports.EnumToken.NumberTokenType:
26564
26594
  return token.val.typ == exports.EnumToken.FractionTokenType
26565
26595
  ? renderValue(token.val, options, cache)
@@ -26624,7 +26654,7 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
26624
26654
  case exports.EnumToken.DeclarationNodeType:
26625
26655
  return (token.nam +
26626
26656
  ":" +
26627
- (options.minify ? filterValues(token.val) : token.val).reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
26657
+ (options.minifyValues ? filterValues(token.val) : token.val).reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
26628
26658
  case exports.EnumToken.MediaQueryUnaryFeatureTokenType:
26629
26659
  return (renderValue(token.l, options, cache, reducer) +
26630
26660
  " " +
@@ -26698,6 +26728,7 @@ function filterValues(values) {
26698
26728
  }
26699
26729
 
26700
26730
  const SymbolsMapTokens = Object.create(null);
26731
+ const SymbolsMapTokensLower = Object.create(null);
26701
26732
  // Regex for escape sequence decoding - compile once, reuse many times
26702
26733
  const ESCAPE_SEQUENCE_REGEX = /\\((\n|\r|\f|\v|\u2028|\u2029|([0-9a-fA-F]{1,6})) ?)/gms;
26703
26734
  function decodeEscapeSequences(value) {
@@ -26726,7 +26757,9 @@ function decodeEscapeSequences(value) {
26726
26757
  }
26727
26758
  function assignTokenMap(entries, tokenType, suffix = "", lowercase = false) {
26728
26759
  for (const entry of entries) {
26729
- SymbolsMapTokens[(lowercase ? entry.toLowerCase() : entry) + suffix] = tokenType;
26760
+ const key = (lowercase ? entry.toLowerCase() : entry) + suffix;
26761
+ SymbolsMapTokens[key] = tokenType;
26762
+ SymbolsMapTokensLower[key.toLowerCase()] = tokenType;
26730
26763
  }
26731
26764
  }
26732
26765
  SymbolsMapTokens[""] = exports.EnumToken.DelimTokenType;
@@ -26826,20 +26859,24 @@ var TokenMap;
26826
26859
  })(TokenMap || (TokenMap = {}));
26827
26860
  function getSymbolHint(parseInfo, start, end) {
26828
26861
  const len = end - start;
26829
- const keysLength = SymbolsMapTokensKeys.length;
26830
- // Early exit for impossible lengths
26831
- if (len < 0)
26862
+ if (len <= 0)
26832
26863
  return null;
26864
+ const value = parseInfo.stream.slice(start, end);
26865
+ // Direct lookup handles the hottest punctuation and keyword cases without
26866
+ // scanning the entire symbol table on every token.
26867
+ const match = SymbolsMapTokens[value] ?? SymbolsMapTokensLower[value.toLowerCase()];
26868
+ if (match != null) {
26869
+ return match;
26870
+ }
26871
+ const keysLength = SymbolsMapTokensKeys.length;
26833
26872
  for (let i = 0; i < keysLength; i++) {
26834
26873
  const key = SymbolsMapTokensKeys[i];
26835
26874
  if (key.length !== len)
26836
26875
  continue;
26837
- // Match character by character
26838
26876
  let match = true;
26839
26877
  for (let j = 0; j < len; j++) {
26840
26878
  let ca = key.charCodeAt(j);
26841
- let cb = parseInfo.stream.charCodeAt(start + j);
26842
- // Normalize A-Z to a-z
26879
+ let cb = value.charCodeAt(j);
26843
26880
  if (ca >= 65 && ca <= 90)
26844
26881
  ca += 32;
26845
26882
  if (cb >= 65 && cb <= 90)
@@ -26857,32 +26894,29 @@ function getSymbolHint(parseInfo, start, end) {
26857
26894
  }
26858
26895
  function searchArray(array, parseInfo, start, end) {
26859
26896
  const len = end - start;
26860
- // Early exit for impossible lengths
26861
- if (len < 0)
26897
+ if (len <= 0)
26862
26898
  return null;
26863
- // Use a simple linear search optimized with length pre-filtering
26864
- let i = array.length;
26865
- while (i--) {
26866
- if (array[i].length !== len)
26899
+ let match;
26900
+ let item;
26901
+ for (let i = 0; i < array.length; i++) {
26902
+ item = array[i];
26903
+ if (item.length !== len)
26867
26904
  continue;
26868
- // Match character by character
26869
- let match = true;
26870
- const arrayItem = array[i];
26905
+ match = true;
26871
26906
  for (let j = 0; j < len; j++) {
26872
- let ca = arrayItem.charCodeAt(j);
26873
- let cb = parseInfo.stream.charCodeAt(start + j);
26874
- // Normalize A-Z to a-z
26907
+ let ca = parseInfo.stream.charCodeAt(start + j);
26908
+ let cb = item.charCodeAt(j);
26875
26909
  if (ca >= 65 && ca <= 90)
26876
26910
  ca += 32;
26877
26911
  if (cb >= 65 && cb <= 90)
26878
26912
  cb += 32;
26879
- if (ca != cb) {
26913
+ if (ca !== cb) {
26880
26914
  match = false;
26881
26915
  break;
26882
26916
  }
26883
26917
  }
26884
26918
  if (match) {
26885
- return arrayItem;
26919
+ return item;
26886
26920
  }
26887
26921
  }
26888
26922
  return null;
@@ -27820,23 +27854,6 @@ class Tokenizer {
27820
27854
  }
27821
27855
  return true;
27822
27856
  }
27823
- /**
27824
- *
27825
- * @param parseInfo
27826
- * @returns
27827
- */
27828
- // isPseudo(parseInfo: ParseInfo): boolean {
27829
- // let position: number = parseInfo.currentPosition - parseInfo.offset;
27830
- // let endPosition: number = parseInfo.currentPosition - parseInfo.offset;
27831
- // return (parseInfo.stream.charAt(position) == ":" &&
27832
- // parseInfo.stream.charAt(endPosition - 1) == "(" &&
27833
- // (parseInfo.stream.charAt(position + 1) == ":"
27834
- // ? this.isIdentToken(parseInfo, 2, -1)
27835
- // : this.isIdentToken(parseInfo, 1, -1))) ||
27836
- // parseInfo.stream.charAt(position + 1) == ":"
27837
- // ? this.isIdentToken(parseInfo, 2)
27838
- // : this.isIdentToken(parseInfo, 1);
27839
- // }
27840
27857
  /**
27841
27858
  *
27842
27859
  * @param parseInfo
@@ -27967,28 +27984,28 @@ class Tokenizer {
27967
27984
  // EOF
27968
27985
  switch (charCode) {
27969
27986
  case 61 /* TokenMap.EQUALS */:
27970
- if (parseInfo.position < parseInfo.currentPosition) {
27971
- return this.makeToken(parseInfo);
27972
- }
27987
+ // if (parseInfo.position < parseInfo.currentPosition) {
27988
+ // return this.makeToken(parseInfo);
27989
+ // }
27973
27990
  this.advance(parseInfo);
27974
27991
  return this.makeToken(parseInfo, exports.EnumToken.DelimTokenType);
27975
27992
  // '+' or '-'
27976
27993
  case 43 /* TokenMap.PLUS */:
27977
- if (parseInfo.position < parseInfo.currentPosition) {
27978
- return this.makeToken(parseInfo);
27979
- }
27994
+ // if (parseInfo.position < parseInfo.currentPosition) {
27995
+ // return this.makeToken(parseInfo);
27996
+ // }
27980
27997
  this.advance(parseInfo);
27981
27998
  charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
27982
- if (isDigit(charCode)) {
27983
- tokensCount = this.consumeNumericToken(parseInfo);
27984
- if (tokensCount > 0) {
27985
- this.advance(parseInfo, tokensCount);
27986
- return this.makeToken(parseInfo, this.hint ?? exports.EnumToken.NumberTokenType, {
27987
- slice: this.slice,
27988
- sign: "+",
27989
- });
27990
- }
27991
- }
27999
+ // if (isDigit(charCode)) {
28000
+ // tokensCount = this.consumeNumericToken(parseInfo);
28001
+ // if (tokensCount > 0) {
28002
+ // this.advance(parseInfo, tokensCount);
28003
+ // return this.makeToken(parseInfo, this.hint ?? EnumToken.NumberTokenType, {
28004
+ // slice: this.slice,
28005
+ // sign: "+",
28006
+ // });
28007
+ // }
28008
+ // }
27992
28009
  return this.makeToken(parseInfo, exports.EnumToken.Plus);
27993
28010
  case 45 /* TokenMap.MINUS */:
27994
28011
  if (parseInfo.position == parseInfo.currentPosition) {
@@ -27998,15 +28015,17 @@ class Tokenizer {
27998
28015
  this.advance(parseInfo);
27999
28016
  return this.makeToken(parseInfo, exports.EnumToken.Sub);
28000
28017
  }
28001
- if (charCode == 45 /* TokenMap.MINUS */ &&
28002
- (nextCharCode == 45 /* TokenMap.MINUS */ || isIdentStart(nextCharCode))) {
28003
- this.advance(parseInfo);
28004
- tokensCount = this.consumeIdentToken(parseInfo);
28005
- if (tokensCount > 0) {
28006
- this.advance(parseInfo, tokensCount);
28007
- return this.makeToken(parseInfo, exports.EnumToken.IdenTokenType);
28008
- }
28009
- }
28018
+ // if (
28019
+ // charCode == TokenMap.MINUS &&
28020
+ // (nextCharCode == TokenMap.MINUS || isIdentStart(nextCharCode))
28021
+ // ) {
28022
+ // this.advance(parseInfo);
28023
+ // tokensCount = this.consumeIdentToken(parseInfo);
28024
+ // if (tokensCount > 0) {
28025
+ // this.advance(parseInfo, tokensCount);
28026
+ // return this.makeToken(parseInfo, EnumToken.IdenTokenType);
28027
+ // }
28028
+ // }
28010
28029
  }
28011
28030
  this.advance(parseInfo);
28012
28031
  break;
@@ -28059,28 +28078,28 @@ class Tokenizer {
28059
28078
  return this.makeToken(parseInfo, exports.EnumToken.EndParensTokenType);
28060
28079
  // '['
28061
28080
  case 91 /* TokenMap.LEFT_BRACKETS */:
28062
- if (parseInfo.position < parseInfo.currentPosition) {
28063
- return this.makeToken(parseInfo);
28064
- }
28081
+ // if (parseInfo.position < parseInfo.currentPosition) {
28082
+ // return this.makeToken(parseInfo);
28083
+ // }
28065
28084
  this.advance(parseInfo);
28066
28085
  return this.makeToken(parseInfo, exports.EnumToken.AttrStartTokenType);
28067
28086
  // ']'
28068
28087
  case 93 /* TokenMap.RIGHT_BRACKETS */:
28069
- if (parseInfo.position < parseInfo.currentPosition) {
28070
- return this.makeToken(parseInfo);
28071
- }
28088
+ // if (parseInfo.position < parseInfo.currentPosition) {
28089
+ // return this.makeToken(parseInfo);
28090
+ // }
28072
28091
  this.advance(parseInfo);
28073
28092
  return this.makeToken(parseInfo, exports.EnumToken.AttrEndTokenType);
28074
28093
  case 59 /* TokenMap.SEMICOLON */:
28075
- if (parseInfo.position < parseInfo.currentPosition) {
28076
- return this.makeToken(parseInfo);
28077
- }
28094
+ // if (parseInfo.position < parseInfo.currentPosition) {
28095
+ // return this.makeToken(parseInfo);
28096
+ // }
28078
28097
  this.advance(parseInfo);
28079
28098
  return this.makeToken(parseInfo, exports.EnumToken.SemiColonTokenType);
28080
28099
  case 58 /* TokenMap.COLON */:
28081
- if (parseInfo.position < parseInfo.currentPosition) {
28082
- return this.makeToken(parseInfo);
28083
- }
28100
+ // if (parseInfo.position < parseInfo.currentPosition) {
28101
+ // return this.makeToken(parseInfo);
28102
+ // }
28084
28103
  this.advance(parseInfo);
28085
28104
  if (this.peekCharCode(parseInfo) == 58 /* TokenMap.COLON */) {
28086
28105
  this.advance(parseInfo);
@@ -28112,15 +28131,15 @@ class Tokenizer {
28112
28131
  }
28113
28132
  return this.makeToken(parseInfo, exports.EnumToken.WhitespaceTokenType);
28114
28133
  case 44 /* TokenMap.COMMA */:
28115
- if (parseInfo.position < parseInfo.currentPosition) {
28116
- return this.makeToken(parseInfo);
28117
- }
28134
+ // if (parseInfo.position < parseInfo.currentPosition) {
28135
+ // return this.makeToken(parseInfo);
28136
+ // }
28118
28137
  this.advance(parseInfo);
28119
28138
  return this.makeToken(parseInfo, exports.EnumToken.CommaTokenType);
28120
28139
  case 36 /* TokenMap.DOLLAR */:
28121
- if (parseInfo.position < parseInfo.currentPosition) {
28122
- return this.makeToken(parseInfo);
28123
- }
28140
+ // if (parseInfo.position < parseInfo.currentPosition) {
28141
+ // return this.makeToken(parseInfo);
28142
+ // }
28124
28143
  if (this.match(parseInfo, "$=")) {
28125
28144
  this.advance(parseInfo, 2);
28126
28145
  return this.makeToken(parseInfo, exports.EnumToken.EndMatchTokenType);
@@ -28128,9 +28147,9 @@ class Tokenizer {
28128
28147
  this.advance(parseInfo);
28129
28148
  break;
28130
28149
  case 126 /* TokenMap.TILDA */:
28131
- if (parseInfo.position < parseInfo.currentPosition) {
28132
- return this.makeToken(parseInfo);
28133
- }
28150
+ // if (parseInfo.position < parseInfo.currentPosition) {
28151
+ // return this.makeToken(parseInfo);
28152
+ // }
28134
28153
  if (this.match(parseInfo, "~=")) {
28135
28154
  this.advance(parseInfo, 2);
28136
28155
  return this.makeToken(parseInfo, exports.EnumToken.IncludeMatchTokenType);
@@ -28139,9 +28158,9 @@ class Tokenizer {
28139
28158
  return this.makeToken(parseInfo, exports.EnumToken.Tilda);
28140
28159
  // case '^':
28141
28160
  case 94 /* TokenMap.CARET */:
28142
- if (parseInfo.position < parseInfo.currentPosition) {
28143
- return this.makeToken(parseInfo);
28144
- }
28161
+ // if (parseInfo.position < parseInfo.currentPosition) {
28162
+ // return this.makeToken(parseInfo);
28163
+ // }
28145
28164
  if (this.match(parseInfo, "^=")) {
28146
28165
  this.advance(parseInfo, 2);
28147
28166
  return this.makeToken(parseInfo, exports.EnumToken.StartMatchTokenType);
@@ -28149,9 +28168,9 @@ class Tokenizer {
28149
28168
  this.advance(parseInfo);
28150
28169
  break;
28151
28170
  case 42 /* TokenMap.STAR */:
28152
- if (parseInfo.position < parseInfo.currentPosition) {
28153
- return this.makeToken(parseInfo);
28154
- }
28171
+ // if (parseInfo.position < parseInfo.currentPosition) {
28172
+ // return this.makeToken(parseInfo);
28173
+ // }
28155
28174
  if (this.match(parseInfo, "*=")) {
28156
28175
  this.advance(parseInfo, 2);
28157
28176
  return this.makeToken(parseInfo, exports.EnumToken.ContainMatchTokenType);
@@ -28165,9 +28184,9 @@ class Tokenizer {
28165
28184
  this.advance(parseInfo);
28166
28185
  return this.makeToken(parseInfo, exports.EnumToken.NestingSelectorTokenType);
28167
28186
  case 124 /* TokenMap.PIPE */:
28168
- if (parseInfo.position < parseInfo.currentPosition) {
28169
- return this.makeToken(parseInfo);
28170
- }
28187
+ // if (parseInfo.position < parseInfo.currentPosition) {
28188
+ // return this.makeToken(parseInfo);
28189
+ // }
28171
28190
  // '||'
28172
28191
  if (this.match(parseInfo, "||")) {
28173
28192
  this.advance(parseInfo, 2);
@@ -28190,9 +28209,9 @@ class Tokenizer {
28190
28209
  this.advance(parseInfo);
28191
28210
  break;
28192
28211
  case 47 /* TokenMap.SLASH */:
28193
- if (parseInfo.position < parseInfo.currentPosition) {
28194
- return this.makeToken(parseInfo);
28195
- }
28212
+ // if (parseInfo.position < parseInfo.currentPosition) {
28213
+ // return this.makeToken(parseInfo);
28214
+ // }
28196
28215
  if (!this.match(parseInfo, "/*")) {
28197
28216
  this.advance(parseInfo);
28198
28217
  return this.makeToken(parseInfo, getSymbolHint(parseInfo, parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset));
@@ -28211,9 +28230,9 @@ class Tokenizer {
28211
28230
  }
28212
28231
  break;
28213
28232
  case 62 /* TokenMap.GREATERTHAN */:
28214
- if (parseInfo.position < parseInfo.currentPosition) {
28215
- return this.makeToken(parseInfo);
28216
- }
28233
+ // if (parseInfo.position < parseInfo.currentPosition) {
28234
+ // return this.makeToken(parseInfo);
28235
+ // }
28217
28236
  if (this.match(parseInfo, ">=")) {
28218
28237
  this.advance(parseInfo, 2);
28219
28238
  return this.makeToken(parseInfo, exports.EnumToken.GteTokenType);
@@ -28252,20 +28271,11 @@ class Tokenizer {
28252
28271
  this.advance(parseInfo);
28253
28272
  break;
28254
28273
  case 92 /* TokenMap.REVERSE_SOLIDUS */:
28255
- // if (!yieldEOFToken && parseInfo.stream.length == parseInfo.currentPosition - parseInfo.offset + 1) {
28256
- // break;
28257
- // }
28258
28274
  this.advance(parseInfo);
28259
28275
  // EOF
28260
- if (!this.peek(parseInfo)) {
28261
- // if (!yieldEOFToken) {
28262
- // break;
28263
- // }
28264
- // end of stream ignore \\
28265
- if (parseInfo.position < parseInfo.currentPosition) {
28266
- return this.makeToken(parseInfo);
28267
- }
28268
- break;
28276
+ // end of stream ignore \\
28277
+ if (!this.peek(parseInfo) && parseInfo.position < parseInfo.currentPosition) {
28278
+ return this.makeToken(parseInfo);
28269
28279
  }
28270
28280
  this.advance(parseInfo);
28271
28281
  break;
@@ -28278,9 +28288,9 @@ class Tokenizer {
28278
28288
  case 46 /* TokenMap.DOT */:
28279
28289
  const codepoint = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1);
28280
28290
  if (isIdentStart(codepoint) || codepoint == 45 /* TokenMap.MINUS */) {
28281
- if (parseInfo.position < parseInfo.currentPosition) {
28282
- return this.makeToken(parseInfo);
28283
- }
28291
+ // if (parseInfo.position < parseInfo.currentPosition) {
28292
+ // return this.makeToken(parseInfo);
28293
+ // }
28284
28294
  this.advance(parseInfo);
28285
28295
  let tokensCount = this.consumeIdentToken(parseInfo);
28286
28296
  if (tokensCount > 0) {
@@ -28288,27 +28298,22 @@ class Tokenizer {
28288
28298
  return this.makeToken(parseInfo, exports.EnumToken.ClassSelectorTokenType);
28289
28299
  }
28290
28300
  }
28291
- if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
28292
- this.makeToken(parseInfo);
28293
- this.advance(parseInfo, 2);
28294
- return this;
28295
- }
28301
+ // if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
28302
+ // this.makeToken(parseInfo);
28303
+ // this.advance(parseInfo, 2);
28304
+ // return this;
28305
+ // }
28296
28306
  this.advance(parseInfo);
28297
28307
  break;
28298
28308
  default:
28299
28309
  this.advance(parseInfo);
28300
28310
  break;
28301
28311
  }
28302
- // if (!yieldEOFToken && endPosition <= parseInfo.currentPosition - parseInfo.offset + 1) {
28303
- // break;
28304
- // }
28305
28312
  }
28306
- // if (yieldEOFToken) {
28307
28313
  if (parseInfo.position < parseInfo.currentPosition) {
28308
28314
  return this.makeToken(parseInfo);
28309
28315
  }
28310
28316
  return this.makeToken(parseInfo, exports.EnumToken.EOFTokenType);
28311
- // }
28312
28317
  }
28313
28318
  /**
28314
28319
  * tokenize readable stream
@@ -29473,8 +29478,6 @@ function parseMediaqueryList(stream, options) {
29473
29478
  }
29474
29479
  }
29475
29480
  }
29476
- // let isValidMFValue = isMFValue(name, left, true);
29477
- // isValidMFValue = isMFValue(name, right, true);
29478
29481
  for (const val of [left, right]) {
29479
29482
  if (mfInfo?.type === MediaFeatureType.RatioType) {
29480
29483
  const filteredValues = val.filter((n) => n.typ !== exports.EnumToken.WhitespaceTokenType &&
@@ -30270,7 +30273,7 @@ function parseAtRuleContainerQueryList(stream, context, options = {}) {
30270
30273
  };
30271
30274
  }
30272
30275
  {
30273
- for (const stream of parts.slice()) {
30276
+ for (const stream of parts) {
30274
30277
  let success = true;
30275
30278
  let i;
30276
30279
  let currentScope = new Set();
@@ -30389,6 +30392,22 @@ function parseAtRuleContainerQueryList(stream, context, options = {}) {
30389
30392
  [LOCSTA]: names[0][LOCSTA],
30390
30393
  [LOCEND]: values.at(-1)[LOCEND],
30391
30394
  });
30395
+ const token = tokens[index3 + 1];
30396
+ if (token.op.typ === exports.EnumToken.ColonTokenType) {
30397
+ let name = token.l.find((t) => t.typ === exports.EnumToken.IdenTokenType);
30398
+ if (name != null) {
30399
+ if (name.val.startsWith("min-")) {
30400
+ name.val = name.val.substring(4);
30401
+ // @ts-ignore
30402
+ token.op.typ = exports.EnumToken.GteTokenType;
30403
+ }
30404
+ else if (name.val.startsWith("max-")) {
30405
+ name.val = name.val.substring(4);
30406
+ // @ts-ignore
30407
+ token.op.typ = exports.EnumToken.LteTokenType;
30408
+ }
30409
+ }
30410
+ }
30392
30411
  // check <style()> or <scroll-state()>
30393
30412
  }
30394
30413
  if (tokensfuncDefMap.has(stack.at(-1)?.typ)) {
@@ -30480,6 +30499,58 @@ function parseAtRuleContainerQueryList(stream, context, options = {}) {
30480
30499
  };
30481
30500
  tokens.length = l + 1;
30482
30501
  expectAndOr = true;
30502
+ if (tokens[l].op.typ === exports.EnumToken.AndTokenType) {
30503
+ let left = tokens[l].l.find((t) => t.typ != exports.EnumToken.WhitespaceTokenType && t.typ != exports.EnumToken.IdenTokenType);
30504
+ let right = tokens[l].r.find((t) => t.typ != exports.EnumToken.WhitespaceTokenType && t.typ != exports.EnumToken.IdenTokenType);
30505
+ if (left.typ == exports.EnumToken.ParensTokenType && right.typ == exports.EnumToken.ParensTokenType) {
30506
+ left = left.chi.find((t) => t.typ != exports.EnumToken.WhitespaceTokenType && t.typ != exports.EnumToken.IdenTokenType);
30507
+ right = right.chi.find((t) => t.typ != exports.EnumToken.WhitespaceTokenType && t.typ != exports.EnumToken.IdenTokenType);
30508
+ if (left.typ == exports.EnumToken.MediaQueryConditionTokenType &&
30509
+ (mFLT.has(left.op.typ) ||
30510
+ mFGT.has(left.op.typ)) &&
30511
+ right.typ == exports.EnumToken.MediaQueryConditionTokenType &&
30512
+ (mFLT.has(right.op.typ) ||
30513
+ mFGT.has(right.op.typ))) {
30514
+ const name = left.l.find((t) => t.typ == exports.EnumToken.IdenTokenType);
30515
+ const name2 = right.l.find((t) => t.typ == exports.EnumToken.IdenTokenType);
30516
+ if (equalsIgnoreCase(name.val, name2.val)) {
30517
+ switch (left.op.typ) {
30518
+ case exports.EnumToken.LtTokenType:
30519
+ left.op.typ = exports.EnumToken.GtTokenType;
30520
+ break;
30521
+ case exports.EnumToken.LteTokenType:
30522
+ left.op.typ = exports.EnumToken.GteTokenType;
30523
+ break;
30524
+ case exports.EnumToken.GtTokenType:
30525
+ left.op.typ = exports.EnumToken.LtTokenType;
30526
+ break;
30527
+ case exports.EnumToken.GteTokenType:
30528
+ left.op.typ = exports.EnumToken.LteTokenType;
30529
+ break;
30530
+ }
30531
+ tokens[l] = {
30532
+ typ: exports.EnumToken.ParensTokenType,
30533
+ chi: [
30534
+ {
30535
+ typ: exports.EnumToken.MediaRangeQueryTokenType,
30536
+ l: left.r,
30537
+ val: [name],
30538
+ op1: left.op,
30539
+ op2: right.op,
30540
+ r: right.r,
30541
+ [LOCSRCID]: name[LOCSRCID],
30542
+ [LOCSTA]: left[LOCSTA],
30543
+ [LOCEND]: right[LOCEND],
30544
+ },
30545
+ ],
30546
+ [LOCSRCID]: name[LOCSRCID],
30547
+ [LOCSTA]: left[LOCSTA],
30548
+ [LOCEND]: right[LOCEND],
30549
+ };
30550
+ }
30551
+ }
30552
+ }
30553
+ }
30483
30554
  }
30484
30555
  break;
30485
30556
  }
@@ -31082,6 +31153,7 @@ function doParseSync(tokenizer, options = {}) {
31082
31153
  if (options.expandNestingRules) {
31083
31154
  options.nestingRules = false;
31084
31155
  }
31156
+ options.minifyAST ??= options.minify;
31085
31157
  const startTime = performance.now();
31086
31158
  const errors = [];
31087
31159
  const stack = [];
@@ -31112,7 +31184,6 @@ function doParseSync(tokenizer, options = {}) {
31112
31184
  // let currentItemIndex: number;
31113
31185
  ast[LOCSRCID] = options.source.id;
31114
31186
  ast[LOCSTA] = 0;
31115
- // let tokenizer: Tokenizer;
31116
31187
  while (!tokenizer.done()) {
31117
31188
  tokenizer.next();
31118
31189
  // item = (iter as Array<TokenizeResult>)[currentItemIndex];
@@ -31461,7 +31532,7 @@ function doParseSync(tokenizer, options = {}) {
31461
31532
  }
31462
31533
  }
31463
31534
  }
31464
- if (options.minify) {
31535
+ if (options.minifyAST) {
31465
31536
  if (ast.chi.length > 0) {
31466
31537
  let passes = options.pass ?? 1;
31467
31538
  while (passes--) {
@@ -32001,6 +32072,7 @@ async function doParse(iter, options = {}) {
32001
32072
  lenient: true,
32002
32073
  ...options,
32003
32074
  };
32075
+ options.minifyAST ??= options.minify;
32004
32076
  if (typeof options.validation !== "boolean") {
32005
32077
  options.validation = !!options.validation;
32006
32078
  }
@@ -32455,7 +32527,7 @@ async function doParse(iter, options = {}) {
32455
32527
  }
32456
32528
  }
32457
32529
  }
32458
- if (options.minify) {
32530
+ if (options.minifyAST) {
32459
32531
  if (ast.chi.length > 0) {
32460
32532
  let passes = options.pass ?? 1;
32461
32533
  while (passes--) {