jiek 0.4.7-alpha.1 → 0.4.7-alpha.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/bin/jiek.js +7 -4
  2. package/dist/cli.cjs +5028 -0
  3. package/dist/cli.js +4277 -95
  4. package/dist/cli.min.cjs +19 -0
  5. package/dist/cli.min.js +19 -1
  6. package/dist/index.cjs +5 -0
  7. package/dist/index.js +1 -3
  8. package/dist/index.min.cjs +1 -0
  9. package/dist/index.min.js +1 -1
  10. package/dist/rollup/index.cjs +4670 -0
  11. package/dist/rollup/index.js +4180 -66
  12. package/dist/rollup/index.min.cjs +19 -0
  13. package/dist/rollup/index.min.js +19 -1
  14. package/package.json +13 -11
  15. package/src/commands/base.ts +1 -2
  16. package/src/commands/build.ts +4 -2
  17. package/src/rollup/index.ts +2 -2
  18. package/src/utils/filterSupport.ts +2 -0
  19. package/src/utils/tsRegister.ts +4 -0
  20. package/dist/cli.d.mts.map +0 -1
  21. package/dist/cli.d.ts.map +0 -1
  22. package/dist/cli.js.map +0 -1
  23. package/dist/cli.min.js.map +0 -1
  24. package/dist/cli.min.mjs +0 -1
  25. package/dist/cli.min.mjs.map +0 -1
  26. package/dist/cli.mjs +0 -803
  27. package/dist/cli.mjs.map +0 -1
  28. package/dist/index.d.mts.map +0 -1
  29. package/dist/index.d.ts.map +0 -1
  30. package/dist/index.js.map +0 -1
  31. package/dist/index.min.js.map +0 -1
  32. package/dist/index.min.mjs +0 -1
  33. package/dist/index.min.mjs.map +0 -1
  34. package/dist/index.mjs +0 -3
  35. package/dist/index.mjs.map +0 -1
  36. package/dist/rollup/index.d.mts.map +0 -1
  37. package/dist/rollup/index.d.ts.map +0 -1
  38. package/dist/rollup/index.js.map +0 -1
  39. package/dist/rollup/index.min.js.map +0 -1
  40. package/dist/rollup/index.min.mjs +0 -1
  41. package/dist/rollup/index.min.mjs.map +0 -1
  42. package/dist/rollup/index.mjs +0 -551
  43. package/dist/rollup/index.mjs.map +0 -1
  44. package/src/pkg.ts +0 -1
  45. /package/dist/{cli.d.mts → cli.d.cts} +0 -0
  46. /package/dist/{index.d.mts → index.d.cts} +0 -0
  47. /package/dist/rollup/{index.d.mts → index.d.cts} +0 -0
