jiek 2.3.0 → 2.3.2

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