You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

7113 lines
230 KiB

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