@posthog/rrweb-snapshot 0.0.7 → 0.0.8

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.
@@ -1536,7 +1536,7 @@ function getAugmentedNamespace(n) {
1536
1536
  var picocolors_browser = { exports: {} };
1537
1537
  var x = String;
1538
1538
  var create = function() {
1539
- return { isColorSupported: false, reset: x, bold: x, dim: x, italic: x, underline: x, inverse: x, hidden: x, strikethrough: x, black: x, red: x, green: x, yellow: x, blue: x, magenta: x, cyan: x, white: x, gray: x, bgBlack: x, bgRed: x, bgGreen: x, bgYellow: x, bgBlue: x, bgMagenta: x, bgCyan: x, bgWhite: x };
1539
+ return { isColorSupported: false, reset: x, bold: x, dim: x, italic: x, underline: x, inverse: x, hidden: x, strikethrough: x, black: x, red: x, green: x, yellow: x, blue: x, magenta: x, cyan: x, white: x, gray: x, bgBlack: x, bgRed: x, bgGreen: x, bgYellow: x, bgBlue: x, bgMagenta: x, bgCyan: x, bgWhite: x, blackBright: x, redBright: x, greenBright: x, yellowBright: x, blueBright: x, magentaBright: x, cyanBright: x, whiteBright: x, bgBlackBright: x, bgRedBright: x, bgGreenBright: x, bgYellowBright: x, bgBlueBright: x, bgMagentaBright: x, bgCyanBright: x, bgWhiteBright: x };
1540
1540
  };
1541
1541
  picocolors_browser.exports = create();
1542
1542
  picocolors_browser.exports.createColors = create;
@@ -1549,8 +1549,8 @@ const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Ob
1549
1549
  const require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
1550
1550
  let pico = picocolors_browserExports;
1551
1551
  let terminalHighlight$1 = require$$2;
1552
- let CssSyntaxError$3 = class CssSyntaxError extends Error {
1553
- constructor(message, line, column, source, file, plugin2) {
1552
+ let CssSyntaxError$4 = class CssSyntaxError extends Error {
1553
+ constructor(message, line, column, source, file, plugin3) {
1554
1554
  super(message);
1555
1555
  this.name = "CssSyntaxError";
1556
1556
  this.reason = message;
@@ -1560,8 +1560,8 @@ let CssSyntaxError$3 = class CssSyntaxError extends Error {
1560
1560
  if (source) {
1561
1561
  this.source = source;
1562
1562
  }
1563
- if (plugin2) {
1564
- this.plugin = plugin2;
1563
+ if (plugin3) {
1564
+ this.plugin = plugin3;
1565
1565
  }
1566
1566
  if (typeof line !== "undefined" && typeof column !== "undefined") {
1567
1567
  if (typeof line === "number") {
@@ -1591,29 +1591,40 @@ let CssSyntaxError$3 = class CssSyntaxError extends Error {
1591
1591
  if (!this.source) return "";
1592
1592
  let css = this.source;
1593
1593
  if (color == null) color = pico.isColorSupported;
1594
- if (terminalHighlight$1) {
1595
- if (color) css = terminalHighlight$1(css);
1596
- }
1597
- let lines = css.split(/\r?\n/);
1598
- let start = Math.max(this.line - 3, 0);
1599
- let end = Math.min(this.line + 2, lines.length);
1600
- let maxWidth = String(end).length;
1601
- let mark, aside;
1594
+ let aside = (text) => text;
1595
+ let mark = (text) => text;
1596
+ let highlight = (text) => text;
1602
1597
  if (color) {
1603
1598
  let { bold, gray, red } = pico.createColors(true);
1604
1599
  mark = (text) => bold(red(text));
1605
1600
  aside = (text) => gray(text);
1606
- } else {
1607
- mark = aside = (str) => str;
1601
+ if (terminalHighlight$1) {
1602
+ highlight = (text) => terminalHighlight$1(text);
1603
+ }
1608
1604
  }
1605
+ let lines = css.split(/\r?\n/);
1606
+ let start = Math.max(this.line - 3, 0);
1607
+ let end = Math.min(this.line + 2, lines.length);
1608
+ let maxWidth = String(end).length;
1609
1609
  return lines.slice(start, end).map((line, index2) => {
1610
1610
  let number = start + 1 + index2;
1611
1611
  let gutter = " " + (" " + number).slice(-maxWidth) + " | ";
1612
1612
  if (number === this.line) {
1613
+ if (line.length > 160) {
1614
+ let padding = 20;
1615
+ let subLineStart = Math.max(0, this.column - padding);
1616
+ let subLineEnd = Math.max(
1617
+ this.column + padding,
1618
+ this.endColumn + padding
1619
+ );
1620
+ let subLine = line.slice(subLineStart, subLineEnd);
1621
+ let spacing2 = aside(gutter.replace(/\d/g, " ")) + line.slice(0, Math.min(this.column - 1, padding - 1)).replace(/[^\t]/g, " ");
1622
+ return mark(">") + aside(gutter) + highlight(subLine) + "\n " + spacing2 + mark("^");
1623
+ }
1613
1624
  let spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, this.column - 1).replace(/[^\t]/g, " ");
1614
- return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
1625
+ return mark(">") + aside(gutter) + highlight(line) + "\n " + spacing + mark("^");
1615
1626
  }
1616
- return " " + aside(gutter) + line;
1627
+ return " " + aside(gutter) + highlight(line);
1617
1628
  }).join("\n");
1618
1629
  }
1619
1630
  toString() {
@@ -1624,11 +1635,8 @@ let CssSyntaxError$3 = class CssSyntaxError extends Error {
1624
1635
  return this.name + ": " + this.message + code;
1625
1636
  }
1626
1637
  };
1627
- var cssSyntaxError = CssSyntaxError$3;
1628
- CssSyntaxError$3.default = CssSyntaxError$3;
1629
- var symbols = {};
1630
- symbols.isClean = Symbol("isClean");
1631
- symbols.my = Symbol("my");
1638
+ var cssSyntaxError = CssSyntaxError$4;
1639
+ CssSyntaxError$4.default = CssSyntaxError$4;
1632
1640
  const DEFAULT_RAW = {
1633
1641
  after: "\n",
1634
1642
  beforeClose: "\n",
@@ -1927,16 +1935,19 @@ let Stringifier$2 = class Stringifier {
1927
1935
  var stringifier = Stringifier$2;
1928
1936
  Stringifier$2.default = Stringifier$2;
1929
1937
  let Stringifier$1 = stringifier;
1930
- function stringify$4(node2, builder) {
1938
+ function stringify$5(node2, builder) {
1931
1939
  let str = new Stringifier$1(builder);
1932
1940
  str.stringify(node2);
1933
1941
  }
1934
- var stringify_1 = stringify$4;
1935
- stringify$4.default = stringify$4;
1936
- let { isClean: isClean$2, my: my$2 } = symbols;
1937
- let CssSyntaxError$2 = cssSyntaxError;
1942
+ var stringify_1 = stringify$5;
1943
+ stringify$5.default = stringify$5;
1944
+ var symbols = {};
1945
+ symbols.isClean = Symbol("isClean");
1946
+ symbols.my = Symbol("my");
1947
+ let CssSyntaxError$3 = cssSyntaxError;
1938
1948
  let Stringifier2 = stringifier;
1939
- let stringify$3 = stringify_1;
1949
+ let stringify$4 = stringify_1;
1950
+ let { isClean: isClean$2, my: my$2 } = symbols;
1940
1951
  function cloneNode(obj, parent) {
1941
1952
  let cloned = new obj.constructor();
1942
1953
  for (let i in obj) {
@@ -1959,7 +1970,28 @@ function cloneNode(obj, parent) {
1959
1970
  }
1960
1971
  return cloned;
1961
1972
  }
1962
- let Node$4 = class Node {
1973
+ function sourceOffset(inputCSS, position) {
1974
+ if (position && typeof position.offset !== "undefined") {
1975
+ return position.offset;
1976
+ }
1977
+ let column = 1;
1978
+ let line = 1;
1979
+ let offset = 0;
1980
+ for (let i = 0; i < inputCSS.length; i++) {
1981
+ if (line === position.line && column === position.column) {
1982
+ offset = i;
1983
+ break;
1984
+ }
1985
+ if (inputCSS[i] === "\n") {
1986
+ column = 1;
1987
+ line += 1;
1988
+ } else {
1989
+ column += 1;
1990
+ }
1991
+ }
1992
+ return offset;
1993
+ }
1994
+ let Node$5 = class Node {
1963
1995
  constructor(defaults = {}) {
1964
1996
  this.raws = {};
1965
1997
  this[isClean$2] = false;
@@ -2036,7 +2068,7 @@ let Node$4 = class Node {
2036
2068
  opts
2037
2069
  );
2038
2070
  }
2039
- return new CssSyntaxError$2(message);
2071
+ return new CssSyntaxError$3(message);
2040
2072
  }
2041
2073
  getProxyProcessor() {
2042
2074
  return {
@@ -2060,6 +2092,10 @@ let Node$4 = class Node {
2060
2092
  }
2061
2093
  };
2062
2094
  }
2095
+ /* c8 ignore next 3 */
2096
+ markClean() {
2097
+ this[isClean$2] = true;
2098
+ }
2063
2099
  markDirty() {
2064
2100
  if (this[isClean$2]) {
2065
2101
  this[isClean$2] = false;
@@ -2074,23 +2110,29 @@ let Node$4 = class Node {
2074
2110
  let index2 = this.parent.index(this);
2075
2111
  return this.parent.nodes[index2 + 1];
2076
2112
  }
2077
- positionBy(opts, stringRepresentation) {
2113
+ positionBy(opts) {
2078
2114
  let pos = this.source.start;
2079
2115
  if (opts.index) {
2080
- pos = this.positionInside(opts.index, stringRepresentation);
2116
+ pos = this.positionInside(opts.index);
2081
2117
  } else if (opts.word) {
2082
- stringRepresentation = this.toString();
2118
+ let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
2119
+ let stringRepresentation = inputString.slice(
2120
+ sourceOffset(inputString, this.source.start),
2121
+ sourceOffset(inputString, this.source.end)
2122
+ );
2083
2123
  let index2 = stringRepresentation.indexOf(opts.word);
2084
- if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
2124
+ if (index2 !== -1) pos = this.positionInside(index2);
2085
2125
  }
2086
2126
  return pos;
2087
2127
  }
2088
- positionInside(index2, stringRepresentation) {
2089
- let string = stringRepresentation || this.toString();
2128
+ positionInside(index2) {
2090
2129
  let column = this.source.start.column;
2091
2130
  let line = this.source.start.line;
2092
- for (let i = 0; i < index2; i++) {
2093
- if (string[i] === "\n") {
2131
+ let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
2132
+ let offset = sourceOffset(inputString, this.source.start);
2133
+ let end = offset + index2;
2134
+ for (let i = offset; i < end; i++) {
2135
+ if (inputString[i] === "\n") {
2094
2136
  column = 1;
2095
2137
  line += 1;
2096
2138
  } else {
@@ -2117,11 +2159,17 @@ let Node$4 = class Node {
2117
2159
  line: start.line
2118
2160
  };
2119
2161
  if (opts.word) {
2120
- let stringRepresentation = this.toString();
2162
+ let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
2163
+ let stringRepresentation = inputString.slice(
2164
+ sourceOffset(inputString, this.source.start),
2165
+ sourceOffset(inputString, this.source.end)
2166
+ );
2121
2167
  let index2 = stringRepresentation.indexOf(opts.word);
2122
2168
  if (index2 !== -1) {
2123
- start = this.positionInside(index2, stringRepresentation);
2124
- end = this.positionInside(index2 + opts.word.length, stringRepresentation);
2169
+ start = this.positionInside(index2);
2170
+ end = this.positionInside(
2171
+ index2 + opts.word.length
2172
+ );
2125
2173
  }
2126
2174
  } else {
2127
2175
  if (opts.start) {
@@ -2234,7 +2282,7 @@ let Node$4 = class Node {
2234
2282
  }
2235
2283
  return this.proxyCache;
2236
2284
  }
2237
- toString(stringifier2 = stringify$3) {
2285
+ toString(stringifier2 = stringify$4) {
2238
2286
  if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
2239
2287
  let result2 = "";
2240
2288
  stringifier2(this, (i) => {
@@ -2251,10 +2299,19 @@ let Node$4 = class Node {
2251
2299
  return this;
2252
2300
  }
2253
2301
  };
2254
- var node = Node$4;
2255
- Node$4.default = Node$4;
2302
+ var node = Node$5;
2303
+ Node$5.default = Node$5;
2304
+ let Node$4 = node;
2305
+ let Comment$6 = class Comment extends Node$4 {
2306
+ constructor(defaults) {
2307
+ super(defaults);
2308
+ this.type = "comment";
2309
+ }
2310
+ };
2311
+ var comment$1 = Comment$6;
2312
+ Comment$6.default = Comment$6;
2256
2313
  let Node$3 = node;
2257
- let Declaration$4 = class Declaration extends Node$3 {
2314
+ let Declaration$5 = class Declaration extends Node$3 {
2258
2315
  constructor(defaults) {
2259
2316
  if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
2260
2317
  defaults = { ...defaults, value: String(defaults.value) };
@@ -2266,1120 +2323,1233 @@ let Declaration$4 = class Declaration extends Node$3 {
2266
2323
  return this.prop.startsWith("--") || this.prop[0] === "$";
2267
2324
  }
2268
2325
  };
2269
- var declaration = Declaration$4;
2270
- Declaration$4.default = Declaration$4;
2271
- let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
2272
- let customAlphabet = (alphabet, defaultSize = 21) => {
2273
- return (size = defaultSize) => {
2274
- let id = "";
2275
- let i = size;
2276
- while (i--) {
2277
- id += alphabet[Math.random() * alphabet.length | 0];
2326
+ var declaration = Declaration$5;
2327
+ Declaration$5.default = Declaration$5;
2328
+ let Comment$5 = comment$1;
2329
+ let Declaration$4 = declaration;
2330
+ let Node$2 = node;
2331
+ let { isClean: isClean$1, my: my$1 } = symbols;
2332
+ let AtRule$5, parse$5, Root$7, Rule$5;
2333
+ function cleanSource(nodes) {
2334
+ return nodes.map((i) => {
2335
+ if (i.nodes) i.nodes = cleanSource(i.nodes);
2336
+ delete i.source;
2337
+ return i;
2338
+ });
2339
+ }
2340
+ function markTreeDirty(node2) {
2341
+ node2[isClean$1] = false;
2342
+ if (node2.proxyOf.nodes) {
2343
+ for (let i of node2.proxyOf.nodes) {
2344
+ markTreeDirty(i);
2278
2345
  }
2279
- return id;
2280
- };
2281
- };
2282
- let nanoid$1 = (size = 21) => {
2283
- let id = "";
2284
- let i = size;
2285
- while (i--) {
2286
- id += urlAlphabet[Math.random() * 64 | 0];
2287
- }
2288
- return id;
2289
- };
2290
- var nonSecure = { nanoid: nanoid$1, customAlphabet };
2291
- let { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$2 } = require$$2;
2292
- let { existsSync, readFileSync } = require$$2;
2293
- let { dirname: dirname$1, join } = require$$2;
2294
- function fromBase64(str) {
2295
- if (Buffer) {
2296
- return Buffer.from(str, "base64").toString();
2297
- } else {
2298
- return window.atob(str);
2299
2346
  }
2300
2347
  }
2301
- let PreviousMap$2 = class PreviousMap {
2302
- constructor(css, opts) {
2303
- if (opts.map === false) return;
2304
- this.loadAnnotation(css);
2305
- this.inline = this.startWith(this.annotation, "data:");
2306
- let prev = opts.map ? opts.map.prev : void 0;
2307
- let text = this.loadMap(opts.from, prev);
2308
- if (!this.mapFile && opts.from) {
2309
- this.mapFile = opts.from;
2348
+ let Container$8 = class Container extends Node$2 {
2349
+ append(...children) {
2350
+ for (let child of children) {
2351
+ let nodes = this.normalize(child, this.last);
2352
+ for (let node2 of nodes) this.proxyOf.nodes.push(node2);
2310
2353
  }
2311
- if (this.mapFile) this.root = dirname$1(this.mapFile);
2312
- if (text) this.text = text;
2354
+ this.markDirty();
2355
+ return this;
2313
2356
  }
2314
- consumer() {
2315
- if (!this.consumerCache) {
2316
- this.consumerCache = new SourceMapConsumer$2(this.text);
2357
+ cleanRaws(keepBetween) {
2358
+ super.cleanRaws(keepBetween);
2359
+ if (this.nodes) {
2360
+ for (let node2 of this.nodes) node2.cleanRaws(keepBetween);
2317
2361
  }
2318
- return this.consumerCache;
2319
2362
  }
2320
- decodeInline(text) {
2321
- let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
2322
- let baseUri = /^data:application\/json;base64,/;
2323
- let charsetUri = /^data:application\/json;charset=utf-?8,/;
2324
- let uri = /^data:application\/json,/;
2325
- if (charsetUri.test(text) || uri.test(text)) {
2326
- return decodeURIComponent(text.substr(RegExp.lastMatch.length));
2327
- }
2328
- if (baseCharsetUri.test(text) || baseUri.test(text)) {
2329
- return fromBase64(text.substr(RegExp.lastMatch.length));
2363
+ each(callback) {
2364
+ if (!this.proxyOf.nodes) return void 0;
2365
+ let iterator = this.getIterator();
2366
+ let index2, result2;
2367
+ while (this.indexes[iterator] < this.proxyOf.nodes.length) {
2368
+ index2 = this.indexes[iterator];
2369
+ result2 = callback(this.proxyOf.nodes[index2], index2);
2370
+ if (result2 === false) break;
2371
+ this.indexes[iterator] += 1;
2330
2372
  }
2331
- let encoding = text.match(/data:application\/json;([^,]+),/)[1];
2332
- throw new Error("Unsupported source map encoding " + encoding);
2333
- }
2334
- getAnnotationURL(sourceMapString) {
2335
- return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
2336
- }
2337
- isMap(map) {
2338
- if (typeof map !== "object") return false;
2339
- return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
2373
+ delete this.indexes[iterator];
2374
+ return result2;
2340
2375
  }
2341
- loadAnnotation(css) {
2342
- let comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
2343
- if (!comments) return;
2344
- let start = css.lastIndexOf(comments.pop());
2345
- let end = css.indexOf("*/", start);
2346
- if (start > -1 && end > -1) {
2347
- this.annotation = this.getAnnotationURL(css.substring(start, end));
2348
- }
2376
+ every(condition) {
2377
+ return this.nodes.every(condition);
2349
2378
  }
2350
- loadFile(path) {
2351
- this.root = dirname$1(path);
2352
- if (existsSync(path)) {
2353
- this.mapFile = path;
2354
- return readFileSync(path, "utf-8").toString().trim();
2355
- }
2379
+ getIterator() {
2380
+ if (!this.lastEach) this.lastEach = 0;
2381
+ if (!this.indexes) this.indexes = {};
2382
+ this.lastEach += 1;
2383
+ let iterator = this.lastEach;
2384
+ this.indexes[iterator] = 0;
2385
+ return iterator;
2356
2386
  }
2357
- loadMap(file, prev) {
2358
- if (prev === false) return false;
2359
- if (prev) {
2360
- if (typeof prev === "string") {
2361
- return prev;
2362
- } else if (typeof prev === "function") {
2363
- let prevPath = prev(file);
2364
- if (prevPath) {
2365
- let map = this.loadFile(prevPath);
2366
- if (!map) {
2367
- throw new Error(
2368
- "Unable to load previous source map: " + prevPath.toString()
2387
+ getProxyProcessor() {
2388
+ return {
2389
+ get(node2, prop) {
2390
+ if (prop === "proxyOf") {
2391
+ return node2;
2392
+ } else if (!node2[prop]) {
2393
+ return node2[prop];
2394
+ } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
2395
+ return (...args) => {
2396
+ return node2[prop](
2397
+ ...args.map((i) => {
2398
+ if (typeof i === "function") {
2399
+ return (child, index2) => i(child.toProxy(), index2);
2400
+ } else {
2401
+ return i;
2402
+ }
2403
+ })
2369
2404
  );
2370
- }
2371
- return map;
2405
+ };
2406
+ } else if (prop === "every" || prop === "some") {
2407
+ return (cb) => {
2408
+ return node2[prop](
2409
+ (child, ...other) => cb(child.toProxy(), ...other)
2410
+ );
2411
+ };
2412
+ } else if (prop === "root") {
2413
+ return () => node2.root().toProxy();
2414
+ } else if (prop === "nodes") {
2415
+ return node2.nodes.map((i) => i.toProxy());
2416
+ } else if (prop === "first" || prop === "last") {
2417
+ return node2[prop].toProxy();
2418
+ } else {
2419
+ return node2[prop];
2372
2420
  }
2373
- } else if (prev instanceof SourceMapConsumer$2) {
2374
- return SourceMapGenerator$2.fromSourceMap(prev).toString();
2375
- } else if (prev instanceof SourceMapGenerator$2) {
2376
- return prev.toString();
2377
- } else if (this.isMap(prev)) {
2378
- return JSON.stringify(prev);
2379
- } else {
2380
- throw new Error(
2381
- "Unsupported previous source map format: " + prev.toString()
2382
- );
2421
+ },
2422
+ set(node2, prop, value) {
2423
+ if (node2[prop] === value) return true;
2424
+ node2[prop] = value;
2425
+ if (prop === "name" || prop === "params" || prop === "selector") {
2426
+ node2.markDirty();
2427
+ }
2428
+ return true;
2383
2429
  }
2384
- } else if (this.inline) {
2385
- return this.decodeInline(this.annotation);
2386
- } else if (this.annotation) {
2387
- let map = this.annotation;
2388
- if (file) map = join(dirname$1(file), map);
2389
- return this.loadFile(map);
2390
- }
2430
+ };
2391
2431
  }
2392
- startWith(string, start) {
2393
- if (!string) return false;
2394
- return string.substr(0, start.length) === start;
2432
+ index(child) {
2433
+ if (typeof child === "number") return child;
2434
+ if (child.proxyOf) child = child.proxyOf;
2435
+ return this.proxyOf.nodes.indexOf(child);
2395
2436
  }
2396
- withContent() {
2397
- return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
2437
+ insertAfter(exist, add) {
2438
+ let existIndex = this.index(exist);
2439
+ let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
2440
+ existIndex = this.index(exist);
2441
+ for (let node2 of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
2442
+ let index2;
2443
+ for (let id in this.indexes) {
2444
+ index2 = this.indexes[id];
2445
+ if (existIndex < index2) {
2446
+ this.indexes[id] = index2 + nodes.length;
2447
+ }
2448
+ }
2449
+ this.markDirty();
2450
+ return this;
2398
2451
  }
2399
- };
2400
- var previousMap = PreviousMap$2;
2401
- PreviousMap$2.default = PreviousMap$2;
2402
- let { SourceMapConsumer: SourceMapConsumer$1, SourceMapGenerator: SourceMapGenerator$1 } = require$$2;
2403
- let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
2404
- let { isAbsolute, resolve: resolve$1 } = require$$2;
2405
- let { nanoid } = nonSecure;
2406
- let terminalHighlight = require$$2;
2407
- let CssSyntaxError$1 = cssSyntaxError;
2408
- let PreviousMap$1 = previousMap;
2409
- let fromOffsetCache = Symbol("fromOffsetCache");
2410
- let sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
2411
- let pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
2412
- let Input$4 = class Input {
2413
- constructor(css, opts = {}) {
2414
- if (css === null || typeof css === "undefined" || typeof css === "object" && !css.toString) {
2415
- throw new Error(`PostCSS received ${css} instead of CSS string`);
2452
+ insertBefore(exist, add) {
2453
+ let existIndex = this.index(exist);
2454
+ let type = existIndex === 0 ? "prepend" : false;
2455
+ let nodes = this.normalize(
2456
+ add,
2457
+ this.proxyOf.nodes[existIndex],
2458
+ type
2459
+ ).reverse();
2460
+ existIndex = this.index(exist);
2461
+ for (let node2 of nodes) this.proxyOf.nodes.splice(existIndex, 0, node2);
2462
+ let index2;
2463
+ for (let id in this.indexes) {
2464
+ index2 = this.indexes[id];
2465
+ if (existIndex <= index2) {
2466
+ this.indexes[id] = index2 + nodes.length;
2467
+ }
2416
2468
  }
2417
- this.css = css.toString();
2418
- if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
2419
- this.hasBOM = true;
2420
- this.css = this.css.slice(1);
2469
+ this.markDirty();
2470
+ return this;
2471
+ }
2472
+ normalize(nodes, sample) {
2473
+ if (typeof nodes === "string") {
2474
+ nodes = cleanSource(parse$5(nodes).nodes);
2475
+ } else if (typeof nodes === "undefined") {
2476
+ nodes = [];
2477
+ } else if (Array.isArray(nodes)) {
2478
+ nodes = nodes.slice(0);
2479
+ for (let i of nodes) {
2480
+ if (i.parent) i.parent.removeChild(i, "ignore");
2481
+ }
2482
+ } else if (nodes.type === "root" && this.type !== "document") {
2483
+ nodes = nodes.nodes.slice(0);
2484
+ for (let i of nodes) {
2485
+ if (i.parent) i.parent.removeChild(i, "ignore");
2486
+ }
2487
+ } else if (nodes.type) {
2488
+ nodes = [nodes];
2489
+ } else if (nodes.prop) {
2490
+ if (typeof nodes.value === "undefined") {
2491
+ throw new Error("Value field is missed in node creation");
2492
+ } else if (typeof nodes.value !== "string") {
2493
+ nodes.value = String(nodes.value);
2494
+ }
2495
+ nodes = [new Declaration$4(nodes)];
2496
+ } else if (nodes.selector || nodes.selectors) {
2497
+ nodes = [new Rule$5(nodes)];
2498
+ } else if (nodes.name) {
2499
+ nodes = [new AtRule$5(nodes)];
2500
+ } else if (nodes.text) {
2501
+ nodes = [new Comment$5(nodes)];
2421
2502
  } else {
2422
- this.hasBOM = false;
2503
+ throw new Error("Unknown node type in node creation");
2423
2504
  }
2424
- if (opts.from) {
2425
- if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
2426
- this.file = opts.from;
2427
- } else {
2428
- this.file = resolve$1(opts.from);
2505
+ let processed = nodes.map((i) => {
2506
+ if (!i[my$1]) Container.rebuild(i);
2507
+ i = i.proxyOf;
2508
+ if (i.parent) i.parent.removeChild(i);
2509
+ if (i[isClean$1]) markTreeDirty(i);
2510
+ if (!i.raws) i.raws = {};
2511
+ if (typeof i.raws.before === "undefined") {
2512
+ if (sample && typeof sample.raws.before !== "undefined") {
2513
+ i.raws.before = sample.raws.before.replace(/\S/g, "");
2514
+ }
2515
+ }
2516
+ i.parent = this.proxyOf;
2517
+ return i;
2518
+ });
2519
+ return processed;
2520
+ }
2521
+ prepend(...children) {
2522
+ children = children.reverse();
2523
+ for (let child of children) {
2524
+ let nodes = this.normalize(child, this.first, "prepend").reverse();
2525
+ for (let node2 of nodes) this.proxyOf.nodes.unshift(node2);
2526
+ for (let id in this.indexes) {
2527
+ this.indexes[id] = this.indexes[id] + nodes.length;
2429
2528
  }
2430
2529
  }
2431
- if (pathAvailable$1 && sourceMapAvailable$1) {
2432
- let map = new PreviousMap$1(this.css, opts);
2433
- if (map.text) {
2434
- this.map = map;
2435
- let file = map.consumer().file;
2436
- if (!this.file && file) this.file = this.mapResolve(file);
2530
+ this.markDirty();
2531
+ return this;
2532
+ }
2533
+ push(child) {
2534
+ child.parent = this;
2535
+ this.proxyOf.nodes.push(child);
2536
+ return this;
2537
+ }
2538
+ removeAll() {
2539
+ for (let node2 of this.proxyOf.nodes) node2.parent = void 0;
2540
+ this.proxyOf.nodes = [];
2541
+ this.markDirty();
2542
+ return this;
2543
+ }
2544
+ removeChild(child) {
2545
+ child = this.index(child);
2546
+ this.proxyOf.nodes[child].parent = void 0;
2547
+ this.proxyOf.nodes.splice(child, 1);
2548
+ let index2;
2549
+ for (let id in this.indexes) {
2550
+ index2 = this.indexes[id];
2551
+ if (index2 >= child) {
2552
+ this.indexes[id] = index2 - 1;
2437
2553
  }
2438
2554
  }
2439
- if (!this.file) {
2440
- this.id = "<input css " + nanoid(6) + ">";
2555
+ this.markDirty();
2556
+ return this;
2557
+ }
2558
+ replaceValues(pattern, opts, callback) {
2559
+ if (!callback) {
2560
+ callback = opts;
2561
+ opts = {};
2441
2562
  }
2442
- if (this.map) this.map.file = this.from;
2563
+ this.walkDecls((decl2) => {
2564
+ if (opts.props && !opts.props.includes(decl2.prop)) return;
2565
+ if (opts.fast && !decl2.value.includes(opts.fast)) return;
2566
+ decl2.value = decl2.value.replace(pattern, callback);
2567
+ });
2568
+ this.markDirty();
2569
+ return this;
2443
2570
  }
2444
- error(message, line, column, opts = {}) {
2445
- let result2, endLine, endColumn;
2446
- if (line && typeof line === "object") {
2447
- let start = line;
2448
- let end = column;
2449
- if (typeof start.offset === "number") {
2450
- let pos = this.fromOffset(start.offset);
2451
- line = pos.line;
2452
- column = pos.col;
2453
- } else {
2454
- line = start.line;
2455
- column = start.column;
2571
+ some(condition) {
2572
+ return this.nodes.some(condition);
2573
+ }
2574
+ walk(callback) {
2575
+ return this.each((child, i) => {
2576
+ let result2;
2577
+ try {
2578
+ result2 = callback(child, i);
2579
+ } catch (e) {
2580
+ throw child.addToError(e);
2456
2581
  }
2457
- if (typeof end.offset === "number") {
2458
- let pos = this.fromOffset(end.offset);
2459
- endLine = pos.line;
2460
- endColumn = pos.col;
2461
- } else {
2462
- endLine = end.line;
2463
- endColumn = end.column;
2582
+ if (result2 !== false && child.walk) {
2583
+ result2 = child.walk(callback);
2464
2584
  }
2465
- } else if (!column) {
2466
- let pos = this.fromOffset(line);
2467
- line = pos.line;
2468
- column = pos.col;
2585
+ return result2;
2586
+ });
2587
+ }
2588
+ walkAtRules(name, callback) {
2589
+ if (!callback) {
2590
+ callback = name;
2591
+ return this.walk((child, i) => {
2592
+ if (child.type === "atrule") {
2593
+ return callback(child, i);
2594
+ }
2595
+ });
2469
2596
  }
2470
- let origin = this.origin(line, column, endLine, endColumn);
2471
- if (origin) {
2472
- result2 = new CssSyntaxError$1(
2473
- message,
2474
- origin.endLine === void 0 ? origin.line : { column: origin.column, line: origin.line },
2475
- origin.endLine === void 0 ? origin.column : { column: origin.endColumn, line: origin.endLine },
2476
- origin.source,
2477
- origin.file,
2478
- opts.plugin
2479
- );
2480
- } else {
2481
- result2 = new CssSyntaxError$1(
2482
- message,
2483
- endLine === void 0 ? line : { column, line },
2484
- endLine === void 0 ? column : { column: endColumn, line: endLine },
2485
- this.css,
2486
- this.file,
2487
- opts.plugin
2488
- );
2597
+ if (name instanceof RegExp) {
2598
+ return this.walk((child, i) => {
2599
+ if (child.type === "atrule" && name.test(child.name)) {
2600
+ return callback(child, i);
2601
+ }
2602
+ });
2489
2603
  }
2490
- result2.input = { column, endColumn, endLine, line, source: this.css };
2491
- if (this.file) {
2492
- if (pathToFileURL$1) {
2493
- result2.input.url = pathToFileURL$1(this.file).toString();
2604
+ return this.walk((child, i) => {
2605
+ if (child.type === "atrule" && child.name === name) {
2606
+ return callback(child, i);
2494
2607
  }
2495
- result2.input.file = this.file;
2496
- }
2497
- return result2;
2608
+ });
2498
2609
  }
2499
- fromOffset(offset) {
2500
- let lastLine, lineToIndex;
2501
- if (!this[fromOffsetCache]) {
2502
- let lines = this.css.split("\n");
2503
- lineToIndex = new Array(lines.length);
2504
- let prevIndex = 0;
2505
- for (let i = 0, l = lines.length; i < l; i++) {
2506
- lineToIndex[i] = prevIndex;
2507
- prevIndex += lines[i].length + 1;
2610
+ walkComments(callback) {
2611
+ return this.walk((child, i) => {
2612
+ if (child.type === "comment") {
2613
+ return callback(child, i);
2508
2614
  }
2509
- this[fromOffsetCache] = lineToIndex;
2510
- } else {
2511
- lineToIndex = this[fromOffsetCache];
2615
+ });
2616
+ }
2617
+ walkDecls(prop, callback) {
2618
+ if (!callback) {
2619
+ callback = prop;
2620
+ return this.walk((child, i) => {
2621
+ if (child.type === "decl") {
2622
+ return callback(child, i);
2623
+ }
2624
+ });
2512
2625
  }
2513
- lastLine = lineToIndex[lineToIndex.length - 1];
2514
- let min = 0;
2515
- if (offset >= lastLine) {
2516
- min = lineToIndex.length - 1;
2517
- } else {
2518
- let max = lineToIndex.length - 2;
2519
- let mid;
2520
- while (min < max) {
2521
- mid = min + (max - min >> 1);
2522
- if (offset < lineToIndex[mid]) {
2523
- max = mid - 1;
2524
- } else if (offset >= lineToIndex[mid + 1]) {
2525
- min = mid + 1;
2526
- } else {
2527
- min = mid;
2528
- break;
2626
+ if (prop instanceof RegExp) {
2627
+ return this.walk((child, i) => {
2628
+ if (child.type === "decl" && prop.test(child.prop)) {
2629
+ return callback(child, i);
2529
2630
  }
2530
- }
2631
+ });
2531
2632
  }
2532
- return {
2533
- col: offset - lineToIndex[min] + 1,
2534
- line: min + 1
2535
- };
2633
+ return this.walk((child, i) => {
2634
+ if (child.type === "decl" && child.prop === prop) {
2635
+ return callback(child, i);
2636
+ }
2637
+ });
2536
2638
  }
2537
- mapResolve(file) {
2538
- if (/^\w+:\/\//.test(file)) {
2539
- return file;
2540
- }
2541
- return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
2542
- }
2543
- origin(line, column, endLine, endColumn) {
2544
- if (!this.map) return false;
2545
- let consumer = this.map.consumer();
2546
- let from = consumer.originalPositionFor({ column, line });
2547
- if (!from.source) return false;
2548
- let to;
2549
- if (typeof endLine === "number") {
2550
- to = consumer.originalPositionFor({ column: endColumn, line: endLine });
2639
+ walkRules(selector, callback) {
2640
+ if (!callback) {
2641
+ callback = selector;
2642
+ return this.walk((child, i) => {
2643
+ if (child.type === "rule") {
2644
+ return callback(child, i);
2645
+ }
2646
+ });
2551
2647
  }
2552
- let fromUrl;
2553
- if (isAbsolute(from.source)) {
2554
- fromUrl = pathToFileURL$1(from.source);
2555
- } else {
2556
- fromUrl = new URL(
2557
- from.source,
2558
- this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile)
2559
- );
2648
+ if (selector instanceof RegExp) {
2649
+ return this.walk((child, i) => {
2650
+ if (child.type === "rule" && selector.test(child.selector)) {
2651
+ return callback(child, i);
2652
+ }
2653
+ });
2560
2654
  }
2561
- let result2 = {
2562
- column: from.column,
2563
- endColumn: to && to.column,
2564
- endLine: to && to.line,
2565
- line: from.line,
2566
- url: fromUrl.toString()
2567
- };
2568
- if (fromUrl.protocol === "file:") {
2569
- if (fileURLToPath) {
2570
- result2.file = fileURLToPath(fromUrl);
2571
- } else {
2572
- throw new Error(`file: protocol is not available in this PostCSS build`);
2655
+ return this.walk((child, i) => {
2656
+ if (child.type === "rule" && child.selector === selector) {
2657
+ return callback(child, i);
2573
2658
  }
2574
- }
2575
- let source = consumer.sourceContentFor(from.source);
2576
- if (source) result2.source = source;
2577
- return result2;
2659
+ });
2578
2660
  }
2579
- toJSON() {
2580
- let json = {};
2581
- for (let name of ["hasBOM", "css", "file", "id"]) {
2582
- if (this[name] != null) {
2583
- json[name] = this[name];
2584
- }
2585
- }
2586
- if (this.map) {
2587
- json.map = { ...this.map };
2588
- if (json.map.consumerCache) {
2589
- json.map.consumerCache = void 0;
2590
- }
2591
- }
2592
- return json;
2661
+ get first() {
2662
+ if (!this.proxyOf.nodes) return void 0;
2663
+ return this.proxyOf.nodes[0];
2593
2664
  }
2594
- get from() {
2595
- return this.file || this.id;
2665
+ get last() {
2666
+ if (!this.proxyOf.nodes) return void 0;
2667
+ return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
2596
2668
  }
2597
2669
  };
2598
- var input = Input$4;
2599
- Input$4.default = Input$4;
2600
- if (terminalHighlight && terminalHighlight.registerInput) {
2601
- terminalHighlight.registerInput(Input$4);
2602
- }
2603
- let { SourceMapConsumer, SourceMapGenerator } = require$$2;
2604
- let { dirname, relative, resolve, sep } = require$$2;
2605
- let { pathToFileURL } = require$$2;
2606
- let Input$3 = input;
2607
- let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
2608
- let pathAvailable = Boolean(dirname && resolve && relative && sep);
2609
- let MapGenerator$2 = class MapGenerator {
2610
- constructor(stringify2, root2, opts, cssString) {
2611
- this.stringify = stringify2;
2612
- this.mapOpts = opts.map || {};
2613
- this.root = root2;
2614
- this.opts = opts;
2615
- this.css = cssString;
2616
- this.originalCSS = cssString;
2617
- this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
2618
- this.memoizedFileURLs = /* @__PURE__ */ new Map();
2619
- this.memoizedPaths = /* @__PURE__ */ new Map();
2620
- this.memoizedURLs = /* @__PURE__ */ new Map();
2670
+ Container$8.registerParse = (dependant) => {
2671
+ parse$5 = dependant;
2672
+ };
2673
+ Container$8.registerRule = (dependant) => {
2674
+ Rule$5 = dependant;
2675
+ };
2676
+ Container$8.registerAtRule = (dependant) => {
2677
+ AtRule$5 = dependant;
2678
+ };
2679
+ Container$8.registerRoot = (dependant) => {
2680
+ Root$7 = dependant;
2681
+ };
2682
+ var container = Container$8;
2683
+ Container$8.default = Container$8;
2684
+ Container$8.rebuild = (node2) => {
2685
+ if (node2.type === "atrule") {
2686
+ Object.setPrototypeOf(node2, AtRule$5.prototype);
2687
+ } else if (node2.type === "rule") {
2688
+ Object.setPrototypeOf(node2, Rule$5.prototype);
2689
+ } else if (node2.type === "decl") {
2690
+ Object.setPrototypeOf(node2, Declaration$4.prototype);
2691
+ } else if (node2.type === "comment") {
2692
+ Object.setPrototypeOf(node2, Comment$5.prototype);
2693
+ } else if (node2.type === "root") {
2694
+ Object.setPrototypeOf(node2, Root$7.prototype);
2621
2695
  }
2622
- addAnnotation() {
2623
- let content;
2624
- if (this.isInline()) {
2625
- content = "data:application/json;base64," + this.toBase64(this.map.toString());
2626
- } else if (typeof this.mapOpts.annotation === "string") {
2627
- content = this.mapOpts.annotation;
2628
- } else if (typeof this.mapOpts.annotation === "function") {
2629
- content = this.mapOpts.annotation(this.opts.to, this.root);
2630
- } else {
2631
- content = this.outputFile() + ".map";
2632
- }
2633
- let eol = "\n";
2634
- if (this.css.includes("\r\n")) eol = "\r\n";
2635
- this.css += eol + "/*# sourceMappingURL=" + content + " */";
2696
+ node2[my$1] = true;
2697
+ if (node2.nodes) {
2698
+ node2.nodes.forEach((child) => {
2699
+ Container$8.rebuild(child);
2700
+ });
2636
2701
  }
2637
- applyPrevMaps() {
2638
- for (let prev of this.previous()) {
2639
- let from = this.toUrl(this.path(prev.file));
2640
- let root2 = prev.root || dirname(prev.file);
2641
- let map;
2642
- if (this.mapOpts.sourcesContent === false) {
2643
- map = new SourceMapConsumer(prev.text);
2644
- if (map.sourcesContent) {
2645
- map.sourcesContent = null;
2646
- }
2647
- } else {
2648
- map = prev.consumer();
2649
- }
2650
- this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
2651
- }
2702
+ };
2703
+ let Container$7 = container;
2704
+ let AtRule$4 = class AtRule extends Container$7 {
2705
+ constructor(defaults) {
2706
+ super(defaults);
2707
+ this.type = "atrule";
2652
2708
  }
2653
- clearAnnotation() {
2654
- if (this.mapOpts.annotation === false) return;
2655
- if (this.root) {
2656
- let node2;
2657
- for (let i = this.root.nodes.length - 1; i >= 0; i--) {
2658
- node2 = this.root.nodes[i];
2659
- if (node2.type !== "comment") continue;
2660
- if (node2.text.indexOf("# sourceMappingURL=") === 0) {
2661
- this.root.removeChild(i);
2662
- }
2663
- }
2664
- } else if (this.css) {
2665
- this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
2666
- }
2709
+ append(...children) {
2710
+ if (!this.proxyOf.nodes) this.nodes = [];
2711
+ return super.append(...children);
2667
2712
  }
2668
- generate() {
2669
- this.clearAnnotation();
2670
- if (pathAvailable && sourceMapAvailable && this.isMap()) {
2671
- return this.generateMap();
2672
- } else {
2673
- let result2 = "";
2674
- this.stringify(this.root, (i) => {
2675
- result2 += i;
2676
- });
2677
- return [result2];
2678
- }
2713
+ prepend(...children) {
2714
+ if (!this.proxyOf.nodes) this.nodes = [];
2715
+ return super.prepend(...children);
2679
2716
  }
2680
- generateMap() {
2681
- if (this.root) {
2682
- this.generateString();
2683
- } else if (this.previous().length === 1) {
2684
- let prev = this.previous()[0].consumer();
2685
- prev.file = this.outputFile();
2686
- this.map = SourceMapGenerator.fromSourceMap(prev, {
2687
- ignoreInvalidMapping: true
2688
- });
2689
- } else {
2690
- this.map = new SourceMapGenerator({
2691
- file: this.outputFile(),
2692
- ignoreInvalidMapping: true
2693
- });
2694
- this.map.addMapping({
2695
- generated: { column: 0, line: 1 },
2696
- original: { column: 0, line: 1 },
2697
- source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
2698
- });
2699
- }
2700
- if (this.isSourcesContent()) this.setSourcesContent();
2701
- if (this.root && this.previous().length > 0) this.applyPrevMaps();
2702
- if (this.isAnnotation()) this.addAnnotation();
2703
- if (this.isInline()) {
2704
- return [this.css];
2705
- } else {
2706
- return [this.css, this.map];
2717
+ };
2718
+ var atRule$1 = AtRule$4;
2719
+ AtRule$4.default = AtRule$4;
2720
+ Container$7.registerAtRule(AtRule$4);
2721
+ let Container$6 = container;
2722
+ let LazyResult$4, Processor$4;
2723
+ let Document$4 = class Document extends Container$6 {
2724
+ constructor(defaults) {
2725
+ super({ type: "document", ...defaults });
2726
+ if (!this.nodes) {
2727
+ this.nodes = [];
2707
2728
  }
2708
2729
  }
2709
- generateString() {
2710
- this.css = "";
2711
- this.map = new SourceMapGenerator({
2712
- file: this.outputFile(),
2713
- ignoreInvalidMapping: true
2714
- });
2715
- let line = 1;
2716
- let column = 1;
2717
- let noSource = "<no source>";
2718
- let mapping = {
2719
- generated: { column: 0, line: 0 },
2720
- original: { column: 0, line: 0 },
2721
- source: ""
2722
- };
2723
- let lines, last;
2724
- this.stringify(this.root, (str, node2, type) => {
2725
- this.css += str;
2726
- if (node2 && type !== "end") {
2727
- mapping.generated.line = line;
2728
- mapping.generated.column = column - 1;
2729
- if (node2.source && node2.source.start) {
2730
- mapping.source = this.sourcePath(node2);
2731
- mapping.original.line = node2.source.start.line;
2732
- mapping.original.column = node2.source.start.column - 1;
2733
- this.map.addMapping(mapping);
2734
- } else {
2735
- mapping.source = noSource;
2736
- mapping.original.line = 1;
2737
- mapping.original.column = 0;
2738
- this.map.addMapping(mapping);
2739
- }
2740
- }
2741
- lines = str.match(/\n/g);
2742
- if (lines) {
2743
- line += lines.length;
2744
- last = str.lastIndexOf("\n");
2745
- column = str.length - last;
2746
- } else {
2747
- column += str.length;
2748
- }
2749
- if (node2 && type !== "start") {
2750
- let p = node2.parent || { raws: {} };
2751
- let childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
2752
- if (!childless || node2 !== p.last || p.raws.semicolon) {
2753
- if (node2.source && node2.source.end) {
2754
- mapping.source = this.sourcePath(node2);
2755
- mapping.original.line = node2.source.end.line;
2756
- mapping.original.column = node2.source.end.column - 1;
2757
- mapping.generated.line = line;
2758
- mapping.generated.column = column - 2;
2759
- this.map.addMapping(mapping);
2760
- } else {
2761
- mapping.source = noSource;
2762
- mapping.original.line = 1;
2763
- mapping.original.column = 0;
2764
- mapping.generated.line = line;
2765
- mapping.generated.column = column - 1;
2766
- this.map.addMapping(mapping);
2767
- }
2768
- }
2769
- }
2770
- });
2730
+ toResult(opts = {}) {
2731
+ let lazy = new LazyResult$4(new Processor$4(), this, opts);
2732
+ return lazy.stringify();
2771
2733
  }
2772
- isAnnotation() {
2773
- if (this.isInline()) {
2774
- return true;
2775
- }
2776
- if (typeof this.mapOpts.annotation !== "undefined") {
2777
- return this.mapOpts.annotation;
2778
- }
2779
- if (this.previous().length) {
2780
- return this.previous().some((i) => i.annotation);
2734
+ };
2735
+ Document$4.registerLazyResult = (dependant) => {
2736
+ LazyResult$4 = dependant;
2737
+ };
2738
+ Document$4.registerProcessor = (dependant) => {
2739
+ Processor$4 = dependant;
2740
+ };
2741
+ var document$2 = Document$4;
2742
+ Document$4.default = Document$4;
2743
+ let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
2744
+ let customAlphabet = (alphabet, defaultSize = 21) => {
2745
+ return (size = defaultSize) => {
2746
+ let id = "";
2747
+ let i = size | 0;
2748
+ while (i--) {
2749
+ id += alphabet[Math.random() * alphabet.length | 0];
2781
2750
  }
2782
- return true;
2751
+ return id;
2752
+ };
2753
+ };
2754
+ let nanoid$1 = (size = 21) => {
2755
+ let id = "";
2756
+ let i = size | 0;
2757
+ while (i--) {
2758
+ id += urlAlphabet[Math.random() * 64 | 0];
2783
2759
  }
2784
- isInline() {
2785
- if (typeof this.mapOpts.inline !== "undefined") {
2786
- return this.mapOpts.inline;
2787
- }
2788
- let annotation = this.mapOpts.annotation;
2789
- if (typeof annotation !== "undefined" && annotation !== true) {
2790
- return false;
2791
- }
2792
- if (this.previous().length) {
2793
- return this.previous().some((i) => i.inline);
2760
+ return id;
2761
+ };
2762
+ var nonSecure = { nanoid: nanoid$1, customAlphabet };
2763
+ let { existsSync, readFileSync } = require$$2;
2764
+ let { dirname: dirname$1, join } = require$$2;
2765
+ let { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$2 } = require$$2;
2766
+ function fromBase64(str) {
2767
+ if (Buffer) {
2768
+ return Buffer.from(str, "base64").toString();
2769
+ } else {
2770
+ return window.atob(str);
2771
+ }
2772
+ }
2773
+ let PreviousMap$2 = class PreviousMap {
2774
+ constructor(css, opts) {
2775
+ if (opts.map === false) return;
2776
+ this.loadAnnotation(css);
2777
+ this.inline = this.startWith(this.annotation, "data:");
2778
+ let prev = opts.map ? opts.map.prev : void 0;
2779
+ let text = this.loadMap(opts.from, prev);
2780
+ if (!this.mapFile && opts.from) {
2781
+ this.mapFile = opts.from;
2794
2782
  }
2795
- return true;
2783
+ if (this.mapFile) this.root = dirname$1(this.mapFile);
2784
+ if (text) this.text = text;
2796
2785
  }
2797
- isMap() {
2798
- if (typeof this.opts.map !== "undefined") {
2799
- return !!this.opts.map;
2786
+ consumer() {
2787
+ if (!this.consumerCache) {
2788
+ this.consumerCache = new SourceMapConsumer$2(this.text);
2800
2789
  }
2801
- return this.previous().length > 0;
2790
+ return this.consumerCache;
2802
2791
  }
2803
- isSourcesContent() {
2804
- if (typeof this.mapOpts.sourcesContent !== "undefined") {
2805
- return this.mapOpts.sourcesContent;
2792
+ decodeInline(text) {
2793
+ let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
2794
+ let baseUri = /^data:application\/json;base64,/;
2795
+ let charsetUri = /^data:application\/json;charset=utf-?8,/;
2796
+ let uri = /^data:application\/json,/;
2797
+ let uriMatch = text.match(charsetUri) || text.match(uri);
2798
+ if (uriMatch) {
2799
+ return decodeURIComponent(text.substr(uriMatch[0].length));
2806
2800
  }
2807
- if (this.previous().length) {
2808
- return this.previous().some((i) => i.withContent());
2801
+ let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri);
2802
+ if (baseUriMatch) {
2803
+ return fromBase64(text.substr(baseUriMatch[0].length));
2809
2804
  }
2810
- return true;
2805
+ let encoding = text.match(/data:application\/json;([^,]+),/)[1];
2806
+ throw new Error("Unsupported source map encoding " + encoding);
2811
2807
  }
2812
- outputFile() {
2813
- if (this.opts.to) {
2814
- return this.path(this.opts.to);
2815
- } else if (this.opts.from) {
2816
- return this.path(this.opts.from);
2817
- } else {
2818
- return "to.css";
2808
+ getAnnotationURL(sourceMapString) {
2809
+ return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
2810
+ }
2811
+ isMap(map) {
2812
+ if (typeof map !== "object") return false;
2813
+ return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
2814
+ }
2815
+ loadAnnotation(css) {
2816
+ let comments = css.match(/\/\*\s*# sourceMappingURL=/g);
2817
+ if (!comments) return;
2818
+ let start = css.lastIndexOf(comments.pop());
2819
+ let end = css.indexOf("*/", start);
2820
+ if (start > -1 && end > -1) {
2821
+ this.annotation = this.getAnnotationURL(css.substring(start, end));
2819
2822
  }
2820
2823
  }
2821
- path(file) {
2822
- if (this.mapOpts.absolute) return file;
2823
- if (file.charCodeAt(0) === 60) return file;
2824
- if (/^\w+:\/\//.test(file)) return file;
2825
- let cached = this.memoizedPaths.get(file);
2826
- if (cached) return cached;
2827
- let from = this.opts.to ? dirname(this.opts.to) : ".";
2828
- if (typeof this.mapOpts.annotation === "string") {
2829
- from = dirname(resolve(from, this.mapOpts.annotation));
2824
+ loadFile(path) {
2825
+ this.root = dirname$1(path);
2826
+ if (existsSync(path)) {
2827
+ this.mapFile = path;
2828
+ return readFileSync(path, "utf-8").toString().trim();
2830
2829
  }
2831
- let path = relative(from, file);
2832
- this.memoizedPaths.set(file, path);
2833
- return path;
2834
2830
  }
2835
- previous() {
2836
- if (!this.previousMaps) {
2837
- this.previousMaps = [];
2838
- if (this.root) {
2839
- this.root.walk((node2) => {
2840
- if (node2.source && node2.source.input.map) {
2841
- let map = node2.source.input.map;
2842
- if (!this.previousMaps.includes(map)) {
2843
- this.previousMaps.push(map);
2844
- }
2831
+ loadMap(file, prev) {
2832
+ if (prev === false) return false;
2833
+ if (prev) {
2834
+ if (typeof prev === "string") {
2835
+ return prev;
2836
+ } else if (typeof prev === "function") {
2837
+ let prevPath = prev(file);
2838
+ if (prevPath) {
2839
+ let map = this.loadFile(prevPath);
2840
+ if (!map) {
2841
+ throw new Error(
2842
+ "Unable to load previous source map: " + prevPath.toString()
2843
+ );
2845
2844
  }
2846
- });
2845
+ return map;
2846
+ }
2847
+ } else if (prev instanceof SourceMapConsumer$2) {
2848
+ return SourceMapGenerator$2.fromSourceMap(prev).toString();
2849
+ } else if (prev instanceof SourceMapGenerator$2) {
2850
+ return prev.toString();
2851
+ } else if (this.isMap(prev)) {
2852
+ return JSON.stringify(prev);
2847
2853
  } else {
2848
- let input2 = new Input$3(this.originalCSS, this.opts);
2849
- if (input2.map) this.previousMaps.push(input2.map);
2854
+ throw new Error(
2855
+ "Unsupported previous source map format: " + prev.toString()
2856
+ );
2850
2857
  }
2858
+ } else if (this.inline) {
2859
+ return this.decodeInline(this.annotation);
2860
+ } else if (this.annotation) {
2861
+ let map = this.annotation;
2862
+ if (file) map = join(dirname$1(file), map);
2863
+ return this.loadFile(map);
2851
2864
  }
2852
- return this.previousMaps;
2853
2865
  }
2854
- setSourcesContent() {
2855
- let already = {};
2856
- if (this.root) {
2857
- this.root.walk((node2) => {
2858
- if (node2.source) {
2859
- let from = node2.source.input.from;
2860
- if (from && !already[from]) {
2861
- already[from] = true;
2862
- let fromUrl = this.usesFileUrls ? this.toFileUrl(from) : this.toUrl(this.path(from));
2863
- this.map.setSourceContent(fromUrl, node2.source.input.css);
2864
- }
2865
- }
2866
- });
2867
- } else if (this.css) {
2868
- let from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
2869
- this.map.setSourceContent(from, this.css);
2866
+ startWith(string, start) {
2867
+ if (!string) return false;
2868
+ return string.substr(0, start.length) === start;
2869
+ }
2870
+ withContent() {
2871
+ return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
2872
+ }
2873
+ };
2874
+ var previousMap = PreviousMap$2;
2875
+ PreviousMap$2.default = PreviousMap$2;
2876
+ let { nanoid } = nonSecure;
2877
+ let { isAbsolute, resolve: resolve$1 } = require$$2;
2878
+ let { SourceMapConsumer: SourceMapConsumer$1, SourceMapGenerator: SourceMapGenerator$1 } = require$$2;
2879
+ let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
2880
+ let CssSyntaxError$2 = cssSyntaxError;
2881
+ let PreviousMap$1 = previousMap;
2882
+ let terminalHighlight = require$$2;
2883
+ let fromOffsetCache = Symbol("fromOffsetCache");
2884
+ let sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
2885
+ let pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
2886
+ let Input$6 = class Input {
2887
+ constructor(css, opts = {}) {
2888
+ if (css === null || typeof css === "undefined" || typeof css === "object" && !css.toString) {
2889
+ throw new Error(`PostCSS received ${css} instead of CSS string`);
2890
+ }
2891
+ this.css = css.toString();
2892
+ if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
2893
+ this.hasBOM = true;
2894
+ this.css = this.css.slice(1);
2895
+ } else {
2896
+ this.hasBOM = false;
2897
+ }
2898
+ this.document = this.css;
2899
+ if (opts.document) this.document = opts.document.toString();
2900
+ if (opts.from) {
2901
+ if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
2902
+ this.file = opts.from;
2903
+ } else {
2904
+ this.file = resolve$1(opts.from);
2905
+ }
2906
+ }
2907
+ if (pathAvailable$1 && sourceMapAvailable$1) {
2908
+ let map = new PreviousMap$1(this.css, opts);
2909
+ if (map.text) {
2910
+ this.map = map;
2911
+ let file = map.consumer().file;
2912
+ if (!this.file && file) this.file = this.mapResolve(file);
2913
+ }
2914
+ }
2915
+ if (!this.file) {
2916
+ this.id = "<input css " + nanoid(6) + ">";
2917
+ }
2918
+ if (this.map) this.map.file = this.from;
2919
+ }
2920
+ error(message, line, column, opts = {}) {
2921
+ let endColumn, endLine, result2;
2922
+ if (line && typeof line === "object") {
2923
+ let start = line;
2924
+ let end = column;
2925
+ if (typeof start.offset === "number") {
2926
+ let pos = this.fromOffset(start.offset);
2927
+ line = pos.line;
2928
+ column = pos.col;
2929
+ } else {
2930
+ line = start.line;
2931
+ column = start.column;
2932
+ }
2933
+ if (typeof end.offset === "number") {
2934
+ let pos = this.fromOffset(end.offset);
2935
+ endLine = pos.line;
2936
+ endColumn = pos.col;
2937
+ } else {
2938
+ endLine = end.line;
2939
+ endColumn = end.column;
2940
+ }
2941
+ } else if (!column) {
2942
+ let pos = this.fromOffset(line);
2943
+ line = pos.line;
2944
+ column = pos.col;
2870
2945
  }
2871
- }
2872
- sourcePath(node2) {
2873
- if (this.mapOpts.from) {
2874
- return this.toUrl(this.mapOpts.from);
2875
- } else if (this.usesFileUrls) {
2876
- return this.toFileUrl(node2.source.input.from);
2946
+ let origin = this.origin(line, column, endLine, endColumn);
2947
+ if (origin) {
2948
+ result2 = new CssSyntaxError$2(
2949
+ message,
2950
+ origin.endLine === void 0 ? origin.line : { column: origin.column, line: origin.line },
2951
+ origin.endLine === void 0 ? origin.column : { column: origin.endColumn, line: origin.endLine },
2952
+ origin.source,
2953
+ origin.file,
2954
+ opts.plugin
2955
+ );
2877
2956
  } else {
2878
- return this.toUrl(this.path(node2.source.input.from));
2957
+ result2 = new CssSyntaxError$2(
2958
+ message,
2959
+ endLine === void 0 ? line : { column, line },
2960
+ endLine === void 0 ? column : { column: endColumn, line: endLine },
2961
+ this.css,
2962
+ this.file,
2963
+ opts.plugin
2964
+ );
2965
+ }
2966
+ result2.input = { column, endColumn, endLine, line, source: this.css };
2967
+ if (this.file) {
2968
+ if (pathToFileURL$1) {
2969
+ result2.input.url = pathToFileURL$1(this.file).toString();
2970
+ }
2971
+ result2.input.file = this.file;
2879
2972
  }
2973
+ return result2;
2880
2974
  }
2881
- toBase64(str) {
2882
- if (Buffer) {
2883
- return Buffer.from(str).toString("base64");
2975
+ fromOffset(offset) {
2976
+ let lastLine, lineToIndex;
2977
+ if (!this[fromOffsetCache]) {
2978
+ let lines = this.css.split("\n");
2979
+ lineToIndex = new Array(lines.length);
2980
+ let prevIndex = 0;
2981
+ for (let i = 0, l = lines.length; i < l; i++) {
2982
+ lineToIndex[i] = prevIndex;
2983
+ prevIndex += lines[i].length + 1;
2984
+ }
2985
+ this[fromOffsetCache] = lineToIndex;
2884
2986
  } else {
2885
- return window.btoa(unescape(encodeURIComponent(str)));
2987
+ lineToIndex = this[fromOffsetCache];
2886
2988
  }
2887
- }
2888
- toFileUrl(path) {
2889
- let cached = this.memoizedFileURLs.get(path);
2890
- if (cached) return cached;
2891
- if (pathToFileURL) {
2892
- let fileURL = pathToFileURL(path).toString();
2893
- this.memoizedFileURLs.set(path, fileURL);
2894
- return fileURL;
2989
+ lastLine = lineToIndex[lineToIndex.length - 1];
2990
+ let min = 0;
2991
+ if (offset >= lastLine) {
2992
+ min = lineToIndex.length - 1;
2895
2993
  } else {
2896
- throw new Error(
2897
- "`map.absolute` option is not available in this PostCSS build"
2898
- );
2994
+ let max = lineToIndex.length - 2;
2995
+ let mid;
2996
+ while (min < max) {
2997
+ mid = min + (max - min >> 1);
2998
+ if (offset < lineToIndex[mid]) {
2999
+ max = mid - 1;
3000
+ } else if (offset >= lineToIndex[mid + 1]) {
3001
+ min = mid + 1;
3002
+ } else {
3003
+ min = mid;
3004
+ break;
3005
+ }
3006
+ }
2899
3007
  }
3008
+ return {
3009
+ col: offset - lineToIndex[min] + 1,
3010
+ line: min + 1
3011
+ };
2900
3012
  }
2901
- toUrl(path) {
2902
- let cached = this.memoizedURLs.get(path);
2903
- if (cached) return cached;
2904
- if (sep === "\\") {
2905
- path = path.replace(/\\/g, "/");
3013
+ mapResolve(file) {
3014
+ if (/^\w+:\/\//.test(file)) {
3015
+ return file;
2906
3016
  }
2907
- let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
2908
- this.memoizedURLs.set(path, url);
2909
- return url;
2910
- }
2911
- };
2912
- var mapGenerator = MapGenerator$2;
2913
- let Node$2 = node;
2914
- let Comment$4 = class Comment extends Node$2 {
2915
- constructor(defaults) {
2916
- super(defaults);
2917
- this.type = "comment";
3017
+ return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
2918
3018
  }
2919
- };
2920
- var comment = Comment$4;
2921
- Comment$4.default = Comment$4;
2922
- let { isClean: isClean$1, my: my$1 } = symbols;
2923
- let Declaration$3 = declaration;
2924
- let Comment$3 = comment;
2925
- let Node$1 = node;
2926
- let parse$4, Rule$4, AtRule$4, Root$6;
2927
- function cleanSource(nodes) {
2928
- return nodes.map((i) => {
2929
- if (i.nodes) i.nodes = cleanSource(i.nodes);
2930
- delete i.source;
2931
- return i;
2932
- });
2933
- }
2934
- function markDirtyUp(node2) {
2935
- node2[isClean$1] = false;
2936
- if (node2.proxyOf.nodes) {
2937
- for (let i of node2.proxyOf.nodes) {
2938
- markDirtyUp(i);
3019
+ origin(line, column, endLine, endColumn) {
3020
+ if (!this.map) return false;
3021
+ let consumer = this.map.consumer();
3022
+ let from = consumer.originalPositionFor({ column, line });
3023
+ if (!from.source) return false;
3024
+ let to;
3025
+ if (typeof endLine === "number") {
3026
+ to = consumer.originalPositionFor({ column: endColumn, line: endLine });
2939
3027
  }
2940
- }
2941
- }
2942
- let Container$7 = class Container extends Node$1 {
2943
- append(...children) {
2944
- for (let child of children) {
2945
- let nodes = this.normalize(child, this.last);
2946
- for (let node2 of nodes) this.proxyOf.nodes.push(node2);
3028
+ let fromUrl;
3029
+ if (isAbsolute(from.source)) {
3030
+ fromUrl = pathToFileURL$1(from.source);
3031
+ } else {
3032
+ fromUrl = new URL(
3033
+ from.source,
3034
+ this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile)
3035
+ );
2947
3036
  }
2948
- this.markDirty();
2949
- return this;
2950
- }
2951
- cleanRaws(keepBetween) {
2952
- super.cleanRaws(keepBetween);
2953
- if (this.nodes) {
2954
- for (let node2 of this.nodes) node2.cleanRaws(keepBetween);
3037
+ let result2 = {
3038
+ column: from.column,
3039
+ endColumn: to && to.column,
3040
+ endLine: to && to.line,
3041
+ line: from.line,
3042
+ url: fromUrl.toString()
3043
+ };
3044
+ if (fromUrl.protocol === "file:") {
3045
+ if (fileURLToPath) {
3046
+ result2.file = fileURLToPath(fromUrl);
3047
+ } else {
3048
+ throw new Error(`file: protocol is not available in this PostCSS build`);
3049
+ }
2955
3050
  }
3051
+ let source = consumer.sourceContentFor(from.source);
3052
+ if (source) result2.source = source;
3053
+ return result2;
2956
3054
  }
2957
- each(callback) {
2958
- if (!this.proxyOf.nodes) return void 0;
2959
- let iterator = this.getIterator();
2960
- let index2, result2;
2961
- while (this.indexes[iterator] < this.proxyOf.nodes.length) {
2962
- index2 = this.indexes[iterator];
2963
- result2 = callback(this.proxyOf.nodes[index2], index2);
2964
- if (result2 === false) break;
2965
- this.indexes[iterator] += 1;
3055
+ toJSON() {
3056
+ let json = {};
3057
+ for (let name of ["hasBOM", "css", "file", "id"]) {
3058
+ if (this[name] != null) {
3059
+ json[name] = this[name];
3060
+ }
2966
3061
  }
2967
- delete this.indexes[iterator];
2968
- return result2;
3062
+ if (this.map) {
3063
+ json.map = { ...this.map };
3064
+ if (json.map.consumerCache) {
3065
+ json.map.consumerCache = void 0;
3066
+ }
3067
+ }
3068
+ return json;
2969
3069
  }
2970
- every(condition) {
2971
- return this.nodes.every(condition);
3070
+ get from() {
3071
+ return this.file || this.id;
2972
3072
  }
2973
- getIterator() {
2974
- if (!this.lastEach) this.lastEach = 0;
2975
- if (!this.indexes) this.indexes = {};
2976
- this.lastEach += 1;
2977
- let iterator = this.lastEach;
2978
- this.indexes[iterator] = 0;
2979
- return iterator;
3073
+ };
3074
+ var input = Input$6;
3075
+ Input$6.default = Input$6;
3076
+ if (terminalHighlight && terminalHighlight.registerInput) {
3077
+ terminalHighlight.registerInput(Input$6);
3078
+ }
3079
+ let Container$5 = container;
3080
+ let LazyResult$3, Processor$3;
3081
+ let Root$6 = class Root extends Container$5 {
3082
+ constructor(defaults) {
3083
+ super(defaults);
3084
+ this.type = "root";
3085
+ if (!this.nodes) this.nodes = [];
2980
3086
  }
2981
- getProxyProcessor() {
2982
- return {
2983
- get(node2, prop) {
2984
- if (prop === "proxyOf") {
2985
- return node2;
2986
- } else if (!node2[prop]) {
2987
- return node2[prop];
2988
- } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
2989
- return (...args) => {
2990
- return node2[prop](
2991
- ...args.map((i) => {
2992
- if (typeof i === "function") {
2993
- return (child, index2) => i(child.toProxy(), index2);
2994
- } else {
2995
- return i;
2996
- }
2997
- })
2998
- );
2999
- };
3000
- } else if (prop === "every" || prop === "some") {
3001
- return (cb) => {
3002
- return node2[prop](
3003
- (child, ...other) => cb(child.toProxy(), ...other)
3004
- );
3005
- };
3006
- } else if (prop === "root") {
3007
- return () => node2.root().toProxy();
3008
- } else if (prop === "nodes") {
3009
- return node2.nodes.map((i) => i.toProxy());
3010
- } else if (prop === "first" || prop === "last") {
3011
- return node2[prop].toProxy();
3087
+ normalize(child, sample, type) {
3088
+ let nodes = super.normalize(child);
3089
+ if (sample) {
3090
+ if (type === "prepend") {
3091
+ if (this.nodes.length > 1) {
3092
+ sample.raws.before = this.nodes[1].raws.before;
3012
3093
  } else {
3013
- return node2[prop];
3094
+ delete sample.raws.before;
3014
3095
  }
3015
- },
3016
- set(node2, prop, value) {
3017
- if (node2[prop] === value) return true;
3018
- node2[prop] = value;
3019
- if (prop === "name" || prop === "params" || prop === "selector") {
3020
- node2.markDirty();
3096
+ } else if (this.first !== sample) {
3097
+ for (let node2 of nodes) {
3098
+ node2.raws.before = sample.raws.before;
3021
3099
  }
3022
- return true;
3023
- }
3024
- };
3025
- }
3026
- index(child) {
3027
- if (typeof child === "number") return child;
3028
- if (child.proxyOf) child = child.proxyOf;
3029
- return this.proxyOf.nodes.indexOf(child);
3030
- }
3031
- insertAfter(exist, add) {
3032
- let existIndex = this.index(exist);
3033
- let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
3034
- existIndex = this.index(exist);
3035
- for (let node2 of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
3036
- let index2;
3037
- for (let id in this.indexes) {
3038
- index2 = this.indexes[id];
3039
- if (existIndex < index2) {
3040
- this.indexes[id] = index2 + nodes.length;
3041
3100
  }
3042
3101
  }
3043
- this.markDirty();
3044
- return this;
3102
+ return nodes;
3045
3103
  }
3046
- insertBefore(exist, add) {
3047
- let existIndex = this.index(exist);
3048
- let type = existIndex === 0 ? "prepend" : false;
3049
- let nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
3050
- existIndex = this.index(exist);
3051
- for (let node2 of nodes) this.proxyOf.nodes.splice(existIndex, 0, node2);
3052
- let index2;
3053
- for (let id in this.indexes) {
3054
- index2 = this.indexes[id];
3055
- if (existIndex <= index2) {
3056
- this.indexes[id] = index2 + nodes.length;
3057
- }
3104
+ removeChild(child, ignore) {
3105
+ let index2 = this.index(child);
3106
+ if (!ignore && index2 === 0 && this.nodes.length > 1) {
3107
+ this.nodes[1].raws.before = this.nodes[index2].raws.before;
3058
3108
  }
3059
- this.markDirty();
3060
- return this;
3109
+ return super.removeChild(child);
3061
3110
  }
3062
- normalize(nodes, sample) {
3063
- if (typeof nodes === "string") {
3064
- nodes = cleanSource(parse$4(nodes).nodes);
3065
- } else if (typeof nodes === "undefined") {
3066
- nodes = [];
3067
- } else if (Array.isArray(nodes)) {
3068
- nodes = nodes.slice(0);
3069
- for (let i of nodes) {
3070
- if (i.parent) i.parent.removeChild(i, "ignore");
3071
- }
3072
- } else if (nodes.type === "root" && this.type !== "document") {
3073
- nodes = nodes.nodes.slice(0);
3074
- for (let i of nodes) {
3075
- if (i.parent) i.parent.removeChild(i, "ignore");
3076
- }
3077
- } else if (nodes.type) {
3078
- nodes = [nodes];
3079
- } else if (nodes.prop) {
3080
- if (typeof nodes.value === "undefined") {
3081
- throw new Error("Value field is missed in node creation");
3082
- } else if (typeof nodes.value !== "string") {
3083
- nodes.value = String(nodes.value);
3084
- }
3085
- nodes = [new Declaration$3(nodes)];
3086
- } else if (nodes.selector) {
3087
- nodes = [new Rule$4(nodes)];
3088
- } else if (nodes.name) {
3089
- nodes = [new AtRule$4(nodes)];
3090
- } else if (nodes.text) {
3091
- nodes = [new Comment$3(nodes)];
3092
- } else {
3093
- throw new Error("Unknown node type in node creation");
3094
- }
3095
- let processed = nodes.map((i) => {
3096
- if (!i[my$1]) Container.rebuild(i);
3097
- i = i.proxyOf;
3098
- if (i.parent) i.parent.removeChild(i);
3099
- if (i[isClean$1]) markDirtyUp(i);
3100
- if (typeof i.raws.before === "undefined") {
3101
- if (sample && typeof sample.raws.before !== "undefined") {
3102
- i.raws.before = sample.raws.before.replace(/\S/g, "");
3111
+ toResult(opts = {}) {
3112
+ let lazy = new LazyResult$3(new Processor$3(), this, opts);
3113
+ return lazy.stringify();
3114
+ }
3115
+ };
3116
+ Root$6.registerLazyResult = (dependant) => {
3117
+ LazyResult$3 = dependant;
3118
+ };
3119
+ Root$6.registerProcessor = (dependant) => {
3120
+ Processor$3 = dependant;
3121
+ };
3122
+ var root$1 = Root$6;
3123
+ Root$6.default = Root$6;
3124
+ Container$5.registerRoot(Root$6);
3125
+ let list$3 = {
3126
+ comma(string) {
3127
+ return list$3.split(string, [","], true);
3128
+ },
3129
+ space(string) {
3130
+ let spaces = [" ", "\n", " "];
3131
+ return list$3.split(string, spaces);
3132
+ },
3133
+ split(string, separators, last) {
3134
+ let array = [];
3135
+ let current = "";
3136
+ let split = false;
3137
+ let func = 0;
3138
+ let inQuote = false;
3139
+ let prevQuote = "";
3140
+ let escape = false;
3141
+ for (let letter of string) {
3142
+ if (escape) {
3143
+ escape = false;
3144
+ } else if (letter === "\\") {
3145
+ escape = true;
3146
+ } else if (inQuote) {
3147
+ if (letter === prevQuote) {
3148
+ inQuote = false;
3103
3149
  }
3150
+ } else if (letter === '"' || letter === "'") {
3151
+ inQuote = true;
3152
+ prevQuote = letter;
3153
+ } else if (letter === "(") {
3154
+ func += 1;
3155
+ } else if (letter === ")") {
3156
+ if (func > 0) func -= 1;
3157
+ } else if (func === 0) {
3158
+ if (separators.includes(letter)) split = true;
3104
3159
  }
3105
- i.parent = this.proxyOf;
3106
- return i;
3107
- });
3108
- return processed;
3109
- }
3110
- prepend(...children) {
3111
- children = children.reverse();
3112
- for (let child of children) {
3113
- let nodes = this.normalize(child, this.first, "prepend").reverse();
3114
- for (let node2 of nodes) this.proxyOf.nodes.unshift(node2);
3115
- for (let id in this.indexes) {
3116
- this.indexes[id] = this.indexes[id] + nodes.length;
3160
+ if (split) {
3161
+ if (current !== "") array.push(current.trim());
3162
+ current = "";
3163
+ split = false;
3164
+ } else {
3165
+ current += letter;
3117
3166
  }
3118
3167
  }
3119
- this.markDirty();
3120
- return this;
3168
+ if (last || current !== "") array.push(current.trim());
3169
+ return array;
3121
3170
  }
3122
- push(child) {
3123
- child.parent = this;
3124
- this.proxyOf.nodes.push(child);
3125
- return this;
3171
+ };
3172
+ var list_1 = list$3;
3173
+ list$3.default = list$3;
3174
+ let Container$4 = container;
3175
+ let list$2 = list_1;
3176
+ let Rule$4 = class Rule extends Container$4 {
3177
+ constructor(defaults) {
3178
+ super(defaults);
3179
+ this.type = "rule";
3180
+ if (!this.nodes) this.nodes = [];
3126
3181
  }
3127
- removeAll() {
3128
- for (let node2 of this.proxyOf.nodes) node2.parent = void 0;
3129
- this.proxyOf.nodes = [];
3130
- this.markDirty();
3131
- return this;
3182
+ get selectors() {
3183
+ return list$2.comma(this.selector);
3132
3184
  }
3133
- removeChild(child) {
3134
- child = this.index(child);
3135
- this.proxyOf.nodes[child].parent = void 0;
3136
- this.proxyOf.nodes.splice(child, 1);
3137
- let index2;
3138
- for (let id in this.indexes) {
3139
- index2 = this.indexes[id];
3140
- if (index2 >= child) {
3141
- this.indexes[id] = index2 - 1;
3185
+ set selectors(values) {
3186
+ let match = this.selector ? this.selector.match(/,\s*/) : null;
3187
+ let sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
3188
+ this.selector = values.join(sep2);
3189
+ }
3190
+ };
3191
+ var rule$1 = Rule$4;
3192
+ Rule$4.default = Rule$4;
3193
+ Container$4.registerRule(Rule$4);
3194
+ let AtRule$3 = atRule$1;
3195
+ let Comment$4 = comment$1;
3196
+ let Declaration$3 = declaration;
3197
+ let Input$5 = input;
3198
+ let PreviousMap2 = previousMap;
3199
+ let Root$5 = root$1;
3200
+ let Rule$3 = rule$1;
3201
+ function fromJSON$2(json, inputs) {
3202
+ if (Array.isArray(json)) return json.map((n) => fromJSON$2(n));
3203
+ let { inputs: ownInputs, ...defaults } = json;
3204
+ if (ownInputs) {
3205
+ inputs = [];
3206
+ for (let input2 of ownInputs) {
3207
+ let inputHydrated = { ...input2, __proto__: Input$5.prototype };
3208
+ if (inputHydrated.map) {
3209
+ inputHydrated.map = {
3210
+ ...inputHydrated.map,
3211
+ __proto__: PreviousMap2.prototype
3212
+ };
3142
3213
  }
3214
+ inputs.push(inputHydrated);
3143
3215
  }
3144
- this.markDirty();
3145
- return this;
3146
3216
  }
3147
- replaceValues(pattern, opts, callback) {
3148
- if (!callback) {
3149
- callback = opts;
3150
- opts = {};
3217
+ if (defaults.nodes) {
3218
+ defaults.nodes = json.nodes.map((n) => fromJSON$2(n, inputs));
3219
+ }
3220
+ if (defaults.source) {
3221
+ let { inputId, ...source } = defaults.source;
3222
+ defaults.source = source;
3223
+ if (inputId != null) {
3224
+ defaults.source.input = inputs[inputId];
3151
3225
  }
3152
- this.walkDecls((decl) => {
3153
- if (opts.props && !opts.props.includes(decl.prop)) return;
3154
- if (opts.fast && !decl.value.includes(opts.fast)) return;
3155
- decl.value = decl.value.replace(pattern, callback);
3156
- });
3157
- this.markDirty();
3158
- return this;
3159
3226
  }
3160
- some(condition) {
3161
- return this.nodes.some(condition);
3227
+ if (defaults.type === "root") {
3228
+ return new Root$5(defaults);
3229
+ } else if (defaults.type === "decl") {
3230
+ return new Declaration$3(defaults);
3231
+ } else if (defaults.type === "rule") {
3232
+ return new Rule$3(defaults);
3233
+ } else if (defaults.type === "comment") {
3234
+ return new Comment$4(defaults);
3235
+ } else if (defaults.type === "atrule") {
3236
+ return new AtRule$3(defaults);
3237
+ } else {
3238
+ throw new Error("Unknown node type: " + json.type);
3162
3239
  }
3163
- walk(callback) {
3164
- return this.each((child, i) => {
3165
- let result2;
3166
- try {
3167
- result2 = callback(child, i);
3168
- } catch (e) {
3169
- throw child.addToError(e);
3170
- }
3171
- if (result2 !== false && child.walk) {
3172
- result2 = child.walk(callback);
3240
+ }
3241
+ var fromJSON_1 = fromJSON$2;
3242
+ fromJSON$2.default = fromJSON$2;
3243
+ let { dirname, relative, resolve, sep } = require$$2;
3244
+ let { SourceMapConsumer, SourceMapGenerator } = require$$2;
3245
+ let { pathToFileURL } = require$$2;
3246
+ let Input$4 = input;
3247
+ let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
3248
+ let pathAvailable = Boolean(dirname && resolve && relative && sep);
3249
+ let MapGenerator$2 = class MapGenerator {
3250
+ constructor(stringify2, root2, opts, cssString) {
3251
+ this.stringify = stringify2;
3252
+ this.mapOpts = opts.map || {};
3253
+ this.root = root2;
3254
+ this.opts = opts;
3255
+ this.css = cssString;
3256
+ this.originalCSS = cssString;
3257
+ this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
3258
+ this.memoizedFileURLs = /* @__PURE__ */ new Map();
3259
+ this.memoizedPaths = /* @__PURE__ */ new Map();
3260
+ this.memoizedURLs = /* @__PURE__ */ new Map();
3261
+ }
3262
+ addAnnotation() {
3263
+ let content;
3264
+ if (this.isInline()) {
3265
+ content = "data:application/json;base64," + this.toBase64(this.map.toString());
3266
+ } else if (typeof this.mapOpts.annotation === "string") {
3267
+ content = this.mapOpts.annotation;
3268
+ } else if (typeof this.mapOpts.annotation === "function") {
3269
+ content = this.mapOpts.annotation(this.opts.to, this.root);
3270
+ } else {
3271
+ content = this.outputFile() + ".map";
3272
+ }
3273
+ let eol = "\n";
3274
+ if (this.css.includes("\r\n")) eol = "\r\n";
3275
+ this.css += eol + "/*# sourceMappingURL=" + content + " */";
3276
+ }
3277
+ applyPrevMaps() {
3278
+ for (let prev of this.previous()) {
3279
+ let from = this.toUrl(this.path(prev.file));
3280
+ let root2 = prev.root || dirname(prev.file);
3281
+ let map;
3282
+ if (this.mapOpts.sourcesContent === false) {
3283
+ map = new SourceMapConsumer(prev.text);
3284
+ if (map.sourcesContent) {
3285
+ map.sourcesContent = null;
3286
+ }
3287
+ } else {
3288
+ map = prev.consumer();
3173
3289
  }
3174
- return result2;
3175
- });
3290
+ this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
3291
+ }
3176
3292
  }
3177
- walkAtRules(name, callback) {
3178
- if (!callback) {
3179
- callback = name;
3180
- return this.walk((child, i) => {
3181
- if (child.type === "atrule") {
3182
- return callback(child, i);
3293
+ clearAnnotation() {
3294
+ if (this.mapOpts.annotation === false) return;
3295
+ if (this.root) {
3296
+ let node2;
3297
+ for (let i = this.root.nodes.length - 1; i >= 0; i--) {
3298
+ node2 = this.root.nodes[i];
3299
+ if (node2.type !== "comment") continue;
3300
+ if (node2.text.startsWith("# sourceMappingURL=")) {
3301
+ this.root.removeChild(i);
3183
3302
  }
3184
- });
3303
+ }
3304
+ } else if (this.css) {
3305
+ this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, "");
3185
3306
  }
3186
- if (name instanceof RegExp) {
3187
- return this.walk((child, i) => {
3188
- if (child.type === "atrule" && name.test(child.name)) {
3189
- return callback(child, i);
3190
- }
3307
+ }
3308
+ generate() {
3309
+ this.clearAnnotation();
3310
+ if (pathAvailable && sourceMapAvailable && this.isMap()) {
3311
+ return this.generateMap();
3312
+ } else {
3313
+ let result2 = "";
3314
+ this.stringify(this.root, (i) => {
3315
+ result2 += i;
3191
3316
  });
3317
+ return [result2];
3192
3318
  }
3193
- return this.walk((child, i) => {
3194
- if (child.type === "atrule" && child.name === name) {
3195
- return callback(child, i);
3196
- }
3197
- });
3198
- }
3199
- walkComments(callback) {
3200
- return this.walk((child, i) => {
3201
- if (child.type === "comment") {
3202
- return callback(child, i);
3203
- }
3204
- });
3205
3319
  }
3206
- walkDecls(prop, callback) {
3207
- if (!callback) {
3208
- callback = prop;
3209
- return this.walk((child, i) => {
3210
- if (child.type === "decl") {
3211
- return callback(child, i);
3212
- }
3320
+ generateMap() {
3321
+ if (this.root) {
3322
+ this.generateString();
3323
+ } else if (this.previous().length === 1) {
3324
+ let prev = this.previous()[0].consumer();
3325
+ prev.file = this.outputFile();
3326
+ this.map = SourceMapGenerator.fromSourceMap(prev, {
3327
+ ignoreInvalidMapping: true
3213
3328
  });
3214
- }
3215
- if (prop instanceof RegExp) {
3216
- return this.walk((child, i) => {
3217
- if (child.type === "decl" && prop.test(child.prop)) {
3218
- return callback(child, i);
3219
- }
3329
+ } else {
3330
+ this.map = new SourceMapGenerator({
3331
+ file: this.outputFile(),
3332
+ ignoreInvalidMapping: true
3333
+ });
3334
+ this.map.addMapping({
3335
+ generated: { column: 0, line: 1 },
3336
+ original: { column: 0, line: 1 },
3337
+ source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
3220
3338
  });
3221
3339
  }
3222
- return this.walk((child, i) => {
3223
- if (child.type === "decl" && child.prop === prop) {
3224
- return callback(child, i);
3225
- }
3226
- });
3340
+ if (this.isSourcesContent()) this.setSourcesContent();
3341
+ if (this.root && this.previous().length > 0) this.applyPrevMaps();
3342
+ if (this.isAnnotation()) this.addAnnotation();
3343
+ if (this.isInline()) {
3344
+ return [this.css];
3345
+ } else {
3346
+ return [this.css, this.map];
3347
+ }
3227
3348
  }
3228
- walkRules(selector, callback) {
3229
- if (!callback) {
3230
- callback = selector;
3231
- return this.walk((child, i) => {
3232
- if (child.type === "rule") {
3233
- return callback(child, i);
3349
+ generateString() {
3350
+ this.css = "";
3351
+ this.map = new SourceMapGenerator({
3352
+ file: this.outputFile(),
3353
+ ignoreInvalidMapping: true
3354
+ });
3355
+ let line = 1;
3356
+ let column = 1;
3357
+ let noSource = "<no source>";
3358
+ let mapping = {
3359
+ generated: { column: 0, line: 0 },
3360
+ original: { column: 0, line: 0 },
3361
+ source: ""
3362
+ };
3363
+ let last, lines;
3364
+ this.stringify(this.root, (str, node2, type) => {
3365
+ this.css += str;
3366
+ if (node2 && type !== "end") {
3367
+ mapping.generated.line = line;
3368
+ mapping.generated.column = column - 1;
3369
+ if (node2.source && node2.source.start) {
3370
+ mapping.source = this.sourcePath(node2);
3371
+ mapping.original.line = node2.source.start.line;
3372
+ mapping.original.column = node2.source.start.column - 1;
3373
+ this.map.addMapping(mapping);
3374
+ } else {
3375
+ mapping.source = noSource;
3376
+ mapping.original.line = 1;
3377
+ mapping.original.column = 0;
3378
+ this.map.addMapping(mapping);
3234
3379
  }
3235
- });
3236
- }
3237
- if (selector instanceof RegExp) {
3238
- return this.walk((child, i) => {
3239
- if (child.type === "rule" && selector.test(child.selector)) {
3240
- return callback(child, i);
3380
+ }
3381
+ lines = str.match(/\n/g);
3382
+ if (lines) {
3383
+ line += lines.length;
3384
+ last = str.lastIndexOf("\n");
3385
+ column = str.length - last;
3386
+ } else {
3387
+ column += str.length;
3388
+ }
3389
+ if (node2 && type !== "start") {
3390
+ let p = node2.parent || { raws: {} };
3391
+ let childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
3392
+ if (!childless || node2 !== p.last || p.raws.semicolon) {
3393
+ if (node2.source && node2.source.end) {
3394
+ mapping.source = this.sourcePath(node2);
3395
+ mapping.original.line = node2.source.end.line;
3396
+ mapping.original.column = node2.source.end.column - 1;
3397
+ mapping.generated.line = line;
3398
+ mapping.generated.column = column - 2;
3399
+ this.map.addMapping(mapping);
3400
+ } else {
3401
+ mapping.source = noSource;
3402
+ mapping.original.line = 1;
3403
+ mapping.original.column = 0;
3404
+ mapping.generated.line = line;
3405
+ mapping.generated.column = column - 1;
3406
+ this.map.addMapping(mapping);
3407
+ }
3241
3408
  }
3242
- });
3243
- }
3244
- return this.walk((child, i) => {
3245
- if (child.type === "rule" && child.selector === selector) {
3246
- return callback(child, i);
3247
3409
  }
3248
3410
  });
3249
3411
  }
3250
- get first() {
3251
- if (!this.proxyOf.nodes) return void 0;
3252
- return this.proxyOf.nodes[0];
3253
- }
3254
- get last() {
3255
- if (!this.proxyOf.nodes) return void 0;
3256
- return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
3257
- }
3258
- };
3259
- Container$7.registerParse = (dependant) => {
3260
- parse$4 = dependant;
3261
- };
3262
- Container$7.registerRule = (dependant) => {
3263
- Rule$4 = dependant;
3264
- };
3265
- Container$7.registerAtRule = (dependant) => {
3266
- AtRule$4 = dependant;
3267
- };
3268
- Container$7.registerRoot = (dependant) => {
3269
- Root$6 = dependant;
3270
- };
3271
- var container = Container$7;
3272
- Container$7.default = Container$7;
3273
- Container$7.rebuild = (node2) => {
3274
- if (node2.type === "atrule") {
3275
- Object.setPrototypeOf(node2, AtRule$4.prototype);
3276
- } else if (node2.type === "rule") {
3277
- Object.setPrototypeOf(node2, Rule$4.prototype);
3278
- } else if (node2.type === "decl") {
3279
- Object.setPrototypeOf(node2, Declaration$3.prototype);
3280
- } else if (node2.type === "comment") {
3281
- Object.setPrototypeOf(node2, Comment$3.prototype);
3282
- } else if (node2.type === "root") {
3283
- Object.setPrototypeOf(node2, Root$6.prototype);
3284
- }
3285
- node2[my$1] = true;
3286
- if (node2.nodes) {
3287
- node2.nodes.forEach((child) => {
3288
- Container$7.rebuild(child);
3289
- });
3290
- }
3291
- };
3292
- let Container$6 = container;
3293
- let LazyResult$4, Processor$3;
3294
- let Document$3 = class Document extends Container$6 {
3295
- constructor(defaults) {
3296
- super({ type: "document", ...defaults });
3297
- if (!this.nodes) {
3298
- this.nodes = [];
3412
+ isAnnotation() {
3413
+ if (this.isInline()) {
3414
+ return true;
3415
+ }
3416
+ if (typeof this.mapOpts.annotation !== "undefined") {
3417
+ return this.mapOpts.annotation;
3418
+ }
3419
+ if (this.previous().length) {
3420
+ return this.previous().some((i) => i.annotation);
3299
3421
  }
3422
+ return true;
3300
3423
  }
3301
- toResult(opts = {}) {
3302
- let lazy = new LazyResult$4(new Processor$3(), this, opts);
3303
- return lazy.stringify();
3424
+ isInline() {
3425
+ if (typeof this.mapOpts.inline !== "undefined") {
3426
+ return this.mapOpts.inline;
3427
+ }
3428
+ let annotation = this.mapOpts.annotation;
3429
+ if (typeof annotation !== "undefined" && annotation !== true) {
3430
+ return false;
3431
+ }
3432
+ if (this.previous().length) {
3433
+ return this.previous().some((i) => i.inline);
3434
+ }
3435
+ return true;
3304
3436
  }
3305
- };
3306
- Document$3.registerLazyResult = (dependant) => {
3307
- LazyResult$4 = dependant;
3308
- };
3309
- Document$3.registerProcessor = (dependant) => {
3310
- Processor$3 = dependant;
3311
- };
3312
- var document$1 = Document$3;
3313
- Document$3.default = Document$3;
3314
- let printed = {};
3315
- var warnOnce$2 = function warnOnce(message) {
3316
- if (printed[message]) return;
3317
- printed[message] = true;
3318
- if (typeof console !== "undefined" && console.warn) {
3319
- console.warn(message);
3437
+ isMap() {
3438
+ if (typeof this.opts.map !== "undefined") {
3439
+ return !!this.opts.map;
3440
+ }
3441
+ return this.previous().length > 0;
3320
3442
  }
3321
- };
3322
- let Warning$2 = class Warning {
3323
- constructor(text, opts = {}) {
3324
- this.type = "warning";
3325
- this.text = text;
3326
- if (opts.node && opts.node.source) {
3327
- let range = opts.node.rangeBy(opts);
3328
- this.line = range.start.line;
3329
- this.column = range.start.column;
3330
- this.endLine = range.end.line;
3331
- this.endColumn = range.end.column;
3443
+ isSourcesContent() {
3444
+ if (typeof this.mapOpts.sourcesContent !== "undefined") {
3445
+ return this.mapOpts.sourcesContent;
3446
+ }
3447
+ if (this.previous().length) {
3448
+ return this.previous().some((i) => i.withContent());
3449
+ }
3450
+ return true;
3451
+ }
3452
+ outputFile() {
3453
+ if (this.opts.to) {
3454
+ return this.path(this.opts.to);
3455
+ } else if (this.opts.from) {
3456
+ return this.path(this.opts.from);
3457
+ } else {
3458
+ return "to.css";
3332
3459
  }
3333
- for (let opt in opts) this[opt] = opts[opt];
3334
3460
  }
3335
- toString() {
3336
- if (this.node) {
3337
- return this.node.error(this.text, {
3338
- index: this.index,
3339
- plugin: this.plugin,
3340
- word: this.word
3341
- }).message;
3461
+ path(file) {
3462
+ if (this.mapOpts.absolute) return file;
3463
+ if (file.charCodeAt(0) === 60) return file;
3464
+ if (/^\w+:\/\//.test(file)) return file;
3465
+ let cached = this.memoizedPaths.get(file);
3466
+ if (cached) return cached;
3467
+ let from = this.opts.to ? dirname(this.opts.to) : ".";
3468
+ if (typeof this.mapOpts.annotation === "string") {
3469
+ from = dirname(resolve(from, this.mapOpts.annotation));
3342
3470
  }
3343
- if (this.plugin) {
3344
- return this.plugin + ": " + this.text;
3471
+ let path = relative(from, file);
3472
+ this.memoizedPaths.set(file, path);
3473
+ return path;
3474
+ }
3475
+ previous() {
3476
+ if (!this.previousMaps) {
3477
+ this.previousMaps = [];
3478
+ if (this.root) {
3479
+ this.root.walk((node2) => {
3480
+ if (node2.source && node2.source.input.map) {
3481
+ let map = node2.source.input.map;
3482
+ if (!this.previousMaps.includes(map)) {
3483
+ this.previousMaps.push(map);
3484
+ }
3485
+ }
3486
+ });
3487
+ } else {
3488
+ let input2 = new Input$4(this.originalCSS, this.opts);
3489
+ if (input2.map) this.previousMaps.push(input2.map);
3490
+ }
3345
3491
  }
3346
- return this.text;
3492
+ return this.previousMaps;
3347
3493
  }
3348
- };
3349
- var warning = Warning$2;
3350
- Warning$2.default = Warning$2;
3351
- let Warning$1 = warning;
3352
- let Result$3 = class Result {
3353
- constructor(processor2, root2, opts) {
3354
- this.processor = processor2;
3355
- this.messages = [];
3356
- this.root = root2;
3357
- this.opts = opts;
3358
- this.css = void 0;
3359
- this.map = void 0;
3494
+ setSourcesContent() {
3495
+ let already = {};
3496
+ if (this.root) {
3497
+ this.root.walk((node2) => {
3498
+ if (node2.source) {
3499
+ let from = node2.source.input.from;
3500
+ if (from && !already[from]) {
3501
+ already[from] = true;
3502
+ let fromUrl = this.usesFileUrls ? this.toFileUrl(from) : this.toUrl(this.path(from));
3503
+ this.map.setSourceContent(fromUrl, node2.source.input.css);
3504
+ }
3505
+ }
3506
+ });
3507
+ } else if (this.css) {
3508
+ let from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
3509
+ this.map.setSourceContent(from, this.css);
3510
+ }
3360
3511
  }
3361
- toString() {
3362
- return this.css;
3512
+ sourcePath(node2) {
3513
+ if (this.mapOpts.from) {
3514
+ return this.toUrl(this.mapOpts.from);
3515
+ } else if (this.usesFileUrls) {
3516
+ return this.toFileUrl(node2.source.input.from);
3517
+ } else {
3518
+ return this.toUrl(this.path(node2.source.input.from));
3519
+ }
3363
3520
  }
3364
- warn(text, opts = {}) {
3365
- if (!opts.plugin) {
3366
- if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
3367
- opts.plugin = this.lastPlugin.postcssPlugin;
3368
- }
3521
+ toBase64(str) {
3522
+ if (Buffer) {
3523
+ return Buffer.from(str).toString("base64");
3524
+ } else {
3525
+ return window.btoa(unescape(encodeURIComponent(str)));
3369
3526
  }
3370
- let warning2 = new Warning$1(text, opts);
3371
- this.messages.push(warning2);
3372
- return warning2;
3373
3527
  }
3374
- warnings() {
3375
- return this.messages.filter((i) => i.type === "warning");
3528
+ toFileUrl(path) {
3529
+ let cached = this.memoizedFileURLs.get(path);
3530
+ if (cached) return cached;
3531
+ if (pathToFileURL) {
3532
+ let fileURL = pathToFileURL(path).toString();
3533
+ this.memoizedFileURLs.set(path, fileURL);
3534
+ return fileURL;
3535
+ } else {
3536
+ throw new Error(
3537
+ "`map.absolute` option is not available in this PostCSS build"
3538
+ );
3539
+ }
3376
3540
  }
3377
- get content() {
3378
- return this.css;
3541
+ toUrl(path) {
3542
+ let cached = this.memoizedURLs.get(path);
3543
+ if (cached) return cached;
3544
+ if (sep === "\\") {
3545
+ path = path.replace(/\\/g, "/");
3546
+ }
3547
+ let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
3548
+ this.memoizedURLs.set(path, url);
3549
+ return url;
3379
3550
  }
3380
3551
  };
3381
- var result = Result$3;
3382
- Result$3.default = Result$3;
3552
+ var mapGenerator = MapGenerator$2;
3383
3553
  const SINGLE_QUOTE = "'".charCodeAt(0);
3384
3554
  const DOUBLE_QUOTE = '"'.charCodeAt(0);
3385
3555
  const BACKSLASH = "\\".charCodeAt(0);
@@ -3406,8 +3576,8 @@ const RE_HEX_ESCAPE = /[\da-f]/i;
3406
3576
  var tokenize = function tokenizer(input2, options = {}) {
3407
3577
  let css = input2.css.valueOf();
3408
3578
  let ignore = options.ignoreErrors;
3409
- let code, next, quote, content, escape;
3410
- let escaped, escapePos, prev, n, currentToken;
3579
+ let code, content, escape, next, quote;
3580
+ let currentToken, escaped, escapePos, n, prev;
3411
3581
  let length = css.length;
3412
3582
  let pos = 0;
3413
3583
  let buffer = [];
@@ -3527,206 +3697,73 @@ var tokenize = function tokenizer(input2, options = {}) {
3527
3697
  }
3528
3698
  case BACKSLASH: {
3529
3699
  next = pos;
3530
- escape = true;
3531
- while (css.charCodeAt(next + 1) === BACKSLASH) {
3532
- next += 1;
3533
- escape = !escape;
3534
- }
3535
- code = css.charCodeAt(next + 1);
3536
- if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
3537
- next += 1;
3538
- if (RE_HEX_ESCAPE.test(css.charAt(next))) {
3539
- while (RE_HEX_ESCAPE.test(css.charAt(next + 1))) {
3540
- next += 1;
3541
- }
3542
- if (css.charCodeAt(next + 1) === SPACE) {
3543
- next += 1;
3544
- }
3545
- }
3546
- }
3547
- currentToken = ["word", css.slice(pos, next + 1), pos, next];
3548
- pos = next;
3549
- break;
3550
- }
3551
- default: {
3552
- if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
3553
- next = css.indexOf("*/", pos + 2) + 1;
3554
- if (next === 0) {
3555
- if (ignore || ignoreUnclosed) {
3556
- next = css.length;
3557
- } else {
3558
- unclosed("comment");
3559
- }
3560
- }
3561
- currentToken = ["comment", css.slice(pos, next + 1), pos, next];
3562
- pos = next;
3563
- } else {
3564
- RE_WORD_END.lastIndex = pos + 1;
3565
- RE_WORD_END.test(css);
3566
- if (RE_WORD_END.lastIndex === 0) {
3567
- next = css.length - 1;
3568
- } else {
3569
- next = RE_WORD_END.lastIndex - 2;
3570
- }
3571
- currentToken = ["word", css.slice(pos, next + 1), pos, next];
3572
- buffer.push(currentToken);
3573
- pos = next;
3574
- }
3575
- break;
3576
- }
3577
- }
3578
- pos++;
3579
- return currentToken;
3580
- }
3581
- function back(token) {
3582
- returned.push(token);
3583
- }
3584
- return {
3585
- back,
3586
- endOfFile,
3587
- nextToken,
3588
- position
3589
- };
3590
- };
3591
- let Container$5 = container;
3592
- let AtRule$3 = class AtRule extends Container$5 {
3593
- constructor(defaults) {
3594
- super(defaults);
3595
- this.type = "atrule";
3596
- }
3597
- append(...children) {
3598
- if (!this.proxyOf.nodes) this.nodes = [];
3599
- return super.append(...children);
3600
- }
3601
- prepend(...children) {
3602
- if (!this.proxyOf.nodes) this.nodes = [];
3603
- return super.prepend(...children);
3604
- }
3605
- };
3606
- var atRule = AtRule$3;
3607
- AtRule$3.default = AtRule$3;
3608
- Container$5.registerAtRule(AtRule$3);
3609
- let Container$4 = container;
3610
- let LazyResult$3, Processor$2;
3611
- let Root$5 = class Root extends Container$4 {
3612
- constructor(defaults) {
3613
- super(defaults);
3614
- this.type = "root";
3615
- if (!this.nodes) this.nodes = [];
3616
- }
3617
- normalize(child, sample, type) {
3618
- let nodes = super.normalize(child);
3619
- if (sample) {
3620
- if (type === "prepend") {
3621
- if (this.nodes.length > 1) {
3622
- sample.raws.before = this.nodes[1].raws.before;
3623
- } else {
3624
- delete sample.raws.before;
3625
- }
3626
- } else if (this.first !== sample) {
3627
- for (let node2 of nodes) {
3628
- node2.raws.before = sample.raws.before;
3629
- }
3630
- }
3631
- }
3632
- return nodes;
3633
- }
3634
- removeChild(child, ignore) {
3635
- let index2 = this.index(child);
3636
- if (!ignore && index2 === 0 && this.nodes.length > 1) {
3637
- this.nodes[1].raws.before = this.nodes[index2].raws.before;
3638
- }
3639
- return super.removeChild(child);
3640
- }
3641
- toResult(opts = {}) {
3642
- let lazy = new LazyResult$3(new Processor$2(), this, opts);
3643
- return lazy.stringify();
3644
- }
3645
- };
3646
- Root$5.registerLazyResult = (dependant) => {
3647
- LazyResult$3 = dependant;
3648
- };
3649
- Root$5.registerProcessor = (dependant) => {
3650
- Processor$2 = dependant;
3651
- };
3652
- var root = Root$5;
3653
- Root$5.default = Root$5;
3654
- Container$4.registerRoot(Root$5);
3655
- let list$2 = {
3656
- comma(string) {
3657
- return list$2.split(string, [","], true);
3658
- },
3659
- space(string) {
3660
- let spaces = [" ", "\n", " "];
3661
- return list$2.split(string, spaces);
3662
- },
3663
- split(string, separators, last) {
3664
- let array = [];
3665
- let current = "";
3666
- let split = false;
3667
- let func = 0;
3668
- let inQuote = false;
3669
- let prevQuote = "";
3670
- let escape = false;
3671
- for (let letter of string) {
3672
- if (escape) {
3673
- escape = false;
3674
- } else if (letter === "\\") {
3675
- escape = true;
3676
- } else if (inQuote) {
3677
- if (letter === prevQuote) {
3678
- inQuote = false;
3700
+ escape = true;
3701
+ while (css.charCodeAt(next + 1) === BACKSLASH) {
3702
+ next += 1;
3703
+ escape = !escape;
3679
3704
  }
3680
- } else if (letter === '"' || letter === "'") {
3681
- inQuote = true;
3682
- prevQuote = letter;
3683
- } else if (letter === "(") {
3684
- func += 1;
3685
- } else if (letter === ")") {
3686
- if (func > 0) func -= 1;
3687
- } else if (func === 0) {
3688
- if (separators.includes(letter)) split = true;
3705
+ code = css.charCodeAt(next + 1);
3706
+ if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
3707
+ next += 1;
3708
+ if (RE_HEX_ESCAPE.test(css.charAt(next))) {
3709
+ while (RE_HEX_ESCAPE.test(css.charAt(next + 1))) {
3710
+ next += 1;
3711
+ }
3712
+ if (css.charCodeAt(next + 1) === SPACE) {
3713
+ next += 1;
3714
+ }
3715
+ }
3716
+ }
3717
+ currentToken = ["word", css.slice(pos, next + 1), pos, next];
3718
+ pos = next;
3719
+ break;
3689
3720
  }
3690
- if (split) {
3691
- if (current !== "") array.push(current.trim());
3692
- current = "";
3693
- split = false;
3694
- } else {
3695
- current += letter;
3721
+ default: {
3722
+ if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
3723
+ next = css.indexOf("*/", pos + 2) + 1;
3724
+ if (next === 0) {
3725
+ if (ignore || ignoreUnclosed) {
3726
+ next = css.length;
3727
+ } else {
3728
+ unclosed("comment");
3729
+ }
3730
+ }
3731
+ currentToken = ["comment", css.slice(pos, next + 1), pos, next];
3732
+ pos = next;
3733
+ } else {
3734
+ RE_WORD_END.lastIndex = pos + 1;
3735
+ RE_WORD_END.test(css);
3736
+ if (RE_WORD_END.lastIndex === 0) {
3737
+ next = css.length - 1;
3738
+ } else {
3739
+ next = RE_WORD_END.lastIndex - 2;
3740
+ }
3741
+ currentToken = ["word", css.slice(pos, next + 1), pos, next];
3742
+ buffer.push(currentToken);
3743
+ pos = next;
3744
+ }
3745
+ break;
3696
3746
  }
3697
3747
  }
3698
- if (last || current !== "") array.push(current.trim());
3699
- return array;
3700
- }
3701
- };
3702
- var list_1 = list$2;
3703
- list$2.default = list$2;
3704
- let Container$3 = container;
3705
- let list$1 = list_1;
3706
- let Rule$3 = class Rule extends Container$3 {
3707
- constructor(defaults) {
3708
- super(defaults);
3709
- this.type = "rule";
3710
- if (!this.nodes) this.nodes = [];
3711
- }
3712
- get selectors() {
3713
- return list$1.comma(this.selector);
3748
+ pos++;
3749
+ return currentToken;
3714
3750
  }
3715
- set selectors(values) {
3716
- let match = this.selector ? this.selector.match(/,\s*/) : null;
3717
- let sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
3718
- this.selector = values.join(sep2);
3751
+ function back(token) {
3752
+ returned.push(token);
3719
3753
  }
3754
+ return {
3755
+ back,
3756
+ endOfFile,
3757
+ nextToken,
3758
+ position
3759
+ };
3720
3760
  };
3721
- var rule = Rule$3;
3722
- Rule$3.default = Rule$3;
3723
- Container$3.registerRule(Rule$3);
3761
+ let AtRule$2 = atRule$1;
3762
+ let Comment$3 = comment$1;
3724
3763
  let Declaration$2 = declaration;
3725
- let tokenizer2 = tokenize;
3726
- let Comment$2 = comment;
3727
- let AtRule$2 = atRule;
3728
- let Root$4 = root;
3729
- let Rule$2 = rule;
3764
+ let Root$4 = root$1;
3765
+ let Rule$2 = rule$1;
3766
+ let tokenizer$1 = tokenize;
3730
3767
  const SAFE_COMMENT_NEIGHBOR = {
3731
3768
  empty: true,
3732
3769
  space: true
@@ -3738,7 +3775,7 @@ function findLastWithPosition(tokens) {
3738
3775
  if (pos) return pos;
3739
3776
  }
3740
3777
  }
3741
- let Parser$1 = class Parser {
3778
+ let Parser$2 = class Parser {
3742
3779
  constructor(input2) {
3743
3780
  this.input = input2;
3744
3781
  this.root = new Root$4();
@@ -3845,7 +3882,7 @@ let Parser$1 = class Parser {
3845
3882
  }
3846
3883
  colon(tokens) {
3847
3884
  let brackets = 0;
3848
- let token, type, prev;
3885
+ let prev, token, type;
3849
3886
  for (let [i, element] of tokens.entries()) {
3850
3887
  token = element;
3851
3888
  type = token[0];
@@ -3869,7 +3906,7 @@ let Parser$1 = class Parser {
3869
3906
  return false;
3870
3907
  }
3871
3908
  comment(token) {
3872
- let node2 = new Comment$2();
3909
+ let node2 = new Comment$3();
3873
3910
  this.init(node2, token[2]);
3874
3911
  node2.source.end = this.getPosition(token[3] || token[2]);
3875
3912
  node2.source.end.offset++;
@@ -3886,7 +3923,7 @@ let Parser$1 = class Parser {
3886
3923
  }
3887
3924
  }
3888
3925
  createTokenizer() {
3889
- this.tokenizer = tokenizer2(this.input);
3926
+ this.tokenizer = tokenizer$1(this.input);
3890
3927
  }
3891
3928
  decl(tokens, customProperty) {
3892
3929
  let node2 = new Declaration$2();
@@ -3952,12 +3989,12 @@ let Parser$1 = class Parser {
3952
3989
  let str = "";
3953
3990
  for (let j = i; j > 0; j--) {
3954
3991
  let type = cache[j][0];
3955
- if (str.trim().indexOf("!") === 0 && type !== "space") {
3992
+ if (str.trim().startsWith("!") && type !== "space") {
3956
3993
  break;
3957
3994
  }
3958
3995
  str = cache.pop()[1] + str;
3959
3996
  }
3960
- if (str.trim().indexOf("!") === 0) {
3997
+ if (str.trim().startsWith("!")) {
3961
3998
  node2.important = true;
3962
3999
  node2.raws.important = str;
3963
4000
  tokens = cache;
@@ -4245,13 +4282,13 @@ let Parser$1 = class Parser {
4245
4282
  );
4246
4283
  }
4247
4284
  };
4248
- var parser = Parser$1;
4249
- let Container$2 = container;
4250
- let Parser2 = parser;
4251
- let Input$2 = input;
4252
- function parse$3(css, opts) {
4253
- let input2 = new Input$2(css, opts);
4254
- let parser2 = new Parser2(input2);
4285
+ var parser = Parser$2;
4286
+ let Container$3 = container;
4287
+ let Input$3 = input;
4288
+ let Parser$1 = parser;
4289
+ function parse$4(css, opts) {
4290
+ let input2 = new Input$3(css, opts);
4291
+ let parser2 = new Parser$1(input2);
4255
4292
  try {
4256
4293
  parser2.parse();
4257
4294
  } catch (e) {
@@ -4270,18 +4307,87 @@ function parse$3(css, opts) {
4270
4307
  }
4271
4308
  return parser2.root;
4272
4309
  }
4273
- var parse_1 = parse$3;
4274
- parse$3.default = parse$3;
4275
- Container$2.registerParse(parse$3);
4276
- let { isClean, my } = symbols;
4310
+ var parse_1 = parse$4;
4311
+ parse$4.default = parse$4;
4312
+ Container$3.registerParse(parse$4);
4313
+ let Warning$3 = class Warning {
4314
+ constructor(text, opts = {}) {
4315
+ this.type = "warning";
4316
+ this.text = text;
4317
+ if (opts.node && opts.node.source) {
4318
+ let range = opts.node.rangeBy(opts);
4319
+ this.line = range.start.line;
4320
+ this.column = range.start.column;
4321
+ this.endLine = range.end.line;
4322
+ this.endColumn = range.end.column;
4323
+ }
4324
+ for (let opt in opts) this[opt] = opts[opt];
4325
+ }
4326
+ toString() {
4327
+ if (this.node) {
4328
+ return this.node.error(this.text, {
4329
+ index: this.index,
4330
+ plugin: this.plugin,
4331
+ word: this.word
4332
+ }).message;
4333
+ }
4334
+ if (this.plugin) {
4335
+ return this.plugin + ": " + this.text;
4336
+ }
4337
+ return this.text;
4338
+ }
4339
+ };
4340
+ var warning = Warning$3;
4341
+ Warning$3.default = Warning$3;
4342
+ let Warning$2 = warning;
4343
+ let Result$4 = class Result {
4344
+ constructor(processor2, root2, opts) {
4345
+ this.processor = processor2;
4346
+ this.messages = [];
4347
+ this.root = root2;
4348
+ this.opts = opts;
4349
+ this.css = void 0;
4350
+ this.map = void 0;
4351
+ }
4352
+ toString() {
4353
+ return this.css;
4354
+ }
4355
+ warn(text, opts = {}) {
4356
+ if (!opts.plugin) {
4357
+ if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
4358
+ opts.plugin = this.lastPlugin.postcssPlugin;
4359
+ }
4360
+ }
4361
+ let warning2 = new Warning$2(text, opts);
4362
+ this.messages.push(warning2);
4363
+ return warning2;
4364
+ }
4365
+ warnings() {
4366
+ return this.messages.filter((i) => i.type === "warning");
4367
+ }
4368
+ get content() {
4369
+ return this.css;
4370
+ }
4371
+ };
4372
+ var result = Result$4;
4373
+ Result$4.default = Result$4;
4374
+ let printed = {};
4375
+ var warnOnce$2 = function warnOnce(message) {
4376
+ if (printed[message]) return;
4377
+ printed[message] = true;
4378
+ if (typeof console !== "undefined" && console.warn) {
4379
+ console.warn(message);
4380
+ }
4381
+ };
4382
+ let Container$2 = container;
4383
+ let Document$3 = document$2;
4277
4384
  let MapGenerator$1 = mapGenerator;
4278
- let stringify$2 = stringify_1;
4279
- let Container$1 = container;
4280
- let Document$2 = document$1;
4385
+ let parse$3 = parse_1;
4386
+ let Result$3 = result;
4387
+ let Root$3 = root$1;
4388
+ let stringify$3 = stringify_1;
4389
+ let { isClean, my } = symbols;
4281
4390
  let warnOnce$1 = warnOnce$2;
4282
- let Result$2 = result;
4283
- let parse$2 = parse_1;
4284
- let Root$3 = root;
4285
4391
  const TYPE_TO_CLASS_NAME = {
4286
4392
  atrule: "AtRule",
4287
4393
  comment: "Comment",
@@ -4364,7 +4470,7 @@ function cleanMarks(node2) {
4364
4470
  if (node2.nodes) node2.nodes.forEach((i) => cleanMarks(i));
4365
4471
  return node2;
4366
4472
  }
4367
- let postcss$2 = {};
4473
+ let postcss$3 = {};
4368
4474
  let LazyResult$2 = class LazyResult {
4369
4475
  constructor(processor2, css, opts) {
4370
4476
  this.stringified = false;
@@ -4372,7 +4478,7 @@ let LazyResult$2 = class LazyResult {
4372
4478
  let root2;
4373
4479
  if (typeof css === "object" && css !== null && (css.type === "root" || css.type === "document")) {
4374
4480
  root2 = cleanMarks(css);
4375
- } else if (css instanceof LazyResult || css instanceof Result$2) {
4481
+ } else if (css instanceof LazyResult || css instanceof Result$3) {
4376
4482
  root2 = cleanMarks(css.root);
4377
4483
  if (css.map) {
4378
4484
  if (typeof opts.map === "undefined") opts.map = {};
@@ -4380,7 +4486,7 @@ let LazyResult$2 = class LazyResult {
4380
4486
  opts.map.prev = css.map;
4381
4487
  }
4382
4488
  } else {
4383
- let parser2 = parse$2;
4489
+ let parser2 = parse$3;
4384
4490
  if (opts.syntax) parser2 = opts.syntax.parse;
4385
4491
  if (opts.parser) parser2 = opts.parser;
4386
4492
  if (parser2.parse) parser2 = parser2.parse;
@@ -4391,16 +4497,16 @@ let LazyResult$2 = class LazyResult {
4391
4497
  this.error = error;
4392
4498
  }
4393
4499
  if (root2 && !root2[my]) {
4394
- Container$1.rebuild(root2);
4500
+ Container$2.rebuild(root2);
4395
4501
  }
4396
4502
  }
4397
- this.result = new Result$2(processor2, root2, opts);
4398
- this.helpers = { ...postcss$2, postcss: postcss$2, result: this.result };
4399
- this.plugins = this.processor.plugins.map((plugin2) => {
4400
- if (typeof plugin2 === "object" && plugin2.prepare) {
4401
- return { ...plugin2, ...plugin2.prepare(this.result) };
4503
+ this.result = new Result$3(processor2, root2, opts);
4504
+ this.helpers = { ...postcss$3, postcss: postcss$3, result: this.result };
4505
+ this.plugins = this.processor.plugins.map((plugin3) => {
4506
+ if (typeof plugin3 === "object" && plugin3.prepare) {
4507
+ return { ...plugin3, ...plugin3.prepare(this.result) };
4402
4508
  } else {
4403
- return plugin2;
4509
+ return plugin3;
4404
4510
  }
4405
4511
  });
4406
4512
  }
@@ -4422,17 +4528,17 @@ let LazyResult$2 = class LazyResult {
4422
4528
  throw new Error("Use process(css).then(cb) to work with async plugins");
4423
4529
  }
4424
4530
  handleError(error, node2) {
4425
- let plugin2 = this.result.lastPlugin;
4531
+ let plugin3 = this.result.lastPlugin;
4426
4532
  try {
4427
4533
  if (node2) node2.addToError(error);
4428
4534
  this.error = error;
4429
4535
  if (error.name === "CssSyntaxError" && !error.plugin) {
4430
- error.plugin = plugin2.postcssPlugin;
4536
+ error.plugin = plugin3.postcssPlugin;
4431
4537
  error.setMessage();
4432
- } else if (plugin2.postcssVersion) {
4538
+ } else if (plugin3.postcssVersion) {
4433
4539
  if (process.env.NODE_ENV !== "production") {
4434
- let pluginName = plugin2.postcssPlugin;
4435
- let pluginVer = plugin2.postcssVersion;
4540
+ let pluginName = plugin3.postcssPlugin;
4541
+ let pluginVer = plugin3.postcssVersion;
4436
4542
  let runtimeVer = this.result.processor.version;
4437
4543
  let a = pluginVer.split(".");
4438
4544
  let b = runtimeVer.split(".");
@@ -4450,33 +4556,33 @@ let LazyResult$2 = class LazyResult {
4450
4556
  }
4451
4557
  prepareVisitors() {
4452
4558
  this.listeners = {};
4453
- let add = (plugin2, type, cb) => {
4559
+ let add = (plugin3, type, cb) => {
4454
4560
  if (!this.listeners[type]) this.listeners[type] = [];
4455
- this.listeners[type].push([plugin2, cb]);
4561
+ this.listeners[type].push([plugin3, cb]);
4456
4562
  };
4457
- for (let plugin2 of this.plugins) {
4458
- if (typeof plugin2 === "object") {
4459
- for (let event in plugin2) {
4563
+ for (let plugin3 of this.plugins) {
4564
+ if (typeof plugin3 === "object") {
4565
+ for (let event in plugin3) {
4460
4566
  if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
4461
4567
  throw new Error(
4462
- `Unknown event ${event} in ${plugin2.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`
4568
+ `Unknown event ${event} in ${plugin3.postcssPlugin}. Try to update PostCSS (${this.processor.version} now).`
4463
4569
  );
4464
4570
  }
4465
4571
  if (!NOT_VISITORS[event]) {
4466
- if (typeof plugin2[event] === "object") {
4467
- for (let filter in plugin2[event]) {
4572
+ if (typeof plugin3[event] === "object") {
4573
+ for (let filter in plugin3[event]) {
4468
4574
  if (filter === "*") {
4469
- add(plugin2, event, plugin2[event][filter]);
4575
+ add(plugin3, event, plugin3[event][filter]);
4470
4576
  } else {
4471
4577
  add(
4472
- plugin2,
4578
+ plugin3,
4473
4579
  event + "-" + filter.toLowerCase(),
4474
- plugin2[event][filter]
4580
+ plugin3[event][filter]
4475
4581
  );
4476
4582
  }
4477
4583
  }
4478
- } else if (typeof plugin2[event] === "function") {
4479
- add(plugin2, event, plugin2[event]);
4584
+ } else if (typeof plugin3[event] === "function") {
4585
+ add(plugin3, event, plugin3[event]);
4480
4586
  }
4481
4587
  }
4482
4588
  }
@@ -4487,8 +4593,8 @@ let LazyResult$2 = class LazyResult {
4487
4593
  async runAsync() {
4488
4594
  this.plugin = 0;
4489
4595
  for (let i = 0; i < this.plugins.length; i++) {
4490
- let plugin2 = this.plugins[i];
4491
- let promise = this.runOnRoot(plugin2);
4596
+ let plugin3 = this.plugins[i];
4597
+ let promise = this.runOnRoot(plugin3);
4492
4598
  if (isPromise(promise)) {
4493
4599
  try {
4494
4600
  await promise;
@@ -4516,8 +4622,8 @@ let LazyResult$2 = class LazyResult {
4516
4622
  }
4517
4623
  }
4518
4624
  if (this.listeners.OnceExit) {
4519
- for (let [plugin2, visitor] of this.listeners.OnceExit) {
4520
- this.result.lastPlugin = plugin2;
4625
+ for (let [plugin3, visitor] of this.listeners.OnceExit) {
4626
+ this.result.lastPlugin = plugin3;
4521
4627
  try {
4522
4628
  if (root2.type === "document") {
4523
4629
  let roots = root2.nodes.map(
@@ -4536,22 +4642,22 @@ let LazyResult$2 = class LazyResult {
4536
4642
  this.processed = true;
4537
4643
  return this.stringify();
4538
4644
  }
4539
- runOnRoot(plugin2) {
4540
- this.result.lastPlugin = plugin2;
4645
+ runOnRoot(plugin3) {
4646
+ this.result.lastPlugin = plugin3;
4541
4647
  try {
4542
- if (typeof plugin2 === "object" && plugin2.Once) {
4648
+ if (typeof plugin3 === "object" && plugin3.Once) {
4543
4649
  if (this.result.root.type === "document") {
4544
4650
  let roots = this.result.root.nodes.map(
4545
- (root2) => plugin2.Once(root2, this.helpers)
4651
+ (root2) => plugin3.Once(root2, this.helpers)
4546
4652
  );
4547
4653
  if (isPromise(roots[0])) {
4548
4654
  return Promise.all(roots);
4549
4655
  }
4550
4656
  return roots;
4551
4657
  }
4552
- return plugin2.Once(this.result.root, this.helpers);
4553
- } else if (typeof plugin2 === "function") {
4554
- return plugin2(this.result.root, this.result);
4658
+ return plugin3.Once(this.result.root, this.helpers);
4659
+ } else if (typeof plugin3 === "function") {
4660
+ return plugin3(this.result.root, this.result);
4555
4661
  }
4556
4662
  } catch (error) {
4557
4663
  throw this.handleError(error);
@@ -4563,7 +4669,7 @@ let LazyResult$2 = class LazyResult {
4563
4669
  this.stringified = true;
4564
4670
  this.sync();
4565
4671
  let opts = this.result.opts;
4566
- let str = stringify$2;
4672
+ let str = stringify$3;
4567
4673
  if (opts.syntax) str = opts.syntax.stringify;
4568
4674
  if (opts.stringifier) str = opts.stringifier;
4569
4675
  if (str.stringify) str = str.stringify;
@@ -4580,8 +4686,8 @@ let LazyResult$2 = class LazyResult {
4580
4686
  if (this.processing) {
4581
4687
  throw this.getAsyncError();
4582
4688
  }
4583
- for (let plugin2 of this.plugins) {
4584
- let promise = this.runOnRoot(plugin2);
4689
+ for (let plugin3 of this.plugins) {
4690
+ let promise = this.runOnRoot(plugin3);
4585
4691
  if (isPromise(promise)) {
4586
4692
  throw this.getAsyncError();
4587
4693
  }
@@ -4619,8 +4725,8 @@ let LazyResult$2 = class LazyResult {
4619
4725
  return this.css;
4620
4726
  }
4621
4727
  visitSync(visitors, node2) {
4622
- for (let [plugin2, visitor] of visitors) {
4623
- this.result.lastPlugin = plugin2;
4728
+ for (let [plugin3, visitor] of visitors) {
4729
+ this.result.lastPlugin = plugin3;
4624
4730
  let promise;
4625
4731
  try {
4626
4732
  promise = visitor(node2, this.helpers);
@@ -4643,13 +4749,13 @@ let LazyResult$2 = class LazyResult {
4643
4749
  return;
4644
4750
  }
4645
4751
  if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
4646
- let [plugin2, visitor] = visitors[visit2.visitorIndex];
4752
+ let [plugin3, visitor] = visitors[visit2.visitorIndex];
4647
4753
  visit2.visitorIndex += 1;
4648
4754
  if (visit2.visitorIndex === visitors.length) {
4649
4755
  visit2.visitors = [];
4650
4756
  visit2.visitorIndex = 0;
4651
4757
  }
4652
- this.result.lastPlugin = plugin2;
4758
+ this.result.lastPlugin = plugin3;
4653
4759
  try {
4654
4760
  return visitor(node2.toProxy(), this.helpers);
4655
4761
  } catch (e) {
@@ -4734,17 +4840,17 @@ let LazyResult$2 = class LazyResult {
4734
4840
  }
4735
4841
  };
4736
4842
  LazyResult$2.registerPostcss = (dependant) => {
4737
- postcss$2 = dependant;
4843
+ postcss$3 = dependant;
4738
4844
  };
4739
4845
  var lazyResult = LazyResult$2;
4740
4846
  LazyResult$2.default = LazyResult$2;
4741
4847
  Root$3.registerLazyResult(LazyResult$2);
4742
- Document$2.registerLazyResult(LazyResult$2);
4848
+ Document$3.registerLazyResult(LazyResult$2);
4743
4849
  let MapGenerator2 = mapGenerator;
4744
- let stringify$1 = stringify_1;
4850
+ let parse$2 = parse_1;
4851
+ const Result$2 = result;
4852
+ let stringify$2 = stringify_1;
4745
4853
  let warnOnce2 = warnOnce$2;
4746
- let parse$1 = parse_1;
4747
- const Result$1 = result;
4748
4854
  let NoWorkResult$1 = class NoWorkResult {
4749
4855
  constructor(processor2, css, opts) {
4750
4856
  css = css.toString();
@@ -4754,8 +4860,8 @@ let NoWorkResult$1 = class NoWorkResult {
4754
4860
  this._opts = opts;
4755
4861
  this._map = void 0;
4756
4862
  let root2;
4757
- let str = stringify$1;
4758
- this.result = new Result$1(this._processor, root2, this._opts);
4863
+ let str = stringify$2;
4864
+ this.result = new Result$2(this._processor, root2, this._opts);
4759
4865
  this.result.css = css;
4760
4866
  let self = this;
4761
4867
  Object.defineProperty(this.result, "root", {
@@ -4830,7 +4936,7 @@ let NoWorkResult$1 = class NoWorkResult {
4830
4936
  return this._root;
4831
4937
  }
4832
4938
  let root2;
4833
- let parser2 = parse$1;
4939
+ let parser2 = parse$2;
4834
4940
  try {
4835
4941
  root2 = parser2(this._css, this._opts);
4836
4942
  } catch (error) {
@@ -4849,13 +4955,13 @@ let NoWorkResult$1 = class NoWorkResult {
4849
4955
  };
4850
4956
  var noWorkResult = NoWorkResult$1;
4851
4957
  NoWorkResult$1.default = NoWorkResult$1;
4852
- let NoWorkResult2 = noWorkResult;
4958
+ let Document$2 = document$2;
4853
4959
  let LazyResult$1 = lazyResult;
4854
- let Document$1 = document$1;
4855
- let Root$2 = root;
4856
- let Processor$1 = class Processor {
4960
+ let NoWorkResult2 = noWorkResult;
4961
+ let Root$2 = root$1;
4962
+ let Processor$2 = class Processor {
4857
4963
  constructor(plugins = []) {
4858
- this.version = "8.4.38";
4964
+ this.version = "8.5.1";
4859
4965
  this.plugins = this.normalize(plugins);
4860
4966
  }
4861
4967
  normalize(plugins) {
@@ -4891,89 +4997,40 @@ let Processor$1 = class Processor {
4891
4997
  return new LazyResult$1(this, css, opts);
4892
4998
  }
4893
4999
  }
4894
- use(plugin2) {
4895
- this.plugins = this.plugins.concat(this.normalize([plugin2]));
5000
+ use(plugin3) {
5001
+ this.plugins = this.plugins.concat(this.normalize([plugin3]));
4896
5002
  return this;
4897
5003
  }
4898
5004
  };
4899
- var processor = Processor$1;
4900
- Processor$1.default = Processor$1;
4901
- Root$2.registerProcessor(Processor$1);
4902
- Document$1.registerProcessor(Processor$1);
5005
+ var processor = Processor$2;
5006
+ Processor$2.default = Processor$2;
5007
+ Root$2.registerProcessor(Processor$2);
5008
+ Document$2.registerProcessor(Processor$2);
5009
+ let AtRule$1 = atRule$1;
5010
+ let Comment$2 = comment$1;
5011
+ let Container$1 = container;
5012
+ let CssSyntaxError$1 = cssSyntaxError;
4903
5013
  let Declaration$1 = declaration;
4904
- let PreviousMap2 = previousMap;
4905
- let Comment$1 = comment;
4906
- let AtRule$1 = atRule;
4907
- let Input$1 = input;
4908
- let Root$1 = root;
4909
- let Rule$1 = rule;
4910
- function fromJSON$1(json, inputs) {
4911
- if (Array.isArray(json)) return json.map((n) => fromJSON$1(n));
4912
- let { inputs: ownInputs, ...defaults } = json;
4913
- if (ownInputs) {
4914
- inputs = [];
4915
- for (let input2 of ownInputs) {
4916
- let inputHydrated = { ...input2, __proto__: Input$1.prototype };
4917
- if (inputHydrated.map) {
4918
- inputHydrated.map = {
4919
- ...inputHydrated.map,
4920
- __proto__: PreviousMap2.prototype
4921
- };
4922
- }
4923
- inputs.push(inputHydrated);
4924
- }
4925
- }
4926
- if (defaults.nodes) {
4927
- defaults.nodes = json.nodes.map((n) => fromJSON$1(n, inputs));
4928
- }
4929
- if (defaults.source) {
4930
- let { inputId, ...source } = defaults.source;
4931
- defaults.source = source;
4932
- if (inputId != null) {
4933
- defaults.source.input = inputs[inputId];
4934
- }
4935
- }
4936
- if (defaults.type === "root") {
4937
- return new Root$1(defaults);
4938
- } else if (defaults.type === "decl") {
4939
- return new Declaration$1(defaults);
4940
- } else if (defaults.type === "rule") {
4941
- return new Rule$1(defaults);
4942
- } else if (defaults.type === "comment") {
4943
- return new Comment$1(defaults);
4944
- } else if (defaults.type === "atrule") {
4945
- return new AtRule$1(defaults);
4946
- } else {
4947
- throw new Error("Unknown node type: " + json.type);
4948
- }
4949
- }
4950
- var fromJSON_1 = fromJSON$1;
4951
- fromJSON$1.default = fromJSON$1;
4952
- let CssSyntaxError2 = cssSyntaxError;
4953
- let Declaration2 = declaration;
5014
+ let Document$1 = document$2;
5015
+ let fromJSON$1 = fromJSON_1;
5016
+ let Input$2 = input;
4954
5017
  let LazyResult2 = lazyResult;
4955
- let Container2 = container;
4956
- let Processor2 = processor;
4957
- let stringify = stringify_1;
4958
- let fromJSON = fromJSON_1;
4959
- let Document2 = document$1;
4960
- let Warning2 = warning;
4961
- let Comment2 = comment;
4962
- let AtRule2 = atRule;
4963
- let Result2 = result;
4964
- let Input2 = input;
4965
- let parse = parse_1;
4966
- let list = list_1;
4967
- let Rule2 = rule;
4968
- let Root2 = root;
4969
- let Node2 = node;
4970
- function postcss(...plugins) {
5018
+ let list$1 = list_1;
5019
+ let Node$1 = node;
5020
+ let parse$1 = parse_1;
5021
+ let Processor$1 = processor;
5022
+ let Result$1 = result;
5023
+ let Root$1 = root$1;
5024
+ let Rule$1 = rule$1;
5025
+ let stringify$1 = stringify_1;
5026
+ let Warning$1 = warning;
5027
+ function postcss$1(...plugins) {
4971
5028
  if (plugins.length === 1 && Array.isArray(plugins[0])) {
4972
5029
  plugins = plugins[0];
4973
5030
  }
4974
- return new Processor2(plugins);
5031
+ return new Processor$1(plugins);
4975
5032
  }
4976
- postcss.plugin = function plugin(name, initializer) {
5033
+ postcss$1.plugin = function plugin(name, initializer) {
4977
5034
  let warningPrinted = false;
4978
5035
  function creator(...args) {
4979
5036
  if (console && console.warn && !warningPrinted) {
@@ -4989,7 +5046,7 @@ postcss.plugin = function plugin(name, initializer) {
4989
5046
  }
4990
5047
  let transformer = initializer(...args);
4991
5048
  transformer.postcssPlugin = name;
4992
- transformer.postcssVersion = new Processor2().version;
5049
+ transformer.postcssVersion = new Processor$1().version;
4993
5050
  return transformer;
4994
5051
  }
4995
5052
  let cache;
@@ -5000,61 +5057,181 @@ postcss.plugin = function plugin(name, initializer) {
5000
5057
  }
5001
5058
  });
5002
5059
  creator.process = function(css, processOpts, pluginOpts) {
5003
- return postcss([creator(pluginOpts)]).process(css, processOpts);
5060
+ return postcss$1([creator(pluginOpts)]).process(css, processOpts);
5004
5061
  };
5005
5062
  return creator;
5006
5063
  };
5007
- postcss.stringify = stringify;
5008
- postcss.parse = parse;
5009
- postcss.fromJSON = fromJSON;
5010
- postcss.list = list;
5011
- postcss.comment = (defaults) => new Comment2(defaults);
5012
- postcss.atRule = (defaults) => new AtRule2(defaults);
5013
- postcss.decl = (defaults) => new Declaration2(defaults);
5014
- postcss.rule = (defaults) => new Rule2(defaults);
5015
- postcss.root = (defaults) => new Root2(defaults);
5016
- postcss.document = (defaults) => new Document2(defaults);
5017
- postcss.CssSyntaxError = CssSyntaxError2;
5018
- postcss.Declaration = Declaration2;
5019
- postcss.Container = Container2;
5020
- postcss.Processor = Processor2;
5021
- postcss.Document = Document2;
5022
- postcss.Comment = Comment2;
5023
- postcss.Warning = Warning2;
5024
- postcss.AtRule = AtRule2;
5025
- postcss.Result = Result2;
5026
- postcss.Input = Input2;
5027
- postcss.Rule = Rule2;
5028
- postcss.Root = Root2;
5029
- postcss.Node = Node2;
5030
- LazyResult2.registerPostcss(postcss);
5031
- var postcss_1 = postcss;
5032
- postcss.default = postcss;
5033
- const postcss$1 = /* @__PURE__ */ getDefaultExportFromCjs(postcss_1);
5034
- postcss$1.stringify;
5035
- postcss$1.fromJSON;
5036
- postcss$1.plugin;
5037
- postcss$1.parse;
5038
- postcss$1.list;
5039
- postcss$1.document;
5040
- postcss$1.comment;
5041
- postcss$1.atRule;
5042
- postcss$1.rule;
5043
- postcss$1.decl;
5044
- postcss$1.root;
5045
- postcss$1.CssSyntaxError;
5046
- postcss$1.Declaration;
5047
- postcss$1.Container;
5048
- postcss$1.Processor;
5049
- postcss$1.Document;
5050
- postcss$1.Comment;
5051
- postcss$1.Warning;
5052
- postcss$1.AtRule;
5053
- postcss$1.Result;
5054
- postcss$1.Input;
5055
- postcss$1.Rule;
5056
- postcss$1.Root;
5057
- postcss$1.Node;
5064
+ postcss$1.stringify = stringify$1;
5065
+ postcss$1.parse = parse$1;
5066
+ postcss$1.fromJSON = fromJSON$1;
5067
+ postcss$1.list = list$1;
5068
+ postcss$1.comment = (defaults) => new Comment$2(defaults);
5069
+ postcss$1.atRule = (defaults) => new AtRule$1(defaults);
5070
+ postcss$1.decl = (defaults) => new Declaration$1(defaults);
5071
+ postcss$1.rule = (defaults) => new Rule$1(defaults);
5072
+ postcss$1.root = (defaults) => new Root$1(defaults);
5073
+ postcss$1.document = (defaults) => new Document$1(defaults);
5074
+ postcss$1.CssSyntaxError = CssSyntaxError$1;
5075
+ postcss$1.Declaration = Declaration$1;
5076
+ postcss$1.Container = Container$1;
5077
+ postcss$1.Processor = Processor$1;
5078
+ postcss$1.Document = Document$1;
5079
+ postcss$1.Comment = Comment$2;
5080
+ postcss$1.Warning = Warning$1;
5081
+ postcss$1.AtRule = AtRule$1;
5082
+ postcss$1.Result = Result$1;
5083
+ postcss$1.Input = Input$2;
5084
+ postcss$1.Rule = Rule$1;
5085
+ postcss$1.Root = Root$1;
5086
+ postcss$1.Node = Node$1;
5087
+ LazyResult2.registerPostcss(postcss$1);
5088
+ var postcss_1 = postcss$1;
5089
+ postcss$1.default = postcss$1;
5090
+ const postcss$2 = /* @__PURE__ */ getDefaultExportFromCjs(postcss_1);
5091
+ const stringify = postcss$2.stringify;
5092
+ const fromJSON = postcss$2.fromJSON;
5093
+ const plugin2 = postcss$2.plugin;
5094
+ const parse = postcss$2.parse;
5095
+ const list = postcss$2.list;
5096
+ const document$1 = postcss$2.document;
5097
+ const comment = postcss$2.comment;
5098
+ const atRule = postcss$2.atRule;
5099
+ const rule = postcss$2.rule;
5100
+ const decl = postcss$2.decl;
5101
+ const root = postcss$2.root;
5102
+ const CssSyntaxError2 = postcss$2.CssSyntaxError;
5103
+ const Declaration2 = postcss$2.Declaration;
5104
+ const Container2 = postcss$2.Container;
5105
+ const Processor2 = postcss$2.Processor;
5106
+ const Document2 = postcss$2.Document;
5107
+ const Comment$1 = postcss$2.Comment;
5108
+ const Warning2 = postcss$2.Warning;
5109
+ const AtRule2 = postcss$2.AtRule;
5110
+ const Result2 = postcss$2.Result;
5111
+ const Input$1 = postcss$2.Input;
5112
+ const Rule2 = postcss$2.Rule;
5113
+ const Root2 = postcss$2.Root;
5114
+ const Node2 = postcss$2.Node;
5115
+ const postcss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5116
+ __proto__: null,
5117
+ AtRule: AtRule2,
5118
+ Comment: Comment$1,
5119
+ Container: Container2,
5120
+ CssSyntaxError: CssSyntaxError2,
5121
+ Declaration: Declaration2,
5122
+ Document: Document2,
5123
+ Input: Input$1,
5124
+ Node: Node2,
5125
+ Processor: Processor2,
5126
+ Result: Result2,
5127
+ Root: Root2,
5128
+ Rule: Rule2,
5129
+ Warning: Warning2,
5130
+ atRule,
5131
+ comment,
5132
+ decl,
5133
+ default: postcss$2,
5134
+ document: document$1,
5135
+ fromJSON,
5136
+ list,
5137
+ parse,
5138
+ plugin: plugin2,
5139
+ root,
5140
+ rule,
5141
+ stringify
5142
+ }, Symbol.toStringTag, { value: "Module" }));
5143
+ const require$$0 = /* @__PURE__ */ getAugmentedNamespace(postcss);
5144
+ let Comment2 = comment$1;
5145
+ let Parser2 = parser;
5146
+ let tokenizer2 = tokenize;
5147
+ let SafeParser$1 = class SafeParser extends Parser2 {
5148
+ checkMissedSemicolon() {
5149
+ }
5150
+ comment(token) {
5151
+ let node2 = new Comment2();
5152
+ this.init(node2, token[2]);
5153
+ let pos = this.input.fromOffset(token[3]) || this.input.fromOffset(this.input.css.length - 1);
5154
+ node2.source.end = {
5155
+ column: pos.col,
5156
+ line: pos.line,
5157
+ offset: token[3] + 1
5158
+ };
5159
+ let text = token[1].slice(2);
5160
+ if (text.slice(-2) === "*/") text = text.slice(0, -2);
5161
+ if (/^\s*$/.test(text)) {
5162
+ node2.text = "";
5163
+ node2.raws.left = text;
5164
+ node2.raws.right = "";
5165
+ } else {
5166
+ let match = text.match(/^(\s*)([^]*\S)(\s*)$/);
5167
+ node2.text = match[2];
5168
+ node2.raws.left = match[1];
5169
+ node2.raws.right = match[3];
5170
+ }
5171
+ }
5172
+ createTokenizer() {
5173
+ this.tokenizer = tokenizer2(this.input, { ignoreErrors: true });
5174
+ }
5175
+ decl(tokens) {
5176
+ if (tokens.length > 1 && tokens.some((i) => i[0] === "word")) {
5177
+ super.decl(tokens);
5178
+ }
5179
+ }
5180
+ doubleColon() {
5181
+ }
5182
+ endFile() {
5183
+ if (this.current.nodes && this.current.nodes.length) {
5184
+ this.current.raws.semicolon = this.semicolon;
5185
+ }
5186
+ this.current.raws.after = (this.current.raws.after || "") + this.spaces;
5187
+ while (this.current.parent) {
5188
+ this.current = this.current.parent;
5189
+ this.current.raws.after = "";
5190
+ }
5191
+ this.root.source.end = this.getPosition(this.tokenizer.position());
5192
+ }
5193
+ precheckMissedSemicolon(tokens) {
5194
+ let colon = this.colon(tokens);
5195
+ if (colon === false) return;
5196
+ let nextStart, prevEnd;
5197
+ for (nextStart = colon - 1; nextStart >= 0; nextStart--) {
5198
+ if (tokens[nextStart][0] === "word") break;
5199
+ }
5200
+ if (nextStart === 0 || nextStart < 0) return;
5201
+ for (prevEnd = nextStart - 1; prevEnd >= 0; prevEnd--) {
5202
+ if (tokens[prevEnd][0] !== "space") {
5203
+ prevEnd += 1;
5204
+ break;
5205
+ }
5206
+ }
5207
+ let other = tokens.slice(nextStart);
5208
+ let spaces = tokens.slice(prevEnd, nextStart);
5209
+ tokens.splice(prevEnd, tokens.length - prevEnd);
5210
+ this.spaces = spaces.map((i) => i[1]).join("");
5211
+ this.decl(other);
5212
+ }
5213
+ unclosedBracket() {
5214
+ }
5215
+ unexpectedClose() {
5216
+ this.current.raws.after += "}";
5217
+ }
5218
+ unknownWord(tokens) {
5219
+ this.spaces += tokens.map((i) => i[1]).join("");
5220
+ }
5221
+ unnamedAtrule(node2) {
5222
+ node2.name = "";
5223
+ }
5224
+ };
5225
+ var safeParser$1 = SafeParser$1;
5226
+ let { Input: Input2 } = require$$0;
5227
+ let SafeParser2 = safeParser$1;
5228
+ var safeParse = function safeParse2(css, opts) {
5229
+ let input2 = new Input2(css, opts);
5230
+ let parser2 = new SafeParser2(input2);
5231
+ parser2.parse();
5232
+ return parser2.root;
5233
+ };
5234
+ const safeParser = /* @__PURE__ */ getDefaultExportFromCjs(safeParse);
5058
5235
  const tagMap = {
5059
5236
  script: "noscript",
5060
5237
  // camel case svg element tag names
@@ -5107,10 +5284,10 @@ function adaptCssForReplay(cssText, cache) {
5107
5284
  if (cachedStyle) return cachedStyle;
5108
5285
  let result2 = cssText;
5109
5286
  try {
5110
- const ast = postcss$1([
5287
+ const ast = postcss$2([
5111
5288
  mediaSelectorPlugin,
5112
5289
  pseudoClassPlugin
5113
- ]).process(cssText);
5290
+ ]).process(cssText, { parser: safeParser });
5114
5291
  result2 = ast.css;
5115
5292
  } catch (error) {
5116
5293
  console.warn("Failed to adapt css for replay", error);