@@ -0,0 +1,4670 @@
1
+ 'use strict';
2
+
3
+ var fs = require('node:fs');
4
+ var path = require('node:path');
5
+ var entrypoints = require('@jiek/pkger/entrypoints');
6
+ var rollupPluginDts = require('@jiek/rollup-plugin-dts');
7
+ var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
8
+ var commonjs = require('@rollup/plugin-commonjs');
9
+ var json = require('@rollup/plugin-json');
10
+ var pluginNodeResolve = require('@rollup/plugin-node-resolve');
11
+ var terser = require('@rollup/plugin-terser');
12
+ var execa = require('execa');
13
+ var jsoncParser = require('jsonc-parser');
14
+ var require$$0 = require('util');
15
+ var require$$0$1 = require('path');
16
+ var esbuild = require('rollup-plugin-esbuild');
17
+ var ts = require('typescript');
18
+ var commander = require('commander');
19
+ var jsYaml = require('js-yaml');
20
+ var node_module = require('node:module');
21
+ require('@pnpm/filter-workspace-packages');
22
+
23
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
24
+ var utils$1 = {};
25
+
26
+ var hasRequiredUtils$1;
27
+
28
+ function requireUtils$1 () {
29
+ if (hasRequiredUtils$1) return utils$1;
30
+ hasRequiredUtils$1 = 1;
31
+ (function (exports) {
32
+
33
+ exports.isInteger = num => {
34
+ if (typeof num === 'number') {
35
+ return Number.isInteger(num);
36
+ }
37
+ if (typeof num === 'string' && num.trim() !== '') {
38
+ return Number.isInteger(Number(num));
39
+ }
40
+ return false;
41
+ };
42
+
43
+ /**
44
+ * Find a node of the given type
45
+ */
46
+
47
+ exports.find = (node, type) => node.nodes.find(node => node.type === type);
48
+
49
+ /**
50
+ * Find a node of the given type
51
+ */
52
+
53
+ exports.exceedsLimit = (min, max, step = 1, limit) => {
54
+ if (limit === false) return false;
55
+ if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
56
+ return ((Number(max) - Number(min)) / Number(step)) >= limit;
57
+ };
58
+
59
+ /**
60
+ * Escape the given node with '\\' before node.value
61
+ */
62
+
63
+ exports.escapeNode = (block, n = 0, type) => {
64
+ let node = block.nodes[n];
65
+ if (!node) return;
66
+
67
+ if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
68
+ if (node.escaped !== true) {
69
+ node.value = '\\' + node.value;
70
+ node.escaped = true;
71
+ }
72
+ }
73
+ };
74
+
75
+ /**
76
+ * Returns true if the given brace node should be enclosed in literal braces
77
+ */
78
+
79
+ exports.encloseBrace = node => {
80
+ if (node.type !== 'brace') return false;
81
+ if ((node.commas >> 0 + node.ranges >> 0) === 0) {
82
+ node.invalid = true;
83
+ return true;
84
+ }
85
+ return false;
86
+ };
87
+
88
+ /**
89
+ * Returns true if a brace node is invalid.
90
+ */
91
+
92
+ exports.isInvalidBrace = block => {
93
+ if (block.type !== 'brace') return false;
94
+ if (block.invalid === true || block.dollar) return true;
95
+ if ((block.commas >> 0 + block.ranges >> 0) === 0) {
96
+ block.invalid = true;
97
+ return true;
98
+ }
99
+ if (block.open !== true || block.close !== true) {
100
+ block.invalid = true;
101
+ return true;
102
+ }
103
+ return false;
104
+ };
105
+
106
+ /**
107
+ * Returns true if a node is an open or close node
108
+ */
109
+
110
+ exports.isOpenOrClose = node => {
111
+ if (node.type === 'open' || node.type === 'close') {
112
+ return true;
113
+ }
114
+ return node.open === true || node.close === true;
115
+ };
116
+
117
+ /**
118
+ * Reduce an array of text nodes.
119
+ */
120
+
121
+ exports.reduce = nodes => nodes.reduce((acc, node) => {
122
+ if (node.type === 'text') acc.push(node.value);
123
+ if (node.type === 'range') node.type = 'text';
124
+ return acc;
125
+ }, []);
126
+
127
+ /**
128
+ * Flatten an array
129
+ */
130
+
131
+ exports.flatten = (...args) => {
132
+ const result = [];
133
+ const flat = arr => {
134
+ for (let i = 0; i < arr.length; i++) {
135
+ let ele = arr[i];
136
+ Array.isArray(ele) ? flat(ele) : ele !== void 0 && result.push(ele);
137
+ }
138
+ return result;
139
+ };
140
+ flat(args);
141
+ return result;
142
+ };
143
+ } (utils$1));
144
+ return utils$1;
145
+ }
146
+
147
+ var stringify;
148
+ var hasRequiredStringify;
149
+
150
+ function requireStringify () {
151
+ if (hasRequiredStringify) return stringify;
152
+ hasRequiredStringify = 1;
153
+
154
+ const utils = requireUtils$1();
155
+
156
+ stringify = (ast, options = {}) => {
157
+ let stringify = (node, parent = {}) => {
158
+ let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
159
+ let invalidNode = node.invalid === true && options.escapeInvalid === true;
160
+ let output = '';
161
+
162
+ if (node.value) {
163
+ if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) {
164
+ return '\\' + node.value;
165
+ }
166
+ return node.value;
167
+ }
168
+
169
+ if (node.value) {
170
+ return node.value;
171
+ }
172
+
173
+ if (node.nodes) {
174
+ for (let child of node.nodes) {
175
+ output += stringify(child);
176
+ }
177
+ }
178
+ return output;
179
+ };
180
+
181
+ return stringify(ast);
182
+ };
183
+ return stringify;
184
+ }
185
+
186
+ /*!
187
+ * is-number <https://github.com/jonschlinkert/is-number>
188
+ *
189
+ * Copyright (c) 2014-present, Jon Schlinkert.
190
+ * Released under the MIT License.
191
+ */
192
+
193
+ var isNumber;
194
+ var hasRequiredIsNumber;
195
+
196
+ function requireIsNumber () {
197
+ if (hasRequiredIsNumber) return isNumber;
198
+ hasRequiredIsNumber = 1;
199
+
200
+ isNumber = function(num) {
201
+ if (typeof num === 'number') {
202
+ return num - num === 0;
203
+ }
204
+ if (typeof num === 'string' && num.trim() !== '') {
205
+ return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
206
+ }
207
+ return false;
208
+ };
209
+ return isNumber;
210
+ }
211
+
212
+ /*!
213
+ * to-regex-range <https://github.com/micromatch/to-regex-range>
214
+ *
215
+ * Copyright (c) 2015-present, Jon Schlinkert.
216
+ * Released under the MIT License.
217
+ */
218
+
219
+ var toRegexRange_1;
220
+ var hasRequiredToRegexRange;
221
+
222
+ function requireToRegexRange () {
223
+ if (hasRequiredToRegexRange) return toRegexRange_1;
224
+ hasRequiredToRegexRange = 1;
225
+
226
+ const isNumber = requireIsNumber();
227
+
228
+ const toRegexRange = (min, max, options) => {
229
+ if (isNumber(min) === false) {
230
+ throw new TypeError('toRegexRange: expected the first argument to be a number');
231
+ }
232
+
233
+ if (max === void 0 || min === max) {
234
+ return String(min);
235
+ }
236
+
237
+ if (isNumber(max) === false) {
238
+ throw new TypeError('toRegexRange: expected the second argument to be a number.');
239
+ }
240
+
241
+ let opts = { relaxZeros: true, ...options };
242
+ if (typeof opts.strictZeros === 'boolean') {
243
+ opts.relaxZeros = opts.strictZeros === false;
244
+ }
245
+
246
+ let relax = String(opts.relaxZeros);
247
+ let shorthand = String(opts.shorthand);
248
+ let capture = String(opts.capture);
249
+ let wrap = String(opts.wrap);
250
+ let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap;
251
+
252
+ if (toRegexRange.cache.hasOwnProperty(cacheKey)) {
253
+ return toRegexRange.cache[cacheKey].result;
254
+ }
255
+
256
+ let a = Math.min(min, max);
257
+ let b = Math.max(min, max);
258
+
259
+ if (Math.abs(a - b) === 1) {
260
+ let result = min + '|' + max;
261
+ if (opts.capture) {
262
+ return `(${result})`;
263
+ }
264
+ if (opts.wrap === false) {
265
+ return result;
266
+ }
267
+ return `(?:${result})`;
268
+ }
269
+
270
+ let isPadded = hasPadding(min) || hasPadding(max);
271
+ let state = { min, max, a, b };
272
+ let positives = [];
273
+ let negatives = [];
274
+
275
+ if (isPadded) {
276
+ state.isPadded = isPadded;
277
+ state.maxLen = String(state.max).length;
278
+ }
279
+
280
+ if (a < 0) {
281
+ let newMin = b < 0 ? Math.abs(b) : 1;
282
+ negatives = splitToPatterns(newMin, Math.abs(a), state, opts);
283
+ a = state.a = 0;
284
+ }
285
+
286
+ if (b >= 0) {
287
+ positives = splitToPatterns(a, b, state, opts);
288
+ }
289
+
290
+ state.negatives = negatives;
291
+ state.positives = positives;
292
+ state.result = collatePatterns(negatives, positives);
293
+
294
+ if (opts.capture === true) {
295
+ state.result = `(${state.result})`;
296
+ } else if (opts.wrap !== false && (positives.length + negatives.length) > 1) {
297
+ state.result = `(?:${state.result})`;
298
+ }
299
+
300
+ toRegexRange.cache[cacheKey] = state;
301
+ return state.result;
302
+ };
303
+
304
+ function collatePatterns(neg, pos, options) {
305
+ let onlyNegative = filterPatterns(neg, pos, '-', false) || [];
306
+ let onlyPositive = filterPatterns(pos, neg, '', false) || [];
307
+ let intersected = filterPatterns(neg, pos, '-?', true) || [];
308
+ let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive);
309
+ return subpatterns.join('|');
310
+ }
311
+
312
+ function splitToRanges(min, max) {
313
+ let nines = 1;
314
+ let zeros = 1;
315
+
316
+ let stop = countNines(min, nines);
317
+ let stops = new Set([max]);
318
+
319
+ while (min <= stop && stop <= max) {
320
+ stops.add(stop);
321
+ nines += 1;
322
+ stop = countNines(min, nines);
323
+ }
324
+
325
+ stop = countZeros(max + 1, zeros) - 1;
326
+
327
+ while (min < stop && stop <= max) {
328
+ stops.add(stop);
329
+ zeros += 1;
330
+ stop = countZeros(max + 1, zeros) - 1;
331
+ }
332
+
333
+ stops = [...stops];
334
+ stops.sort(compare);
335
+ return stops;
336
+ }
337
+
338
+ /**
339
+ * Convert a range to a regex pattern
340
+ * @param {Number} `start`
341
+ * @param {Number} `stop`
342
+ * @return {String}
343
+ */
344
+
345
+ function rangeToPattern(start, stop, options) {
346
+ if (start === stop) {
347
+ return { pattern: start, count: [], digits: 0 };
348
+ }
349
+
350
+ let zipped = zip(start, stop);
351
+ let digits = zipped.length;
352
+ let pattern = '';
353
+ let count = 0;
354
+
355
+ for (let i = 0; i < digits; i++) {
356
+ let [startDigit, stopDigit] = zipped[i];
357
+
358
+ if (startDigit === stopDigit) {
359
+ pattern += startDigit;
360
+
361
+ } else if (startDigit !== '0' || stopDigit !== '9') {
362
+ pattern += toCharacterClass(startDigit, stopDigit);
363
+
364
+ } else {
365
+ count++;
366
+ }
367
+ }
368
+
369
+ if (count) {
370
+ pattern += options.shorthand === true ? '\\d' : '[0-9]';
371
+ }
372
+
373
+ return { pattern, count: [count], digits };
374
+ }
375
+
376
+ function splitToPatterns(min, max, tok, options) {
377
+ let ranges = splitToRanges(min, max);
378
+ let tokens = [];
379
+ let start = min;
380
+ let prev;
381
+
382
+ for (let i = 0; i < ranges.length; i++) {
383
+ let max = ranges[i];
384
+ let obj = rangeToPattern(String(start), String(max), options);
385
+ let zeros = '';
386
+
387
+ if (!tok.isPadded && prev && prev.pattern === obj.pattern) {
388
+ if (prev.count.length > 1) {
389
+ prev.count.pop();
390
+ }
391
+
392
+ prev.count.push(obj.count[0]);
393
+ prev.string = prev.pattern + toQuantifier(prev.count);
394
+ start = max + 1;
395
+ continue;
396
+ }
397
+
398
+ if (tok.isPadded) {
399
+ zeros = padZeros(max, tok, options);
400
+ }
401
+
402
+ obj.string = zeros + obj.pattern + toQuantifier(obj.count);
403
+ tokens.push(obj);
404
+ start = max + 1;
405
+ prev = obj;
406
+ }
407
+
408
+ return tokens;
409
+ }
410
+
411
+ function filterPatterns(arr, comparison, prefix, intersection, options) {
412
+ let result = [];
413
+
414
+ for (let ele of arr) {
415
+ let { string } = ele;
416
+
417
+ // only push if _both_ are negative...
418
+ if (!intersection && !contains(comparison, 'string', string)) {
419
+ result.push(prefix + string);
420
+ }
421
+
422
+ // or _both_ are positive
423
+ if (intersection && contains(comparison, 'string', string)) {
424
+ result.push(prefix + string);
425
+ }
426
+ }
427
+ return result;
428
+ }
429
+
430
+ /**
431
+ * Zip strings
432
+ */
433
+
434
+ function zip(a, b) {
435
+ let arr = [];
436
+ for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]);
437
+ return arr;
438
+ }
439
+
440
+ function compare(a, b) {
441
+ return a > b ? 1 : b > a ? -1 : 0;
442
+ }
443
+
444
+ function contains(arr, key, val) {
445
+ return arr.some(ele => ele[key] === val);
446
+ }
447
+
448
+ function countNines(min, len) {
449
+ return Number(String(min).slice(0, -len) + '9'.repeat(len));
450
+ }
451
+
452
+ function countZeros(integer, zeros) {
453
+ return integer - (integer % Math.pow(10, zeros));
454
+ }
455
+
456
+ function toQuantifier(digits) {
457
+ let [start = 0, stop = ''] = digits;
458
+ if (stop || start > 1) {
459
+ return `{${start + (stop ? ',' + stop : '')}}`;
460
+ }
461
+ return '';
462
+ }
463
+
464
+ function toCharacterClass(a, b, options) {
465
+ return `[${a}${(b - a === 1) ? '' : '-'}${b}]`;
466
+ }
467
+
468
+ function hasPadding(str) {
469
+ return /^-?(0+)\d/.test(str);
470
+ }
471
+
472
+ function padZeros(value, tok, options) {
473
+ if (!tok.isPadded) {
474
+ return value;
475
+ }
476
+
477
+ let diff = Math.abs(tok.maxLen - String(value).length);
478
+ let relax = options.relaxZeros !== false;
479
+
480
+ switch (diff) {
481
+ case 0:
482
+ return '';
483
+ case 1:
484
+ return relax ? '0?' : '0';
485
+ case 2:
486
+ return relax ? '0{0,2}' : '00';
487
+ default: {
488
+ return relax ? `0{0,${diff}}` : `0{${diff}}`;
489
+ }
490
+ }
491
+ }
492
+
493
+ /**
494
+ * Cache
495
+ */
496
+
497
+ toRegexRange.cache = {};
498
+ toRegexRange.clearCache = () => (toRegexRange.cache = {});
499
+
500
+ /**
501
+ * Expose `toRegexRange`
502
+ */
503
+
504
+ toRegexRange_1 = toRegexRange;
505
+ return toRegexRange_1;
506
+ }
507
+
508
+ /*!
509
+ * fill-range <https://github.com/jonschlinkert/fill-range>
510
+ *
511
+ * Copyright (c) 2014-present, Jon Schlinkert.
512
+ * Licensed under the MIT License.
513
+ */
514
+
515
+ var fillRange;
516
+ var hasRequiredFillRange;
517
+
518
+ function requireFillRange () {
519
+ if (hasRequiredFillRange) return fillRange;
520
+ hasRequiredFillRange = 1;
521
+
522
+ const util = require$$0;
523
+ const toRegexRange = requireToRegexRange();
524
+
525
+ const isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
526
+
527
+ const transform = toNumber => {
528
+ return value => toNumber === true ? Number(value) : String(value);
529
+ };
530
+
531
+ const isValidValue = value => {
532
+ return typeof value === 'number' || (typeof value === 'string' && value !== '');
533
+ };
534
+
535
+ const isNumber = num => Number.isInteger(+num);
536
+
537
+ const zeros = input => {
538
+ let value = `${input}`;
539
+ let index = -1;
540
+ if (value[0] === '-') value = value.slice(1);
541
+ if (value === '0') return false;
542
+ while (value[++index] === '0');
543
+ return index > 0;
544
+ };
545
+
546
+ const stringify = (start, end, options) => {
547
+ if (typeof start === 'string' || typeof end === 'string') {
548
+ return true;
549
+ }
550
+ return options.stringify === true;
551
+ };
552
+
553
+ const pad = (input, maxLength, toNumber) => {
554
+ if (maxLength > 0) {
555
+ let dash = input[0] === '-' ? '-' : '';
556
+ if (dash) input = input.slice(1);
557
+ input = (dash + input.padStart(dash ? maxLength - 1 : maxLength, '0'));
558
+ }
559
+ if (toNumber === false) {
560
+ return String(input);
561
+ }
562
+ return input;
563
+ };
564
+
565
+ const toMaxLen = (input, maxLength) => {
566
+ let negative = input[0] === '-' ? '-' : '';
567
+ if (negative) {
568
+ input = input.slice(1);
569
+ maxLength--;
570
+ }
571
+ while (input.length < maxLength) input = '0' + input;
572
+ return negative ? ('-' + input) : input;
573
+ };
574
+
575
+ const toSequence = (parts, options) => {
576
+ parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
577
+ parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
578
+
579
+ let prefix = options.capture ? '' : '?:';
580
+ let positives = '';
581
+ let negatives = '';
582
+ let result;
583
+
584
+ if (parts.positives.length) {
585
+ positives = parts.positives.join('|');
586
+ }
587
+
588
+ if (parts.negatives.length) {
589
+ negatives = `-(${prefix}${parts.negatives.join('|')})`;
590
+ }
591
+
592
+ if (positives && negatives) {
593
+ result = `${positives}|${negatives}`;
594
+ } else {
595
+ result = positives || negatives;
596
+ }
597
+
598
+ if (options.wrap) {
599
+ return `(${prefix}${result})`;
600
+ }
601
+
602
+ return result;
603
+ };
604
+
605
+ const toRange = (a, b, isNumbers, options) => {
606
+ if (isNumbers) {
607
+ return toRegexRange(a, b, { wrap: false, ...options });
608
+ }
609
+
610
+ let start = String.fromCharCode(a);
611
+ if (a === b) return start;
612
+
613
+ let stop = String.fromCharCode(b);
614
+ return `[${start}-${stop}]`;
615
+ };
616
+
617
+ const toRegex = (start, end, options) => {
618
+ if (Array.isArray(start)) {
619
+ let wrap = options.wrap === true;
620
+ let prefix = options.capture ? '' : '?:';
621
+ return wrap ? `(${prefix}${start.join('|')})` : start.join('|');
622
+ }
623
+ return toRegexRange(start, end, options);
624
+ };
625
+
626
+ const rangeError = (...args) => {
627
+ return new RangeError('Invalid range arguments: ' + util.inspect(...args));
628
+ };
629
+
630
+ const invalidRange = (start, end, options) => {
631
+ if (options.strictRanges === true) throw rangeError([start, end]);
632
+ return [];
633
+ };
634
+
635
+ const invalidStep = (step, options) => {
636
+ if (options.strictRanges === true) {
637
+ throw new TypeError(`Expected step "${step}" to be a number`);
638
+ }
639
+ return [];
640
+ };
641
+
642
+ const fillNumbers = (start, end, step = 1, options = {}) => {
643
+ let a = Number(start);
644
+ let b = Number(end);
645
+
646
+ if (!Number.isInteger(a) || !Number.isInteger(b)) {
647
+ if (options.strictRanges === true) throw rangeError([start, end]);
648
+ return [];
649
+ }
650
+
651
+ // fix negative zero
652
+ if (a === 0) a = 0;
653
+ if (b === 0) b = 0;
654
+
655
+ let descending = a > b;
656
+ let startString = String(start);
657
+ let endString = String(end);
658
+ let stepString = String(step);
659
+ step = Math.max(Math.abs(step), 1);
660
+
661
+ let padded = zeros(startString) || zeros(endString) || zeros(stepString);
662
+ let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
663
+ let toNumber = padded === false && stringify(start, end, options) === false;
664
+ let format = options.transform || transform(toNumber);
665
+
666
+ if (options.toRegex && step === 1) {
667
+ return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
668
+ }
669
+
670
+ let parts = { negatives: [], positives: [] };
671
+ let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num));
672
+ let range = [];
673
+ let index = 0;
674
+
675
+ while (descending ? a >= b : a <= b) {
676
+ if (options.toRegex === true && step > 1) {
677
+ push(a);
678
+ } else {
679
+ range.push(pad(format(a, index), maxLen, toNumber));
680
+ }
681
+ a = descending ? a - step : a + step;
682
+ index++;
683
+ }
684
+
685
+ if (options.toRegex === true) {
686
+ return step > 1
687
+ ? toSequence(parts, options)
688
+ : toRegex(range, null, { wrap: false, ...options });
689
+ }
690
+
691
+ return range;
692
+ };
693
+
694
+ const fillLetters = (start, end, step = 1, options = {}) => {
695
+ if ((!isNumber(start) && start.length > 1) || (!isNumber(end) && end.length > 1)) {
696
+ return invalidRange(start, end, options);
697
+ }
698
+
699
+
700
+ let format = options.transform || (val => String.fromCharCode(val));
701
+ let a = `${start}`.charCodeAt(0);
702
+ let b = `${end}`.charCodeAt(0);
703
+
704
+ let descending = a > b;
705
+ let min = Math.min(a, b);
706
+ let max = Math.max(a, b);
707
+
708
+ if (options.toRegex && step === 1) {
709
+ return toRange(min, max, false, options);
710
+ }
711
+
712
+ let range = [];
713
+ let index = 0;
714
+
715
+ while (descending ? a >= b : a <= b) {
716
+ range.push(format(a, index));
717
+ a = descending ? a - step : a + step;
718
+ index++;
719
+ }
720
+
721
+ if (options.toRegex === true) {
722
+ return toRegex(range, null, { wrap: false, options });
723
+ }
724
+
725
+ return range;
726
+ };
727
+
728
+ const fill = (start, end, step, options = {}) => {
729
+ if (end == null && isValidValue(start)) {
730
+ return [start];
731
+ }
732
+
733
+ if (!isValidValue(start) || !isValidValue(end)) {
734
+ return invalidRange(start, end, options);
735
+ }
736
+
737
+ if (typeof step === 'function') {
738
+ return fill(start, end, 1, { transform: step });
739
+ }
740
+
741
+ if (isObject(step)) {
742
+ return fill(start, end, 0, step);
743
+ }
744
+
745
+ let opts = { ...options };
746
+ if (opts.capture === true) opts.wrap = true;
747
+ step = step || opts.step || 1;
748
+
749
+ if (!isNumber(step)) {
750
+ if (step != null && !isObject(step)) return invalidStep(step, opts);
751
+ return fill(start, end, 1, step);
752
+ }
753
+
754
+ if (isNumber(start) && isNumber(end)) {
755
+ return fillNumbers(start, end, step, opts);
756
+ }
757
+
758
+ return fillLetters(start, end, Math.max(Math.abs(step), 1), opts);
759
+ };
760
+
761
+ fillRange = fill;
762
+ return fillRange;
763
+ }
764
+
765
+ var compile_1;
766
+ var hasRequiredCompile;
767
+
768
+ function requireCompile () {
769
+ if (hasRequiredCompile) return compile_1;
770
+ hasRequiredCompile = 1;
771
+
772
+ const fill = requireFillRange();
773
+ const utils = requireUtils$1();
774
+
775
+ const compile = (ast, options = {}) => {
776
+ let walk = (node, parent = {}) => {
777
+ let invalidBlock = utils.isInvalidBrace(parent);
778
+ let invalidNode = node.invalid === true && options.escapeInvalid === true;
779
+ let invalid = invalidBlock === true || invalidNode === true;
780
+ let prefix = options.escapeInvalid === true ? '\\' : '';
781
+ let output = '';
782
+
783
+ if (node.isOpen === true) {
784
+ return prefix + node.value;
785
+ }
786
+ if (node.isClose === true) {
787
+ return prefix + node.value;
788
+ }
789
+
790
+ if (node.type === 'open') {
791
+ return invalid ? (prefix + node.value) : '(';
792
+ }
793
+
794
+ if (node.type === 'close') {
795
+ return invalid ? (prefix + node.value) : ')';
796
+ }
797
+
798
+ if (node.type === 'comma') {
799
+ return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|');
800
+ }
801
+
802
+ if (node.value) {
803
+ return node.value;
804
+ }
805
+
806
+ if (node.nodes && node.ranges > 0) {
807
+ let args = utils.reduce(node.nodes);
808
+ let range = fill(...args, { ...options, wrap: false, toRegex: true });
809
+
810
+ if (range.length !== 0) {
811
+ return args.length > 1 && range.length > 1 ? `(${range})` : range;
812
+ }
813
+ }
814
+
815
+ if (node.nodes) {
816
+ for (let child of node.nodes) {
817
+ output += walk(child, node);
818
+ }
819
+ }
820
+ return output;
821
+ };
822
+
823
+ return walk(ast);
824
+ };
825
+
826
+ compile_1 = compile;
827
+ return compile_1;
828
+ }
829
+
830
+ var expand_1;
831
+ var hasRequiredExpand;
832
+
833
+ function requireExpand () {
834
+ if (hasRequiredExpand) return expand_1;
835
+ hasRequiredExpand = 1;
836
+
837
+ const fill = requireFillRange();
838
+ const stringify = requireStringify();
839
+ const utils = requireUtils$1();
840
+
841
+ const append = (queue = '', stash = '', enclose = false) => {
842
+ let result = [];
843
+
844
+ queue = [].concat(queue);
845
+ stash = [].concat(stash);
846
+
847
+ if (!stash.length) return queue;
848
+ if (!queue.length) {
849
+ return enclose ? utils.flatten(stash).map(ele => `{${ele}}`) : stash;
850
+ }
851
+
852
+ for (let item of queue) {
853
+ if (Array.isArray(item)) {
854
+ for (let value of item) {
855
+ result.push(append(value, stash, enclose));
856
+ }
857
+ } else {
858
+ for (let ele of stash) {
859
+ if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
860
+ result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele));
861
+ }
862
+ }
863
+ }
864
+ return utils.flatten(result);
865
+ };
866
+
867
+ const expand = (ast, options = {}) => {
868
+ let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
869
+
870
+ let walk = (node, parent = {}) => {
871
+ node.queue = [];
872
+
873
+ let p = parent;
874
+ let q = parent.queue;
875
+
876
+ while (p.type !== 'brace' && p.type !== 'root' && p.parent) {
877
+ p = p.parent;
878
+ q = p.queue;
879
+ }
880
+
881
+ if (node.invalid || node.dollar) {
882
+ q.push(append(q.pop(), stringify(node, options)));
883
+ return;
884
+ }
885
+
886
+ if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) {
887
+ q.push(append(q.pop(), ['{}']));
888
+ return;
889
+ }
890
+
891
+ if (node.nodes && node.ranges > 0) {
892
+ let args = utils.reduce(node.nodes);
893
+
894
+ if (utils.exceedsLimit(...args, options.step, rangeLimit)) {
895
+ throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
896
+ }
897
+
898
+ let range = fill(...args, options);
899
+ if (range.length === 0) {
900
+ range = stringify(node, options);
901
+ }
902
+
903
+ q.push(append(q.pop(), range));
904
+ node.nodes = [];
905
+ return;
906
+ }
907
+
908
+ let enclose = utils.encloseBrace(node);
909
+ let queue = node.queue;
910
+ let block = node;
911
+
912
+ while (block.type !== 'brace' && block.type !== 'root' && block.parent) {
913
+ block = block.parent;
914
+ queue = block.queue;
915
+ }
916
+
917
+ for (let i = 0; i < node.nodes.length; i++) {
918
+ let child = node.nodes[i];
919
+
920
+ if (child.type === 'comma' && node.type === 'brace') {
921
+ if (i === 1) queue.push('');
922
+ queue.push('');
923
+ continue;
924
+ }
925
+
926
+ if (child.type === 'close') {
927
+ q.push(append(q.pop(), queue, enclose));
928
+ continue;
929
+ }
930
+
931
+ if (child.value && child.type !== 'open') {
932
+ queue.push(append(queue.pop(), child.value));
933
+ continue;
934
+ }
935
+
936
+ if (child.nodes) {
937
+ walk(child, node);
938
+ }
939
+ }
940
+
941
+ return queue;
942
+ };
943
+
944
+ return utils.flatten(walk(ast));
945
+ };
946
+
947
+ expand_1 = expand;
948
+ return expand_1;
949
+ }
950
+
951
+ var constants$1;
952
+ var hasRequiredConstants$1;
953
+
954
+ function requireConstants$1 () {
955
+ if (hasRequiredConstants$1) return constants$1;
956
+ hasRequiredConstants$1 = 1;
957
+
958
+ constants$1 = {
959
+ MAX_LENGTH: 1024 * 64,
960
+
961
+ // Digits
962
+ CHAR_0: '0', /* 0 */
963
+ CHAR_9: '9', /* 9 */
964
+
965
+ // Alphabet chars.
966
+ CHAR_UPPERCASE_A: 'A', /* A */
967
+ CHAR_LOWERCASE_A: 'a', /* a */
968
+ CHAR_UPPERCASE_Z: 'Z', /* Z */
969
+ CHAR_LOWERCASE_Z: 'z', /* z */
970
+
971
+ CHAR_LEFT_PARENTHESES: '(', /* ( */
972
+ CHAR_RIGHT_PARENTHESES: ')', /* ) */
973
+
974
+ CHAR_ASTERISK: '*', /* * */
975
+
976
+ // Non-alphabetic chars.
977
+ CHAR_AMPERSAND: '&', /* & */
978
+ CHAR_AT: '@', /* @ */
979
+ CHAR_BACKSLASH: '\\', /* \ */
980
+ CHAR_BACKTICK: '`', /* ` */
981
+ CHAR_CARRIAGE_RETURN: '\r', /* \r */
982
+ CHAR_CIRCUMFLEX_ACCENT: '^', /* ^ */
983
+ CHAR_COLON: ':', /* : */
984
+ CHAR_COMMA: ',', /* , */
985
+ CHAR_DOLLAR: '$', /* . */
986
+ CHAR_DOT: '.', /* . */
987
+ CHAR_DOUBLE_QUOTE: '"', /* " */
988
+ CHAR_EQUAL: '=', /* = */
989
+ CHAR_EXCLAMATION_MARK: '!', /* ! */
990
+ CHAR_FORM_FEED: '\f', /* \f */
991
+ CHAR_FORWARD_SLASH: '/', /* / */
992
+ CHAR_HASH: '#', /* # */
993
+ CHAR_HYPHEN_MINUS: '-', /* - */
994
+ CHAR_LEFT_ANGLE_BRACKET: '<', /* < */
995
+ CHAR_LEFT_CURLY_BRACE: '{', /* { */
996
+ CHAR_LEFT_SQUARE_BRACKET: '[', /* [ */
997
+ CHAR_LINE_FEED: '\n', /* \n */
998
+ CHAR_NO_BREAK_SPACE: '\u00A0', /* \u00A0 */
999
+ CHAR_PERCENT: '%', /* % */
1000
+ CHAR_PLUS: '+', /* + */
1001
+ CHAR_QUESTION_MARK: '?', /* ? */
1002
+ CHAR_RIGHT_ANGLE_BRACKET: '>', /* > */
1003
+ CHAR_RIGHT_CURLY_BRACE: '}', /* } */
1004
+ CHAR_RIGHT_SQUARE_BRACKET: ']', /* ] */
1005
+ CHAR_SEMICOLON: ';', /* ; */
1006
+ CHAR_SINGLE_QUOTE: '\'', /* ' */
1007
+ CHAR_SPACE: ' ', /* */
1008
+ CHAR_TAB: '\t', /* \t */
1009
+ CHAR_UNDERSCORE: '_', /* _ */
1010
+ CHAR_VERTICAL_LINE: '|', /* | */
1011
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF' /* \uFEFF */
1012
+ };
1013
+ return constants$1;
1014
+ }
1015
+
1016
+ var parse_1$1;
1017
+ var hasRequiredParse$1;
1018
+
1019
+ function requireParse$1 () {
1020
+ if (hasRequiredParse$1) return parse_1$1;
1021
+ hasRequiredParse$1 = 1;
1022
+
1023
+ const stringify = requireStringify();
1024
+
1025
+ /**
1026
+ * Constants
1027
+ */
1028
+
1029
+ const {
1030
+ MAX_LENGTH,
1031
+ CHAR_BACKSLASH, /* \ */
1032
+ CHAR_BACKTICK, /* ` */
1033
+ CHAR_COMMA, /* , */
1034
+ CHAR_DOT, /* . */
1035
+ CHAR_LEFT_PARENTHESES, /* ( */
1036
+ CHAR_RIGHT_PARENTHESES, /* ) */
1037
+ CHAR_LEFT_CURLY_BRACE, /* { */
1038
+ CHAR_RIGHT_CURLY_BRACE, /* } */
1039
+ CHAR_LEFT_SQUARE_BRACKET, /* [ */
1040
+ CHAR_RIGHT_SQUARE_BRACKET, /* ] */
1041
+ CHAR_DOUBLE_QUOTE, /* " */
1042
+ CHAR_SINGLE_QUOTE, /* ' */
1043
+ CHAR_NO_BREAK_SPACE,
1044
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE
1045
+ } = requireConstants$1();
1046
+
1047
+ /**
1048
+ * parse
1049
+ */
1050
+
1051
+ const parse = (input, options = {}) => {
1052
+ if (typeof input !== 'string') {
1053
+ throw new TypeError('Expected a string');
1054
+ }
1055
+
1056
+ let opts = options || {};
1057
+ let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1058
+ if (input.length > max) {
1059
+ throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
1060
+ }
1061
+
1062
+ let ast = { type: 'root', input, nodes: [] };
1063
+ let stack = [ast];
1064
+ let block = ast;
1065
+ let prev = ast;
1066
+ let brackets = 0;
1067
+ let length = input.length;
1068
+ let index = 0;
1069
+ let depth = 0;
1070
+ let value;
1071
+
1072
+ /**
1073
+ * Helpers
1074
+ */
1075
+
1076
+ const advance = () => input[index++];
1077
+ const push = node => {
1078
+ if (node.type === 'text' && prev.type === 'dot') {
1079
+ prev.type = 'text';
1080
+ }
1081
+
1082
+ if (prev && prev.type === 'text' && node.type === 'text') {
1083
+ prev.value += node.value;
1084
+ return;
1085
+ }
1086
+
1087
+ block.nodes.push(node);
1088
+ node.parent = block;
1089
+ node.prev = prev;
1090
+ prev = node;
1091
+ return node;
1092
+ };
1093
+
1094
+ push({ type: 'bos' });
1095
+
1096
+ while (index < length) {
1097
+ block = stack[stack.length - 1];
1098
+ value = advance();
1099
+
1100
+ /**
1101
+ * Invalid chars
1102
+ */
1103
+
1104
+ if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) {
1105
+ continue;
1106
+ }
1107
+
1108
+ /**
1109
+ * Escaped chars
1110
+ */
1111
+
1112
+ if (value === CHAR_BACKSLASH) {
1113
+ push({ type: 'text', value: (options.keepEscaping ? value : '') + advance() });
1114
+ continue;
1115
+ }
1116
+
1117
+ /**
1118
+ * Right square bracket (literal): ']'
1119
+ */
1120
+
1121
+ if (value === CHAR_RIGHT_SQUARE_BRACKET) {
1122
+ push({ type: 'text', value: '\\' + value });
1123
+ continue;
1124
+ }
1125
+
1126
+ /**
1127
+ * Left square bracket: '['
1128
+ */
1129
+
1130
+ if (value === CHAR_LEFT_SQUARE_BRACKET) {
1131
+ brackets++;
1132
+ let next;
1133
+
1134
+ while (index < length && (next = advance())) {
1135
+ value += next;
1136
+
1137
+ if (next === CHAR_LEFT_SQUARE_BRACKET) {
1138
+ brackets++;
1139
+ continue;
1140
+ }
1141
+
1142
+ if (next === CHAR_BACKSLASH) {
1143
+ value += advance();
1144
+ continue;
1145
+ }
1146
+
1147
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
1148
+ brackets--;
1149
+
1150
+ if (brackets === 0) {
1151
+ break;
1152
+ }
1153
+ }
1154
+ }
1155
+
1156
+ push({ type: 'text', value });
1157
+ continue;
1158
+ }
1159
+
1160
+ /**
1161
+ * Parentheses
1162
+ */
1163
+
1164
+ if (value === CHAR_LEFT_PARENTHESES) {
1165
+ block = push({ type: 'paren', nodes: [] });
1166
+ stack.push(block);
1167
+ push({ type: 'text', value });
1168
+ continue;
1169
+ }
1170
+
1171
+ if (value === CHAR_RIGHT_PARENTHESES) {
1172
+ if (block.type !== 'paren') {
1173
+ push({ type: 'text', value });
1174
+ continue;
1175
+ }
1176
+ block = stack.pop();
1177
+ push({ type: 'text', value });
1178
+ block = stack[stack.length - 1];
1179
+ continue;
1180
+ }
1181
+
1182
+ /**
1183
+ * Quotes: '|"|`
1184
+ */
1185
+
1186
+ if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
1187
+ let open = value;
1188
+ let next;
1189
+
1190
+ if (options.keepQuotes !== true) {
1191
+ value = '';
1192
+ }
1193
+
1194
+ while (index < length && (next = advance())) {
1195
+ if (next === CHAR_BACKSLASH) {
1196
+ value += next + advance();
1197
+ continue;
1198
+ }
1199
+
1200
+ if (next === open) {
1201
+ if (options.keepQuotes === true) value += next;
1202
+ break;
1203
+ }
1204
+
1205
+ value += next;
1206
+ }
1207
+
1208
+ push({ type: 'text', value });
1209
+ continue;
1210
+ }
1211
+
1212
+ /**
1213
+ * Left curly brace: '{'
1214
+ */
1215
+
1216
+ if (value === CHAR_LEFT_CURLY_BRACE) {
1217
+ depth++;
1218
+
1219
+ let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
1220
+ let brace = {
1221
+ type: 'brace',
1222
+ open: true,
1223
+ close: false,
1224
+ dollar,
1225
+ depth,
1226
+ commas: 0,
1227
+ ranges: 0,
1228
+ nodes: []
1229
+ };
1230
+
1231
+ block = push(brace);
1232
+ stack.push(block);
1233
+ push({ type: 'open', value });
1234
+ continue;
1235
+ }
1236
+
1237
+ /**
1238
+ * Right curly brace: '}'
1239
+ */
1240
+
1241
+ if (value === CHAR_RIGHT_CURLY_BRACE) {
1242
+ if (block.type !== 'brace') {
1243
+ push({ type: 'text', value });
1244
+ continue;
1245
+ }
1246
+
1247
+ let type = 'close';
1248
+ block = stack.pop();
1249
+ block.close = true;
1250
+
1251
+ push({ type, value });
1252
+ depth--;
1253
+
1254
+ block = stack[stack.length - 1];
1255
+ continue;
1256
+ }
1257
+
1258
+ /**
1259
+ * Comma: ','
1260
+ */
1261
+
1262
+ if (value === CHAR_COMMA && depth > 0) {
1263
+ if (block.ranges > 0) {
1264
+ block.ranges = 0;
1265
+ let open = block.nodes.shift();
1266
+ block.nodes = [open, { type: 'text', value: stringify(block) }];
1267
+ }
1268
+
1269
+ push({ type: 'comma', value });
1270
+ block.commas++;
1271
+ continue;
1272
+ }
1273
+
1274
+ /**
1275
+ * Dot: '.'
1276
+ */
1277
+
1278
+ if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
1279
+ let siblings = block.nodes;
1280
+
1281
+ if (depth === 0 || siblings.length === 0) {
1282
+ push({ type: 'text', value });
1283
+ continue;
1284
+ }
1285
+
1286
+ if (prev.type === 'dot') {
1287
+ block.range = [];
1288
+ prev.value += value;
1289
+ prev.type = 'range';
1290
+
1291
+ if (block.nodes.length !== 3 && block.nodes.length !== 5) {
1292
+ block.invalid = true;
1293
+ block.ranges = 0;
1294
+ prev.type = 'text';
1295
+ continue;
1296
+ }
1297
+
1298
+ block.ranges++;
1299
+ block.args = [];
1300
+ continue;
1301
+ }
1302
+
1303
+ if (prev.type === 'range') {
1304
+ siblings.pop();
1305
+
1306
+ let before = siblings[siblings.length - 1];
1307
+ before.value += prev.value + value;
1308
+ prev = before;
1309
+ block.ranges--;
1310
+ continue;
1311
+ }
1312
+
1313
+ push({ type: 'dot', value });
1314
+ continue;
1315
+ }
1316
+
1317
+ /**
1318
+ * Text
1319
+ */
1320
+
1321
+ push({ type: 'text', value });
1322
+ }
1323
+
1324
+ // Mark imbalanced braces and brackets as invalid
1325
+ do {
1326
+ block = stack.pop();
1327
+
1328
+ if (block.type !== 'root') {
1329
+ block.nodes.forEach(node => {
1330
+ if (!node.nodes) {
1331
+ if (node.type === 'open') node.isOpen = true;
1332
+ if (node.type === 'close') node.isClose = true;
1333
+ if (!node.nodes) node.type = 'text';
1334
+ node.invalid = true;
1335
+ }
1336
+ });
1337
+
1338
+ // get the location of the block on parent.nodes (block's siblings)
1339
+ let parent = stack[stack.length - 1];
1340
+ let index = parent.nodes.indexOf(block);
1341
+ // replace the (invalid) block with it's nodes
1342
+ parent.nodes.splice(index, 1, ...block.nodes);
1343
+ }
1344
+ } while (stack.length > 0);
1345
+
1346
+ push({ type: 'eos' });
1347
+ return ast;
1348
+ };
1349
+
1350
+ parse_1$1 = parse;
1351
+ return parse_1$1;
1352
+ }
1353
+
1354
+ var braces_1;
1355
+ var hasRequiredBraces;
1356
+
1357
+ function requireBraces () {
1358
+ if (hasRequiredBraces) return braces_1;
1359
+ hasRequiredBraces = 1;
1360
+
1361
+ const stringify = requireStringify();
1362
+ const compile = requireCompile();
1363
+ const expand = requireExpand();
1364
+ const parse = requireParse$1();
1365
+
1366
+ /**
1367
+ * Expand the given pattern or create a regex-compatible string.
1368
+ *
1369
+ * ```js
1370
+ * const braces = require('braces');
1371
+ * console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)']
1372
+ * console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c']
1373
+ * ```
1374
+ * @param {String} `str`
1375
+ * @param {Object} `options`
1376
+ * @return {String}
1377
+ * @api public
1378
+ */
1379
+
1380
+ const braces = (input, options = {}) => {
1381
+ let output = [];
1382
+
1383
+ if (Array.isArray(input)) {
1384
+ for (let pattern of input) {
1385
+ let result = braces.create(pattern, options);
1386
+ if (Array.isArray(result)) {
1387
+ output.push(...result);
1388
+ } else {
1389
+ output.push(result);
1390
+ }
1391
+ }
1392
+ } else {
1393
+ output = [].concat(braces.create(input, options));
1394
+ }
1395
+
1396
+ if (options && options.expand === true && options.nodupes === true) {
1397
+ output = [...new Set(output)];
1398
+ }
1399
+ return output;
1400
+ };
1401
+
1402
+ /**
1403
+ * Parse the given `str` with the given `options`.
1404
+ *
1405
+ * ```js
1406
+ * // braces.parse(pattern, [, options]);
1407
+ * const ast = braces.parse('a/{b,c}/d');
1408
+ * console.log(ast);
1409
+ * ```
1410
+ * @param {String} pattern Brace pattern to parse
1411
+ * @param {Object} options
1412
+ * @return {Object} Returns an AST
1413
+ * @api public
1414
+ */
1415
+
1416
+ braces.parse = (input, options = {}) => parse(input, options);
1417
+
1418
+ /**
1419
+ * Creates a braces string from an AST, or an AST node.
1420
+ *
1421
+ * ```js
1422
+ * const braces = require('braces');
1423
+ * let ast = braces.parse('foo/{a,b}/bar');
1424
+ * console.log(stringify(ast.nodes[2])); //=> '{a,b}'
1425
+ * ```
1426
+ * @param {String} `input` Brace pattern or AST.
1427
+ * @param {Object} `options`
1428
+ * @return {Array} Returns an array of expanded values.
1429
+ * @api public
1430
+ */
1431
+
1432
+ braces.stringify = (input, options = {}) => {
1433
+ if (typeof input === 'string') {
1434
+ return stringify(braces.parse(input, options), options);
1435
+ }
1436
+ return stringify(input, options);
1437
+ };
1438
+
1439
+ /**
1440
+ * Compiles a brace pattern into a regex-compatible, optimized string.
1441
+ * This method is called by the main [braces](#braces) function by default.
1442
+ *
1443
+ * ```js
1444
+ * const braces = require('braces');
1445
+ * console.log(braces.compile('a/{b,c}/d'));
1446
+ * //=> ['a/(b|c)/d']
1447
+ * ```
1448
+ * @param {String} `input` Brace pattern or AST.
1449
+ * @param {Object} `options`
1450
+ * @return {Array} Returns an array of expanded values.
1451
+ * @api public
1452
+ */
1453
+
1454
+ braces.compile = (input, options = {}) => {
1455
+ if (typeof input === 'string') {
1456
+ input = braces.parse(input, options);
1457
+ }
1458
+ return compile(input, options);
1459
+ };
1460
+
1461
+ /**
1462
+ * Expands a brace pattern into an array. This method is called by the
1463
+ * main [braces](#braces) function when `options.expand` is true. Before
1464
+ * using this method it's recommended that you read the [performance notes](#performance))
1465
+ * and advantages of using [.compile](#compile) instead.
1466
+ *
1467
+ * ```js
1468
+ * const braces = require('braces');
1469
+ * console.log(braces.expand('a/{b,c}/d'));
1470
+ * //=> ['a/b/d', 'a/c/d'];
1471
+ * ```
1472
+ * @param {String} `pattern` Brace pattern
1473
+ * @param {Object} `options`
1474
+ * @return {Array} Returns an array of expanded values.
1475
+ * @api public
1476
+ */
1477
+
1478
+ braces.expand = (input, options = {}) => {
1479
+ if (typeof input === 'string') {
1480
+ input = braces.parse(input, options);
1481
+ }
1482
+
1483
+ let result = expand(input, options);
1484
+
1485
+ // filter out empty strings if specified
1486
+ if (options.noempty === true) {
1487
+ result = result.filter(Boolean);
1488
+ }
1489
+
1490
+ // filter out duplicates if specified
1491
+ if (options.nodupes === true) {
1492
+ result = [...new Set(result)];
1493
+ }
1494
+
1495
+ return result;
1496
+ };
1497
+
1498
+ /**
1499
+ * Processes a brace pattern and returns either an expanded array
1500
+ * (if `options.expand` is true), a highly optimized regex-compatible string.
1501
+ * This method is called by the main [braces](#braces) function.
1502
+ *
1503
+ * ```js
1504
+ * const braces = require('braces');
1505
+ * console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}'))
1506
+ * //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)'
1507
+ * ```
1508
+ * @param {String} `pattern` Brace pattern
1509
+ * @param {Object} `options`
1510
+ * @return {Array} Returns an array of expanded values.
1511
+ * @api public
1512
+ */
1513
+
1514
+ braces.create = (input, options = {}) => {
1515
+ if (input === '' || input.length < 3) {
1516
+ return [input];
1517
+ }
1518
+
1519
+ return options.expand !== true
1520
+ ? braces.compile(input, options)
1521
+ : braces.expand(input, options);
1522
+ };
1523
+
1524
+ /**
1525
+ * Expose "braces"
1526
+ */
1527
+
1528
+ braces_1 = braces;
1529
+ return braces_1;
1530
+ }
1531
+
1532
+ var utils = {};
1533
+
1534
+ var constants;
1535
+ var hasRequiredConstants;
1536
+
1537
+ function requireConstants () {
1538
+ if (hasRequiredConstants) return constants;
1539
+ hasRequiredConstants = 1;
1540
+
1541
+ const path = require$$0$1;
1542
+ const WIN_SLASH = '\\\\/';
1543
+ const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
1544
+
1545
+ /**
1546
+ * Posix glob regex
1547
+ */
1548
+
1549
+ const DOT_LITERAL = '\\.';
1550
+ const PLUS_LITERAL = '\\+';
1551
+ const QMARK_LITERAL = '\\?';
1552
+ const SLASH_LITERAL = '\\/';
1553
+ const ONE_CHAR = '(?=.)';
1554
+ const QMARK = '[^/]';
1555
+ const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
1556
+ const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
1557
+ const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
1558
+ const NO_DOT = `(?!${DOT_LITERAL})`;
1559
+ const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
1560
+ const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
1561
+ const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
1562
+ const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
1563
+ const STAR = `${QMARK}*?`;
1564
+
1565
+ const POSIX_CHARS = {
1566
+ DOT_LITERAL,
1567
+ PLUS_LITERAL,
1568
+ QMARK_LITERAL,
1569
+ SLASH_LITERAL,
1570
+ ONE_CHAR,
1571
+ QMARK,
1572
+ END_ANCHOR,
1573
+ DOTS_SLASH,
1574
+ NO_DOT,
1575
+ NO_DOTS,
1576
+ NO_DOT_SLASH,
1577
+ NO_DOTS_SLASH,
1578
+ QMARK_NO_DOT,
1579
+ STAR,
1580
+ START_ANCHOR
1581
+ };
1582
+
1583
+ /**
1584
+ * Windows glob regex
1585
+ */
1586
+
1587
+ const WINDOWS_CHARS = {
1588
+ ...POSIX_CHARS,
1589
+
1590
+ SLASH_LITERAL: `[${WIN_SLASH}]`,
1591
+ QMARK: WIN_NO_SLASH,
1592
+ STAR: `${WIN_NO_SLASH}*?`,
1593
+ DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
1594
+ NO_DOT: `(?!${DOT_LITERAL})`,
1595
+ NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
1596
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
1597
+ NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
1598
+ QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
1599
+ START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
1600
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
1601
+ };
1602
+
1603
+ /**
1604
+ * POSIX Bracket Regex
1605
+ */
1606
+
1607
+ const POSIX_REGEX_SOURCE = {
1608
+ alnum: 'a-zA-Z0-9',
1609
+ alpha: 'a-zA-Z',
1610
+ ascii: '\\x00-\\x7F',
1611
+ blank: ' \\t',
1612
+ cntrl: '\\x00-\\x1F\\x7F',
1613
+ digit: '0-9',
1614
+ graph: '\\x21-\\x7E',
1615
+ lower: 'a-z',
1616
+ print: '\\x20-\\x7E ',
1617
+ punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
1618
+ space: ' \\t\\r\\n\\v\\f',
1619
+ upper: 'A-Z',
1620
+ word: 'A-Za-z0-9_',
1621
+ xdigit: 'A-Fa-f0-9'
1622
+ };
1623
+
1624
+ constants = {
1625
+ MAX_LENGTH: 1024 * 64,
1626
+ POSIX_REGEX_SOURCE,
1627
+
1628
+ // regular expressions
1629
+ REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
1630
+ REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
1631
+ REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
1632
+ REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
1633
+ REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
1634
+ REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
1635
+
1636
+ // Replace globs with equivalent patterns to reduce parsing time.
1637
+ REPLACEMENTS: {
1638
+ '***': '*',
1639
+ '**/**': '**',
1640
+ '**/**/**': '**'
1641
+ },
1642
+
1643
+ // Digits
1644
+ CHAR_0: 48, /* 0 */
1645
+ CHAR_9: 57, /* 9 */
1646
+
1647
+ // Alphabet chars.
1648
+ CHAR_UPPERCASE_A: 65, /* A */
1649
+ CHAR_LOWERCASE_A: 97, /* a */
1650
+ CHAR_UPPERCASE_Z: 90, /* Z */
1651
+ CHAR_LOWERCASE_Z: 122, /* z */
1652
+
1653
+ CHAR_LEFT_PARENTHESES: 40, /* ( */
1654
+ CHAR_RIGHT_PARENTHESES: 41, /* ) */
1655
+
1656
+ CHAR_ASTERISK: 42, /* * */
1657
+
1658
+ // Non-alphabetic chars.
1659
+ CHAR_AMPERSAND: 38, /* & */
1660
+ CHAR_AT: 64, /* @ */
1661
+ CHAR_BACKWARD_SLASH: 92, /* \ */
1662
+ CHAR_CARRIAGE_RETURN: 13, /* \r */
1663
+ CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
1664
+ CHAR_COLON: 58, /* : */
1665
+ CHAR_COMMA: 44, /* , */
1666
+ CHAR_DOT: 46, /* . */
1667
+ CHAR_DOUBLE_QUOTE: 34, /* " */
1668
+ CHAR_EQUAL: 61, /* = */
1669
+ CHAR_EXCLAMATION_MARK: 33, /* ! */
1670
+ CHAR_FORM_FEED: 12, /* \f */
1671
+ CHAR_FORWARD_SLASH: 47, /* / */
1672
+ CHAR_GRAVE_ACCENT: 96, /* ` */
1673
+ CHAR_HASH: 35, /* # */
1674
+ CHAR_HYPHEN_MINUS: 45, /* - */
1675
+ CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
1676
+ CHAR_LEFT_CURLY_BRACE: 123, /* { */
1677
+ CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
1678
+ CHAR_LINE_FEED: 10, /* \n */
1679
+ CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
1680
+ CHAR_PERCENT: 37, /* % */
1681
+ CHAR_PLUS: 43, /* + */
1682
+ CHAR_QUESTION_MARK: 63, /* ? */
1683
+ CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
1684
+ CHAR_RIGHT_CURLY_BRACE: 125, /* } */
1685
+ CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
1686
+ CHAR_SEMICOLON: 59, /* ; */
1687
+ CHAR_SINGLE_QUOTE: 39, /* ' */
1688
+ CHAR_SPACE: 32, /* */
1689
+ CHAR_TAB: 9, /* \t */
1690
+ CHAR_UNDERSCORE: 95, /* _ */
1691
+ CHAR_VERTICAL_LINE: 124, /* | */
1692
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
1693
+
1694
+ SEP: path.sep,
1695
+
1696
+ /**
1697
+ * Create EXTGLOB_CHARS
1698
+ */
1699
+
1700
+ extglobChars(chars) {
1701
+ return {
1702
+ '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
1703
+ '?': { type: 'qmark', open: '(?:', close: ')?' },
1704
+ '+': { type: 'plus', open: '(?:', close: ')+' },
1705
+ '*': { type: 'star', open: '(?:', close: ')*' },
1706
+ '@': { type: 'at', open: '(?:', close: ')' }
1707
+ };
1708
+ },
1709
+
1710
+ /**
1711
+ * Create GLOB_CHARS
1712
+ */
1713
+
1714
+ globChars(win32) {
1715
+ return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
1716
+ }
1717
+ };
1718
+ return constants;
1719
+ }
1720
+
1721
+ var hasRequiredUtils;
1722
+
1723
+ function requireUtils () {
1724
+ if (hasRequiredUtils) return utils;
1725
+ hasRequiredUtils = 1;
1726
+ (function (exports) {
1727
+
1728
+ const path = require$$0$1;
1729
+ const win32 = process.platform === 'win32';
1730
+ const {
1731
+ REGEX_BACKSLASH,
1732
+ REGEX_REMOVE_BACKSLASH,
1733
+ REGEX_SPECIAL_CHARS,
1734
+ REGEX_SPECIAL_CHARS_GLOBAL
1735
+ } = requireConstants();
1736
+
1737
+ exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
1738
+ exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
1739
+ exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
1740
+ exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
1741
+ exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
1742
+
1743
+ exports.removeBackslashes = str => {
1744
+ return str.replace(REGEX_REMOVE_BACKSLASH, match => {
1745
+ return match === '\\' ? '' : match;
1746
+ });
1747
+ };
1748
+
1749
+ exports.supportsLookbehinds = () => {
1750
+ const segs = process.version.slice(1).split('.').map(Number);
1751
+ if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
1752
+ return true;
1753
+ }
1754
+ return false;
1755
+ };
1756
+
1757
+ exports.isWindows = options => {
1758
+ if (options && typeof options.windows === 'boolean') {
1759
+ return options.windows;
1760
+ }
1761
+ return win32 === true || path.sep === '\\';
1762
+ };
1763
+
1764
+ exports.escapeLast = (input, char, lastIdx) => {
1765
+ const idx = input.lastIndexOf(char, lastIdx);
1766
+ if (idx === -1) return input;
1767
+ if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
1768
+ return `${input.slice(0, idx)}\\${input.slice(idx)}`;
1769
+ };
1770
+
1771
+ exports.removePrefix = (input, state = {}) => {
1772
+ let output = input;
1773
+ if (output.startsWith('./')) {
1774
+ output = output.slice(2);
1775
+ state.prefix = './';
1776
+ }
1777
+ return output;
1778
+ };
1779
+
1780
+ exports.wrapOutput = (input, state = {}, options = {}) => {
1781
+ const prepend = options.contains ? '' : '^';
1782
+ const append = options.contains ? '' : '$';
1783
+
1784
+ let output = `${prepend}(?:${input})${append}`;
1785
+ if (state.negated === true) {
1786
+ output = `(?:^(?!${output}).*$)`;
1787
+ }
1788
+ return output;
1789
+ };
1790
+ } (utils));
1791
+ return utils;
1792
+ }
1793
+
1794
+ var scan_1;
1795
+ var hasRequiredScan;
1796
+
1797
+ function requireScan () {
1798
+ if (hasRequiredScan) return scan_1;
1799
+ hasRequiredScan = 1;
1800
+
1801
+ const utils = requireUtils();
1802
+ const {
1803
+ CHAR_ASTERISK, /* * */
1804
+ CHAR_AT, /* @ */
1805
+ CHAR_BACKWARD_SLASH, /* \ */
1806
+ CHAR_COMMA, /* , */
1807
+ CHAR_DOT, /* . */
1808
+ CHAR_EXCLAMATION_MARK, /* ! */
1809
+ CHAR_FORWARD_SLASH, /* / */
1810
+ CHAR_LEFT_CURLY_BRACE, /* { */
1811
+ CHAR_LEFT_PARENTHESES, /* ( */
1812
+ CHAR_LEFT_SQUARE_BRACKET, /* [ */
1813
+ CHAR_PLUS, /* + */
1814
+ CHAR_QUESTION_MARK, /* ? */
1815
+ CHAR_RIGHT_CURLY_BRACE, /* } */
1816
+ CHAR_RIGHT_PARENTHESES, /* ) */
1817
+ CHAR_RIGHT_SQUARE_BRACKET /* ] */
1818
+ } = requireConstants();
1819
+
1820
+ const isPathSeparator = code => {
1821
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
1822
+ };
1823
+
1824
+ const depth = token => {
1825
+ if (token.isPrefix !== true) {
1826
+ token.depth = token.isGlobstar ? Infinity : 1;
1827
+ }
1828
+ };
1829
+
1830
+ /**
1831
+ * Quickly scans a glob pattern and returns an object with a handful of
1832
+ * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
1833
+ * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
1834
+ * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
1835
+ *
1836
+ * ```js
1837
+ * const pm = require('picomatch');
1838
+ * console.log(pm.scan('foo/bar/*.js'));
1839
+ * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
1840
+ * ```
1841
+ * @param {String} `str`
1842
+ * @param {Object} `options`
1843
+ * @return {Object} Returns an object with tokens and regex source string.
1844
+ * @api public
1845
+ */
1846
+
1847
+ const scan = (input, options) => {
1848
+ const opts = options || {};
1849
+
1850
+ const length = input.length - 1;
1851
+ const scanToEnd = opts.parts === true || opts.scanToEnd === true;
1852
+ const slashes = [];
1853
+ const tokens = [];
1854
+ const parts = [];
1855
+
1856
+ let str = input;
1857
+ let index = -1;
1858
+ let start = 0;
1859
+ let lastIndex = 0;
1860
+ let isBrace = false;
1861
+ let isBracket = false;
1862
+ let isGlob = false;
1863
+ let isExtglob = false;
1864
+ let isGlobstar = false;
1865
+ let braceEscaped = false;
1866
+ let backslashes = false;
1867
+ let negated = false;
1868
+ let negatedExtglob = false;
1869
+ let finished = false;
1870
+ let braces = 0;
1871
+ let prev;
1872
+ let code;
1873
+ let token = { value: '', depth: 0, isGlob: false };
1874
+
1875
+ const eos = () => index >= length;
1876
+ const peek = () => str.charCodeAt(index + 1);
1877
+ const advance = () => {
1878
+ prev = code;
1879
+ return str.charCodeAt(++index);
1880
+ };
1881
+
1882
+ while (index < length) {
1883
+ code = advance();
1884
+ let next;
1885
+
1886
+ if (code === CHAR_BACKWARD_SLASH) {
1887
+ backslashes = token.backslashes = true;
1888
+ code = advance();
1889
+
1890
+ if (code === CHAR_LEFT_CURLY_BRACE) {
1891
+ braceEscaped = true;
1892
+ }
1893
+ continue;
1894
+ }
1895
+
1896
+ if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
1897
+ braces++;
1898
+
1899
+ while (eos() !== true && (code = advance())) {
1900
+ if (code === CHAR_BACKWARD_SLASH) {
1901
+ backslashes = token.backslashes = true;
1902
+ advance();
1903
+ continue;
1904
+ }
1905
+
1906
+ if (code === CHAR_LEFT_CURLY_BRACE) {
1907
+ braces++;
1908
+ continue;
1909
+ }
1910
+
1911
+ if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
1912
+ isBrace = token.isBrace = true;
1913
+ isGlob = token.isGlob = true;
1914
+ finished = true;
1915
+
1916
+ if (scanToEnd === true) {
1917
+ continue;
1918
+ }
1919
+
1920
+ break;
1921
+ }
1922
+
1923
+ if (braceEscaped !== true && code === CHAR_COMMA) {
1924
+ isBrace = token.isBrace = true;
1925
+ isGlob = token.isGlob = true;
1926
+ finished = true;
1927
+
1928
+ if (scanToEnd === true) {
1929
+ continue;
1930
+ }
1931
+
1932
+ break;
1933
+ }
1934
+
1935
+ if (code === CHAR_RIGHT_CURLY_BRACE) {
1936
+ braces--;
1937
+
1938
+ if (braces === 0) {
1939
+ braceEscaped = false;
1940
+ isBrace = token.isBrace = true;
1941
+ finished = true;
1942
+ break;
1943
+ }
1944
+ }
1945
+ }
1946
+
1947
+ if (scanToEnd === true) {
1948
+ continue;
1949
+ }
1950
+
1951
+ break;
1952
+ }
1953
+
1954
+ if (code === CHAR_FORWARD_SLASH) {
1955
+ slashes.push(index);
1956
+ tokens.push(token);
1957
+ token = { value: '', depth: 0, isGlob: false };
1958
+
1959
+ if (finished === true) continue;
1960
+ if (prev === CHAR_DOT && index === (start + 1)) {
1961
+ start += 2;
1962
+ continue;
1963
+ }
1964
+
1965
+ lastIndex = index + 1;
1966
+ continue;
1967
+ }
1968
+
1969
+ if (opts.noext !== true) {
1970
+ const isExtglobChar = code === CHAR_PLUS
1971
+ || code === CHAR_AT
1972
+ || code === CHAR_ASTERISK
1973
+ || code === CHAR_QUESTION_MARK
1974
+ || code === CHAR_EXCLAMATION_MARK;
1975
+
1976
+ if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
1977
+ isGlob = token.isGlob = true;
1978
+ isExtglob = token.isExtglob = true;
1979
+ finished = true;
1980
+ if (code === CHAR_EXCLAMATION_MARK && index === start) {
1981
+ negatedExtglob = true;
1982
+ }
1983
+
1984
+ if (scanToEnd === true) {
1985
+ while (eos() !== true && (code = advance())) {
1986
+ if (code === CHAR_BACKWARD_SLASH) {
1987
+ backslashes = token.backslashes = true;
1988
+ code = advance();
1989
+ continue;
1990
+ }
1991
+
1992
+ if (code === CHAR_RIGHT_PARENTHESES) {
1993
+ isGlob = token.isGlob = true;
1994
+ finished = true;
1995
+ break;
1996
+ }
1997
+ }
1998
+ continue;
1999
+ }
2000
+ break;
2001
+ }
2002
+ }
2003
+
2004
+ if (code === CHAR_ASTERISK) {
2005
+ if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
2006
+ isGlob = token.isGlob = true;
2007
+ finished = true;
2008
+
2009
+ if (scanToEnd === true) {
2010
+ continue;
2011
+ }
2012
+ break;
2013
+ }
2014
+
2015
+ if (code === CHAR_QUESTION_MARK) {
2016
+ isGlob = token.isGlob = true;
2017
+ finished = true;
2018
+
2019
+ if (scanToEnd === true) {
2020
+ continue;
2021
+ }
2022
+ break;
2023
+ }
2024
+
2025
+ if (code === CHAR_LEFT_SQUARE_BRACKET) {
2026
+ while (eos() !== true && (next = advance())) {
2027
+ if (next === CHAR_BACKWARD_SLASH) {
2028
+ backslashes = token.backslashes = true;
2029
+ advance();
2030
+ continue;
2031
+ }
2032
+
2033
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
2034
+ isBracket = token.isBracket = true;
2035
+ isGlob = token.isGlob = true;
2036
+ finished = true;
2037
+ break;
2038
+ }
2039
+ }
2040
+
2041
+ if (scanToEnd === true) {
2042
+ continue;
2043
+ }
2044
+
2045
+ break;
2046
+ }
2047
+
2048
+ if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
2049
+ negated = token.negated = true;
2050
+ start++;
2051
+ continue;
2052
+ }
2053
+
2054
+ if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
2055
+ isGlob = token.isGlob = true;
2056
+
2057
+ if (scanToEnd === true) {
2058
+ while (eos() !== true && (code = advance())) {
2059
+ if (code === CHAR_LEFT_PARENTHESES) {
2060
+ backslashes = token.backslashes = true;
2061
+ code = advance();
2062
+ continue;
2063
+ }
2064
+
2065
+ if (code === CHAR_RIGHT_PARENTHESES) {
2066
+ finished = true;
2067
+ break;
2068
+ }
2069
+ }
2070
+ continue;
2071
+ }
2072
+ break;
2073
+ }
2074
+
2075
+ if (isGlob === true) {
2076
+ finished = true;
2077
+
2078
+ if (scanToEnd === true) {
2079
+ continue;
2080
+ }
2081
+
2082
+ break;
2083
+ }
2084
+ }
2085
+
2086
+ if (opts.noext === true) {
2087
+ isExtglob = false;
2088
+ isGlob = false;
2089
+ }
2090
+
2091
+ let base = str;
2092
+ let prefix = '';
2093
+ let glob = '';
2094
+
2095
+ if (start > 0) {
2096
+ prefix = str.slice(0, start);
2097
+ str = str.slice(start);
2098
+ lastIndex -= start;
2099
+ }
2100
+
2101
+ if (base && isGlob === true && lastIndex > 0) {
2102
+ base = str.slice(0, lastIndex);
2103
+ glob = str.slice(lastIndex);
2104
+ } else if (isGlob === true) {
2105
+ base = '';
2106
+ glob = str;
2107
+ } else {
2108
+ base = str;
2109
+ }
2110
+
2111
+ if (base && base !== '' && base !== '/' && base !== str) {
2112
+ if (isPathSeparator(base.charCodeAt(base.length - 1))) {
2113
+ base = base.slice(0, -1);
2114
+ }
2115
+ }
2116
+
2117
+ if (opts.unescape === true) {
2118
+ if (glob) glob = utils.removeBackslashes(glob);
2119
+
2120
+ if (base && backslashes === true) {
2121
+ base = utils.removeBackslashes(base);
2122
+ }
2123
+ }
2124
+
2125
+ const state = {
2126
+ prefix,
2127
+ input,
2128
+ start,
2129
+ base,
2130
+ glob,
2131
+ isBrace,
2132
+ isBracket,
2133
+ isGlob,
2134
+ isExtglob,
2135
+ isGlobstar,
2136
+ negated,
2137
+ negatedExtglob
2138
+ };
2139
+
2140
+ if (opts.tokens === true) {
2141
+ state.maxDepth = 0;
2142
+ if (!isPathSeparator(code)) {
2143
+ tokens.push(token);
2144
+ }
2145
+ state.tokens = tokens;
2146
+ }
2147
+
2148
+ if (opts.parts === true || opts.tokens === true) {
2149
+ let prevIndex;
2150
+
2151
+ for (let idx = 0; idx < slashes.length; idx++) {
2152
+ const n = prevIndex ? prevIndex + 1 : start;
2153
+ const i = slashes[idx];
2154
+ const value = input.slice(n, i);
2155
+ if (opts.tokens) {
2156
+ if (idx === 0 && start !== 0) {
2157
+ tokens[idx].isPrefix = true;
2158
+ tokens[idx].value = prefix;
2159
+ } else {
2160
+ tokens[idx].value = value;
2161
+ }
2162
+ depth(tokens[idx]);
2163
+ state.maxDepth += tokens[idx].depth;
2164
+ }
2165
+ if (idx !== 0 || value !== '') {
2166
+ parts.push(value);
2167
+ }
2168
+ prevIndex = i;
2169
+ }
2170
+
2171
+ if (prevIndex && prevIndex + 1 < input.length) {
2172
+ const value = input.slice(prevIndex + 1);
2173
+ parts.push(value);
2174
+
2175
+ if (opts.tokens) {
2176
+ tokens[tokens.length - 1].value = value;
2177
+ depth(tokens[tokens.length - 1]);
2178
+ state.maxDepth += tokens[tokens.length - 1].depth;
2179
+ }
2180
+ }
2181
+
2182
+ state.slashes = slashes;
2183
+ state.parts = parts;
2184
+ }
2185
+
2186
+ return state;
2187
+ };
2188
+
2189
+ scan_1 = scan;
2190
+ return scan_1;
2191
+ }
2192
+
2193
+ var parse_1;
2194
+ var hasRequiredParse;
2195
+
2196
+ function requireParse () {
2197
+ if (hasRequiredParse) return parse_1;
2198
+ hasRequiredParse = 1;
2199
+
2200
+ const constants = requireConstants();
2201
+ const utils = requireUtils();
2202
+
2203
+ /**
2204
+ * Constants
2205
+ */
2206
+
2207
+ const {
2208
+ MAX_LENGTH,
2209
+ POSIX_REGEX_SOURCE,
2210
+ REGEX_NON_SPECIAL_CHARS,
2211
+ REGEX_SPECIAL_CHARS_BACKREF,
2212
+ REPLACEMENTS
2213
+ } = constants;
2214
+
2215
+ /**
2216
+ * Helpers
2217
+ */
2218
+
2219
+ const expandRange = (args, options) => {
2220
+ if (typeof options.expandRange === 'function') {
2221
+ return options.expandRange(...args, options);
2222
+ }
2223
+
2224
+ args.sort();
2225
+ const value = `[${args.join('-')}]`;
2226
+
2227
+ try {
2228
+ /* eslint-disable-next-line no-new */
2229
+ new RegExp(value);
2230
+ } catch (ex) {
2231
+ return args.map(v => utils.escapeRegex(v)).join('..');
2232
+ }
2233
+
2234
+ return value;
2235
+ };
2236
+
2237
+ /**
2238
+ * Create the message for a syntax error
2239
+ */
2240
+
2241
+ const syntaxError = (type, char) => {
2242
+ return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
2243
+ };
2244
+
2245
+ /**
2246
+ * Parse the given input string.
2247
+ * @param {String} input
2248
+ * @param {Object} options
2249
+ * @return {Object}
2250
+ */
2251
+
2252
+ const parse = (input, options) => {
2253
+ if (typeof input !== 'string') {
2254
+ throw new TypeError('Expected a string');
2255
+ }
2256
+
2257
+ input = REPLACEMENTS[input] || input;
2258
+
2259
+ const opts = { ...options };
2260
+ const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
2261
+
2262
+ let len = input.length;
2263
+ if (len > max) {
2264
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
2265
+ }
2266
+
2267
+ const bos = { type: 'bos', value: '', output: opts.prepend || '' };
2268
+ const tokens = [bos];
2269
+
2270
+ const capture = opts.capture ? '' : '?:';
2271
+ const win32 = utils.isWindows(options);
2272
+
2273
+ // create constants based on platform, for windows or posix
2274
+ const PLATFORM_CHARS = constants.globChars(win32);
2275
+ const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
2276
+
2277
+ const {
2278
+ DOT_LITERAL,
2279
+ PLUS_LITERAL,
2280
+ SLASH_LITERAL,
2281
+ ONE_CHAR,
2282
+ DOTS_SLASH,
2283
+ NO_DOT,
2284
+ NO_DOT_SLASH,
2285
+ NO_DOTS_SLASH,
2286
+ QMARK,
2287
+ QMARK_NO_DOT,
2288
+ STAR,
2289
+ START_ANCHOR
2290
+ } = PLATFORM_CHARS;
2291
+
2292
+ const globstar = opts => {
2293
+ return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
2294
+ };
2295
+
2296
+ const nodot = opts.dot ? '' : NO_DOT;
2297
+ const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
2298
+ let star = opts.bash === true ? globstar(opts) : STAR;
2299
+
2300
+ if (opts.capture) {
2301
+ star = `(${star})`;
2302
+ }
2303
+
2304
+ // minimatch options support
2305
+ if (typeof opts.noext === 'boolean') {
2306
+ opts.noextglob = opts.noext;
2307
+ }
2308
+
2309
+ const state = {
2310
+ input,
2311
+ index: -1,
2312
+ start: 0,
2313
+ dot: opts.dot === true,
2314
+ consumed: '',
2315
+ output: '',
2316
+ prefix: '',
2317
+ backtrack: false,
2318
+ negated: false,
2319
+ brackets: 0,
2320
+ braces: 0,
2321
+ parens: 0,
2322
+ quotes: 0,
2323
+ globstar: false,
2324
+ tokens
2325
+ };
2326
+
2327
+ input = utils.removePrefix(input, state);
2328
+ len = input.length;
2329
+
2330
+ const extglobs = [];
2331
+ const braces = [];
2332
+ const stack = [];
2333
+ let prev = bos;
2334
+ let value;
2335
+
2336
+ /**
2337
+ * Tokenizing helpers
2338
+ */
2339
+
2340
+ const eos = () => state.index === len - 1;
2341
+ const peek = state.peek = (n = 1) => input[state.index + n];
2342
+ const advance = state.advance = () => input[++state.index] || '';
2343
+ const remaining = () => input.slice(state.index + 1);
2344
+ const consume = (value = '', num = 0) => {
2345
+ state.consumed += value;
2346
+ state.index += num;
2347
+ };
2348
+
2349
+ const append = token => {
2350
+ state.output += token.output != null ? token.output : token.value;
2351
+ consume(token.value);
2352
+ };
2353
+
2354
+ const negate = () => {
2355
+ let count = 1;
2356
+
2357
+ while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
2358
+ advance();
2359
+ state.start++;
2360
+ count++;
2361
+ }
2362
+
2363
+ if (count % 2 === 0) {
2364
+ return false;
2365
+ }
2366
+
2367
+ state.negated = true;
2368
+ state.start++;
2369
+ return true;
2370
+ };
2371
+
2372
+ const increment = type => {
2373
+ state[type]++;
2374
+ stack.push(type);
2375
+ };
2376
+
2377
+ const decrement = type => {
2378
+ state[type]--;
2379
+ stack.pop();
2380
+ };
2381
+
2382
+ /**
2383
+ * Push tokens onto the tokens array. This helper speeds up
2384
+ * tokenizing by 1) helping us avoid backtracking as much as possible,
2385
+ * and 2) helping us avoid creating extra tokens when consecutive
2386
+ * characters are plain text. This improves performance and simplifies
2387
+ * lookbehinds.
2388
+ */
2389
+
2390
+ const push = tok => {
2391
+ if (prev.type === 'globstar') {
2392
+ const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
2393
+ const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
2394
+
2395
+ if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
2396
+ state.output = state.output.slice(0, -prev.output.length);
2397
+ prev.type = 'star';
2398
+ prev.value = '*';
2399
+ prev.output = star;
2400
+ state.output += prev.output;
2401
+ }
2402
+ }
2403
+
2404
+ if (extglobs.length && tok.type !== 'paren') {
2405
+ extglobs[extglobs.length - 1].inner += tok.value;
2406
+ }
2407
+
2408
+ if (tok.value || tok.output) append(tok);
2409
+ if (prev && prev.type === 'text' && tok.type === 'text') {
2410
+ prev.value += tok.value;
2411
+ prev.output = (prev.output || '') + tok.value;
2412
+ return;
2413
+ }
2414
+
2415
+ tok.prev = prev;
2416
+ tokens.push(tok);
2417
+ prev = tok;
2418
+ };
2419
+
2420
+ const extglobOpen = (type, value) => {
2421
+ const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
2422
+
2423
+ token.prev = prev;
2424
+ token.parens = state.parens;
2425
+ token.output = state.output;
2426
+ const output = (opts.capture ? '(' : '') + token.open;
2427
+
2428
+ increment('parens');
2429
+ push({ type, value, output: state.output ? '' : ONE_CHAR });
2430
+ push({ type: 'paren', extglob: true, value: advance(), output });
2431
+ extglobs.push(token);
2432
+ };
2433
+
2434
+ const extglobClose = token => {
2435
+ let output = token.close + (opts.capture ? ')' : '');
2436
+ let rest;
2437
+
2438
+ if (token.type === 'negate') {
2439
+ let extglobStar = star;
2440
+
2441
+ if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
2442
+ extglobStar = globstar(opts);
2443
+ }
2444
+
2445
+ if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
2446
+ output = token.close = `)$))${extglobStar}`;
2447
+ }
2448
+
2449
+ if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
2450
+ // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
2451
+ // In this case, we need to parse the string and use it in the output of the original pattern.
2452
+ // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
2453
+ //
2454
+ // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
2455
+ const expression = parse(rest, { ...options, fastpaths: false }).output;
2456
+
2457
+ output = token.close = `)${expression})${extglobStar})`;
2458
+ }
2459
+
2460
+ if (token.prev.type === 'bos') {
2461
+ state.negatedExtglob = true;
2462
+ }
2463
+ }
2464
+
2465
+ push({ type: 'paren', extglob: true, value, output });
2466
+ decrement('parens');
2467
+ };
2468
+
2469
+ /**
2470
+ * Fast paths
2471
+ */
2472
+
2473
+ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
2474
+ let backslashes = false;
2475
+
2476
+ let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
2477
+ if (first === '\\') {
2478
+ backslashes = true;
2479
+ return m;
2480
+ }
2481
+
2482
+ if (first === '?') {
2483
+ if (esc) {
2484
+ return esc + first + (rest ? QMARK.repeat(rest.length) : '');
2485
+ }
2486
+ if (index === 0) {
2487
+ return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
2488
+ }
2489
+ return QMARK.repeat(chars.length);
2490
+ }
2491
+
2492
+ if (first === '.') {
2493
+ return DOT_LITERAL.repeat(chars.length);
2494
+ }
2495
+
2496
+ if (first === '*') {
2497
+ if (esc) {
2498
+ return esc + first + (rest ? star : '');
2499
+ }
2500
+ return star;
2501
+ }
2502
+ return esc ? m : `\\${m}`;
2503
+ });
2504
+
2505
+ if (backslashes === true) {
2506
+ if (opts.unescape === true) {
2507
+ output = output.replace(/\\/g, '');
2508
+ } else {
2509
+ output = output.replace(/\\+/g, m => {
2510
+ return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
2511
+ });
2512
+ }
2513
+ }
2514
+
2515
+ if (output === input && opts.contains === true) {
2516
+ state.output = input;
2517
+ return state;
2518
+ }
2519
+
2520
+ state.output = utils.wrapOutput(output, state, options);
2521
+ return state;
2522
+ }
2523
+
2524
+ /**
2525
+ * Tokenize input until we reach end-of-string
2526
+ */
2527
+
2528
+ while (!eos()) {
2529
+ value = advance();
2530
+
2531
+ if (value === '\u0000') {
2532
+ continue;
2533
+ }
2534
+
2535
+ /**
2536
+ * Escaped characters
2537
+ */
2538
+
2539
+ if (value === '\\') {
2540
+ const next = peek();
2541
+
2542
+ if (next === '/' && opts.bash !== true) {
2543
+ continue;
2544
+ }
2545
+
2546
+ if (next === '.' || next === ';') {
2547
+ continue;
2548
+ }
2549
+
2550
+ if (!next) {
2551
+ value += '\\';
2552
+ push({ type: 'text', value });
2553
+ continue;
2554
+ }
2555
+
2556
+ // collapse slashes to reduce potential for exploits
2557
+ const match = /^\\+/.exec(remaining());
2558
+ let slashes = 0;
2559
+
2560
+ if (match && match[0].length > 2) {
2561
+ slashes = match[0].length;
2562
+ state.index += slashes;
2563
+ if (slashes % 2 !== 0) {
2564
+ value += '\\';
2565
+ }
2566
+ }
2567
+
2568
+ if (opts.unescape === true) {
2569
+ value = advance();
2570
+ } else {
2571
+ value += advance();
2572
+ }
2573
+
2574
+ if (state.brackets === 0) {
2575
+ push({ type: 'text', value });
2576
+ continue;
2577
+ }
2578
+ }
2579
+
2580
+ /**
2581
+ * If we're inside a regex character class, continue
2582
+ * until we reach the closing bracket.
2583
+ */
2584
+
2585
+ if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
2586
+ if (opts.posix !== false && value === ':') {
2587
+ const inner = prev.value.slice(1);
2588
+ if (inner.includes('[')) {
2589
+ prev.posix = true;
2590
+
2591
+ if (inner.includes(':')) {
2592
+ const idx = prev.value.lastIndexOf('[');
2593
+ const pre = prev.value.slice(0, idx);
2594
+ const rest = prev.value.slice(idx + 2);
2595
+ const posix = POSIX_REGEX_SOURCE[rest];
2596
+ if (posix) {
2597
+ prev.value = pre + posix;
2598
+ state.backtrack = true;
2599
+ advance();
2600
+
2601
+ if (!bos.output && tokens.indexOf(prev) === 1) {
2602
+ bos.output = ONE_CHAR;
2603
+ }
2604
+ continue;
2605
+ }
2606
+ }
2607
+ }
2608
+ }
2609
+
2610
+ if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
2611
+ value = `\\${value}`;
2612
+ }
2613
+
2614
+ if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
2615
+ value = `\\${value}`;
2616
+ }
2617
+
2618
+ if (opts.posix === true && value === '!' && prev.value === '[') {
2619
+ value = '^';
2620
+ }
2621
+
2622
+ prev.value += value;
2623
+ append({ value });
2624
+ continue;
2625
+ }
2626
+
2627
+ /**
2628
+ * If we're inside a quoted string, continue
2629
+ * until we reach the closing double quote.
2630
+ */
2631
+
2632
+ if (state.quotes === 1 && value !== '"') {
2633
+ value = utils.escapeRegex(value);
2634
+ prev.value += value;
2635
+ append({ value });
2636
+ continue;
2637
+ }
2638
+
2639
+ /**
2640
+ * Double quotes
2641
+ */
2642
+
2643
+ if (value === '"') {
2644
+ state.quotes = state.quotes === 1 ? 0 : 1;
2645
+ if (opts.keepQuotes === true) {
2646
+ push({ type: 'text', value });
2647
+ }
2648
+ continue;
2649
+ }
2650
+
2651
+ /**
2652
+ * Parentheses
2653
+ */
2654
+
2655
+ if (value === '(') {
2656
+ increment('parens');
2657
+ push({ type: 'paren', value });
2658
+ continue;
2659
+ }
2660
+
2661
+ if (value === ')') {
2662
+ if (state.parens === 0 && opts.strictBrackets === true) {
2663
+ throw new SyntaxError(syntaxError('opening', '('));
2664
+ }
2665
+
2666
+ const extglob = extglobs[extglobs.length - 1];
2667
+ if (extglob && state.parens === extglob.parens + 1) {
2668
+ extglobClose(extglobs.pop());
2669
+ continue;
2670
+ }
2671
+
2672
+ push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
2673
+ decrement('parens');
2674
+ continue;
2675
+ }
2676
+
2677
+ /**
2678
+ * Square brackets
2679
+ */
2680
+
2681
+ if (value === '[') {
2682
+ if (opts.nobracket === true || !remaining().includes(']')) {
2683
+ if (opts.nobracket !== true && opts.strictBrackets === true) {
2684
+ throw new SyntaxError(syntaxError('closing', ']'));
2685
+ }
2686
+
2687
+ value = `\\${value}`;
2688
+ } else {
2689
+ increment('brackets');
2690
+ }
2691
+
2692
+ push({ type: 'bracket', value });
2693
+ continue;
2694
+ }
2695
+
2696
+ if (value === ']') {
2697
+ if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
2698
+ push({ type: 'text', value, output: `\\${value}` });
2699
+ continue;
2700
+ }
2701
+
2702
+ if (state.brackets === 0) {
2703
+ if (opts.strictBrackets === true) {
2704
+ throw new SyntaxError(syntaxError('opening', '['));
2705
+ }
2706
+
2707
+ push({ type: 'text', value, output: `\\${value}` });
2708
+ continue;
2709
+ }
2710
+
2711
+ decrement('brackets');
2712
+
2713
+ const prevValue = prev.value.slice(1);
2714
+ if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
2715
+ value = `/${value}`;
2716
+ }
2717
+
2718
+ prev.value += value;
2719
+ append({ value });
2720
+
2721
+ // when literal brackets are explicitly disabled
2722
+ // assume we should match with a regex character class
2723
+ if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
2724
+ continue;
2725
+ }
2726
+
2727
+ const escaped = utils.escapeRegex(prev.value);
2728
+ state.output = state.output.slice(0, -prev.value.length);
2729
+
2730
+ // when literal brackets are explicitly enabled
2731
+ // assume we should escape the brackets to match literal characters
2732
+ if (opts.literalBrackets === true) {
2733
+ state.output += escaped;
2734
+ prev.value = escaped;
2735
+ continue;
2736
+ }
2737
+
2738
+ // when the user specifies nothing, try to match both
2739
+ prev.value = `(${capture}${escaped}|${prev.value})`;
2740
+ state.output += prev.value;
2741
+ continue;
2742
+ }
2743
+
2744
+ /**
2745
+ * Braces
2746
+ */
2747
+
2748
+ if (value === '{' && opts.nobrace !== true) {
2749
+ increment('braces');
2750
+
2751
+ const open = {
2752
+ type: 'brace',
2753
+ value,
2754
+ output: '(',
2755
+ outputIndex: state.output.length,
2756
+ tokensIndex: state.tokens.length
2757
+ };
2758
+
2759
+ braces.push(open);
2760
+ push(open);
2761
+ continue;
2762
+ }
2763
+
2764
+ if (value === '}') {
2765
+ const brace = braces[braces.length - 1];
2766
+
2767
+ if (opts.nobrace === true || !brace) {
2768
+ push({ type: 'text', value, output: value });
2769
+ continue;
2770
+ }
2771
+
2772
+ let output = ')';
2773
+
2774
+ if (brace.dots === true) {
2775
+ const arr = tokens.slice();
2776
+ const range = [];
2777
+
2778
+ for (let i = arr.length - 1; i >= 0; i--) {
2779
+ tokens.pop();
2780
+ if (arr[i].type === 'brace') {
2781
+ break;
2782
+ }
2783
+ if (arr[i].type !== 'dots') {
2784
+ range.unshift(arr[i].value);
2785
+ }
2786
+ }
2787
+
2788
+ output = expandRange(range, opts);
2789
+ state.backtrack = true;
2790
+ }
2791
+
2792
+ if (brace.comma !== true && brace.dots !== true) {
2793
+ const out = state.output.slice(0, brace.outputIndex);
2794
+ const toks = state.tokens.slice(brace.tokensIndex);
2795
+ brace.value = brace.output = '\\{';
2796
+ value = output = '\\}';
2797
+ state.output = out;
2798
+ for (const t of toks) {
2799
+ state.output += (t.output || t.value);
2800
+ }
2801
+ }
2802
+
2803
+ push({ type: 'brace', value, output });
2804
+ decrement('braces');
2805
+ braces.pop();
2806
+ continue;
2807
+ }
2808
+
2809
+ /**
2810
+ * Pipes
2811
+ */
2812
+
2813
+ if (value === '|') {
2814
+ if (extglobs.length > 0) {
2815
+ extglobs[extglobs.length - 1].conditions++;
2816
+ }
2817
+ push({ type: 'text', value });
2818
+ continue;
2819
+ }
2820
+
2821
+ /**
2822
+ * Commas
2823
+ */
2824
+
2825
+ if (value === ',') {
2826
+ let output = value;
2827
+
2828
+ const brace = braces[braces.length - 1];
2829
+ if (brace && stack[stack.length - 1] === 'braces') {
2830
+ brace.comma = true;
2831
+ output = '|';
2832
+ }
2833
+
2834
+ push({ type: 'comma', value, output });
2835
+ continue;
2836
+ }
2837
+
2838
+ /**
2839
+ * Slashes
2840
+ */
2841
+
2842
+ if (value === '/') {
2843
+ // if the beginning of the glob is "./", advance the start
2844
+ // to the current index, and don't add the "./" characters
2845
+ // to the state. This greatly simplifies lookbehinds when
2846
+ // checking for BOS characters like "!" and "." (not "./")
2847
+ if (prev.type === 'dot' && state.index === state.start + 1) {
2848
+ state.start = state.index + 1;
2849
+ state.consumed = '';
2850
+ state.output = '';
2851
+ tokens.pop();
2852
+ prev = bos; // reset "prev" to the first token
2853
+ continue;
2854
+ }
2855
+
2856
+ push({ type: 'slash', value, output: SLASH_LITERAL });
2857
+ continue;
2858
+ }
2859
+
2860
+ /**
2861
+ * Dots
2862
+ */
2863
+
2864
+ if (value === '.') {
2865
+ if (state.braces > 0 && prev.type === 'dot') {
2866
+ if (prev.value === '.') prev.output = DOT_LITERAL;
2867
+ const brace = braces[braces.length - 1];
2868
+ prev.type = 'dots';
2869
+ prev.output += value;
2870
+ prev.value += value;
2871
+ brace.dots = true;
2872
+ continue;
2873
+ }
2874
+
2875
+ if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
2876
+ push({ type: 'text', value, output: DOT_LITERAL });
2877
+ continue;
2878
+ }
2879
+
2880
+ push({ type: 'dot', value, output: DOT_LITERAL });
2881
+ continue;
2882
+ }
2883
+
2884
+ /**
2885
+ * Question marks
2886
+ */
2887
+
2888
+ if (value === '?') {
2889
+ const isGroup = prev && prev.value === '(';
2890
+ if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2891
+ extglobOpen('qmark', value);
2892
+ continue;
2893
+ }
2894
+
2895
+ if (prev && prev.type === 'paren') {
2896
+ const next = peek();
2897
+ let output = value;
2898
+
2899
+ if (next === '<' && !utils.supportsLookbehinds()) {
2900
+ throw new Error('Node.js v10 or higher is required for regex lookbehinds');
2901
+ }
2902
+
2903
+ if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
2904
+ output = `\\${value}`;
2905
+ }
2906
+
2907
+ push({ type: 'text', value, output });
2908
+ continue;
2909
+ }
2910
+
2911
+ if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
2912
+ push({ type: 'qmark', value, output: QMARK_NO_DOT });
2913
+ continue;
2914
+ }
2915
+
2916
+ push({ type: 'qmark', value, output: QMARK });
2917
+ continue;
2918
+ }
2919
+
2920
+ /**
2921
+ * Exclamation
2922
+ */
2923
+
2924
+ if (value === '!') {
2925
+ if (opts.noextglob !== true && peek() === '(') {
2926
+ if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
2927
+ extglobOpen('negate', value);
2928
+ continue;
2929
+ }
2930
+ }
2931
+
2932
+ if (opts.nonegate !== true && state.index === 0) {
2933
+ negate();
2934
+ continue;
2935
+ }
2936
+ }
2937
+
2938
+ /**
2939
+ * Plus
2940
+ */
2941
+
2942
+ if (value === '+') {
2943
+ if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2944
+ extglobOpen('plus', value);
2945
+ continue;
2946
+ }
2947
+
2948
+ if ((prev && prev.value === '(') || opts.regex === false) {
2949
+ push({ type: 'plus', value, output: PLUS_LITERAL });
2950
+ continue;
2951
+ }
2952
+
2953
+ if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
2954
+ push({ type: 'plus', value });
2955
+ continue;
2956
+ }
2957
+
2958
+ push({ type: 'plus', value: PLUS_LITERAL });
2959
+ continue;
2960
+ }
2961
+
2962
+ /**
2963
+ * Plain text
2964
+ */
2965
+
2966
+ if (value === '@') {
2967
+ if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2968
+ push({ type: 'at', extglob: true, value, output: '' });
2969
+ continue;
2970
+ }
2971
+
2972
+ push({ type: 'text', value });
2973
+ continue;
2974
+ }
2975
+
2976
+ /**
2977
+ * Plain text
2978
+ */
2979
+
2980
+ if (value !== '*') {
2981
+ if (value === '$' || value === '^') {
2982
+ value = `\\${value}`;
2983
+ }
2984
+
2985
+ const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
2986
+ if (match) {
2987
+ value += match[0];
2988
+ state.index += match[0].length;
2989
+ }
2990
+
2991
+ push({ type: 'text', value });
2992
+ continue;
2993
+ }
2994
+
2995
+ /**
2996
+ * Stars
2997
+ */
2998
+
2999
+ if (prev && (prev.type === 'globstar' || prev.star === true)) {
3000
+ prev.type = 'star';
3001
+ prev.star = true;
3002
+ prev.value += value;
3003
+ prev.output = star;
3004
+ state.backtrack = true;
3005
+ state.globstar = true;
3006
+ consume(value);
3007
+ continue;
3008
+ }
3009
+
3010
+ let rest = remaining();
3011
+ if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
3012
+ extglobOpen('star', value);
3013
+ continue;
3014
+ }
3015
+
3016
+ if (prev.type === 'star') {
3017
+ if (opts.noglobstar === true) {
3018
+ consume(value);
3019
+ continue;
3020
+ }
3021
+
3022
+ const prior = prev.prev;
3023
+ const before = prior.prev;
3024
+ const isStart = prior.type === 'slash' || prior.type === 'bos';
3025
+ const afterStar = before && (before.type === 'star' || before.type === 'globstar');
3026
+
3027
+ if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
3028
+ push({ type: 'star', value, output: '' });
3029
+ continue;
3030
+ }
3031
+
3032
+ const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
3033
+ const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
3034
+ if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
3035
+ push({ type: 'star', value, output: '' });
3036
+ continue;
3037
+ }
3038
+
3039
+ // strip consecutive `/**/`
3040
+ while (rest.slice(0, 3) === '/**') {
3041
+ const after = input[state.index + 4];
3042
+ if (after && after !== '/') {
3043
+ break;
3044
+ }
3045
+ rest = rest.slice(3);
3046
+ consume('/**', 3);
3047
+ }
3048
+
3049
+ if (prior.type === 'bos' && eos()) {
3050
+ prev.type = 'globstar';
3051
+ prev.value += value;
3052
+ prev.output = globstar(opts);
3053
+ state.output = prev.output;
3054
+ state.globstar = true;
3055
+ consume(value);
3056
+ continue;
3057
+ }
3058
+
3059
+ if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
3060
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
3061
+ prior.output = `(?:${prior.output}`;
3062
+
3063
+ prev.type = 'globstar';
3064
+ prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
3065
+ prev.value += value;
3066
+ state.globstar = true;
3067
+ state.output += prior.output + prev.output;
3068
+ consume(value);
3069
+ continue;
3070
+ }
3071
+
3072
+ if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
3073
+ const end = rest[1] !== void 0 ? '|$' : '';
3074
+
3075
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
3076
+ prior.output = `(?:${prior.output}`;
3077
+
3078
+ prev.type = 'globstar';
3079
+ prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
3080
+ prev.value += value;
3081
+
3082
+ state.output += prior.output + prev.output;
3083
+ state.globstar = true;
3084
+
3085
+ consume(value + advance());
3086
+
3087
+ push({ type: 'slash', value: '/', output: '' });
3088
+ continue;
3089
+ }
3090
+
3091
+ if (prior.type === 'bos' && rest[0] === '/') {
3092
+ prev.type = 'globstar';
3093
+ prev.value += value;
3094
+ prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
3095
+ state.output = prev.output;
3096
+ state.globstar = true;
3097
+ consume(value + advance());
3098
+ push({ type: 'slash', value: '/', output: '' });
3099
+ continue;
3100
+ }
3101
+
3102
+ // remove single star from output
3103
+ state.output = state.output.slice(0, -prev.output.length);
3104
+
3105
+ // reset previous token to globstar
3106
+ prev.type = 'globstar';
3107
+ prev.output = globstar(opts);
3108
+ prev.value += value;
3109
+
3110
+ // reset output with globstar
3111
+ state.output += prev.output;
3112
+ state.globstar = true;
3113
+ consume(value);
3114
+ continue;
3115
+ }
3116
+
3117
+ const token = { type: 'star', value, output: star };
3118
+
3119
+ if (opts.bash === true) {
3120
+ token.output = '.*?';
3121
+ if (prev.type === 'bos' || prev.type === 'slash') {
3122
+ token.output = nodot + token.output;
3123
+ }
3124
+ push(token);
3125
+ continue;
3126
+ }
3127
+
3128
+ if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
3129
+ token.output = value;
3130
+ push(token);
3131
+ continue;
3132
+ }
3133
+
3134
+ if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
3135
+ if (prev.type === 'dot') {
3136
+ state.output += NO_DOT_SLASH;
3137
+ prev.output += NO_DOT_SLASH;
3138
+
3139
+ } else if (opts.dot === true) {
3140
+ state.output += NO_DOTS_SLASH;
3141
+ prev.output += NO_DOTS_SLASH;
3142
+
3143
+ } else {
3144
+ state.output += nodot;
3145
+ prev.output += nodot;
3146
+ }
3147
+
3148
+ if (peek() !== '*') {
3149
+ state.output += ONE_CHAR;
3150
+ prev.output += ONE_CHAR;
3151
+ }
3152
+ }
3153
+
3154
+ push(token);
3155
+ }
3156
+
3157
+ while (state.brackets > 0) {
3158
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
3159
+ state.output = utils.escapeLast(state.output, '[');
3160
+ decrement('brackets');
3161
+ }
3162
+
3163
+ while (state.parens > 0) {
3164
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
3165
+ state.output = utils.escapeLast(state.output, '(');
3166
+ decrement('parens');
3167
+ }
3168
+
3169
+ while (state.braces > 0) {
3170
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
3171
+ state.output = utils.escapeLast(state.output, '{');
3172
+ decrement('braces');
3173
+ }
3174
+
3175
+ if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
3176
+ push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
3177
+ }
3178
+
3179
+ // rebuild the output if we had to backtrack at any point
3180
+ if (state.backtrack === true) {
3181
+ state.output = '';
3182
+
3183
+ for (const token of state.tokens) {
3184
+ state.output += token.output != null ? token.output : token.value;
3185
+
3186
+ if (token.suffix) {
3187
+ state.output += token.suffix;
3188
+ }
3189
+ }
3190
+ }
3191
+
3192
+ return state;
3193
+ };
3194
+
3195
+ /**
3196
+ * Fast paths for creating regular expressions for common glob patterns.
3197
+ * This can significantly speed up processing and has very little downside
3198
+ * impact when none of the fast paths match.
3199
+ */
3200
+
3201
+ parse.fastpaths = (input, options) => {
3202
+ const opts = { ...options };
3203
+ const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
3204
+ const len = input.length;
3205
+ if (len > max) {
3206
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
3207
+ }
3208
+
3209
+ input = REPLACEMENTS[input] || input;
3210
+ const win32 = utils.isWindows(options);
3211
+
3212
+ // create constants based on platform, for windows or posix
3213
+ const {
3214
+ DOT_LITERAL,
3215
+ SLASH_LITERAL,
3216
+ ONE_CHAR,
3217
+ DOTS_SLASH,
3218
+ NO_DOT,
3219
+ NO_DOTS,
3220
+ NO_DOTS_SLASH,
3221
+ STAR,
3222
+ START_ANCHOR
3223
+ } = constants.globChars(win32);
3224
+
3225
+ const nodot = opts.dot ? NO_DOTS : NO_DOT;
3226
+ const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
3227
+ const capture = opts.capture ? '' : '?:';
3228
+ const state = { negated: false, prefix: '' };
3229
+ let star = opts.bash === true ? '.*?' : STAR;
3230
+
3231
+ if (opts.capture) {
3232
+ star = `(${star})`;
3233
+ }
3234
+
3235
+ const globstar = opts => {
3236
+ if (opts.noglobstar === true) return star;
3237
+ return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
3238
+ };
3239
+
3240
+ const create = str => {
3241
+ switch (str) {
3242
+ case '*':
3243
+ return `${nodot}${ONE_CHAR}${star}`;
3244
+
3245
+ case '.*':
3246
+ return `${DOT_LITERAL}${ONE_CHAR}${star}`;
3247
+
3248
+ case '*.*':
3249
+ return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
3250
+
3251
+ case '*/*':
3252
+ return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
3253
+
3254
+ case '**':
3255
+ return nodot + globstar(opts);
3256
+
3257
+ case '**/*':
3258
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
3259
+
3260
+ case '**/*.*':
3261
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
3262
+
3263
+ case '**/.*':
3264
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
3265
+
3266
+ default: {
3267
+ const match = /^(.*?)\.(\w+)$/.exec(str);
3268
+ if (!match) return;
3269
+
3270
+ const source = create(match[1]);
3271
+ if (!source) return;
3272
+
3273
+ return source + DOT_LITERAL + match[2];
3274
+ }
3275
+ }
3276
+ };
3277
+
3278
+ const output = utils.removePrefix(input, state);
3279
+ let source = create(output);
3280
+
3281
+ if (source && opts.strictSlashes !== true) {
3282
+ source += `${SLASH_LITERAL}?`;
3283
+ }
3284
+
3285
+ return source;
3286
+ };
3287
+
3288
+ parse_1 = parse;
3289
+ return parse_1;
3290
+ }
3291
+
3292
+ var picomatch_1;
3293
+ var hasRequiredPicomatch$1;
3294
+
3295
+ function requirePicomatch$1 () {
3296
+ if (hasRequiredPicomatch$1) return picomatch_1;
3297
+ hasRequiredPicomatch$1 = 1;
3298
+
3299
+ const path = require$$0$1;
3300
+ const scan = requireScan();
3301
+ const parse = requireParse();
3302
+ const utils = requireUtils();
3303
+ const constants = requireConstants();
3304
+ const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
3305
+
3306
+ /**
3307
+ * Creates a matcher function from one or more glob patterns. The
3308
+ * returned function takes a string to match as its first argument,
3309
+ * and returns true if the string is a match. The returned matcher
3310
+ * function also takes a boolean as the second argument that, when true,
3311
+ * returns an object with additional information.
3312
+ *
3313
+ * ```js
3314
+ * const picomatch = require('picomatch');
3315
+ * // picomatch(glob[, options]);
3316
+ *
3317
+ * const isMatch = picomatch('*.!(*a)');
3318
+ * console.log(isMatch('a.a')); //=> false
3319
+ * console.log(isMatch('a.b')); //=> true
3320
+ * ```
3321
+ * @name picomatch
3322
+ * @param {String|Array} `globs` One or more glob patterns.
3323
+ * @param {Object=} `options`
3324
+ * @return {Function=} Returns a matcher function.
3325
+ * @api public
3326
+ */
3327
+
3328
+ const picomatch = (glob, options, returnState = false) => {
3329
+ if (Array.isArray(glob)) {
3330
+ const fns = glob.map(input => picomatch(input, options, returnState));
3331
+ const arrayMatcher = str => {
3332
+ for (const isMatch of fns) {
3333
+ const state = isMatch(str);
3334
+ if (state) return state;
3335
+ }
3336
+ return false;
3337
+ };
3338
+ return arrayMatcher;
3339
+ }
3340
+
3341
+ const isState = isObject(glob) && glob.tokens && glob.input;
3342
+
3343
+ if (glob === '' || (typeof glob !== 'string' && !isState)) {
3344
+ throw new TypeError('Expected pattern to be a non-empty string');
3345
+ }
3346
+
3347
+ const opts = options || {};
3348
+ const posix = utils.isWindows(options);
3349
+ const regex = isState
3350
+ ? picomatch.compileRe(glob, options)
3351
+ : picomatch.makeRe(glob, options, false, true);
3352
+
3353
+ const state = regex.state;
3354
+ delete regex.state;
3355
+
3356
+ let isIgnored = () => false;
3357
+ if (opts.ignore) {
3358
+ const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
3359
+ isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
3360
+ }
3361
+
3362
+ const matcher = (input, returnObject = false) => {
3363
+ const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
3364
+ const result = { glob, state, regex, posix, input, output, match, isMatch };
3365
+
3366
+ if (typeof opts.onResult === 'function') {
3367
+ opts.onResult(result);
3368
+ }
3369
+
3370
+ if (isMatch === false) {
3371
+ result.isMatch = false;
3372
+ return returnObject ? result : false;
3373
+ }
3374
+
3375
+ if (isIgnored(input)) {
3376
+ if (typeof opts.onIgnore === 'function') {
3377
+ opts.onIgnore(result);
3378
+ }
3379
+ result.isMatch = false;
3380
+ return returnObject ? result : false;
3381
+ }
3382
+
3383
+ if (typeof opts.onMatch === 'function') {
3384
+ opts.onMatch(result);
3385
+ }
3386
+ return returnObject ? result : true;
3387
+ };
3388
+
3389
+ if (returnState) {
3390
+ matcher.state = state;
3391
+ }
3392
+
3393
+ return matcher;
3394
+ };
3395
+
3396
+ /**
3397
+ * Test `input` with the given `regex`. This is used by the main
3398
+ * `picomatch()` function to test the input string.
3399
+ *
3400
+ * ```js
3401
+ * const picomatch = require('picomatch');
3402
+ * // picomatch.test(input, regex[, options]);
3403
+ *
3404
+ * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
3405
+ * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
3406
+ * ```
3407
+ * @param {String} `input` String to test.
3408
+ * @param {RegExp} `regex`
3409
+ * @return {Object} Returns an object with matching info.
3410
+ * @api public
3411
+ */
3412
+
3413
+ picomatch.test = (input, regex, options, { glob, posix } = {}) => {
3414
+ if (typeof input !== 'string') {
3415
+ throw new TypeError('Expected input to be a string');
3416
+ }
3417
+
3418
+ if (input === '') {
3419
+ return { isMatch: false, output: '' };
3420
+ }
3421
+
3422
+ const opts = options || {};
3423
+ const format = opts.format || (posix ? utils.toPosixSlashes : null);
3424
+ let match = input === glob;
3425
+ let output = (match && format) ? format(input) : input;
3426
+
3427
+ if (match === false) {
3428
+ output = format ? format(input) : input;
3429
+ match = output === glob;
3430
+ }
3431
+
3432
+ if (match === false || opts.capture === true) {
3433
+ if (opts.matchBase === true || opts.basename === true) {
3434
+ match = picomatch.matchBase(input, regex, options, posix);
3435
+ } else {
3436
+ match = regex.exec(output);
3437
+ }
3438
+ }
3439
+
3440
+ return { isMatch: Boolean(match), match, output };
3441
+ };
3442
+
3443
+ /**
3444
+ * Match the basename of a filepath.
3445
+ *
3446
+ * ```js
3447
+ * const picomatch = require('picomatch');
3448
+ * // picomatch.matchBase(input, glob[, options]);
3449
+ * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
3450
+ * ```
3451
+ * @param {String} `input` String to test.
3452
+ * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
3453
+ * @return {Boolean}
3454
+ * @api public
3455
+ */
3456
+
3457
+ picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
3458
+ const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
3459
+ return regex.test(path.basename(input));
3460
+ };
3461
+
3462
+ /**
3463
+ * Returns true if **any** of the given glob `patterns` match the specified `string`.
3464
+ *
3465
+ * ```js
3466
+ * const picomatch = require('picomatch');
3467
+ * // picomatch.isMatch(string, patterns[, options]);
3468
+ *
3469
+ * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
3470
+ * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
3471
+ * ```
3472
+ * @param {String|Array} str The string to test.
3473
+ * @param {String|Array} patterns One or more glob patterns to use for matching.
3474
+ * @param {Object} [options] See available [options](#options).
3475
+ * @return {Boolean} Returns true if any patterns match `str`
3476
+ * @api public
3477
+ */
3478
+
3479
+ picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
3480
+
3481
+ /**
3482
+ * Parse a glob pattern to create the source string for a regular
3483
+ * expression.
3484
+ *
3485
+ * ```js
3486
+ * const picomatch = require('picomatch');
3487
+ * const result = picomatch.parse(pattern[, options]);
3488
+ * ```
3489
+ * @param {String} `pattern`
3490
+ * @param {Object} `options`
3491
+ * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
3492
+ * @api public
3493
+ */
3494
+
3495
+ picomatch.parse = (pattern, options) => {
3496
+ if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
3497
+ return parse(pattern, { ...options, fastpaths: false });
3498
+ };
3499
+
3500
+ /**
3501
+ * Scan a glob pattern to separate the pattern into segments.
3502
+ *
3503
+ * ```js
3504
+ * const picomatch = require('picomatch');
3505
+ * // picomatch.scan(input[, options]);
3506
+ *
3507
+ * const result = picomatch.scan('!./foo/*.js');
3508
+ * console.log(result);
3509
+ * { prefix: '!./',
3510
+ * input: '!./foo/*.js',
3511
+ * start: 3,
3512
+ * base: 'foo',
3513
+ * glob: '*.js',
3514
+ * isBrace: false,
3515
+ * isBracket: false,
3516
+ * isGlob: true,
3517
+ * isExtglob: false,
3518
+ * isGlobstar: false,
3519
+ * negated: true }
3520
+ * ```
3521
+ * @param {String} `input` Glob pattern to scan.
3522
+ * @param {Object} `options`
3523
+ * @return {Object} Returns an object with
3524
+ * @api public
3525
+ */
3526
+
3527
+ picomatch.scan = (input, options) => scan(input, options);
3528
+
3529
+ /**
3530
+ * Compile a regular expression from the `state` object returned by the
3531
+ * [parse()](#parse) method.
3532
+ *
3533
+ * @param {Object} `state`
3534
+ * @param {Object} `options`
3535
+ * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
3536
+ * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
3537
+ * @return {RegExp}
3538
+ * @api public
3539
+ */
3540
+
3541
+ picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
3542
+ if (returnOutput === true) {
3543
+ return state.output;
3544
+ }
3545
+
3546
+ const opts = options || {};
3547
+ const prepend = opts.contains ? '' : '^';
3548
+ const append = opts.contains ? '' : '$';
3549
+
3550
+ let source = `${prepend}(?:${state.output})${append}`;
3551
+ if (state && state.negated === true) {
3552
+ source = `^(?!${source}).*$`;
3553
+ }
3554
+
3555
+ const regex = picomatch.toRegex(source, options);
3556
+ if (returnState === true) {
3557
+ regex.state = state;
3558
+ }
3559
+
3560
+ return regex;
3561
+ };
3562
+
3563
+ /**
3564
+ * Create a regular expression from a parsed glob pattern.
3565
+ *
3566
+ * ```js
3567
+ * const picomatch = require('picomatch');
3568
+ * const state = picomatch.parse('*.js');
3569
+ * // picomatch.compileRe(state[, options]);
3570
+ *
3571
+ * console.log(picomatch.compileRe(state));
3572
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
3573
+ * ```
3574
+ * @param {String} `state` The object returned from the `.parse` method.
3575
+ * @param {Object} `options`
3576
+ * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
3577
+ * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
3578
+ * @return {RegExp} Returns a regex created from the given pattern.
3579
+ * @api public
3580
+ */
3581
+
3582
+ picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
3583
+ if (!input || typeof input !== 'string') {
3584
+ throw new TypeError('Expected a non-empty string');
3585
+ }
3586
+
3587
+ let parsed = { negated: false, fastpaths: true };
3588
+
3589
+ if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
3590
+ parsed.output = parse.fastpaths(input, options);
3591
+ }
3592
+
3593
+ if (!parsed.output) {
3594
+ parsed = parse(input, options);
3595
+ }
3596
+
3597
+ return picomatch.compileRe(parsed, options, returnOutput, returnState);
3598
+ };
3599
+
3600
+ /**
3601
+ * Create a regular expression from the given regex source string.
3602
+ *
3603
+ * ```js
3604
+ * const picomatch = require('picomatch');
3605
+ * // picomatch.toRegex(source[, options]);
3606
+ *
3607
+ * const { output } = picomatch.parse('*.js');
3608
+ * console.log(picomatch.toRegex(output));
3609
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
3610
+ * ```
3611
+ * @param {String} `source` Regular expression source string.
3612
+ * @param {Object} `options`
3613
+ * @return {RegExp}
3614
+ * @api public
3615
+ */
3616
+
3617
+ picomatch.toRegex = (source, options) => {
3618
+ try {
3619
+ const opts = options || {};
3620
+ return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
3621
+ } catch (err) {
3622
+ if (options && options.debug === true) throw err;
3623
+ return /$^/;
3624
+ }
3625
+ };
3626
+
3627
+ /**
3628
+ * Picomatch constants.
3629
+ * @return {Object}
3630
+ */
3631
+
3632
+ picomatch.constants = constants;
3633
+
3634
+ /**
3635
+ * Expose "picomatch"
3636
+ */
3637
+
3638
+ picomatch_1 = picomatch;
3639
+ return picomatch_1;
3640
+ }
3641
+
3642
+ var picomatch;
3643
+ var hasRequiredPicomatch;
3644
+
3645
+ function requirePicomatch () {
3646
+ if (hasRequiredPicomatch) return picomatch;
3647
+ hasRequiredPicomatch = 1;
3648
+
3649
+ picomatch = requirePicomatch$1();
3650
+ return picomatch;
3651
+ }
3652
+
3653
+ var micromatch_1;
3654
+ var hasRequiredMicromatch;
3655
+
3656
+ function requireMicromatch () {
3657
+ if (hasRequiredMicromatch) return micromatch_1;
3658
+ hasRequiredMicromatch = 1;
3659
+
3660
+ const util = require$$0;
3661
+ const braces = requireBraces();
3662
+ const picomatch = requirePicomatch();
3663
+ const utils = requireUtils();
3664
+ const isEmptyString = val => val === '' || val === './';
3665
+
3666
+ /**
3667
+ * Returns an array of strings that match one or more glob patterns.
3668
+ *
3669
+ * ```js
3670
+ * const mm = require('micromatch');
3671
+ * // mm(list, patterns[, options]);
3672
+ *
3673
+ * console.log(mm(['a.js', 'a.txt'], ['*.js']));
3674
+ * //=> [ 'a.js' ]
3675
+ * ```
3676
+ * @param {String|Array<string>} `list` List of strings to match.
3677
+ * @param {String|Array<string>} `patterns` One or more glob patterns to use for matching.
3678
+ * @param {Object} `options` See available [options](#options)
3679
+ * @return {Array} Returns an array of matches
3680
+ * @summary false
3681
+ * @api public
3682
+ */
3683
+
3684
+ const micromatch = (list, patterns, options) => {
3685
+ patterns = [].concat(patterns);
3686
+ list = [].concat(list);
3687
+
3688
+ let omit = new Set();
3689
+ let keep = new Set();
3690
+ let items = new Set();
3691
+ let negatives = 0;
3692
+
3693
+ let onResult = state => {
3694
+ items.add(state.output);
3695
+ if (options && options.onResult) {
3696
+ options.onResult(state);
3697
+ }
3698
+ };
3699
+
3700
+ for (let i = 0; i < patterns.length; i++) {
3701
+ let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
3702
+ let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
3703
+ if (negated) negatives++;
3704
+
3705
+ for (let item of list) {
3706
+ let matched = isMatch(item, true);
3707
+
3708
+ let match = negated ? !matched.isMatch : matched.isMatch;
3709
+ if (!match) continue;
3710
+
3711
+ if (negated) {
3712
+ omit.add(matched.output);
3713
+ } else {
3714
+ omit.delete(matched.output);
3715
+ keep.add(matched.output);
3716
+ }
3717
+ }
3718
+ }
3719
+
3720
+ let result = negatives === patterns.length ? [...items] : [...keep];
3721
+ let matches = result.filter(item => !omit.has(item));
3722
+
3723
+ if (options && matches.length === 0) {
3724
+ if (options.failglob === true) {
3725
+ throw new Error(`No matches found for "${patterns.join(', ')}"`);
3726
+ }
3727
+
3728
+ if (options.nonull === true || options.nullglob === true) {
3729
+ return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns;
3730
+ }
3731
+ }
3732
+
3733
+ return matches;
3734
+ };
3735
+
3736
+ /**
3737
+ * Backwards compatibility
3738
+ */
3739
+
3740
+ micromatch.match = micromatch;
3741
+
3742
+ /**
3743
+ * Returns a matcher function from the given glob `pattern` and `options`.
3744
+ * The returned function takes a string to match as its only argument and returns
3745
+ * true if the string is a match.
3746
+ *
3747
+ * ```js
3748
+ * const mm = require('micromatch');
3749
+ * // mm.matcher(pattern[, options]);
3750
+ *
3751
+ * const isMatch = mm.matcher('*.!(*a)');
3752
+ * console.log(isMatch('a.a')); //=> false
3753
+ * console.log(isMatch('a.b')); //=> true
3754
+ * ```
3755
+ * @param {String} `pattern` Glob pattern
3756
+ * @param {Object} `options`
3757
+ * @return {Function} Returns a matcher function.
3758
+ * @api public
3759
+ */
3760
+
3761
+ micromatch.matcher = (pattern, options) => picomatch(pattern, options);
3762
+
3763
+ /**
3764
+ * Returns true if **any** of the given glob `patterns` match the specified `string`.
3765
+ *
3766
+ * ```js
3767
+ * const mm = require('micromatch');
3768
+ * // mm.isMatch(string, patterns[, options]);
3769
+ *
3770
+ * console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true
3771
+ * console.log(mm.isMatch('a.a', 'b.*')); //=> false
3772
+ * ```
3773
+ * @param {String} `str` The string to test.
3774
+ * @param {String|Array} `patterns` One or more glob patterns to use for matching.
3775
+ * @param {Object} `[options]` See available [options](#options).
3776
+ * @return {Boolean} Returns true if any patterns match `str`
3777
+ * @api public
3778
+ */
3779
+
3780
+ micromatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
3781
+
3782
+ /**
3783
+ * Backwards compatibility
3784
+ */
3785
+
3786
+ micromatch.any = micromatch.isMatch;
3787
+
3788
+ /**
3789
+ * Returns a list of strings that _**do not match any**_ of the given `patterns`.
3790
+ *
3791
+ * ```js
3792
+ * const mm = require('micromatch');
3793
+ * // mm.not(list, patterns[, options]);
3794
+ *
3795
+ * console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
3796
+ * //=> ['b.b', 'c.c']
3797
+ * ```
3798
+ * @param {Array} `list` Array of strings to match.
3799
+ * @param {String|Array} `patterns` One or more glob pattern to use for matching.
3800
+ * @param {Object} `options` See available [options](#options) for changing how matches are performed
3801
+ * @return {Array} Returns an array of strings that **do not match** the given patterns.
3802
+ * @api public
3803
+ */
3804
+
3805
+ micromatch.not = (list, patterns, options = {}) => {
3806
+ patterns = [].concat(patterns).map(String);
3807
+ let result = new Set();
3808
+ let items = [];
3809
+
3810
+ let onResult = state => {
3811
+ if (options.onResult) options.onResult(state);
3812
+ items.push(state.output);
3813
+ };
3814
+
3815
+ let matches = new Set(micromatch(list, patterns, { ...options, onResult }));
3816
+
3817
+ for (let item of items) {
3818
+ if (!matches.has(item)) {
3819
+ result.add(item);
3820
+ }
3821
+ }
3822
+ return [...result];
3823
+ };
3824
+
3825
+ /**
3826
+ * Returns true if the given `string` contains the given pattern. Similar
3827
+ * to [.isMatch](#isMatch) but the pattern can match any part of the string.
3828
+ *
3829
+ * ```js
3830
+ * var mm = require('micromatch');
3831
+ * // mm.contains(string, pattern[, options]);
3832
+ *
3833
+ * console.log(mm.contains('aa/bb/cc', '*b'));
3834
+ * //=> true
3835
+ * console.log(mm.contains('aa/bb/cc', '*d'));
3836
+ * //=> false
3837
+ * ```
3838
+ * @param {String} `str` The string to match.
3839
+ * @param {String|Array} `patterns` Glob pattern to use for matching.
3840
+ * @param {Object} `options` See available [options](#options) for changing how matches are performed
3841
+ * @return {Boolean} Returns true if any of the patterns matches any part of `str`.
3842
+ * @api public
3843
+ */
3844
+
3845
+ micromatch.contains = (str, pattern, options) => {
3846
+ if (typeof str !== 'string') {
3847
+ throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
3848
+ }
3849
+
3850
+ if (Array.isArray(pattern)) {
3851
+ return pattern.some(p => micromatch.contains(str, p, options));
3852
+ }
3853
+
3854
+ if (typeof pattern === 'string') {
3855
+ if (isEmptyString(str) || isEmptyString(pattern)) {
3856
+ return false;
3857
+ }
3858
+
3859
+ if (str.includes(pattern) || (str.startsWith('./') && str.slice(2).includes(pattern))) {
3860
+ return true;
3861
+ }
3862
+ }
3863
+
3864
+ return micromatch.isMatch(str, pattern, { ...options, contains: true });
3865
+ };
3866
+
3867
+ /**
3868
+ * Filter the keys of the given object with the given `glob` pattern
3869
+ * and `options`. Does not attempt to match nested keys. If you need this feature,
3870
+ * use [glob-object][] instead.
3871
+ *
3872
+ * ```js
3873
+ * const mm = require('micromatch');
3874
+ * // mm.matchKeys(object, patterns[, options]);
3875
+ *
3876
+ * const obj = { aa: 'a', ab: 'b', ac: 'c' };
3877
+ * console.log(mm.matchKeys(obj, '*b'));
3878
+ * //=> { ab: 'b' }
3879
+ * ```
3880
+ * @param {Object} `object` The object with keys to filter.
3881
+ * @param {String|Array} `patterns` One or more glob patterns to use for matching.
3882
+ * @param {Object} `options` See available [options](#options) for changing how matches are performed
3883
+ * @return {Object} Returns an object with only keys that match the given patterns.
3884
+ * @api public
3885
+ */
3886
+
3887
+ micromatch.matchKeys = (obj, patterns, options) => {
3888
+ if (!utils.isObject(obj)) {
3889
+ throw new TypeError('Expected the first argument to be an object');
3890
+ }
3891
+ let keys = micromatch(Object.keys(obj), patterns, options);
3892
+ let res = {};
3893
+ for (let key of keys) res[key] = obj[key];
3894
+ return res;
3895
+ };
3896
+
3897
+ /**
3898
+ * Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
3899
+ *
3900
+ * ```js
3901
+ * const mm = require('micromatch');
3902
+ * // mm.some(list, patterns[, options]);
3903
+ *
3904
+ * console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
3905
+ * // true
3906
+ * console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
3907
+ * // false
3908
+ * ```
3909
+ * @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found.
3910
+ * @param {String|Array} `patterns` One or more glob patterns to use for matching.
3911
+ * @param {Object} `options` See available [options](#options) for changing how matches are performed
3912
+ * @return {Boolean} Returns true if any `patterns` matches any of the strings in `list`
3913
+ * @api public
3914
+ */
3915
+
3916
+ micromatch.some = (list, patterns, options) => {
3917
+ let items = [].concat(list);
3918
+
3919
+ for (let pattern of [].concat(patterns)) {
3920
+ let isMatch = picomatch(String(pattern), options);
3921
+ if (items.some(item => isMatch(item))) {
3922
+ return true;
3923
+ }
3924
+ }
3925
+ return false;
3926
+ };
3927
+
3928
+ /**
3929
+ * Returns true if every string in the given `list` matches
3930
+ * any of the given glob `patterns`.
3931
+ *
3932
+ * ```js
3933
+ * const mm = require('micromatch');
3934
+ * // mm.every(list, patterns[, options]);
3935
+ *
3936
+ * console.log(mm.every('foo.js', ['foo.js']));
3937
+ * // true
3938
+ * console.log(mm.every(['foo.js', 'bar.js'], ['*.js']));
3939
+ * // true
3940
+ * console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
3941
+ * // false
3942
+ * console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
3943
+ * // false
3944
+ * ```
3945
+ * @param {String|Array} `list` The string or array of strings to test.
3946
+ * @param {String|Array} `patterns` One or more glob patterns to use for matching.
3947
+ * @param {Object} `options` See available [options](#options) for changing how matches are performed
3948
+ * @return {Boolean} Returns true if all `patterns` matches all of the strings in `list`
3949
+ * @api public
3950
+ */
3951
+
3952
+ micromatch.every = (list, patterns, options) => {
3953
+ let items = [].concat(list);
3954
+
3955
+ for (let pattern of [].concat(patterns)) {
3956
+ let isMatch = picomatch(String(pattern), options);
3957
+ if (!items.every(item => isMatch(item))) {
3958
+ return false;
3959
+ }
3960
+ }
3961
+ return true;
3962
+ };
3963
+
3964
+ /**
3965
+ * Returns true if **all** of the given `patterns` match
3966
+ * the specified string.
3967
+ *
3968
+ * ```js
3969
+ * const mm = require('micromatch');
3970
+ * // mm.all(string, patterns[, options]);
3971
+ *
3972
+ * console.log(mm.all('foo.js', ['foo.js']));
3973
+ * // true
3974
+ *
3975
+ * console.log(mm.all('foo.js', ['*.js', '!foo.js']));
3976
+ * // false
3977
+ *
3978
+ * console.log(mm.all('foo.js', ['*.js', 'foo.js']));
3979
+ * // true
3980
+ *
3981
+ * console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
3982
+ * // true
3983
+ * ```
3984
+ * @param {String|Array} `str` The string to test.
3985
+ * @param {String|Array} `patterns` One or more glob patterns to use for matching.
3986
+ * @param {Object} `options` See available [options](#options) for changing how matches are performed
3987
+ * @return {Boolean} Returns true if any patterns match `str`
3988
+ * @api public
3989
+ */
3990
+
3991
+ micromatch.all = (str, patterns, options) => {
3992
+ if (typeof str !== 'string') {
3993
+ throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
3994
+ }
3995
+
3996
+ return [].concat(patterns).every(p => picomatch(p, options)(str));
3997
+ };
3998
+
3999
+ /**
4000
+ * Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match.
4001
+ *
4002
+ * ```js
4003
+ * const mm = require('micromatch');
4004
+ * // mm.capture(pattern, string[, options]);
4005
+ *
4006
+ * console.log(mm.capture('test/*.js', 'test/foo.js'));
4007
+ * //=> ['foo']
4008
+ * console.log(mm.capture('test/*.js', 'foo/bar.css'));
4009
+ * //=> null
4010
+ * ```
4011
+ * @param {String} `glob` Glob pattern to use for matching.
4012
+ * @param {String} `input` String to match
4013
+ * @param {Object} `options` See available [options](#options) for changing how matches are performed
4014
+ * @return {Array|null} Returns an array of captures if the input matches the glob pattern, otherwise `null`.
4015
+ * @api public
4016
+ */
4017
+
4018
+ micromatch.capture = (glob, input, options) => {
4019
+ let posix = utils.isWindows(options);
4020
+ let regex = picomatch.makeRe(String(glob), { ...options, capture: true });
4021
+ let match = regex.exec(posix ? utils.toPosixSlashes(input) : input);
4022
+
4023
+ if (match) {
4024
+ return match.slice(1).map(v => v === void 0 ? '' : v);
4025
+ }
4026
+ };
4027
+
4028
+ /**
4029
+ * Create a regular expression from the given glob `pattern`.
4030
+ *
4031
+ * ```js
4032
+ * const mm = require('micromatch');
4033
+ * // mm.makeRe(pattern[, options]);
4034
+ *
4035
+ * console.log(mm.makeRe('*.js'));
4036
+ * //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
4037
+ * ```
4038
+ * @param {String} `pattern` A glob pattern to convert to regex.
4039
+ * @param {Object} `options`
4040
+ * @return {RegExp} Returns a regex created from the given pattern.
4041
+ * @api public
4042
+ */
4043
+
4044
+ micromatch.makeRe = (...args) => picomatch.makeRe(...args);
4045
+
4046
+ /**
4047
+ * Scan a glob pattern to separate the pattern into segments. Used
4048
+ * by the [split](#split) method.
4049
+ *
4050
+ * ```js
4051
+ * const mm = require('micromatch');
4052
+ * const state = mm.scan(pattern[, options]);
4053
+ * ```
4054
+ * @param {String} `pattern`
4055
+ * @param {Object} `options`
4056
+ * @return {Object} Returns an object with
4057
+ * @api public
4058
+ */
4059
+
4060
+ micromatch.scan = (...args) => picomatch.scan(...args);
4061
+
4062
+ /**
4063
+ * Parse a glob pattern to create the source string for a regular
4064
+ * expression.
4065
+ *
4066
+ * ```js
4067
+ * const mm = require('micromatch');
4068
+ * const state = mm.parse(pattern[, options]);
4069
+ * ```
4070
+ * @param {String} `glob`
4071
+ * @param {Object} `options`
4072
+ * @return {Object} Returns an object with useful properties and output to be used as regex source string.
4073
+ * @api public
4074
+ */
4075
+
4076
+ micromatch.parse = (patterns, options) => {
4077
+ let res = [];
4078
+ for (let pattern of [].concat(patterns || [])) {
4079
+ for (let str of braces(String(pattern), options)) {
4080
+ res.push(picomatch.parse(str, options));
4081
+ }
4082
+ }
4083
+ return res;
4084
+ };
4085
+
4086
+ /**
4087
+ * Process the given brace `pattern`.
4088
+ *
4089
+ * ```js
4090
+ * const { braces } = require('micromatch');
4091
+ * console.log(braces('foo/{a,b,c}/bar'));
4092
+ * //=> [ 'foo/(a|b|c)/bar' ]
4093
+ *
4094
+ * console.log(braces('foo/{a,b,c}/bar', { expand: true }));
4095
+ * //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ]
4096
+ * ```
4097
+ * @param {String} `pattern` String with brace pattern to process.
4098
+ * @param {Object} `options` Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options.
4099
+ * @return {Array}
4100
+ * @api public
4101
+ */
4102
+
4103
+ micromatch.braces = (pattern, options) => {
4104
+ if (typeof pattern !== 'string') throw new TypeError('Expected a string');
4105
+ if ((options && options.nobrace === true) || !/\{.*\}/.test(pattern)) {
4106
+ return [pattern];
4107
+ }
4108
+ return braces(pattern, options);
4109
+ };
4110
+
4111
+ /**
4112
+ * Expand braces
4113
+ */
4114
+
4115
+ micromatch.braceExpand = (pattern, options) => {
4116
+ if (typeof pattern !== 'string') throw new TypeError('Expected a string');
4117
+ return micromatch.braces(pattern, { ...options, expand: true });
4118
+ };
4119
+
4120
+ /**
4121
+ * Expose micromatch
4122
+ */
4123
+
4124
+ micromatch_1 = micromatch;
4125
+ return micromatch_1;
4126
+ }
4127
+
4128
+ var micromatchExports = requireMicromatch();
4129
+
4130
+ const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
4131
+ function getExports({
4132
+ entrypoints: entrypoints$1,
4133
+ pkgIsModule,
4134
+ entries,
4135
+ config,
4136
+ dir,
4137
+ noFilter,
4138
+ withSource,
4139
+ withSuffix
4140
+ }) {
4141
+ const dirResolve = (...paths) => path.resolve(dir ?? process.cwd(), ...paths);
4142
+ const dirRelative = (path$1) => path.relative(dir ?? process.cwd(), path$1);
4143
+ const { build = {} } = config ?? {};
4144
+ const {
4145
+ crossModuleConvertor = true
4146
+ } = build;
4147
+ const jsOutdir = `./${dirRelative(dirResolve(
4148
+ (typeof build?.output?.dir === "object" ? build.output.dir.js : build?.output?.dir) ?? "dist"
4149
+ ))}`;
4150
+ const [, resolvedEntrypoints] = entrypoints.resolveEntrypoints(entrypoints$1);
4151
+ if (entries) {
4152
+ Object.entries(resolvedEntrypoints).forEach(([key]) => {
4153
+ if (!entries.some((e) => micromatchExports.isMatch(key, e, { matchBase: true }))) {
4154
+ delete resolvedEntrypoints[key];
4155
+ }
4156
+ });
4157
+ }
4158
+ const filteredResolvedEntrypoints = noFilter ? resolvedEntrypoints : entrypoints.filterLeafs(
4159
+ resolvedEntrypoints,
4160
+ {
4161
+ skipValue: [
4162
+ // ignore values that filename starts with `.jk-noentry`
4163
+ /(^|\/)\.jk-noentry/,
4164
+ ...entrypoints.DEFAULT_SKIP_VALUES
4165
+ ]
4166
+ }
4167
+ );
4168
+ const crossModuleWithConditional = crossModuleConvertor ? {
4169
+ import: (opts) => !pkgIsModule && intersection(
4170
+ new Set(opts.conditionals),
4171
+ /* @__PURE__ */ new Set(["import", "module"])
4172
+ ).size === 0 ? opts.dist.replace(/\.js$/, ".mjs") : false,
4173
+ require: (opts) => pkgIsModule && intersection(
4174
+ new Set(opts.conditionals),
4175
+ /* @__PURE__ */ new Set(["require", "node"])
4176
+ ).size === 0 ? opts.dist.replace(/\.js$/, ".cjs") : false
4177
+ } : {};
4178
+ return [
4179
+ filteredResolvedEntrypoints,
4180
+ entrypoints.entrypoints2Exports(filteredResolvedEntrypoints, {
4181
+ outdir: jsOutdir,
4182
+ withSource,
4183
+ withSuffix,
4184
+ withConditional: {
4185
+ ...crossModuleWithConditional
4186
+ }
4187
+ })
4188
+ ];
4189
+ }
4190
+
4191
+ let root;
4192
+ function getRoot() {
4193
+ if (root)
4194
+ return root;
4195
+ const rootOption = commander.program.getOptionValue("root");
4196
+ root = rootOption ? path.isAbsolute(rootOption) ? rootOption : path.resolve(process.cwd(), rootOption) : void 0;
4197
+ return root;
4198
+ }
4199
+
4200
+ let type = "";
4201
+ try {
4202
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4203
+ require$1.resolve("@pnpm/filter-workspace-packages");
4204
+ type = "pnpm";
4205
+ } catch {
4206
+ }
4207
+ if (type !== "") {
4208
+ commander.program.option("-f, --filter <filter>", "filter packages");
4209
+ }
4210
+
4211
+ let wd;
4212
+ let notWorkspace = false;
4213
+ function getWD() {
4214
+ if (wd)
4215
+ return { wd, notWorkspace };
4216
+ const root = getRoot();
4217
+ if (root !== void 0) {
4218
+ const isWorkspace = getWorkspaceDir.isWorkspaceDir(root, type);
4219
+ notWorkspace = !isWorkspace;
4220
+ wd = root;
4221
+ return { wd, notWorkspace };
4222
+ }
4223
+ try {
4224
+ wd = getWorkspaceDir.getWorkspaceDir(type);
4225
+ } catch (e) {
4226
+ if ("message" in e && e.message === "workspace root not found") {
4227
+ wd = root;
4228
+ notWorkspace = true;
4229
+ } else {
4230
+ throw e;
4231
+ }
4232
+ }
4233
+ return { wd, notWorkspace };
4234
+ }
4235
+
4236
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
4237
+ function packageIsExist(name) {
4238
+ try {
4239
+ require$1.resolve(name);
4240
+ return true;
4241
+ } catch (e) {
4242
+ return false;
4243
+ }
4244
+ }
4245
+ let tsRegisterName;
4246
+ const registers = [
4247
+ process.env.JIEK_TS_REGISTER,
4248
+ "esbuild-register",
4249
+ "@swc-node/register",
4250
+ "ts-node/register"
4251
+ ].filter(Boolean);
4252
+ for (const register of registers) {
4253
+ if (packageIsExist(register)) {
4254
+ tsRegisterName = register;
4255
+ break;
4256
+ }
4257
+ }
4258
+
4259
+ let configName = "jiek.config";
4260
+ function getConfigPath(root, dir) {
4261
+ const isSupportTsLoader = !!tsRegisterName;
4262
+ function configWithExtIsExist(ext) {
4263
+ const filenames = [
4264
+ path.resolve(process.cwd(), `${configName}.${ext}`),
4265
+ path.resolve(process.cwd(), `.${configName}.${ext}`),
4266
+ path.resolve(root, `${configName}.${ext}`),
4267
+ path.resolve(root, `.${configName}.${ext}`)
4268
+ ];
4269
+ if (dir) {
4270
+ filenames.unshift(...[
4271
+ path.resolve(dir, `${configName}.${ext}`),
4272
+ path.resolve(dir, `.${configName}.${ext}`)
4273
+ ]);
4274
+ }
4275
+ for (const filename of filenames) {
4276
+ if (fs.existsSync(filename) && fs.lstatSync(filename).isFile()) {
4277
+ return filename;
4278
+ }
4279
+ }
4280
+ return;
4281
+ }
4282
+ configName = configWithExtIsExist("js") ?? configName;
4283
+ configName = configWithExtIsExist("json") ?? configName;
4284
+ configName = configWithExtIsExist("yaml") ?? configName;
4285
+ if (isSupportTsLoader) {
4286
+ configName = configWithExtIsExist("ts") ?? configName;
4287
+ }
4288
+ return path.resolve(root, configName);
4289
+ }
4290
+ function loadConfig(dir) {
4291
+ const { wd: root } = getWD();
4292
+ let configPath = commander.program.getOptionValue("configPath");
4293
+ if (!configPath) {
4294
+ configPath = getConfigPath(root, dir);
4295
+ } else {
4296
+ if (!fs.existsSync(configPath)) {
4297
+ throw new Error(`config file not found: ${configPath}`);
4298
+ }
4299
+ if (!path.isAbsolute(configPath)) {
4300
+ configPath = path.resolve(root, configPath);
4301
+ }
4302
+ }
4303
+ const ext = path.extname(configPath);
4304
+ let module;
4305
+ switch (ext) {
4306
+ case ".js":
4307
+ module = require(configPath);
4308
+ break;
4309
+ case ".json":
4310
+ return require(configPath);
4311
+ case ".yaml":
4312
+ return jsYaml.load(fs.readFileSync(configPath, "utf-8"));
4313
+ case ".ts":
4314
+ if (tsRegisterName) {
4315
+ require(tsRegisterName);
4316
+ module = require(configPath);
4317
+ break;
4318
+ }
4319
+ throw new Error(
4320
+ "ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register"
4321
+ );
4322
+ case ".config":
4323
+ module = {};
4324
+ break;
4325
+ default:
4326
+ throw new Error(`unsupported config file type: ${ext}`);
4327
+ }
4328
+ if (!module)
4329
+ throw new Error("config file is empty");
4330
+ return module.default ?? module;
4331
+ }
4332
+
4333
+ var progress = (options = {}) => {
4334
+ const { onEvent } = options;
4335
+ return {
4336
+ name: "progress",
4337
+ buildStart: () => onEvent?.("start", "Start building..."),
4338
+ buildEnd: () => onEvent?.("end", "Build completed!"),
4339
+ resolveId: {
4340
+ order: "post",
4341
+ handler: (source) => onEvent?.("resolve", `Resolving ${source}...`)
4342
+ },
4343
+ load: {
4344
+ order: "post",
4345
+ handler: (id) => onEvent?.("load", `Loading ${id}...`)
4346
+ },
4347
+ transform: {
4348
+ order: "post",
4349
+ handler: (_, id) => onEvent?.("transform", `Transforming ${id}...`)
4350
+ }
4351
+ };
4352
+ };
4353
+
4354
+ var skip = (options = {}) => {
4355
+ return {
4356
+ name: "skip",
4357
+ // skip the specified files by `options.patterns`
4358
+ load(id) {
4359
+ if (options.patterns?.some(
4360
+ (pattern) => typeof pattern === "string" ? id.includes(pattern) : pattern.test(id)
4361
+ )) {
4362
+ return "";
4363
+ }
4364
+ }
4365
+ };
4366
+ };
4367
+
4368
+ function externalResolver(jsonOrPath = process.cwd()) {
4369
+ const pkg = typeof jsonOrPath === "string" ? fs.existsSync(`${jsonOrPath}/package.json`) ? JSON.parse(fs.readFileSync(`${jsonOrPath}/package.json`, "utf-8")) : {} : jsonOrPath;
4370
+ const { dependencies = {}, peerDependencies = {}, optionalDependencies = {} } = pkg;
4371
+ const external = Object.keys(dependencies).concat(Object.keys(peerDependencies)).concat(Object.keys(optionalDependencies));
4372
+ return external.map((dep) => new RegExp(`^${dep}(/.*)?$`)).concat([
4373
+ /^node:/
4374
+ ]);
4375
+ }
4376
+
4377
+ const {
4378
+ JIEK_ROOT,
4379
+ JIEK_ENTRIES
4380
+ } = process.env;
4381
+ const WORKSPACE_ROOT = JIEK_ROOT ?? getWorkspaceDir.getWorkspaceDir();
4382
+ const COMMON_OPTIONS = {};
4383
+ const COMMON_PLUGINS = [
4384
+ json()
4385
+ ];
4386
+ const config = loadConfig() ?? {};
4387
+ const { build = {} } = config;
4388
+ const jsOutdir = `./${path.relative(
4389
+ process.cwd(),
4390
+ path.resolve(
4391
+ (typeof build?.output?.dir === "object" ? build.output.dir.js : build?.output?.dir) ?? "dist"
4392
+ )
4393
+ )}`;
4394
+ const STYLE_REGEXP = /\.(css|s[ac]ss|less|styl)$/;
4395
+ const resolveWorkspacePath = (p) => path.resolve(WORKSPACE_ROOT, p);
4396
+ const pascalCase = (str) => str.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()).replace(/(?:^|-)(\w)/g, (_, $1) => $1.toUpperCase());
4397
+ const reveal = (obj, keys) => keys.reduce((acc, key) => {
4398
+ if (typeof acc === "string")
4399
+ throw new Error("key not found in exports");
4400
+ if (!(key in acc))
4401
+ throw new Error(`key ${key} not found in exports`);
4402
+ return acc[key];
4403
+ }, obj);
4404
+ const withMinify = (output, minify = build?.output?.minify) => minify === false ? [output] : minify === "only-minify" ? [{
4405
+ ...output,
4406
+ // TODO replace suffix when pubish to npm and the `build.output.minify` is 'only-minify'
4407
+ // TODO resolve dts output file name
4408
+ file: output.file?.replace(/(\.[cm]?js)$/, ".min$1"),
4409
+ plugins: [
4410
+ ...output.plugins ?? [],
4411
+ terser()
4412
+ ]
4413
+ }] : [
4414
+ output,
4415
+ {
4416
+ ...output,
4417
+ file: output.file?.replace(/(\.[cm]?js)$/, ".min$1"),
4418
+ plugins: [
4419
+ ...output.plugins ?? [],
4420
+ terser()
4421
+ ]
4422
+ }
4423
+ ];
4424
+ const getTSConfig = (p) => !fs.existsSync(p) || !fs.statSync(p).isFile() ? {} : jsoncParser.parse(fs.readFileSync(p, "utf-8"), [], { allowTrailingComma: true, allowEmptyContent: true });
4425
+ const getExtendTSConfig = (tsconfigPath) => {
4426
+ tsconfigPath = path.resolve(tsconfigPath);
4427
+ const tsconfigPathDirname = path.dirname(tsconfigPath);
4428
+ const { extends: exts, ...tsconfig } = getTSConfig(tsconfigPath);
4429
+ const resolvePaths = (paths) => paths?.map((p) => path.resolve(tsconfigPathDirname, p)) ?? [];
4430
+ const extendsPaths = resolvePaths(
4431
+ exts ? Array.isArray(exts) ? exts : [exts] : []
4432
+ );
4433
+ if (extendsPaths.length === 0)
4434
+ return tsconfig;
4435
+ return extendsPaths.map(getExtendTSConfig).reduce((acc, { compilerOptions = {}, references: _, ...curr }) => ({
4436
+ ...acc,
4437
+ ...curr,
4438
+ compilerOptions: {
4439
+ ...acc.compilerOptions,
4440
+ ...compilerOptions
4441
+ }
4442
+ }), tsconfig);
4443
+ };
4444
+ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
4445
+ tsconfigPath = path.resolve(tsconfigPath);
4446
+ filePath = path.resolve(filePath);
4447
+ const tsconfigPathDirname = path.dirname(tsconfigPath);
4448
+ const tsconfig = getExtendTSConfig(tsconfigPath);
4449
+ const resolvePaths = (paths) => paths?.map((p) => path.resolve(tsconfigPathDirname, p)) ?? [];
4450
+ const [
4451
+ references,
4452
+ files,
4453
+ include,
4454
+ exclude
4455
+ ] = [
4456
+ tsconfig.references?.map(({ path }) => path),
4457
+ tsconfig.files,
4458
+ tsconfig.include,
4459
+ tsconfig.exclude
4460
+ ].map(resolvePaths);
4461
+ if (exclude.length > 0 && exclude.some((i) => micromatchExports.isMatch(filePath, i)))
4462
+ return;
4463
+ if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0)
4464
+ return;
4465
+ let isInclude = false;
4466
+ isInclude || (isInclude = files.length > 0 && files.includes(filePath));
4467
+ isInclude || (isInclude = include.length > 0 && include.some((i) => micromatchExports.isMatch(filePath, i)));
4468
+ if (isInclude) {
4469
+ return tsconfig.compilerOptions ?? {};
4470
+ } else {
4471
+ if (tsconfig.files && tsconfig.files.length > 0 || tsconfig.include && tsconfig.include.length > 0)
4472
+ return;
4473
+ }
4474
+ references.reverse();
4475
+ for (const ref of references) {
4476
+ const compilerOptions = getCompilerOptionsByFilePath(ref, filePath);
4477
+ if (compilerOptions)
4478
+ return compilerOptions;
4479
+ }
4480
+ return tsconfig.compilerOptions;
4481
+ };
4482
+ const generateConfigs = ({
4483
+ path: path$1,
4484
+ name,
4485
+ input,
4486
+ output,
4487
+ external,
4488
+ pkgIsModule,
4489
+ conditionals
4490
+ }, options = {}) => {
4491
+ const isModule = conditionals.includes("import");
4492
+ const isCommonJS = conditionals.includes("require");
4493
+ const isBrowser = conditionals.includes("browser");
4494
+ const dtsTSConfigPaths = [
4495
+ resolveWorkspacePath("tsconfig.json"),
4496
+ resolveWorkspacePath("tsconfig.dts.json")
4497
+ ];
4498
+ let dtsTSConfigPath;
4499
+ dtsTSConfigPaths.forEach((p) => {
4500
+ if (fs.existsSync(p) && fs.statSync(p).isFile()) {
4501
+ dtsTSConfigPath = p;
4502
+ }
4503
+ });
4504
+ let compilerOptions = {};
4505
+ if (dtsTSConfigPath) {
4506
+ const jsonCompilerOptions = getCompilerOptionsByFilePath(dtsTSConfigPath, path.resolve(input));
4507
+ const { options: options2, errors } = ts.convertCompilerOptionsFromJson(
4508
+ jsonCompilerOptions,
4509
+ path.dirname(dtsTSConfigPath)
4510
+ );
4511
+ if (errors.length > 0) {
4512
+ throw new Error(errors.map((e) => e.messageText).join("\n"));
4513
+ }
4514
+ compilerOptions = options2;
4515
+ }
4516
+ const exportConditions = [...conditionals, ...compilerOptions.customConditions ?? []];
4517
+ const throughEventProps = {
4518
+ type: "progress",
4519
+ data: { name, path: path$1, exportConditions, input }
4520
+ };
4521
+ const outdir = options?.output?.dir;
4522
+ return [
4523
+ {
4524
+ input,
4525
+ external,
4526
+ output: [
4527
+ ...withMinify({
4528
+ file: output,
4529
+ name,
4530
+ sourcemap: typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.js : options?.output?.sourcemap,
4531
+ format: isModule ? "esm" : isCommonJS ? "cjs" : isBrowser ? "umd" : pkgIsModule ? "esm" : "cjs",
4532
+ strict: typeof options?.output?.strict === "object" ? options.output.strict.js : options?.output?.strict
4533
+ })
4534
+ ],
4535
+ plugins: [
4536
+ pluginNodeResolve.nodeResolve({ exportConditions }),
4537
+ import('rollup-plugin-postcss').then(
4538
+ ({ default: postcss }) => postcss({
4539
+ extract: path.resolve(output.replace(/\.[cm]?js$/, ".css")),
4540
+ minimize: true
4541
+ })
4542
+ ).catch(() => void 0),
4543
+ esbuild(),
4544
+ commonjs(),
4545
+ progress({
4546
+ onEvent: (event, message) => execa.sendMessage(
4547
+ {
4548
+ ...throughEventProps,
4549
+ data: { ...throughEventProps.data, event, message, tags: ["js"] }
4550
+ }
4551
+ )
4552
+ })
4553
+ ]
4554
+ },
4555
+ {
4556
+ input,
4557
+ external,
4558
+ output: [
4559
+ {
4560
+ dir: path.resolve((typeof outdir === "object" ? outdir.dts : outdir) ?? "dist"),
4561
+ sourcemap: typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.dts : options?.output?.sourcemap,
4562
+ entryFileNames: () => output.replace(`${jsOutdir}/`, "").replace(/(\.[cm]?)js$/, ".d$1ts"),
4563
+ strict: typeof options?.output?.strict === "object" ? options.output.strict.dts : options?.output?.strict
4564
+ }
4565
+ ],
4566
+ plugins: [
4567
+ pluginNodeResolve.nodeResolve({ exportConditions }),
4568
+ skip({ patterns: [STYLE_REGEXP] }),
4569
+ rollupPluginDts.dts({
4570
+ respectExternal: true,
4571
+ compilerOptions
4572
+ }),
4573
+ progress({
4574
+ onEvent: (event, message) => execa.sendMessage(
4575
+ {
4576
+ ...throughEventProps,
4577
+ data: { ...throughEventProps.data, event, message, tags: ["dts"] }
4578
+ }
4579
+ )
4580
+ })
4581
+ ]
4582
+ }
4583
+ ];
4584
+ };
4585
+ function template(packageJSON) {
4586
+ const { name, type, exports: entrypoints$1 } = packageJSON;
4587
+ const pkgIsModule = type === "module";
4588
+ if (!name)
4589
+ throw new Error("package.json name is required");
4590
+ if (!entrypoints$1)
4591
+ throw new Error("package.json exports is required");
4592
+ const entries = JIEK_ENTRIES?.split(",").map((e) => e.trim()).map((e) => ({
4593
+ "index": "."
4594
+ })[e] ?? e);
4595
+ const packageName = pascalCase(name);
4596
+ const external = externalResolver(packageJSON);
4597
+ const [filteredResolvedEntrypoints, exports] = getExports({
4598
+ entrypoints: entrypoints$1,
4599
+ pkgIsModule,
4600
+ entries,
4601
+ config
4602
+ });
4603
+ const leafMap = /* @__PURE__ */ new Map();
4604
+ entrypoints.getAllLeafs(filteredResolvedEntrypoints, ({ keys, value }) => {
4605
+ if (typeof value === "string") {
4606
+ const keysArr = leafMap.get(value) ?? [];
4607
+ leafMap.set(value, keysArr);
4608
+ keysArr.push(keys);
4609
+ }
4610
+ return false;
4611
+ });
4612
+ const configs = [];
4613
+ leafMap.forEach(
4614
+ (keysArr, input) => keysArr.forEach((keys) => {
4615
+ const [path, ...conditionals] = keys;
4616
+ const name2 = packageName + (path === "." ? "" : pascalCase(path));
4617
+ const keyExports = reveal(exports, keys);
4618
+ const commonOptions = {
4619
+ path,
4620
+ name: name2,
4621
+ input,
4622
+ external,
4623
+ pkgIsModule
4624
+ };
4625
+ switch (typeof keyExports) {
4626
+ case "string": {
4627
+ configs.push(...generateConfigs({
4628
+ ...commonOptions,
4629
+ output: keyExports,
4630
+ conditionals
4631
+ }, build));
4632
+ break;
4633
+ }
4634
+ case "object": {
4635
+ entrypoints.getAllLeafs(keyExports, ({ keys: nextKeys, value }) => {
4636
+ const allConditionals = [.../* @__PURE__ */ new Set([...conditionals, ...nextKeys])];
4637
+ if (typeof value === "string") {
4638
+ configs.push(...generateConfigs({
4639
+ ...commonOptions,
4640
+ output: value,
4641
+ conditionals: allConditionals
4642
+ }, build));
4643
+ }
4644
+ return false;
4645
+ });
4646
+ break;
4647
+ }
4648
+ }
4649
+ })
4650
+ );
4651
+ execa.sendMessage(
4652
+ {
4653
+ type: "init",
4654
+ data: {
4655
+ leafMap,
4656
+ targetsLength: configs.length
4657
+ }
4658
+ }
4659
+ );
4660
+ return configs.map((c) => ({
4661
+ ...COMMON_OPTIONS,
4662
+ ...c,
4663
+ plugins: [
4664
+ ...COMMON_PLUGINS,
4665
+ c.plugins
4666
+ ]
4667
+ }));
4668
+ }
4669
+
4670
+ exports.template = template;