@appsurify-testmap/rrdom-nodejs 3.1.1-alpha.1 → 3.1.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -118,7 +118,7 @@ function getAugmentedNamespace(n) {
118
118
  var picocolors_browser = { exports: {} };
119
119
  var x = String;
120
120
  var create = function() {
121
- 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 };
121
+ 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 };
122
122
  };
123
123
  picocolors_browser.exports = create();
124
124
  picocolors_browser.exports.createColors = create;
@@ -173,29 +173,40 @@ let CssSyntaxError$3 = class CssSyntaxError extends Error {
173
173
  if (!this.source) return "";
174
174
  let css = this.source;
175
175
  if (color == null) color = pico.isColorSupported;
176
- if (terminalHighlight$1) {
177
- if (color) css = terminalHighlight$1(css);
178
- }
179
- let lines = css.split(/\r?\n/);
180
- let start = Math.max(this.line - 3, 0);
181
- let end = Math.min(this.line + 2, lines.length);
182
- let maxWidth = String(end).length;
183
- let mark, aside;
176
+ let aside = (text) => text;
177
+ let mark = (text) => text;
178
+ let highlight = (text) => text;
184
179
  if (color) {
185
180
  let { bold, gray, red } = pico.createColors(true);
186
181
  mark = (text) => bold(red(text));
187
182
  aside = (text) => gray(text);
188
- } else {
189
- mark = aside = (str) => str;
183
+ if (terminalHighlight$1) {
184
+ highlight = (text) => terminalHighlight$1(text);
185
+ }
190
186
  }
187
+ let lines = css.split(/\r?\n/);
188
+ let start = Math.max(this.line - 3, 0);
189
+ let end = Math.min(this.line + 2, lines.length);
190
+ let maxWidth = String(end).length;
191
191
  return lines.slice(start, end).map((line, index2) => {
192
192
  let number = start + 1 + index2;
193
193
  let gutter = " " + (" " + number).slice(-maxWidth) + " | ";
194
194
  if (number === this.line) {
195
+ if (line.length > 160) {
196
+ let padding = 20;
197
+ let subLineStart = Math.max(0, this.column - padding);
198
+ let subLineEnd = Math.max(
199
+ this.column + padding,
200
+ this.endColumn + padding
201
+ );
202
+ let subLine = line.slice(subLineStart, subLineEnd);
203
+ let spacing2 = aside(gutter.replace(/\d/g, " ")) + line.slice(0, Math.min(this.column - 1, padding - 1)).replace(/[^\t]/g, " ");
204
+ return mark(">") + aside(gutter) + highlight(subLine) + "\n " + spacing2 + mark("^");
205
+ }
195
206
  let spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, this.column - 1).replace(/[^\t]/g, " ");
196
- return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
207
+ return mark(">") + aside(gutter) + highlight(line) + "\n " + spacing + mark("^");
197
208
  }
198
- return " " + aside(gutter) + line;
209
+ return " " + aside(gutter) + highlight(line);
199
210
  }).join("\n");
200
211
  }
