source: imaps-frontend/node_modules/vite/dist/node/chunks/dep-CjZz522d.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 221.5 KB
Line 
1import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-mCdpKltl.js';
2import require$$0__default from 'fs';
3import require$$0 from 'postcss';
4import require$$0$1 from 'path';
5import require$$3 from 'crypto';
6import require$$0$2 from 'util';
7import { l as lib } from './dep-IQS-Za7F.js';
8
9import { fileURLToPath as __cjs_fileURLToPath } from 'node:url';
10import { dirname as __cjs_dirname } from 'node:path';
11import { createRequire as __cjs_createRequire } from 'node:module';
12
13const __filename = __cjs_fileURLToPath(import.meta.url);
14const __dirname = __cjs_dirname(__filename);
15const require = __cjs_createRequire(import.meta.url);
16const __require = require;
17function _mergeNamespaces(n, m) {
18 for (var i = 0; i < m.length; i++) {
19 var e = m[i];
20 if (typeof e !== 'string' && !Array.isArray(e)) { for (var k in e) {
21 if (k !== 'default' && !(k in n)) {
22 n[k] = e[k];
23 }
24 } }
25 }
26 return n;
27}
28
29var build = {exports: {}};
30
31var fs = {};
32
33Object.defineProperty(fs, "__esModule", {
34 value: true
35});
36fs.getFileSystem = getFileSystem;
37fs.setFileSystem = setFileSystem;
38let fileSystem = {
39 readFile: () => {
40 throw Error("readFile not implemented");
41 },
42 writeFile: () => {
43 throw Error("writeFile not implemented");
44 }
45};
46
47function setFileSystem(fs) {
48 fileSystem.readFile = fs.readFile;
49 fileSystem.writeFile = fs.writeFile;
50}
51
52function getFileSystem() {
53 return fileSystem;
54}
55
56var pluginFactory = {};
57
58var unquote$1 = {};
59
60Object.defineProperty(unquote$1, "__esModule", {
61 value: true
62});
63unquote$1.default = unquote;
64// copied from https://github.com/lakenen/node-unquote
65const reg = /['"]/;
66
67function unquote(str) {
68 if (!str) {
69 return "";
70 }
71
72 if (reg.test(str.charAt(0))) {
73 str = str.substr(1);
74 }
75
76 if (reg.test(str.charAt(str.length - 1))) {
77 str = str.substr(0, str.length - 1);
78 }
79
80 return str;
81}
82
83var Parser$1 = {};
84
85const matchValueName = /[$]?[\w-]+/g;
86
87const replaceValueSymbols$2 = (value, replacements) => {
88 let matches;
89
90 while ((matches = matchValueName.exec(value))) {
91 const replacement = replacements[matches[0]];
92
93 if (replacement) {
94 value =
95 value.slice(0, matches.index) +
96 replacement +
97 value.slice(matchValueName.lastIndex);
98
99 matchValueName.lastIndex -= matches[0].length - replacement.length;
100 }
101 }
102
103 return value;
104};
105
106var replaceValueSymbols_1 = replaceValueSymbols$2;
107
108const replaceValueSymbols$1 = replaceValueSymbols_1;
109
110const replaceSymbols$1 = (css, replacements) => {
111 css.walk((node) => {
112 if (node.type === "decl" && node.value) {
113 node.value = replaceValueSymbols$1(node.value.toString(), replacements);
114 } else if (node.type === "rule" && node.selector) {
115 node.selector = replaceValueSymbols$1(
116 node.selector.toString(),
117 replacements
118 );
119 } else if (node.type === "atrule" && node.params) {
120 node.params = replaceValueSymbols$1(node.params.toString(), replacements);
121 }
122 });
123};
124
125var replaceSymbols_1 = replaceSymbols$1;
126
127const importPattern = /^:import\(("[^"]*"|'[^']*'|[^"']+)\)$/;
128const balancedQuotes = /^("[^"]*"|'[^']*'|[^"']+)$/;
129
130const getDeclsObject = (rule) => {
131 const object = {};
132
133 rule.walkDecls((decl) => {
134 const before = decl.raws.before ? decl.raws.before.trim() : "";
135
136 object[before + decl.prop] = decl.value;
137 });
138
139 return object;
140};
141/**
142 *
143 * @param {string} css
144 * @param {boolean} removeRules
145 * @param {'auto' | 'rule' | 'at-rule'} mode
146 */
147const extractICSS$2 = (css, removeRules = true, mode = "auto") => {
148 const icssImports = {};
149 const icssExports = {};
150
151 function addImports(node, path) {
152 const unquoted = path.replace(/'|"/g, "");
153 icssImports[unquoted] = Object.assign(
154 icssImports[unquoted] || {},
155 getDeclsObject(node)
156 );
157
158 if (removeRules) {
159 node.remove();
160 }
161 }
162
163 function addExports(node) {
164 Object.assign(icssExports, getDeclsObject(node));
165 if (removeRules) {
166 node.remove();
167 }
168 }
169
170 css.each((node) => {
171 if (node.type === "rule" && mode !== "at-rule") {
172 if (node.selector.slice(0, 7) === ":import") {
173 const matches = importPattern.exec(node.selector);
174
175 if (matches) {
176 addImports(node, matches[1]);
177 }
178 }
179
180 if (node.selector === ":export") {
181 addExports(node);
182 }
183 }
184
185 if (node.type === "atrule" && mode !== "rule") {
186 if (node.name === "icss-import") {
187 const matches = balancedQuotes.exec(node.params);
188
189 if (matches) {
190 addImports(node, matches[1]);
191 }
192 }
193 if (node.name === "icss-export") {
194 addExports(node);
195 }
196 }
197 });
198
199 return { icssImports, icssExports };
200};
201
202var extractICSS_1 = extractICSS$2;
203
204const createImports = (imports, postcss, mode = "rule") => {
205 return Object.keys(imports).map((path) => {
206 const aliases = imports[path];
207 const declarations = Object.keys(aliases).map((key) =>
208 postcss.decl({
209 prop: key,
210 value: aliases[key],
211 raws: { before: "\n " },
212 })
213 );
214
215 const hasDeclarations = declarations.length > 0;
216
217 const rule =
218 mode === "rule"
219 ? postcss.rule({
220 selector: `:import('${path}')`,
221 raws: { after: hasDeclarations ? "\n" : "" },
222 })
223 : postcss.atRule({
224 name: "icss-import",
225 params: `'${path}'`,
226 raws: { after: hasDeclarations ? "\n" : "" },
227 });
228
229 if (hasDeclarations) {
230 rule.append(declarations);
231 }
232
233 return rule;
234 });
235};
236
237const createExports = (exports, postcss, mode = "rule") => {
238 const declarations = Object.keys(exports).map((key) =>
239 postcss.decl({
240 prop: key,
241 value: exports[key],
242 raws: { before: "\n " },
243 })
244 );
245
246 if (declarations.length === 0) {
247 return [];
248 }
249 const rule =
250 mode === "rule"
251 ? postcss.rule({
252 selector: `:export`,
253 raws: { after: "\n" },
254 })
255 : postcss.atRule({
256 name: "icss-export",
257 raws: { after: "\n" },
258 });
259
260 rule.append(declarations);
261
262 return [rule];
263};
264
265const createICSSRules$1 = (imports, exports, postcss, mode) => [
266 ...createImports(imports, postcss, mode),
267 ...createExports(exports, postcss, mode),
268];
269
270var createICSSRules_1 = createICSSRules$1;
271
272const replaceValueSymbols = replaceValueSymbols_1;
273const replaceSymbols = replaceSymbols_1;
274const extractICSS$1 = extractICSS_1;
275const createICSSRules = createICSSRules_1;
276
277var src$4 = {
278 replaceValueSymbols,
279 replaceSymbols,
280 extractICSS: extractICSS$1,
281 createICSSRules,
282};
283
284Object.defineProperty(Parser$1, "__esModule", {
285 value: true
286});
287Parser$1.default = void 0;
288
289var _icssUtils = src$4;
290
291// Initially copied from https://github.com/css-modules/css-modules-loader-core
292const importRegexp = /^:import\((.+)\)$/;
293
294class Parser {
295 constructor(pathFetcher, trace) {
296 this.pathFetcher = pathFetcher;
297 this.plugin = this.plugin.bind(this);
298 this.exportTokens = {};
299 this.translations = {};
300 this.trace = trace;
301 }
302
303 plugin() {
304 const parser = this;
305 return {
306 postcssPlugin: "css-modules-parser",
307
308 async OnceExit(css) {
309 await Promise.all(parser.fetchAllImports(css));
310 parser.linkImportedSymbols(css);
311 return parser.extractExports(css);
312 }
313
314 };
315 }
316
317 fetchAllImports(css) {
318 let imports = [];
319 css.each(node => {
320 if (node.type == "rule" && node.selector.match(importRegexp)) {
321 imports.push(this.fetchImport(node, css.source.input.from, imports.length));
322 }
323 });
324 return imports;
325 }
326
327 linkImportedSymbols(css) {
328 (0, _icssUtils.replaceSymbols)(css, this.translations);
329 }
330
331 extractExports(css) {
332 css.each(node => {
333 if (node.type == "rule" && node.selector == ":export") this.handleExport(node);
334 });
335 }
336
337 handleExport(exportNode) {
338 exportNode.each(decl => {
339 if (decl.type == "decl") {
340 Object.keys(this.translations).forEach(translation => {
341 decl.value = decl.value.replace(translation, this.translations[translation]);
342 });
343 this.exportTokens[decl.prop] = decl.value;
344 }
345 });
346 exportNode.remove();
347 }
348
349 async fetchImport(importNode, relativeTo, depNr) {
350 const file = importNode.selector.match(importRegexp)[1];
351 const depTrace = this.trace + String.fromCharCode(depNr);
352 const exports = await this.pathFetcher(file, relativeTo, depTrace);
353
354 try {
355 importNode.each(decl => {
356 if (decl.type == "decl") {
357 this.translations[decl.prop] = exports[decl.value];
358 }
359 });
360 importNode.remove();
361 } catch (err) {
362 console.log(err);
363 }
364 }
365
366}
367
368Parser$1.default = Parser;
369
370var saveJSON$1 = {};
371
372Object.defineProperty(saveJSON$1, "__esModule", {
373 value: true
374});
375saveJSON$1.default = saveJSON;
376
377var _fs$2 = fs;
378
379function saveJSON(cssFile, json) {
380 return new Promise((resolve, reject) => {
381 const {
382 writeFile
383 } = (0, _fs$2.getFileSystem)();
384 writeFile(`${cssFile}.json`, JSON.stringify(json), e => e ? reject(e) : resolve(json));
385 });
386}
387
388var localsConvention = {};
389
390/**
391 * lodash (Custom Build) <https://lodash.com/>
392 * Build: `lodash modularize exports="npm" -o ./`
393 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
394 * Released under MIT license <https://lodash.com/license>
395 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
396 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
397 */
398
399/** Used as references for various `Number` constants. */
400var INFINITY = 1 / 0;
401
402/** `Object#toString` result references. */
403var symbolTag = '[object Symbol]';
404
405/** Used to match words composed of alphanumeric characters. */
406var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
407
408/** Used to match Latin Unicode letters (excluding mathematical operators). */
409var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
410
411/** Used to compose unicode character classes. */
412var rsAstralRange = '\\ud800-\\udfff',
413 rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
414 rsComboSymbolsRange = '\\u20d0-\\u20f0',
415 rsDingbatRange = '\\u2700-\\u27bf',
416 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
417 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
418 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
419 rsPunctuationRange = '\\u2000-\\u206f',
420 rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
421 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
422 rsVarRange = '\\ufe0e\\ufe0f',
423 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
424
425/** Used to compose unicode capture groups. */
426var rsApos = "['\u2019]",
427 rsAstral = '[' + rsAstralRange + ']',
428 rsBreak = '[' + rsBreakRange + ']',
429 rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
430 rsDigits = '\\d+',
431 rsDingbat = '[' + rsDingbatRange + ']',
432 rsLower = '[' + rsLowerRange + ']',
433 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
434 rsFitz = '\\ud83c[\\udffb-\\udfff]',
435 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
436 rsNonAstral = '[^' + rsAstralRange + ']',
437 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
438 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
439 rsUpper = '[' + rsUpperRange + ']',
440 rsZWJ = '\\u200d';
441
442/** Used to compose unicode regexes. */
443var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
444 rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
445 rsOptLowerContr = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
446 rsOptUpperContr = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
447 reOptMod = rsModifier + '?',
448 rsOptVar = '[' + rsVarRange + ']?',
449 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
450 rsSeq = rsOptVar + reOptMod + rsOptJoin,
451 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
452 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
453
454/** Used to match apostrophes. */
455var reApos = RegExp(rsApos, 'g');
456
457/**
458 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
459 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
460 */
461var reComboMark = RegExp(rsCombo, 'g');
462
463/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
464var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
465
466/** Used to match complex or compound words. */
467var reUnicodeWord = RegExp([
468 rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
469 rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
470 rsUpper + '?' + rsLowerMisc + '+' + rsOptLowerContr,
471 rsUpper + '+' + rsOptUpperContr,
472 rsDigits,
473 rsEmoji
474].join('|'), 'g');
475
476/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
477var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
478
479/** Used to detect strings that need a more robust regexp to match words. */
480var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
481
482/** Used to map Latin Unicode letters to basic Latin letters. */
483var deburredLetters = {
484 // Latin-1 Supplement block.
485 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
486 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
487 '\xc7': 'C', '\xe7': 'c',
488 '\xd0': 'D', '\xf0': 'd',
489 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
490 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
491 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
492 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
493 '\xd1': 'N', '\xf1': 'n',
494 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
495 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
496 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
497 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
498 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
499 '\xc6': 'Ae', '\xe6': 'ae',
500 '\xde': 'Th', '\xfe': 'th',
501 '\xdf': 'ss',
502 // Latin Extended-A block.
503 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
504 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
505 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
506 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
507 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
508 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
509 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
510 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
511 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
512 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
513 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
514 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
515 '\u0134': 'J', '\u0135': 'j',
516 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
517 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
518 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
519 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
520 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
521 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
522 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
523 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
524 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
525 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
526 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
527 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
528 '\u0163': 't', '\u0165': 't', '\u0167': 't',
529 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
530 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
531 '\u0174': 'W', '\u0175': 'w',
532 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
533 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
534 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
535 '\u0132': 'IJ', '\u0133': 'ij',
536 '\u0152': 'Oe', '\u0153': 'oe',
537 '\u0149': "'n", '\u017f': 'ss'
538};
539
540/** Detect free variable `global` from Node.js. */
541var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
542
543/** Detect free variable `self`. */
544var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
545
546/** Used as a reference to the global object. */
547var root$2 = freeGlobal || freeSelf || Function('return this')();
548
549/**
550 * A specialized version of `_.reduce` for arrays without support for
551 * iteratee shorthands.
552 *
553 * @private
554 * @param {Array} [array] The array to iterate over.
555 * @param {Function} iteratee The function invoked per iteration.
556 * @param {*} [accumulator] The initial value.
557 * @param {boolean} [initAccum] Specify using the first element of `array` as
558 * the initial value.
559 * @returns {*} Returns the accumulated value.
560 */
561function arrayReduce(array, iteratee, accumulator, initAccum) {
562 var index = -1,
563 length = array ? array.length : 0;
564 while (++index < length) {
565 accumulator = iteratee(accumulator, array[index], index, array);
566 }
567 return accumulator;
568}
569
570/**
571 * Converts an ASCII `string` to an array.
572 *
573 * @private
574 * @param {string} string The string to convert.
575 * @returns {Array} Returns the converted array.
576 */
577function asciiToArray(string) {
578 return string.split('');
579}
580
581/**
582 * Splits an ASCII `string` into an array of its words.
583 *
584 * @private
585 * @param {string} The string to inspect.
586 * @returns {Array} Returns the words of `string`.
587 */
588function asciiWords(string) {
589 return string.match(reAsciiWord) || [];
590}
591
592/**
593 * The base implementation of `_.propertyOf` without support for deep paths.
594 *
595 * @private
596 * @param {Object} object The object to query.
597 * @returns {Function} Returns the new accessor function.
598 */
599function basePropertyOf(object) {
600 return function(key) {
601 return object == null ? undefined : object[key];
602 };
603}
604
605/**
606 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
607 * letters to basic Latin letters.
608 *
609 * @private
610 * @param {string} letter The matched letter to deburr.
611 * @returns {string} Returns the deburred letter.
612 */
613var deburrLetter = basePropertyOf(deburredLetters);
614
615/**
616 * Checks if `string` contains Unicode symbols.
617 *
618 * @private
619 * @param {string} string The string to inspect.
620 * @returns {boolean} Returns `true` if a symbol is found, else `false`.
621 */
622function hasUnicode(string) {
623 return reHasUnicode.test(string);
624}
625
626/**
627 * Checks if `string` contains a word composed of Unicode symbols.
628 *
629 * @private
630 * @param {string} string The string to inspect.
631 * @returns {boolean} Returns `true` if a word is found, else `false`.
632 */
633function hasUnicodeWord(string) {
634 return reHasUnicodeWord.test(string);
635}
636
637/**
638 * Converts `string` to an array.
639 *
640 * @private
641 * @param {string} string The string to convert.
642 * @returns {Array} Returns the converted array.
643 */
644function stringToArray(string) {
645 return hasUnicode(string)
646 ? unicodeToArray(string)
647 : asciiToArray(string);
648}
649
650/**
651 * Converts a Unicode `string` to an array.
652 *
653 * @private
654 * @param {string} string The string to convert.
655 * @returns {Array} Returns the converted array.
656 */
657function unicodeToArray(string) {
658 return string.match(reUnicode) || [];
659}
660
661/**
662 * Splits a Unicode `string` into an array of its words.
663 *
664 * @private
665 * @param {string} The string to inspect.
666 * @returns {Array} Returns the words of `string`.
667 */
668function unicodeWords(string) {
669 return string.match(reUnicodeWord) || [];
670}
671
672/** Used for built-in method references. */
673var objectProto = Object.prototype;
674
675/**
676 * Used to resolve the
677 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
678 * of values.
679 */
680var objectToString = objectProto.toString;
681
682/** Built-in value references. */
683var Symbol$1 = root$2.Symbol;
684
685/** Used to convert symbols to primitives and strings. */
686var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
687 symbolToString = symbolProto ? symbolProto.toString : undefined;
688
689/**
690 * The base implementation of `_.slice` without an iteratee call guard.
691 *
692 * @private
693 * @param {Array} array The array to slice.
694 * @param {number} [start=0] The start position.
695 * @param {number} [end=array.length] The end position.
696 * @returns {Array} Returns the slice of `array`.
697 */
698function baseSlice(array, start, end) {
699 var index = -1,
700 length = array.length;
701
702 if (start < 0) {
703 start = -start > length ? 0 : (length + start);
704 }
705 end = end > length ? length : end;
706 if (end < 0) {
707 end += length;
708 }
709 length = start > end ? 0 : ((end - start) >>> 0);
710 start >>>= 0;
711
712 var result = Array(length);
713 while (++index < length) {
714 result[index] = array[index + start];
715 }
716 return result;
717}
718
719/**
720 * The base implementation of `_.toString` which doesn't convert nullish
721 * values to empty strings.
722 *
723 * @private
724 * @param {*} value The value to process.
725 * @returns {string} Returns the string.
726 */
727function baseToString(value) {
728 // Exit early for strings to avoid a performance hit in some environments.
729 if (typeof value == 'string') {
730 return value;
731 }
732 if (isSymbol(value)) {
733 return symbolToString ? symbolToString.call(value) : '';
734 }
735 var result = (value + '');
736 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
737}
738
739/**
740 * Casts `array` to a slice if it's needed.
741 *
742 * @private
743 * @param {Array} array The array to inspect.
744 * @param {number} start The start position.
745 * @param {number} [end=array.length] The end position.
746 * @returns {Array} Returns the cast slice.
747 */
748function castSlice(array, start, end) {
749 var length = array.length;
750 end = end === undefined ? length : end;
751 return (!start && end >= length) ? array : baseSlice(array, start, end);
752}
753
754/**
755 * Creates a function like `_.lowerFirst`.
756 *
757 * @private
758 * @param {string} methodName The name of the `String` case method to use.
759 * @returns {Function} Returns the new case function.
760 */
761function createCaseFirst(methodName) {
762 return function(string) {
763 string = toString(string);
764
765 var strSymbols = hasUnicode(string)
766 ? stringToArray(string)
767 : undefined;
768
769 var chr = strSymbols
770 ? strSymbols[0]
771 : string.charAt(0);
772
773 var trailing = strSymbols
774 ? castSlice(strSymbols, 1).join('')
775 : string.slice(1);
776
777 return chr[methodName]() + trailing;
778 };
779}
780
781/**
782 * Creates a function like `_.camelCase`.
783 *
784 * @private
785 * @param {Function} callback The function to combine each word.
786 * @returns {Function} Returns the new compounder function.
787 */
788function createCompounder(callback) {
789 return function(string) {
790 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
791 };
792}
793
794/**
795 * Checks if `value` is object-like. A value is object-like if it's not `null`
796 * and has a `typeof` result of "object".
797 *
798 * @static
799 * @memberOf _
800 * @since 4.0.0
801 * @category Lang
802 * @param {*} value The value to check.
803 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
804 * @example
805 *
806 * _.isObjectLike({});
807 * // => true
808 *
809 * _.isObjectLike([1, 2, 3]);
810 * // => true
811 *
812 * _.isObjectLike(_.noop);
813 * // => false
814 *
815 * _.isObjectLike(null);
816 * // => false
817 */
818function isObjectLike(value) {
819 return !!value && typeof value == 'object';
820}
821
822/**
823 * Checks if `value` is classified as a `Symbol` primitive or object.
824 *
825 * @static
826 * @memberOf _
827 * @since 4.0.0
828 * @category Lang
829 * @param {*} value The value to check.
830 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
831 * @example
832 *
833 * _.isSymbol(Symbol.iterator);
834 * // => true
835 *
836 * _.isSymbol('abc');
837 * // => false
838 */
839function isSymbol(value) {
840 return typeof value == 'symbol' ||
841 (isObjectLike(value) && objectToString.call(value) == symbolTag);
842}
843
844/**
845 * Converts `value` to a string. An empty string is returned for `null`
846 * and `undefined` values. The sign of `-0` is preserved.
847 *
848 * @static
849 * @memberOf _
850 * @since 4.0.0
851 * @category Lang
852 * @param {*} value The value to process.
853 * @returns {string} Returns the string.
854 * @example
855 *
856 * _.toString(null);
857 * // => ''
858 *
859 * _.toString(-0);
860 * // => '-0'
861 *
862 * _.toString([1, 2, 3]);
863 * // => '1,2,3'
864 */
865function toString(value) {
866 return value == null ? '' : baseToString(value);
867}
868
869/**
870 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
871 *
872 * @static
873 * @memberOf _
874 * @since 3.0.0
875 * @category String
876 * @param {string} [string=''] The string to convert.
877 * @returns {string} Returns the camel cased string.
878 * @example
879 *
880 * _.camelCase('Foo Bar');
881 * // => 'fooBar'
882 *
883 * _.camelCase('--foo-bar--');
884 * // => 'fooBar'
885 *
886 * _.camelCase('__FOO_BAR__');
887 * // => 'fooBar'
888 */
889var camelCase = createCompounder(function(result, word, index) {
890 word = word.toLowerCase();
891 return result + (index ? capitalize(word) : word);
892});
893
894/**
895 * Converts the first character of `string` to upper case and the remaining
896 * to lower case.
897 *
898 * @static
899 * @memberOf _
900 * @since 3.0.0
901 * @category String
902 * @param {string} [string=''] The string to capitalize.
903 * @returns {string} Returns the capitalized string.
904 * @example
905 *
906 * _.capitalize('FRED');
907 * // => 'Fred'
908 */
909function capitalize(string) {
910 return upperFirst(toString(string).toLowerCase());
911}
912
913/**
914 * Deburrs `string` by converting
915 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
916 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
917 * letters to basic Latin letters and removing
918 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
919 *
920 * @static
921 * @memberOf _
922 * @since 3.0.0
923 * @category String
924 * @param {string} [string=''] The string to deburr.
925 * @returns {string} Returns the deburred string.
926 * @example
927 *
928 * _.deburr('déjà vu');
929 * // => 'deja vu'
930 */
931function deburr(string) {
932 string = toString(string);
933 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
934}
935
936/**
937 * Converts the first character of `string` to upper case.
938 *
939 * @static
940 * @memberOf _
941 * @since 4.0.0
942 * @category String
943 * @param {string} [string=''] The string to convert.
944 * @returns {string} Returns the converted string.
945 * @example
946 *
947 * _.upperFirst('fred');
948 * // => 'Fred'
949 *
950 * _.upperFirst('FRED');
951 * // => 'FRED'
952 */
953var upperFirst = createCaseFirst('toUpperCase');
954
955/**
956 * Splits `string` into an array of its words.
957 *
958 * @static
959 * @memberOf _
960 * @since 3.0.0
961 * @category String
962 * @param {string} [string=''] The string to inspect.
963 * @param {RegExp|string} [pattern] The pattern to match words.
964 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
965 * @returns {Array} Returns the words of `string`.
966 * @example
967 *
968 * _.words('fred, barney, & pebbles');
969 * // => ['fred', 'barney', 'pebbles']
970 *
971 * _.words('fred, barney, & pebbles', /[^, ]+/g);
972 * // => ['fred', 'barney', '&', 'pebbles']
973 */
974function words(string, pattern, guard) {
975 string = toString(string);
976 pattern = pattern;
977
978 if (pattern === undefined) {
979 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
980 }
981 return string.match(pattern) || [];
982}
983
984var lodash_camelcase = camelCase;
985
986Object.defineProperty(localsConvention, "__esModule", {
987 value: true
988});
989localsConvention.makeLocalsConventionReducer = makeLocalsConventionReducer;
990
991var _lodash = _interopRequireDefault$5(lodash_camelcase);
992
993function _interopRequireDefault$5(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
994
995function dashesCamelCase(string) {
996 return string.replace(/-+(\w)/g, (_, firstLetter) => firstLetter.toUpperCase());
997}
998
999function makeLocalsConventionReducer(localsConvention, inputFile) {
1000 const isFunc = typeof localsConvention === "function";
1001 return (tokens, [className, value]) => {
1002 if (isFunc) {
1003 const convention = localsConvention(className, value, inputFile);
1004 tokens[convention] = value;
1005 return tokens;
1006 }
1007
1008 switch (localsConvention) {
1009 case "camelCase":
1010 tokens[className] = value;
1011 tokens[(0, _lodash.default)(className)] = value;
1012 break;
1013
1014 case "camelCaseOnly":
1015 tokens[(0, _lodash.default)(className)] = value;
1016 break;
1017
1018 case "dashes":
1019 tokens[className] = value;
1020 tokens[dashesCamelCase(className)] = value;
1021 break;
1022
1023 case "dashesOnly":
1024 tokens[dashesCamelCase(className)] = value;
1025 break;
1026 }
1027
1028 return tokens;
1029 };
1030}
1031
1032var FileSystemLoader$1 = {};
1033
1034Object.defineProperty(FileSystemLoader$1, "__esModule", {
1035 value: true
1036});
1037FileSystemLoader$1.default = void 0;
1038
1039var _postcss$1 = _interopRequireDefault$4(require$$0);
1040
1041var _path = _interopRequireDefault$4(require$$0$1);
1042
1043var _Parser$1 = _interopRequireDefault$4(Parser$1);
1044
1045var _fs$1 = fs;
1046
1047function _interopRequireDefault$4(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1048
1049// Initially copied from https://github.com/css-modules/css-modules-loader-core
1050class Core {
1051 constructor(plugins) {
1052 this.plugins = plugins || Core.defaultPlugins;
1053 }
1054
1055 async load(sourceString, sourcePath, trace, pathFetcher) {
1056 const parser = new _Parser$1.default(pathFetcher, trace);
1057 const plugins = this.plugins.concat([parser.plugin()]);
1058 const result = await (0, _postcss$1.default)(plugins).process(sourceString, {
1059 from: sourcePath
1060 });
1061 return {
1062 injectableSource: result.css,
1063 exportTokens: parser.exportTokens
1064 };
1065 }
1066
1067} // Sorts dependencies in the following way:
1068// AAA comes before AA and A
1069// AB comes after AA and before A
1070// All Bs come after all As
1071// This ensures that the files are always returned in the following order:
1072// - In the order they were required, except
1073// - After all their dependencies
1074
1075
1076const traceKeySorter = (a, b) => {
1077 if (a.length < b.length) {
1078 return a < b.substring(0, a.length) ? -1 : 1;
1079 }
1080
1081 if (a.length > b.length) {
1082 return a.substring(0, b.length) <= b ? -1 : 1;
1083 }
1084
1085 return a < b ? -1 : 1;
1086};
1087
1088class FileSystemLoader {
1089 constructor(root, plugins, fileResolve) {
1090 if (root === "/" && process.platform === "win32") {
1091 const cwdDrive = process.cwd().slice(0, 3);
1092
1093 if (!/^[A-Za-z]:\\$/.test(cwdDrive)) {
1094 throw new Error(`Failed to obtain root from "${process.cwd()}".`);
1095 }
1096
1097 root = cwdDrive;
1098 }
1099
1100 this.root = root;
1101 this.fileResolve = fileResolve;
1102 this.sources = {};
1103 this.traces = {};
1104 this.importNr = 0;
1105 this.core = new Core(plugins);
1106 this.tokensByFile = {};
1107 this.fs = (0, _fs$1.getFileSystem)();
1108 }
1109
1110 async fetch(_newPath, relativeTo, _trace) {
1111 const newPath = _newPath.replace(/^["']|["']$/g, "");
1112
1113 const trace = _trace || String.fromCharCode(this.importNr++);
1114
1115 const useFileResolve = typeof this.fileResolve === "function";
1116 const fileResolvedPath = useFileResolve ? await this.fileResolve(newPath, relativeTo) : await Promise.resolve();
1117
1118 if (fileResolvedPath && !_path.default.isAbsolute(fileResolvedPath)) {
1119 throw new Error('The returned path from the "fileResolve" option must be absolute.');
1120 }
1121
1122 const relativeDir = _path.default.dirname(relativeTo);
1123
1124 const rootRelativePath = fileResolvedPath || _path.default.resolve(relativeDir, newPath);
1125
1126 let fileRelativePath = fileResolvedPath || _path.default.resolve(_path.default.resolve(this.root, relativeDir), newPath); // if the path is not relative or absolute, try to resolve it in node_modules
1127
1128
1129 if (!useFileResolve && newPath[0] !== "." && !_path.default.isAbsolute(newPath)) {
1130 try {
1131 fileRelativePath = require.resolve(newPath);
1132 } catch (e) {// noop
1133 }
1134 }
1135
1136 const tokens = this.tokensByFile[fileRelativePath];
1137 if (tokens) return tokens;
1138 return new Promise((resolve, reject) => {
1139 this.fs.readFile(fileRelativePath, "utf-8", async (err, source) => {
1140 if (err) reject(err);
1141 const {
1142 injectableSource,
1143 exportTokens
1144 } = await this.core.load(source, rootRelativePath, trace, this.fetch.bind(this));
1145 this.sources[fileRelativePath] = injectableSource;
1146 this.traces[trace] = fileRelativePath;
1147 this.tokensByFile[fileRelativePath] = exportTokens;
1148 resolve(exportTokens);
1149 });
1150 });
1151 }
1152
1153 get finalSource() {
1154 const traces = this.traces;
1155 const sources = this.sources;
1156 let written = new Set();
1157 return Object.keys(traces).sort(traceKeySorter).map(key => {
1158 const filename = traces[key];
1159
1160 if (written.has(filename)) {
1161 return null;
1162 }
1163
1164 written.add(filename);
1165 return sources[filename];
1166 }).join("");
1167 }
1168
1169}
1170
1171FileSystemLoader$1.default = FileSystemLoader;
1172
1173var scoping = {};
1174
1175var src$3 = {exports: {}};
1176
1177const PERMANENT_MARKER = 2;
1178const TEMPORARY_MARKER = 1;
1179
1180function createError(node, graph) {
1181 const er = new Error("Nondeterministic import's order");
1182
1183 const related = graph[node];
1184 const relatedNode = related.find(
1185 (relatedNode) => graph[relatedNode].indexOf(node) > -1
1186 );
1187
1188 er.nodes = [node, relatedNode];
1189
1190 return er;
1191}
1192
1193function walkGraph(node, graph, state, result, strict) {
1194 if (state[node] === PERMANENT_MARKER) {
1195 return;
1196 }
1197
1198 if (state[node] === TEMPORARY_MARKER) {
1199 if (strict) {
1200 return createError(node, graph);
1201 }
1202
1203 return;
1204 }
1205
1206 state[node] = TEMPORARY_MARKER;
1207
1208 const children = graph[node];
1209 const length = children.length;
1210
1211 for (let i = 0; i < length; ++i) {
1212 const error = walkGraph(children[i], graph, state, result, strict);
1213
1214 if (error instanceof Error) {
1215 return error;
1216 }
1217 }
1218
1219 state[node] = PERMANENT_MARKER;
1220
1221 result.push(node);
1222}
1223
1224function topologicalSort$1(graph, strict) {
1225 const result = [];
1226 const state = {};
1227
1228 const nodes = Object.keys(graph);
1229 const length = nodes.length;
1230
1231 for (let i = 0; i < length; ++i) {
1232 const er = walkGraph(nodes[i], graph, state, result, strict);
1233
1234 if (er instanceof Error) {
1235 return er;
1236 }
1237 }
1238
1239 return result;
1240}
1241
1242var topologicalSort_1 = topologicalSort$1;
1243
1244const topologicalSort = topologicalSort_1;
1245
1246const matchImports$1 = /^(.+?)\s+from\s+(?:"([^"]+)"|'([^']+)'|(global))$/;
1247const icssImport = /^:import\((?:"([^"]+)"|'([^']+)')\)/;
1248
1249const VISITED_MARKER = 1;
1250
1251/**
1252 * :import('G') {}
1253 *
1254 * Rule
1255 * composes: ... from 'A'
1256 * composes: ... from 'B'
1257
1258 * Rule
1259 * composes: ... from 'A'
1260 * composes: ... from 'A'
1261 * composes: ... from 'C'
1262 *
1263 * Results in:
1264 *
1265 * graph: {
1266 * G: [],
1267 * A: [],
1268 * B: ['A'],
1269 * C: ['A'],
1270 * }
1271 */
1272function addImportToGraph(importId, parentId, graph, visited) {
1273 const siblingsId = parentId + "_" + "siblings";
1274 const visitedId = parentId + "_" + importId;
1275
1276 if (visited[visitedId] !== VISITED_MARKER) {
1277 if (!Array.isArray(visited[siblingsId])) {
1278 visited[siblingsId] = [];
1279 }
1280
1281 const siblings = visited[siblingsId];
1282
1283 if (Array.isArray(graph[importId])) {
1284 graph[importId] = graph[importId].concat(siblings);
1285 } else {
1286 graph[importId] = siblings.slice();
1287 }
1288
1289 visited[visitedId] = VISITED_MARKER;
1290
1291 siblings.push(importId);
1292 }
1293}
1294
1295src$3.exports = (options = {}) => {
1296 let importIndex = 0;
1297 const createImportedName =
1298 typeof options.createImportedName !== "function"
1299 ? (importName /*, path*/) =>
1300 `i__imported_${importName.replace(/\W/g, "_")}_${importIndex++}`
1301 : options.createImportedName;
1302 const failOnWrongOrder = options.failOnWrongOrder;
1303
1304 return {
1305 postcssPlugin: "postcss-modules-extract-imports",
1306 prepare() {
1307 const graph = {};
1308 const visited = {};
1309 const existingImports = {};
1310 const importDecls = {};
1311 const imports = {};
1312
1313 return {
1314 Once(root, postcss) {
1315 // Check the existing imports order and save refs
1316 root.walkRules((rule) => {
1317 const matches = icssImport.exec(rule.selector);
1318
1319 if (matches) {
1320 const [, /*match*/ doubleQuotePath, singleQuotePath] = matches;
1321 const importPath = doubleQuotePath || singleQuotePath;
1322
1323 addImportToGraph(importPath, "root", graph, visited);
1324
1325 existingImports[importPath] = rule;
1326 }
1327 });
1328
1329 root.walkDecls(/^composes$/, (declaration) => {
1330 const matches = declaration.value.match(matchImports$1);
1331
1332 if (!matches) {
1333 return;
1334 }
1335
1336 let tmpSymbols;
1337 let [
1338 ,
1339 /*match*/ symbols,
1340 doubleQuotePath,
1341 singleQuotePath,
1342 global,
1343 ] = matches;
1344
1345 if (global) {
1346 // Composing globals simply means changing these classes to wrap them in global(name)
1347 tmpSymbols = symbols.split(/\s+/).map((s) => `global(${s})`);
1348 } else {
1349 const importPath = doubleQuotePath || singleQuotePath;
1350
1351 let parent = declaration.parent;
1352 let parentIndexes = "";
1353
1354 while (parent.type !== "root") {
1355 parentIndexes =
1356 parent.parent.index(parent) + "_" + parentIndexes;
1357 parent = parent.parent;
1358 }
1359
1360 const { selector } = declaration.parent;
1361 const parentRule = `_${parentIndexes}${selector}`;
1362
1363 addImportToGraph(importPath, parentRule, graph, visited);
1364
1365 importDecls[importPath] = declaration;
1366 imports[importPath] = imports[importPath] || {};
1367
1368 tmpSymbols = symbols.split(/\s+/).map((s) => {
1369 if (!imports[importPath][s]) {
1370 imports[importPath][s] = createImportedName(s, importPath);
1371 }
1372
1373 return imports[importPath][s];
1374 });
1375 }
1376
1377 declaration.value = tmpSymbols.join(" ");
1378 });
1379
1380 const importsOrder = topologicalSort(graph, failOnWrongOrder);
1381
1382 if (importsOrder instanceof Error) {
1383 const importPath = importsOrder.nodes.find((importPath) =>
1384 // eslint-disable-next-line no-prototype-builtins
1385 importDecls.hasOwnProperty(importPath)
1386 );
1387 const decl = importDecls[importPath];
1388
1389 throw decl.error(
1390 "Failed to resolve order of composed modules " +
1391 importsOrder.nodes
1392 .map((importPath) => "`" + importPath + "`")
1393 .join(", ") +
1394 ".",
1395 {
1396 plugin: "postcss-modules-extract-imports",
1397 word: "composes",
1398 }
1399 );
1400 }
1401
1402 let lastImportRule;
1403
1404 importsOrder.forEach((path) => {
1405 const importedSymbols = imports[path];
1406 let rule = existingImports[path];
1407
1408 if (!rule && importedSymbols) {
1409 rule = postcss.rule({
1410 selector: `:import("${path}")`,
1411 raws: { after: "\n" },
1412 });
1413
1414 if (lastImportRule) {
1415 root.insertAfter(lastImportRule, rule);
1416 } else {
1417 root.prepend(rule);
1418 }
1419 }
1420
1421 lastImportRule = rule;
1422
1423 if (!importedSymbols) {
1424 return;
1425 }
1426
1427 Object.keys(importedSymbols).forEach((importedSymbol) => {
1428 rule.append(
1429 postcss.decl({
1430 value: importedSymbol,
1431 prop: importedSymbols[importedSymbol],
1432 raws: { before: "\n " },
1433 })
1434 );
1435 });
1436 });
1437 },
1438 };
1439 },
1440 };
1441};
1442
1443src$3.exports.postcss = true;
1444
1445var srcExports$2 = src$3.exports;
1446
1447var wasmHash = {exports: {}};
1448
1449/*
1450 MIT License http://www.opensource.org/licenses/mit-license.php
1451 Author Tobias Koppers @sokra
1452*/
1453
1454var hasRequiredWasmHash;
1455
1456function requireWasmHash () {
1457 if (hasRequiredWasmHash) return wasmHash.exports;
1458 hasRequiredWasmHash = 1;
1459
1460 // 65536 is the size of a wasm memory page
1461 // 64 is the maximum chunk size for every possible wasm hash implementation
1462 // 4 is the maximum number of bytes per char for string encoding (max is utf-8)
1463 // ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
1464 const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
1465
1466 class WasmHash {
1467 /**
1468 * @param {WebAssembly.Instance} instance wasm instance
1469 * @param {WebAssembly.Instance[]} instancesPool pool of instances
1470 * @param {number} chunkSize size of data chunks passed to wasm
1471 * @param {number} digestSize size of digest returned by wasm
1472 */
1473 constructor(instance, instancesPool, chunkSize, digestSize) {
1474 const exports = /** @type {any} */ (instance.exports);
1475
1476 exports.init();
1477
1478 this.exports = exports;
1479 this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
1480 this.buffered = 0;
1481 this.instancesPool = instancesPool;
1482 this.chunkSize = chunkSize;
1483 this.digestSize = digestSize;
1484 }
1485
1486 reset() {
1487 this.buffered = 0;
1488 this.exports.init();
1489 }
1490
1491 /**
1492 * @param {Buffer | string} data data
1493 * @param {BufferEncoding=} encoding encoding
1494 * @returns {this} itself
1495 */
1496 update(data, encoding) {
1497 if (typeof data === "string") {
1498 while (data.length > MAX_SHORT_STRING) {
1499 this._updateWithShortString(data.slice(0, MAX_SHORT_STRING), encoding);
1500 data = data.slice(MAX_SHORT_STRING);
1501 }
1502
1503 this._updateWithShortString(data, encoding);
1504
1505 return this;
1506 }
1507
1508 this._updateWithBuffer(data);
1509
1510 return this;
1511 }
1512
1513 /**
1514 * @param {string} data data
1515 * @param {BufferEncoding=} encoding encoding
1516 * @returns {void}
1517 */
1518 _updateWithShortString(data, encoding) {
1519 const { exports, buffered, mem, chunkSize } = this;
1520
1521 let endPos;
1522
1523 if (data.length < 70) {
1524 if (!encoding || encoding === "utf-8" || encoding === "utf8") {
1525 endPos = buffered;
1526 for (let i = 0; i < data.length; i++) {
1527 const cc = data.charCodeAt(i);
1528
1529 if (cc < 0x80) {
1530 mem[endPos++] = cc;
1531 } else if (cc < 0x800) {
1532 mem[endPos] = (cc >> 6) | 0xc0;
1533 mem[endPos + 1] = (cc & 0x3f) | 0x80;
1534 endPos += 2;
1535 } else {
1536 // bail-out for weird chars
1537 endPos += mem.write(data.slice(i), endPos, encoding);
1538 break;
1539 }
1540 }
1541 } else if (encoding === "latin1") {
1542 endPos = buffered;
1543
1544 for (let i = 0; i < data.length; i++) {
1545 const cc = data.charCodeAt(i);
1546
1547 mem[endPos++] = cc;
1548 }
1549 } else {
1550 endPos = buffered + mem.write(data, buffered, encoding);
1551 }
1552 } else {
1553 endPos = buffered + mem.write(data, buffered, encoding);
1554 }
1555
1556 if (endPos < chunkSize) {
1557 this.buffered = endPos;
1558 } else {
1559 const l = endPos & ~(this.chunkSize - 1);
1560
1561 exports.update(l);
1562
1563 const newBuffered = endPos - l;
1564
1565 this.buffered = newBuffered;
1566
1567 if (newBuffered > 0) {
1568 mem.copyWithin(0, l, endPos);
1569 }
1570 }
1571 }
1572
1573 /**
1574 * @param {Buffer} data data
1575 * @returns {void}
1576 */
1577 _updateWithBuffer(data) {
1578 const { exports, buffered, mem } = this;
1579 const length = data.length;
1580
1581 if (buffered + length < this.chunkSize) {
1582 data.copy(mem, buffered, 0, length);
1583
1584 this.buffered += length;
1585 } else {
1586 const l = (buffered + length) & ~(this.chunkSize - 1);
1587
1588 if (l > 65536) {
1589 let i = 65536 - buffered;
1590
1591 data.copy(mem, buffered, 0, i);
1592 exports.update(65536);
1593
1594 const stop = l - buffered - 65536;
1595
1596 while (i < stop) {
1597 data.copy(mem, 0, i, i + 65536);
1598 exports.update(65536);
1599 i += 65536;
1600 }
1601
1602 data.copy(mem, 0, i, l - buffered);
1603
1604 exports.update(l - buffered - i);
1605 } else {
1606 data.copy(mem, buffered, 0, l - buffered);
1607
1608 exports.update(l);
1609 }
1610
1611 const newBuffered = length + buffered - l;
1612
1613 this.buffered = newBuffered;
1614
1615 if (newBuffered > 0) {
1616 data.copy(mem, 0, length - newBuffered, length);
1617 }
1618 }
1619 }
1620
1621 digest(type) {
1622 const { exports, buffered, mem, digestSize } = this;
1623
1624 exports.final(buffered);
1625
1626 this.instancesPool.push(this);
1627
1628 const hex = mem.toString("latin1", 0, digestSize);
1629
1630 if (type === "hex") {
1631 return hex;
1632 }
1633
1634 if (type === "binary" || !type) {
1635 return Buffer.from(hex, "hex");
1636 }
1637
1638 return Buffer.from(hex, "hex").toString(type);
1639 }
1640 }
1641
1642 const create = (wasmModule, instancesPool, chunkSize, digestSize) => {
1643 if (instancesPool.length > 0) {
1644 const old = instancesPool.pop();
1645
1646 old.reset();
1647
1648 return old;
1649 } else {
1650 return new WasmHash(
1651 new WebAssembly.Instance(wasmModule),
1652 instancesPool,
1653 chunkSize,
1654 digestSize
1655 );
1656 }
1657 };
1658
1659 wasmHash.exports = create;
1660 wasmHash.exports.MAX_SHORT_STRING = MAX_SHORT_STRING;
1661 return wasmHash.exports;
1662}
1663
1664/*
1665 MIT License http://www.opensource.org/licenses/mit-license.php
1666 Author Tobias Koppers @sokra
1667*/
1668
1669var xxhash64_1;
1670var hasRequiredXxhash64;
1671
1672function requireXxhash64 () {
1673 if (hasRequiredXxhash64) return xxhash64_1;
1674 hasRequiredXxhash64 = 1;
1675
1676 const create = requireWasmHash();
1677
1678 //#region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1
1679 const xxhash64 = new WebAssembly.Module(
1680 Buffer.from(
1681 // 1173 bytes
1682 "AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+AUIAC34BQgALByIEBGluaXQAAAZ1cGRhdGUAAQVmaW5hbAACBm1lbW9yeQIACrUIAzAAQtbrgu7q/Yn14AAkAELP1tO+0ser2UIkAUIAJAJC+erQ0OfJoeThACQDQgAkBAvUAQIBfwR+IABFBEAPCyMEIACtfCQEIwAhAiMBIQMjAiEEIwMhBQNAIAIgASkDAELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiECIAMgASkDCELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEDIAQgASkDEELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEEIAUgASkDGELP1tO+0ser2UJ+fEIfiUKHla+vmLbem55/fiEFIAAgAUEgaiIBSw0ACyACJAAgAyQBIAQkAiAFJAMLqwYCAX8EfiMEQgBSBH4jACICQgGJIwEiA0IHiXwjAiIEQgyJfCMDIgVCEol8IAJCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0gA0LP1tO+0ser2UJ+Qh+JQoeVr6+Ytt6bnn9+hUKHla+vmLbem55/fkKdo7Xqg7GNivoAfSAEQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IAVCz9bTvtLHq9lCfkIfiUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0FQsXP2bLx5brqJwsjBCAArXx8IQIDQCABQQhqIABNBEAgAiABKQMAQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQhuJQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IQIgAUEIaiEBDAELCyABQQRqIABNBEACfyACIAE1AgBCh5Wvr5i23puef36FQheJQs/W077Sx6vZQn5C+fPd8Zn2masWfCECIAFBBGoLIQELA0AgACABRwRAIAIgATEAAELFz9my8eW66id+hUILiUKHla+vmLbem55/fiECIAFBAWohAQwBCwtBACACIAJCIYiFQs/W077Sx6vZQn4iAiACQh2IhUL5893xmfaZqxZ+IgIgAkIgiIUiAkIgiCIDQv//A4NCIIYgA0KAgPz/D4NCEIiEIgNC/4GAgPAfg0IQhiADQoD+g4CA4D+DQgiIhCIDQo+AvIDwgcAHg0IIhiADQvCBwIeAnoD4AINCBIiEIgNChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IANCsODAgYOGjJgwhHw3AwBBCCACQv////8PgyICQv//A4NCIIYgAkKAgPz/D4NCEIiEIgJC/4GAgPAfg0IQhiACQoD+g4CA4D+DQgiIhCICQo+AvIDwgcAHg0IIhiACQvCBwIeAnoD4AINCBIiEIgJChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IAJCsODAgYOGjJgwhHw3AwAL",
1683 "base64"
1684 )
1685 );
1686 //#endregion
1687
1688 xxhash64_1 = create.bind(null, xxhash64, [], 32, 16);
1689 return xxhash64_1;
1690}
1691
1692var BatchedHash_1;
1693var hasRequiredBatchedHash;
1694
1695function requireBatchedHash () {
1696 if (hasRequiredBatchedHash) return BatchedHash_1;
1697 hasRequiredBatchedHash = 1;
1698 const MAX_SHORT_STRING = requireWasmHash().MAX_SHORT_STRING;
1699
1700 class BatchedHash {
1701 constructor(hash) {
1702 this.string = undefined;
1703 this.encoding = undefined;
1704 this.hash = hash;
1705 }
1706
1707 /**
1708 * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
1709 * @param {string|Buffer} data data
1710 * @param {string=} inputEncoding data encoding
1711 * @returns {this} updated hash
1712 */
1713 update(data, inputEncoding) {
1714 if (this.string !== undefined) {
1715 if (
1716 typeof data === "string" &&
1717 inputEncoding === this.encoding &&
1718 this.string.length + data.length < MAX_SHORT_STRING
1719 ) {
1720 this.string += data;
1721
1722 return this;
1723 }
1724
1725 this.hash.update(this.string, this.encoding);
1726 this.string = undefined;
1727 }
1728
1729 if (typeof data === "string") {
1730 if (
1731 data.length < MAX_SHORT_STRING &&
1732 // base64 encoding is not valid since it may contain padding chars
1733 (!inputEncoding || !inputEncoding.startsWith("ba"))
1734 ) {
1735 this.string = data;
1736 this.encoding = inputEncoding;
1737 } else {
1738 this.hash.update(data, inputEncoding);
1739 }
1740 } else {
1741 this.hash.update(data);
1742 }
1743
1744 return this;
1745 }
1746
1747 /**
1748 * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
1749 * @param {string=} encoding encoding of the return value
1750 * @returns {string|Buffer} digest
1751 */
1752 digest(encoding) {
1753 if (this.string !== undefined) {
1754 this.hash.update(this.string, this.encoding);
1755 }
1756
1757 return this.hash.digest(encoding);
1758 }
1759 }
1760
1761 BatchedHash_1 = BatchedHash;
1762 return BatchedHash_1;
1763}
1764
1765/*
1766 MIT License http://www.opensource.org/licenses/mit-license.php
1767 Author Tobias Koppers @sokra
1768*/
1769
1770var md4_1;
1771var hasRequiredMd4;
1772
1773function requireMd4 () {
1774 if (hasRequiredMd4) return md4_1;
1775 hasRequiredMd4 = 1;
1776
1777 const create = requireWasmHash();
1778
1779 //#region wasm code: md4 (../../../assembly/hash/md4.asm.ts) --initialMemory 1
1780 const md4 = new WebAssembly.Module(
1781 Buffer.from(
1782 // 2150 bytes
1783 "AGFzbQEAAAABCAJgAX8AYAAAAwUEAQAAAAUDAQABBhoFfwFBAAt/AUEAC38BQQALfwFBAAt/AUEACwciBARpbml0AAAGdXBkYXRlAAIFZmluYWwAAwZtZW1vcnkCAAqFEAQmAEGBxpS6BiQBQYnXtv5+JAJB/rnrxXkkA0H2qMmBASQEQQAkAAvMCgEYfyMBIQojAiEGIwMhByMEIQgDQCAAIAVLBEAgBSgCCCINIAcgBiAFKAIEIgsgCCAHIAUoAgAiDCAKIAggBiAHIAhzcXNqakEDdyIDIAYgB3Nxc2pqQQd3IgEgAyAGc3FzampBC3chAiAFKAIUIg8gASACIAUoAhAiCSADIAEgBSgCDCIOIAYgAyACIAEgA3Nxc2pqQRN3IgQgASACc3FzampBA3ciAyACIARzcXNqakEHdyEBIAUoAiAiEiADIAEgBSgCHCIRIAQgAyAFKAIYIhAgAiAEIAEgAyAEc3FzampBC3ciAiABIANzcXNqakETdyIEIAEgAnNxc2pqQQN3IQMgBSgCLCIVIAQgAyAFKAIoIhQgAiAEIAUoAiQiEyABIAIgAyACIARzcXNqakEHdyIBIAMgBHNxc2pqQQt3IgIgASADc3FzampBE3chBCAPIBAgCSAVIBQgEyAFKAI4IhYgAiAEIAUoAjQiFyABIAIgBSgCMCIYIAMgASAEIAEgAnNxc2pqQQN3IgEgAiAEc3FzampBB3ciAiABIARzcXNqakELdyIDIAkgAiAMIAEgBSgCPCIJIAQgASADIAEgAnNxc2pqQRN3IgEgAiADcnEgAiADcXJqakGZ84nUBWpBA3ciAiABIANycSABIANxcmpqQZnzidQFakEFdyIEIAEgAnJxIAEgAnFyaiASakGZ84nUBWpBCXciAyAPIAQgCyACIBggASADIAIgBHJxIAIgBHFyampBmfOJ1AVqQQ13IgEgAyAEcnEgAyAEcXJqakGZ84nUBWpBA3ciAiABIANycSABIANxcmpqQZnzidQFakEFdyIEIAEgAnJxIAEgAnFyampBmfOJ1AVqQQl3IgMgECAEIAIgFyABIAMgAiAEcnEgAiAEcXJqakGZ84nUBWpBDXciASADIARycSADIARxcmogDWpBmfOJ1AVqQQN3IgIgASADcnEgASADcXJqakGZ84nUBWpBBXciBCABIAJycSABIAJxcmpqQZnzidQFakEJdyIDIBEgBCAOIAIgFiABIAMgAiAEcnEgAiAEcXJqakGZ84nUBWpBDXciASADIARycSADIARxcmpqQZnzidQFakEDdyICIAEgA3JxIAEgA3FyampBmfOJ1AVqQQV3IgQgASACcnEgASACcXJqakGZ84nUBWpBCXciAyAMIAIgAyAJIAEgAyACIARycSACIARxcmpqQZnzidQFakENdyIBcyAEc2pqQaHX5/YGakEDdyICIAQgASACcyADc2ogEmpBodfn9gZqQQl3IgRzIAFzampBodfn9gZqQQt3IgMgAiADIBggASADIARzIAJzampBodfn9gZqQQ93IgFzIARzaiANakGh1+f2BmpBA3ciAiAUIAQgASACcyADc2pqQaHX5/YGakEJdyIEcyABc2pqQaHX5/YGakELdyIDIAsgAiADIBYgASADIARzIAJzampBodfn9gZqQQ93IgFzIARzampBodfn9gZqQQN3IgIgEyAEIAEgAnMgA3NqakGh1+f2BmpBCXciBHMgAXNqakGh1+f2BmpBC3chAyAKIA4gAiADIBcgASADIARzIAJzampBodfn9gZqQQ93IgFzIARzampBodfn9gZqQQN3IgJqIQogBiAJIAEgESADIAIgFSAEIAEgAnMgA3NqakGh1+f2BmpBCXciBHMgAXNqakGh1+f2BmpBC3ciAyAEcyACc2pqQaHX5/YGakEPd2ohBiADIAdqIQcgBCAIaiEIIAVBQGshBQwBCwsgCiQBIAYkAiAHJAMgCCQECw0AIAAQASMAIABqJAAL/wQCA38BfiMAIABqrUIDhiEEIABByABqQUBxIgJBCGshAyAAIgFBAWohACABQYABOgAAA0AgACACSUEAIABBB3EbBEAgAEEAOgAAIABBAWohAAwBCwsDQCAAIAJJBEAgAEIANwMAIABBCGohAAwBCwsgAyAENwMAIAIQAUEAIwGtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEIIwKtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEQIwOtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEYIwStIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAAs=",
1784 "base64"
1785 )
1786 );
1787 //#endregion
1788
1789 md4_1 = create.bind(null, md4, [], 64, 32);
1790 return md4_1;
1791}
1792
1793var BulkUpdateDecorator_1;
1794var hasRequiredBulkUpdateDecorator;
1795
1796function requireBulkUpdateDecorator () {
1797 if (hasRequiredBulkUpdateDecorator) return BulkUpdateDecorator_1;
1798 hasRequiredBulkUpdateDecorator = 1;
1799 const BULK_SIZE = 2000;
1800
1801 // We are using an object instead of a Map as this will stay static during the runtime
1802 // so access to it can be optimized by v8
1803 const digestCaches = {};
1804
1805 class BulkUpdateDecorator {
1806 /**
1807 * @param {Hash | function(): Hash} hashOrFactory function to create a hash
1808 * @param {string=} hashKey key for caching
1809 */
1810 constructor(hashOrFactory, hashKey) {
1811 this.hashKey = hashKey;
1812
1813 if (typeof hashOrFactory === "function") {
1814 this.hashFactory = hashOrFactory;
1815 this.hash = undefined;
1816 } else {
1817 this.hashFactory = undefined;
1818 this.hash = hashOrFactory;
1819 }
1820
1821 this.buffer = "";
1822 }
1823
1824 /**
1825 * Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
1826 * @param {string|Buffer} data data
1827 * @param {string=} inputEncoding data encoding
1828 * @returns {this} updated hash
1829 */
1830 update(data, inputEncoding) {
1831 if (
1832 inputEncoding !== undefined ||
1833 typeof data !== "string" ||
1834 data.length > BULK_SIZE
1835 ) {
1836 if (this.hash === undefined) {
1837 this.hash = this.hashFactory();
1838 }
1839
1840 if (this.buffer.length > 0) {
1841 this.hash.update(this.buffer);
1842 this.buffer = "";
1843 }
1844
1845 this.hash.update(data, inputEncoding);
1846 } else {
1847 this.buffer += data;
1848
1849 if (this.buffer.length > BULK_SIZE) {
1850 if (this.hash === undefined) {
1851 this.hash = this.hashFactory();
1852 }
1853
1854 this.hash.update(this.buffer);
1855 this.buffer = "";
1856 }
1857 }
1858
1859 return this;
1860 }
1861
1862 /**
1863 * Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
1864 * @param {string=} encoding encoding of the return value
1865 * @returns {string|Buffer} digest
1866 */
1867 digest(encoding) {
1868 let digestCache;
1869
1870 const buffer = this.buffer;
1871
1872 if (this.hash === undefined) {
1873 // short data for hash, we can use caching
1874 const cacheKey = `${this.hashKey}-${encoding}`;
1875
1876 digestCache = digestCaches[cacheKey];
1877
1878 if (digestCache === undefined) {
1879 digestCache = digestCaches[cacheKey] = new Map();
1880 }
1881
1882 const cacheEntry = digestCache.get(buffer);
1883
1884 if (cacheEntry !== undefined) {
1885 return cacheEntry;
1886 }
1887
1888 this.hash = this.hashFactory();
1889 }
1890
1891 if (buffer.length > 0) {
1892 this.hash.update(buffer);
1893 }
1894
1895 const digestResult = this.hash.digest(encoding);
1896
1897 if (digestCache !== undefined) {
1898 digestCache.set(buffer, digestResult);
1899 }
1900
1901 return digestResult;
1902 }
1903 }
1904
1905 BulkUpdateDecorator_1 = BulkUpdateDecorator;
1906 return BulkUpdateDecorator_1;
1907}
1908
1909const baseEncodeTables = {
1910 26: "abcdefghijklmnopqrstuvwxyz",
1911 32: "123456789abcdefghjkmnpqrstuvwxyz", // no 0lio
1912 36: "0123456789abcdefghijklmnopqrstuvwxyz",
1913 49: "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ", // no lIO
1914 52: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
1915 58: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ", // no 0lIO
1916 62: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
1917 64: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_",
1918};
1919
1920/**
1921 * @param {Uint32Array} uint32Array Treated as a long base-0x100000000 number, little endian
1922 * @param {number} divisor The divisor
1923 * @return {number} Modulo (remainder) of the division
1924 */
1925function divmod32(uint32Array, divisor) {
1926 let carry = 0;
1927 for (let i = uint32Array.length - 1; i >= 0; i--) {
1928 const value = carry * 0x100000000 + uint32Array[i];
1929 carry = value % divisor;
1930 uint32Array[i] = Math.floor(value / divisor);
1931 }
1932 return carry;
1933}
1934
1935function encodeBufferToBase(buffer, base, length) {
1936 const encodeTable = baseEncodeTables[base];
1937
1938 if (!encodeTable) {
1939 throw new Error("Unknown encoding base" + base);
1940 }
1941
1942 // Input bits are only enough to generate this many characters
1943 const limit = Math.ceil((buffer.length * 8) / Math.log2(base));
1944 length = Math.min(length, limit);
1945
1946 // Most of the crypto digests (if not all) has length a multiple of 4 bytes.
1947 // Fewer numbers in the array means faster math.
1948 const uint32Array = new Uint32Array(Math.ceil(buffer.length / 4));
1949
1950 // Make sure the input buffer data is copied and is not mutated by reference.
1951 // divmod32() would corrupt the BulkUpdateDecorator cache otherwise.
1952 buffer.copy(Buffer.from(uint32Array.buffer));
1953
1954 let output = "";
1955
1956 for (let i = 0; i < length; i++) {
1957 output = encodeTable[divmod32(uint32Array, base)] + output;
1958 }
1959
1960 return output;
1961}
1962
1963let crypto = undefined;
1964let createXXHash64 = undefined;
1965let createMd4 = undefined;
1966let BatchedHash = undefined;
1967let BulkUpdateDecorator = undefined;
1968
1969function getHashDigest$1(buffer, algorithm, digestType, maxLength) {
1970 algorithm = algorithm || "xxhash64";
1971 maxLength = maxLength || 9999;
1972
1973 let hash;
1974
1975 if (algorithm === "xxhash64") {
1976 if (createXXHash64 === undefined) {
1977 createXXHash64 = requireXxhash64();
1978
1979 if (BatchedHash === undefined) {
1980 BatchedHash = requireBatchedHash();
1981 }
1982 }
1983
1984 hash = new BatchedHash(createXXHash64());
1985 } else if (algorithm === "md4") {
1986 if (createMd4 === undefined) {
1987 createMd4 = requireMd4();
1988
1989 if (BatchedHash === undefined) {
1990 BatchedHash = requireBatchedHash();
1991 }
1992 }
1993
1994 hash = new BatchedHash(createMd4());
1995 } else if (algorithm === "native-md4") {
1996 if (typeof crypto === "undefined") {
1997 crypto = require$$3;
1998
1999 if (BulkUpdateDecorator === undefined) {
2000 BulkUpdateDecorator = requireBulkUpdateDecorator();
2001 }
2002 }
2003
2004 hash = new BulkUpdateDecorator(() => crypto.createHash("md4"), "md4");
2005 } else {
2006 if (typeof crypto === "undefined") {
2007 crypto = require$$3;
2008
2009 if (BulkUpdateDecorator === undefined) {
2010 BulkUpdateDecorator = requireBulkUpdateDecorator();
2011 }
2012 }
2013
2014 hash = new BulkUpdateDecorator(
2015 () => crypto.createHash(algorithm),
2016 algorithm
2017 );
2018 }
2019
2020 hash.update(buffer);
2021
2022 if (
2023 digestType === "base26" ||
2024 digestType === "base32" ||
2025 digestType === "base36" ||
2026 digestType === "base49" ||
2027 digestType === "base52" ||
2028 digestType === "base58" ||
2029 digestType === "base62"
2030 ) {
2031 return encodeBufferToBase(hash.digest(), digestType.substr(4), maxLength);
2032 } else {
2033 return hash.digest(digestType || "hex").substr(0, maxLength);
2034 }
2035}
2036
2037var getHashDigest_1 = getHashDigest$1;
2038
2039const path$1 = require$$0$1;
2040const getHashDigest = getHashDigest_1;
2041
2042function interpolateName$1(loaderContext, name, options = {}) {
2043 let filename;
2044
2045 const hasQuery =
2046 loaderContext.resourceQuery && loaderContext.resourceQuery.length > 1;
2047
2048 if (typeof name === "function") {
2049 filename = name(
2050 loaderContext.resourcePath,
2051 hasQuery ? loaderContext.resourceQuery : undefined
2052 );
2053 } else {
2054 filename = name || "[hash].[ext]";
2055 }
2056
2057 const context = options.context;
2058 const content = options.content;
2059 const regExp = options.regExp;
2060
2061 let ext = "bin";
2062 let basename = "file";
2063 let directory = "";
2064 let folder = "";
2065 let query = "";
2066
2067 if (loaderContext.resourcePath) {
2068 const parsed = path$1.parse(loaderContext.resourcePath);
2069 let resourcePath = loaderContext.resourcePath;
2070
2071 if (parsed.ext) {
2072 ext = parsed.ext.substr(1);
2073 }
2074
2075 if (parsed.dir) {
2076 basename = parsed.name;
2077 resourcePath = parsed.dir + path$1.sep;
2078 }
2079
2080 if (typeof context !== "undefined") {
2081 directory = path$1
2082 .relative(context, resourcePath + "_")
2083 .replace(/\\/g, "/")
2084 .replace(/\.\.(\/)?/g, "_$1");
2085 directory = directory.substr(0, directory.length - 1);
2086 } else {
2087 directory = resourcePath.replace(/\\/g, "/").replace(/\.\.(\/)?/g, "_$1");
2088 }
2089
2090 if (directory.length === 1) {
2091 directory = "";
2092 } else if (directory.length > 1) {
2093 folder = path$1.basename(directory);
2094 }
2095 }
2096
2097 if (loaderContext.resourceQuery && loaderContext.resourceQuery.length > 1) {
2098 query = loaderContext.resourceQuery;
2099
2100 const hashIdx = query.indexOf("#");
2101
2102 if (hashIdx >= 0) {
2103 query = query.substr(0, hashIdx);
2104 }
2105 }
2106
2107 let url = filename;
2108
2109 if (content) {
2110 // Match hash template
2111 url = url
2112 // `hash` and `contenthash` are same in `loader-utils` context
2113 // let's keep `hash` for backward compatibility
2114 .replace(
2115 /\[(?:([^[:\]]+):)?(?:hash|contenthash)(?::([a-z]+\d*))?(?::(\d+))?\]/gi,
2116 (all, hashType, digestType, maxLength) =>
2117 getHashDigest(content, hashType, digestType, parseInt(maxLength, 10))
2118 );
2119 }
2120
2121 url = url
2122 .replace(/\[ext\]/gi, () => ext)
2123 .replace(/\[name\]/gi, () => basename)
2124 .replace(/\[path\]/gi, () => directory)
2125 .replace(/\[folder\]/gi, () => folder)
2126 .replace(/\[query\]/gi, () => query);
2127
2128 if (regExp && loaderContext.resourcePath) {
2129 const match = loaderContext.resourcePath.match(new RegExp(regExp));
2130
2131 match &&
2132 match.forEach((matched, i) => {
2133 url = url.replace(new RegExp("\\[" + i + "\\]", "ig"), matched);
2134 });
2135 }
2136
2137 if (
2138 typeof loaderContext.options === "object" &&
2139 typeof loaderContext.options.customInterpolateName === "function"
2140 ) {
2141 url = loaderContext.options.customInterpolateName.call(
2142 loaderContext,
2143 url,
2144 name,
2145 options
2146 );
2147 }
2148
2149 return url;
2150}
2151
2152var interpolateName_1 = interpolateName$1;
2153
2154var interpolateName = interpolateName_1;
2155var path = require$$0$1;
2156
2157/**
2158 * @param {string} pattern
2159 * @param {object} options
2160 * @param {string} options.context
2161 * @param {string} options.hashPrefix
2162 * @return {function}
2163 */
2164var genericNames = function createGenerator(pattern, options) {
2165 options = options || {};
2166 var context =
2167 options && typeof options.context === "string"
2168 ? options.context
2169 : process.cwd();
2170 var hashPrefix =
2171 options && typeof options.hashPrefix === "string" ? options.hashPrefix : "";
2172
2173 /**
2174 * @param {string} localName Usually a class name
2175 * @param {string} filepath Absolute path
2176 * @return {string}
2177 */
2178 return function generate(localName, filepath) {
2179 var name = pattern.replace(/\[local\]/gi, localName);
2180 var loaderContext = {
2181 resourcePath: filepath,
2182 };
2183
2184 var loaderOptions = {
2185 content:
2186 hashPrefix +
2187 path.relative(context, filepath).replace(/\\/g, "/") +
2188 "\x00" +
2189 localName,
2190 context: context,
2191 };
2192
2193 var genericName = interpolateName(loaderContext, name, loaderOptions);
2194 return genericName
2195 .replace(new RegExp("[^a-zA-Z0-9\\-_\u00A0-\uFFFF]", "g"), "-")
2196 .replace(/^((-?[0-9])|--)/, "_$1");
2197 };
2198};
2199
2200var src$2 = {exports: {}};
2201
2202var dist = {exports: {}};
2203
2204var processor = {exports: {}};
2205
2206var parser = {exports: {}};
2207
2208var root$1 = {exports: {}};
2209
2210var container = {exports: {}};
2211
2212var node$1 = {exports: {}};
2213
2214var util = {};
2215
2216var unesc = {exports: {}};
2217
2218(function (module, exports) {
2219
2220 exports.__esModule = true;
2221 exports["default"] = unesc;
2222
2223 // Many thanks for this post which made this migration much easier.
2224 // https://mathiasbynens.be/notes/css-escapes
2225
2226 /**
2227 *
2228 * @param {string} str
2229 * @returns {[string, number]|undefined}
2230 */
2231 function gobbleHex(str) {
2232 var lower = str.toLowerCase();
2233 var hex = '';
2234 var spaceTerminated = false;
2235
2236 for (var i = 0; i < 6 && lower[i] !== undefined; i++) {
2237 var code = lower.charCodeAt(i); // check to see if we are dealing with a valid hex char [a-f|0-9]
2238
2239 var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57; // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point
2240
2241 spaceTerminated = code === 32;
2242
2243 if (!valid) {
2244 break;
2245 }
2246
2247 hex += lower[i];
2248 }
2249
2250 if (hex.length === 0) {
2251 return undefined;
2252 }
2253
2254 var codePoint = parseInt(hex, 16);
2255 var isSurrogate = codePoint >= 0xD800 && codePoint <= 0xDFFF; // Add special case for
2256 // "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point"
2257 // https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point
2258
2259 if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10FFFF) {
2260 return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)];
2261 }
2262
2263 return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)];
2264 }
2265
2266 var CONTAINS_ESCAPE = /\\/;
2267
2268 function unesc(str) {
2269 var needToProcess = CONTAINS_ESCAPE.test(str);
2270
2271 if (!needToProcess) {
2272 return str;
2273 }
2274
2275 var ret = "";
2276
2277 for (var i = 0; i < str.length; i++) {
2278 if (str[i] === "\\") {
2279 var gobbled = gobbleHex(str.slice(i + 1, i + 7));
2280
2281 if (gobbled !== undefined) {
2282 ret += gobbled[0];
2283 i += gobbled[1];
2284 continue;
2285 } // Retain a pair of \\ if double escaped `\\\\`
2286 // https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e
2287
2288
2289 if (str[i + 1] === "\\") {
2290 ret += "\\";
2291 i++;
2292 continue;
2293 } // if \\ is at the end of the string retain it
2294 // https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb
2295
2296
2297 if (str.length === i + 1) {
2298 ret += str[i];
2299 }
2300
2301 continue;
2302 }
2303
2304 ret += str[i];
2305 }
2306
2307 return ret;
2308 }
2309
2310 module.exports = exports.default;
2311} (unesc, unesc.exports));
2312
2313var unescExports = unesc.exports;
2314
2315var getProp = {exports: {}};
2316
2317(function (module, exports) {
2318
2319 exports.__esModule = true;
2320 exports["default"] = getProp;
2321
2322 function getProp(obj) {
2323 for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2324 props[_key - 1] = arguments[_key];
2325 }
2326
2327 while (props.length > 0) {
2328 var prop = props.shift();
2329
2330 if (!obj[prop]) {
2331 return undefined;
2332 }
2333
2334 obj = obj[prop];
2335 }
2336
2337 return obj;
2338 }
2339
2340 module.exports = exports.default;
2341} (getProp, getProp.exports));
2342
2343var getPropExports = getProp.exports;
2344
2345var ensureObject = {exports: {}};
2346
2347(function (module, exports) {
2348
2349 exports.__esModule = true;
2350 exports["default"] = ensureObject;
2351
2352 function ensureObject(obj) {
2353 for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2354 props[_key - 1] = arguments[_key];
2355 }
2356
2357 while (props.length > 0) {
2358 var prop = props.shift();
2359
2360 if (!obj[prop]) {
2361 obj[prop] = {};
2362 }
2363
2364 obj = obj[prop];
2365 }
2366 }
2367
2368 module.exports = exports.default;
2369} (ensureObject, ensureObject.exports));
2370
2371var ensureObjectExports = ensureObject.exports;
2372
2373var stripComments = {exports: {}};
2374
2375(function (module, exports) {
2376
2377 exports.__esModule = true;
2378 exports["default"] = stripComments;
2379
2380 function stripComments(str) {
2381 var s = "";
2382 var commentStart = str.indexOf("/*");
2383 var lastEnd = 0;
2384
2385 while (commentStart >= 0) {
2386 s = s + str.slice(lastEnd, commentStart);
2387 var commentEnd = str.indexOf("*/", commentStart + 2);
2388
2389 if (commentEnd < 0) {
2390 return s;
2391 }
2392
2393 lastEnd = commentEnd + 2;
2394 commentStart = str.indexOf("/*", lastEnd);
2395 }
2396
2397 s = s + str.slice(lastEnd);
2398 return s;
2399 }
2400
2401 module.exports = exports.default;
2402} (stripComments, stripComments.exports));
2403
2404var stripCommentsExports = stripComments.exports;
2405
2406util.__esModule = true;
2407util.stripComments = util.ensureObject = util.getProp = util.unesc = void 0;
2408
2409var _unesc = _interopRequireDefault$3(unescExports);
2410
2411util.unesc = _unesc["default"];
2412
2413var _getProp = _interopRequireDefault$3(getPropExports);
2414
2415util.getProp = _getProp["default"];
2416
2417var _ensureObject = _interopRequireDefault$3(ensureObjectExports);
2418
2419util.ensureObject = _ensureObject["default"];
2420
2421var _stripComments = _interopRequireDefault$3(stripCommentsExports);
2422
2423util.stripComments = _stripComments["default"];
2424
2425function _interopRequireDefault$3(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
2426
2427(function (module, exports) {
2428
2429 exports.__esModule = true;
2430 exports["default"] = void 0;
2431
2432 var _util = util;
2433
2434 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2435
2436 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; }
2437
2438 var cloneNode = function cloneNode(obj, parent) {
2439 if (typeof obj !== 'object' || obj === null) {
2440 return obj;
2441 }
2442
2443 var cloned = new obj.constructor();
2444
2445 for (var i in obj) {
2446 if (!obj.hasOwnProperty(i)) {
2447 continue;
2448 }
2449
2450 var value = obj[i];
2451 var type = typeof value;
2452
2453 if (i === 'parent' && type === 'object') {
2454 if (parent) {
2455 cloned[i] = parent;
2456 }
2457 } else if (value instanceof Array) {
2458 cloned[i] = value.map(function (j) {
2459 return cloneNode(j, cloned);
2460 });
2461 } else {
2462 cloned[i] = cloneNode(value, cloned);
2463 }
2464 }
2465
2466 return cloned;
2467 };
2468
2469 var Node = /*#__PURE__*/function () {
2470 function Node(opts) {
2471 if (opts === void 0) {
2472 opts = {};
2473 }
2474
2475 Object.assign(this, opts);
2476 this.spaces = this.spaces || {};
2477 this.spaces.before = this.spaces.before || '';
2478 this.spaces.after = this.spaces.after || '';
2479 }
2480
2481 var _proto = Node.prototype;
2482
2483 _proto.remove = function remove() {
2484 if (this.parent) {
2485 this.parent.removeChild(this);
2486 }
2487
2488 this.parent = undefined;
2489 return this;
2490 };
2491
2492 _proto.replaceWith = function replaceWith() {
2493 if (this.parent) {
2494 for (var index in arguments) {
2495 this.parent.insertBefore(this, arguments[index]);
2496 }
2497
2498 this.remove();
2499 }
2500
2501 return this;
2502 };
2503
2504 _proto.next = function next() {
2505 return this.parent.at(this.parent.index(this) + 1);
2506 };
2507
2508 _proto.prev = function prev() {
2509 return this.parent.at(this.parent.index(this) - 1);
2510 };
2511
2512 _proto.clone = function clone(overrides) {
2513 if (overrides === void 0) {
2514 overrides = {};
2515 }
2516
2517 var cloned = cloneNode(this);
2518
2519 for (var name in overrides) {
2520 cloned[name] = overrides[name];
2521 }
2522
2523 return cloned;
2524 }
2525 /**
2526 * Some non-standard syntax doesn't follow normal escaping rules for css.
2527 * This allows non standard syntax to be appended to an existing property
2528 * by specifying the escaped value. By specifying the escaped value,
2529 * illegal characters are allowed to be directly inserted into css output.
2530 * @param {string} name the property to set
2531 * @param {any} value the unescaped value of the property
2532 * @param {string} valueEscaped optional. the escaped value of the property.
2533 */
2534 ;
2535
2536 _proto.appendToPropertyAndEscape = function appendToPropertyAndEscape(name, value, valueEscaped) {
2537 if (!this.raws) {
2538 this.raws = {};
2539 }
2540
2541 var originalValue = this[name];
2542 var originalEscaped = this.raws[name];
2543 this[name] = originalValue + value; // this may trigger a setter that updates raws, so it has to be set first.
2544
2545 if (originalEscaped || valueEscaped !== value) {
2546 this.raws[name] = (originalEscaped || originalValue) + valueEscaped;
2547 } else {
2548 delete this.raws[name]; // delete any escaped value that was created by the setter.
2549 }
2550 }
2551 /**
2552 * Some non-standard syntax doesn't follow normal escaping rules for css.
2553 * This allows the escaped value to be specified directly, allowing illegal
2554 * characters to be directly inserted into css output.
2555 * @param {string} name the property to set
2556 * @param {any} value the unescaped value of the property
2557 * @param {string} valueEscaped the escaped value of the property.
2558 */
2559 ;
2560
2561 _proto.setPropertyAndEscape = function setPropertyAndEscape(name, value, valueEscaped) {
2562 if (!this.raws) {
2563 this.raws = {};
2564 }
2565
2566 this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
2567
2568 this.raws[name] = valueEscaped;
2569 }
2570 /**
2571 * When you want a value to passed through to CSS directly. This method
2572 * deletes the corresponding raw value causing the stringifier to fallback
2573 * to the unescaped value.
2574 * @param {string} name the property to set.
2575 * @param {any} value The value that is both escaped and unescaped.
2576 */
2577 ;
2578
2579 _proto.setPropertyWithoutEscape = function setPropertyWithoutEscape(name, value) {
2580 this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
2581
2582 if (this.raws) {
2583 delete this.raws[name];
2584 }
2585 }
2586 /**
2587 *
2588 * @param {number} line The number (starting with 1)
2589 * @param {number} column The column number (starting with 1)
2590 */
2591 ;
2592
2593 _proto.isAtPosition = function isAtPosition(line, column) {
2594 if (this.source && this.source.start && this.source.end) {
2595 if (this.source.start.line > line) {
2596 return false;
2597 }
2598
2599 if (this.source.end.line < line) {
2600 return false;
2601 }
2602
2603 if (this.source.start.line === line && this.source.start.column > column) {
2604 return false;
2605 }
2606
2607 if (this.source.end.line === line && this.source.end.column < column) {
2608 return false;
2609 }
2610
2611 return true;
2612 }
2613
2614 return undefined;
2615 };
2616
2617 _proto.stringifyProperty = function stringifyProperty(name) {
2618 return this.raws && this.raws[name] || this[name];
2619 };
2620
2621 _proto.valueToString = function valueToString() {
2622 return String(this.stringifyProperty("value"));
2623 };
2624
2625 _proto.toString = function toString() {
2626 return [this.rawSpaceBefore, this.valueToString(), this.rawSpaceAfter].join('');
2627 };
2628
2629 _createClass(Node, [{
2630 key: "rawSpaceBefore",
2631 get: function get() {
2632 var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before;
2633
2634 if (rawSpace === undefined) {
2635 rawSpace = this.spaces && this.spaces.before;
2636 }
2637
2638 return rawSpace || "";
2639 },
2640 set: function set(raw) {
2641 (0, _util.ensureObject)(this, "raws", "spaces");
2642 this.raws.spaces.before = raw;
2643 }
2644 }, {
2645 key: "rawSpaceAfter",
2646 get: function get() {
2647 var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after;
2648
2649 if (rawSpace === undefined) {
2650 rawSpace = this.spaces.after;
2651 }
2652
2653 return rawSpace || "";
2654 },
2655 set: function set(raw) {
2656 (0, _util.ensureObject)(this, "raws", "spaces");
2657 this.raws.spaces.after = raw;
2658 }
2659 }]);
2660
2661 return Node;
2662 }();
2663
2664 exports["default"] = Node;
2665 module.exports = exports.default;
2666} (node$1, node$1.exports));
2667
2668var nodeExports = node$1.exports;
2669
2670var types = {};
2671
2672types.__esModule = true;
2673types.UNIVERSAL = types.ATTRIBUTE = types.CLASS = types.COMBINATOR = types.COMMENT = types.ID = types.NESTING = types.PSEUDO = types.ROOT = types.SELECTOR = types.STRING = types.TAG = void 0;
2674var TAG = 'tag';
2675types.TAG = TAG;
2676var STRING = 'string';
2677types.STRING = STRING;
2678var SELECTOR = 'selector';
2679types.SELECTOR = SELECTOR;
2680var ROOT = 'root';
2681types.ROOT = ROOT;
2682var PSEUDO = 'pseudo';
2683types.PSEUDO = PSEUDO;
2684var NESTING = 'nesting';
2685types.NESTING = NESTING;
2686var ID = 'id';
2687types.ID = ID;
2688var COMMENT = 'comment';
2689types.COMMENT = COMMENT;
2690var COMBINATOR = 'combinator';
2691types.COMBINATOR = COMBINATOR;
2692var CLASS = 'class';
2693types.CLASS = CLASS;
2694var ATTRIBUTE = 'attribute';
2695types.ATTRIBUTE = ATTRIBUTE;
2696var UNIVERSAL = 'universal';
2697types.UNIVERSAL = UNIVERSAL;
2698
2699(function (module, exports) {
2700
2701 exports.__esModule = true;
2702 exports["default"] = void 0;
2703
2704 var _node = _interopRequireDefault(nodeExports);
2705
2706 var types$1 = _interopRequireWildcard(types);
2707
2708 function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
2709
2710 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
2711
2712 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
2713
2714 function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
2715
2716 function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
2717
2718 function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
2719
2720 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2721
2722 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; }
2723
2724 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
2725
2726 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
2727
2728 var Container = /*#__PURE__*/function (_Node) {
2729 _inheritsLoose(Container, _Node);
2730
2731 function Container(opts) {
2732 var _this;
2733
2734 _this = _Node.call(this, opts) || this;
2735
2736 if (!_this.nodes) {
2737 _this.nodes = [];
2738 }
2739
2740 return _this;
2741 }
2742
2743 var _proto = Container.prototype;
2744
2745 _proto.append = function append(selector) {
2746 selector.parent = this;
2747 this.nodes.push(selector);
2748 return this;
2749 };
2750
2751 _proto.prepend = function prepend(selector) {
2752 selector.parent = this;
2753 this.nodes.unshift(selector);
2754 return this;
2755 };
2756
2757 _proto.at = function at(index) {
2758 return this.nodes[index];
2759 };
2760
2761 _proto.index = function index(child) {
2762 if (typeof child === 'number') {
2763 return child;
2764 }
2765
2766 return this.nodes.indexOf(child);
2767 };
2768
2769 _proto.removeChild = function removeChild(child) {
2770 child = this.index(child);
2771 this.at(child).parent = undefined;
2772 this.nodes.splice(child, 1);
2773 var index;
2774
2775 for (var id in this.indexes) {
2776 index = this.indexes[id];
2777
2778 if (index >= child) {
2779 this.indexes[id] = index - 1;
2780 }
2781 }
2782
2783 return this;
2784 };
2785
2786 _proto.removeAll = function removeAll() {
2787 for (var _iterator = _createForOfIteratorHelperLoose(this.nodes), _step; !(_step = _iterator()).done;) {
2788 var node = _step.value;
2789 node.parent = undefined;
2790 }
2791
2792 this.nodes = [];
2793 return this;
2794 };
2795
2796 _proto.empty = function empty() {
2797 return this.removeAll();
2798 };
2799
2800 _proto.insertAfter = function insertAfter(oldNode, newNode) {
2801 newNode.parent = this;
2802 var oldIndex = this.index(oldNode);
2803 this.nodes.splice(oldIndex + 1, 0, newNode);
2804 newNode.parent = this;
2805 var index;
2806
2807 for (var id in this.indexes) {
2808 index = this.indexes[id];
2809
2810 if (oldIndex <= index) {
2811 this.indexes[id] = index + 1;
2812 }
2813 }
2814
2815 return this;
2816 };
2817
2818 _proto.insertBefore = function insertBefore(oldNode, newNode) {
2819 newNode.parent = this;
2820 var oldIndex = this.index(oldNode);
2821 this.nodes.splice(oldIndex, 0, newNode);
2822 newNode.parent = this;
2823 var index;
2824
2825 for (var id in this.indexes) {
2826 index = this.indexes[id];
2827
2828 if (index <= oldIndex) {
2829 this.indexes[id] = index + 1;
2830 }
2831 }
2832
2833 return this;
2834 };
2835
2836 _proto._findChildAtPosition = function _findChildAtPosition(line, col) {
2837 var found = undefined;
2838 this.each(function (node) {
2839 if (node.atPosition) {
2840 var foundChild = node.atPosition(line, col);
2841
2842 if (foundChild) {
2843 found = foundChild;
2844 return false;
2845 }
2846 } else if (node.isAtPosition(line, col)) {
2847 found = node;
2848 return false;
2849 }
2850 });
2851 return found;
2852 }
2853 /**
2854 * Return the most specific node at the line and column number given.
2855 * The source location is based on the original parsed location, locations aren't
2856 * updated as selector nodes are mutated.
2857 *
2858 * Note that this location is relative to the location of the first character
2859 * of the selector, and not the location of the selector in the overall document
2860 * when used in conjunction with postcss.
2861 *
2862 * If not found, returns undefined.
2863 * @param {number} line The line number of the node to find. (1-based index)
2864 * @param {number} col The column number of the node to find. (1-based index)
2865 */
2866 ;
2867
2868 _proto.atPosition = function atPosition(line, col) {
2869 if (this.isAtPosition(line, col)) {
2870 return this._findChildAtPosition(line, col) || this;
2871 } else {
2872 return undefined;
2873 }
2874 };
2875
2876 _proto._inferEndPosition = function _inferEndPosition() {
2877 if (this.last && this.last.source && this.last.source.end) {
2878 this.source = this.source || {};
2879 this.source.end = this.source.end || {};
2880 Object.assign(this.source.end, this.last.source.end);
2881 }
2882 };
2883
2884 _proto.each = function each(callback) {
2885 if (!this.lastEach) {
2886 this.lastEach = 0;
2887 }
2888
2889 if (!this.indexes) {
2890 this.indexes = {};
2891 }
2892
2893 this.lastEach++;
2894 var id = this.lastEach;
2895 this.indexes[id] = 0;
2896
2897 if (!this.length) {
2898 return undefined;
2899 }
2900
2901 var index, result;
2902
2903 while (this.indexes[id] < this.length) {
2904 index = this.indexes[id];
2905 result = callback(this.at(index), index);
2906
2907 if (result === false) {
2908 break;
2909 }
2910
2911 this.indexes[id] += 1;
2912 }
2913
2914 delete this.indexes[id];
2915
2916 if (result === false) {
2917 return false;
2918 }
2919 };
2920
2921 _proto.walk = function walk(callback) {
2922 return this.each(function (node, i) {
2923 var result = callback(node, i);
2924
2925 if (result !== false && node.length) {
2926 result = node.walk(callback);
2927 }
2928
2929 if (result === false) {
2930 return false;
2931 }
2932 });
2933 };
2934
2935 _proto.walkAttributes = function walkAttributes(callback) {
2936 var _this2 = this;
2937
2938 return this.walk(function (selector) {
2939 if (selector.type === types$1.ATTRIBUTE) {
2940 return callback.call(_this2, selector);
2941 }
2942 });
2943 };
2944
2945 _proto.walkClasses = function walkClasses(callback) {
2946 var _this3 = this;
2947
2948 return this.walk(function (selector) {
2949 if (selector.type === types$1.CLASS) {
2950 return callback.call(_this3, selector);
2951 }
2952 });
2953 };
2954
2955 _proto.walkCombinators = function walkCombinators(callback) {
2956 var _this4 = this;
2957
2958 return this.walk(function (selector) {
2959 if (selector.type === types$1.COMBINATOR) {
2960 return callback.call(_this4, selector);
2961 }
2962 });
2963 };
2964
2965 _proto.walkComments = function walkComments(callback) {
2966 var _this5 = this;
2967
2968 return this.walk(function (selector) {
2969 if (selector.type === types$1.COMMENT) {
2970 return callback.call(_this5, selector);
2971 }
2972 });
2973 };
2974
2975 _proto.walkIds = function walkIds(callback) {
2976 var _this6 = this;
2977
2978 return this.walk(function (selector) {
2979 if (selector.type === types$1.ID) {
2980 return callback.call(_this6, selector);
2981 }
2982 });
2983 };
2984
2985 _proto.walkNesting = function walkNesting(callback) {
2986 var _this7 = this;
2987
2988 return this.walk(function (selector) {
2989 if (selector.type === types$1.NESTING) {
2990 return callback.call(_this7, selector);
2991 }
2992 });
2993 };
2994
2995 _proto.walkPseudos = function walkPseudos(callback) {
2996 var _this8 = this;
2997
2998 return this.walk(function (selector) {
2999 if (selector.type === types$1.PSEUDO) {
3000 return callback.call(_this8, selector);
3001 }
3002 });
3003 };
3004
3005 _proto.walkTags = function walkTags(callback) {
3006 var _this9 = this;
3007
3008 return this.walk(function (selector) {
3009 if (selector.type === types$1.TAG) {
3010 return callback.call(_this9, selector);
3011 }
3012 });
3013 };
3014
3015 _proto.walkUniversals = function walkUniversals(callback) {
3016 var _this10 = this;
3017
3018 return this.walk(function (selector) {
3019 if (selector.type === types$1.UNIVERSAL) {
3020 return callback.call(_this10, selector);
3021 }
3022 });
3023 };
3024
3025 _proto.split = function split(callback) {
3026 var _this11 = this;
3027
3028 var current = [];
3029 return this.reduce(function (memo, node, index) {
3030 var split = callback.call(_this11, node);
3031 current.push(node);
3032
3033 if (split) {
3034 memo.push(current);
3035 current = [];
3036 } else if (index === _this11.length - 1) {
3037 memo.push(current);
3038 }
3039
3040 return memo;
3041 }, []);
3042 };
3043
3044 _proto.map = function map(callback) {
3045 return this.nodes.map(callback);
3046 };
3047
3048 _proto.reduce = function reduce(callback, memo) {
3049 return this.nodes.reduce(callback, memo);
3050 };
3051
3052 _proto.every = function every(callback) {
3053 return this.nodes.every(callback);
3054 };
3055
3056 _proto.some = function some(callback) {
3057 return this.nodes.some(callback);
3058 };
3059
3060 _proto.filter = function filter(callback) {
3061 return this.nodes.filter(callback);
3062 };
3063
3064 _proto.sort = function sort(callback) {
3065 return this.nodes.sort(callback);
3066 };
3067
3068 _proto.toString = function toString() {
3069 return this.map(String).join('');
3070 };
3071
3072 _createClass(Container, [{
3073 key: "first",
3074 get: function get() {
3075 return this.at(0);
3076 }
3077 }, {
3078 key: "last",
3079 get: function get() {
3080 return this.at(this.length - 1);
3081 }
3082 }, {
3083 key: "length",
3084 get: function get() {
3085 return this.nodes.length;
3086 }
3087 }]);
3088
3089 return Container;
3090 }(_node["default"]);
3091
3092 exports["default"] = Container;
3093 module.exports = exports.default;
3094} (container, container.exports));
3095
3096var containerExports = container.exports;
3097
3098(function (module, exports) {
3099
3100 exports.__esModule = true;
3101 exports["default"] = void 0;
3102
3103 var _container = _interopRequireDefault(containerExports);
3104
3105 var _types = types;
3106
3107 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
3108
3109 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
3110
3111 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; }
3112
3113 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
3114
3115 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
3116
3117 var Root = /*#__PURE__*/function (_Container) {
3118 _inheritsLoose(Root, _Container);
3119
3120 function Root(opts) {
3121 var _this;
3122
3123 _this = _Container.call(this, opts) || this;
3124 _this.type = _types.ROOT;
3125 return _this;
3126 }
3127
3128 var _proto = Root.prototype;
3129
3130 _proto.toString = function toString() {
3131 var str = this.reduce(function (memo, selector) {
3132 memo.push(String(selector));
3133 return memo;
3134 }, []).join(',');
3135 return this.trailingComma ? str + ',' : str;
3136 };
3137
3138 _proto.error = function error(message, options) {
3139 if (this._error) {
3140 return this._error(message, options);
3141 } else {
3142 return new Error(message);
3143 }
3144 };
3145
3146 _createClass(Root, [{
3147 key: "errorGenerator",
3148 set: function set(handler) {
3149 this._error = handler;
3150 }
3151 }]);
3152
3153 return Root;
3154 }(_container["default"]);
3155
3156 exports["default"] = Root;
3157 module.exports = exports.default;
3158} (root$1, root$1.exports));
3159
3160var rootExports = root$1.exports;
3161
3162var selector$1 = {exports: {}};
3163
3164(function (module, exports) {
3165
3166 exports.__esModule = true;
3167 exports["default"] = void 0;
3168
3169 var _container = _interopRequireDefault(containerExports);
3170
3171 var _types = types;
3172
3173 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
3174
3175 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
3176
3177 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
3178
3179 var Selector = /*#__PURE__*/function (_Container) {
3180 _inheritsLoose(Selector, _Container);
3181
3182 function Selector(opts) {
3183 var _this;
3184
3185 _this = _Container.call(this, opts) || this;
3186 _this.type = _types.SELECTOR;
3187 return _this;
3188 }
3189
3190 return Selector;
3191 }(_container["default"]);
3192
3193 exports["default"] = Selector;
3194 module.exports = exports.default;
3195} (selector$1, selector$1.exports));
3196
3197var selectorExports = selector$1.exports;
3198
3199var className$1 = {exports: {}};
3200
3201/*! https://mths.be/cssesc v3.0.0 by @mathias */
3202
3203var object = {};
3204var hasOwnProperty$1 = object.hasOwnProperty;
3205var merge = function merge(options, defaults) {
3206 if (!options) {
3207 return defaults;
3208 }
3209 var result = {};
3210 for (var key in defaults) {
3211 // `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
3212 // only recognized option names are used.
3213 result[key] = hasOwnProperty$1.call(options, key) ? options[key] : defaults[key];
3214 }
3215 return result;
3216};
3217
3218var regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
3219var regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
3220var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
3221
3222// https://mathiasbynens.be/notes/css-escapes#css
3223var cssesc = function cssesc(string, options) {
3224 options = merge(options, cssesc.options);
3225 if (options.quotes != 'single' && options.quotes != 'double') {
3226 options.quotes = 'single';
3227 }
3228 var quote = options.quotes == 'double' ? '"' : '\'';
3229 var isIdentifier = options.isIdentifier;
3230
3231 var firstChar = string.charAt(0);
3232 var output = '';
3233 var counter = 0;
3234 var length = string.length;
3235 while (counter < length) {
3236 var character = string.charAt(counter++);
3237 var codePoint = character.charCodeAt();
3238 var value = void 0;
3239 // If it’s not a printable ASCII character…
3240 if (codePoint < 0x20 || codePoint > 0x7E) {
3241 if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
3242 // It’s a high surrogate, and there is a next character.
3243 var extra = string.charCodeAt(counter++);
3244 if ((extra & 0xFC00) == 0xDC00) {
3245 // next character is low surrogate
3246 codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
3247 } else {
3248 // It’s an unmatched surrogate; only append this code unit, in case
3249 // the next code unit is the high surrogate of a surrogate pair.
3250 counter--;
3251 }
3252 }
3253 value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
3254 } else {
3255 if (options.escapeEverything) {
3256 if (regexAnySingleEscape.test(character)) {
3257 value = '\\' + character;
3258 } else {
3259 value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
3260 }
3261 } else if (/[\t\n\f\r\x0B]/.test(character)) {
3262 value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
3263 } else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
3264 value = '\\' + character;
3265 } else {
3266 value = character;
3267 }
3268 }
3269 output += value;
3270 }
3271
3272 if (isIdentifier) {
3273 if (/^-[-\d]/.test(output)) {
3274 output = '\\-' + output.slice(1);
3275 } else if (/\d/.test(firstChar)) {
3276 output = '\\3' + firstChar + ' ' + output.slice(1);
3277 }
3278 }
3279
3280 // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
3281 // since they’re redundant. Note that this is only possible if the escape
3282 // sequence isn’t preceded by an odd number of backslashes.
3283 output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
3284 if ($1 && $1.length % 2) {
3285 // It’s not safe to remove the space, so don’t.
3286 return $0;
3287 }
3288 // Strip the space.
3289 return ($1 || '') + $2;
3290 });
3291
3292 if (!isIdentifier && options.wrap) {
3293 return quote + output + quote;
3294 }
3295 return output;
3296};
3297
3298// Expose default options (so they can be overridden globally).
3299cssesc.options = {
3300 'escapeEverything': false,
3301 'isIdentifier': false,
3302 'quotes': 'single',
3303 'wrap': false
3304};
3305
3306cssesc.version = '3.0.0';
3307
3308var cssesc_1 = cssesc;
3309
3310(function (module, exports) {
3311
3312 exports.__esModule = true;
3313 exports["default"] = void 0;
3314
3315 var _cssesc = _interopRequireDefault(cssesc_1);
3316
3317 var _util = util;
3318
3319 var _node = _interopRequireDefault(nodeExports);
3320
3321 var _types = types;
3322
3323 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
3324
3325 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
3326
3327 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; }
3328
3329 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
3330
3331 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
3332
3333 var ClassName = /*#__PURE__*/function (_Node) {
3334 _inheritsLoose(ClassName, _Node);
3335
3336 function ClassName(opts) {
3337 var _this;
3338
3339 _this = _Node.call(this, opts) || this;
3340 _this.type = _types.CLASS;
3341 _this._constructed = true;
3342 return _this;
3343 }
3344
3345 var _proto = ClassName.prototype;
3346
3347 _proto.valueToString = function valueToString() {
3348 return '.' + _Node.prototype.valueToString.call(this);
3349 };
3350
3351 _createClass(ClassName, [{
3352 key: "value",
3353 get: function get() {
3354 return this._value;
3355 },
3356 set: function set(v) {
3357 if (this._constructed) {
3358 var escaped = (0, _cssesc["default"])(v, {
3359 isIdentifier: true
3360 });
3361
3362 if (escaped !== v) {
3363 (0, _util.ensureObject)(this, "raws");
3364 this.raws.value = escaped;
3365 } else if (this.raws) {
3366 delete this.raws.value;
3367 }
3368 }
3369
3370 this._value = v;
3371 }
3372 }]);
3373
3374 return ClassName;
3375 }(_node["default"]);
3376
3377 exports["default"] = ClassName;
3378 module.exports = exports.default;
3379} (className$1, className$1.exports));
3380
3381var classNameExports = className$1.exports;
3382
3383var comment$2 = {exports: {}};
3384
3385(function (module, exports) {
3386
3387 exports.__esModule = true;
3388 exports["default"] = void 0;
3389
3390 var _node = _interopRequireDefault(nodeExports);
3391
3392 var _types = types;
3393
3394 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
3395
3396 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
3397
3398 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
3399
3400 var Comment = /*#__PURE__*/function (_Node) {
3401 _inheritsLoose(Comment, _Node);
3402
3403 function Comment(opts) {
3404 var _this;
3405
3406 _this = _Node.call(this, opts) || this;
3407 _this.type = _types.COMMENT;
3408 return _this;
3409 }
3410
3411 return Comment;
3412 }(_node["default"]);
3413
3414 exports["default"] = Comment;
3415 module.exports = exports.default;
3416} (comment$2, comment$2.exports));
3417
3418var commentExports = comment$2.exports;
3419
3420var id$1 = {exports: {}};
3421
3422(function (module, exports) {
3423
3424 exports.__esModule = true;
3425 exports["default"] = void 0;
3426
3427 var _node = _interopRequireDefault(nodeExports);
3428
3429 var _types = types;
3430
3431 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
3432
3433 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
3434
3435 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
3436
3437 var ID = /*#__PURE__*/function (_Node) {
3438 _inheritsLoose(ID, _Node);
3439
3440 function ID(opts) {
3441 var _this;
3442
3443 _this = _Node.call(this, opts) || this;
3444 _this.type = _types.ID;
3445 return _this;
3446 }
3447
3448 var _proto = ID.prototype;
3449
3450 _proto.valueToString = function valueToString() {
3451 return '#' + _Node.prototype.valueToString.call(this);
3452 };
3453
3454 return ID;
3455 }(_node["default"]);
3456
3457 exports["default"] = ID;
3458 module.exports = exports.default;
3459} (id$1, id$1.exports));
3460
3461var idExports = id$1.exports;
3462
3463var tag$1 = {exports: {}};
3464
3465var namespace = {exports: {}};
3466
3467(function (module, exports) {
3468
3469 exports.__esModule = true;
3470 exports["default"] = void 0;
3471
3472 var _cssesc = _interopRequireDefault(cssesc_1);
3473
3474 var _util = util;
3475
3476 var _node = _interopRequireDefault(nodeExports);
3477
3478 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
3479
3480 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
3481
3482 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; }
3483
3484 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
3485
3486 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
3487
3488 var Namespace = /*#__PURE__*/function (_Node) {
3489 _inheritsLoose(Namespace, _Node);
3490
3491 function Namespace() {
3492 return _Node.apply(this, arguments) || this;
3493 }
3494
3495 var _proto = Namespace.prototype;
3496
3497 _proto.qualifiedName = function qualifiedName(value) {
3498 if (this.namespace) {
3499 return this.namespaceString + "|" + value;
3500 } else {
3501 return value;
3502 }
3503 };
3504
3505 _proto.valueToString = function valueToString() {
3506 return this.qualifiedName(_Node.prototype.valueToString.call(this));
3507 };
3508
3509 _createClass(Namespace, [{
3510 key: "namespace",
3511 get: function get() {
3512 return this._namespace;
3513 },
3514 set: function set(namespace) {
3515 if (namespace === true || namespace === "*" || namespace === "&") {
3516 this._namespace = namespace;
3517
3518 if (this.raws) {
3519 delete this.raws.namespace;
3520 }
3521
3522 return;
3523 }
3524
3525 var escaped = (0, _cssesc["default"])(namespace, {
3526 isIdentifier: true
3527 });
3528 this._namespace = namespace;
3529
3530 if (escaped !== namespace) {
3531 (0, _util.ensureObject)(this, "raws");
3532 this.raws.namespace = escaped;
3533 } else if (this.raws) {
3534 delete this.raws.namespace;
3535 }
3536 }
3537 }, {
3538 key: "ns",
3539 get: function get() {
3540 return this._namespace;
3541 },
3542 set: function set(namespace) {
3543 this.namespace = namespace;
3544 }
3545 }, {
3546 key: "namespaceString",
3547 get: function get() {
3548 if (this.namespace) {
3549 var ns = this.stringifyProperty("namespace");
3550
3551 if (ns === true) {
3552 return '';
3553 } else {
3554 return ns;
3555 }
3556 } else {
3557 return '';
3558 }
3559 }
3560 }]);
3561
3562 return Namespace;
3563 }(_node["default"]);
3564
3565 exports["default"] = Namespace;
3566 module.exports = exports.default;
3567} (namespace, namespace.exports));
3568
3569var namespaceExports = namespace.exports;
3570
3571(function (module, exports) {
3572
3573 exports.__esModule = true;
3574 exports["default"] = void 0;
3575
3576 var _namespace = _interopRequireDefault(namespaceExports);
3577
3578 var _types = types;
3579
3580 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
3581
3582 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
3583
3584 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
3585
3586 var Tag = /*#__PURE__*/function (_Namespace) {
3587 _inheritsLoose(Tag, _Namespace);
3588
3589 function Tag(opts) {
3590 var _this;
3591
3592 _this = _Namespace.call(this, opts) || this;
3593 _this.type = _types.TAG;
3594 return _this;
3595 }
3596
3597 return Tag;
3598 }(_namespace["default"]);
3599
3600 exports["default"] = Tag;
3601 module.exports = exports.default;
3602} (tag$1, tag$1.exports));
3603
3604var tagExports = tag$1.exports;
3605
3606var string$1 = {exports: {}};
3607
3608(function (module, exports) {
3609
3610 exports.__esModule = true;
3611 exports["default"] = void 0;
3612
3613 var _node = _interopRequireDefault(nodeExports);
3614
3615 var _types = types;
3616
3617 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
3618
3619 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
3620
3621 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
3622
3623 var String = /*#__PURE__*/function (_Node) {
3624 _inheritsLoose(String, _Node);
3625
3626 function String(opts) {
3627 var _this;
3628
3629 _this = _Node.call(this, opts) || this;
3630 _this.type = _types.STRING;
3631 return _this;
3632 }
3633
3634 return String;
3635 }(_node["default"]);
3636
3637 exports["default"] = String;
3638 module.exports = exports.default;
3639} (string$1, string$1.exports));
3640
3641var stringExports = string$1.exports;
3642
3643var pseudo$1 = {exports: {}};
3644
3645(function (module, exports) {
3646
3647 exports.__esModule = true;
3648 exports["default"] = void 0;
3649
3650 var _container = _interopRequireDefault(containerExports);
3651
3652 var _types = types;
3653
3654 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
3655
3656 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
3657
3658 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
3659
3660 var Pseudo = /*#__PURE__*/function (_Container) {
3661 _inheritsLoose(Pseudo, _Container);
3662
3663 function Pseudo(opts) {
3664 var _this;
3665
3666 _this = _Container.call(this, opts) || this;
3667 _this.type = _types.PSEUDO;
3668 return _this;
3669 }
3670
3671 var _proto = Pseudo.prototype;
3672
3673 _proto.toString = function toString() {
3674 var params = this.length ? '(' + this.map(String).join(',') + ')' : '';
3675 return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join('');
3676 };
3677
3678 return Pseudo;
3679 }(_container["default"]);
3680
3681 exports["default"] = Pseudo;
3682 module.exports = exports.default;
3683} (pseudo$1, pseudo$1.exports));
3684
3685var pseudoExports = pseudo$1.exports;
3686
3687var attribute$1 = {};
3688
3689/**
3690 * For Node.js, simply re-export the core `util.deprecate` function.
3691 */
3692
3693var node = require$$0$2.deprecate;
3694
3695(function (exports) {
3696
3697 exports.__esModule = true;
3698 exports.unescapeValue = unescapeValue;
3699 exports["default"] = void 0;
3700
3701 var _cssesc = _interopRequireDefault(cssesc_1);
3702
3703 var _unesc = _interopRequireDefault(unescExports);
3704
3705 var _namespace = _interopRequireDefault(namespaceExports);
3706
3707 var _types = types;
3708
3709 var _CSSESC_QUOTE_OPTIONS;
3710
3711 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
3712
3713 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
3714
3715 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; }
3716
3717 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
3718
3719 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
3720
3721 var deprecate = node;
3722
3723 var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;
3724 var warnOfDeprecatedValueAssignment = deprecate(function () {}, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. " + "Call attribute.setValue() instead.");
3725 var warnOfDeprecatedQuotedAssignment = deprecate(function () {}, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead.");
3726 var warnOfDeprecatedConstructor = deprecate(function () {}, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now.");
3727
3728 function unescapeValue(value) {
3729 var deprecatedUsage = false;
3730 var quoteMark = null;
3731 var unescaped = value;
3732 var m = unescaped.match(WRAPPED_IN_QUOTES);
3733
3734 if (m) {
3735 quoteMark = m[1];
3736 unescaped = m[2];
3737 }
3738
3739 unescaped = (0, _unesc["default"])(unescaped);
3740
3741 if (unescaped !== value) {
3742 deprecatedUsage = true;
3743 }
3744
3745 return {
3746 deprecatedUsage: deprecatedUsage,
3747 unescaped: unescaped,
3748 quoteMark: quoteMark
3749 };
3750 }
3751
3752 function handleDeprecatedContructorOpts(opts) {
3753 if (opts.quoteMark !== undefined) {
3754 return opts;
3755 }
3756
3757 if (opts.value === undefined) {
3758 return opts;
3759 }
3760
3761 warnOfDeprecatedConstructor();
3762
3763 var _unescapeValue = unescapeValue(opts.value),
3764 quoteMark = _unescapeValue.quoteMark,
3765 unescaped = _unescapeValue.unescaped;
3766
3767 if (!opts.raws) {
3768 opts.raws = {};
3769 }
3770
3771 if (opts.raws.value === undefined) {
3772 opts.raws.value = opts.value;
3773 }
3774
3775 opts.value = unescaped;
3776 opts.quoteMark = quoteMark;
3777 return opts;
3778 }
3779
3780 var Attribute = /*#__PURE__*/function (_Namespace) {
3781 _inheritsLoose(Attribute, _Namespace);
3782
3783 function Attribute(opts) {
3784 var _this;
3785
3786 if (opts === void 0) {
3787 opts = {};
3788 }
3789
3790 _this = _Namespace.call(this, handleDeprecatedContructorOpts(opts)) || this;
3791 _this.type = _types.ATTRIBUTE;
3792 _this.raws = _this.raws || {};
3793 Object.defineProperty(_this.raws, 'unquoted', {
3794 get: deprecate(function () {
3795 return _this.value;
3796 }, "attr.raws.unquoted is deprecated. Call attr.value instead."),
3797 set: deprecate(function () {
3798 return _this.value;
3799 }, "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now.")
3800 });
3801 _this._constructed = true;
3802 return _this;
3803 }
3804 /**
3805 * Returns the Attribute's value quoted such that it would be legal to use
3806 * in the value of a css file. The original value's quotation setting
3807 * used for stringification is left unchanged. See `setValue(value, options)`
3808 * if you want to control the quote settings of a new value for the attribute.
3809 *
3810 * You can also change the quotation used for the current value by setting quoteMark.
3811 *
3812 * Options:
3813 * * quoteMark {'"' | "'" | null} - Use this value to quote the value. If this
3814 * option is not set, the original value for quoteMark will be used. If
3815 * indeterminate, a double quote is used. The legal values are:
3816 * * `null` - the value will be unquoted and characters will be escaped as necessary.
3817 * * `'` - the value will be quoted with a single quote and single quotes are escaped.
3818 * * `"` - the value will be quoted with a double quote and double quotes are escaped.
3819 * * preferCurrentQuoteMark {boolean} - if true, prefer the source quote mark
3820 * over the quoteMark option value.
3821 * * smart {boolean} - if true, will select a quote mark based on the value
3822 * and the other options specified here. See the `smartQuoteMark()`
3823 * method.
3824 **/
3825
3826
3827 var _proto = Attribute.prototype;
3828
3829 _proto.getQuotedValue = function getQuotedValue(options) {
3830 if (options === void 0) {
3831 options = {};
3832 }
3833
3834 var quoteMark = this._determineQuoteMark(options);
3835
3836 var cssescopts = CSSESC_QUOTE_OPTIONS[quoteMark];
3837 var escaped = (0, _cssesc["default"])(this._value, cssescopts);
3838 return escaped;
3839 };
3840
3841 _proto._determineQuoteMark = function _determineQuoteMark(options) {
3842 return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options);
3843 }
3844 /**
3845 * Set the unescaped value with the specified quotation options. The value
3846 * provided must not include any wrapping quote marks -- those quotes will
3847 * be interpreted as part of the value and escaped accordingly.
3848 */
3849 ;
3850
3851 _proto.setValue = function setValue(value, options) {
3852 if (options === void 0) {
3853 options = {};
3854 }
3855
3856 this._value = value;
3857 this._quoteMark = this._determineQuoteMark(options);
3858
3859 this._syncRawValue();
3860 }
3861 /**
3862 * Intelligently select a quoteMark value based on the value's contents. If
3863 * the value is a legal CSS ident, it will not be quoted. Otherwise a quote
3864 * mark will be picked that minimizes the number of escapes.
3865 *
3866 * If there's no clear winner, the quote mark from these options is used,
3867 * then the source quote mark (this is inverted if `preferCurrentQuoteMark` is
3868 * true). If the quoteMark is unspecified, a double quote is used.
3869 *
3870 * @param options This takes the quoteMark and preferCurrentQuoteMark options
3871 * from the quoteValue method.
3872 */
3873 ;
3874
3875 _proto.smartQuoteMark = function smartQuoteMark(options) {
3876 var v = this.value;
3877 var numSingleQuotes = v.replace(/[^']/g, '').length;
3878 var numDoubleQuotes = v.replace(/[^"]/g, '').length;
3879
3880 if (numSingleQuotes + numDoubleQuotes === 0) {
3881 var escaped = (0, _cssesc["default"])(v, {
3882 isIdentifier: true
3883 });
3884
3885 if (escaped === v) {
3886 return Attribute.NO_QUOTE;
3887 } else {
3888 var pref = this.preferredQuoteMark(options);
3889
3890 if (pref === Attribute.NO_QUOTE) {
3891 // pick a quote mark that isn't none and see if it's smaller
3892 var quote = this.quoteMark || options.quoteMark || Attribute.DOUBLE_QUOTE;
3893 var opts = CSSESC_QUOTE_OPTIONS[quote];
3894 var quoteValue = (0, _cssesc["default"])(v, opts);
3895
3896 if (quoteValue.length < escaped.length) {
3897 return quote;
3898 }
3899 }
3900
3901 return pref;
3902 }
3903 } else if (numDoubleQuotes === numSingleQuotes) {
3904 return this.preferredQuoteMark(options);
3905 } else if (numDoubleQuotes < numSingleQuotes) {
3906 return Attribute.DOUBLE_QUOTE;
3907 } else {
3908 return Attribute.SINGLE_QUOTE;
3909 }
3910 }
3911 /**
3912 * Selects the preferred quote mark based on the options and the current quote mark value.
3913 * If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)`
3914 * instead.
3915 */
3916 ;
3917
3918 _proto.preferredQuoteMark = function preferredQuoteMark(options) {
3919 var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark;
3920
3921 if (quoteMark === undefined) {
3922 quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark;
3923 }
3924
3925 if (quoteMark === undefined) {
3926 quoteMark = Attribute.DOUBLE_QUOTE;
3927 }
3928
3929 return quoteMark;
3930 };
3931
3932 _proto._syncRawValue = function _syncRawValue() {
3933 var rawValue = (0, _cssesc["default"])(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]);
3934
3935 if (rawValue === this._value) {
3936 if (this.raws) {
3937 delete this.raws.value;
3938 }
3939 } else {
3940 this.raws.value = rawValue;
3941 }
3942 };
3943
3944 _proto._handleEscapes = function _handleEscapes(prop, value) {
3945 if (this._constructed) {
3946 var escaped = (0, _cssesc["default"])(value, {
3947 isIdentifier: true
3948 });
3949
3950 if (escaped !== value) {
3951 this.raws[prop] = escaped;
3952 } else {
3953 delete this.raws[prop];
3954 }
3955 }
3956 };
3957
3958 _proto._spacesFor = function _spacesFor(name) {
3959 var attrSpaces = {
3960 before: '',
3961 after: ''
3962 };
3963 var spaces = this.spaces[name] || {};
3964 var rawSpaces = this.raws.spaces && this.raws.spaces[name] || {};
3965 return Object.assign(attrSpaces, spaces, rawSpaces);
3966 };
3967
3968 _proto._stringFor = function _stringFor(name, spaceName, concat) {
3969 if (spaceName === void 0) {
3970 spaceName = name;
3971 }
3972
3973 if (concat === void 0) {
3974 concat = defaultAttrConcat;
3975 }
3976
3977 var attrSpaces = this._spacesFor(spaceName);
3978
3979 return concat(this.stringifyProperty(name), attrSpaces);
3980 }
3981 /**
3982 * returns the offset of the attribute part specified relative to the
3983 * start of the node of the output string.
3984 *
3985 * * "ns" - alias for "namespace"
3986 * * "namespace" - the namespace if it exists.
3987 * * "attribute" - the attribute name
3988 * * "attributeNS" - the start of the attribute or its namespace
3989 * * "operator" - the match operator of the attribute
3990 * * "value" - The value (string or identifier)
3991 * * "insensitive" - the case insensitivity flag;
3992 * @param part One of the possible values inside an attribute.
3993 * @returns -1 if the name is invalid or the value doesn't exist in this attribute.
3994 */
3995 ;
3996
3997 _proto.offsetOf = function offsetOf(name) {
3998 var count = 1;
3999
4000 var attributeSpaces = this._spacesFor("attribute");
4001
4002 count += attributeSpaces.before.length;
4003
4004 if (name === "namespace" || name === "ns") {
4005 return this.namespace ? count : -1;
4006 }
4007
4008 if (name === "attributeNS") {
4009 return count;
4010 }
4011
4012 count += this.namespaceString.length;
4013
4014 if (this.namespace) {
4015 count += 1;
4016 }
4017
4018 if (name === "attribute") {
4019 return count;
4020 }
4021
4022 count += this.stringifyProperty("attribute").length;
4023 count += attributeSpaces.after.length;
4024
4025 var operatorSpaces = this._spacesFor("operator");
4026
4027 count += operatorSpaces.before.length;
4028 var operator = this.stringifyProperty("operator");
4029
4030 if (name === "operator") {
4031 return operator ? count : -1;
4032 }
4033
4034 count += operator.length;
4035 count += operatorSpaces.after.length;
4036
4037 var valueSpaces = this._spacesFor("value");
4038
4039 count += valueSpaces.before.length;
4040 var value = this.stringifyProperty("value");
4041
4042 if (name === "value") {
4043 return value ? count : -1;
4044 }
4045
4046 count += value.length;
4047 count += valueSpaces.after.length;
4048
4049 var insensitiveSpaces = this._spacesFor("insensitive");
4050
4051 count += insensitiveSpaces.before.length;
4052
4053 if (name === "insensitive") {
4054 return this.insensitive ? count : -1;
4055 }
4056
4057 return -1;
4058 };
4059
4060 _proto.toString = function toString() {
4061 var _this2 = this;
4062
4063 var selector = [this.rawSpaceBefore, '['];
4064 selector.push(this._stringFor('qualifiedAttribute', 'attribute'));
4065
4066 if (this.operator && (this.value || this.value === '')) {
4067 selector.push(this._stringFor('operator'));
4068 selector.push(this._stringFor('value'));
4069 selector.push(this._stringFor('insensitiveFlag', 'insensitive', function (attrValue, attrSpaces) {
4070 if (attrValue.length > 0 && !_this2.quoted && attrSpaces.before.length === 0 && !(_this2.spaces.value && _this2.spaces.value.after)) {
4071 attrSpaces.before = " ";
4072 }
4073
4074 return defaultAttrConcat(attrValue, attrSpaces);
4075 }));
4076 }
4077
4078 selector.push(']');
4079 selector.push(this.rawSpaceAfter);
4080 return selector.join('');
4081 };
4082
4083 _createClass(Attribute, [{
4084 key: "quoted",
4085 get: function get() {
4086 var qm = this.quoteMark;
4087 return qm === "'" || qm === '"';
4088 },
4089 set: function set(value) {
4090 warnOfDeprecatedQuotedAssignment();
4091 }
4092 /**
4093 * returns a single (`'`) or double (`"`) quote character if the value is quoted.
4094 * returns `null` if the value is not quoted.
4095 * returns `undefined` if the quotation state is unknown (this can happen when
4096 * the attribute is constructed without specifying a quote mark.)
4097 */
4098
4099 }, {
4100 key: "quoteMark",
4101 get: function get() {
4102 return this._quoteMark;
4103 }
4104 /**
4105 * Set the quote mark to be used by this attribute's value.
4106 * If the quote mark changes, the raw (escaped) value at `attr.raws.value` of the attribute
4107 * value is updated accordingly.
4108 *
4109 * @param {"'" | '"' | null} quoteMark The quote mark or `null` if the value should be unquoted.
4110 */
4111 ,
4112 set: function set(quoteMark) {
4113 if (!this._constructed) {
4114 this._quoteMark = quoteMark;
4115 return;
4116 }
4117
4118 if (this._quoteMark !== quoteMark) {
4119 this._quoteMark = quoteMark;
4120
4121 this._syncRawValue();
4122 }
4123 }
4124 }, {
4125 key: "qualifiedAttribute",
4126 get: function get() {
4127 return this.qualifiedName(this.raws.attribute || this.attribute);
4128 }
4129 }, {
4130 key: "insensitiveFlag",
4131 get: function get() {
4132 return this.insensitive ? 'i' : '';
4133 }
4134 }, {
4135 key: "value",
4136 get: function get() {
4137 return this._value;
4138 },
4139 set:
4140 /**
4141 * Before 3.0, the value had to be set to an escaped value including any wrapped
4142 * quote marks. In 3.0, the semantics of `Attribute.value` changed so that the value
4143 * is unescaped during parsing and any quote marks are removed.
4144 *
4145 * Because the ambiguity of this semantic change, if you set `attr.value = newValue`,
4146 * a deprecation warning is raised when the new value contains any characters that would
4147 * require escaping (including if it contains wrapped quotes).
4148 *
4149 * Instead, you should call `attr.setValue(newValue, opts)` and pass options that describe
4150 * how the new value is quoted.
4151 */
4152 function set(v) {
4153 if (this._constructed) {
4154 var _unescapeValue2 = unescapeValue(v),
4155 deprecatedUsage = _unescapeValue2.deprecatedUsage,
4156 unescaped = _unescapeValue2.unescaped,
4157 quoteMark = _unescapeValue2.quoteMark;
4158
4159 if (deprecatedUsage) {
4160 warnOfDeprecatedValueAssignment();
4161 }
4162
4163 if (unescaped === this._value && quoteMark === this._quoteMark) {
4164 return;
4165 }
4166
4167 this._value = unescaped;
4168 this._quoteMark = quoteMark;
4169
4170 this._syncRawValue();
4171 } else {
4172 this._value = v;
4173 }
4174 }
4175 }, {
4176 key: "insensitive",
4177 get: function get() {
4178 return this._insensitive;
4179 }
4180 /**
4181 * Set the case insensitive flag.
4182 * If the case insensitive flag changes, the raw (escaped) value at `attr.raws.insensitiveFlag`
4183 * of the attribute is updated accordingly.
4184 *
4185 * @param {true | false} insensitive true if the attribute should match case-insensitively.
4186 */
4187 ,
4188 set: function set(insensitive) {
4189 if (!insensitive) {
4190 this._insensitive = false; // "i" and "I" can be used in "this.raws.insensitiveFlag" to store the original notation.
4191 // When setting `attr.insensitive = false` both should be erased to ensure correct serialization.
4192
4193 if (this.raws && (this.raws.insensitiveFlag === 'I' || this.raws.insensitiveFlag === 'i')) {
4194 this.raws.insensitiveFlag = undefined;
4195 }
4196 }
4197
4198 this._insensitive = insensitive;
4199 }
4200 }, {
4201 key: "attribute",
4202 get: function get() {
4203 return this._attribute;
4204 },
4205 set: function set(name) {
4206 this._handleEscapes("attribute", name);
4207
4208 this._attribute = name;
4209 }
4210 }]);
4211
4212 return Attribute;
4213 }(_namespace["default"]);
4214
4215 exports["default"] = Attribute;
4216 Attribute.NO_QUOTE = null;
4217 Attribute.SINGLE_QUOTE = "'";
4218 Attribute.DOUBLE_QUOTE = '"';
4219 var CSSESC_QUOTE_OPTIONS = (_CSSESC_QUOTE_OPTIONS = {
4220 "'": {
4221 quotes: 'single',
4222 wrap: true
4223 },
4224 '"': {
4225 quotes: 'double',
4226 wrap: true
4227 }
4228 }, _CSSESC_QUOTE_OPTIONS[null] = {
4229 isIdentifier: true
4230 }, _CSSESC_QUOTE_OPTIONS);
4231
4232 function defaultAttrConcat(attrValue, attrSpaces) {
4233 return "" + attrSpaces.before + attrValue + attrSpaces.after;
4234 }
4235} (attribute$1));
4236
4237var universal$1 = {exports: {}};
4238
4239(function (module, exports) {
4240
4241 exports.__esModule = true;
4242 exports["default"] = void 0;
4243
4244 var _namespace = _interopRequireDefault(namespaceExports);
4245
4246 var _types = types;
4247
4248 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
4249
4250 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
4251
4252 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
4253
4254 var Universal = /*#__PURE__*/function (_Namespace) {
4255 _inheritsLoose(Universal, _Namespace);
4256
4257 function Universal(opts) {
4258 var _this;
4259
4260 _this = _Namespace.call(this, opts) || this;
4261 _this.type = _types.UNIVERSAL;
4262 _this.value = '*';
4263 return _this;
4264 }
4265
4266 return Universal;
4267 }(_namespace["default"]);
4268
4269 exports["default"] = Universal;
4270 module.exports = exports.default;
4271} (universal$1, universal$1.exports));
4272
4273var universalExports = universal$1.exports;
4274
4275var combinator$2 = {exports: {}};
4276
4277(function (module, exports) {
4278
4279 exports.__esModule = true;
4280 exports["default"] = void 0;
4281
4282 var _node = _interopRequireDefault(nodeExports);
4283
4284 var _types = types;
4285
4286 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
4287
4288 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
4289
4290 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
4291
4292 var Combinator = /*#__PURE__*/function (_Node) {
4293 _inheritsLoose(Combinator, _Node);
4294
4295 function Combinator(opts) {
4296 var _this;
4297
4298 _this = _Node.call(this, opts) || this;
4299 _this.type = _types.COMBINATOR;
4300 return _this;
4301 }
4302
4303 return Combinator;
4304 }(_node["default"]);
4305
4306 exports["default"] = Combinator;
4307 module.exports = exports.default;
4308} (combinator$2, combinator$2.exports));
4309
4310var combinatorExports = combinator$2.exports;
4311
4312var nesting$1 = {exports: {}};
4313
4314(function (module, exports) {
4315
4316 exports.__esModule = true;
4317 exports["default"] = void 0;
4318
4319 var _node = _interopRequireDefault(nodeExports);
4320
4321 var _types = types;
4322
4323 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
4324
4325 function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
4326
4327 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
4328
4329 var Nesting = /*#__PURE__*/function (_Node) {
4330 _inheritsLoose(Nesting, _Node);
4331
4332 function Nesting(opts) {
4333 var _this;
4334
4335 _this = _Node.call(this, opts) || this;
4336 _this.type = _types.NESTING;
4337 _this.value = '&';
4338 return _this;
4339 }
4340
4341 return Nesting;
4342 }(_node["default"]);
4343
4344 exports["default"] = Nesting;
4345 module.exports = exports.default;
4346} (nesting$1, nesting$1.exports));
4347
4348var nestingExports = nesting$1.exports;
4349
4350var sortAscending = {exports: {}};
4351
4352(function (module, exports) {
4353
4354 exports.__esModule = true;
4355 exports["default"] = sortAscending;
4356
4357 function sortAscending(list) {
4358 return list.sort(function (a, b) {
4359 return a - b;
4360 });
4361 }
4362 module.exports = exports.default;
4363} (sortAscending, sortAscending.exports));
4364
4365var sortAscendingExports = sortAscending.exports;
4366
4367var tokenize = {};
4368
4369var tokenTypes = {};
4370
4371tokenTypes.__esModule = true;
4372tokenTypes.combinator = tokenTypes.word = tokenTypes.comment = tokenTypes.str = tokenTypes.tab = tokenTypes.newline = tokenTypes.feed = tokenTypes.cr = tokenTypes.backslash = tokenTypes.bang = tokenTypes.slash = tokenTypes.doubleQuote = tokenTypes.singleQuote = tokenTypes.space = tokenTypes.greaterThan = tokenTypes.pipe = tokenTypes.equals = tokenTypes.plus = tokenTypes.caret = tokenTypes.tilde = tokenTypes.dollar = tokenTypes.closeSquare = tokenTypes.openSquare = tokenTypes.closeParenthesis = tokenTypes.openParenthesis = tokenTypes.semicolon = tokenTypes.colon = tokenTypes.comma = tokenTypes.at = tokenTypes.asterisk = tokenTypes.ampersand = void 0;
4373var ampersand = 38; // `&`.charCodeAt(0);
4374
4375tokenTypes.ampersand = ampersand;
4376var asterisk = 42; // `*`.charCodeAt(0);
4377
4378tokenTypes.asterisk = asterisk;
4379var at = 64; // `@`.charCodeAt(0);
4380
4381tokenTypes.at = at;
4382var comma = 44; // `,`.charCodeAt(0);
4383
4384tokenTypes.comma = comma;
4385var colon = 58; // `:`.charCodeAt(0);
4386
4387tokenTypes.colon = colon;
4388var semicolon = 59; // `;`.charCodeAt(0);
4389
4390tokenTypes.semicolon = semicolon;
4391var openParenthesis = 40; // `(`.charCodeAt(0);
4392
4393tokenTypes.openParenthesis = openParenthesis;
4394var closeParenthesis = 41; // `)`.charCodeAt(0);
4395
4396tokenTypes.closeParenthesis = closeParenthesis;
4397var openSquare = 91; // `[`.charCodeAt(0);
4398
4399tokenTypes.openSquare = openSquare;
4400var closeSquare = 93; // `]`.charCodeAt(0);
4401
4402tokenTypes.closeSquare = closeSquare;
4403var dollar = 36; // `$`.charCodeAt(0);
4404
4405tokenTypes.dollar = dollar;
4406var tilde = 126; // `~`.charCodeAt(0);
4407
4408tokenTypes.tilde = tilde;
4409var caret = 94; // `^`.charCodeAt(0);
4410
4411tokenTypes.caret = caret;
4412var plus = 43; // `+`.charCodeAt(0);
4413
4414tokenTypes.plus = plus;
4415var equals = 61; // `=`.charCodeAt(0);
4416
4417tokenTypes.equals = equals;
4418var pipe = 124; // `|`.charCodeAt(0);
4419
4420tokenTypes.pipe = pipe;
4421var greaterThan = 62; // `>`.charCodeAt(0);
4422
4423tokenTypes.greaterThan = greaterThan;
4424var space = 32; // ` `.charCodeAt(0);
4425
4426tokenTypes.space = space;
4427var singleQuote = 39; // `'`.charCodeAt(0);
4428
4429tokenTypes.singleQuote = singleQuote;
4430var doubleQuote = 34; // `"`.charCodeAt(0);
4431
4432tokenTypes.doubleQuote = doubleQuote;
4433var slash = 47; // `/`.charCodeAt(0);
4434
4435tokenTypes.slash = slash;
4436var bang = 33; // `!`.charCodeAt(0);
4437
4438tokenTypes.bang = bang;
4439var backslash = 92; // '\\'.charCodeAt(0);
4440
4441tokenTypes.backslash = backslash;
4442var cr = 13; // '\r'.charCodeAt(0);
4443
4444tokenTypes.cr = cr;
4445var feed = 12; // '\f'.charCodeAt(0);
4446
4447tokenTypes.feed = feed;
4448var newline = 10; // '\n'.charCodeAt(0);
4449
4450tokenTypes.newline = newline;
4451var tab = 9; // '\t'.charCodeAt(0);
4452// Expose aliases primarily for readability.
4453
4454tokenTypes.tab = tab;
4455var str = singleQuote; // No good single character representation!
4456
4457tokenTypes.str = str;
4458var comment$1 = -1;
4459tokenTypes.comment = comment$1;
4460var word = -2;
4461tokenTypes.word = word;
4462var combinator$1 = -3;
4463tokenTypes.combinator = combinator$1;
4464
4465(function (exports) {
4466
4467 exports.__esModule = true;
4468 exports["default"] = tokenize;
4469 exports.FIELDS = void 0;
4470
4471 var t = _interopRequireWildcard(tokenTypes);
4472
4473 var _unescapable, _wordDelimiters;
4474
4475 function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
4476
4477 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
4478
4479 var unescapable = (_unescapable = {}, _unescapable[t.tab] = true, _unescapable[t.newline] = true, _unescapable[t.cr] = true, _unescapable[t.feed] = true, _unescapable);
4480 var wordDelimiters = (_wordDelimiters = {}, _wordDelimiters[t.space] = true, _wordDelimiters[t.tab] = true, _wordDelimiters[t.newline] = true, _wordDelimiters[t.cr] = true, _wordDelimiters[t.feed] = true, _wordDelimiters[t.ampersand] = true, _wordDelimiters[t.asterisk] = true, _wordDelimiters[t.bang] = true, _wordDelimiters[t.comma] = true, _wordDelimiters[t.colon] = true, _wordDelimiters[t.semicolon] = true, _wordDelimiters[t.openParenthesis] = true, _wordDelimiters[t.closeParenthesis] = true, _wordDelimiters[t.openSquare] = true, _wordDelimiters[t.closeSquare] = true, _wordDelimiters[t.singleQuote] = true, _wordDelimiters[t.doubleQuote] = true, _wordDelimiters[t.plus] = true, _wordDelimiters[t.pipe] = true, _wordDelimiters[t.tilde] = true, _wordDelimiters[t.greaterThan] = true, _wordDelimiters[t.equals] = true, _wordDelimiters[t.dollar] = true, _wordDelimiters[t.caret] = true, _wordDelimiters[t.slash] = true, _wordDelimiters);
4481 var hex = {};
4482 var hexChars = "0123456789abcdefABCDEF";
4483
4484 for (var i = 0; i < hexChars.length; i++) {
4485 hex[hexChars.charCodeAt(i)] = true;
4486 }
4487 /**
4488 * Returns the last index of the bar css word
4489 * @param {string} css The string in which the word begins
4490 * @param {number} start The index into the string where word's first letter occurs
4491 */
4492
4493
4494 function consumeWord(css, start) {
4495 var next = start;
4496 var code;
4497
4498 do {
4499 code = css.charCodeAt(next);
4500
4501 if (wordDelimiters[code]) {
4502 return next - 1;
4503 } else if (code === t.backslash) {
4504 next = consumeEscape(css, next) + 1;
4505 } else {
4506 // All other characters are part of the word
4507 next++;
4508 }
4509 } while (next < css.length);
4510
4511 return next - 1;
4512 }
4513 /**
4514 * Returns the last index of the escape sequence
4515 * @param {string} css The string in which the sequence begins
4516 * @param {number} start The index into the string where escape character (`\`) occurs.
4517 */
4518
4519
4520 function consumeEscape(css, start) {
4521 var next = start;
4522 var code = css.charCodeAt(next + 1);
4523
4524 if (unescapable[code]) ; else if (hex[code]) {
4525 var hexDigits = 0; // consume up to 6 hex chars
4526
4527 do {
4528 next++;
4529 hexDigits++;
4530 code = css.charCodeAt(next + 1);
4531 } while (hex[code] && hexDigits < 6); // if fewer than 6 hex chars, a trailing space ends the escape
4532
4533
4534 if (hexDigits < 6 && code === t.space) {
4535 next++;
4536 }
4537 } else {
4538 // the next char is part of the current word
4539 next++;
4540 }
4541
4542 return next;
4543 }
4544
4545 var FIELDS = {
4546 TYPE: 0,
4547 START_LINE: 1,
4548 START_COL: 2,
4549 END_LINE: 3,
4550 END_COL: 4,
4551 START_POS: 5,
4552 END_POS: 6
4553 };
4554 exports.FIELDS = FIELDS;
4555
4556 function tokenize(input) {
4557 var tokens = [];
4558 var css = input.css.valueOf();
4559 var _css = css,
4560 length = _css.length;
4561 var offset = -1;
4562 var line = 1;
4563 var start = 0;
4564 var end = 0;
4565 var code, content, endColumn, endLine, escaped, escapePos, last, lines, next, nextLine, nextOffset, quote, tokenType;
4566
4567 function unclosed(what, fix) {
4568 if (input.safe) {
4569 // fyi: this is never set to true.
4570 css += fix;
4571 next = css.length - 1;
4572 } else {
4573 throw input.error('Unclosed ' + what, line, start - offset, start);
4574 }
4575 }
4576
4577 while (start < length) {
4578 code = css.charCodeAt(start);
4579
4580 if (code === t.newline) {
4581 offset = start;
4582 line += 1;
4583 }
4584
4585 switch (code) {
4586 case t.space:
4587 case t.tab:
4588 case t.newline:
4589 case t.cr:
4590 case t.feed:
4591 next = start;
4592
4593 do {
4594 next += 1;
4595 code = css.charCodeAt(next);
4596
4597 if (code === t.newline) {
4598 offset = next;
4599 line += 1;
4600 }
4601 } while (code === t.space || code === t.newline || code === t.tab || code === t.cr || code === t.feed);
4602
4603 tokenType = t.space;
4604 endLine = line;
4605 endColumn = next - offset - 1;
4606 end = next;
4607 break;
4608
4609 case t.plus:
4610 case t.greaterThan:
4611 case t.tilde:
4612 case t.pipe:
4613 next = start;
4614
4615 do {
4616 next += 1;
4617 code = css.charCodeAt(next);
4618 } while (code === t.plus || code === t.greaterThan || code === t.tilde || code === t.pipe);
4619
4620 tokenType = t.combinator;
4621 endLine = line;
4622 endColumn = start - offset;
4623 end = next;
4624 break;
4625 // Consume these characters as single tokens.
4626
4627 case t.asterisk:
4628 case t.ampersand:
4629 case t.bang:
4630 case t.comma:
4631 case t.equals:
4632 case t.dollar:
4633 case t.caret:
4634 case t.openSquare:
4635 case t.closeSquare:
4636 case t.colon:
4637 case t.semicolon:
4638 case t.openParenthesis:
4639 case t.closeParenthesis:
4640 next = start;
4641 tokenType = code;
4642 endLine = line;
4643 endColumn = start - offset;
4644 end = next + 1;
4645 break;
4646
4647 case t.singleQuote:
4648 case t.doubleQuote:
4649 quote = code === t.singleQuote ? "'" : '"';
4650 next = start;
4651
4652 do {
4653 escaped = false;
4654 next = css.indexOf(quote, next + 1);
4655
4656 if (next === -1) {
4657 unclosed('quote', quote);
4658 }
4659
4660 escapePos = next;
4661
4662 while (css.charCodeAt(escapePos - 1) === t.backslash) {
4663 escapePos -= 1;
4664 escaped = !escaped;
4665 }
4666 } while (escaped);
4667
4668 tokenType = t.str;
4669 endLine = line;
4670 endColumn = start - offset;
4671 end = next + 1;
4672 break;
4673
4674 default:
4675 if (code === t.slash && css.charCodeAt(start + 1) === t.asterisk) {
4676 next = css.indexOf('*/', start + 2) + 1;
4677
4678 if (next === 0) {
4679 unclosed('comment', '*/');
4680 }
4681
4682 content = css.slice(start, next + 1);
4683 lines = content.split('\n');
4684 last = lines.length - 1;
4685
4686 if (last > 0) {
4687 nextLine = line + last;
4688 nextOffset = next - lines[last].length;
4689 } else {
4690 nextLine = line;
4691 nextOffset = offset;
4692 }
4693
4694 tokenType = t.comment;
4695 line = nextLine;
4696 endLine = nextLine;
4697 endColumn = next - nextOffset;
4698 } else if (code === t.slash) {
4699 next = start;
4700 tokenType = code;
4701 endLine = line;
4702 endColumn = start - offset;
4703 end = next + 1;
4704 } else {
4705 next = consumeWord(css, start);
4706 tokenType = t.word;
4707 endLine = line;
4708 endColumn = next - offset;
4709 }
4710
4711 end = next + 1;
4712 break;
4713 } // Ensure that the token structure remains consistent
4714
4715
4716 tokens.push([tokenType, // [0] Token type
4717 line, // [1] Starting line
4718 start - offset, // [2] Starting column
4719 endLine, // [3] Ending line
4720 endColumn, // [4] Ending column
4721 start, // [5] Start position / Source index
4722 end // [6] End position
4723 ]); // Reset offset for the next token
4724
4725 if (nextOffset) {
4726 offset = nextOffset;
4727 nextOffset = null;
4728 }
4729
4730 start = end;
4731 }
4732
4733 return tokens;
4734 }
4735} (tokenize));
4736
4737(function (module, exports) {
4738
4739 exports.__esModule = true;
4740 exports["default"] = void 0;
4741
4742 var _root = _interopRequireDefault(rootExports);
4743
4744 var _selector = _interopRequireDefault(selectorExports);
4745
4746 var _className = _interopRequireDefault(classNameExports);
4747
4748 var _comment = _interopRequireDefault(commentExports);
4749
4750 var _id = _interopRequireDefault(idExports);
4751
4752 var _tag = _interopRequireDefault(tagExports);
4753
4754 var _string = _interopRequireDefault(stringExports);
4755
4756 var _pseudo = _interopRequireDefault(pseudoExports);
4757
4758 var _attribute = _interopRequireWildcard(attribute$1);
4759
4760 var _universal = _interopRequireDefault(universalExports);
4761
4762 var _combinator = _interopRequireDefault(combinatorExports);
4763
4764 var _nesting = _interopRequireDefault(nestingExports);
4765
4766 var _sortAscending = _interopRequireDefault(sortAscendingExports);
4767
4768 var _tokenize = _interopRequireWildcard(tokenize);
4769
4770 var tokens = _interopRequireWildcard(tokenTypes);
4771
4772 var types$1 = _interopRequireWildcard(types);
4773
4774 var _util = util;
4775
4776 var _WHITESPACE_TOKENS, _Object$assign;
4777
4778 function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
4779
4780 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
4781
4782 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
4783
4784 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4785
4786 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; }
4787
4788 var WHITESPACE_TOKENS = (_WHITESPACE_TOKENS = {}, _WHITESPACE_TOKENS[tokens.space] = true, _WHITESPACE_TOKENS[tokens.cr] = true, _WHITESPACE_TOKENS[tokens.feed] = true, _WHITESPACE_TOKENS[tokens.newline] = true, _WHITESPACE_TOKENS[tokens.tab] = true, _WHITESPACE_TOKENS);
4789 var WHITESPACE_EQUIV_TOKENS = Object.assign({}, WHITESPACE_TOKENS, (_Object$assign = {}, _Object$assign[tokens.comment] = true, _Object$assign));
4790
4791 function tokenStart(token) {
4792 return {
4793 line: token[_tokenize.FIELDS.START_LINE],
4794 column: token[_tokenize.FIELDS.START_COL]
4795 };
4796 }
4797
4798 function tokenEnd(token) {
4799 return {
4800 line: token[_tokenize.FIELDS.END_LINE],
4801 column: token[_tokenize.FIELDS.END_COL]
4802 };
4803 }
4804
4805 function getSource(startLine, startColumn, endLine, endColumn) {
4806 return {
4807 start: {
4808 line: startLine,
4809 column: startColumn
4810 },
4811 end: {
4812 line: endLine,
4813 column: endColumn
4814 }
4815 };
4816 }
4817
4818 function getTokenSource(token) {
4819 return getSource(token[_tokenize.FIELDS.START_LINE], token[_tokenize.FIELDS.START_COL], token[_tokenize.FIELDS.END_LINE], token[_tokenize.FIELDS.END_COL]);
4820 }
4821
4822 function getTokenSourceSpan(startToken, endToken) {
4823 if (!startToken) {
4824 return undefined;
4825 }
4826
4827 return getSource(startToken[_tokenize.FIELDS.START_LINE], startToken[_tokenize.FIELDS.START_COL], endToken[_tokenize.FIELDS.END_LINE], endToken[_tokenize.FIELDS.END_COL]);
4828 }
4829
4830 function unescapeProp(node, prop) {
4831 var value = node[prop];
4832
4833 if (typeof value !== "string") {
4834 return;
4835 }
4836
4837 if (value.indexOf("\\") !== -1) {
4838 (0, _util.ensureObject)(node, 'raws');
4839 node[prop] = (0, _util.unesc)(value);
4840
4841 if (node.raws[prop] === undefined) {
4842 node.raws[prop] = value;
4843 }
4844 }
4845
4846 return node;
4847 }
4848
4849 function indexesOf(array, item) {
4850 var i = -1;
4851 var indexes = [];
4852
4853 while ((i = array.indexOf(item, i + 1)) !== -1) {
4854 indexes.push(i);
4855 }
4856
4857 return indexes;
4858 }
4859
4860 function uniqs() {
4861 var list = Array.prototype.concat.apply([], arguments);
4862 return list.filter(function (item, i) {
4863 return i === list.indexOf(item);
4864 });
4865 }
4866
4867 var Parser = /*#__PURE__*/function () {
4868 function Parser(rule, options) {
4869 if (options === void 0) {
4870 options = {};
4871 }
4872
4873 this.rule = rule;
4874 this.options = Object.assign({
4875 lossy: false,
4876 safe: false
4877 }, options);
4878 this.position = 0;
4879 this.css = typeof this.rule === 'string' ? this.rule : this.rule.selector;
4880 this.tokens = (0, _tokenize["default"])({
4881 css: this.css,
4882 error: this._errorGenerator(),
4883 safe: this.options.safe
4884 });
4885 var rootSource = getTokenSourceSpan(this.tokens[0], this.tokens[this.tokens.length - 1]);
4886 this.root = new _root["default"]({
4887 source: rootSource
4888 });
4889 this.root.errorGenerator = this._errorGenerator();
4890 var selector = new _selector["default"]({
4891 source: {
4892 start: {
4893 line: 1,
4894 column: 1
4895 }
4896 }
4897 });
4898 this.root.append(selector);
4899 this.current = selector;
4900 this.loop();
4901 }
4902
4903 var _proto = Parser.prototype;
4904
4905 _proto._errorGenerator = function _errorGenerator() {
4906 var _this = this;
4907
4908 return function (message, errorOptions) {
4909 if (typeof _this.rule === 'string') {
4910 return new Error(message);
4911 }
4912
4913 return _this.rule.error(message, errorOptions);
4914 };
4915 };
4916
4917 _proto.attribute = function attribute() {
4918 var attr = [];
4919 var startingToken = this.currToken;
4920 this.position++;
4921
4922 while (this.position < this.tokens.length && this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
4923 attr.push(this.currToken);
4924 this.position++;
4925 }
4926
4927 if (this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
4928 return this.expected('closing square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
4929 }
4930
4931 var len = attr.length;
4932 var node = {
4933 source: getSource(startingToken[1], startingToken[2], this.currToken[3], this.currToken[4]),
4934 sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
4935 };
4936
4937 if (len === 1 && !~[tokens.word].indexOf(attr[0][_tokenize.FIELDS.TYPE])) {
4938 return this.expected('attribute', attr[0][_tokenize.FIELDS.START_POS]);
4939 }
4940
4941 var pos = 0;
4942 var spaceBefore = '';
4943 var commentBefore = '';
4944 var lastAdded = null;
4945 var spaceAfterMeaningfulToken = false;
4946
4947 while (pos < len) {
4948 var token = attr[pos];
4949 var content = this.content(token);
4950 var next = attr[pos + 1];
4951
4952 switch (token[_tokenize.FIELDS.TYPE]) {
4953 case tokens.space:
4954 // if (
4955 // len === 1 ||
4956 // pos === 0 && this.content(next) === '|'
4957 // ) {
4958 // return this.expected('attribute', token[TOKEN.START_POS], content);
4959 // }
4960 spaceAfterMeaningfulToken = true;
4961
4962 if (this.options.lossy) {
4963 break;
4964 }
4965
4966 if (lastAdded) {
4967 (0, _util.ensureObject)(node, 'spaces', lastAdded);
4968 var prevContent = node.spaces[lastAdded].after || '';
4969 node.spaces[lastAdded].after = prevContent + content;
4970 var existingComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || null;
4971
4972 if (existingComment) {
4973 node.raws.spaces[lastAdded].after = existingComment + content;
4974 }
4975 } else {
4976 spaceBefore = spaceBefore + content;
4977 commentBefore = commentBefore + content;
4978 }
4979
4980 break;
4981
4982 case tokens.asterisk:
4983 if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
4984 node.operator = content;
4985 lastAdded = 'operator';
4986 } else if ((!node.namespace || lastAdded === "namespace" && !spaceAfterMeaningfulToken) && next) {
4987 if (spaceBefore) {
4988 (0, _util.ensureObject)(node, 'spaces', 'attribute');
4989 node.spaces.attribute.before = spaceBefore;
4990 spaceBefore = '';
4991 }
4992
4993 if (commentBefore) {
4994 (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
4995 node.raws.spaces.attribute.before = spaceBefore;
4996 commentBefore = '';
4997 }
4998
4999 node.namespace = (node.namespace || "") + content;
5000 var rawValue = (0, _util.getProp)(node, 'raws', 'namespace') || null;
5001
5002 if (rawValue) {
5003 node.raws.namespace += content;
5004 }
5005
5006 lastAdded = 'namespace';
5007 }
5008
5009 spaceAfterMeaningfulToken = false;
5010 break;
5011
5012 case tokens.dollar:
5013 if (lastAdded === "value") {
5014 var oldRawValue = (0, _util.getProp)(node, 'raws', 'value');
5015 node.value += "$";
5016
5017 if (oldRawValue) {
5018 node.raws.value = oldRawValue + "$";
5019 }
5020
5021 break;
5022 }
5023
5024 // Falls through
5025
5026 case tokens.caret:
5027 if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
5028 node.operator = content;
5029 lastAdded = 'operator';
5030 }
5031
5032 spaceAfterMeaningfulToken = false;
5033 break;
5034
5035 case tokens.combinator:
5036 if (content === '~' && next[_tokenize.FIELDS.TYPE] === tokens.equals) {
5037 node.operator = content;
5038 lastAdded = 'operator';
5039 }
5040
5041 if (content !== '|') {
5042 spaceAfterMeaningfulToken = false;
5043 break;
5044 }
5045
5046 if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
5047 node.operator = content;
5048 lastAdded = 'operator';
5049 } else if (!node.namespace && !node.attribute) {
5050 node.namespace = true;
5051 }
5052
5053 spaceAfterMeaningfulToken = false;
5054 break;
5055
5056 case tokens.word:
5057 if (next && this.content(next) === '|' && attr[pos + 2] && attr[pos + 2][_tokenize.FIELDS.TYPE] !== tokens.equals && // this look-ahead probably fails with comment nodes involved.
5058 !node.operator && !node.namespace) {
5059 node.namespace = content;
5060 lastAdded = 'namespace';
5061 } else if (!node.attribute || lastAdded === "attribute" && !spaceAfterMeaningfulToken) {
5062 if (spaceBefore) {
5063 (0, _util.ensureObject)(node, 'spaces', 'attribute');
5064 node.spaces.attribute.before = spaceBefore;
5065 spaceBefore = '';
5066 }
5067
5068 if (commentBefore) {
5069 (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
5070 node.raws.spaces.attribute.before = commentBefore;
5071 commentBefore = '';
5072 }
5073
5074 node.attribute = (node.attribute || "") + content;
5075
5076 var _rawValue = (0, _util.getProp)(node, 'raws', 'attribute') || null;
5077
5078 if (_rawValue) {
5079 node.raws.attribute += content;
5080 }
5081
5082 lastAdded = 'attribute';
5083 } else if (!node.value && node.value !== "" || lastAdded === "value" && !(spaceAfterMeaningfulToken || node.quoteMark)) {
5084 var _unescaped = (0, _util.unesc)(content);
5085
5086 var _oldRawValue = (0, _util.getProp)(node, 'raws', 'value') || '';
5087
5088 var oldValue = node.value || '';
5089 node.value = oldValue + _unescaped;
5090 node.quoteMark = null;
5091
5092 if (_unescaped !== content || _oldRawValue) {
5093 (0, _util.ensureObject)(node, 'raws');
5094 node.raws.value = (_oldRawValue || oldValue) + content;
5095 }
5096
5097 lastAdded = 'value';
5098 } else {
5099 var insensitive = content === 'i' || content === "I";
5100
5101 if ((node.value || node.value === '') && (node.quoteMark || spaceAfterMeaningfulToken)) {
5102 node.insensitive = insensitive;
5103
5104 if (!insensitive || content === "I") {
5105 (0, _util.ensureObject)(node, 'raws');
5106 node.raws.insensitiveFlag = content;
5107 }
5108
5109 lastAdded = 'insensitive';
5110
5111 if (spaceBefore) {
5112 (0, _util.ensureObject)(node, 'spaces', 'insensitive');
5113 node.spaces.insensitive.before = spaceBefore;
5114 spaceBefore = '';
5115 }
5116
5117 if (commentBefore) {
5118 (0, _util.ensureObject)(node, 'raws', 'spaces', 'insensitive');
5119 node.raws.spaces.insensitive.before = commentBefore;
5120 commentBefore = '';
5121 }
5122 } else if (node.value || node.value === '') {
5123 lastAdded = 'value';
5124 node.value += content;
5125
5126 if (node.raws.value) {
5127 node.raws.value += content;
5128 }
5129 }
5130 }
5131
5132 spaceAfterMeaningfulToken = false;
5133 break;
5134
5135 case tokens.str:
5136 if (!node.attribute || !node.operator) {
5137 return this.error("Expected an attribute followed by an operator preceding the string.", {
5138 index: token[_tokenize.FIELDS.START_POS]
5139 });
5140 }
5141
5142 var _unescapeValue = (0, _attribute.unescapeValue)(content),
5143 unescaped = _unescapeValue.unescaped,
5144 quoteMark = _unescapeValue.quoteMark;
5145
5146 node.value = unescaped;
5147 node.quoteMark = quoteMark;
5148 lastAdded = 'value';
5149 (0, _util.ensureObject)(node, 'raws');
5150 node.raws.value = content;
5151 spaceAfterMeaningfulToken = false;
5152 break;
5153
5154 case tokens.equals:
5155 if (!node.attribute) {
5156 return this.expected('attribute', token[_tokenize.FIELDS.START_POS], content);
5157 }
5158
5159 if (node.value) {
5160 return this.error('Unexpected "=" found; an operator was already defined.', {
5161 index: token[_tokenize.FIELDS.START_POS]
5162 });
5163 }
5164
5165 node.operator = node.operator ? node.operator + content : content;
5166 lastAdded = 'operator';
5167 spaceAfterMeaningfulToken = false;
5168 break;
5169
5170 case tokens.comment:
5171 if (lastAdded) {
5172 if (spaceAfterMeaningfulToken || next && next[_tokenize.FIELDS.TYPE] === tokens.space || lastAdded === 'insensitive') {
5173 var lastComment = (0, _util.getProp)(node, 'spaces', lastAdded, 'after') || '';
5174 var rawLastComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || lastComment;
5175 (0, _util.ensureObject)(node, 'raws', 'spaces', lastAdded);
5176 node.raws.spaces[lastAdded].after = rawLastComment + content;
5177 } else {
5178 var lastValue = node[lastAdded] || '';
5179 var rawLastValue = (0, _util.getProp)(node, 'raws', lastAdded) || lastValue;
5180 (0, _util.ensureObject)(node, 'raws');
5181 node.raws[lastAdded] = rawLastValue + content;
5182 }
5183 } else {
5184 commentBefore = commentBefore + content;
5185 }
5186
5187 break;
5188
5189 default:
5190 return this.error("Unexpected \"" + content + "\" found.", {
5191 index: token[_tokenize.FIELDS.START_POS]
5192 });
5193 }
5194
5195 pos++;
5196 }
5197
5198 unescapeProp(node, "attribute");
5199 unescapeProp(node, "namespace");
5200 this.newNode(new _attribute["default"](node));
5201 this.position++;
5202 }
5203 /**
5204 * return a node containing meaningless garbage up to (but not including) the specified token position.
5205 * if the token position is negative, all remaining tokens are consumed.
5206 *
5207 * This returns an array containing a single string node if all whitespace,
5208 * otherwise an array of comment nodes with space before and after.
5209 *
5210 * These tokens are not added to the current selector, the caller can add them or use them to amend
5211 * a previous node's space metadata.
5212 *
5213 * In lossy mode, this returns only comments.
5214 */
5215 ;
5216
5217 _proto.parseWhitespaceEquivalentTokens = function parseWhitespaceEquivalentTokens(stopPosition) {
5218 if (stopPosition < 0) {
5219 stopPosition = this.tokens.length;
5220 }
5221
5222 var startPosition = this.position;
5223 var nodes = [];
5224 var space = "";
5225 var lastComment = undefined;
5226
5227 do {
5228 if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) {
5229 if (!this.options.lossy) {
5230 space += this.content();
5231 }
5232 } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.comment) {
5233 var spaces = {};
5234
5235 if (space) {
5236 spaces.before = space;
5237 space = "";
5238 }
5239
5240 lastComment = new _comment["default"]({
5241 value: this.content(),
5242 source: getTokenSource(this.currToken),
5243 sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
5244 spaces: spaces
5245 });
5246 nodes.push(lastComment);
5247 }
5248 } while (++this.position < stopPosition);
5249
5250 if (space) {
5251 if (lastComment) {
5252 lastComment.spaces.after = space;
5253 } else if (!this.options.lossy) {
5254 var firstToken = this.tokens[startPosition];
5255 var lastToken = this.tokens[this.position - 1];
5256 nodes.push(new _string["default"]({
5257 value: '',
5258 source: getSource(firstToken[_tokenize.FIELDS.START_LINE], firstToken[_tokenize.FIELDS.START_COL], lastToken[_tokenize.FIELDS.END_LINE], lastToken[_tokenize.FIELDS.END_COL]),
5259 sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
5260 spaces: {
5261 before: space,
5262 after: ''
5263 }
5264 }));
5265 }
5266 }
5267
5268 return nodes;
5269 }
5270 /**
5271 *
5272 * @param {*} nodes
5273 */
5274 ;
5275
5276 _proto.convertWhitespaceNodesToSpace = function convertWhitespaceNodesToSpace(nodes, requiredSpace) {
5277 var _this2 = this;
5278
5279 if (requiredSpace === void 0) {
5280 requiredSpace = false;
5281 }
5282
5283 var space = "";
5284 var rawSpace = "";
5285 nodes.forEach(function (n) {
5286 var spaceBefore = _this2.lossySpace(n.spaces.before, requiredSpace);
5287
5288 var rawSpaceBefore = _this2.lossySpace(n.rawSpaceBefore, requiredSpace);
5289
5290 space += spaceBefore + _this2.lossySpace(n.spaces.after, requiredSpace && spaceBefore.length === 0);
5291 rawSpace += spaceBefore + n.value + _this2.lossySpace(n.rawSpaceAfter, requiredSpace && rawSpaceBefore.length === 0);
5292 });
5293
5294 if (rawSpace === space) {
5295 rawSpace = undefined;
5296 }
5297
5298 var result = {
5299 space: space,
5300 rawSpace: rawSpace
5301 };
5302 return result;
5303 };
5304
5305 _proto.isNamedCombinator = function isNamedCombinator(position) {
5306 if (position === void 0) {
5307 position = this.position;
5308 }
5309
5310 return this.tokens[position + 0] && this.tokens[position + 0][_tokenize.FIELDS.TYPE] === tokens.slash && this.tokens[position + 1] && this.tokens[position + 1][_tokenize.FIELDS.TYPE] === tokens.word && this.tokens[position + 2] && this.tokens[position + 2][_tokenize.FIELDS.TYPE] === tokens.slash;
5311 };
5312
5313 _proto.namedCombinator = function namedCombinator() {
5314 if (this.isNamedCombinator()) {
5315 var nameRaw = this.content(this.tokens[this.position + 1]);
5316 var name = (0, _util.unesc)(nameRaw).toLowerCase();
5317 var raws = {};
5318
5319 if (name !== nameRaw) {
5320 raws.value = "/" + nameRaw + "/";
5321 }
5322
5323 var node = new _combinator["default"]({
5324 value: "/" + name + "/",
5325 source: getSource(this.currToken[_tokenize.FIELDS.START_LINE], this.currToken[_tokenize.FIELDS.START_COL], this.tokens[this.position + 2][_tokenize.FIELDS.END_LINE], this.tokens[this.position + 2][_tokenize.FIELDS.END_COL]),
5326 sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
5327 raws: raws
5328 });
5329 this.position = this.position + 3;
5330 return node;
5331 } else {
5332 this.unexpected();
5333 }
5334 };
5335
5336 _proto.combinator = function combinator() {
5337 var _this3 = this;
5338
5339 if (this.content() === '|') {
5340 return this.namespace();
5341 } // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
5342
5343
5344 var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
5345
5346 if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma) {
5347 var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
5348
5349 if (nodes.length > 0) {
5350 var last = this.current.last;
5351
5352 if (last) {
5353 var _this$convertWhitespa = this.convertWhitespaceNodesToSpace(nodes),
5354 space = _this$convertWhitespa.space,
5355 rawSpace = _this$convertWhitespa.rawSpace;
5356
5357 if (rawSpace !== undefined) {
5358 last.rawSpaceAfter += rawSpace;
5359 }
5360
5361 last.spaces.after += space;
5362 } else {
5363 nodes.forEach(function (n) {
5364 return _this3.newNode(n);
5365 });
5366 }
5367 }
5368
5369 return;
5370 }
5371
5372 var firstToken = this.currToken;
5373 var spaceOrDescendantSelectorNodes = undefined;
5374
5375 if (nextSigTokenPos > this.position) {
5376 spaceOrDescendantSelectorNodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
5377 }
5378
5379 var node;
5380
5381 if (this.isNamedCombinator()) {
5382 node = this.namedCombinator();
5383 } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.combinator) {
5384 node = new _combinator["default"]({
5385 value: this.content(),
5386 source: getTokenSource(this.currToken),
5387 sourceIndex: this.currToken[_tokenize.FIELDS.START_POS]
5388 });
5389 this.position++;
5390 } else if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) ; else if (!spaceOrDescendantSelectorNodes) {
5391 this.unexpected();
5392 }
5393
5394 if (node) {
5395 if (spaceOrDescendantSelectorNodes) {
5396 var _this$convertWhitespa2 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes),
5397 _space = _this$convertWhitespa2.space,
5398 _rawSpace = _this$convertWhitespa2.rawSpace;
5399
5400 node.spaces.before = _space;
5401 node.rawSpaceBefore = _rawSpace;
5402 }
5403 } else {
5404 // descendant combinator
5405 var _this$convertWhitespa3 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes, true),
5406 _space2 = _this$convertWhitespa3.space,
5407 _rawSpace2 = _this$convertWhitespa3.rawSpace;
5408
5409 if (!_rawSpace2) {
5410 _rawSpace2 = _space2;
5411 }
5412
5413 var spaces = {};
5414 var raws = {
5415 spaces: {}
5416 };
5417
5418 if (_space2.endsWith(' ') && _rawSpace2.endsWith(' ')) {
5419 spaces.before = _space2.slice(0, _space2.length - 1);
5420 raws.spaces.before = _rawSpace2.slice(0, _rawSpace2.length - 1);
5421 } else if (_space2.startsWith(' ') && _rawSpace2.startsWith(' ')) {
5422 spaces.after = _space2.slice(1);
5423 raws.spaces.after = _rawSpace2.slice(1);
5424 } else {
5425 raws.value = _rawSpace2;
5426 }
5427
5428 node = new _combinator["default"]({
5429 value: ' ',
5430 source: getTokenSourceSpan(firstToken, this.tokens[this.position - 1]),
5431 sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
5432 spaces: spaces,
5433 raws: raws
5434 });
5435 }
5436
5437 if (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.space) {
5438 node.spaces.after = this.optionalSpace(this.content());
5439 this.position++;
5440 }
5441
5442 return this.newNode(node);
5443 };
5444
5445 _proto.comma = function comma() {
5446 if (this.position === this.tokens.length - 1) {
5447 this.root.trailingComma = true;
5448 this.position++;
5449 return;
5450 }
5451
5452 this.current._inferEndPosition();
5453
5454 var selector = new _selector["default"]({
5455 source: {
5456 start: tokenStart(this.tokens[this.position + 1])
5457 }
5458 });
5459 this.current.parent.append(selector);
5460 this.current = selector;
5461 this.position++;
5462 };
5463
5464 _proto.comment = function comment() {
5465 var current = this.currToken;
5466 this.newNode(new _comment["default"]({
5467 value: this.content(),
5468 source: getTokenSource(current),
5469 sourceIndex: current[_tokenize.FIELDS.START_POS]
5470 }));
5471 this.position++;
5472 };
5473
5474 _proto.error = function error(message, opts) {
5475 throw this.root.error(message, opts);
5476 };
5477
5478 _proto.missingBackslash = function missingBackslash() {
5479 return this.error('Expected a backslash preceding the semicolon.', {
5480 index: this.currToken[_tokenize.FIELDS.START_POS]
5481 });
5482 };
5483
5484 _proto.missingParenthesis = function missingParenthesis() {
5485 return this.expected('opening parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
5486 };
5487
5488 _proto.missingSquareBracket = function missingSquareBracket() {
5489 return this.expected('opening square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
5490 };
5491
5492 _proto.unexpected = function unexpected() {
5493 return this.error("Unexpected '" + this.content() + "'. Escaping special characters with \\ may help.", this.currToken[_tokenize.FIELDS.START_POS]);
5494 };
5495
5496 _proto.namespace = function namespace() {
5497 var before = this.prevToken && this.content(this.prevToken) || true;
5498
5499 if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.word) {
5500 this.position++;
5501 return this.word(before);
5502 } else if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.asterisk) {
5503 this.position++;
5504 return this.universal(before);
5505 }
5506 };
5507
5508 _proto.nesting = function nesting() {
5509 if (this.nextToken) {
5510 var nextContent = this.content(this.nextToken);
5511
5512 if (nextContent === "|") {
5513 this.position++;
5514 return;
5515 }
5516 }
5517
5518 var current = this.currToken;
5519 this.newNode(new _nesting["default"]({
5520 value: this.content(),
5521 source: getTokenSource(current),
5522 sourceIndex: current[_tokenize.FIELDS.START_POS]
5523 }));
5524 this.position++;
5525 };
5526
5527 _proto.parentheses = function parentheses() {
5528 var last = this.current.last;
5529 var unbalanced = 1;
5530 this.position++;
5531
5532 if (last && last.type === types$1.PSEUDO) {
5533 var selector = new _selector["default"]({
5534 source: {
5535 start: tokenStart(this.tokens[this.position - 1])
5536 }
5537 });
5538 var cache = this.current;
5539 last.append(selector);
5540 this.current = selector;
5541
5542 while (this.position < this.tokens.length && unbalanced) {
5543 if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
5544 unbalanced++;
5545 }
5546
5547 if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
5548 unbalanced--;
5549 }
5550
5551 if (unbalanced) {
5552 this.parse();
5553 } else {
5554 this.current.source.end = tokenEnd(this.currToken);
5555 this.current.parent.source.end = tokenEnd(this.currToken);
5556 this.position++;
5557 }
5558 }
5559
5560 this.current = cache;
5561 } else {
5562 // I think this case should be an error. It's used to implement a basic parse of media queries
5563 // but I don't think it's a good idea.
5564 var parenStart = this.currToken;
5565 var parenValue = "(";
5566 var parenEnd;
5567
5568 while (this.position < this.tokens.length && unbalanced) {
5569 if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
5570 unbalanced++;
5571 }
5572
5573 if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
5574 unbalanced--;
5575 }
5576
5577 parenEnd = this.currToken;
5578 parenValue += this.parseParenthesisToken(this.currToken);
5579 this.position++;
5580 }
5581
5582 if (last) {
5583 last.appendToPropertyAndEscape("value", parenValue, parenValue);
5584 } else {
5585 this.newNode(new _string["default"]({
5586 value: parenValue,
5587 source: getSource(parenStart[_tokenize.FIELDS.START_LINE], parenStart[_tokenize.FIELDS.START_COL], parenEnd[_tokenize.FIELDS.END_LINE], parenEnd[_tokenize.FIELDS.END_COL]),
5588 sourceIndex: parenStart[_tokenize.FIELDS.START_POS]
5589 }));
5590 }
5591 }
5592
5593 if (unbalanced) {
5594 return this.expected('closing parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
5595 }
5596 };
5597
5598 _proto.pseudo = function pseudo() {
5599 var _this4 = this;
5600
5601 var pseudoStr = '';
5602 var startingToken = this.currToken;
5603
5604 while (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.colon) {
5605 pseudoStr += this.content();
5606 this.position++;
5607 }
5608
5609 if (!this.currToken) {
5610 return this.expected(['pseudo-class', 'pseudo-element'], this.position - 1);
5611 }
5612
5613 if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.word) {
5614 this.splitWord(false, function (first, length) {
5615 pseudoStr += first;
5616
5617 _this4.newNode(new _pseudo["default"]({
5618 value: pseudoStr,
5619 source: getTokenSourceSpan(startingToken, _this4.currToken),
5620 sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
5621 }));
5622
5623 if (length > 1 && _this4.nextToken && _this4.nextToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
5624 _this4.error('Misplaced parenthesis.', {
5625 index: _this4.nextToken[_tokenize.FIELDS.START_POS]
5626 });
5627 }
5628 });
5629 } else {
5630 return this.expected(['pseudo-class', 'pseudo-element'], this.currToken[_tokenize.FIELDS.START_POS]);
5631 }
5632 };
5633
5634 _proto.space = function space() {
5635 var content = this.content(); // Handle space before and after the selector
5636
5637 if (this.position === 0 || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis || this.current.nodes.every(function (node) {
5638 return node.type === 'comment';
5639 })) {
5640 this.spaces = this.optionalSpace(content);
5641 this.position++;
5642 } else if (this.position === this.tokens.length - 1 || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
5643 this.current.last.spaces.after = this.optionalSpace(content);
5644 this.position++;
5645 } else {
5646 this.combinator();
5647 }
5648 };
5649
5650 _proto.string = function string() {
5651 var current = this.currToken;
5652 this.newNode(new _string["default"]({
5653 value: this.content(),
5654 source: getTokenSource(current),
5655 sourceIndex: current[_tokenize.FIELDS.START_POS]
5656 }));
5657 this.position++;
5658 };
5659
5660 _proto.universal = function universal(namespace) {
5661 var nextToken = this.nextToken;
5662
5663 if (nextToken && this.content(nextToken) === '|') {
5664 this.position++;
5665 return this.namespace();
5666 }
5667
5668 var current = this.currToken;
5669 this.newNode(new _universal["default"]({
5670 value: this.content(),
5671 source: getTokenSource(current),
5672 sourceIndex: current[_tokenize.FIELDS.START_POS]
5673 }), namespace);
5674 this.position++;
5675 };
5676
5677 _proto.splitWord = function splitWord(namespace, firstCallback) {
5678 var _this5 = this;
5679
5680 var nextToken = this.nextToken;
5681 var word = this.content();
5682
5683 while (nextToken && ~[tokens.dollar, tokens.caret, tokens.equals, tokens.word].indexOf(nextToken[_tokenize.FIELDS.TYPE])) {
5684 this.position++;
5685 var current = this.content();
5686 word += current;
5687
5688 if (current.lastIndexOf('\\') === current.length - 1) {
5689 var next = this.nextToken;
5690
5691 if (next && next[_tokenize.FIELDS.TYPE] === tokens.space) {
5692 word += this.requiredSpace(this.content(next));
5693 this.position++;
5694 }
5695 }
5696
5697 nextToken = this.nextToken;
5698 }
5699
5700 var hasClass = indexesOf(word, '.').filter(function (i) {
5701 // Allow escaped dot within class name
5702 var escapedDot = word[i - 1] === '\\'; // Allow decimal numbers percent in @keyframes
5703
5704 var isKeyframesPercent = /^\d+\.\d+%$/.test(word);
5705 return !escapedDot && !isKeyframesPercent;
5706 });
5707 var hasId = indexesOf(word, '#').filter(function (i) {
5708 return word[i - 1] !== '\\';
5709 }); // Eliminate Sass interpolations from the list of id indexes
5710
5711 var interpolations = indexesOf(word, '#{');
5712
5713 if (interpolations.length) {
5714 hasId = hasId.filter(function (hashIndex) {
5715 return !~interpolations.indexOf(hashIndex);
5716 });
5717 }
5718
5719 var indices = (0, _sortAscending["default"])(uniqs([0].concat(hasClass, hasId)));
5720 indices.forEach(function (ind, i) {
5721 var index = indices[i + 1] || word.length;
5722 var value = word.slice(ind, index);
5723
5724 if (i === 0 && firstCallback) {
5725 return firstCallback.call(_this5, value, indices.length);
5726 }
5727
5728 var node;
5729 var current = _this5.currToken;
5730 var sourceIndex = current[_tokenize.FIELDS.START_POS] + indices[i];
5731 var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1));
5732
5733 if (~hasClass.indexOf(ind)) {
5734 var classNameOpts = {
5735 value: value.slice(1),
5736 source: source,
5737 sourceIndex: sourceIndex
5738 };
5739 node = new _className["default"](unescapeProp(classNameOpts, "value"));
5740 } else if (~hasId.indexOf(ind)) {
5741 var idOpts = {
5742 value: value.slice(1),
5743 source: source,
5744 sourceIndex: sourceIndex
5745 };
5746 node = new _id["default"](unescapeProp(idOpts, "value"));
5747 } else {
5748 var tagOpts = {
5749 value: value,
5750 source: source,
5751 sourceIndex: sourceIndex
5752 };
5753 unescapeProp(tagOpts, "value");
5754 node = new _tag["default"](tagOpts);
5755 }
5756
5757 _this5.newNode(node, namespace); // Ensure that the namespace is used only once
5758
5759
5760 namespace = null;
5761 });
5762 this.position++;
5763 };
5764
5765 _proto.word = function word(namespace) {
5766 var nextToken = this.nextToken;
5767
5768 if (nextToken && this.content(nextToken) === '|') {
5769 this.position++;
5770 return this.namespace();
5771 }
5772
5773 return this.splitWord(namespace);
5774 };
5775
5776 _proto.loop = function loop() {
5777 while (this.position < this.tokens.length) {
5778 this.parse(true);
5779 }
5780
5781 this.current._inferEndPosition();
5782
5783 return this.root;
5784 };
5785
5786 _proto.parse = function parse(throwOnParenthesis) {
5787 switch (this.currToken[_tokenize.FIELDS.TYPE]) {
5788 case tokens.space:
5789 this.space();
5790 break;
5791
5792 case tokens.comment:
5793 this.comment();
5794 break;
5795
5796 case tokens.openParenthesis:
5797 this.parentheses();
5798 break;
5799
5800 case tokens.closeParenthesis:
5801 if (throwOnParenthesis) {
5802 this.missingParenthesis();
5803 }
5804
5805 break;
5806
5807 case tokens.openSquare:
5808 this.attribute();
5809 break;
5810
5811 case tokens.dollar:
5812 case tokens.caret:
5813 case tokens.equals:
5814 case tokens.word:
5815 this.word();
5816 break;
5817
5818 case tokens.colon:
5819 this.pseudo();
5820 break;
5821
5822 case tokens.comma:
5823 this.comma();
5824 break;
5825
5826 case tokens.asterisk:
5827 this.universal();
5828 break;
5829
5830 case tokens.ampersand:
5831 this.nesting();
5832 break;
5833
5834 case tokens.slash:
5835 case tokens.combinator:
5836 this.combinator();
5837 break;
5838
5839 case tokens.str:
5840 this.string();
5841 break;
5842 // These cases throw; no break needed.
5843
5844 case tokens.closeSquare:
5845 this.missingSquareBracket();
5846
5847 case tokens.semicolon:
5848 this.missingBackslash();
5849
5850 default:
5851 this.unexpected();
5852 }
5853 }
5854 /**
5855 * Helpers
5856 */
5857 ;
5858
5859 _proto.expected = function expected(description, index, found) {
5860 if (Array.isArray(description)) {
5861 var last = description.pop();
5862 description = description.join(', ') + " or " + last;
5863 }
5864
5865 var an = /^[aeiou]/.test(description[0]) ? 'an' : 'a';
5866
5867 if (!found) {
5868 return this.error("Expected " + an + " " + description + ".", {
5869 index: index
5870 });
5871 }
5872
5873 return this.error("Expected " + an + " " + description + ", found \"" + found + "\" instead.", {
5874 index: index
5875 });
5876 };
5877
5878 _proto.requiredSpace = function requiredSpace(space) {
5879 return this.options.lossy ? ' ' : space;
5880 };
5881
5882 _proto.optionalSpace = function optionalSpace(space) {
5883 return this.options.lossy ? '' : space;
5884 };
5885
5886 _proto.lossySpace = function lossySpace(space, required) {
5887 if (this.options.lossy) {
5888 return required ? ' ' : '';
5889 } else {
5890 return space;
5891 }
5892 };
5893
5894 _proto.parseParenthesisToken = function parseParenthesisToken(token) {
5895 var content = this.content(token);
5896
5897 if (token[_tokenize.FIELDS.TYPE] === tokens.space) {
5898 return this.requiredSpace(content);
5899 } else {
5900 return content;
5901 }
5902 };
5903
5904 _proto.newNode = function newNode(node, namespace) {
5905 if (namespace) {
5906 if (/^ +$/.test(namespace)) {
5907 if (!this.options.lossy) {
5908 this.spaces = (this.spaces || '') + namespace;
5909 }
5910
5911 namespace = true;
5912 }
5913
5914 node.namespace = namespace;
5915 unescapeProp(node, "namespace");
5916 }
5917
5918 if (this.spaces) {
5919 node.spaces.before = this.spaces;
5920 this.spaces = '';
5921 }
5922
5923 return this.current.append(node);
5924 };
5925
5926 _proto.content = function content(token) {
5927 if (token === void 0) {
5928 token = this.currToken;
5929 }
5930
5931 return this.css.slice(token[_tokenize.FIELDS.START_POS], token[_tokenize.FIELDS.END_POS]);
5932 };
5933
5934 /**
5935 * returns the index of the next non-whitespace, non-comment token.
5936 * returns -1 if no meaningful token is found.
5937 */
5938 _proto.locateNextMeaningfulToken = function locateNextMeaningfulToken(startPosition) {
5939 if (startPosition === void 0) {
5940 startPosition = this.position + 1;
5941 }
5942
5943 var searchPosition = startPosition;
5944
5945 while (searchPosition < this.tokens.length) {
5946 if (WHITESPACE_EQUIV_TOKENS[this.tokens[searchPosition][_tokenize.FIELDS.TYPE]]) {
5947 searchPosition++;
5948 continue;
5949 } else {
5950 return searchPosition;
5951 }
5952 }
5953
5954 return -1;
5955 };
5956
5957 _createClass(Parser, [{
5958 key: "currToken",
5959 get: function get() {
5960 return this.tokens[this.position];
5961 }
5962 }, {
5963 key: "nextToken",
5964 get: function get() {
5965 return this.tokens[this.position + 1];
5966 }
5967 }, {
5968 key: "prevToken",
5969 get: function get() {
5970 return this.tokens[this.position - 1];
5971 }
5972 }]);
5973
5974 return Parser;
5975 }();
5976
5977 exports["default"] = Parser;
5978 module.exports = exports.default;
5979} (parser, parser.exports));
5980
5981var parserExports = parser.exports;
5982
5983(function (module, exports) {
5984
5985 exports.__esModule = true;
5986 exports["default"] = void 0;
5987
5988 var _parser = _interopRequireDefault(parserExports);
5989
5990 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
5991
5992 var Processor = /*#__PURE__*/function () {
5993 function Processor(func, options) {
5994 this.func = func || function noop() {};
5995
5996 this.funcRes = null;
5997 this.options = options;
5998 }
5999
6000 var _proto = Processor.prototype;
6001
6002 _proto._shouldUpdateSelector = function _shouldUpdateSelector(rule, options) {
6003 if (options === void 0) {
6004 options = {};
6005 }
6006
6007 var merged = Object.assign({}, this.options, options);
6008
6009 if (merged.updateSelector === false) {
6010 return false;
6011 } else {
6012 return typeof rule !== "string";
6013 }
6014 };
6015
6016 _proto._isLossy = function _isLossy(options) {
6017 if (options === void 0) {
6018 options = {};
6019 }
6020
6021 var merged = Object.assign({}, this.options, options);
6022
6023 if (merged.lossless === false) {
6024 return true;
6025 } else {
6026 return false;
6027 }
6028 };
6029
6030 _proto._root = function _root(rule, options) {
6031 if (options === void 0) {
6032 options = {};
6033 }
6034
6035 var parser = new _parser["default"](rule, this._parseOptions(options));
6036 return parser.root;
6037 };
6038
6039 _proto._parseOptions = function _parseOptions(options) {
6040 return {
6041 lossy: this._isLossy(options)
6042 };
6043 };
6044
6045 _proto._run = function _run(rule, options) {
6046 var _this = this;
6047
6048 if (options === void 0) {
6049 options = {};
6050 }
6051
6052 return new Promise(function (resolve, reject) {
6053 try {
6054 var root = _this._root(rule, options);
6055
6056 Promise.resolve(_this.func(root)).then(function (transform) {
6057 var string = undefined;
6058
6059 if (_this._shouldUpdateSelector(rule, options)) {
6060 string = root.toString();
6061 rule.selector = string;
6062 }
6063
6064 return {
6065 transform: transform,
6066 root: root,
6067 string: string
6068 };
6069 }).then(resolve, reject);
6070 } catch (e) {
6071 reject(e);
6072 return;
6073 }
6074 });
6075 };
6076
6077 _proto._runSync = function _runSync(rule, options) {
6078 if (options === void 0) {
6079 options = {};
6080 }
6081
6082 var root = this._root(rule, options);
6083
6084 var transform = this.func(root);
6085
6086 if (transform && typeof transform.then === "function") {
6087 throw new Error("Selector processor returned a promise to a synchronous call.");
6088 }
6089
6090 var string = undefined;
6091
6092 if (options.updateSelector && typeof rule !== "string") {
6093 string = root.toString();
6094 rule.selector = string;
6095 }
6096
6097 return {
6098 transform: transform,
6099 root: root,
6100 string: string
6101 };
6102 }
6103 /**
6104 * Process rule into a selector AST.
6105 *
6106 * @param rule {postcss.Rule | string} The css selector to be processed
6107 * @param options The options for processing
6108 * @returns {Promise<parser.Root>} The AST of the selector after processing it.
6109 */
6110 ;
6111
6112 _proto.ast = function ast(rule, options) {
6113 return this._run(rule, options).then(function (result) {
6114 return result.root;
6115 });
6116 }
6117 /**
6118 * Process rule into a selector AST synchronously.
6119 *
6120 * @param rule {postcss.Rule | string} The css selector to be processed
6121 * @param options The options for processing
6122 * @returns {parser.Root} The AST of the selector after processing it.
6123 */
6124 ;
6125
6126 _proto.astSync = function astSync(rule, options) {
6127 return this._runSync(rule, options).root;
6128 }
6129 /**
6130 * Process a selector into a transformed value asynchronously
6131 *
6132 * @param rule {postcss.Rule | string} The css selector to be processed
6133 * @param options The options for processing
6134 * @returns {Promise<any>} The value returned by the processor.
6135 */
6136 ;
6137
6138 _proto.transform = function transform(rule, options) {
6139 return this._run(rule, options).then(function (result) {
6140 return result.transform;
6141 });
6142 }
6143 /**
6144 * Process a selector into a transformed value synchronously.
6145 *
6146 * @param rule {postcss.Rule | string} The css selector to be processed
6147 * @param options The options for processing
6148 * @returns {any} The value returned by the processor.
6149 */
6150 ;
6151
6152 _proto.transformSync = function transformSync(rule, options) {
6153 return this._runSync(rule, options).transform;
6154 }
6155 /**
6156 * Process a selector into a new selector string asynchronously.
6157 *
6158 * @param rule {postcss.Rule | string} The css selector to be processed
6159 * @param options The options for processing
6160 * @returns {string} the selector after processing.
6161 */
6162 ;
6163
6164 _proto.process = function process(rule, options) {
6165 return this._run(rule, options).then(function (result) {
6166 return result.string || result.root.toString();
6167 });
6168 }
6169 /**
6170 * Process a selector into a new selector string synchronously.
6171 *
6172 * @param rule {postcss.Rule | string} The css selector to be processed
6173 * @param options The options for processing
6174 * @returns {string} the selector after processing.
6175 */
6176 ;
6177
6178 _proto.processSync = function processSync(rule, options) {
6179 var result = this._runSync(rule, options);
6180
6181 return result.string || result.root.toString();
6182 };
6183
6184 return Processor;
6185 }();
6186
6187 exports["default"] = Processor;
6188 module.exports = exports.default;
6189} (processor, processor.exports));
6190
6191var processorExports = processor.exports;
6192
6193var selectors = {};
6194
6195var constructors = {};
6196
6197constructors.__esModule = true;
6198constructors.universal = constructors.tag = constructors.string = constructors.selector = constructors.root = constructors.pseudo = constructors.nesting = constructors.id = constructors.comment = constructors.combinator = constructors.className = constructors.attribute = void 0;
6199
6200var _attribute = _interopRequireDefault$2(attribute$1);
6201
6202var _className = _interopRequireDefault$2(classNameExports);
6203
6204var _combinator = _interopRequireDefault$2(combinatorExports);
6205
6206var _comment = _interopRequireDefault$2(commentExports);
6207
6208var _id = _interopRequireDefault$2(idExports);
6209
6210var _nesting = _interopRequireDefault$2(nestingExports);
6211
6212var _pseudo = _interopRequireDefault$2(pseudoExports);
6213
6214var _root = _interopRequireDefault$2(rootExports);
6215
6216var _selector = _interopRequireDefault$2(selectorExports);
6217
6218var _string = _interopRequireDefault$2(stringExports);
6219
6220var _tag = _interopRequireDefault$2(tagExports);
6221
6222var _universal = _interopRequireDefault$2(universalExports);
6223
6224function _interopRequireDefault$2(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6225
6226var attribute = function attribute(opts) {
6227 return new _attribute["default"](opts);
6228};
6229
6230constructors.attribute = attribute;
6231
6232var className = function className(opts) {
6233 return new _className["default"](opts);
6234};
6235
6236constructors.className = className;
6237
6238var combinator = function combinator(opts) {
6239 return new _combinator["default"](opts);
6240};
6241
6242constructors.combinator = combinator;
6243
6244var comment = function comment(opts) {
6245 return new _comment["default"](opts);
6246};
6247
6248constructors.comment = comment;
6249
6250var id = function id(opts) {
6251 return new _id["default"](opts);
6252};
6253
6254constructors.id = id;
6255
6256var nesting = function nesting(opts) {
6257 return new _nesting["default"](opts);
6258};
6259
6260constructors.nesting = nesting;
6261
6262var pseudo = function pseudo(opts) {
6263 return new _pseudo["default"](opts);
6264};
6265
6266constructors.pseudo = pseudo;
6267
6268var root = function root(opts) {
6269 return new _root["default"](opts);
6270};
6271
6272constructors.root = root;
6273
6274var selector = function selector(opts) {
6275 return new _selector["default"](opts);
6276};
6277
6278constructors.selector = selector;
6279
6280var string = function string(opts) {
6281 return new _string["default"](opts);
6282};
6283
6284constructors.string = string;
6285
6286var tag = function tag(opts) {
6287 return new _tag["default"](opts);
6288};
6289
6290constructors.tag = tag;
6291
6292var universal = function universal(opts) {
6293 return new _universal["default"](opts);
6294};
6295
6296constructors.universal = universal;
6297
6298var guards = {};
6299
6300guards.__esModule = true;
6301guards.isNode = isNode;
6302guards.isPseudoElement = isPseudoElement;
6303guards.isPseudoClass = isPseudoClass;
6304guards.isContainer = isContainer;
6305guards.isNamespace = isNamespace;
6306guards.isUniversal = guards.isTag = guards.isString = guards.isSelector = guards.isRoot = guards.isPseudo = guards.isNesting = guards.isIdentifier = guards.isComment = guards.isCombinator = guards.isClassName = guards.isAttribute = void 0;
6307
6308var _types = types;
6309
6310var _IS_TYPE;
6311
6312var IS_TYPE = (_IS_TYPE = {}, _IS_TYPE[_types.ATTRIBUTE] = true, _IS_TYPE[_types.CLASS] = true, _IS_TYPE[_types.COMBINATOR] = true, _IS_TYPE[_types.COMMENT] = true, _IS_TYPE[_types.ID] = true, _IS_TYPE[_types.NESTING] = true, _IS_TYPE[_types.PSEUDO] = true, _IS_TYPE[_types.ROOT] = true, _IS_TYPE[_types.SELECTOR] = true, _IS_TYPE[_types.STRING] = true, _IS_TYPE[_types.TAG] = true, _IS_TYPE[_types.UNIVERSAL] = true, _IS_TYPE);
6313
6314function isNode(node) {
6315 return typeof node === "object" && IS_TYPE[node.type];
6316}
6317
6318function isNodeType(type, node) {
6319 return isNode(node) && node.type === type;
6320}
6321
6322var isAttribute = isNodeType.bind(null, _types.ATTRIBUTE);
6323guards.isAttribute = isAttribute;
6324var isClassName = isNodeType.bind(null, _types.CLASS);
6325guards.isClassName = isClassName;
6326var isCombinator = isNodeType.bind(null, _types.COMBINATOR);
6327guards.isCombinator = isCombinator;
6328var isComment = isNodeType.bind(null, _types.COMMENT);
6329guards.isComment = isComment;
6330var isIdentifier = isNodeType.bind(null, _types.ID);
6331guards.isIdentifier = isIdentifier;
6332var isNesting = isNodeType.bind(null, _types.NESTING);
6333guards.isNesting = isNesting;
6334var isPseudo = isNodeType.bind(null, _types.PSEUDO);
6335guards.isPseudo = isPseudo;
6336var isRoot = isNodeType.bind(null, _types.ROOT);
6337guards.isRoot = isRoot;
6338var isSelector = isNodeType.bind(null, _types.SELECTOR);
6339guards.isSelector = isSelector;
6340var isString = isNodeType.bind(null, _types.STRING);
6341guards.isString = isString;
6342var isTag = isNodeType.bind(null, _types.TAG);
6343guards.isTag = isTag;
6344var isUniversal = isNodeType.bind(null, _types.UNIVERSAL);
6345guards.isUniversal = isUniversal;
6346
6347function isPseudoElement(node) {
6348 return isPseudo(node) && node.value && (node.value.startsWith("::") || node.value.toLowerCase() === ":before" || node.value.toLowerCase() === ":after" || node.value.toLowerCase() === ":first-letter" || node.value.toLowerCase() === ":first-line");
6349}
6350
6351function isPseudoClass(node) {
6352 return isPseudo(node) && !isPseudoElement(node);
6353}
6354
6355function isContainer(node) {
6356 return !!(isNode(node) && node.walk);
6357}
6358
6359function isNamespace(node) {
6360 return isAttribute(node) || isTag(node);
6361}
6362
6363(function (exports) {
6364
6365 exports.__esModule = true;
6366
6367 var _types = types;
6368
6369 Object.keys(_types).forEach(function (key) {
6370 if (key === "default" || key === "__esModule") return;
6371 if (key in exports && exports[key] === _types[key]) return;
6372 exports[key] = _types[key];
6373 });
6374
6375 var _constructors = constructors;
6376
6377 Object.keys(_constructors).forEach(function (key) {
6378 if (key === "default" || key === "__esModule") return;
6379 if (key in exports && exports[key] === _constructors[key]) return;
6380 exports[key] = _constructors[key];
6381 });
6382
6383 var _guards = guards;
6384
6385 Object.keys(_guards).forEach(function (key) {
6386 if (key === "default" || key === "__esModule") return;
6387 if (key in exports && exports[key] === _guards[key]) return;
6388 exports[key] = _guards[key];
6389 });
6390} (selectors));
6391
6392(function (module, exports) {
6393
6394 exports.__esModule = true;
6395 exports["default"] = void 0;
6396
6397 var _processor = _interopRequireDefault(processorExports);
6398
6399 var selectors$1 = _interopRequireWildcard(selectors);
6400
6401 function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
6402
6403 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
6404
6405 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6406
6407 var parser = function parser(processor) {
6408 return new _processor["default"](processor);
6409 };
6410
6411 Object.assign(parser, selectors$1);
6412 delete parser.__esModule;
6413 var _default = parser;
6414 exports["default"] = _default;
6415 module.exports = exports.default;
6416} (dist, dist.exports));
6417
6418var distExports = dist.exports;
6419
6420const selectorParser$1 = distExports;
6421const valueParser = lib;
6422const { extractICSS } = src$4;
6423
6424const isSpacing = (node) => node.type === "combinator" && node.value === " ";
6425
6426function normalizeNodeArray(nodes) {
6427 const array = [];
6428
6429 nodes.forEach((x) => {
6430 if (Array.isArray(x)) {
6431 normalizeNodeArray(x).forEach((item) => {
6432 array.push(item);
6433 });
6434 } else if (x) {
6435 array.push(x);
6436 }
6437 });
6438
6439 if (array.length > 0 && isSpacing(array[array.length - 1])) {
6440 array.pop();
6441 }
6442 return array;
6443}
6444
6445function localizeNode(rule, mode, localAliasMap) {
6446 const transform = (node, context) => {
6447 if (context.ignoreNextSpacing && !isSpacing(node)) {
6448 throw new Error("Missing whitespace after " + context.ignoreNextSpacing);
6449 }
6450
6451 if (context.enforceNoSpacing && isSpacing(node)) {
6452 throw new Error("Missing whitespace before " + context.enforceNoSpacing);
6453 }
6454
6455 let newNodes;
6456
6457 switch (node.type) {
6458 case "root": {
6459 let resultingGlobal;
6460
6461 context.hasPureGlobals = false;
6462
6463 newNodes = node.nodes.map((n) => {
6464 const nContext = {
6465 global: context.global,
6466 lastWasSpacing: true,
6467 hasLocals: false,
6468 explicit: false,
6469 };
6470
6471 n = transform(n, nContext);
6472
6473 if (typeof resultingGlobal === "undefined") {
6474 resultingGlobal = nContext.global;
6475 } else if (resultingGlobal !== nContext.global) {
6476 throw new Error(
6477 'Inconsistent rule global/local result in rule "' +
6478 node +
6479 '" (multiple selectors must result in the same mode for the rule)'
6480 );
6481 }
6482
6483 if (!nContext.hasLocals) {
6484 context.hasPureGlobals = true;
6485 }
6486
6487 return n;
6488 });
6489
6490 context.global = resultingGlobal;
6491
6492 node.nodes = normalizeNodeArray(newNodes);
6493 break;
6494 }
6495 case "selector": {
6496 newNodes = node.map((childNode) => transform(childNode, context));
6497
6498 node = node.clone();
6499 node.nodes = normalizeNodeArray(newNodes);
6500 break;
6501 }
6502 case "combinator": {
6503 if (isSpacing(node)) {
6504 if (context.ignoreNextSpacing) {
6505 context.ignoreNextSpacing = false;
6506 context.lastWasSpacing = false;
6507 context.enforceNoSpacing = false;
6508 return null;
6509 }
6510 context.lastWasSpacing = true;
6511 return node;
6512 }
6513 break;
6514 }
6515 case "pseudo": {
6516 let childContext;
6517 const isNested = !!node.length;
6518 const isScoped = node.value === ":local" || node.value === ":global";
6519 const isImportExport =
6520 node.value === ":import" || node.value === ":export";
6521
6522 if (isImportExport) {
6523 context.hasLocals = true;
6524 // :local(.foo)
6525 } else if (isNested) {
6526 if (isScoped) {
6527 if (node.nodes.length === 0) {
6528 throw new Error(`${node.value}() can't be empty`);
6529 }
6530
6531 if (context.inside) {
6532 throw new Error(
6533 `A ${node.value} is not allowed inside of a ${context.inside}(...)`
6534 );
6535 }
6536
6537 childContext = {
6538 global: node.value === ":global",
6539 inside: node.value,
6540 hasLocals: false,
6541 explicit: true,
6542 };
6543
6544 newNodes = node
6545 .map((childNode) => transform(childNode, childContext))
6546 .reduce((acc, next) => acc.concat(next.nodes), []);
6547
6548 if (newNodes.length) {
6549 const { before, after } = node.spaces;
6550
6551 const first = newNodes[0];
6552 const last = newNodes[newNodes.length - 1];
6553
6554 first.spaces = { before, after: first.spaces.after };
6555 last.spaces = { before: last.spaces.before, after };
6556 }
6557
6558 node = newNodes;
6559
6560 break;
6561 } else {
6562 childContext = {
6563 global: context.global,
6564 inside: context.inside,
6565 lastWasSpacing: true,
6566 hasLocals: false,
6567 explicit: context.explicit,
6568 };
6569 newNodes = node.map((childNode) =>
6570 transform(childNode, childContext)
6571 );
6572
6573 node = node.clone();
6574 node.nodes = normalizeNodeArray(newNodes);
6575
6576 if (childContext.hasLocals) {
6577 context.hasLocals = true;
6578 }
6579 }
6580 break;
6581
6582 //:local .foo .bar
6583 } else if (isScoped) {
6584 if (context.inside) {
6585 throw new Error(
6586 `A ${node.value} is not allowed inside of a ${context.inside}(...)`
6587 );
6588 }
6589
6590 const addBackSpacing = !!node.spaces.before;
6591
6592 context.ignoreNextSpacing = context.lastWasSpacing
6593 ? node.value
6594 : false;
6595
6596 context.enforceNoSpacing = context.lastWasSpacing
6597 ? false
6598 : node.value;
6599
6600 context.global = node.value === ":global";
6601 context.explicit = true;
6602
6603 // because this node has spacing that is lost when we remove it
6604 // we make up for it by adding an extra combinator in since adding
6605 // spacing on the parent selector doesn't work
6606 return addBackSpacing
6607 ? selectorParser$1.combinator({ value: " " })
6608 : null;
6609 }
6610 break;
6611 }
6612 case "id":
6613 case "class": {
6614 if (!node.value) {
6615 throw new Error("Invalid class or id selector syntax");
6616 }
6617
6618 if (context.global) {
6619 break;
6620 }
6621
6622 const isImportedValue = localAliasMap.has(node.value);
6623 const isImportedWithExplicitScope = isImportedValue && context.explicit;
6624
6625 if (!isImportedValue || isImportedWithExplicitScope) {
6626 const innerNode = node.clone();
6627 innerNode.spaces = { before: "", after: "" };
6628
6629 node = selectorParser$1.pseudo({
6630 value: ":local",
6631 nodes: [innerNode],
6632 spaces: node.spaces,
6633 });
6634
6635 context.hasLocals = true;
6636 }
6637
6638 break;
6639 }
6640 }
6641
6642 context.lastWasSpacing = false;
6643 context.ignoreNextSpacing = false;
6644 context.enforceNoSpacing = false;
6645
6646 return node;
6647 };
6648
6649 const rootContext = {
6650 global: mode === "global",
6651 hasPureGlobals: false,
6652 };
6653
6654 rootContext.selector = selectorParser$1((root) => {
6655 transform(root, rootContext);
6656 }).processSync(rule, { updateSelector: false, lossless: true });
6657
6658 return rootContext;
6659}
6660
6661function localizeDeclNode(node, context) {
6662 switch (node.type) {
6663 case "word":
6664 if (context.localizeNextItem) {
6665 if (!context.localAliasMap.has(node.value)) {
6666 node.value = ":local(" + node.value + ")";
6667 context.localizeNextItem = false;
6668 }
6669 }
6670 break;
6671
6672 case "function":
6673 if (
6674 context.options &&
6675 context.options.rewriteUrl &&
6676 node.value.toLowerCase() === "url"
6677 ) {
6678 node.nodes.map((nestedNode) => {
6679 if (nestedNode.type !== "string" && nestedNode.type !== "word") {
6680 return;
6681 }
6682
6683 let newUrl = context.options.rewriteUrl(
6684 context.global,
6685 nestedNode.value
6686 );
6687
6688 switch (nestedNode.type) {
6689 case "string":
6690 if (nestedNode.quote === "'") {
6691 newUrl = newUrl.replace(/(\\)/g, "\\$1").replace(/'/g, "\\'");
6692 }
6693
6694 if (nestedNode.quote === '"') {
6695 newUrl = newUrl.replace(/(\\)/g, "\\$1").replace(/"/g, '\\"');
6696 }
6697
6698 break;
6699 case "word":
6700 newUrl = newUrl.replace(/("|'|\)|\\)/g, "\\$1");
6701 break;
6702 }
6703
6704 nestedNode.value = newUrl;
6705 });
6706 }
6707 break;
6708 }
6709 return node;
6710}
6711
6712function isWordAFunctionArgument(wordNode, functionNode) {
6713 return functionNode
6714 ? functionNode.nodes.some(
6715 (functionNodeChild) =>
6716 functionNodeChild.sourceIndex === wordNode.sourceIndex
6717 )
6718 : false;
6719}
6720
6721function localizeDeclarationValues(localize, declaration, context) {
6722 const valueNodes = valueParser(declaration.value);
6723
6724 valueNodes.walk((node, index, nodes) => {
6725 const subContext = {
6726 options: context.options,
6727 global: context.global,
6728 localizeNextItem: localize && !context.global,
6729 localAliasMap: context.localAliasMap,
6730 };
6731 nodes[index] = localizeDeclNode(node, subContext);
6732 });
6733
6734 declaration.value = valueNodes.toString();
6735}
6736
6737function localizeDeclaration(declaration, context) {
6738 const isAnimation = /animation$/i.test(declaration.prop);
6739
6740 if (isAnimation) {
6741 const validIdent = /^-?[_a-z][_a-z0-9-]*$/i;
6742
6743 /*
6744 The spec defines some keywords that you can use to describe properties such as the timing
6745 function. These are still valid animation names, so as long as there is a property that accepts
6746 a keyword, it is given priority. Only when all the properties that can take a keyword are
6747 exhausted can the animation name be set to the keyword. I.e.
6748
6749 animation: infinite infinite;
6750
6751 The animation will repeat an infinite number of times from the first argument, and will have an
6752 animation name of infinite from the second.
6753 */
6754 const animationKeywords = {
6755 $alternate: 1,
6756 "$alternate-reverse": 1,
6757 $backwards: 1,
6758 $both: 1,
6759 $ease: 1,
6760 "$ease-in": 1,
6761 "$ease-in-out": 1,
6762 "$ease-out": 1,
6763 $forwards: 1,
6764 $infinite: 1,
6765 $linear: 1,
6766 $none: Infinity, // No matter how many times you write none, it will never be an animation name
6767 $normal: 1,
6768 $paused: 1,
6769 $reverse: 1,
6770 $running: 1,
6771 "$step-end": 1,
6772 "$step-start": 1,
6773 $initial: Infinity,
6774 $inherit: Infinity,
6775 $unset: Infinity,
6776 };
6777 let parsedAnimationKeywords = {};
6778 let stepsFunctionNode = null;
6779 const valueNodes = valueParser(declaration.value).walk((node) => {
6780 /* If div-token appeared (represents as comma ','), a possibility of an animation-keywords should be reflesh. */
6781 if (node.type === "div") {
6782 parsedAnimationKeywords = {};
6783 }
6784 if (node.type === "function" && node.value.toLowerCase() === "steps") {
6785 stepsFunctionNode = node;
6786 }
6787 const value =
6788 node.type === "word" &&
6789 !isWordAFunctionArgument(node, stepsFunctionNode)
6790 ? node.value.toLowerCase()
6791 : null;
6792
6793 let shouldParseAnimationName = false;
6794
6795 if (value && validIdent.test(value)) {
6796 if ("$" + value in animationKeywords) {
6797 parsedAnimationKeywords["$" + value] =
6798 "$" + value in parsedAnimationKeywords
6799 ? parsedAnimationKeywords["$" + value] + 1
6800 : 0;
6801
6802 shouldParseAnimationName =
6803 parsedAnimationKeywords["$" + value] >=
6804 animationKeywords["$" + value];
6805 } else {
6806 shouldParseAnimationName = true;
6807 }
6808 }
6809
6810 const subContext = {
6811 options: context.options,
6812 global: context.global,
6813 localizeNextItem: shouldParseAnimationName && !context.global,
6814 localAliasMap: context.localAliasMap,
6815 };
6816 return localizeDeclNode(node, subContext);
6817 });
6818
6819 declaration.value = valueNodes.toString();
6820
6821 return;
6822 }
6823
6824 const isAnimationName = /animation(-name)?$/i.test(declaration.prop);
6825
6826 if (isAnimationName) {
6827 return localizeDeclarationValues(true, declaration, context);
6828 }
6829
6830 const hasUrl = /url\(/i.test(declaration.value);
6831
6832 if (hasUrl) {
6833 return localizeDeclarationValues(false, declaration, context);
6834 }
6835}
6836
6837src$2.exports = (options = {}) => {
6838 if (
6839 options &&
6840 options.mode &&
6841 options.mode !== "global" &&
6842 options.mode !== "local" &&
6843 options.mode !== "pure"
6844 ) {
6845 throw new Error(
6846 'options.mode must be either "global", "local" or "pure" (default "local")'
6847 );
6848 }
6849
6850 const pureMode = options && options.mode === "pure";
6851 const globalMode = options && options.mode === "global";
6852
6853 return {
6854 postcssPlugin: "postcss-modules-local-by-default",
6855 prepare() {
6856 const localAliasMap = new Map();
6857
6858 return {
6859 Once(root) {
6860 const { icssImports } = extractICSS(root, false);
6861
6862 Object.keys(icssImports).forEach((key) => {
6863 Object.keys(icssImports[key]).forEach((prop) => {
6864 localAliasMap.set(prop, icssImports[key][prop]);
6865 });
6866 });
6867
6868 root.walkAtRules((atRule) => {
6869 if (/keyframes$/i.test(atRule.name)) {
6870 const globalMatch = /^\s*:global\s*\((.+)\)\s*$/.exec(
6871 atRule.params
6872 );
6873 const localMatch = /^\s*:local\s*\((.+)\)\s*$/.exec(
6874 atRule.params
6875 );
6876
6877 let globalKeyframes = globalMode;
6878
6879 if (globalMatch) {
6880 if (pureMode) {
6881 throw atRule.error(
6882 "@keyframes :global(...) is not allowed in pure mode"
6883 );
6884 }
6885 atRule.params = globalMatch[1];
6886 globalKeyframes = true;
6887 } else if (localMatch) {
6888 atRule.params = localMatch[0];
6889 globalKeyframes = false;
6890 } else if (!globalMode) {
6891 if (atRule.params && !localAliasMap.has(atRule.params)) {
6892 atRule.params = ":local(" + atRule.params + ")";
6893 }
6894 }
6895
6896 atRule.walkDecls((declaration) => {
6897 localizeDeclaration(declaration, {
6898 localAliasMap,
6899 options: options,
6900 global: globalKeyframes,
6901 });
6902 });
6903 } else if (atRule.nodes) {
6904 atRule.nodes.forEach((declaration) => {
6905 if (declaration.type === "decl") {
6906 localizeDeclaration(declaration, {
6907 localAliasMap,
6908 options: options,
6909 global: globalMode,
6910 });
6911 }
6912 });
6913 }
6914 });
6915
6916 root.walkRules((rule) => {
6917 if (
6918 rule.parent &&
6919 rule.parent.type === "atrule" &&
6920 /keyframes$/i.test(rule.parent.name)
6921 ) {
6922 // ignore keyframe rules
6923 return;
6924 }
6925
6926 const context = localizeNode(rule, options.mode, localAliasMap);
6927
6928 context.options = options;
6929 context.localAliasMap = localAliasMap;
6930
6931 if (pureMode && context.hasPureGlobals) {
6932 throw rule.error(
6933 'Selector "' +
6934 rule.selector +
6935 '" is not pure ' +
6936 "(pure selectors must contain at least one local class or id)"
6937 );
6938 }
6939
6940 rule.selector = context.selector;
6941
6942 // Less-syntax mixins parse as rules with no nodes
6943 if (rule.nodes) {
6944 rule.nodes.forEach((declaration) =>
6945 localizeDeclaration(declaration, context)
6946 );
6947 }
6948 });
6949 },
6950 };
6951 },
6952 };
6953};
6954src$2.exports.postcss = true;
6955
6956var srcExports$1 = src$2.exports;
6957
6958const selectorParser = distExports;
6959
6960const hasOwnProperty = Object.prototype.hasOwnProperty;
6961
6962function getSingleLocalNamesForComposes(root) {
6963 return root.nodes.map((node) => {
6964 if (node.type !== "selector" || node.nodes.length !== 1) {
6965 throw new Error(
6966 `composition is only allowed when selector is single :local class name not in "${root}"`
6967 );
6968 }
6969
6970 node = node.nodes[0];
6971
6972 if (
6973 node.type !== "pseudo" ||
6974 node.value !== ":local" ||
6975 node.nodes.length !== 1
6976 ) {
6977 throw new Error(
6978 'composition is only allowed when selector is single :local class name not in "' +
6979 root +
6980 '", "' +
6981 node +
6982 '" is weird'
6983 );
6984 }
6985
6986 node = node.first;
6987
6988 if (node.type !== "selector" || node.length !== 1) {
6989 throw new Error(
6990 'composition is only allowed when selector is single :local class name not in "' +
6991 root +
6992 '", "' +
6993 node +
6994 '" is weird'
6995 );
6996 }
6997
6998 node = node.first;
6999
7000 if (node.type !== "class") {
7001 // 'id' is not possible, because you can't compose ids
7002 throw new Error(
7003 'composition is only allowed when selector is single :local class name not in "' +
7004 root +
7005 '", "' +
7006 node +
7007 '" is weird'
7008 );
7009 }
7010
7011 return node.value;
7012 });
7013}
7014
7015const whitespace = "[\\x20\\t\\r\\n\\f]";
7016const unescapeRegExp = new RegExp(
7017 "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)",
7018 "ig"
7019);
7020
7021function unescape(str) {
7022 return str.replace(unescapeRegExp, (_, escaped, escapedWhitespace) => {
7023 const high = "0x" + escaped - 0x10000;
7024
7025 // NaN means non-codepoint
7026 // Workaround erroneous numeric interpretation of +"0x"
7027 return high !== high || escapedWhitespace
7028 ? escaped
7029 : high < 0
7030 ? // BMP codepoint
7031 String.fromCharCode(high + 0x10000)
7032 : // Supplemental Plane codepoint (surrogate pair)
7033 String.fromCharCode((high >> 10) | 0xd800, (high & 0x3ff) | 0xdc00);
7034 });
7035}
7036
7037const plugin = (options = {}) => {
7038 const generateScopedName =
7039 (options && options.generateScopedName) || plugin.generateScopedName;
7040 const generateExportEntry =
7041 (options && options.generateExportEntry) || plugin.generateExportEntry;
7042 const exportGlobals = options && options.exportGlobals;
7043
7044 return {
7045 postcssPlugin: "postcss-modules-scope",
7046 Once(root, { rule }) {
7047 const exports = Object.create(null);
7048
7049 function exportScopedName(name, rawName) {
7050 const scopedName = generateScopedName(
7051 rawName ? rawName : name,
7052 root.source.input.from,
7053 root.source.input.css
7054 );
7055 const exportEntry = generateExportEntry(
7056 rawName ? rawName : name,
7057 scopedName,
7058 root.source.input.from,
7059 root.source.input.css
7060 );
7061 const { key, value } = exportEntry;
7062
7063 exports[key] = exports[key] || [];
7064
7065 if (exports[key].indexOf(value) < 0) {
7066 exports[key].push(value);
7067 }
7068
7069 return scopedName;
7070 }
7071
7072 function localizeNode(node) {
7073 switch (node.type) {
7074 case "selector":
7075 node.nodes = node.map(localizeNode);
7076 return node;
7077 case "class":
7078 return selectorParser.className({
7079 value: exportScopedName(
7080 node.value,
7081 node.raws && node.raws.value ? node.raws.value : null
7082 ),
7083 });
7084 case "id": {
7085 return selectorParser.id({
7086 value: exportScopedName(
7087 node.value,
7088 node.raws && node.raws.value ? node.raws.value : null
7089 ),
7090 });
7091 }
7092 }
7093
7094 throw new Error(
7095 `${node.type} ("${node}") is not allowed in a :local block`
7096 );
7097 }
7098
7099 function traverseNode(node) {
7100 switch (node.type) {
7101 case "pseudo":
7102 if (node.value === ":local") {
7103 if (node.nodes.length !== 1) {
7104 throw new Error('Unexpected comma (",") in :local block');
7105 }
7106
7107 const selector = localizeNode(node.first);
7108 // move the spaces that were around the psuedo selector to the first
7109 // non-container node
7110 selector.first.spaces = node.spaces;
7111
7112 const nextNode = node.next();
7113
7114 if (
7115 nextNode &&
7116 nextNode.type === "combinator" &&
7117 nextNode.value === " " &&
7118 /\\[A-F0-9]{1,6}$/.test(selector.last.value)
7119 ) {
7120 selector.last.spaces.after = " ";
7121 }
7122
7123 node.replaceWith(selector);
7124
7125 return;
7126 }
7127 /* falls through */
7128 case "root":
7129 case "selector": {
7130 node.each(traverseNode);
7131 break;
7132 }
7133 case "id":
7134 case "class":
7135 if (exportGlobals) {
7136 exports[node.value] = [node.value];
7137 }
7138 break;
7139 }
7140 return node;
7141 }
7142
7143 // Find any :import and remember imported names
7144 const importedNames = {};
7145
7146 root.walkRules(/^:import\(.+\)$/, (rule) => {
7147 rule.walkDecls((decl) => {
7148 importedNames[decl.prop] = true;
7149 });
7150 });
7151
7152 // Find any :local selectors
7153 root.walkRules((rule) => {
7154 let parsedSelector = selectorParser().astSync(rule);
7155
7156 rule.selector = traverseNode(parsedSelector.clone()).toString();
7157
7158 rule.walkDecls(/composes|compose-with/i, (decl) => {
7159 const localNames = getSingleLocalNamesForComposes(parsedSelector);
7160 const classes = decl.value.split(/\s+/);
7161
7162 classes.forEach((className) => {
7163 const global = /^global\(([^)]+)\)$/.exec(className);
7164
7165 if (global) {
7166 localNames.forEach((exportedName) => {
7167 exports[exportedName].push(global[1]);
7168 });
7169 } else if (hasOwnProperty.call(importedNames, className)) {
7170 localNames.forEach((exportedName) => {
7171 exports[exportedName].push(className);
7172 });
7173 } else if (hasOwnProperty.call(exports, className)) {
7174 localNames.forEach((exportedName) => {
7175 exports[className].forEach((item) => {
7176 exports[exportedName].push(item);
7177 });
7178 });
7179 } else {
7180 throw decl.error(
7181 `referenced class name "${className}" in ${decl.prop} not found`
7182 );
7183 }
7184 });
7185
7186 decl.remove();
7187 });
7188
7189 // Find any :local values
7190 rule.walkDecls((decl) => {
7191 if (!/:local\s*\((.+?)\)/.test(decl.value)) {
7192 return;
7193 }
7194
7195 let tokens = decl.value.split(/(,|'[^']*'|"[^"]*")/);
7196
7197 tokens = tokens.map((token, idx) => {
7198 if (idx === 0 || tokens[idx - 1] === ",") {
7199 let result = token;
7200
7201 const localMatch = /:local\s*\((.+?)\)/.exec(token);
7202
7203 if (localMatch) {
7204 const input = localMatch.input;
7205 const matchPattern = localMatch[0];
7206 const matchVal = localMatch[1];
7207 const newVal = exportScopedName(matchVal);
7208
7209 result = input.replace(matchPattern, newVal);
7210 } else {
7211 return token;
7212 }
7213
7214 return result;
7215 } else {
7216 return token;
7217 }
7218 });
7219
7220 decl.value = tokens.join("");
7221 });
7222 });
7223
7224 // Find any :local keyframes
7225 root.walkAtRules(/keyframes$/i, (atRule) => {
7226 const localMatch = /^\s*:local\s*\((.+?)\)\s*$/.exec(atRule.params);
7227
7228 if (!localMatch) {
7229 return;
7230 }
7231
7232 atRule.params = exportScopedName(localMatch[1]);
7233 });
7234
7235 // If we found any :locals, insert an :export rule
7236 const exportedNames = Object.keys(exports);
7237
7238 if (exportedNames.length > 0) {
7239 const exportRule = rule({ selector: ":export" });
7240
7241 exportedNames.forEach((exportedName) =>
7242 exportRule.append({
7243 prop: exportedName,
7244 value: exports[exportedName].join(" "),
7245 raws: { before: "\n " },
7246 })
7247 );
7248
7249 root.append(exportRule);
7250 }
7251 },
7252 };
7253};
7254
7255plugin.postcss = true;
7256
7257plugin.generateScopedName = function (name, path) {
7258 const sanitisedPath = path
7259 .replace(/\.[^./\\]+$/, "")
7260 .replace(/[\W_]+/g, "_")
7261 .replace(/^_|_$/g, "");
7262
7263 return `_${sanitisedPath}__${name}`.trim();
7264};
7265
7266plugin.generateExportEntry = function (name, scopedName) {
7267 return {
7268 key: unescape(name),
7269 value: unescape(scopedName),
7270 };
7271};
7272
7273var src$1 = plugin;
7274
7275function hash(str) {
7276 var hash = 5381,
7277 i = str.length;
7278
7279 while(i) {
7280 hash = (hash * 33) ^ str.charCodeAt(--i);
7281 }
7282
7283 /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
7284 * integers. Since we want the results to be always positive, convert the
7285 * signed int to an unsigned by doing an unsigned bitshift. */
7286 return hash >>> 0;
7287}
7288
7289var stringHash = hash;
7290
7291var src = {exports: {}};
7292
7293const ICSSUtils = src$4;
7294
7295const matchImports = /^(.+?|\([\s\S]+?\))\s+from\s+("[^"]*"|'[^']*'|[\w-]+)$/;
7296const matchValueDefinition = /(?:\s+|^)([\w-]+):?(.*?)$/;
7297const matchImport = /^([\w-]+)(?:\s+as\s+([\w-]+))?/;
7298
7299src.exports = (options) => {
7300 let importIndex = 0;
7301 const createImportedName =
7302 (options && options.createImportedName) ||
7303 ((importName /*, path*/) =>
7304 `i__const_${importName.replace(/\W/g, "_")}_${importIndex++}`);
7305
7306 return {
7307 postcssPlugin: "postcss-modules-values",
7308 prepare(result) {
7309 const importAliases = [];
7310 const definitions = {};
7311
7312 return {
7313 Once(root, postcss) {
7314 root.walkAtRules(/value/i, (atRule) => {
7315 const matches = atRule.params.match(matchImports);
7316
7317 if (matches) {
7318 let [, /*match*/ aliases, path] = matches;
7319
7320 // We can use constants for path names
7321 if (definitions[path]) {
7322 path = definitions[path];
7323 }
7324
7325 const imports = aliases
7326 .replace(/^\(\s*([\s\S]+)\s*\)$/, "$1")
7327 .split(/\s*,\s*/)
7328 .map((alias) => {
7329 const tokens = matchImport.exec(alias);
7330
7331 if (tokens) {
7332 const [, /*match*/ theirName, myName = theirName] = tokens;
7333 const importedName = createImportedName(myName);
7334 definitions[myName] = importedName;
7335 return { theirName, importedName };
7336 } else {
7337 throw new Error(`@import statement "${alias}" is invalid!`);
7338 }
7339 });
7340
7341 importAliases.push({ path, imports });
7342
7343 atRule.remove();
7344
7345 return;
7346 }
7347
7348 if (atRule.params.indexOf("@value") !== -1) {
7349 result.warn("Invalid value definition: " + atRule.params);
7350 }
7351
7352 let [, key, value] = `${atRule.params}${atRule.raws.between}`.match(
7353 matchValueDefinition
7354 );
7355
7356 const normalizedValue = value.replace(/\/\*((?!\*\/).*?)\*\//g, "");
7357
7358 if (normalizedValue.length === 0) {
7359 result.warn("Invalid value definition: " + atRule.params);
7360 atRule.remove();
7361
7362 return;
7363 }
7364
7365 let isOnlySpace = /^\s+$/.test(normalizedValue);
7366
7367 if (!isOnlySpace) {
7368 value = value.trim();
7369 }
7370
7371 // Add to the definitions, knowing that values can refer to each other
7372 definitions[key] = ICSSUtils.replaceValueSymbols(
7373 value,
7374 definitions
7375 );
7376
7377 atRule.remove();
7378 });
7379
7380 /* If we have no definitions, don't continue */
7381 if (!Object.keys(definitions).length) {
7382 return;
7383 }
7384
7385 /* Perform replacements */
7386 ICSSUtils.replaceSymbols(root, definitions);
7387
7388 /* We want to export anything defined by now, but don't add it to the CSS yet or it well get picked up by the replacement stuff */
7389 const exportDeclarations = Object.keys(definitions).map((key) =>
7390 postcss.decl({
7391 value: definitions[key],
7392 prop: key,
7393 raws: { before: "\n " },
7394 })
7395 );
7396
7397 /* Add export rules if any */
7398 if (exportDeclarations.length > 0) {
7399 const exportRule = postcss.rule({
7400 selector: ":export",
7401 raws: { after: "\n" },
7402 });
7403
7404 exportRule.append(exportDeclarations);
7405
7406 root.prepend(exportRule);
7407 }
7408
7409 /* Add import rules */
7410 importAliases.reverse().forEach(({ path, imports }) => {
7411 const importRule = postcss.rule({
7412 selector: `:import(${path})`,
7413 raws: { after: "\n" },
7414 });
7415
7416 imports.forEach(({ theirName, importedName }) => {
7417 importRule.append({
7418 value: theirName,
7419 prop: importedName,
7420 raws: { before: "\n " },
7421 });
7422 });
7423
7424 root.prepend(importRule);
7425 });
7426 },
7427 };
7428 },
7429 };
7430};
7431
7432src.exports.postcss = true;
7433
7434var srcExports = src.exports;
7435
7436Object.defineProperty(scoping, "__esModule", {
7437 value: true
7438});
7439scoping.behaviours = void 0;
7440scoping.getDefaultPlugins = getDefaultPlugins;
7441scoping.getDefaultScopeBehaviour = getDefaultScopeBehaviour;
7442scoping.getScopedNameGenerator = getScopedNameGenerator;
7443
7444var _postcssModulesExtractImports = _interopRequireDefault$1(srcExports$2);
7445
7446var _genericNames = _interopRequireDefault$1(genericNames);
7447
7448var _postcssModulesLocalByDefault = _interopRequireDefault$1(srcExports$1);
7449
7450var _postcssModulesScope = _interopRequireDefault$1(src$1);
7451
7452var _stringHash = _interopRequireDefault$1(stringHash);
7453
7454var _postcssModulesValues = _interopRequireDefault$1(srcExports);
7455
7456function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7457
7458const behaviours = {
7459 LOCAL: "local",
7460 GLOBAL: "global"
7461};
7462scoping.behaviours = behaviours;
7463
7464function getDefaultPlugins({
7465 behaviour,
7466 generateScopedName,
7467 exportGlobals
7468}) {
7469 const scope = (0, _postcssModulesScope.default)({
7470 generateScopedName,
7471 exportGlobals
7472 });
7473 const plugins = {
7474 [behaviours.LOCAL]: [_postcssModulesValues.default, (0, _postcssModulesLocalByDefault.default)({
7475 mode: "local"
7476 }), _postcssModulesExtractImports.default, scope],
7477 [behaviours.GLOBAL]: [_postcssModulesValues.default, (0, _postcssModulesLocalByDefault.default)({
7478 mode: "global"
7479 }), _postcssModulesExtractImports.default, scope]
7480 };
7481 return plugins[behaviour];
7482}
7483
7484function isValidBehaviour(behaviour) {
7485 return Object.keys(behaviours).map(key => behaviours[key]).indexOf(behaviour) > -1;
7486}
7487
7488function getDefaultScopeBehaviour(scopeBehaviour) {
7489 return scopeBehaviour && isValidBehaviour(scopeBehaviour) ? scopeBehaviour : behaviours.LOCAL;
7490}
7491
7492function generateScopedNameDefault(name, filename, css) {
7493 const i = css.indexOf(`.${name}`);
7494 const lineNumber = css.substr(0, i).split(/[\r\n]/).length;
7495 const hash = (0, _stringHash.default)(css).toString(36).substr(0, 5);
7496 return `_${name}_${hash}_${lineNumber}`;
7497}
7498
7499function getScopedNameGenerator(generateScopedName, hashPrefix) {
7500 const scopedNameGenerator = generateScopedName || generateScopedNameDefault;
7501
7502 if (typeof scopedNameGenerator === "function") {
7503 return scopedNameGenerator;
7504 }
7505
7506 return (0, _genericNames.default)(scopedNameGenerator, {
7507 context: process.cwd(),
7508 hashPrefix: hashPrefix
7509 });
7510}
7511
7512Object.defineProperty(pluginFactory, "__esModule", {
7513 value: true
7514});
7515pluginFactory.makePlugin = makePlugin;
7516
7517var _postcss = _interopRequireDefault(require$$0);
7518
7519var _unquote = _interopRequireDefault(unquote$1);
7520
7521var _Parser = _interopRequireDefault(Parser$1);
7522
7523var _saveJSON = _interopRequireDefault(saveJSON$1);
7524
7525var _localsConvention = localsConvention;
7526
7527var _FileSystemLoader = _interopRequireDefault(FileSystemLoader$1);
7528
7529var _scoping = scoping;
7530
7531function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7532
7533const PLUGIN_NAME = "postcss-modules";
7534
7535function isGlobalModule(globalModules, inputFile) {
7536 return globalModules.some(regex => inputFile.match(regex));
7537}
7538
7539function getDefaultPluginsList(opts, inputFile) {
7540 const globalModulesList = opts.globalModulePaths || null;
7541 const exportGlobals = opts.exportGlobals || false;
7542 const defaultBehaviour = (0, _scoping.getDefaultScopeBehaviour)(opts.scopeBehaviour);
7543 const generateScopedName = (0, _scoping.getScopedNameGenerator)(opts.generateScopedName, opts.hashPrefix);
7544
7545 if (globalModulesList && isGlobalModule(globalModulesList, inputFile)) {
7546 return (0, _scoping.getDefaultPlugins)({
7547 behaviour: _scoping.behaviours.GLOBAL,
7548 generateScopedName,
7549 exportGlobals
7550 });
7551 }
7552
7553 return (0, _scoping.getDefaultPlugins)({
7554 behaviour: defaultBehaviour,
7555 generateScopedName,
7556 exportGlobals
7557 });
7558}
7559
7560function getLoader(opts, plugins) {
7561 const root = typeof opts.root === "undefined" ? "/" : opts.root;
7562 return typeof opts.Loader === "function" ? new opts.Loader(root, plugins, opts.resolve) : new _FileSystemLoader.default(root, plugins, opts.resolve);
7563}
7564
7565function isOurPlugin(plugin) {
7566 return plugin.postcssPlugin === PLUGIN_NAME;
7567}
7568
7569function makePlugin(opts) {
7570 return {
7571 postcssPlugin: PLUGIN_NAME,
7572
7573 async OnceExit(css, {
7574 result
7575 }) {
7576 const getJSON = opts.getJSON || _saveJSON.default;
7577 const inputFile = css.source.input.file;
7578 const pluginList = getDefaultPluginsList(opts, inputFile);
7579 const resultPluginIndex = result.processor.plugins.findIndex(plugin => isOurPlugin(plugin));
7580
7581 if (resultPluginIndex === -1) {
7582 throw new Error("Plugin missing from options.");
7583 }
7584
7585 const earlierPlugins = result.processor.plugins.slice(0, resultPluginIndex);
7586 const loaderPlugins = [...earlierPlugins, ...pluginList];
7587 const loader = getLoader(opts, loaderPlugins);
7588
7589 const fetcher = async (file, relativeTo, depTrace) => {
7590 const unquoteFile = (0, _unquote.default)(file);
7591 return loader.fetch.call(loader, unquoteFile, relativeTo, depTrace);
7592 };
7593
7594 const parser = new _Parser.default(fetcher);
7595 await (0, _postcss.default)([...pluginList, parser.plugin()]).process(css, {
7596 from: inputFile
7597 });
7598 const out = loader.finalSource;
7599 if (out) css.prepend(out);
7600
7601 if (opts.localsConvention) {
7602 const reducer = (0, _localsConvention.makeLocalsConventionReducer)(opts.localsConvention, inputFile);
7603 parser.exportTokens = Object.entries(parser.exportTokens).reduce(reducer, {});
7604 }
7605
7606 result.messages.push({
7607 type: "export",
7608 plugin: "postcss-modules",
7609 exportTokens: parser.exportTokens
7610 }); // getJSON may return a promise
7611
7612 return getJSON(css.source.input.file, parser.exportTokens, result.opts.to);
7613 }
7614
7615 };
7616}
7617
7618var _fs = require$$0__default;
7619
7620var _fs2 = fs;
7621
7622var _pluginFactory = pluginFactory;
7623
7624(0, _fs2.setFileSystem)({
7625 readFile: _fs.readFile,
7626 writeFile: _fs.writeFile
7627});
7628
7629build.exports = (opts = {}) => (0, _pluginFactory.makePlugin)(opts);
7630
7631var postcss = build.exports.postcss = true;
7632
7633var buildExports = build.exports;
7634var index = /*@__PURE__*/getDefaultExportFromCjs(buildExports);
7635
7636var index$1 = /*#__PURE__*/_mergeNamespaces({
7637 __proto__: null,
7638 default: index,
7639 postcss: postcss
7640}, [buildExports]);
7641
7642export { index$1 as i };
Note: See TracBrowser for help on using the repository browser.