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