201
212
  toString() {
@@ -208,9 +219,6 @@ let CssSyntaxError$3 = class CssSyntaxError extends Error {
208
219
  };
209
220
  var cssSyntaxError = CssSyntaxError$3;
210
221
  CssSyntaxError$3.default = CssSyntaxError$3;
211
- var symbols = {};
212
- symbols.isClean = Symbol("isClean");
213
- symbols.my = Symbol("my");
214
222
  const DEFAULT_RAW = {
215
223
  after: "\n",
216
224
  beforeClose: "\n",
@@ -515,10 +523,13 @@ function stringify$4(node2, builder) {
515
523
  }
516
524
  var stringify_1 = stringify$4;
517
525
  stringify$4.default = stringify$4;
518
- let { isClean: isClean$2, my: my$2 } = symbols;
526
+ var symbols = {};
527
+ symbols.isClean = Symbol("isClean");
528
+ symbols.my = Symbol("my");
519
529
  let CssSyntaxError$2 = cssSyntaxError;
520
530
  let Stringifier2 = stringifier;
521
531
  let stringify$3 = stringify_1;
532
+ let { isClean: isClean$2, my: my$2 } = symbols;
522
533
  function cloneNode(obj, parent) {
523
534
  let cloned = new obj.constructor();
524
535
  for (let i in obj) {
@@ -541,7 +552,31 @@ function cloneNode(obj, parent) {
541
552
  }
542
553
  return cloned;
543
554
  }
555
+ function sourceOffset(inputCSS, position) {
556
+ if (position && typeof position.offset !== "undefined") {
557
+ return position.offset;
558
+ }
559
+ let column = 1;
560
+ let line = 1;
561
+ let offset = 0;
562
+ for (let i = 0; i < inputCSS.length; i++) {
563
+ if (line === position.line && column === position.column) {
564
+ offset = i;
565
+ break;
566
+ }
567
+ if (inputCSS[i] === "\n") {
568
+ column = 1;
569
+ line += 1;
570
+ } else {
571
+ column += 1;
572
+ }
573
+ }
574
+ return offset;
575
+ }
544
576
  let Node$5 = class Node2 {
577
+ get proxyOf() {
578
+ return this;
579
+ }
545
580
  constructor(defaults = {}) {
546
581
  this.raws = {};
547
582
  this[isClean$2] = false;
@@ -642,6 +677,10 @@ let Node$5 = class Node2 {
642
677
  }
643
678
  };
644
679
  }
680
+ /* c8 ignore next 3 */
681
+ markClean() {
682
+ this[isClean$2] = true;
683
+ }
645
684
  markDirty() {
646
685
  if (this[isClean$2]) {
647
686
  this[isClean$2] = false;
@@ -656,60 +695,82 @@ let Node$5 = class Node2 {
656
695
  let index2 = this.parent.index(this);
657
696
  return this.parent.nodes[index2 + 1];
658
697
  }
659
- positionBy(opts, stringRepresentation) {
698
+ positionBy(opts = {}) {
660
699
  let pos = this.source.start;
661
700
  if (opts.index) {
662
- pos = this.positionInside(opts.index, stringRepresentation);
701
+ pos = this.positionInside(opts.index);
663
702
  } else if (opts.word) {
664
- stringRepresentation = this.toString();
703
+ let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
704
+ let stringRepresentation = inputString.slice(
705
+ sourceOffset(inputString, this.source.start),
706
+ sourceOffset(inputString, this.source.end)
707
+ );
665
708
  let index2 = stringRepresentation.indexOf(opts.word);
666
- if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
709
+ if (index2 !== -1) pos = this.positionInside(index2);
667
710
  }
668
711
  return pos;
669
712
  }
670
- positionInside(index2, stringRepresentation) {
671
- let string = stringRepresentation || this.toString();
713
+ positionInside(index2) {
672
714
  let column = this.source.start.column;
673
715
  let line = this.source.start.line;
674
- for (let i = 0; i < index2; i++) {
675
- if (string[i] === "\n") {
716
+ let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
717
+ let offset = sourceOffset(inputString, this.source.start);
718
+ let end = offset + index2;
719
+ for (let i = offset; i < end; i++) {
720
+ if (inputString[i] === "\n") {
676
721
  column = 1;
677
722
  line += 1;
678
723
  } else {
679
724
  column += 1;
680
725
  }
681
726
  }
682
- return { column, line };
727
+ return { column, line, offset: end };
683
728
  }
684
729
  prev() {
685
730
  if (!this.parent) return void 0;
686
731
  let index2 = this.parent.index(this);
687
732
  return this.parent.nodes[index2 - 1];
688
733
  }
689
- rangeBy(opts) {
734
+ rangeBy(opts = {}) {
735
+ let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
690
736
  let start = {
691
737
  column: this.source.start.column,
692
- line: this.source.start.line
738
+ line: this.source.start.line,
739
+ offset: sourceOffset(inputString, this.source.start)
693
740
  };
694
741
  let end = this.source.end ? {
695
742
  column: this.source.end.column + 1,
696
- line: this.source.end.line
743
+ line: this.source.end.line,
744
+ offset: typeof this.source.end.offset === "number" ? (
745
+ // `source.end.offset` is exclusive, so we don't need to add 1
746
+ this.source.end.offset
747
+ ) : (
748
+ // Since line/column in this.source.end is inclusive,
749
+ // the `sourceOffset(... , this.source.end)` returns an inclusive offset.
750
+ // So, we add 1 to convert it to exclusive.
751
+ sourceOffset(inputString, this.source.end) + 1
752
+ )
697
753
  } : {
698
754
  column: start.column + 1,
699
- line: start.line
755
+ line: start.line,
756
+ offset: start.offset + 1
700
757
  };
701
758
  if (opts.word) {
702
- let stringRepresentation = this.toString();
759
+ let stringRepresentation = inputString.slice(
760
+ sourceOffset(inputString, this.source.start),
761
+ sourceOffset(inputString, this.source.end)
762
+ );
703
763
  let index2 = stringRepresentation.indexOf(opts.word);
704
764
  if (index2 !== -1) {
705
- start = this.positionInside(index2, stringRepresentation);
706
- end = this.positionInside(index2 + opts.word.length, stringRepresentation);
765
+ start = this.positionInside(index2);
766
+ end = this.positionInside(index2 + opts.word.length);
707
767
  }
708
768
  } else {
709
769
  if (opts.start) {
710
770
  start = {
711
771
  column: opts.start.column,
712
- line: opts.start.line
772
+ line: opts.start.line,
773
+ offset: sourceOffset(inputString, opts.start)
713
774
  };
714
775
  } else if (opts.index) {
715
776
  start = this.positionInside(opts.index);
@@ -717,7 +778,8 @@ let Node$5 = class Node2 {
717
778
  if (opts.end) {
718
779
  end = {
719
780
  column: opts.end.column,
720
- line: opts.end.line
781
+ line: opts.end.line,
782
+ offset: sourceOffset(inputString, opts.end)
721
783
  };
722
784
  } else if (typeof opts.endIndex === "number") {
723
785
  end = this.positionInside(opts.endIndex);
@@ -726,7 +788,11 @@ let Node$5 = class Node2 {
726
788
  }
727
789
  }
728
790
  if (end.line < start.line || end.line === start.line && end.column <= start.column) {
729
- end = { column: start.column + 1, line: start.line };
791
+ end = {
792
+ column: start.column + 1,
793
+ line: start.line,
794
+ offset: start.offset + 1
795
+ };
730
796
  }
731
797
  return { end, start };
732
798
  }
@@ -790,6 +856,7 @@ let Node$5 = class Node2 {
790
856
  } else if (typeof value === "object" && value.toJSON) {
791
857
  fixed[name] = value.toJSON(null, inputs);
792
858
  } else if (name === "source") {
859
+ if (value == null) continue;
793
860
  let inputId = inputs.get(value.input);
794
861
  if (inputId == null) {
795
862
  inputId = inputsNextIndex;
@@ -824,19 +891,28 @@ let Node$5 = class Node2 {
824
891
  });
825
892
  return result2;
826
893
  }
827
- warn(result2, text, opts) {
894
+ warn(result2, text, opts = {}) {
828
895
  let data = { node: this };
829
896
  for (let i in opts) data[i] = opts[i];
830
897
  return result2.warn(text, data);
831
898
  }
832
- get proxyOf() {
833
- return this;
834
- }
835
899
  };
836
900
  var node = Node$5;
837
901
  Node$5.default = Node$5;
838
902
  let Node$4 = node;
839
- let Declaration$4 = class Declaration extends Node$4 {
903
+ let Comment$4 = class Comment extends Node$4 {
904
+ constructor(defaults) {
905
+ super(defaults);
906
+ this.type = "comment";
907
+ }
908
+ };
909
+ var comment = Comment$4;
910
+ Comment$4.default = Comment$4;
911
+ let Node$3 = node;
912
+ let Declaration$4 = class Declaration extends Node$3 {
913
+ get variable() {
914
+ return this.prop.startsWith("--") || this.prop[0] === "$";
915
+ }
840
916
  constructor(defaults) {
841
917
  if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
842
918
  defaults = { ...defaults, value: String(defaults.value) };
@@ -844,1124 +920,1236 @@ let Declaration$4 = class Declaration extends Node$4 {
844
920
  super(defaults);
845
921
  this.type = "decl";
846
922
  }
847
- get variable() {
848
- return this.prop.startsWith("--") || this.prop[0] === "$";
849
- }
850
923
  };
851
924
  var declaration = Declaration$4;
852
925
  Declaration$4.default = Declaration$4;
853
- let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
854
- let customAlphabet = (alphabet, defaultSize = 21) => {
855
- return (size = defaultSize) => {
856
- let id = "";
857
- let i = size;
858
- while (i--) {
859
- id += alphabet[Math.random() * alphabet.length | 0];
860
- }
861
- return id;
862
- };
863
- };
864
- let nanoid$1 = (size = 21) => {
865
- let id = "";
866
- let i = size;
867
- while (i--) {
868
- id += urlAlphabet[Math.random() * 64 | 0];
869
- }
870
- return id;
871
- };
872
- var nonSecure = { nanoid: nanoid$1, customAlphabet };
873
- let { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$2 } = require$$2;
874
- let { existsSync, readFileSync } = require$$2;
875
- let { dirname: dirname$1, join } = require$$2;
876
- function fromBase64(str) {
877
- if (Buffer) {
878
- return Buffer.from(str, "base64").toString();
879
- } else {
880
- return window.atob(str);
881
- }
926
+ let Comment$3 = comment;
927
+ let Declaration$3 = declaration;
928
+ let Node$2 = node;
929
+ let { isClean: isClean$1, my: my$1 } = symbols;
930
+ let AtRule$4, parse$4, Root$6, Rule$4;
931
+ function cleanSource(nodes) {
932
+ return nodes.map((i) => {
933
+ if (i.nodes) i.nodes = cleanSource(i.nodes);
934
+ delete i.source;
935
+ return i;
936
+ });
882
937
  }
883
- let PreviousMap$2 = class PreviousMap {
884
- constructor(css, opts) {
885
- if (opts.map === false) return;
886
- this.loadAnnotation(css);
887
- this.inline = this.startWith(this.annotation, "data:");
888
- let prev = opts.map ? opts.map.prev : void 0;
889
- let text = this.loadMap(opts.from, prev);
890
- if (!this.mapFile && opts.from) {
891
- this.mapFile = opts.from;
892
- }
893
- if (this.mapFile) this.root = dirname$1(this.mapFile);
894
- if (text) this.text = text;
895
- }
896
- consumer() {
897
- if (!this.consumerCache) {
898
- this.consumerCache = new SourceMapConsumer$2(this.text);
938
+ function markTreeDirty(node2) {
939
+ node2[isClean$1] = false;
940
+ if (node2.proxyOf.nodes) {
941
+ for (let i of node2.proxyOf.nodes) {
942
+ markTreeDirty(i);
899
943
  }
900
- return this.consumerCache;
901
944
  }
902
- decodeInline(text) {
903
- let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
904
- let baseUri = /^data:application\/json;base64,/;
905
- let charsetUri = /^data:application\/json;charset=utf-?8,/;
906
- let uri = /^data:application\/json,/;
907
- if (charsetUri.test(text) || uri.test(text)) {
908
- return decodeURIComponent(text.substr(RegExp.lastMatch.length));
909
- }
910
- if (baseCharsetUri.test(text) || baseUri.test(text)) {
911
- return fromBase64(text.substr(RegExp.lastMatch.length));
912
- }
913
- let encoding = text.match(/data:application\/json;([^,]+),/)[1];
914
- throw new Error("Unsupported source map encoding " + encoding);
945
+ }
946
+ let Container$7 = class Container extends Node$2 {
947
+ get first() {
948
+ if (!this.proxyOf.nodes) return void 0;
949
+ return this.proxyOf.nodes[0];
915
950
  }
916
- getAnnotationURL(sourceMapString) {
917
- return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
951
+ get last() {
952
+ if (!this.proxyOf.nodes) return void 0;
953
+ return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
918
954
  }
919
- isMap(map) {
920
- if (typeof map !== "object") return false;
921
- return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
955
+ append(...children) {
956
+ for (let child of children) {
957
+ let nodes = this.normalize(child, this.last);
958
+ for (let node2 of nodes) this.proxyOf.nodes.push(node2);
959
+ }
960
+ this.markDirty();
961
+ return this;
922
962
  }
923
- loadAnnotation(css) {
924
- let comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
925
- if (!comments) return;
926
- let start = css.lastIndexOf(comments.pop());
927
- let end = css.indexOf("*/", start);
928
- if (start > -1 && end > -1) {
929
- this.annotation = this.getAnnotationURL(css.substring(start, end));
963
+ cleanRaws(keepBetween) {
964
+ super.cleanRaws(keepBetween);
965
+ if (this.nodes) {
966
+ for (let node2 of this.nodes) node2.cleanRaws(keepBetween);
930
967
  }
931
968
  }
932
- loadFile(path) {
933
- this.root = dirname$1(path);
934
- if (existsSync(path)) {
935
- this.mapFile = path;
936
- return readFileSync(path, "utf-8").toString().trim();
969
+ each(callback) {
970
+ if (!this.proxyOf.nodes) return void 0;
971
+ let iterator = this.getIterator();
972
+ let index2, result2;
973
+ while (this.indexes[iterator] < this.proxyOf.nodes.length) {
974
+ index2 = this.indexes[iterator];
975
+ result2 = callback(this.proxyOf.nodes[index2], index2);
976
+ if (result2 === false) break;
977
+ this.indexes[iterator] += 1;
937
978
  }
979
+ delete this.indexes[iterator];
980
+ return result2;
938
981
  }
939
- loadMap(file, prev) {
940
- if (prev === false) return false;
941
- if (prev) {
942
- if (typeof prev === "string") {
943
- return prev;
944
- } else if (typeof prev === "function") {
945
- let prevPath = prev(file);
946
- if (prevPath) {
947
- let map = this.loadFile(prevPath);
948
- if (!map) {
949
- throw new Error(
950
- "Unable to load previous source map: " + prevPath.toString()
982
+ every(condition) {
983
+ return this.nodes.every(condition);
984
+ }
985
+ getIterator() {
986
+ if (!this.lastEach) this.lastEach = 0;
987
+ if (!this.indexes) this.indexes = {};
988
+ this.lastEach += 1;
989
+ let iterator = this.lastEach;
990
+ this.indexes[iterator] = 0;
991
+ return iterator;
992
+ }
993
+ getProxyProcessor() {
994
+ return {
995
+ get(node2, prop) {
996
+ if (prop === "proxyOf") {
997
+ return node2;
998
+ } else if (!node2[prop]) {
999
+ return node2[prop];
1000
+ } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
1001
+ return (...args) => {
1002
+ return node2[prop](
1003
+ ...args.map((i) => {
1004
+ if (typeof i === "function") {
1005
+ return (child, index2) => i(child.toProxy(), index2);
1006
+ } else {
1007
+ return i;
1008
+ }
1009
+ })
951
1010
  );
952
- }
953
- return map;
1011
+ };
1012
+ } else if (prop === "every" || prop === "some") {
1013
+ return (cb) => {
1014
+ return node2[prop](
1015
+ (child, ...other) => cb(child.toProxy(), ...other)
1016
+ );
1017
+ };
1018
+ } else if (prop === "root") {
1019
+ return () => node2.root().toProxy();
1020
+ } else if (prop === "nodes") {
1021
+ return node2.nodes.map((i) => i.toProxy());
1022
+ } else if (prop === "first" || prop === "last") {
1023
+ return node2[prop].toProxy();
1024
+ } else {
1025
+ return node2[prop];
954
1026
  }
955
- } else if (prev instanceof SourceMapConsumer$2) {
956
- return SourceMapGenerator$2.fromSourceMap(prev).toString();
957
- } else if (prev instanceof SourceMapGenerator$2) {
958
- return prev.toString();
959
- } else if (this.isMap(prev)) {
960
- return JSON.stringify(prev);
961
- } else {
962
- throw new Error(
963
- "Unsupported previous source map format: " + prev.toString()
964
- );
1027
+ },
1028
+ set(node2, prop, value) {
1029
+ if (node2[prop] === value) return true;
1030
+ node2[prop] = value;
1031
+ if (prop === "name" || prop === "params" || prop === "selector") {
1032
+ node2.markDirty();
1033
+ }
1034
+ return true;
965
1035
  }
966
- } else if (this.inline) {
967
- return this.decodeInline(this.annotation);
968
- } else if (this.annotation) {
969
- let map = this.annotation;
970
- if (file) map = join(dirname$1(file), map);
971
- return this.loadFile(map);
972
- }
973
- }
974
- startWith(string, start) {
975
- if (!string) return false;
976
- return string.substr(0, start.length) === start;
1036
+ };
977
1037
  }
978
- withContent() {
979
- return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
1038
+ index(child) {
1039
+ if (typeof child === "number") return child;
1040
+ if (child.proxyOf) child = child.proxyOf;
1041
+ return this.proxyOf.nodes.indexOf(child);
980
1042
  }
981
- };
982
- var previousMap = PreviousMap$2;
983
- PreviousMap$2.default = PreviousMap$2;
984
- let { SourceMapConsumer: SourceMapConsumer$1, SourceMapGenerator: SourceMapGenerator$1 } = require$$2;
985
- let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
986
- let { isAbsolute, resolve: resolve$1 } = require$$2;
987
- let { nanoid } = nonSecure;
988
- let terminalHighlight = require$$2;
989
- let CssSyntaxError$1 = cssSyntaxError;
990
- let PreviousMap$1 = previousMap;
991
- let fromOffsetCache = Symbol("fromOffsetCache");
992
- let sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
993
- let pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
994
- let Input$4 = class Input {
995
- constructor(css, opts = {}) {
996
- if (css === null || typeof css === "undefined" || typeof css === "object" && !css.toString) {
997
- throw new Error(`PostCSS received ${css} instead of CSS string`);
998
- }
999
- this.css = css.toString();
1000
- if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
1001
- this.hasBOM = true;
1002
- this.css = this.css.slice(1);
1003
- } else {
1004
- this.hasBOM = false;
1005
- }
1006
- if (opts.from) {
1007
- if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
1008
- this.file = opts.from;
1009
- } else {
1010
- this.file = resolve$1(opts.from);
1043
+ insertAfter(exist, add) {
1044
+ let existIndex = this.index(exist);
1045
+ let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
1046
+ existIndex = this.index(exist);
1047
+ for (let node2 of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
1048
+ let index2;
1049
+ for (let id in this.indexes) {
1050
+ index2 = this.indexes[id];
1051
+ if (existIndex < index2) {
1052
+ this.indexes[id] = index2 + nodes.length;
1011
1053
  }
1012
1054
  }
1013
- if (pathAvailable$1 && sourceMapAvailable$1) {
1014
- let map = new PreviousMap$1(this.css, opts);
1015
- if (map.text) {
1016
- this.map = map;
1017
- let file = map.consumer().file;
1018
- if (!this.file && file) this.file = this.mapResolve(file);
1055
+ this.markDirty();
1056
+ return this;
1057
+ }
1058
+ insertBefore(exist, add) {
1059
+ let existIndex = this.index(exist);
1060
+ let type = existIndex === 0 ? "prepend" : false;
1061
+ let nodes = this.normalize(
1062
+ add,
1063
+ this.proxyOf.nodes[existIndex],
1064
+ type
1065
+ ).reverse();
1066
+ existIndex = this.index(exist);
1067
+ for (let node2 of nodes) this.proxyOf.nodes.splice(existIndex, 0, node2);
1068
+ let index2;
1069
+ for (let id in this.indexes) {
1070
+ index2 = this.indexes[id];
1071
+ if (existIndex <= index2) {
1072
+ this.indexes[id] = index2 + nodes.length;
1019
1073
  }
1020
1074
  }
1021
- if (!this.file) {
1022
- this.id = "<input css " + nanoid(6) + ">";
1023
- }
1024
- if (this.map) this.map.file = this.from;
1075
+ this.markDirty();
1076
+ return this;
1025
1077
  }
1026
- error(message, line, column, opts = {}) {
1027
- let result2, endLine, endColumn;
1028
- if (line && typeof line === "object") {
1029
- let start = line;
1030
- let end = column;
1031
- if (typeof start.offset === "number") {
1032
- let pos = this.fromOffset(start.offset);
1033
- line = pos.line;
1034
- column = pos.col;
1035
- } else {
1036
- line = start.line;
1037
- column = start.column;
1038
- }
1039
- if (typeof end.offset === "number") {
1040
- let pos = this.fromOffset(end.offset);
1041
- endLine = pos.line;
1042
- endColumn = pos.col;
1043
- } else {
1044
- endLine = end.line;
1045
- endColumn = end.column;
1078
+ normalize(nodes, sample) {
1079
+ if (typeof nodes === "string") {
1080
+ nodes = cleanSource(parse$4(nodes).nodes);
1081
+ } else if (typeof nodes === "undefined") {
1082
+ nodes = [];
1083
+ } else if (Array.isArray(nodes)) {
1084
+ nodes = nodes.slice(0);
1085
+ for (let i of nodes) {
1086
+ if (i.parent) i.parent.removeChild(i, "ignore");
1046
1087
  }
1047
- } else if (!column) {
1048
- let pos = this.fromOffset(line);
1049
- line = pos.line;
1050
- column = pos.col;
1051
- }
1052
- let origin = this.origin(line, column, endLine, endColumn);
1053
- if (origin) {
1054
- result2 = new CssSyntaxError$1(
1055
- message,
1056
- origin.endLine === void 0 ? origin.line : { column: origin.column, line: origin.line },
1057
- origin.endLine === void 0 ? origin.column : { column: origin.endColumn, line: origin.endLine },
1058
- origin.source,
1059
- origin.file,
1060
- opts.plugin
1061
- );
1062
- } else {
1063
- result2 = new CssSyntaxError$1(
1064
- message,
1065
- endLine === void 0 ? line : { column, line },
1066
- endLine === void 0 ? column : { column: endColumn, line: endLine },
1067
- this.css,
1068
- this.file,
1069
- opts.plugin
1070
- );
1071
- }
1072
- result2.input = { column, endColumn, endLine, line, source: this.css };
1073
- if (this.file) {
1074
- if (pathToFileURL$1) {
1075
- result2.input.url = pathToFileURL$1(this.file).toString();
1088
+ } else if (nodes.type === "root" && this.type !== "document") {
1089
+ nodes = nodes.nodes.slice(0);
1090
+ for (let i of nodes) {
1091
+ if (i.parent) i.parent.removeChild(i, "ignore");
1076
1092
  }
1077
- result2.input.file = this.file;
1078
- }
1079
- return result2;
1080
- }
1081
- fromOffset(offset) {
1082
- let lastLine, lineToIndex;
1083
- if (!this[fromOffsetCache]) {
1084
- let lines = this.css.split("\n");
1085
- lineToIndex = new Array(lines.length);
1086
- let prevIndex = 0;
1087
- for (let i = 0, l = lines.length; i < l; i++) {
1088
- lineToIndex[i] = prevIndex;
1089
- prevIndex += lines[i].length + 1;
1093
+ } else if (nodes.type) {
1094
+ nodes = [nodes];
1095
+ } else if (nodes.prop) {
1096
+ if (typeof nodes.value === "undefined") {
1097
+ throw new Error("Value field is missed in node creation");
1098
+ } else if (typeof nodes.value !== "string") {
1099
+ nodes.value = String(nodes.value);
1090
1100
  }
1091
- this[fromOffsetCache] = lineToIndex;
1101
+ nodes = [new Declaration$3(nodes)];
1102
+ } else if (nodes.selector || nodes.selectors) {
1103
+ nodes = [new Rule$4(nodes)];
1104
+ } else if (nodes.name) {
1105
+ nodes = [new AtRule$4(nodes)];
1106
+ } else if (nodes.text) {
1107
+ nodes = [new Comment$3(nodes)];
1092
1108
  } else {
1093
- lineToIndex = this[fromOffsetCache];
1109
+ throw new Error("Unknown node type in node creation");
1094
1110
  }
1095
- lastLine = lineToIndex[lineToIndex.length - 1];
1096
- let min = 0;
1097
- if (offset >= lastLine) {
1098
- min = lineToIndex.length - 1;
1099
- } else {
1100
- let max = lineToIndex.length - 2;
1101
- let mid;
1102
- while (min < max) {
1103
- mid = min + (max - min >> 1);
1104
- if (offset < lineToIndex[mid]) {
1105
- max = mid - 1;
1106
- } else if (offset >= lineToIndex[mid + 1]) {
1107
- min = mid + 1;
1108
- } else {
1109
- min = mid;
1110
- break;
1111
+ let processed = nodes.map((i) => {
1112
+ if (!i[my$1]) Container.rebuild(i);
1113
+ i = i.proxyOf;
1114
+ if (i.parent) i.parent.removeChild(i);
1115
+ if (i[isClean$1]) markTreeDirty(i);
1116
+ if (!i.raws) i.raws = {};
1117
+ if (typeof i.raws.before === "undefined") {
1118
+ if (sample && typeof sample.raws.before !== "undefined") {
1119
+ i.raws.before = sample.raws.before.replace(/\S/g, "");
1111
1120
  }
1112
1121
  }
1113
- }
1114
- return {
1115
- col: offset - lineToIndex[min] + 1,
1116
- line: min + 1
1117
- };
1118
- }
1119
- mapResolve(file) {
1120
- if (/^\w+:\/\//.test(file)) {
1121
- return file;
1122
- }
1123
- return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
1122
+ i.parent = this.proxyOf;
1123
+ return i;
1124
+ });
1125
+ return processed;
1124
1126
  }
1125
- origin(line, column, endLine, endColumn) {
1126
- if (!this.map) return false;
1127
- let consumer = this.map.consumer();
1128
- let from = consumer.originalPositionFor({ column, line });
1129
- if (!from.source) return false;
1130
- let to;
1131
- if (typeof endLine === "number") {
1132
- to = consumer.originalPositionFor({ column: endColumn, line: endLine });
1133
- }
1134
- let fromUrl;
1135
- if (isAbsolute(from.source)) {
1136
- fromUrl = pathToFileURL$1(from.source);
1137
- } else {
1138
- fromUrl = new URL(
1139
- from.source,
1140
- this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile)
1141
- );
1142
- }
1143
- let result2 = {
1144
- column: from.column,
1145
- endColumn: to && to.column,
1146
- endLine: to && to.line,
1147
- line: from.line,
1148
- url: fromUrl.toString()
1149
- };
1150
- if (fromUrl.protocol === "file:") {
1151
- if (fileURLToPath) {
1152
- result2.file = fileURLToPath(fromUrl);
1153
- } else {
1154
- throw new Error(`file: protocol is not available in this PostCSS build`);
1127
+ prepend(...children) {
1128
+ children = children.reverse();
1129
+ for (let child of children) {
1130
+ let nodes = this.normalize(child, this.first, "prepend").reverse();
1131
+ for (let node2 of nodes) this.proxyOf.nodes.unshift(node2);
1132
+ for (let id in this.indexes) {
1133
+ this.indexes[id] = this.indexes[id] + nodes.length;
1155
1134
  }
1156
1135
  }
1157
- let source = consumer.sourceContentFor(from.source);
1158
- if (source) result2.source = source;
1159
- return result2;
1136
+ this.markDirty();
1137
+ return this;
1160
1138
  }
1161
- toJSON() {
1162
- let json = {};
1163
- for (let name of ["hasBOM", "css", "file", "id"]) {
1164
- if (this[name] != null) {
1165
- json[name] = this[name];
1166
- }
1167
- }
1168
- if (this.map) {
1169
- json.map = { ...this.map };
1170
- if (json.map.consumerCache) {
1171
- json.map.consumerCache = void 0;
1139
+ push(child) {
1140
+ child.parent = this;
1141
+ this.proxyOf.nodes.push(child);
1142
+ return this;
1143
+ }
1144
+ removeAll() {
1145
+ for (let node2 of this.proxyOf.nodes) node2.parent = void 0;
1146
+ this.proxyOf.nodes = [];
1147
+ this.markDirty();
1148
+ return this;
1149
+ }
1150
+ removeChild(child) {
1151
+ child = this.index(child);
1152
+ this.proxyOf.nodes[child].parent = void 0;
1153
+ this.proxyOf.nodes.splice(child, 1);
1154
+ let index2;
1155
+ for (let id in this.indexes) {
1156
+ index2 = this.indexes[id];
1157
+ if (index2 >= child) {
1158
+ this.indexes[id] = index2 - 1;
1172
1159
  }
1173
1160
  }
1174
- return json;
1161
+ this.markDirty();
1162
+ return this;
1175
1163
  }
1176
- get from() {
1177
- return this.file || this.id;
1164
+ replaceValues(pattern, opts, callback) {
1165
+ if (!callback) {
1166
+ callback = opts;
1167
+ opts = {};
1168
+ }
1169
+ this.walkDecls((decl) => {
1170
+ if (opts.props && !opts.props.includes(decl.prop)) return;
1171
+ if (opts.fast && !decl.value.includes(opts.fast)) return;
1172
+ decl.value = decl.value.replace(pattern, callback);
1173
+ });
1174
+ this.markDirty();
1175
+ return this;
1178
1176
  }
1179
- };
1180
- var input = Input$4;
1181
- Input$4.default = Input$4;
1182
- if (terminalHighlight && terminalHighlight.registerInput) {
1183
- terminalHighlight.registerInput(Input$4);
1184
- }
1185
- let { SourceMapConsumer, SourceMapGenerator } = require$$2;
1186
- let { dirname, relative, resolve, sep } = require$$2;
1187
- let { pathToFileURL } = require$$2;
1188
- let Input$3 = input;
1189
- let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
1190
- let pathAvailable = Boolean(dirname && resolve && relative && sep);
1191
- let MapGenerator$2 = class MapGenerator {
1192
- constructor(stringify2, root2, opts, cssString) {
1193
- this.stringify = stringify2;
1194
- this.mapOpts = opts.map || {};
1195
- this.root = root2;
1196
- this.opts = opts;
1197
- this.css = cssString;
1198
- this.originalCSS = cssString;
1199
- this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
1200
- this.memoizedFileURLs = /* @__PURE__ */ new Map();
1201
- this.memoizedPaths = /* @__PURE__ */ new Map();
1202
- this.memoizedURLs = /* @__PURE__ */ new Map();
1203
- }
1204
- addAnnotation() {
1205
- let content;
1206
- if (this.isInline()) {
1207
- content = "data:application/json;base64," + this.toBase64(this.map.toString());
1208
- } else if (typeof this.mapOpts.annotation === "string") {
1209
- content = this.mapOpts.annotation;
1210
- } else if (typeof this.mapOpts.annotation === "function") {
1211
- content = this.mapOpts.annotation(this.opts.to, this.root);
1212
- } else {
1213
- content = this.outputFile() + ".map";
1214
- }
1215
- let eol = "\n";
1216
- if (this.css.includes("\r\n")) eol = "\r\n";
1217
- this.css += eol + "/*# sourceMappingURL=" + content + " */";
1177
+ some(condition) {
1178
+ return this.nodes.some(condition);
1218
1179
  }
1219
- applyPrevMaps() {
1220
- for (let prev of this.previous()) {
1221
- let from = this.toUrl(this.path(prev.file));
1222
- let root2 = prev.root || dirname(prev.file);
1223
- let map;
1224
- if (this.mapOpts.sourcesContent === false) {
1225
- map = new SourceMapConsumer(prev.text);
1226
- if (map.sourcesContent) {
1227
- map.sourcesContent = null;
1228
- }
1229
- } else {
1230
- map = prev.consumer();
1180
+ walk(callback) {
1181
+ return this.each((child, i) => {
1182
+ let result2;
1183
+ try {
1184
+ result2 = callback(child, i);
1185
+ } catch (e) {
1186
+ throw child.addToError(e);
1231
1187
  }
1232
- this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
1233
- }
1234
- }
1235
- clearAnnotation() {
1236
- if (this.mapOpts.annotation === false) return;
1237
- if (this.root) {
1238
- let node2;
1239
- for (let i = this.root.nodes.length - 1; i >= 0; i--) {
1240
- node2 = this.root.nodes[i];
1241
- if (node2.type !== "comment") continue;
1242
- if (node2.text.indexOf("# sourceMappingURL=") === 0) {
1243
- this.root.removeChild(i);
1244
- }
1188
+ if (result2 !== false && child.walk) {
1189
+ result2 = child.walk(callback);
1245
1190
  }
1246
- } else if (this.css) {
1247
- this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
1248
- }
1191
+ return result2;
1192
+ });
1249
1193
  }
1250
- generate() {
1251
- this.clearAnnotation();
1252
- if (pathAvailable && sourceMapAvailable && this.isMap()) {
1253
- return this.generateMap();
1254
- } else {
1255
- let result2 = "";
1256
- this.stringify(this.root, (i) => {
1257
- result2 += i;
1194
+ walkAtRules(name, callback) {
1195
+ if (!callback) {
1196
+ callback = name;
1197
+ return this.walk((child, i) => {
1198
+ if (child.type === "atrule") {
1199
+ return callback(child, i);
1200
+ }
1258
1201
  });
1259
- return [result2];
1260
1202
  }
1261
- }
1262
- generateMap() {
1263
- if (this.root) {
1264
- this.generateString();
1265
- } else if (this.previous().length === 1) {
1266
- let prev = this.previous()[0].consumer();
1267
- prev.file = this.outputFile();
1268
- this.map = SourceMapGenerator.fromSourceMap(prev, {
1269
- ignoreInvalidMapping: true
1270
- });
1271
- } else {
1272
- this.map = new SourceMapGenerator({
1273
- file: this.outputFile(),
1274
- ignoreInvalidMapping: true
1275
- });
1276
- this.map.addMapping({
1277
- generated: { column: 0, line: 1 },
1278
- original: { column: 0, line: 1 },
1279
- source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
1203
+ if (name instanceof RegExp) {
1204
+ return this.walk((child, i) => {
1205
+ if (child.type === "atrule" && name.test(child.name)) {
1206
+ return callback(child, i);
1207
+ }
1280
1208
  });
1281
1209
  }
1282
- if (this.isSourcesContent()) this.setSourcesContent();
1283
- if (this.root && this.previous().length > 0) this.applyPrevMaps();
1284
- if (this.isAnnotation()) this.addAnnotation();
1285
- if (this.isInline()) {
1286
- return [this.css];
1287
- } else {
1288
- return [this.css, this.map];
1289
- }
1290
- }
1291
- generateString() {
1292
- this.css = "";
1293
- this.map = new SourceMapGenerator({
1294
- file: this.outputFile(),
1295
- ignoreInvalidMapping: true
1296
- });
1297
- let line = 1;
1298
- let column = 1;
1299
- let noSource = "<no source>";
1300
- let mapping = {
1301
- generated: { column: 0, line: 0 },
1302
- original: { column: 0, line: 0 },
1303
- source: ""
1304
- };
1305
- let lines, last;
1306
- this.stringify(this.root, (str, node2, type) => {
1307
- this.css += str;
1308
- if (node2 && type !== "end") {
1309
- mapping.generated.line = line;
1310
- mapping.generated.column = column - 1;
1311
- if (node2.source && node2.source.start) {
1312
- mapping.source = this.sourcePath(node2);
1313
- mapping.original.line = node2.source.start.line;
1314
- mapping.original.column = node2.source.start.column - 1;
1315
- this.map.addMapping(mapping);
1316
- } else {
1317
- mapping.source = noSource;
1318
- mapping.original.line = 1;
1319
- mapping.original.column = 0;
1320
- this.map.addMapping(mapping);
1321
- }
1322
- }
1323
- lines = str.match(/\n/g);
1324
- if (lines) {
1325
- line += lines.length;
1326
- last = str.lastIndexOf("\n");
1327
- column = str.length - last;
1328
- } else {
1329
- column += str.length;
1210
+ return this.walk((child, i) => {
1211
+ if (child.type === "atrule" && child.name === name) {
1212
+ return callback(child, i);
1330
1213
  }
1331
- if (node2 && type !== "start") {
1332
- let p = node2.parent || { raws: {} };
1333
- let childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
1334
- if (!childless || node2 !== p.last || p.raws.semicolon) {
1335
- if (node2.source && node2.source.end) {
1336
- mapping.source = this.sourcePath(node2);
1337
- mapping.original.line = node2.source.end.line;
1338
- mapping.original.column = node2.source.end.column - 1;
1339
- mapping.generated.line = line;
1340
- mapping.generated.column = column - 2;
1341
- this.map.addMapping(mapping);
1342
- } else {
1343
- mapping.source = noSource;
1344
- mapping.original.line = 1;
1345
- mapping.original.column = 0;
1346
- mapping.generated.line = line;
1347
- mapping.generated.column = column - 1;
1348
- this.map.addMapping(mapping);
1349
- }
1350
- }
1214
+ });
1215
+ }
1216
+ walkComments(callback) {
1217
+ return this.walk((child, i) => {
1218
+ if (child.type === "comment") {
1219
+ return callback(child, i);
1351
1220
  }
1352
1221
  });
1353
1222
  }
1354
- isAnnotation() {
1355
- if (this.isInline()) {
1356
- return true;
1357
- }
1358
- if (typeof this.mapOpts.annotation !== "undefined") {
1359
- return this.mapOpts.annotation;
1223
+ walkDecls(prop, callback) {
1224
+ if (!callback) {
1225
+ callback = prop;
1226
+ return this.walk((child, i) => {
1227
+ if (child.type === "decl") {
1228
+ return callback(child, i);
1229
+ }
1230
+ });
1360
1231
  }
1361
- if (this.previous().length) {
1362
- return this.previous().some((i) => i.annotation);
1232
+ if (prop instanceof RegExp) {
1233
+ return this.walk((child, i) => {
1234
+ if (child.type === "decl" && prop.test(child.prop)) {
1235
+ return callback(child, i);
1236
+ }
1237
+ });
1363
1238
  }
1364
- return true;
1239
+ return this.walk((child, i) => {
1240
+ if (child.type === "decl" && child.prop === prop) {
1241
+ return callback(child, i);
1242
+ }
1243
+ });
1365
1244
  }
1366
- isInline() {
1367
- if (typeof this.mapOpts.inline !== "undefined") {
1368
- return this.mapOpts.inline;
1369
- }
1370
- let annotation = this.mapOpts.annotation;
1371
- if (typeof annotation !== "undefined" && annotation !== true) {
1372
- return false;
1245
+ walkRules(selector, callback) {
1246
+ if (!callback) {
1247
+ callback = selector;
1248
+ return this.walk((child, i) => {
1249
+ if (child.type === "rule") {
1250
+ return callback(child, i);
1251
+ }
1252
+ });
1373
1253
  }
1374
- if (this.previous().length) {
1375
- return this.previous().some((i) => i.inline);
1254
+ if (selector instanceof RegExp) {
1255
+ return this.walk((child, i) => {
1256
+ if (child.type === "rule" && selector.test(child.selector)) {
1257
+ return callback(child, i);
1258
+ }
1259
+ });
1376
1260
  }
1377
- return true;
1261
+ return this.walk((child, i) => {
1262
+ if (child.type === "rule" && child.selector === selector) {
1263
+ return callback(child, i);
1264
+ }
1265
+ });
1378
1266
  }
1379
- isMap() {
1380
- if (typeof this.opts.map !== "undefined") {
1381
- return !!this.opts.map;
1382
- }
1383
- return this.previous().length > 0;
1384
- }
1385
- isSourcesContent() {
1386
- if (typeof this.mapOpts.sourcesContent !== "undefined") {
1387
- return this.mapOpts.sourcesContent;
1388
- }
1389
- if (this.previous().length) {
1390
- return this.previous().some((i) => i.withContent());
1391
- }
1392
- return true;
1393
- }
1394
- outputFile() {
1395
- if (this.opts.to) {
1396
- return this.path(this.opts.to);
1397
- } else if (this.opts.from) {
1398
- return this.path(this.opts.from);
1399
- } else {
1400
- return "to.css";
1401
- }
1402
- }
1403
- path(file) {
1404
- if (this.mapOpts.absolute) return file;
1405
- if (file.charCodeAt(0) === 60) return file;
1406
- if (/^\w+:\/\//.test(file)) return file;
1407
- let cached = this.memoizedPaths.get(file);
1408
- if (cached) return cached;
1409
- let from = this.opts.to ? dirname(this.opts.to) : ".";
1410
- if (typeof this.mapOpts.annotation === "string") {
1411
- from = dirname(resolve(from, this.mapOpts.annotation));
1412
- }
1413
- let path = relative(from, file);
1414
- this.memoizedPaths.set(file, path);
1415
- return path;
1267
+ };
1268
+ Container$7.registerParse = (dependant) => {
1269
+ parse$4 = dependant;
1270
+ };
1271
+ Container$7.registerRule = (dependant) => {
1272
+ Rule$4 = dependant;
1273
+ };
1274
+ Container$7.registerAtRule = (dependant) => {
1275
+ AtRule$4 = dependant;
1276
+ };
1277
+ Container$7.registerRoot = (dependant) => {
1278
+ Root$6 = dependant;
1279
+ };
1280
+ var container = Container$7;
1281
+ Container$7.default = Container$7;
1282
+ Container$7.rebuild = (node2) => {
1283
+ if (node2.type === "atrule") {
1284
+ Object.setPrototypeOf(node2, AtRule$4.prototype);
1285
+ } else if (node2.type === "rule") {
1286
+ Object.setPrototypeOf(node2, Rule$4.prototype);
1287
+ } else if (node2.type === "decl") {
1288
+ Object.setPrototypeOf(node2, Declaration$3.prototype);
1289
+ } else if (node2.type === "comment") {
1290
+ Object.setPrototypeOf(node2, Comment$3.prototype);
1291
+ } else if (node2.type === "root") {
1292
+ Object.setPrototypeOf(node2, Root$6.prototype);
1416
1293
  }
1417
- previous() {
1418
- if (!this.previousMaps) {
1419
- this.previousMaps = [];
1420
- if (this.root) {
1421
- this.root.walk((node2) => {
1422
- if (node2.source && node2.source.input.map) {
1423
- let map = node2.source.input.map;
1424
- if (!this.previousMaps.includes(map)) {
1425
- this.previousMaps.push(map);
1426
- }
1427
- }
1428
- });
1429
- } else {
1430
- let input2 = new Input$3(this.originalCSS, this.opts);
1431
- if (input2.map) this.previousMaps.push(input2.map);
1432
- }
1433
- }
1434
- return this.previousMaps;
1294
+ node2[my$1] = true;
1295
+ if (node2.nodes) {
1296
+ node2.nodes.forEach((child) => {
1297
+ Container$7.rebuild(child);
1298
+ });
1435
1299
  }
1436
- setSourcesContent() {
1437
- let already = {};
1438
- if (this.root) {
1439
- this.root.walk((node2) => {
1440
- if (node2.source) {
1441
- let from = node2.source.input.from;
1442
- if (from && !already[from]) {
1443
- already[from] = true;
1444
- let fromUrl = this.usesFileUrls ? this.toFileUrl(from) : this.toUrl(this.path(from));
1445
- this.map.setSourceContent(fromUrl, node2.source.input.css);
1446
- }
1447
- }
1448
- });
1449
- } else if (this.css) {
1450
- let from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
1451
- this.map.setSourceContent(from, this.css);
1452
- }
1300
+ };
1301
+ let Container$6 = container;
1302
+ let AtRule$3 = class AtRule extends Container$6 {
1303
+ constructor(defaults) {
1304
+ super(defaults);
1305
+ this.type = "atrule";
1453
1306
  }
1454
- sourcePath(node2) {
1455
- if (this.mapOpts.from) {
1456
- return this.toUrl(this.mapOpts.from);
1457
- } else if (this.usesFileUrls) {
1458
- return this.toFileUrl(node2.source.input.from);
1459
- } else {
1460
- return this.toUrl(this.path(node2.source.input.from));
1461
- }
1307
+ append(...children) {
1308
+ if (!this.proxyOf.nodes) this.nodes = [];
1309
+ return super.append(...children);
1462
1310
  }
1463
- toBase64(str) {
1464
- if (Buffer) {
1465
- return Buffer.from(str).toString("base64");
1466
- } else {
1467
- return window.btoa(unescape(encodeURIComponent(str)));
1468
- }
1311
+ prepend(...children) {
1312
+ if (!this.proxyOf.nodes) this.nodes = [];
1313
+ return super.prepend(...children);
1469
1314
  }
1470
- toFileUrl(path) {
1471
- let cached = this.memoizedFileURLs.get(path);
1472
- if (cached) return cached;
1473
- if (pathToFileURL) {
1474
- let fileURL = pathToFileURL(path).toString();
1475
- this.memoizedFileURLs.set(path, fileURL);
1476
- return fileURL;
1477
- } else {
1478
- throw new Error(
1479
- "`map.absolute` option is not available in this PostCSS build"
1480
- );
1315
+ };
1316
+ var atRule = AtRule$3;
1317
+ AtRule$3.default = AtRule$3;
1318
+ Container$6.registerAtRule(AtRule$3);
1319
+ let Container$5 = container;
1320
+ let LazyResult$4, Processor$3;
1321
+ let Document$4 = class Document2 extends Container$5 {
1322
+ constructor(defaults) {
1323
+ super({ type: "document", ...defaults });
1324
+ if (!this.nodes) {
1325
+ this.nodes = [];
1481
1326
  }
1482
1327
  }
1483
- toUrl(path) {
1484
- let cached = this.memoizedURLs.get(path);
1485
- if (cached) return cached;
1486
- if (sep === "\\") {
1487
- path = path.replace(/\\/g, "/");
1488
- }
1489
- let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
1490
- this.memoizedURLs.set(path, url);
1491
- return url;
1328
+ toResult(opts = {}) {
1329
+ let lazy = new LazyResult$4(new Processor$3(), this, opts);
1330
+ return lazy.stringify();
1492
1331
  }
1493
1332
  };
1494
- var mapGenerator = MapGenerator$2;
1495
- let Node$3 = node;
1496
- let Comment$4 = class Comment extends Node$3 {
1497
- constructor(defaults) {
1498
- super(defaults);
1499
- this.type = "comment";
1333
+ Document$4.registerLazyResult = (dependant) => {
1334
+ LazyResult$4 = dependant;
1335
+ };
1336
+ Document$4.registerProcessor = (dependant) => {
1337
+ Processor$3 = dependant;
1338
+ };
1339
+ var document$1 = Document$4;
1340
+ Document$4.default = Document$4;
1341
+ let urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1342
+ let nanoid$1 = (size = 21) => {
1343
+ let id = "";
1344
+ let i = size | 0;
1345
+ while (i--) {
1346
+ id += urlAlphabet[Math.random() * 64 | 0];
1500
1347
  }
1348
+ return id;
1501
1349
  };
1502
- var comment = Comment$4;
1503
- Comment$4.default = Comment$4;
1504
- let { isClean: isClean$1, my: my$1 } = symbols;
1505
- let Declaration$3 = declaration;
1506
- let Comment$3 = comment;
1507
- let Node$2 = node;
1508
- let parse$4, Rule$4, AtRule$4, Root$6;
1509
- function cleanSource(nodes) {
1510
- return nodes.map((i) => {
1511
- if (i.nodes) i.nodes = cleanSource(i.nodes);
1512
- delete i.source;
1513
- return i;
1514
- });
1515
- }
1516
- function markDirtyUp(node2) {
1517
- node2[isClean$1] = false;
1518
- if (node2.proxyOf.nodes) {
1519
- for (let i of node2.proxyOf.nodes) {
1520
- markDirtyUp(i);
1521
- }
1350
+ var nonSecure = { nanoid: nanoid$1 };
1351
+ let { existsSync, readFileSync } = require$$2;
1352
+ let { dirname: dirname$1, join } = require$$2;
1353
+ let { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$2 } = require$$2;
1354
+ function fromBase64(str) {
1355
+ if (Buffer) {
1356
+ return Buffer.from(str, "base64").toString();
1357
+ } else {
1358
+ return window.atob(str);
1522
1359
  }
1523
1360
  }
1524
- let Container$7 = class Container extends Node$2 {
1525
- append(...children) {
1526
- for (let child of children) {
1527
- let nodes = this.normalize(child, this.last);
1528
- for (let node2 of nodes) this.proxyOf.nodes.push(node2);
1361
+ let PreviousMap$2 = class PreviousMap {
1362
+ constructor(css, opts) {
1363
+ if (opts.map === false) return;
1364
+ this.loadAnnotation(css);
1365
+ this.inline = this.startWith(this.annotation, "data:");
1366
+ let prev = opts.map ? opts.map.prev : void 0;
1367
+ let text = this.loadMap(opts.from, prev);
1368
+ if (!this.mapFile && opts.from) {
1369
+ this.mapFile = opts.from;
1529
1370
  }
1530
- this.markDirty();
1531
- return this;
1371
+ if (this.mapFile) this.root = dirname$1(this.mapFile);
1372
+ if (text) this.text = text;
1532
1373
  }
1533
- cleanRaws(keepBetween) {
1534
- super.cleanRaws(keepBetween);
1535
- if (this.nodes) {
1536
- for (let node2 of this.nodes) node2.cleanRaws(keepBetween);
1374
+ consumer() {
1375
+ if (!this.consumerCache) {
1376
+ this.consumerCache = new SourceMapConsumer$2(this.text);
1537
1377
  }
1378
+ return this.consumerCache;
1538
1379
  }
1539
- each(callback) {
1540
- if (!this.proxyOf.nodes) return void 0;
1541
- let iterator = this.getIterator();
1542
- let index2, result2;
1543
- while (this.indexes[iterator] < this.proxyOf.nodes.length) {
1544
- index2 = this.indexes[iterator];
1545
- result2 = callback(this.proxyOf.nodes[index2], index2);
1546
- if (result2 === false) break;
1547
- this.indexes[iterator] += 1;
1380
+ decodeInline(text) {
1381
+ let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
1382
+ let baseUri = /^data:application\/json;base64,/;
1383
+ let charsetUri = /^data:application\/json;charset=utf-?8,/;
1384
+ let uri = /^data:application\/json,/;
1385
+ let uriMatch = text.match(charsetUri) || text.match(uri);
1386
+ if (uriMatch) {
1387
+ return decodeURIComponent(text.substr(uriMatch[0].length));
1548
1388
  }
1549
- delete this.indexes[iterator];
1550
- return result2;
1389
+ let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri);
1390
+ if (baseUriMatch) {
1391
+ return fromBase64(text.substr(baseUriMatch[0].length));
1392
+ }
1393
+ let encoding = text.match(/data:application\/json;([^,]+),/)[1];
1394
+ throw new Error("Unsupported source map encoding " + encoding);
1551
1395
  }
1552
- every(condition) {
1553
- return this.nodes.every(condition);
1396
+ getAnnotationURL(sourceMapString) {
1397
+ return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
1554
1398
  }
1555
- getIterator() {
1556
- if (!this.lastEach) this.lastEach = 0;
1557
- if (!this.indexes) this.indexes = {};
1558
- this.lastEach += 1;
1559
- let iterator = this.lastEach;
1560
- this.indexes[iterator] = 0;
1561
- return iterator;
1399
+ isMap(map) {
1400
+ if (typeof map !== "object") return false;
1401
+ return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
1562
1402
  }
1563
- getProxyProcessor() {
1564
- return {
1565
- get(node2, prop) {
1566
- if (prop === "proxyOf") {
1567
- return node2;
1568
- } else if (!node2[prop]) {
1569
- return node2[prop];
1570
- } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
1571
- return (...args) => {
1572
- return node2[prop](
1573
- ...args.map((i) => {
1574
- if (typeof i === "function") {
1575
- return (child, index2) => i(child.toProxy(), index2);
1576
- } else {
1577
- return i;
1578
- }
1579
- })
1580
- );
1581
- };
1582
- } else if (prop === "every" || prop === "some") {
1583
- return (cb) => {
1584
- return node2[prop](
1585
- (child, ...other) => cb(child.toProxy(), ...other)
1403
+ loadAnnotation(css) {
1404
+ let comments = css.match(/\/\*\s*# sourceMappingURL=/g);
1405
+ if (!comments) return;
1406
+ let start = css.lastIndexOf(comments.pop());
1407
+ let end = css.indexOf("*/", start);
1408
+ if (start > -1 && end > -1) {
1409
+ this.annotation = this.getAnnotationURL(css.substring(start, end));
1410
+ }
1411
+ }
1412
+ loadFile(path) {
1413
+ this.root = dirname$1(path);
1414
+ if (existsSync(path)) {
1415
+ this.mapFile = path;
1416
+ return readFileSync(path, "utf-8").toString().trim();
1417
+ }
1418
+ }
1419
+ loadMap(file, prev) {
1420
+ if (prev === false) return false;
1421
+ if (prev) {
1422
+ if (typeof prev === "string") {
1423
+ return prev;
1424
+ } else if (typeof prev === "function") {
1425
+ let prevPath = prev(file);
1426
+ if (prevPath) {
1427
+ let map = this.loadFile(prevPath);
1428
+ if (!map) {
1429
+ throw new Error(
1430
+ "Unable to load previous source map: " + prevPath.toString()
1586
1431
  );
1587
- };
1588
- } else if (prop === "root") {
1589
- return () => node2.root().toProxy();
1590
- } else if (prop === "nodes") {
1591
- return node2.nodes.map((i) => i.toProxy());
1592
- } else if (prop === "first" || prop === "last") {
1593
- return node2[prop].toProxy();
1594
- } else {
1595
- return node2[prop];
1596
- }
1597
- },
1598
- set(node2, prop, value) {
1599
- if (node2[prop] === value) return true;
1600
- node2[prop] = value;
1601
- if (prop === "name" || prop === "params" || prop === "selector") {
1602
- node2.markDirty();
1432
+ }
1433
+ return map;
1603
1434
  }
1604
- return true;
1435
+ } else if (prev instanceof SourceMapConsumer$2) {
1436
+ return SourceMapGenerator$2.fromSourceMap(prev).toString();
1437
+ } else if (prev instanceof SourceMapGenerator$2) {
1438
+ return prev.toString();
1439
+ } else if (this.isMap(prev)) {
1440
+ return JSON.stringify(prev);
1441
+ } else {
1442
+ throw new Error(
1443
+ "Unsupported previous source map format: " + prev.toString()
1444
+ );
1605
1445
  }
1606
- };
1446
+ } else if (this.inline) {
1447
+ return this.decodeInline(this.annotation);
1448
+ } else if (this.annotation) {
1449
+ let map = this.annotation;
1450
+ if (file) map = join(dirname$1(file), map);
1451
+ return this.loadFile(map);
1452
+ }
1607
1453
  }
1608
- index(child) {
1609
- if (typeof child === "number") return child;
1610
- if (child.proxyOf) child = child.proxyOf;
1611
- return this.proxyOf.nodes.indexOf(child);
1454
+ startWith(string, start) {
1455
+ if (!string) return false;
1456
+ return string.substr(0, start.length) === start;
1612
1457
  }
1613
- insertAfter(exist, add) {
1614
- let existIndex = this.index(exist);
1615
- let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
1616
- existIndex = this.index(exist);
1617
- for (let node2 of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
1618
- let index2;
1619
- for (let id in this.indexes) {
1620
- index2 = this.indexes[id];
1621
- if (existIndex < index2) {
1622
- this.indexes[id] = index2 + nodes.length;
1458
+ withContent() {
1459
+ return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
1460
+ }
1461
+ };
1462
+ var previousMap = PreviousMap$2;
1463
+ PreviousMap$2.default = PreviousMap$2;
1464
+ let { nanoid } = nonSecure;
1465
+ let { isAbsolute, resolve: resolve$1 } = require$$2;
1466
+ let { SourceMapConsumer: SourceMapConsumer$1, SourceMapGenerator: SourceMapGenerator$1 } = require$$2;
1467
+ let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
1468
+ let CssSyntaxError$1 = cssSyntaxError;
1469
+ let PreviousMap$1 = previousMap;
1470
+ let terminalHighlight = require$$2;
1471
+ let lineToIndexCache = Symbol("lineToIndexCache");
1472
+ let sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
1473
+ let pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
1474
+ function getLineToIndex(input2) {
1475
+ if (input2[lineToIndexCache]) return input2[lineToIndexCache];
1476
+ let lines = input2.css.split("\n");
1477
+ let lineToIndex = new Array(lines.length);
1478
+ let prevIndex = 0;
1479
+ for (let i = 0, l = lines.length; i < l; i++) {
1480
+ lineToIndex[i] = prevIndex;
1481
+ prevIndex += lines[i].length + 1;
1482
+ }
1483
+ input2[lineToIndexCache] = lineToIndex;
1484
+ return lineToIndex;
1485
+ }
1486
+ let Input$4 = class Input {
1487
+ get from() {
1488
+ return this.file || this.id;
1489
+ }
1490
+ constructor(css, opts = {}) {
1491
+ if (css === null || typeof css === "undefined" || typeof css === "object" && !css.toString) {
1492
+ throw new Error(`PostCSS received ${css} instead of CSS string`);
1493
+ }
1494
+ this.css = css.toString();
1495
+ if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
1496
+ this.hasBOM = true;
1497
+ this.css = this.css.slice(1);
1498
+ } else {
1499
+ this.hasBOM = false;
1500
+ }
1501
+ this.document = this.css;
1502
+ if (opts.document) this.document = opts.document.toString();
1503
+ if (opts.from) {
1504
+ if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
1505
+ this.file = opts.from;
1506
+ } else {
1507
+ this.file = resolve$1(opts.from);
1623
1508
  }
1624
1509
  }
1625
- this.markDirty();
1626
- return this;
1627
- }
1628
- insertBefore(exist, add) {
1629
- let existIndex = this.index(exist);
1630
- let type = existIndex === 0 ? "prepend" : false;
1631
- let nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
1632
- existIndex = this.index(exist);
1633
- for (let node2 of nodes) this.proxyOf.nodes.splice(existIndex, 0, node2);
1634
- let index2;
1635
- for (let id in this.indexes) {
1636
- index2 = this.indexes[id];
1637
- if (existIndex <= index2) {
1638
- this.indexes[id] = index2 + nodes.length;
1510
+ if (pathAvailable$1 && sourceMapAvailable$1) {
1511
+ let map = new PreviousMap$1(this.css, opts);
1512
+ if (map.text) {
1513
+ this.map = map;
1514
+ let file = map.consumer().file;
1515
+ if (!this.file && file) this.file = this.mapResolve(file);
1639
1516
  }
1640
1517
  }
1641
- this.markDirty();
1642
- return this;
1518
+ if (!this.file) {
1519
+ this.id = "<input css " + nanoid(6) + ">";
1520
+ }
1521
+ if (this.map) this.map.file = this.from;
1643
1522
  }
1644
- normalize(nodes, sample) {
1645
- if (typeof nodes === "string") {
1646
- nodes = cleanSource(parse$4(nodes).nodes);
1647
- } else if (typeof nodes === "undefined") {
1648
- nodes = [];
1649
- } else if (Array.isArray(nodes)) {
1650
- nodes = nodes.slice(0);
1651
- for (let i of nodes) {
1652
- if (i.parent) i.parent.removeChild(i, "ignore");
1523
+ error(message, line, column, opts = {}) {
1524
+ let endColumn, endLine, endOffset, offset, result2;
1525
+ if (line && typeof line === "object") {
1526
+ let start = line;
1527
+ let end = column;
1528
+ if (typeof start.offset === "number") {
1529
+ offset = start.offset;
1530
+ let pos = this.fromOffset(offset);
1531
+ line = pos.line;
1532
+ column = pos.col;
1533
+ } else {
1534
+ line = start.line;
1535
+ column = start.column;
1536
+ offset = this.fromLineAndColumn(line, column);
1653
1537
  }
1654
- } else if (nodes.type === "root" && this.type !== "document") {
1655
- nodes = nodes.nodes.slice(0);
1656
- for (let i of nodes) {
1657
- if (i.parent) i.parent.removeChild(i, "ignore");
1538
+ if (typeof end.offset === "number") {
1539
+ endOffset = end.offset;
1540
+ let pos = this.fromOffset(endOffset);
1541
+ endLine = pos.line;
1542
+ endColumn = pos.col;
1543
+ } else {
1544
+ endLine = end.line;
1545
+ endColumn = end.column;
1546
+ endOffset = this.fromLineAndColumn(end.line, end.column);
1658
1547
  }
1659
- } else if (nodes.type) {
1660
- nodes = [nodes];
1661
- } else if (nodes.prop) {
1662
- if (typeof nodes.value === "undefined") {
1663
- throw new Error("Value field is missed in node creation");
1664
- } else if (typeof nodes.value !== "string") {
1665
- nodes.value = String(nodes.value);
1548
+ } else if (!column) {
1549
+ offset = line;
1550
+ let pos = this.fromOffset(offset);
1551
+ line = pos.line;
1552
+ column = pos.col;
1553
+ } else {
1554
+ offset = this.fromLineAndColumn(line, column);
1555
+ }
1556
+ let origin = this.origin(line, column, endLine, endColumn);
1557
+ if (origin) {
1558
+ result2 = new CssSyntaxError$1(
1559
+ message,
1560
+ origin.endLine === void 0 ? origin.line : { column: origin.column, line: origin.line },
1561
+ origin.endLine === void 0 ? origin.column : { column: origin.endColumn, line: origin.endLine },
1562
+ origin.source,
1563
+ origin.file,
1564
+ opts.plugin
1565
+ );
1566
+ } else {
1567
+ result2 = new CssSyntaxError$1(
1568
+ message,
1569
+ endLine === void 0 ? line : { column, line },
1570
+ endLine === void 0 ? column : { column: endColumn, line: endLine },
1571
+ this.css,
1572
+ this.file,
1573
+ opts.plugin
1574
+ );
1575
+ }
1576
+ result2.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css };
1577
+ if (this.file) {
1578
+ if (pathToFileURL$1) {
1579
+ result2.input.url = pathToFileURL$1(this.file).toString();
1666
1580
  }
1667
- nodes = [new Declaration$3(nodes)];
1668
- } else if (nodes.selector) {
1669
- nodes = [new Rule$4(nodes)];
1670
- } else if (nodes.name) {
1671
- nodes = [new AtRule$4(nodes)];
1672
- } else if (nodes.text) {
1673
- nodes = [new Comment$3(nodes)];
1581
+ result2.input.file = this.file;
1582
+ }
1583
+ return result2;
1584
+ }
1585
+ fromLineAndColumn(line, column) {
1586
+ let lineToIndex = getLineToIndex(this);
1587
+ let index2 = lineToIndex[line - 1];
1588
+ return index2 + column - 1;
1589
+ }
1590
+ fromOffset(offset) {
1591
+ let lineToIndex = getLineToIndex(this);
1592
+ let lastLine = lineToIndex[lineToIndex.length - 1];
1593
+ let min = 0;
1594
+ if (offset >= lastLine) {
1595
+ min = lineToIndex.length - 1;
1674
1596
  } else {
1675
- throw new Error("Unknown node type in node creation");
1597
+ let max = lineToIndex.length - 2;
1598
+ let mid;
1599
+ while (min < max) {
1600
+ mid = min + (max - min >> 1);
1601
+ if (offset < lineToIndex[mid]) {
1602
+ max = mid - 1;
1603
+ } else if (offset >= lineToIndex[mid + 1]) {
1604
+ min = mid + 1;
1605
+ } else {
1606
+ min = mid;
1607
+ break;
1608
+ }
1609
+ }
1676
1610
  }
1677
- let processed = nodes.map((i) => {
1678
- if (!i[my$1]) Container.rebuild(i);
1679
- i = i.proxyOf;
1680
- if (i.parent) i.parent.removeChild(i);
1681
- if (i[isClean$1]) markDirtyUp(i);
1682
- if (typeof i.raws.before === "undefined") {
1683
- if (sample && typeof sample.raws.before !== "undefined") {
1684
- i.raws.before = sample.raws.before.replace(/\S/g, "");
1611
+ return {
1612
+ col: offset - lineToIndex[min] + 1,
1613
+ line: min + 1
1614
+ };
1615
+ }
1616
+ mapResolve(file) {
1617
+ if (/^\w+:\/\//.test(file)) {
1618
+ return file;
1619
+ }
1620
+ return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
1621
+ }
1622
+ origin(line, column, endLine, endColumn) {
1623
+ if (!this.map) return false;
1624
+ let consumer = this.map.consumer();
1625
+ let from = consumer.originalPositionFor({ column, line });
1626
+ if (!from.source) return false;
1627
+ let to;
1628
+ if (typeof endLine === "number") {
1629
+ to = consumer.originalPositionFor({ column: endColumn, line: endLine });
1630
+ }
1631
+ let fromUrl;
1632
+ if (isAbsolute(from.source)) {
1633
+ fromUrl = pathToFileURL$1(from.source);
1634
+ } else {
1635
+ fromUrl = new URL(
1636
+ from.source,
1637
+ this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile)
1638
+ );
1639
+ }
1640
+ let result2 = {
1641
+ column: from.column,
1642
+ endColumn: to && to.column,
1643
+ endLine: to && to.line,
1644
+ line: from.line,
1645
+ url: fromUrl.toString()
1646
+ };
1647
+ if (fromUrl.protocol === "file:") {
1648
+ if (fileURLToPath) {
1649
+ result2.file = fileURLToPath(fromUrl);
1650
+ } else {
1651
+ throw new Error(`file: protocol is not available in this PostCSS build`);
1652
+ }
1653
+ }
1654
+ let source = consumer.sourceContentFor(from.source);
1655
+ if (source) result2.source = source;
1656
+ return result2;
1657
+ }
1658
+ toJSON() {
1659
+ let json = {};
1660
+ for (let name of ["hasBOM", "css", "file", "id"]) {
1661
+ if (this[name] != null) {
1662
+ json[name] = this[name];
1663
+ }
1664
+ }
1665
+ if (this.map) {
1666
+ json.map = { ...this.map };
1667
+ if (json.map.consumerCache) {
1668
+ json.map.consumerCache = void 0;
1669
+ }
1670
+ }
1671
+ return json;
1672
+ }
1673
+ };
1674
+ var input = Input$4;
1675
+ Input$4.default = Input$4;
1676
+ if (terminalHighlight && terminalHighlight.registerInput) {
1677
+ terminalHighlight.registerInput(Input$4);
1678
+ }
1679
+ let Container$4 = container;
1680
+ let LazyResult$3, Processor$2;
1681
+ let Root$5 = class Root extends Container$4 {
1682
+ constructor(defaults) {
1683
+ super(defaults);
1684
+ this.type = "root";
1685
+ if (!this.nodes) this.nodes = [];
1686
+ }
1687
+ normalize(child, sample, type) {
1688
+ let nodes = super.normalize(child);
1689
+ if (sample) {
1690
+ if (type === "prepend") {
1691
+ if (this.nodes.length > 1) {
1692
+ sample.raws.before = this.nodes[1].raws.before;
1693
+ } else {
1694
+ delete sample.raws.before;
1695
+ }
1696
+ } else if (this.first !== sample) {
1697
+ for (let node2 of nodes) {
1698
+ node2.raws.before = sample.raws.before;
1685
1699
  }
1686
1700
  }
1687
- i.parent = this.proxyOf;
1688
- return i;
1689
- });
1690
- return processed;
1701
+ }
1702
+ return nodes;
1691
1703
  }
1692
- prepend(...children) {
1693
- children = children.reverse();
1694
- for (let child of children) {
1695
- let nodes = this.normalize(child, this.first, "prepend").reverse();
1696
- for (let node2 of nodes) this.proxyOf.nodes.unshift(node2);
1697
- for (let id in this.indexes) {
1698
- this.indexes[id] = this.indexes[id] + nodes.length;
1704
+ removeChild(child, ignore) {
1705
+ let index2 = this.index(child);
1706
+ if (!ignore && index2 === 0 && this.nodes.length > 1) {
1707
+ this.nodes[1].raws.before = this.nodes[index2].raws.before;
1708
+ }
1709
+ return super.removeChild(child);
1710
+ }
1711
+ toResult(opts = {}) {
1712
+ let lazy = new LazyResult$3(new Processor$2(), this, opts);
1713
+ return lazy.stringify();
1714
+ }
1715
+ };
1716
+ Root$5.registerLazyResult = (dependant) => {
1717
+ LazyResult$3 = dependant;
1718
+ };
1719
+ Root$5.registerProcessor = (dependant) => {
1720
+ Processor$2 = dependant;
1721
+ };
1722
+ var root = Root$5;
1723
+ Root$5.default = Root$5;
1724
+ Container$4.registerRoot(Root$5);
1725
+ let list$2 = {
1726
+ comma(string) {
1727
+ return list$2.split(string, [","], true);
1728
+ },
1729
+ space(string) {
1730
+ let spaces = [" ", "\n", " "];
1731
+ return list$2.split(string, spaces);
1732
+ },
1733
+ split(string, separators, last) {
1734
+ let array = [];
1735
+ let current = "";
1736
+ let split = false;
1737
+ let func = 0;
1738
+ let inQuote = false;
1739
+ let prevQuote = "";
1740
+ let escape = false;
1741
+ for (let letter of string) {
1742
+ if (escape) {
1743
+ escape = false;
1744
+ } else if (letter === "\\") {
1745
+ escape = true;
1746
+ } else if (inQuote) {
1747
+ if (letter === prevQuote) {
1748
+ inQuote = false;
1749
+ }
1750
+ } else if (letter === '"' || letter === "'") {
1751
+ inQuote = true;
1752
+ prevQuote = letter;
1753
+ } else if (letter === "(") {
1754
+ func += 1;
1755
+ } else if (letter === ")") {
1756
+ if (func > 0) func -= 1;
1757
+ } else if (func === 0) {
1758
+ if (separators.includes(letter)) split = true;
1759
+ }
1760
+ if (split) {
1761
+ if (current !== "") array.push(current.trim());
1762
+ current = "";
1763
+ split = false;
1764
+ } else {
1765
+ current += letter;
1699
1766
  }
1700
1767
  }
1701
- this.markDirty();
1702
- return this;
1768
+ if (last || current !== "") array.push(current.trim());
1769
+ return array;
1703
1770
  }
1704
- push(child) {
1705
- child.parent = this;
1706
- this.proxyOf.nodes.push(child);
1707
- return this;
1771
+ };
1772
+ var list_1 = list$2;
1773
+ list$2.default = list$2;
1774
+ let Container$3 = container;
1775
+ let list$1 = list_1;
1776
+ let Rule$3 = class Rule extends Container$3 {
1777
+ get selectors() {
1778
+ return list$1.comma(this.selector);
1708
1779
  }
1709
- removeAll() {
1710
- for (let node2 of this.proxyOf.nodes) node2.parent = void 0;
1711
- this.proxyOf.nodes = [];
1712
- this.markDirty();
1713
- return this;
1780
+ set selectors(values) {
1781
+ let match = this.selector ? this.selector.match(/,\s*/) : null;
1782
+ let sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
1783
+ this.selector = values.join(sep2);
1714
1784
  }
1715
- removeChild(child) {
1716
- child = this.index(child);
1717
- this.proxyOf.nodes[child].parent = void 0;
1718
- this.proxyOf.nodes.splice(child, 1);
1719
- let index2;
1720
- for (let id in this.indexes) {
1721
- index2 = this.indexes[id];
1722
- if (index2 >= child) {
1723
- this.indexes[id] = index2 - 1;
1785
+ constructor(defaults) {
1786
+ super(defaults);
1787
+ this.type = "rule";
1788
+ if (!this.nodes) this.nodes = [];
1789
+ }
1790
+ };
1791
+ var rule = Rule$3;
1792
+ Rule$3.default = Rule$3;
1793
+ Container$3.registerRule(Rule$3);
1794
+ let AtRule$2 = atRule;
1795
+ let Comment$2 = comment;
1796
+ let Declaration$2 = declaration;
1797
+ let Input$3 = input;
1798
+ let PreviousMap2 = previousMap;
1799
+ let Root$4 = root;
1800
+ let Rule$2 = rule;
1801
+ function fromJSON$1(json, inputs) {
1802
+ if (Array.isArray(json)) return json.map((n) => fromJSON$1(n));
1803
+ let { inputs: ownInputs, ...defaults } = json;
1804
+ if (ownInputs) {
1805
+ inputs = [];
1806
+ for (let input2 of ownInputs) {
1807
+ let inputHydrated = { ...input2, __proto__: Input$3.prototype };
1808
+ if (inputHydrated.map) {
1809
+ inputHydrated.map = {
1810
+ ...inputHydrated.map,
1811
+ __proto__: PreviousMap2.prototype
1812
+ };
1724
1813
  }
1814
+ inputs.push(inputHydrated);
1725
1815
  }
1726
- this.markDirty();
1727
- return this;
1728
1816
  }
1729
- replaceValues(pattern, opts, callback) {
1730
- if (!callback) {
1731
- callback = opts;
1732
- opts = {};
1817
+ if (defaults.nodes) {
1818
+ defaults.nodes = json.nodes.map((n) => fromJSON$1(n, inputs));
1819
+ }
1820
+ if (defaults.source) {
1821
+ let { inputId, ...source } = defaults.source;
1822
+ defaults.source = source;
1823
+ if (inputId != null) {
1824
+ defaults.source.input = inputs[inputId];
1733
1825
  }
1734
- this.walkDecls((decl) => {
1735
- if (opts.props && !opts.props.includes(decl.prop)) return;
1736
- if (opts.fast && !decl.value.includes(opts.fast)) return;
1737
- decl.value = decl.value.replace(pattern, callback);
1738
- });
1739
- this.markDirty();
1740
- return this;
1741
1826
  }
1742
- some(condition) {
1743
- return this.nodes.some(condition);
1827
+ if (defaults.type === "root") {
1828
+ return new Root$4(defaults);
1829
+ } else if (defaults.type === "decl") {
1830
+ return new Declaration$2(defaults);
1831
+ } else if (defaults.type === "rule") {
1832
+ return new Rule$2(defaults);
1833
+ } else if (defaults.type === "comment") {
1834
+ return new Comment$2(defaults);
1835
+ } else if (defaults.type === "atrule") {
1836
+ return new AtRule$2(defaults);
1837
+ } else {
1838
+ throw new Error("Unknown node type: " + json.type);
1744
1839
  }
1745
- walk(callback) {
1746
- return this.each((child, i) => {
1747
- let result2;
1748
- try {
1749
- result2 = callback(child, i);
1750
- } catch (e) {
1751
- throw child.addToError(e);
1752
- }
1753
- if (result2 !== false && child.walk) {
1754
- result2 = child.walk(callback);
1840
+ }
1841
+ var fromJSON_1 = fromJSON$1;
1842
+ fromJSON$1.default = fromJSON$1;
1843
+ let { dirname, relative, resolve, sep } = require$$2;
1844
+ let { SourceMapConsumer, SourceMapGenerator } = require$$2;
1845
+ let { pathToFileURL } = require$$2;
1846
+ let Input$2 = input;
1847
+ let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
1848
+ let pathAvailable = Boolean(dirname && resolve && relative && sep);
1849
+ let MapGenerator$2 = class MapGenerator {
1850
+ constructor(stringify2, root2, opts, cssString) {
1851
+ this.stringify = stringify2;
1852
+ this.mapOpts = opts.map || {};
1853
+ this.root = root2;
1854
+ this.opts = opts;
1855
+ this.css = cssString;
1856
+ this.originalCSS = cssString;
1857
+ this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
1858
+ this.memoizedFileURLs = /* @__PURE__ */ new Map();
1859
+ this.memoizedPaths = /* @__PURE__ */ new Map();
1860
+ this.memoizedURLs = /* @__PURE__ */ new Map();
1861
+ }
1862
+ addAnnotation() {
1863
+ let content;
1864
+ if (this.isInline()) {
1865
+ content = "data:application/json;base64," + this.toBase64(this.map.toString());
1866
+ } else if (typeof this.mapOpts.annotation === "string") {
1867
+ content = this.mapOpts.annotation;
1868
+ } else if (typeof this.mapOpts.annotation === "function") {
1869
+ content = this.mapOpts.annotation(this.opts.to, this.root);
1870
+ } else {
1871
+ content = this.outputFile() + ".map";
1872
+ }
1873
+ let eol = "\n";
1874
+ if (this.css.includes("\r\n")) eol = "\r\n";
1875
+ this.css += eol + "/*# sourceMappingURL=" + content + " */";
1876
+ }
1877
+ applyPrevMaps() {
1878
+ for (let prev of this.previous()) {
1879
+ let from = this.toUrl(this.path(prev.file));
1880
+ let root2 = prev.root || dirname(prev.file);
1881
+ let map;
1882
+ if (this.mapOpts.sourcesContent === false) {
1883
+ map = new SourceMapConsumer(prev.text);
1884
+ if (map.sourcesContent) {
1885
+ map.sourcesContent = null;
1886
+ }
1887
+ } else {
1888
+ map = prev.consumer();
1755
1889
  }
1756
- return result2;
1757
- });
1890
+ this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
1891
+ }
1758
1892
  }
1759
- walkAtRules(name, callback) {
1760
- if (!callback) {
1761
- callback = name;
1762
- return this.walk((child, i) => {
1763
- if (child.type === "atrule") {
1764
- return callback(child, i);
1893
+ clearAnnotation() {
1894
+ if (this.mapOpts.annotation === false) return;
1895
+ if (this.root) {
1896
+ let node2;
1897
+ for (let i = this.root.nodes.length - 1; i >= 0; i--) {
1898
+ node2 = this.root.nodes[i];
1899
+ if (node2.type !== "comment") continue;
1900
+ if (node2.text.startsWith("# sourceMappingURL=")) {
1901
+ this.root.removeChild(i);
1765
1902
  }
1903
+ }
1904
+ } else if (this.css) {
1905
+ this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, "");
1906
+ }
1907
+ }
1908
+ generate() {
1909
+ this.clearAnnotation();
1910
+ if (pathAvailable && sourceMapAvailable && this.isMap()) {
1911
+ return this.generateMap();
1912
+ } else {
1913
+ let result2 = "";
1914
+ this.stringify(this.root, (i) => {
1915
+ result2 += i;
1766
1916
  });
1917
+ return [result2];
1767
1918
  }
1768
- if (name instanceof RegExp) {
1769
- return this.walk((child, i) => {
1770
- if (child.type === "atrule" && name.test(child.name)) {
1771
- return callback(child, i);
1772
- }
1919
+ }
1920
+ generateMap() {
1921
+ if (this.root) {
1922
+ this.generateString();
1923
+ } else if (this.previous().length === 1) {
1924
+ let prev = this.previous()[0].consumer();
1925
+ prev.file = this.outputFile();
1926
+ this.map = SourceMapGenerator.fromSourceMap(prev, {
1927
+ ignoreInvalidMapping: true
1928
+ });
1929
+ } else {
1930
+ this.map = new SourceMapGenerator({
1931
+ file: this.outputFile(),
1932
+ ignoreInvalidMapping: true
1933
+ });
1934
+ this.map.addMapping({
1935
+ generated: { column: 0, line: 1 },
1936
+ original: { column: 0, line: 1 },
1937
+ source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
1773
1938
  });
1774
1939
  }
1775
- return this.walk((child, i) => {
1776
- if (child.type === "atrule" && child.name === name) {
1777
- return callback(child, i);
1940
+ if (this.isSourcesContent()) this.setSourcesContent();
1941
+ if (this.root && this.previous().length > 0) this.applyPrevMaps();
1942
+ if (this.isAnnotation()) this.addAnnotation();
1943
+ if (this.isInline()) {
1944
+ return [this.css];
1945
+ } else {
1946
+ return [this.css, this.map];
1947
+ }
1948
+ }
1949
+ generateString() {
1950
+ this.css = "";
1951
+ this.map = new SourceMapGenerator({
1952
+ file: this.outputFile(),
1953
+ ignoreInvalidMapping: true
1954
+ });
1955
+ let line = 1;
1956
+ let column = 1;
1957
+ let noSource = "<no source>";
1958
+ let mapping = {
1959
+ generated: { column: 0, line: 0 },
1960
+ original: { column: 0, line: 0 },
1961
+ source: ""
1962
+ };
1963
+ let last, lines;
1964
+ this.stringify(this.root, (str, node2, type) => {
1965
+ this.css += str;
1966
+ if (node2 && type !== "end") {
1967
+ mapping.generated.line = line;
1968
+ mapping.generated.column = column - 1;
1969
+ if (node2.source && node2.source.start) {
1970
+ mapping.source = this.sourcePath(node2);
1971
+ mapping.original.line = node2.source.start.line;
1972
+ mapping.original.column = node2.source.start.column - 1;
1973
+ this.map.addMapping(mapping);
1974
+ } else {
1975
+ mapping.source = noSource;
1976
+ mapping.original.line = 1;
1977
+ mapping.original.column = 0;
1978
+ this.map.addMapping(mapping);
1979
+ }
1980
+ }
1981
+ lines = str.match(/\n/g);
1982
+ if (lines) {
1983
+ line += lines.length;
1984
+ last = str.lastIndexOf("\n");
1985
+ column = str.length - last;
1986
+ } else {
1987
+ column += str.length;
1778
1988
  }
1779
- });
1780
- }
1781
- walkComments(callback) {
1782
- return this.walk((child, i) => {
1783
- if (child.type === "comment") {
1784
- return callback(child, i);
1989
+ if (node2 && type !== "start") {
1990
+ let p = node2.parent || { raws: {} };
1991
+ let childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
1992
+ if (!childless || node2 !== p.last || p.raws.semicolon) {
1993
+ if (node2.source && node2.source.end) {
1994
+ mapping.source = this.sourcePath(node2);
1995
+ mapping.original.line = node2.source.end.line;
1996
+ mapping.original.column = node2.source.end.column - 1;
1997
+ mapping.generated.line = line;
1998
+ mapping.generated.column = column - 2;
1999
+ this.map.addMapping(mapping);
2000
+ } else {
2001
+ mapping.source = noSource;
2002
+ mapping.original.line = 1;
2003
+ mapping.original.column = 0;
2004
+ mapping.generated.line = line;
2005
+ mapping.generated.column = column - 1;
2006
+ this.map.addMapping(mapping);
2007
+ }
2008
+ }
1785
2009
  }
1786
2010
  });
1787
2011
  }
1788
- walkDecls(prop, callback) {
1789
- if (!callback) {
1790
- callback = prop;
1791
- return this.walk((child, i) => {
1792
- if (child.type === "decl") {
1793
- return callback(child, i);
1794
- }
1795
- });
2012
+ isAnnotation() {
2013
+ if (this.isInline()) {
2014
+ return true;
1796
2015
  }
1797
- if (prop instanceof RegExp) {
1798
- return this.walk((child, i) => {
1799
- if (child.type === "decl" && prop.test(child.prop)) {
1800
- return callback(child, i);
1801
- }
1802
- });
2016
+ if (typeof this.mapOpts.annotation !== "undefined") {
2017
+ return this.mapOpts.annotation;
1803
2018
  }
1804
- return this.walk((child, i) => {
1805
- if (child.type === "decl" && child.prop === prop) {
1806
- return callback(child, i);
1807
- }
1808
- });
2019
+ if (this.previous().length) {
2020
+ return this.previous().some((i) => i.annotation);
2021
+ }
2022
+ return true;
1809
2023
  }
1810
- walkRules(selector, callback) {
1811
- if (!callback) {
1812
- callback = selector;
1813
- return this.walk((child, i) => {
1814
- if (child.type === "rule") {
1815
- return callback(child, i);
1816
- }
1817
- });
2024
+ isInline() {
2025
+ if (typeof this.mapOpts.inline !== "undefined") {
2026
+ return this.mapOpts.inline;
1818
2027
  }
1819
- if (selector instanceof RegExp) {
1820
- return this.walk((child, i) => {
1821
- if (child.type === "rule" && selector.test(child.selector)) {
1822
- return callback(child, i);
1823
- }
1824
- });
2028
+ let annotation = this.mapOpts.annotation;
2029
+ if (typeof annotation !== "undefined" && annotation !== true) {
2030
+ return false;
1825
2031
  }
1826
- return this.walk((child, i) => {
1827
- if (child.type === "rule" && child.selector === selector) {
1828
- return callback(child, i);
1829
- }
1830
- });
1831
- }
1832
- get first() {
1833
- if (!this.proxyOf.nodes) return void 0;
1834
- return this.proxyOf.nodes[0];
1835
- }
1836
- get last() {
1837
- if (!this.proxyOf.nodes) return void 0;
1838
- return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
1839
- }
1840
- };
1841
- Container$7.registerParse = (dependant) => {
1842
- parse$4 = dependant;
1843
- };
1844
- Container$7.registerRule = (dependant) => {
1845
- Rule$4 = dependant;
1846
- };
1847
- Container$7.registerAtRule = (dependant) => {
1848
- AtRule$4 = dependant;
1849
- };
1850
- Container$7.registerRoot = (dependant) => {
1851
- Root$6 = dependant;
1852
- };
1853
- var container = Container$7;
1854
- Container$7.default = Container$7;
1855
- Container$7.rebuild = (node2) => {
1856
- if (node2.type === "atrule") {
1857
- Object.setPrototypeOf(node2, AtRule$4.prototype);
1858
- } else if (node2.type === "rule") {
1859
- Object.setPrototypeOf(node2, Rule$4.prototype);
1860
- } else if (node2.type === "decl") {
1861
- Object.setPrototypeOf(node2, Declaration$3.prototype);
1862
- } else if (node2.type === "comment") {
1863
- Object.setPrototypeOf(node2, Comment$3.prototype);
1864
- } else if (node2.type === "root") {
1865
- Object.setPrototypeOf(node2, Root$6.prototype);
1866
- }
1867
- node2[my$1] = true;
1868
- if (node2.nodes) {
1869
- node2.nodes.forEach((child) => {
1870
- Container$7.rebuild(child);
1871
- });
1872
- }
1873
- };
1874
- let Container$6 = container;
1875
- let LazyResult$4, Processor$3;
1876
- let Document$3 = class Document2 extends Container$6 {
1877
- constructor(defaults) {
1878
- super({ type: "document", ...defaults });
1879
- if (!this.nodes) {
1880
- this.nodes = [];
2032
+ if (this.previous().length) {
2033
+ return this.previous().some((i) => i.inline);
1881
2034
  }
2035
+ return true;
1882
2036
  }
1883
- toResult(opts = {}) {
1884
- let lazy = new LazyResult$4(new Processor$3(), this, opts);
1885
- return lazy.stringify();
2037
+ isMap() {
2038
+ if (typeof this.opts.map !== "undefined") {
2039
+ return !!this.opts.map;
2040
+ }
2041
+ return this.previous().length > 0;
1886
2042
  }
1887
- };
1888
- Document$3.registerLazyResult = (dependant) => {
1889
- LazyResult$4 = dependant;
1890
- };
1891
- Document$3.registerProcessor = (dependant) => {
1892
- Processor$3 = dependant;
1893
- };
1894
- var document$1 = Document$3;
1895
- Document$3.default = Document$3;
1896
- let printed = {};
1897
- var warnOnce$2 = function warnOnce(message) {
1898
- if (printed[message]) return;
1899
- printed[message] = true;
1900
- if (typeof console !== "undefined" && console.warn) {
1901
- console.warn(message);
2043
+ isSourcesContent() {
2044
+ if (typeof this.mapOpts.sourcesContent !== "undefined") {
2045
+ return this.mapOpts.sourcesContent;
2046
+ }
2047
+ if (this.previous().length) {
2048
+ return this.previous().some((i) => i.withContent());
2049
+ }
2050
+ return true;
1902
2051
  }
1903
- };
1904
- let Warning$2 = class Warning {
1905
- constructor(text, opts = {}) {
1906
- this.type = "warning";
1907
- this.text = text;
1908
- if (opts.node && opts.node.source) {
1909
- let range = opts.node.rangeBy(opts);
1910
- this.line = range.start.line;
1911
- this.column = range.start.column;
1912
- this.endLine = range.end.line;
1913
- this.endColumn = range.end.column;
2052
+ outputFile() {
2053
+ if (this.opts.to) {
2054
+ return this.path(this.opts.to);
2055
+ } else if (this.opts.from) {
2056
+ return this.path(this.opts.from);
2057
+ } else {
2058
+ return "to.css";
1914
2059
  }
1915
- for (let opt in opts) this[opt] = opts[opt];
1916
2060
  }
1917
- toString() {
1918
- if (this.node) {
1919
- return this.node.error(this.text, {
1920
- index: this.index,
1921
- plugin: this.plugin,
1922
- word: this.word
1923
- }).message;
2061
+ path(file) {
2062
+ if (this.mapOpts.absolute) return file;
2063
+ if (file.charCodeAt(0) === 60) return file;
2064
+ if (/^\w+:\/\//.test(file)) return file;
2065
+ let cached = this.memoizedPaths.get(file);
2066
+ if (cached) return cached;
2067
+ let from = this.opts.to ? dirname(this.opts.to) : ".";
2068
+ if (typeof this.mapOpts.annotation === "string") {
2069
+ from = dirname(resolve(from, this.mapOpts.annotation));
1924
2070
  }
1925
- if (this.plugin) {
1926
- return this.plugin + ": " + this.text;
2071
+ let path = relative(from, file);
2072
+ this.memoizedPaths.set(file, path);
2073
+ return path;
2074
+ }
2075
+ previous() {
2076
+ if (!this.previousMaps) {
2077
+ this.previousMaps = [];
2078
+ if (this.root) {
2079
+ this.root.walk((node2) => {
2080
+ if (node2.source && node2.source.input.map) {
2081
+ let map = node2.source.input.map;
2082
+ if (!this.previousMaps.includes(map)) {
2083
+ this.previousMaps.push(map);
2084
+ }
2085
+ }
2086
+ });
2087
+ } else {
2088
+ let input2 = new Input$2(this.originalCSS, this.opts);
2089
+ if (input2.map) this.previousMaps.push(input2.map);
2090
+ }
1927
2091
  }
1928
- return this.text;
2092
+ return this.previousMaps;
1929
2093
  }
1930
- };
1931
- var warning = Warning$2;
1932
- Warning$2.default = Warning$2;
1933
- let Warning$1 = warning;
1934
- let Result$3 = class Result {
1935
- constructor(processor2, root2, opts) {
1936
- this.processor = processor2;
1937
- this.messages = [];
1938
- this.root = root2;
1939
- this.opts = opts;
1940
- this.css = void 0;
1941
- this.map = void 0;
2094
+ setSourcesContent() {
2095
+ let already = {};
2096
+ if (this.root) {
2097
+ this.root.walk((node2) => {
2098
+ if (node2.source) {
2099
+ let from = node2.source.input.from;
2100
+ if (from && !already[from]) {
2101
+ already[from] = true;
2102
+ let fromUrl = this.usesFileUrls ? this.toFileUrl(from) : this.toUrl(this.path(from));
2103
+ this.map.setSourceContent(fromUrl, node2.source.input.css);
2104
+ }
2105
+ }
2106
+ });
2107
+ } else if (this.css) {
2108
+ let from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
2109
+ this.map.setSourceContent(from, this.css);
2110
+ }
1942
2111
  }
1943
- toString() {
1944
- return this.css;
2112
+ sourcePath(node2) {
2113
+ if (this.mapOpts.from) {
2114
+ return this.toUrl(this.mapOpts.from);
2115
+ } else if (this.usesFileUrls) {
2116
+ return this.toFileUrl(node2.source.input.from);
2117
+ } else {
2118
+ return this.toUrl(this.path(node2.source.input.from));
2119
+ }
1945
2120
  }
1946
- warn(text, opts = {}) {
1947
- if (!opts.plugin) {
1948
- if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
1949
- opts.plugin = this.lastPlugin.postcssPlugin;
1950
- }
2121
+ toBase64(str) {
2122
+ if (Buffer) {
2123
+ return Buffer.from(str).toString("base64");
2124
+ } else {
2125
+ return window.btoa(unescape(encodeURIComponent(str)));
1951
2126
  }
1952
- let warning2 = new Warning$1(text, opts);
1953
- this.messages.push(warning2);
1954
- return warning2;
1955
2127
  }
1956
- warnings() {
1957
- return this.messages.filter((i) => i.type === "warning");
2128
+ toFileUrl(path) {
2129
+ let cached = this.memoizedFileURLs.get(path);
2130
+ if (cached) return cached;
2131
+ if (pathToFileURL) {
2132
+ let fileURL = pathToFileURL(path).toString();
2133
+ this.memoizedFileURLs.set(path, fileURL);
2134
+ return fileURL;
2135
+ } else {
2136
+ throw new Error(
2137
+ "`map.absolute` option is not available in this PostCSS build"
2138
+ );
2139
+ }
1958
2140
  }
1959
- get content() {
1960
- return this.css;
2141
+ toUrl(path) {
2142
+ let cached = this.memoizedURLs.get(path);
2143
+ if (cached) return cached;
2144
+ if (sep === "\\") {
2145
+ path = path.replace(/\\/g, "/");
2146
+ }
2147
+ let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
2148
+ this.memoizedURLs.set(path, url);
2149
+ return url;
1961
2150
  }
1962
2151
  };
1963
- var result = Result$3;
1964
- Result$3.default = Result$3;
2152
+ var mapGenerator = MapGenerator$2;
1965
2153
  const SINGLE_QUOTE = "'".charCodeAt(0);
1966
2154
  const DOUBLE_QUOTE = '"'.charCodeAt(0);
1967
2155
  const BACKSLASH = "\\".charCodeAt(0);
@@ -1988,8 +2176,8 @@ const RE_HEX_ESCAPE = /[\da-f]/i;
1988
2176
  var tokenize = function tokenizer(input2, options = {}) {
1989
2177
  let css = input2.css.valueOf();
1990
2178
  let ignore = options.ignoreErrors;
1991
- let code, next, quote, content, escape;
1992
- let escaped, escapePos, prev, n, currentToken;
2179
+ let code, content, escape, next, quote;
2180
+ let currentToken, escaped, escapePos, n, prev;
1993
2181
  let length = css.length;
1994
2182
  let pos = 0;
1995
2183
  let buffer = [];
@@ -2170,145 +2358,12 @@ var tokenize = function tokenizer(input2, options = {}) {
2170
2358
  position
2171
2359
  };
2172
2360
  };
2173
- let Container$5 = container;
2174
- let AtRule$3 = class AtRule extends Container$5 {
2175
- constructor(defaults) {
2176
- super(defaults);
2177
- this.type = "atrule";
2178
- }
2179
- append(...children) {
2180
- if (!this.proxyOf.nodes) this.nodes = [];
2181
- return super.append(...children);
2182
- }
2183
- prepend(...children) {
2184
- if (!this.proxyOf.nodes) this.nodes = [];
2185
- return super.prepend(...children);
2186
- }
2187
- };
2188
- var atRule = AtRule$3;
2189
- AtRule$3.default = AtRule$3;
2190
- Container$5.registerAtRule(AtRule$3);
2191
- let Container$4 = container;
2192
- let LazyResult$3, Processor$2;
2193
- let Root$5 = class Root extends Container$4 {
2194
- constructor(defaults) {
2195
- super(defaults);
2196
- this.type = "root";
2197
- if (!this.nodes) this.nodes = [];
2198
- }
2199
- normalize(child, sample, type) {
2200
- let nodes = super.normalize(child);
2201
- if (sample) {
2202
- if (type === "prepend") {
2203
- if (this.nodes.length > 1) {
2204
- sample.raws.before = this.nodes[1].raws.before;
2205
- } else {
2206
- delete sample.raws.before;
2207
- }
2208
- } else if (this.first !== sample) {
2209
- for (let node2 of nodes) {
2210
- node2.raws.before = sample.raws.before;
2211
- }
2212
- }
2213
- }
2214
- return nodes;
2215
- }
2216
- removeChild(child, ignore) {
2217
- let index2 = this.index(child);
2218
- if (!ignore && index2 === 0 && this.nodes.length > 1) {
2219
- this.nodes[1].raws.before = this.nodes[index2].raws.before;
2220
- }
2221
- return super.removeChild(child);
2222
- }
2223
- toResult(opts = {}) {
2224
- let lazy = new LazyResult$3(new Processor$2(), this, opts);
2225
- return lazy.stringify();
2226
- }
2227
- };
2228
- Root$5.registerLazyResult = (dependant) => {
2229
- LazyResult$3 = dependant;
2230
- };
2231
- Root$5.registerProcessor = (dependant) => {
2232
- Processor$2 = dependant;
2233
- };
2234
- var root = Root$5;
2235
- Root$5.default = Root$5;
2236
- Container$4.registerRoot(Root$5);
2237
- let list$2 = {
2238
- comma(string) {
2239
- return list$2.split(string, [","], true);
2240
- },
2241
- space(string) {
2242
- let spaces = [" ", "\n", " "];
2243
- return list$2.split(string, spaces);
2244
- },
2245
- split(string, separators, last) {
2246
- let array = [];
2247
- let current = "";
2248
- let split = false;
2249
- let func = 0;
2250
- let inQuote = false;
2251
- let prevQuote = "";
2252
- let escape = false;
2253
- for (let letter of string) {
2254
- if (escape) {
2255
- escape = false;
2256
- } else if (letter === "\\") {
2257
- escape = true;
2258
- } else if (inQuote) {
2259
- if (letter === prevQuote) {
2260
- inQuote = false;
2261
- }
2262
- } else if (letter === '"' || letter === "'") {
2263
- inQuote = true;
2264
- prevQuote = letter;
2265
- } else if (letter === "(") {
2266
- func += 1;
2267
- } else if (letter === ")") {
2268
- if (func > 0) func -= 1;
2269
- } else if (func === 0) {
2270
- if (separators.includes(letter)) split = true;
2271
- }
2272
- if (split) {
2273
- if (current !== "") array.push(current.trim());
2274
- current = "";
2275
- split = false;
2276
- } else {
2277
- current += letter;
2278
- }
2279
- }
2280
- if (last || current !== "") array.push(current.trim());
2281
- return array;
2282
- }
2283
- };
2284
- var list_1 = list$2;
2285
- list$2.default = list$2;
2286
- let Container$3 = container;
2287
- let list$1 = list_1;
2288
- let Rule$3 = class Rule extends Container$3 {
2289
- constructor(defaults) {
2290
- super(defaults);
2291
- this.type = "rule";
2292
- if (!this.nodes) this.nodes = [];
2293
- }
2294
- get selectors() {
2295
- return list$1.comma(this.selector);
2296
- }
2297
- set selectors(values) {
2298
- let match = this.selector ? this.selector.match(/,\s*/) : null;
2299
- let sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
2300
- this.selector = values.join(sep2);
2301
- }
2302
- };
2303
- var rule = Rule$3;
2304
- Rule$3.default = Rule$3;
2305
- Container$3.registerRule(Rule$3);
2306
- let Declaration$2 = declaration;
2361
+ let AtRule$1 = atRule;
2362
+ let Comment$1 = comment;
2363
+ let Declaration$1 = declaration;
2364
+ let Root$3 = root;
2365
+ let Rule$1 = rule;
2307
2366
  let tokenizer2 = tokenize;
2308
- let Comment$2 = comment;
2309
- let AtRule$2 = atRule;
2310
- let Root$4 = root;
2311
- let Rule$2 = rule;
2312
2367
  const SAFE_COMMENT_NEIGHBOR = {
2313
2368
  empty: true,
2314
2369
  space: true
@@ -2323,7 +2378,7 @@ function findLastWithPosition(tokens) {
2323
2378
  let Parser$1 = class Parser {
2324
2379
  constructor(input2) {
2325
2380
  this.input = input2;
2326
- this.root = new Root$4();
2381
+ this.root = new Root$3();
2327
2382
  this.current = this.root;
2328
2383
  this.spaces = "";
2329
2384
  this.semicolon = false;
@@ -2331,7 +2386,7 @@ let Parser$1 = class Parser {
2331
2386
  this.root.source = { input: input2, start: { column: 1, line: 1, offset: 0 } };
2332
2387
  }
2333
2388
  atrule(token) {
2334
- let node2 = new AtRule$2();
2389
+ let node2 = new AtRule$1();
2335
2390
  node2.name = token[1].slice(1);
2336
2391
  if (node2.name === "") {
2337
2392
  this.unnamedAtrule(node2, token);
@@ -2427,7 +2482,7 @@ let Parser$1 = class Parser {
2427
2482
  }
2428
2483
  colon(tokens) {
2429
2484
  let brackets = 0;
2430
- let token, type, prev;
2485
+ let prev, token, type;
2431
2486
  for (let [i, element] of tokens.entries()) {
2432
2487
  token = element;
2433
2488
  type = token[0];
@@ -2451,7 +2506,7 @@ let Parser$1 = class Parser {
2451
2506
  return false;
2452
2507
  }
2453
2508
  comment(token) {
2454
- let node2 = new Comment$2();
2509
+ let node2 = new Comment$1();
2455
2510
  this.init(node2, token[2]);
2456
2511
  node2.source.end = this.getPosition(token[3] || token[2]);
2457
2512
  node2.source.end.offset++;
@@ -2471,7 +2526,7 @@ let Parser$1 = class Parser {
2471
2526
  this.tokenizer = tokenizer2(this.input);
2472
2527
  }
2473
2528
  decl(tokens, customProperty) {
2474
- let node2 = new Declaration$2();
2529
+ let node2 = new Declaration$1();
2475
2530
  this.init(node2, tokens[0][2]);
2476
2531
  let last = tokens[tokens.length - 1];
2477
2532
  if (last[0] === ";") {
@@ -2534,12 +2589,12 @@ let Parser$1 = class Parser {
2534
2589
  let str = "";
2535
2590
  for (let j2 = i; j2 > 0; j2--) {
2536
2591
  let type = cache[j2][0];
2537
- if (str.trim().indexOf("!") === 0 && type !== "space") {
2592
+ if (str.trim().startsWith("!") && type !== "space") {
2538
2593
  break;
2539
2594
  }
2540
2595
  str = cache.pop()[1] + str;
2541
2596
  }
2542
- if (str.trim().indexOf("!") === 0) {
2597
+ if (str.trim().startsWith("!")) {
2543
2598
  node2.important = true;
2544
2599
  node2.raws.important = str;
2545
2600
  tokens = cache;
@@ -2567,7 +2622,7 @@ let Parser$1 = class Parser {
2567
2622
  );
2568
2623
  }
2569
2624
  emptyRule(token) {
2570
- let node2 = new Rule$2();
2625
+ let node2 = new Rule$1();
2571
2626
  this.init(node2, token[2]);
2572
2627
  node2.selector = "";
2573
2628
  node2.raws.between = "";
@@ -2603,6 +2658,8 @@ let Parser$1 = class Parser {
2603
2658
  if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
2604
2659
  prev.raws.ownSemicolon = this.spaces;
2605
2660
  this.spaces = "";
2661
+ prev.source.end = this.getPosition(token[2]);
2662
+ prev.source.end.offset += prev.raws.ownSemicolon.length;
2606
2663
  }
2607
2664
  }
2608
2665
  }
@@ -2749,7 +2806,7 @@ let Parser$1 = class Parser {
2749
2806
  }
2750
2807
  rule(tokens) {
2751
2808
  tokens.pop();
2752
- let node2 = new Rule$2();
2809
+ let node2 = new Rule$1();
2753
2810
  this.init(node2, tokens[0][2]);
2754
2811
  node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
2755
2812
  this.raw(node2, "selector", tokens);
@@ -2814,56 +2871,125 @@ let Parser$1 = class Parser {
2814
2871
  }
2815
2872
  unknownWord(tokens) {
2816
2873
  throw this.input.error(
2817
- "Unknown word",
2874
+ "Unknown word " + tokens[0][1],
2818
2875
  { offset: tokens[0][2] },
2819
2876
  { offset: tokens[0][2] + tokens[0][1].length }
2820
2877
  );
2821
2878
  }
2822
- unnamedAtrule(node2, token) {
2823
- throw this.input.error(
2824
- "At-rule without name",
2825
- { offset: token[2] },
2826
- { offset: token[2] + token[1].length }
2827
- );
2879
+ unnamedAtrule(node2, token) {
2880
+ throw this.input.error(
2881
+ "At-rule without name",
2882
+ { offset: token[2] },
2883
+ { offset: token[2] + token[1].length }
2884
+ );
2885
+ }
2886
+ };
2887
+ var parser = Parser$1;
2888
+ let Container$2 = container;
2889
+ let Input$1 = input;
2890
+ let Parser2 = parser;
2891
+ function parse$3(css, opts) {
2892
+ let input2 = new Input$1(css, opts);
2893
+ let parser2 = new Parser2(input2);
2894
+ try {
2895
+ parser2.parse();
2896
+ } catch (e) {
2897
+ if (process.env.NODE_ENV !== "production") {
2898
+ if (e.name === "CssSyntaxError" && opts && opts.from) {
2899
+ if (/\.scss$/i.test(opts.from)) {
2900
+ e.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
2901
+ } else if (/\.sass/i.test(opts.from)) {
2902
+ e.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
2903
+ } else if (/\.less$/i.test(opts.from)) {
2904
+ e.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
2905
+ }
2906
+ }
2907
+ }
2908
+ throw e;
2909
+ }
2910
+ return parser2.root;
2911
+ }
2912
+ var parse_1 = parse$3;
2913
+ parse$3.default = parse$3;
2914
+ Container$2.registerParse(parse$3);
2915
+ let Warning$2 = class Warning {
2916
+ constructor(text, opts = {}) {
2917
+ this.type = "warning";
2918
+ this.text = text;
2919
+ if (opts.node && opts.node.source) {
2920
+ let range = opts.node.rangeBy(opts);
2921
+ this.line = range.start.line;
2922
+ this.column = range.start.column;
2923
+ this.endLine = range.end.line;
2924
+ this.endColumn = range.end.column;
2925
+ }
2926
+ for (let opt in opts) this[opt] = opts[opt];
2927
+ }
2928
+ toString() {
2929
+ if (this.node) {
2930
+ return this.node.error(this.text, {
2931
+ index: this.index,
2932
+ plugin: this.plugin,
2933
+ word: this.word
2934
+ }).message;
2935
+ }
2936
+ if (this.plugin) {
2937
+ return this.plugin + ": " + this.text;
2938
+ }
2939
+ return this.text;
2940
+ }
2941
+ };
2942
+ var warning = Warning$2;
2943
+ Warning$2.default = Warning$2;
2944
+ let Warning$1 = warning;
2945
+ let Result$3 = class Result {
2946
+ get content() {
2947
+ return this.css;
2948
+ }
2949
+ constructor(processor2, root2, opts) {
2950
+ this.processor = processor2;
2951
+ this.messages = [];
2952
+ this.root = root2;
2953
+ this.opts = opts;
2954
+ this.css = "";
2955
+ this.map = void 0;
2956
+ }
2957
+ toString() {
2958
+ return this.css;
2828
2959
  }
2829
- };
2830
- var parser = Parser$1;
2831
- let Container$2 = container;
2832
- let Parser2 = parser;
2833
- let Input$2 = input;
2834
- function parse$3(css, opts) {
2835
- let input2 = new Input$2(css, opts);
2836
- let parser2 = new Parser2(input2);
2837
- try {
2838
- parser2.parse();
2839
- } catch (e) {
2840
- if (process.env.NODE_ENV !== "production") {
2841
- if (e.name === "CssSyntaxError" && opts && opts.from) {
2842
- if (/\.scss$/i.test(opts.from)) {
2843
- e.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
2844
- } else if (/\.sass/i.test(opts.from)) {
2845
- e.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
2846
- } else if (/\.less$/i.test(opts.from)) {
2847
- e.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
2848
- }
2960
+ warn(text, opts = {}) {
2961
+ if (!opts.plugin) {
2962
+ if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
2963
+ opts.plugin = this.lastPlugin.postcssPlugin;
2849
2964
  }
2850
2965
  }
2851
- throw e;
2966
+ let warning2 = new Warning$1(text, opts);
2967
+ this.messages.push(warning2);
2968
+ return warning2;
2852
2969
  }
2853
- return parser2.root;
2854
- }
2855
- var parse_1 = parse$3;
2856
- parse$3.default = parse$3;
2857
- Container$2.registerParse(parse$3);
2858
- let { isClean, my } = symbols;
2970
+ warnings() {
2971
+ return this.messages.filter((i) => i.type === "warning");
2972
+ }
2973
+ };
2974
+ var result = Result$3;
2975
+ Result$3.default = Result$3;
2976
+ let printed = {};
2977
+ var warnOnce$2 = function warnOnce(message) {
2978
+ if (printed[message]) return;
2979
+ printed[message] = true;
2980
+ if (typeof console !== "undefined" && console.warn) {
2981
+ console.warn(message);
2982
+ }
2983
+ };
2984
+ let Container$1 = container;
2985
+ let Document$3 = document$1;
2859
2986
  let MapGenerator$1 = mapGenerator;
2987
+ let parse$2 = parse_1;
2988
+ let Result$2 = result;
2989
+ let Root$2 = root;
2860
2990
  let stringify$2 = stringify_1;
2861
- let Container$1 = container;
2862
- let Document$2 = document$1;
2991
+ let { isClean, my } = symbols;
2863
2992
  let warnOnce$1 = warnOnce$2;
2864
- let Result$2 = result;
2865
- let parse$2 = parse_1;
2866
- let Root$3 = root;
2867
2993
  const TYPE_TO_CLASS_NAME = {
2868
2994
  atrule: "AtRule",
2869
2995
  comment: "Comment",
@@ -2948,6 +3074,30 @@ function cleanMarks(node2) {
2948
3074
  }
2949
3075
  let postcss$2 = {};
2950
3076
  let LazyResult$2 = class LazyResult {
3077
+ get content() {
3078
+ return this.stringify().content;
3079
+ }
3080
+ get css() {
3081
+ return this.stringify().css;
3082
+ }
3083
+ get map() {
3084
+ return this.stringify().map;
3085
+ }
3086
+ get messages() {
3087
+ return this.sync().messages;
3088
+ }
3089
+ get opts() {
3090
+ return this.result.opts;
3091
+ }
3092
+ get processor() {
3093
+ return this.result.processor;
3094
+ }
3095
+ get root() {
3096
+ return this.sync().root;
3097
+ }
3098
+ get [Symbol.toStringTag]() {
3099
+ return "LazyResult";
3100
+ }
2951
3101
  constructor(processor2, css, opts) {
2952
3102
  this.stringified = false;
2953
3103
  this.processed = false;
@@ -3290,17 +3440,31 @@ let LazyResult$2 = class LazyResult {
3290
3440
  warnings() {
3291
3441
  return this.sync().warnings();
3292
3442
  }
3443
+ };
3444
+ LazyResult$2.registerPostcss = (dependant) => {
3445
+ postcss$2 = dependant;
3446
+ };
3447
+ var lazyResult = LazyResult$2;
3448
+ LazyResult$2.default = LazyResult$2;
3449
+ Root$2.registerLazyResult(LazyResult$2);
3450
+ Document$3.registerLazyResult(LazyResult$2);
3451
+ let MapGenerator2 = mapGenerator;
3452
+ let parse$1 = parse_1;
3453
+ const Result$1 = result;
3454
+ let stringify$1 = stringify_1;
3455
+ let warnOnce2 = warnOnce$2;
3456
+ let NoWorkResult$1 = class NoWorkResult {
3293
3457
  get content() {
3294
- return this.stringify().content;
3458
+ return this.result.css;
3295
3459
  }
3296
3460
  get css() {
3297
- return this.stringify().css;
3461
+ return this.result.css;
3298
3462
  }
3299
3463
  get map() {
3300
- return this.stringify().map;
3464
+ return this.result.map;
3301
3465
  }
3302
3466
  get messages() {
3303
- return this.sync().messages;
3467
+ return [];
3304
3468
  }
3305
3469
  get opts() {
3306
3470
  return this.result.opts;
@@ -3309,25 +3473,26 @@ let LazyResult$2 = class LazyResult {
3309
3473
  return this.result.processor;
3310
3474
  }
3311
3475
  get root() {
3312
- return this.sync().root;
3476
+ if (this._root) {
3477
+ return this._root;
3478
+ }
3479
+ let root2;
3480
+ let parser2 = parse$1;
3481
+ try {
3482
+ root2 = parser2(this._css, this._opts);
3483
+ } catch (error) {
3484
+ this.error = error;
3485
+ }
3486
+ if (this.error) {
3487
+ throw this.error;
3488
+ } else {
3489
+ this._root = root2;
3490
+ return root2;
3491
+ }
3313
3492
  }
3314
3493
  get [Symbol.toStringTag]() {
3315
- return "LazyResult";
3494
+ return "NoWorkResult";
3316
3495
  }
3317
- };
3318
- LazyResult$2.registerPostcss = (dependant) => {
3319
- postcss$2 = dependant;
3320
- };
3321
- var lazyResult = LazyResult$2;
3322
- LazyResult$2.default = LazyResult$2;
3323
- Root$3.registerLazyResult(LazyResult$2);
3324
- Document$2.registerLazyResult(LazyResult$2);
3325
- let MapGenerator2 = mapGenerator;
3326
- let stringify$1 = stringify_1;
3327
- let warnOnce2 = warnOnce$2;
3328
- let parse$1 = parse_1;
3329
- const Result$1 = result;
3330
- let NoWorkResult$1 = class NoWorkResult {
3331
3496
  constructor(processor2, css, opts) {
3332
3497
  css = css.toString();
3333
3498
  this.stringified = false;
@@ -3389,55 +3554,16 @@ let NoWorkResult$1 = class NoWorkResult {
3389
3554
  warnings() {
3390
3555
  return [];
3391
3556
  }
3392
- get content() {
3393
- return this.result.css;
3394
- }
3395
- get css() {
3396
- return this.result.css;
3397
- }
3398
- get map() {
3399
- return this.result.map;
3400
- }
3401
- get messages() {
3402
- return [];
3403
- }
3404
- get opts() {
3405
- return this.result.opts;
3406
- }
3407
- get processor() {
3408
- return this.result.processor;
3409
- }
3410
- get root() {
3411
- if (this._root) {
3412
- return this._root;
3413
- }
3414
- let root2;
3415
- let parser2 = parse$1;
3416
- try {
3417
- root2 = parser2(this._css, this._opts);
3418
- } catch (error) {
3419
- this.error = error;
3420
- }
3421
- if (this.error) {
3422
- throw this.error;
3423
- } else {
3424
- this._root = root2;
3425
- return root2;
3426
- }
3427
- }
3428
- get [Symbol.toStringTag]() {
3429
- return "NoWorkResult";
3430
- }
3431
3557
  };
3432
3558
  var noWorkResult = NoWorkResult$1;
3433
3559
  NoWorkResult$1.default = NoWorkResult$1;
3434
- let NoWorkResult2 = noWorkResult;
3560
+ let Document$2 = document$1;
3435
3561
  let LazyResult$1 = lazyResult;
3436
- let Document$1 = document$1;
3437
- let Root$2 = root;
3562
+ let NoWorkResult2 = noWorkResult;
3563
+ let Root$1 = root;
3438
3564
  let Processor$1 = class Processor {
3439
3565
  constructor(plugins = []) {
3440
- this.version = "8.4.38";
3566
+ this.version = "8.5.6";
3441
3567
  this.plugins = this.normalize(plugins);
3442
3568
  }
3443
3569
  normalize(plugins) {
@@ -3480,75 +3606,26 @@ let Processor$1 = class Processor {
3480
3606
  };
3481
3607
  var processor = Processor$1;
3482
3608
  Processor$1.default = Processor$1;
3483
- Root$2.registerProcessor(Processor$1);
3484
- Document$1.registerProcessor(Processor$1);
3485
- let Declaration$1 = declaration;
3486
- let PreviousMap2 = previousMap;
3487
- let Comment$1 = comment;
3488
- let AtRule$1 = atRule;
3489
- let Input$1 = input;
3490
- let Root$1 = root;
3491
- let Rule$1 = rule;
3492
- function fromJSON$1(json, inputs) {
3493
- if (Array.isArray(json)) return json.map((n) => fromJSON$1(n));
3494
- let { inputs: ownInputs, ...defaults } = json;
3495
- if (ownInputs) {
3496
- inputs = [];
3497
- for (let input2 of ownInputs) {
3498
- let inputHydrated = { ...input2, __proto__: Input$1.prototype };
3499
- if (inputHydrated.map) {
3500
- inputHydrated.map = {
3501
- ...inputHydrated.map,
3502
- __proto__: PreviousMap2.prototype
3503
- };
3504
- }
3505
- inputs.push(inputHydrated);
3506
- }
3507
- }
3508
- if (defaults.nodes) {
3509
- defaults.nodes = json.nodes.map((n) => fromJSON$1(n, inputs));
3510
- }
3511
- if (defaults.source) {
3512
- let { inputId, ...source } = defaults.source;
3513
- defaults.source = source;
3514
- if (inputId != null) {
3515
- defaults.source.input = inputs[inputId];
3516
- }
3517
- }
3518
- if (defaults.type === "root") {
3519
- return new Root$1(defaults);
3520
- } else if (defaults.type === "decl") {
3521
- return new Declaration$1(defaults);
3522
- } else if (defaults.type === "rule") {
3523
- return new Rule$1(defaults);
3524
- } else if (defaults.type === "comment") {
3525
- return new Comment$1(defaults);
3526
- } else if (defaults.type === "atrule") {
3527
- return new AtRule$1(defaults);
3528
- } else {
3529
- throw new Error("Unknown node type: " + json.type);
3530
- }
3531
- }
3532
- var fromJSON_1 = fromJSON$1;
3533
- fromJSON$1.default = fromJSON$1;
3609
+ Root$1.registerProcessor(Processor$1);
3610
+ Document$2.registerProcessor(Processor$1);
3611
+ let AtRule2 = atRule;
3612
+ let Comment2 = comment;
3613
+ let Container2 = container;
3534
3614
  let CssSyntaxError2 = cssSyntaxError;
3535
3615
  let Declaration2 = declaration;
3536
- let LazyResult2 = lazyResult;
3537
- let Container2 = container;
3538
- let Processor2 = processor;
3539
- let stringify = stringify_1;
3616
+ let Document$1 = document$1;
3540
3617
  let fromJSON = fromJSON_1;
3541
- let Document22 = document$1;
3542
- let Warning2 = warning;
3543
- let Comment2 = comment;
3544
- let AtRule2 = atRule;
3545
- let Result2 = result;
3546
3618
  let Input2 = input;
3547
- let parse = parse_1;
3619
+ let LazyResult2 = lazyResult;
3548
3620
  let list = list_1;
3549
- let Rule2 = rule;
3550
- let Root2 = root;
3551
3621
  let Node$1 = node;
3622
+ let parse = parse_1;
3623
+ let Processor2 = processor;
3624
+ let Result2 = result;
3625
+ let Root2 = root;
3626
+ let Rule2 = rule;
3627
+ let stringify = stringify_1;
3628
+ let Warning2 = warning;
3552
3629
  function postcss(...plugins) {
3553
3630
  if (plugins.length === 1 && Array.isArray(plugins[0])) {
3554
3631
  plugins = plugins[0];
@@ -3595,12 +3672,12 @@ postcss.atRule = (defaults) => new AtRule2(defaults);
3595
3672
  postcss.decl = (defaults) => new Declaration2(defaults);
3596
3673
  postcss.rule = (defaults) => new Rule2(defaults);
3597
3674
  postcss.root = (defaults) => new Root2(defaults);
3598
- postcss.document = (defaults) => new Document22(defaults);
3675
+ postcss.document = (defaults) => new Document$1(defaults);
3599
3676
  postcss.CssSyntaxError = CssSyntaxError2;
3600
3677
  postcss.Declaration = Declaration2;
3601
3678
  postcss.Container = Container2;
3602
3679
  postcss.Processor = Processor2;
3603
- postcss.Document = Document22;
3680
+ postcss.Document = Document$1;
3604
3681
  postcss.Comment = Comment2;
3605
3682
  postcss.Warning = Warning2;
3606
3683
  postcss.AtRule = AtRule2;