source: imaps-frontend/node_modules/vite/dist/node-cjs/publicUtils.cjs@ d565449

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

Update repo after prototype presentation

  • Property mode set to 100644
File size: 156.0 KB
RevLine 
[d565449]1'use strict';
2
3var path$3 = require('node:path');
4var node_url = require('node:url');
5var fs$1 = require('node:fs');
6var esbuild = require('esbuild');
7var node_module = require('node:module');
8var require$$0 = require('tty');
9var require$$1 = require('util');
10var require$$0$1 = require('path');
11var require$$0$2 = require('crypto');
12var fs$2 = require('fs');
13var readline = require('node:readline');
14var require$$2 = require('os');
15
16var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
17const { version: version$2 } = JSON.parse(
18 fs$1.readFileSync(new URL("../../package.json", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)))).toString()
19);
20const VERSION = version$2;
21const FS_PREFIX = `/@fs/`;
22const VITE_PACKAGE_DIR = path$3.resolve(
23 // import.meta.url is `dist/node/constants.js` after bundle
24 node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))),
25 "../../.."
26);
27const CLIENT_ENTRY = path$3.resolve(VITE_PACKAGE_DIR, "dist/client/client.mjs");
28path$3.resolve(VITE_PACKAGE_DIR, "dist/client/env.mjs");
29path$3.dirname(CLIENT_ENTRY);
30
31const comma = ','.charCodeAt(0);
32const semicolon = ';'.charCodeAt(0);
33const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
34const intToChar = new Uint8Array(64); // 64 possible chars.
35const charToInt = new Uint8Array(128); // z is 122 in ASCII
36for (let i = 0; i < chars.length; i++) {
37 const c = chars.charCodeAt(i);
38 intToChar[i] = c;
39 charToInt[c] = i;
40}
41// Provide a fallback for older environments.
42const td = typeof TextDecoder !== 'undefined'
43 ? /* #__PURE__ */ new TextDecoder()
44 : typeof Buffer !== 'undefined'
45 ? {
46 decode(buf) {
47 const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
48 return out.toString();
49 },
50 }
51 : {
52 decode(buf) {
53 let out = '';
54 for (let i = 0; i < buf.length; i++) {
55 out += String.fromCharCode(buf[i]);
56 }
57 return out;
58 },
59 };
60function encode(decoded) {
61 const state = new Int32Array(5);
62 const bufLength = 1024 * 16;
63 const subLength = bufLength - 36;
64 const buf = new Uint8Array(bufLength);
65 const sub = buf.subarray(0, subLength);
66 let pos = 0;
67 let out = '';
68 for (let i = 0; i < decoded.length; i++) {
69 const line = decoded[i];
70 if (i > 0) {
71 if (pos === bufLength) {
72 out += td.decode(buf);
73 pos = 0;
74 }
75 buf[pos++] = semicolon;
76 }
77 if (line.length === 0)
78 continue;
79 state[0] = 0;
80 for (let j = 0; j < line.length; j++) {
81 const segment = line[j];
82 // We can push up to 5 ints, each int can take at most 7 chars, and we
83 // may push a comma.
84 if (pos > subLength) {
85 out += td.decode(sub);
86 buf.copyWithin(0, subLength, pos);
87 pos -= subLength;
88 }
89 if (j > 0)
90 buf[pos++] = comma;
91 pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
92 if (segment.length === 1)
93 continue;
94 pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
95 pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
96 pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
97 if (segment.length === 4)
98 continue;
99 pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
100 }
101 }
102 return out + td.decode(buf.subarray(0, pos));
103}
104function encodeInteger(buf, pos, state, segment, j) {
105 const next = segment[j];
106 let num = next - state[j];
107 state[j] = next;
108 num = num < 0 ? (-num << 1) | 1 : num << 1;
109 do {
110 let clamped = num & 0b011111;
111 num >>>= 5;
112 if (num > 0)
113 clamped |= 0b100000;
114 buf[pos++] = intToChar[clamped];
115 } while (num > 0);
116 return pos;
117}
118
119function getDefaultExportFromCjs (x) {
120 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
121}
122
123function commonjsRequire(path) {
124 throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
125}
126
127var picocolors = {exports: {}};
128
129let argv = process.argv || [],
130 env = process.env;
131let isColorSupported =
132 !("NO_COLOR" in env || argv.includes("--no-color")) &&
133 ("FORCE_COLOR" in env ||
134 argv.includes("--color") ||
135 process.platform === "win32" ||
136 (commonjsRequire != null && require$$0.isatty(1) && env.TERM !== "dumb") ||
137 "CI" in env);
138
139let formatter =
140 (open, close, replace = open) =>
141 input => {
142 let string = "" + input;
143 let index = string.indexOf(close, open.length);
144 return ~index
145 ? open + replaceClose(string, close, replace, index) + close
146 : open + string + close
147 };
148
149let replaceClose = (string, close, replace, index) => {
150 let result = "";
151 let cursor = 0;
152 do {
153 result += string.substring(cursor, index) + replace;
154 cursor = index + close.length;
155 index = string.indexOf(close, cursor);
156 } while (~index)
157 return result + string.substring(cursor)
158};
159
160let createColors = (enabled = isColorSupported) => {
161 let init = enabled ? formatter : () => String;
162 return {
163 isColorSupported: enabled,
164 reset: init("\x1b[0m", "\x1b[0m"),
165 bold: init("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
166 dim: init("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
167 italic: init("\x1b[3m", "\x1b[23m"),
168 underline: init("\x1b[4m", "\x1b[24m"),
169 inverse: init("\x1b[7m", "\x1b[27m"),
170 hidden: init("\x1b[8m", "\x1b[28m"),
171 strikethrough: init("\x1b[9m", "\x1b[29m"),
172 black: init("\x1b[30m", "\x1b[39m"),
173 red: init("\x1b[31m", "\x1b[39m"),
174 green: init("\x1b[32m", "\x1b[39m"),
175 yellow: init("\x1b[33m", "\x1b[39m"),
176 blue: init("\x1b[34m", "\x1b[39m"),
177 magenta: init("\x1b[35m", "\x1b[39m"),
178 cyan: init("\x1b[36m", "\x1b[39m"),
179 white: init("\x1b[37m", "\x1b[39m"),
180 gray: init("\x1b[90m", "\x1b[39m"),
181 bgBlack: init("\x1b[40m", "\x1b[49m"),
182 bgRed: init("\x1b[41m", "\x1b[49m"),
183 bgGreen: init("\x1b[42m", "\x1b[49m"),
184 bgYellow: init("\x1b[43m", "\x1b[49m"),
185 bgBlue: init("\x1b[44m", "\x1b[49m"),
186 bgMagenta: init("\x1b[45m", "\x1b[49m"),
187 bgCyan: init("\x1b[46m", "\x1b[49m"),
188 bgWhite: init("\x1b[47m", "\x1b[49m"),
189 }
190};
191
192picocolors.exports = createColors();
193picocolors.exports.createColors = createColors;
194
195var picocolorsExports = picocolors.exports;
196var colors = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
197
198var src = {exports: {}};
199
200var browser$1 = {exports: {}};
201
202/**
203 * Helpers.
204 */
205
206var ms;
207var hasRequiredMs;
208
209function requireMs () {
210 if (hasRequiredMs) return ms;
211 hasRequiredMs = 1;
212 var s = 1000;
213 var m = s * 60;
214 var h = m * 60;
215 var d = h * 24;
216 var w = d * 7;
217 var y = d * 365.25;
218
219 /**
220 * Parse or format the given `val`.
221 *
222 * Options:
223 *
224 * - `long` verbose formatting [false]
225 *
226 * @param {String|Number} val
227 * @param {Object} [options]
228 * @throws {Error} throw an error if val is not a non-empty string or a number
229 * @return {String|Number}
230 * @api public
231 */
232
233 ms = function(val, options) {
234 options = options || {};
235 var type = typeof val;
236 if (type === 'string' && val.length > 0) {
237 return parse(val);
238 } else if (type === 'number' && isFinite(val)) {
239 return options.long ? fmtLong(val) : fmtShort(val);
240 }
241 throw new Error(
242 'val is not a non-empty string or a valid number. val=' +
243 JSON.stringify(val)
244 );
245 };
246
247 /**
248 * Parse the given `str` and return milliseconds.
249 *
250 * @param {String} str
251 * @return {Number}
252 * @api private
253 */
254
255 function parse(str) {
256 str = String(str);
257 if (str.length > 100) {
258 return;
259 }
260 var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
261 str
262 );
263 if (!match) {
264 return;
265 }
266 var n = parseFloat(match[1]);
267 var type = (match[2] || 'ms').toLowerCase();
268 switch (type) {
269 case 'years':
270 case 'year':
271 case 'yrs':
272 case 'yr':
273 case 'y':
274 return n * y;
275 case 'weeks':
276 case 'week':
277 case 'w':
278 return n * w;
279 case 'days':
280 case 'day':
281 case 'd':
282 return n * d;
283 case 'hours':
284 case 'hour':
285 case 'hrs':
286 case 'hr':
287 case 'h':
288 return n * h;
289 case 'minutes':
290 case 'minute':
291 case 'mins':
292 case 'min':
293 case 'm':
294 return n * m;
295 case 'seconds':
296 case 'second':
297 case 'secs':
298 case 'sec':
299 case 's':
300 return n * s;
301 case 'milliseconds':
302 case 'millisecond':
303 case 'msecs':
304 case 'msec':
305 case 'ms':
306 return n;
307 default:
308 return undefined;
309 }
310 }
311
312 /**
313 * Short format for `ms`.
314 *
315 * @param {Number} ms
316 * @return {String}
317 * @api private
318 */
319
320 function fmtShort(ms) {
321 var msAbs = Math.abs(ms);
322 if (msAbs >= d) {
323 return Math.round(ms / d) + 'd';
324 }
325 if (msAbs >= h) {
326 return Math.round(ms / h) + 'h';
327 }
328 if (msAbs >= m) {
329 return Math.round(ms / m) + 'm';
330 }
331 if (msAbs >= s) {
332 return Math.round(ms / s) + 's';
333 }
334 return ms + 'ms';
335 }
336
337 /**
338 * Long format for `ms`.
339 *
340 * @param {Number} ms
341 * @return {String}
342 * @api private
343 */
344
345 function fmtLong(ms) {
346 var msAbs = Math.abs(ms);
347 if (msAbs >= d) {
348 return plural(ms, msAbs, d, 'day');
349 }
350 if (msAbs >= h) {
351 return plural(ms, msAbs, h, 'hour');
352 }
353 if (msAbs >= m) {
354 return plural(ms, msAbs, m, 'minute');
355 }
356 if (msAbs >= s) {
357 return plural(ms, msAbs, s, 'second');
358 }
359 return ms + ' ms';
360 }
361
362 /**
363 * Pluralization helper.
364 */
365
366 function plural(ms, msAbs, n, name) {
367 var isPlural = msAbs >= n * 1.5;
368 return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
369 }
370 return ms;
371}
372
373var common;
374var hasRequiredCommon;
375
376function requireCommon () {
377 if (hasRequiredCommon) return common;
378 hasRequiredCommon = 1;
379 /**
380 * This is the common logic for both the Node.js and web browser
381 * implementations of `debug()`.
382 */
383
384 function setup(env) {
385 createDebug.debug = createDebug;
386 createDebug.default = createDebug;
387 createDebug.coerce = coerce;
388 createDebug.disable = disable;
389 createDebug.enable = enable;
390 createDebug.enabled = enabled;
391 createDebug.humanize = requireMs();
392 createDebug.destroy = destroy;
393
394 Object.keys(env).forEach(key => {
395 createDebug[key] = env[key];
396 });
397
398 /**
399 * The currently active debug mode names, and names to skip.
400 */
401
402 createDebug.names = [];
403 createDebug.skips = [];
404
405 /**
406 * Map of special "%n" handling functions, for the debug "format" argument.
407 *
408 * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
409 */
410 createDebug.formatters = {};
411
412 /**
413 * Selects a color for a debug namespace
414 * @param {String} namespace The namespace string for the debug instance to be colored
415 * @return {Number|String} An ANSI color code for the given namespace
416 * @api private
417 */
418 function selectColor(namespace) {
419 let hash = 0;
420
421 for (let i = 0; i < namespace.length; i++) {
422 hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
423 hash |= 0; // Convert to 32bit integer
424 }
425
426 return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
427 }
428 createDebug.selectColor = selectColor;
429
430 /**
431 * Create a debugger with the given `namespace`.
432 *
433 * @param {String} namespace
434 * @return {Function}
435 * @api public
436 */
437 function createDebug(namespace) {
438 let prevTime;
439 let enableOverride = null;
440 let namespacesCache;
441 let enabledCache;
442
443 function debug(...args) {
444 // Disabled?
445 if (!debug.enabled) {
446 return;
447 }
448
449 const self = debug;
450
451 // Set `diff` timestamp
452 const curr = Number(new Date());
453 const ms = curr - (prevTime || curr);
454 self.diff = ms;
455 self.prev = prevTime;
456 self.curr = curr;
457 prevTime = curr;
458
459 args[0] = createDebug.coerce(args[0]);
460
461 if (typeof args[0] !== 'string') {
462 // Anything else let's inspect with %O
463 args.unshift('%O');
464 }
465
466 // Apply any `formatters` transformations
467 let index = 0;
468 args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
469 // If we encounter an escaped % then don't increase the array index
470 if (match === '%%') {
471 return '%';
472 }
473 index++;
474 const formatter = createDebug.formatters[format];
475 if (typeof formatter === 'function') {
476 const val = args[index];
477 match = formatter.call(self, val);
478
479 // Now we need to remove `args[index]` since it's inlined in the `format`
480 args.splice(index, 1);
481 index--;
482 }
483 return match;
484 });
485
486 // Apply env-specific formatting (colors, etc.)
487 createDebug.formatArgs.call(self, args);
488
489 const logFn = self.log || createDebug.log;
490 logFn.apply(self, args);
491 }
492
493 debug.namespace = namespace;
494 debug.useColors = createDebug.useColors();
495 debug.color = createDebug.selectColor(namespace);
496 debug.extend = extend;
497 debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
498
499 Object.defineProperty(debug, 'enabled', {
500 enumerable: true,
501 configurable: false,
502 get: () => {
503 if (enableOverride !== null) {
504 return enableOverride;
505 }
506 if (namespacesCache !== createDebug.namespaces) {
507 namespacesCache = createDebug.namespaces;
508 enabledCache = createDebug.enabled(namespace);
509 }
510
511 return enabledCache;
512 },
513 set: v => {
514 enableOverride = v;
515 }
516 });
517
518 // Env-specific initialization logic for debug instances
519 if (typeof createDebug.init === 'function') {
520 createDebug.init(debug);
521 }
522
523 return debug;
524 }
525
526 function extend(namespace, delimiter) {
527 const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
528 newDebug.log = this.log;
529 return newDebug;
530 }
531
532 /**
533 * Enables a debug mode by namespaces. This can include modes
534 * separated by a colon and wildcards.
535 *
536 * @param {String} namespaces
537 * @api public
538 */
539 function enable(namespaces) {
540 createDebug.save(namespaces);
541 createDebug.namespaces = namespaces;
542
543 createDebug.names = [];
544 createDebug.skips = [];
545
546 let i;
547 const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
548 const len = split.length;
549
550 for (i = 0; i < len; i++) {
551 if (!split[i]) {
552 // ignore empty strings
553 continue;
554 }
555
556 namespaces = split[i].replace(/\*/g, '.*?');
557
558 if (namespaces[0] === '-') {
559 createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
560 } else {
561 createDebug.names.push(new RegExp('^' + namespaces + '$'));
562 }
563 }
564 }
565
566 /**
567 * Disable debug output.
568 *
569 * @return {String} namespaces
570 * @api public
571 */
572 function disable() {
573 const namespaces = [
574 ...createDebug.names.map(toNamespace),
575 ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
576 ].join(',');
577 createDebug.enable('');
578 return namespaces;
579 }
580
581 /**
582 * Returns true if the given mode name is enabled, false otherwise.
583 *
584 * @param {String} name
585 * @return {Boolean}
586 * @api public
587 */
588 function enabled(name) {
589 if (name[name.length - 1] === '*') {
590 return true;
591 }
592
593 let i;
594 let len;
595
596 for (i = 0, len = createDebug.skips.length; i < len; i++) {
597 if (createDebug.skips[i].test(name)) {
598 return false;
599 }
600 }
601
602 for (i = 0, len = createDebug.names.length; i < len; i++) {
603 if (createDebug.names[i].test(name)) {
604 return true;
605 }
606 }
607
608 return false;
609 }
610
611 /**
612 * Convert regexp to namespace
613 *
614 * @param {RegExp} regxep
615 * @return {String} namespace
616 * @api private
617 */
618 function toNamespace(regexp) {
619 return regexp.toString()
620 .substring(2, regexp.toString().length - 2)
621 .replace(/\.\*\?$/, '*');
622 }
623
624 /**
625 * Coerce `val`.
626 *
627 * @param {Mixed} val
628 * @return {Mixed}
629 * @api private
630 */
631 function coerce(val) {
632 if (val instanceof Error) {
633 return val.stack || val.message;
634 }
635 return val;
636 }
637
638 /**
639 * XXX DO NOT USE. This is a temporary stub function.
640 * XXX It WILL be removed in the next major release.
641 */
642 function destroy() {
643 console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
644 }
645
646 createDebug.enable(createDebug.load());
647
648 return createDebug;
649 }
650
651 common = setup;
652 return common;
653}
654
655/* eslint-env browser */
656
657var hasRequiredBrowser;
658
659function requireBrowser () {
660 if (hasRequiredBrowser) return browser$1.exports;
661 hasRequiredBrowser = 1;
662 (function (module, exports) {
663 /**
664 * This is the web browser implementation of `debug()`.
665 */
666
667 exports.formatArgs = formatArgs;
668 exports.save = save;
669 exports.load = load;
670 exports.useColors = useColors;
671 exports.storage = localstorage();
672 exports.destroy = (() => {
673 let warned = false;
674
675 return () => {
676 if (!warned) {
677 warned = true;
678 console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
679 }
680 };
681 })();
682
683 /**
684 * Colors.
685 */
686
687 exports.colors = [
688 '#0000CC',
689 '#0000FF',
690 '#0033CC',
691 '#0033FF',
692 '#0066CC',
693 '#0066FF',
694 '#0099CC',
695 '#0099FF',
696 '#00CC00',
697 '#00CC33',
698 '#00CC66',
699 '#00CC99',
700 '#00CCCC',
701 '#00CCFF',
702 '#3300CC',
703 '#3300FF',
704 '#3333CC',
705 '#3333FF',
706 '#3366CC',
707 '#3366FF',
708 '#3399CC',
709 '#3399FF',
710 '#33CC00',
711 '#33CC33',
712 '#33CC66',
713 '#33CC99',
714 '#33CCCC',
715 '#33CCFF',
716 '#6600CC',
717 '#6600FF',
718 '#6633CC',
719 '#6633FF',
720 '#66CC00',
721 '#66CC33',
722 '#9900CC',
723 '#9900FF',
724 '#9933CC',
725 '#9933FF',
726 '#99CC00',
727 '#99CC33',
728 '#CC0000',
729 '#CC0033',
730 '#CC0066',
731 '#CC0099',
732 '#CC00CC',
733 '#CC00FF',
734 '#CC3300',
735 '#CC3333',
736 '#CC3366',
737 '#CC3399',
738 '#CC33CC',
739 '#CC33FF',
740 '#CC6600',
741 '#CC6633',
742 '#CC9900',
743 '#CC9933',
744 '#CCCC00',
745 '#CCCC33',
746 '#FF0000',
747 '#FF0033',
748 '#FF0066',
749 '#FF0099',
750 '#FF00CC',
751 '#FF00FF',
752 '#FF3300',
753 '#FF3333',
754 '#FF3366',
755 '#FF3399',
756 '#FF33CC',
757 '#FF33FF',
758 '#FF6600',
759 '#FF6633',
760 '#FF9900',
761 '#FF9933',
762 '#FFCC00',
763 '#FFCC33'
764 ];
765
766 /**
767 * Currently only WebKit-based Web Inspectors, Firefox >= v31,
768 * and the Firebug extension (any Firefox version) are known
769 * to support "%c" CSS customizations.
770 *
771 * TODO: add a `localStorage` variable to explicitly enable/disable colors
772 */
773
774 // eslint-disable-next-line complexity
775 function useColors() {
776 // NB: In an Electron preload script, document will be defined but not fully
777 // initialized. Since we know we're in Chrome, we'll just detect this case
778 // explicitly
779 if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
780 return true;
781 }
782
783 // Internet Explorer and Edge do not support colors.
784 if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
785 return false;
786 }
787
788 // Is webkit? http://stackoverflow.com/a/16459606/376773
789 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
790 return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
791 // Is firebug? http://stackoverflow.com/a/398120/376773
792 (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
793 // Is firefox >= v31?
794 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
795 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
796 // Double check webkit in userAgent just in case we are in a worker
797 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
798 }
799
800 /**
801 * Colorize log arguments if enabled.
802 *
803 * @api public
804 */
805
806 function formatArgs(args) {
807 args[0] = (this.useColors ? '%c' : '') +
808 this.namespace +
809 (this.useColors ? ' %c' : ' ') +
810 args[0] +
811 (this.useColors ? '%c ' : ' ') +
812 '+' + module.exports.humanize(this.diff);
813
814 if (!this.useColors) {
815 return;
816 }
817
818 const c = 'color: ' + this.color;
819 args.splice(1, 0, c, 'color: inherit');
820
821 // The final "%c" is somewhat tricky, because there could be other
822 // arguments passed either before or after the %c, so we need to
823 // figure out the correct index to insert the CSS into
824 let index = 0;
825 let lastC = 0;
826 args[0].replace(/%[a-zA-Z%]/g, match => {
827 if (match === '%%') {
828 return;
829 }
830 index++;
831 if (match === '%c') {
832 // We only are interested in the *last* %c
833 // (the user may have provided their own)
834 lastC = index;
835 }
836 });
837
838 args.splice(lastC, 0, c);
839 }
840
841 /**
842 * Invokes `console.debug()` when available.
843 * No-op when `console.debug` is not a "function".
844 * If `console.debug` is not available, falls back
845 * to `console.log`.
846 *
847 * @api public
848 */
849 exports.log = console.debug || console.log || (() => {});
850
851 /**
852 * Save `namespaces`.
853 *
854 * @param {String} namespaces
855 * @api private
856 */
857 function save(namespaces) {
858 try {
859 if (namespaces) {
860 exports.storage.setItem('debug', namespaces);
861 } else {
862 exports.storage.removeItem('debug');
863 }
864 } catch (error) {
865 // Swallow
866 // XXX (@Qix-) should we be logging these?
867 }
868 }
869
870 /**
871 * Load `namespaces`.
872 *
873 * @return {String} returns the previously persisted debug modes
874 * @api private
875 */
876 function load() {
877 let r;
878 try {
879 r = exports.storage.getItem('debug');
880 } catch (error) {
881 // Swallow
882 // XXX (@Qix-) should we be logging these?
883 }
884
885 // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
886 if (!r && typeof process !== 'undefined' && 'env' in process) {
887 r = process.env.DEBUG;
888 }
889
890 return r;
891 }
892
893 /**
894 * Localstorage attempts to return the localstorage.
895 *
896 * This is necessary because safari throws
897 * when a user disables cookies/localstorage
898 * and you attempt to access it.
899 *
900 * @return {LocalStorage}
901 * @api private
902 */
903
904 function localstorage() {
905 try {
906 // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
907 // The Browser also has localStorage in the global context.
908 return localStorage;
909 } catch (error) {
910 // Swallow
911 // XXX (@Qix-) should we be logging these?
912 }
913 }
914
915 module.exports = requireCommon()(exports);
916
917 const {formatters} = module.exports;
918
919 /**
920 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
921 */
922
923 formatters.j = function (v) {
924 try {
925 return JSON.stringify(v);
926 } catch (error) {
927 return '[UnexpectedJSONParseError]: ' + error.message;
928 }
929 };
930 } (browser$1, browser$1.exports));
931 return browser$1.exports;
932}
933
934var node = {exports: {}};
935
936/**
937 * Module dependencies.
938 */
939
940var hasRequiredNode;
941
942function requireNode () {
943 if (hasRequiredNode) return node.exports;
944 hasRequiredNode = 1;
945 (function (module, exports) {
946 const tty = require$$0;
947 const util = require$$1;
948
949 /**
950 * This is the Node.js implementation of `debug()`.
951 */
952
953 exports.init = init;
954 exports.log = log;
955 exports.formatArgs = formatArgs;
956 exports.save = save;
957 exports.load = load;
958 exports.useColors = useColors;
959 exports.destroy = util.deprecate(
960 () => {},
961 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
962 );
963
964 /**
965 * Colors.
966 */
967
968 exports.colors = [6, 2, 3, 4, 5, 1];
969
970 try {
971 // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
972 // eslint-disable-next-line import/no-extraneous-dependencies
973 const supportsColor = require('supports-color');
974
975 if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
976 exports.colors = [
977 20,
978 21,
979 26,
980 27,
981 32,
982 33,
983 38,
984 39,
985 40,
986 41,
987 42,
988 43,
989 44,
990 45,
991 56,
992 57,
993 62,
994 63,
995 68,
996 69,
997 74,
998 75,
999 76,
1000 77,
1001 78,
1002 79,
1003 80,
1004 81,
1005 92,
1006 93,
1007 98,
1008 99,
1009 112,
1010 113,
1011 128,
1012 129,
1013 134,
1014 135,
1015 148,
1016 149,
1017 160,
1018 161,
1019 162,
1020 163,
1021 164,
1022 165,
1023 166,
1024 167,
1025 168,
1026 169,
1027 170,
1028 171,
1029 172,
1030 173,
1031 178,
1032 179,
1033 184,
1034 185,
1035 196,
1036 197,
1037 198,
1038 199,
1039 200,
1040 201,
1041 202,
1042 203,
1043 204,
1044 205,
1045 206,
1046 207,
1047 208,
1048 209,
1049 214,
1050 215,
1051 220,
1052 221
1053 ];
1054 }
1055 } catch (error) {
1056 // Swallow - we only care if `supports-color` is available; it doesn't have to be.
1057 }
1058
1059 /**
1060 * Build up the default `inspectOpts` object from the environment variables.
1061 *
1062 * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
1063 */
1064
1065 exports.inspectOpts = Object.keys(process.env).filter(key => {
1066 return /^debug_/i.test(key);
1067 }).reduce((obj, key) => {
1068 // Camel-case
1069 const prop = key
1070 .substring(6)
1071 .toLowerCase()
1072 .replace(/_([a-z])/g, (_, k) => {
1073 return k.toUpperCase();
1074 });
1075
1076 // Coerce string value into JS value
1077 let val = process.env[key];
1078 if (/^(yes|on|true|enabled)$/i.test(val)) {
1079 val = true;
1080 } else if (/^(no|off|false|disabled)$/i.test(val)) {
1081 val = false;
1082 } else if (val === 'null') {
1083 val = null;
1084 } else {
1085 val = Number(val);
1086 }
1087
1088 obj[prop] = val;
1089 return obj;
1090 }, {});
1091
1092 /**
1093 * Is stdout a TTY? Colored output is enabled when `true`.
1094 */
1095
1096 function useColors() {
1097 return 'colors' in exports.inspectOpts ?
1098 Boolean(exports.inspectOpts.colors) :
1099 tty.isatty(process.stderr.fd);
1100 }
1101
1102 /**
1103 * Adds ANSI color escape codes if enabled.
1104 *
1105 * @api public
1106 */
1107
1108 function formatArgs(args) {
1109 const {namespace: name, useColors} = this;
1110
1111 if (useColors) {
1112 const c = this.color;
1113 const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
1114 const prefix = ` ${colorCode};1m${name} \u001B[0m`;
1115
1116 args[0] = prefix + args[0].split('\n').join('\n' + prefix);
1117 args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
1118 } else {
1119 args[0] = getDate() + name + ' ' + args[0];
1120 }
1121 }
1122
1123 function getDate() {
1124 if (exports.inspectOpts.hideDate) {
1125 return '';
1126 }
1127 return new Date().toISOString() + ' ';
1128 }
1129
1130 /**
1131 * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
1132 */
1133
1134 function log(...args) {
1135 return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
1136 }
1137
1138 /**
1139 * Save `namespaces`.
1140 *
1141 * @param {String} namespaces
1142 * @api private
1143 */
1144 function save(namespaces) {
1145 if (namespaces) {
1146 process.env.DEBUG = namespaces;
1147 } else {
1148 // If you set a process.env field to null or undefined, it gets cast to the
1149 // string 'null' or 'undefined'. Just delete instead.
1150 delete process.env.DEBUG;
1151 }
1152 }
1153
1154 /**
1155 * Load `namespaces`.
1156 *
1157 * @return {String} returns the previously persisted debug modes
1158 * @api private
1159 */
1160
1161 function load() {
1162 return process.env.DEBUG;
1163 }
1164
1165 /**
1166 * Init logic for `debug` instances.
1167 *
1168 * Create a new `inspectOpts` object in case `useColors` is set
1169 * differently for a particular `debug` instance.
1170 */
1171
1172 function init(debug) {
1173 debug.inspectOpts = {};
1174
1175 const keys = Object.keys(exports.inspectOpts);
1176 for (let i = 0; i < keys.length; i++) {
1177 debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
1178 }
1179 }
1180
1181 module.exports = requireCommon()(exports);
1182
1183 const {formatters} = module.exports;
1184
1185 /**
1186 * Map %o to `util.inspect()`, all on a single line.
1187 */
1188
1189 formatters.o = function (v) {
1190 this.inspectOpts.colors = this.useColors;
1191 return util.inspect(v, this.inspectOpts)
1192 .split('\n')
1193 .map(str => str.trim())
1194 .join(' ');
1195 };
1196
1197 /**
1198 * Map %O to `util.inspect()`, allowing multiple lines if needed.
1199 */
1200
1201 formatters.O = function (v) {
1202 this.inspectOpts.colors = this.useColors;
1203 return util.inspect(v, this.inspectOpts);
1204 };
1205 } (node, node.exports));
1206 return node.exports;
1207}
1208
1209/**
1210 * Detect Electron renderer / nwjs process, which is node, but we should
1211 * treat as a browser.
1212 */
1213
1214if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
1215 src.exports = requireBrowser();
1216} else {
1217 src.exports = requireNode();
1218}
1219
1220var srcExports = src.exports;
1221var debug$2 = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
1222
1223var utils$3 = {};
1224
1225const path$2 = require$$0$1;
1226const WIN_SLASH = '\\\\/';
1227const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
1228
1229/**
1230 * Posix glob regex
1231 */
1232
1233const DOT_LITERAL = '\\.';
1234const PLUS_LITERAL = '\\+';
1235const QMARK_LITERAL = '\\?';
1236const SLASH_LITERAL = '\\/';
1237const ONE_CHAR = '(?=.)';
1238const QMARK = '[^/]';
1239const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
1240const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
1241const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
1242const NO_DOT = `(?!${DOT_LITERAL})`;
1243const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
1244const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
1245const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
1246const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
1247const STAR = `${QMARK}*?`;
1248
1249const POSIX_CHARS = {
1250 DOT_LITERAL,
1251 PLUS_LITERAL,
1252 QMARK_LITERAL,
1253 SLASH_LITERAL,
1254 ONE_CHAR,
1255 QMARK,
1256 END_ANCHOR,
1257 DOTS_SLASH,
1258 NO_DOT,
1259 NO_DOTS,
1260 NO_DOT_SLASH,
1261 NO_DOTS_SLASH,
1262 QMARK_NO_DOT,
1263 STAR,
1264 START_ANCHOR
1265};
1266
1267/**
1268 * Windows glob regex
1269 */
1270
1271const WINDOWS_CHARS = {
1272 ...POSIX_CHARS,
1273
1274 SLASH_LITERAL: `[${WIN_SLASH}]`,
1275 QMARK: WIN_NO_SLASH,
1276 STAR: `${WIN_NO_SLASH}*?`,
1277 DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
1278 NO_DOT: `(?!${DOT_LITERAL})`,
1279 NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
1280 NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
1281 NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
1282 QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
1283 START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
1284 END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
1285};
1286
1287/**
1288 * POSIX Bracket Regex
1289 */
1290
1291const POSIX_REGEX_SOURCE$1 = {
1292 alnum: 'a-zA-Z0-9',
1293 alpha: 'a-zA-Z',
1294 ascii: '\\x00-\\x7F',
1295 blank: ' \\t',
1296 cntrl: '\\x00-\\x1F\\x7F',
1297 digit: '0-9',
1298 graph: '\\x21-\\x7E',
1299 lower: 'a-z',
1300 print: '\\x20-\\x7E ',
1301 punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
1302 space: ' \\t\\r\\n\\v\\f',
1303 upper: 'A-Z',
1304 word: 'A-Za-z0-9_',
1305 xdigit: 'A-Fa-f0-9'
1306};
1307
1308var constants$2 = {
1309 MAX_LENGTH: 1024 * 64,
1310 POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
1311
1312 // regular expressions
1313 REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
1314 REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
1315 REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
1316 REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
1317 REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
1318 REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
1319
1320 // Replace globs with equivalent patterns to reduce parsing time.
1321 REPLACEMENTS: {
1322 '***': '*',
1323 '**/**': '**',
1324 '**/**/**': '**'
1325 },
1326
1327 // Digits
1328 CHAR_0: 48, /* 0 */
1329 CHAR_9: 57, /* 9 */
1330
1331 // Alphabet chars.
1332 CHAR_UPPERCASE_A: 65, /* A */
1333 CHAR_LOWERCASE_A: 97, /* a */
1334 CHAR_UPPERCASE_Z: 90, /* Z */
1335 CHAR_LOWERCASE_Z: 122, /* z */
1336
1337 CHAR_LEFT_PARENTHESES: 40, /* ( */
1338 CHAR_RIGHT_PARENTHESES: 41, /* ) */
1339
1340 CHAR_ASTERISK: 42, /* * */
1341
1342 // Non-alphabetic chars.
1343 CHAR_AMPERSAND: 38, /* & */
1344 CHAR_AT: 64, /* @ */
1345 CHAR_BACKWARD_SLASH: 92, /* \ */
1346 CHAR_CARRIAGE_RETURN: 13, /* \r */
1347 CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
1348 CHAR_COLON: 58, /* : */
1349 CHAR_COMMA: 44, /* , */
1350 CHAR_DOT: 46, /* . */
1351 CHAR_DOUBLE_QUOTE: 34, /* " */
1352 CHAR_EQUAL: 61, /* = */
1353 CHAR_EXCLAMATION_MARK: 33, /* ! */
1354 CHAR_FORM_FEED: 12, /* \f */
1355 CHAR_FORWARD_SLASH: 47, /* / */
1356 CHAR_GRAVE_ACCENT: 96, /* ` */
1357 CHAR_HASH: 35, /* # */
1358 CHAR_HYPHEN_MINUS: 45, /* - */
1359 CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
1360 CHAR_LEFT_CURLY_BRACE: 123, /* { */
1361 CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
1362 CHAR_LINE_FEED: 10, /* \n */
1363 CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
1364 CHAR_PERCENT: 37, /* % */
1365 CHAR_PLUS: 43, /* + */
1366 CHAR_QUESTION_MARK: 63, /* ? */
1367 CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
1368 CHAR_RIGHT_CURLY_BRACE: 125, /* } */
1369 CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
1370 CHAR_SEMICOLON: 59, /* ; */
1371 CHAR_SINGLE_QUOTE: 39, /* ' */
1372 CHAR_SPACE: 32, /* */
1373 CHAR_TAB: 9, /* \t */
1374 CHAR_UNDERSCORE: 95, /* _ */
1375 CHAR_VERTICAL_LINE: 124, /* | */
1376 CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
1377
1378 SEP: path$2.sep,
1379
1380 /**
1381 * Create EXTGLOB_CHARS
1382 */
1383
1384 extglobChars(chars) {
1385 return {
1386 '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
1387 '?': { type: 'qmark', open: '(?:', close: ')?' },
1388 '+': { type: 'plus', open: '(?:', close: ')+' },
1389 '*': { type: 'star', open: '(?:', close: ')*' },
1390 '@': { type: 'at', open: '(?:', close: ')' }
1391 };
1392 },
1393
1394 /**
1395 * Create GLOB_CHARS
1396 */
1397
1398 globChars(win32) {
1399 return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
1400 }
1401};
1402
1403(function (exports) {
1404
1405 const path = require$$0$1;
1406 const win32 = process.platform === 'win32';
1407 const {
1408 REGEX_BACKSLASH,
1409 REGEX_REMOVE_BACKSLASH,
1410 REGEX_SPECIAL_CHARS,
1411 REGEX_SPECIAL_CHARS_GLOBAL
1412 } = constants$2;
1413
1414 exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
1415 exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
1416 exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
1417 exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
1418 exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
1419
1420 exports.removeBackslashes = str => {
1421 return str.replace(REGEX_REMOVE_BACKSLASH, match => {
1422 return match === '\\' ? '' : match;
1423 });
1424 };
1425
1426 exports.supportsLookbehinds = () => {
1427 const segs = process.version.slice(1).split('.').map(Number);
1428 if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
1429 return true;
1430 }
1431 return false;
1432 };
1433
1434 exports.isWindows = options => {
1435 if (options && typeof options.windows === 'boolean') {
1436 return options.windows;
1437 }
1438 return win32 === true || path.sep === '\\';
1439 };
1440
1441 exports.escapeLast = (input, char, lastIdx) => {
1442 const idx = input.lastIndexOf(char, lastIdx);
1443 if (idx === -1) return input;
1444 if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
1445 return `${input.slice(0, idx)}\\${input.slice(idx)}`;
1446 };
1447
1448 exports.removePrefix = (input, state = {}) => {
1449 let output = input;
1450 if (output.startsWith('./')) {
1451 output = output.slice(2);
1452 state.prefix = './';
1453 }
1454 return output;
1455 };
1456
1457 exports.wrapOutput = (input, state = {}, options = {}) => {
1458 const prepend = options.contains ? '' : '^';
1459 const append = options.contains ? '' : '$';
1460
1461 let output = `${prepend}(?:${input})${append}`;
1462 if (state.negated === true) {
1463 output = `(?:^(?!${output}).*$)`;
1464 }
1465 return output;
1466 };
1467} (utils$3));
1468
1469const utils$2 = utils$3;
1470const {
1471 CHAR_ASTERISK, /* * */
1472 CHAR_AT, /* @ */
1473 CHAR_BACKWARD_SLASH, /* \ */
1474 CHAR_COMMA, /* , */
1475 CHAR_DOT, /* . */
1476 CHAR_EXCLAMATION_MARK, /* ! */
1477 CHAR_FORWARD_SLASH, /* / */
1478 CHAR_LEFT_CURLY_BRACE, /* { */
1479 CHAR_LEFT_PARENTHESES, /* ( */
1480 CHAR_LEFT_SQUARE_BRACKET, /* [ */
1481 CHAR_PLUS, /* + */
1482 CHAR_QUESTION_MARK, /* ? */
1483 CHAR_RIGHT_CURLY_BRACE, /* } */
1484 CHAR_RIGHT_PARENTHESES, /* ) */
1485 CHAR_RIGHT_SQUARE_BRACKET /* ] */
1486} = constants$2;
1487
1488const isPathSeparator = code => {
1489 return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
1490};
1491
1492const depth = token => {
1493 if (token.isPrefix !== true) {
1494 token.depth = token.isGlobstar ? Infinity : 1;
1495 }
1496};
1497
1498/**
1499 * Quickly scans a glob pattern and returns an object with a handful of
1500 * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
1501 * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
1502 * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
1503 *
1504 * ```js
1505 * const pm = require('picomatch');
1506 * console.log(pm.scan('foo/bar/*.js'));
1507 * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
1508 * ```
1509 * @param {String} `str`
1510 * @param {Object} `options`
1511 * @return {Object} Returns an object with tokens and regex source string.
1512 * @api public
1513 */
1514
1515const scan$1 = (input, options) => {
1516 const opts = options || {};
1517
1518 const length = input.length - 1;
1519 const scanToEnd = opts.parts === true || opts.scanToEnd === true;
1520 const slashes = [];
1521 const tokens = [];
1522 const parts = [];
1523
1524 let str = input;
1525 let index = -1;
1526 let start = 0;
1527 let lastIndex = 0;
1528 let isBrace = false;
1529 let isBracket = false;
1530 let isGlob = false;
1531 let isExtglob = false;
1532 let isGlobstar = false;
1533 let braceEscaped = false;
1534 let backslashes = false;
1535 let negated = false;
1536 let negatedExtglob = false;
1537 let finished = false;
1538 let braces = 0;
1539 let prev;
1540 let code;
1541 let token = { value: '', depth: 0, isGlob: false };
1542
1543 const eos = () => index >= length;
1544 const peek = () => str.charCodeAt(index + 1);
1545 const advance = () => {
1546 prev = code;
1547 return str.charCodeAt(++index);
1548 };
1549
1550 while (index < length) {
1551 code = advance();
1552 let next;
1553
1554 if (code === CHAR_BACKWARD_SLASH) {
1555 backslashes = token.backslashes = true;
1556 code = advance();
1557
1558 if (code === CHAR_LEFT_CURLY_BRACE) {
1559 braceEscaped = true;
1560 }
1561 continue;
1562 }
1563
1564 if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
1565 braces++;
1566
1567 while (eos() !== true && (code = advance())) {
1568 if (code === CHAR_BACKWARD_SLASH) {
1569 backslashes = token.backslashes = true;
1570 advance();
1571 continue;
1572 }
1573
1574 if (code === CHAR_LEFT_CURLY_BRACE) {
1575 braces++;
1576 continue;
1577 }
1578
1579 if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
1580 isBrace = token.isBrace = true;
1581 isGlob = token.isGlob = true;
1582 finished = true;
1583
1584 if (scanToEnd === true) {
1585 continue;
1586 }
1587
1588 break;
1589 }
1590
1591 if (braceEscaped !== true && code === CHAR_COMMA) {
1592 isBrace = token.isBrace = true;
1593 isGlob = token.isGlob = true;
1594 finished = true;
1595
1596 if (scanToEnd === true) {
1597 continue;
1598 }
1599
1600 break;
1601 }
1602
1603 if (code === CHAR_RIGHT_CURLY_BRACE) {
1604 braces--;
1605
1606 if (braces === 0) {
1607 braceEscaped = false;
1608 isBrace = token.isBrace = true;
1609 finished = true;
1610 break;
1611 }
1612 }
1613 }
1614
1615 if (scanToEnd === true) {
1616 continue;
1617 }
1618
1619 break;
1620 }
1621
1622 if (code === CHAR_FORWARD_SLASH) {
1623 slashes.push(index);
1624 tokens.push(token);
1625 token = { value: '', depth: 0, isGlob: false };
1626
1627 if (finished === true) continue;
1628 if (prev === CHAR_DOT && index === (start + 1)) {
1629 start += 2;
1630 continue;
1631 }
1632
1633 lastIndex = index + 1;
1634 continue;
1635 }
1636
1637 if (opts.noext !== true) {
1638 const isExtglobChar = code === CHAR_PLUS
1639 || code === CHAR_AT
1640 || code === CHAR_ASTERISK
1641 || code === CHAR_QUESTION_MARK
1642 || code === CHAR_EXCLAMATION_MARK;
1643
1644 if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
1645 isGlob = token.isGlob = true;
1646 isExtglob = token.isExtglob = true;
1647 finished = true;
1648 if (code === CHAR_EXCLAMATION_MARK && index === start) {
1649 negatedExtglob = true;
1650 }
1651
1652 if (scanToEnd === true) {
1653 while (eos() !== true && (code = advance())) {
1654 if (code === CHAR_BACKWARD_SLASH) {
1655 backslashes = token.backslashes = true;
1656 code = advance();
1657 continue;
1658 }
1659
1660 if (code === CHAR_RIGHT_PARENTHESES) {
1661 isGlob = token.isGlob = true;
1662 finished = true;
1663 break;
1664 }
1665 }
1666 continue;
1667 }
1668 break;
1669 }
1670 }
1671
1672 if (code === CHAR_ASTERISK) {
1673 if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
1674 isGlob = token.isGlob = true;
1675 finished = true;
1676
1677 if (scanToEnd === true) {
1678 continue;
1679 }
1680 break;
1681 }
1682
1683 if (code === CHAR_QUESTION_MARK) {
1684 isGlob = token.isGlob = true;
1685 finished = true;
1686
1687 if (scanToEnd === true) {
1688 continue;
1689 }
1690 break;
1691 }
1692
1693 if (code === CHAR_LEFT_SQUARE_BRACKET) {
1694 while (eos() !== true && (next = advance())) {
1695 if (next === CHAR_BACKWARD_SLASH) {
1696 backslashes = token.backslashes = true;
1697 advance();
1698 continue;
1699 }
1700
1701 if (next === CHAR_RIGHT_SQUARE_BRACKET) {
1702 isBracket = token.isBracket = true;
1703 isGlob = token.isGlob = true;
1704 finished = true;
1705 break;
1706 }
1707 }
1708
1709 if (scanToEnd === true) {
1710 continue;
1711 }
1712
1713 break;
1714 }
1715
1716 if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
1717 negated = token.negated = true;
1718 start++;
1719 continue;
1720 }
1721
1722 if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
1723 isGlob = token.isGlob = true;
1724
1725 if (scanToEnd === true) {
1726 while (eos() !== true && (code = advance())) {
1727 if (code === CHAR_LEFT_PARENTHESES) {
1728 backslashes = token.backslashes = true;
1729 code = advance();
1730 continue;
1731 }
1732
1733 if (code === CHAR_RIGHT_PARENTHESES) {
1734 finished = true;
1735 break;
1736 }
1737 }
1738 continue;
1739 }
1740 break;
1741 }
1742
1743 if (isGlob === true) {
1744 finished = true;
1745
1746 if (scanToEnd === true) {
1747 continue;
1748 }
1749
1750 break;
1751 }
1752 }
1753
1754 if (opts.noext === true) {
1755 isExtglob = false;
1756 isGlob = false;
1757 }
1758
1759 let base = str;
1760 let prefix = '';
1761 let glob = '';
1762
1763 if (start > 0) {
1764 prefix = str.slice(0, start);
1765 str = str.slice(start);
1766 lastIndex -= start;
1767 }
1768
1769 if (base && isGlob === true && lastIndex > 0) {
1770 base = str.slice(0, lastIndex);
1771 glob = str.slice(lastIndex);
1772 } else if (isGlob === true) {
1773 base = '';
1774 glob = str;
1775 } else {
1776 base = str;
1777 }
1778
1779 if (base && base !== '' && base !== '/' && base !== str) {
1780 if (isPathSeparator(base.charCodeAt(base.length - 1))) {
1781 base = base.slice(0, -1);
1782 }
1783 }
1784
1785 if (opts.unescape === true) {
1786 if (glob) glob = utils$2.removeBackslashes(glob);
1787
1788 if (base && backslashes === true) {
1789 base = utils$2.removeBackslashes(base);
1790 }
1791 }
1792
1793 const state = {
1794 prefix,
1795 input,
1796 start,
1797 base,
1798 glob,
1799 isBrace,
1800 isBracket,
1801 isGlob,
1802 isExtglob,
1803 isGlobstar,
1804 negated,
1805 negatedExtglob
1806 };
1807
1808 if (opts.tokens === true) {
1809 state.maxDepth = 0;
1810 if (!isPathSeparator(code)) {
1811 tokens.push(token);
1812 }
1813 state.tokens = tokens;
1814 }
1815
1816 if (opts.parts === true || opts.tokens === true) {
1817 let prevIndex;
1818
1819 for (let idx = 0; idx < slashes.length; idx++) {
1820 const n = prevIndex ? prevIndex + 1 : start;
1821 const i = slashes[idx];
1822 const value = input.slice(n, i);
1823 if (opts.tokens) {
1824 if (idx === 0 && start !== 0) {
1825 tokens[idx].isPrefix = true;
1826 tokens[idx].value = prefix;
1827 } else {
1828 tokens[idx].value = value;
1829 }
1830 depth(tokens[idx]);
1831 state.maxDepth += tokens[idx].depth;
1832 }
1833 if (idx !== 0 || value !== '') {
1834 parts.push(value);
1835 }
1836 prevIndex = i;
1837 }
1838
1839 if (prevIndex && prevIndex + 1 < input.length) {
1840 const value = input.slice(prevIndex + 1);
1841 parts.push(value);
1842
1843 if (opts.tokens) {
1844 tokens[tokens.length - 1].value = value;
1845 depth(tokens[tokens.length - 1]);
1846 state.maxDepth += tokens[tokens.length - 1].depth;
1847 }
1848 }
1849
1850 state.slashes = slashes;
1851 state.parts = parts;
1852 }
1853
1854 return state;
1855};
1856
1857var scan_1 = scan$1;
1858
1859const constants$1 = constants$2;
1860const utils$1 = utils$3;
1861
1862/**
1863 * Constants
1864 */
1865
1866const {
1867 MAX_LENGTH,
1868 POSIX_REGEX_SOURCE,
1869 REGEX_NON_SPECIAL_CHARS,
1870 REGEX_SPECIAL_CHARS_BACKREF,
1871 REPLACEMENTS
1872} = constants$1;
1873
1874/**
1875 * Helpers
1876 */
1877
1878const expandRange = (args, options) => {
1879 if (typeof options.expandRange === 'function') {
1880 return options.expandRange(...args, options);
1881 }
1882
1883 args.sort();
1884 const value = `[${args.join('-')}]`;
1885
1886 return value;
1887};
1888
1889/**
1890 * Create the message for a syntax error
1891 */
1892
1893const syntaxError = (type, char) => {
1894 return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
1895};
1896
1897/**
1898 * Parse the given input string.
1899 * @param {String} input
1900 * @param {Object} options
1901 * @return {Object}
1902 */
1903
1904const parse$2 = (input, options) => {
1905 if (typeof input !== 'string') {
1906 throw new TypeError('Expected a string');
1907 }
1908
1909 input = REPLACEMENTS[input] || input;
1910
1911 const opts = { ...options };
1912 const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1913
1914 let len = input.length;
1915 if (len > max) {
1916 throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1917 }
1918
1919 const bos = { type: 'bos', value: '', output: opts.prepend || '' };
1920 const tokens = [bos];
1921
1922 const capture = opts.capture ? '' : '?:';
1923 const win32 = utils$1.isWindows(options);
1924
1925 // create constants based on platform, for windows or posix
1926 const PLATFORM_CHARS = constants$1.globChars(win32);
1927 const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
1928
1929 const {
1930 DOT_LITERAL,
1931 PLUS_LITERAL,
1932 SLASH_LITERAL,
1933 ONE_CHAR,
1934 DOTS_SLASH,
1935 NO_DOT,
1936 NO_DOT_SLASH,
1937 NO_DOTS_SLASH,
1938 QMARK,
1939 QMARK_NO_DOT,
1940 STAR,
1941 START_ANCHOR
1942 } = PLATFORM_CHARS;
1943
1944 const globstar = opts => {
1945 return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
1946 };
1947
1948 const nodot = opts.dot ? '' : NO_DOT;
1949 const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
1950 let star = opts.bash === true ? globstar(opts) : STAR;
1951
1952 if (opts.capture) {
1953 star = `(${star})`;
1954 }
1955
1956 // minimatch options support
1957 if (typeof opts.noext === 'boolean') {
1958 opts.noextglob = opts.noext;
1959 }
1960
1961 const state = {
1962 input,
1963 index: -1,
1964 start: 0,
1965 dot: opts.dot === true,
1966 consumed: '',
1967 output: '',
1968 prefix: '',
1969 backtrack: false,
1970 negated: false,
1971 brackets: 0,
1972 braces: 0,
1973 parens: 0,
1974 quotes: 0,
1975 globstar: false,
1976 tokens
1977 };
1978
1979 input = utils$1.removePrefix(input, state);
1980 len = input.length;
1981
1982 const extglobs = [];
1983 const braces = [];
1984 const stack = [];
1985 let prev = bos;
1986 let value;
1987
1988 /**
1989 * Tokenizing helpers
1990 */
1991
1992 const eos = () => state.index === len - 1;
1993 const peek = state.peek = (n = 1) => input[state.index + n];
1994 const advance = state.advance = () => input[++state.index] || '';
1995 const remaining = () => input.slice(state.index + 1);
1996 const consume = (value = '', num = 0) => {
1997 state.consumed += value;
1998 state.index += num;
1999 };
2000
2001 const append = token => {
2002 state.output += token.output != null ? token.output : token.value;
2003 consume(token.value);
2004 };
2005
2006 const negate = () => {
2007 let count = 1;
2008
2009 while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
2010 advance();
2011 state.start++;
2012 count++;
2013 }
2014
2015 if (count % 2 === 0) {
2016 return false;
2017 }
2018
2019 state.negated = true;
2020 state.start++;
2021 return true;
2022 };
2023
2024 const increment = type => {
2025 state[type]++;
2026 stack.push(type);
2027 };
2028
2029 const decrement = type => {
2030 state[type]--;
2031 stack.pop();
2032 };
2033
2034 /**
2035 * Push tokens onto the tokens array. This helper speeds up
2036 * tokenizing by 1) helping us avoid backtracking as much as possible,
2037 * and 2) helping us avoid creating extra tokens when consecutive
2038 * characters are plain text. This improves performance and simplifies
2039 * lookbehinds.
2040 */
2041
2042 const push = tok => {
2043 if (prev.type === 'globstar') {
2044 const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
2045 const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
2046
2047 if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
2048 state.output = state.output.slice(0, -prev.output.length);
2049 prev.type = 'star';
2050 prev.value = '*';
2051 prev.output = star;
2052 state.output += prev.output;
2053 }
2054 }
2055
2056 if (extglobs.length && tok.type !== 'paren') {
2057 extglobs[extglobs.length - 1].inner += tok.value;
2058 }
2059
2060 if (tok.value || tok.output) append(tok);
2061 if (prev && prev.type === 'text' && tok.type === 'text') {
2062 prev.value += tok.value;
2063 prev.output = (prev.output || '') + tok.value;
2064 return;
2065 }
2066
2067 tok.prev = prev;
2068 tokens.push(tok);
2069 prev = tok;
2070 };
2071
2072 const extglobOpen = (type, value) => {
2073 const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
2074
2075 token.prev = prev;
2076 token.parens = state.parens;
2077 token.output = state.output;
2078 const output = (opts.capture ? '(' : '') + token.open;
2079
2080 increment('parens');
2081 push({ type, value, output: state.output ? '' : ONE_CHAR });
2082 push({ type: 'paren', extglob: true, value: advance(), output });
2083 extglobs.push(token);
2084 };
2085
2086 const extglobClose = token => {
2087 let output = token.close + (opts.capture ? ')' : '');
2088 let rest;
2089
2090 if (token.type === 'negate') {
2091 let extglobStar = star;
2092
2093 if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
2094 extglobStar = globstar(opts);
2095 }
2096
2097 if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
2098 output = token.close = `)$))${extglobStar}`;
2099 }
2100
2101 if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
2102 // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
2103 // In this case, we need to parse the string and use it in the output of the original pattern.
2104 // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
2105 //
2106 // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
2107 const expression = parse$2(rest, { ...options, fastpaths: false }).output;
2108
2109 output = token.close = `)${expression})${extglobStar})`;
2110 }
2111
2112 if (token.prev.type === 'bos') {
2113 state.negatedExtglob = true;
2114 }
2115 }
2116
2117 push({ type: 'paren', extglob: true, value, output });
2118 decrement('parens');
2119 };
2120
2121 /**
2122 * Fast paths
2123 */
2124
2125 if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
2126 let backslashes = false;
2127
2128 let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
2129 if (first === '\\') {
2130 backslashes = true;
2131 return m;
2132 }
2133
2134 if (first === '?') {
2135 if (esc) {
2136 return esc + first + (rest ? QMARK.repeat(rest.length) : '');
2137 }
2138 if (index === 0) {
2139 return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
2140 }
2141 return QMARK.repeat(chars.length);
2142 }
2143
2144 if (first === '.') {
2145 return DOT_LITERAL.repeat(chars.length);
2146 }
2147
2148 if (first === '*') {
2149 if (esc) {
2150 return esc + first + (rest ? star : '');
2151 }
2152 return star;
2153 }
2154 return esc ? m : `\\${m}`;
2155 });
2156
2157 if (backslashes === true) {
2158 if (opts.unescape === true) {
2159 output = output.replace(/\\/g, '');
2160 } else {
2161 output = output.replace(/\\+/g, m => {
2162 return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
2163 });
2164 }
2165 }
2166
2167 if (output === input && opts.contains === true) {
2168 state.output = input;
2169 return state;
2170 }
2171
2172 state.output = utils$1.wrapOutput(output, state, options);
2173 return state;
2174 }
2175
2176 /**
2177 * Tokenize input until we reach end-of-string
2178 */
2179
2180 while (!eos()) {
2181 value = advance();
2182
2183 if (value === '\u0000') {
2184 continue;
2185 }
2186
2187 /**
2188 * Escaped characters
2189 */
2190
2191 if (value === '\\') {
2192 const next = peek();
2193
2194 if (next === '/' && opts.bash !== true) {
2195 continue;
2196 }
2197
2198 if (next === '.' || next === ';') {
2199 continue;
2200 }
2201
2202 if (!next) {
2203 value += '\\';
2204 push({ type: 'text', value });
2205 continue;
2206 }
2207
2208 // collapse slashes to reduce potential for exploits
2209 const match = /^\\+/.exec(remaining());
2210 let slashes = 0;
2211
2212 if (match && match[0].length > 2) {
2213 slashes = match[0].length;
2214 state.index += slashes;
2215 if (slashes % 2 !== 0) {
2216 value += '\\';
2217 }
2218 }
2219
2220 if (opts.unescape === true) {
2221 value = advance();
2222 } else {
2223 value += advance();
2224 }
2225
2226 if (state.brackets === 0) {
2227 push({ type: 'text', value });
2228 continue;
2229 }
2230 }
2231
2232 /**
2233 * If we're inside a regex character class, continue
2234 * until we reach the closing bracket.
2235 */
2236
2237 if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
2238 if (opts.posix !== false && value === ':') {
2239 const inner = prev.value.slice(1);
2240 if (inner.includes('[')) {
2241 prev.posix = true;
2242
2243 if (inner.includes(':')) {
2244 const idx = prev.value.lastIndexOf('[');
2245 const pre = prev.value.slice(0, idx);
2246 const rest = prev.value.slice(idx + 2);
2247 const posix = POSIX_REGEX_SOURCE[rest];
2248 if (posix) {
2249 prev.value = pre + posix;
2250 state.backtrack = true;
2251 advance();
2252
2253 if (!bos.output && tokens.indexOf(prev) === 1) {
2254 bos.output = ONE_CHAR;
2255 }
2256 continue;
2257 }
2258 }
2259 }
2260 }
2261
2262 if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
2263 value = `\\${value}`;
2264 }
2265
2266 if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
2267 value = `\\${value}`;
2268 }
2269
2270 if (opts.posix === true && value === '!' && prev.value === '[') {
2271 value = '^';
2272 }
2273
2274 prev.value += value;
2275 append({ value });
2276 continue;
2277 }
2278
2279 /**
2280 * If we're inside a quoted string, continue
2281 * until we reach the closing double quote.
2282 */
2283
2284 if (state.quotes === 1 && value !== '"') {
2285 value = utils$1.escapeRegex(value);
2286 prev.value += value;
2287 append({ value });
2288 continue;
2289 }
2290
2291 /**
2292 * Double quotes
2293 */
2294
2295 if (value === '"') {
2296 state.quotes = state.quotes === 1 ? 0 : 1;
2297 if (opts.keepQuotes === true) {
2298 push({ type: 'text', value });
2299 }
2300 continue;
2301 }
2302
2303 /**
2304 * Parentheses
2305 */
2306
2307 if (value === '(') {
2308 increment('parens');
2309 push({ type: 'paren', value });
2310 continue;
2311 }
2312
2313 if (value === ')') {
2314 if (state.parens === 0 && opts.strictBrackets === true) {
2315 throw new SyntaxError(syntaxError('opening', '('));
2316 }
2317
2318 const extglob = extglobs[extglobs.length - 1];
2319 if (extglob && state.parens === extglob.parens + 1) {
2320 extglobClose(extglobs.pop());
2321 continue;
2322 }
2323
2324 push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
2325 decrement('parens');
2326 continue;
2327 }
2328
2329 /**
2330 * Square brackets
2331 */
2332
2333 if (value === '[') {
2334 if (opts.nobracket === true || !remaining().includes(']')) {
2335 if (opts.nobracket !== true && opts.strictBrackets === true) {
2336 throw new SyntaxError(syntaxError('closing', ']'));
2337 }
2338
2339 value = `\\${value}`;
2340 } else {
2341 increment('brackets');
2342 }
2343
2344 push({ type: 'bracket', value });
2345 continue;
2346 }
2347
2348 if (value === ']') {
2349 if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
2350 push({ type: 'text', value, output: `\\${value}` });
2351 continue;
2352 }
2353
2354 if (state.brackets === 0) {
2355 if (opts.strictBrackets === true) {
2356 throw new SyntaxError(syntaxError('opening', '['));
2357 }
2358
2359 push({ type: 'text', value, output: `\\${value}` });
2360 continue;
2361 }
2362
2363 decrement('brackets');
2364
2365 const prevValue = prev.value.slice(1);
2366 if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
2367 value = `/${value}`;
2368 }
2369
2370 prev.value += value;
2371 append({ value });
2372
2373 // when literal brackets are explicitly disabled
2374 // assume we should match with a regex character class
2375 if (opts.literalBrackets === false || utils$1.hasRegexChars(prevValue)) {
2376 continue;
2377 }
2378
2379 const escaped = utils$1.escapeRegex(prev.value);
2380 state.output = state.output.slice(0, -prev.value.length);
2381
2382 // when literal brackets are explicitly enabled
2383 // assume we should escape the brackets to match literal characters
2384 if (opts.literalBrackets === true) {
2385 state.output += escaped;
2386 prev.value = escaped;
2387 continue;
2388 }
2389
2390 // when the user specifies nothing, try to match both
2391 prev.value = `(${capture}${escaped}|${prev.value})`;
2392 state.output += prev.value;
2393 continue;
2394 }
2395
2396 /**
2397 * Braces
2398 */
2399
2400 if (value === '{' && opts.nobrace !== true) {
2401 increment('braces');
2402
2403 const open = {
2404 type: 'brace',
2405 value,
2406 output: '(',
2407 outputIndex: state.output.length,
2408 tokensIndex: state.tokens.length
2409 };
2410
2411 braces.push(open);
2412 push(open);
2413 continue;
2414 }
2415
2416 if (value === '}') {
2417 const brace = braces[braces.length - 1];
2418
2419 if (opts.nobrace === true || !brace) {
2420 push({ type: 'text', value, output: value });
2421 continue;
2422 }
2423
2424 let output = ')';
2425
2426 if (brace.dots === true) {
2427 const arr = tokens.slice();
2428 const range = [];
2429
2430 for (let i = arr.length - 1; i >= 0; i--) {
2431 tokens.pop();
2432 if (arr[i].type === 'brace') {
2433 break;
2434 }
2435 if (arr[i].type !== 'dots') {
2436 range.unshift(arr[i].value);
2437 }
2438 }
2439
2440 output = expandRange(range, opts);
2441 state.backtrack = true;
2442 }
2443
2444 if (brace.comma !== true && brace.dots !== true) {
2445 const out = state.output.slice(0, brace.outputIndex);
2446 const toks = state.tokens.slice(brace.tokensIndex);
2447 brace.value = brace.output = '\\{';
2448 value = output = '\\}';
2449 state.output = out;
2450 for (const t of toks) {
2451 state.output += (t.output || t.value);
2452 }
2453 }
2454
2455 push({ type: 'brace', value, output });
2456 decrement('braces');
2457 braces.pop();
2458 continue;
2459 }
2460
2461 /**
2462 * Pipes
2463 */
2464
2465 if (value === '|') {
2466 if (extglobs.length > 0) {
2467 extglobs[extglobs.length - 1].conditions++;
2468 }
2469 push({ type: 'text', value });
2470 continue;
2471 }
2472
2473 /**
2474 * Commas
2475 */
2476
2477 if (value === ',') {
2478 let output = value;
2479
2480 const brace = braces[braces.length - 1];
2481 if (brace && stack[stack.length - 1] === 'braces') {
2482 brace.comma = true;
2483 output = '|';
2484 }
2485
2486 push({ type: 'comma', value, output });
2487 continue;
2488 }
2489
2490 /**
2491 * Slashes
2492 */
2493
2494 if (value === '/') {
2495 // if the beginning of the glob is "./", advance the start
2496 // to the current index, and don't add the "./" characters
2497 // to the state. This greatly simplifies lookbehinds when
2498 // checking for BOS characters like "!" and "." (not "./")
2499 if (prev.type === 'dot' && state.index === state.start + 1) {
2500 state.start = state.index + 1;
2501 state.consumed = '';
2502 state.output = '';
2503 tokens.pop();
2504 prev = bos; // reset "prev" to the first token
2505 continue;
2506 }
2507
2508 push({ type: 'slash', value, output: SLASH_LITERAL });
2509 continue;
2510 }
2511
2512 /**
2513 * Dots
2514 */
2515
2516 if (value === '.') {
2517 if (state.braces > 0 && prev.type === 'dot') {
2518 if (prev.value === '.') prev.output = DOT_LITERAL;
2519 const brace = braces[braces.length - 1];
2520 prev.type = 'dots';
2521 prev.output += value;
2522 prev.value += value;
2523 brace.dots = true;
2524 continue;
2525 }
2526
2527 if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
2528 push({ type: 'text', value, output: DOT_LITERAL });
2529 continue;
2530 }
2531
2532 push({ type: 'dot', value, output: DOT_LITERAL });
2533 continue;
2534 }
2535
2536 /**
2537 * Question marks
2538 */
2539
2540 if (value === '?') {
2541 const isGroup = prev && prev.value === '(';
2542 if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2543 extglobOpen('qmark', value);
2544 continue;
2545 }
2546
2547 if (prev && prev.type === 'paren') {
2548 const next = peek();
2549 let output = value;
2550
2551 if (next === '<' && !utils$1.supportsLookbehinds()) {
2552 throw new Error('Node.js v10 or higher is required for regex lookbehinds');
2553 }
2554
2555 if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
2556 output = `\\${value}`;
2557 }
2558
2559 push({ type: 'text', value, output });
2560 continue;
2561 }
2562
2563 if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
2564 push({ type: 'qmark', value, output: QMARK_NO_DOT });
2565 continue;
2566 }
2567
2568 push({ type: 'qmark', value, output: QMARK });
2569 continue;
2570 }
2571
2572 /**
2573 * Exclamation
2574 */
2575
2576 if (value === '!') {
2577 if (opts.noextglob !== true && peek() === '(') {
2578 if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
2579 extglobOpen('negate', value);
2580 continue;
2581 }
2582 }
2583
2584 if (opts.nonegate !== true && state.index === 0) {
2585 negate();
2586 continue;
2587 }
2588 }
2589
2590 /**
2591 * Plus
2592 */
2593
2594 if (value === '+') {
2595 if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2596 extglobOpen('plus', value);
2597 continue;
2598 }
2599
2600 if ((prev && prev.value === '(') || opts.regex === false) {
2601 push({ type: 'plus', value, output: PLUS_LITERAL });
2602 continue;
2603 }
2604
2605 if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
2606 push({ type: 'plus', value });
2607 continue;
2608 }
2609
2610 push({ type: 'plus', value: PLUS_LITERAL });
2611 continue;
2612 }
2613
2614 /**
2615 * Plain text
2616 */
2617
2618 if (value === '@') {
2619 if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
2620 push({ type: 'at', extglob: true, value, output: '' });
2621 continue;
2622 }
2623
2624 push({ type: 'text', value });
2625 continue;
2626 }
2627
2628 /**
2629 * Plain text
2630 */
2631
2632 if (value !== '*') {
2633 if (value === '$' || value === '^') {
2634 value = `\\${value}`;
2635 }
2636
2637 const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
2638 if (match) {
2639 value += match[0];
2640 state.index += match[0].length;
2641 }
2642
2643 push({ type: 'text', value });
2644 continue;
2645 }
2646
2647 /**
2648 * Stars
2649 */
2650
2651 if (prev && (prev.type === 'globstar' || prev.star === true)) {
2652 prev.type = 'star';
2653 prev.star = true;
2654 prev.value += value;
2655 prev.output = star;
2656 state.backtrack = true;
2657 state.globstar = true;
2658 consume(value);
2659 continue;
2660 }
2661
2662 let rest = remaining();
2663 if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
2664 extglobOpen('star', value);
2665 continue;
2666 }
2667
2668 if (prev.type === 'star') {
2669 if (opts.noglobstar === true) {
2670 consume(value);
2671 continue;
2672 }
2673
2674 const prior = prev.prev;
2675 const before = prior.prev;
2676 const isStart = prior.type === 'slash' || prior.type === 'bos';
2677 const afterStar = before && (before.type === 'star' || before.type === 'globstar');
2678
2679 if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
2680 push({ type: 'star', value, output: '' });
2681 continue;
2682 }
2683
2684 const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
2685 const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
2686 if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
2687 push({ type: 'star', value, output: '' });
2688 continue;
2689 }
2690
2691 // strip consecutive `/**/`
2692 while (rest.slice(0, 3) === '/**') {
2693 const after = input[state.index + 4];
2694 if (after && after !== '/') {
2695 break;
2696 }
2697 rest = rest.slice(3);
2698 consume('/**', 3);
2699 }
2700
2701 if (prior.type === 'bos' && eos()) {
2702 prev.type = 'globstar';
2703 prev.value += value;
2704 prev.output = globstar(opts);
2705 state.output = prev.output;
2706 state.globstar = true;
2707 consume(value);
2708 continue;
2709 }
2710
2711 if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
2712 state.output = state.output.slice(0, -(prior.output + prev.output).length);
2713 prior.output = `(?:${prior.output}`;
2714
2715 prev.type = 'globstar';
2716 prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
2717 prev.value += value;
2718 state.globstar = true;
2719 state.output += prior.output + prev.output;
2720 consume(value);
2721 continue;
2722 }
2723
2724 if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
2725 const end = rest[1] !== void 0 ? '|$' : '';
2726
2727 state.output = state.output.slice(0, -(prior.output + prev.output).length);
2728 prior.output = `(?:${prior.output}`;
2729
2730 prev.type = 'globstar';
2731 prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
2732 prev.value += value;
2733
2734 state.output += prior.output + prev.output;
2735 state.globstar = true;
2736
2737 consume(value + advance());
2738
2739 push({ type: 'slash', value: '/', output: '' });
2740 continue;
2741 }
2742
2743 if (prior.type === 'bos' && rest[0] === '/') {
2744 prev.type = 'globstar';
2745 prev.value += value;
2746 prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
2747 state.output = prev.output;
2748 state.globstar = true;
2749 consume(value + advance());
2750 push({ type: 'slash', value: '/', output: '' });
2751 continue;
2752 }
2753
2754 // remove single star from output
2755 state.output = state.output.slice(0, -prev.output.length);
2756
2757 // reset previous token to globstar
2758 prev.type = 'globstar';
2759 prev.output = globstar(opts);
2760 prev.value += value;
2761
2762 // reset output with globstar
2763 state.output += prev.output;
2764 state.globstar = true;
2765 consume(value);
2766 continue;
2767 }
2768
2769 const token = { type: 'star', value, output: star };
2770
2771 if (opts.bash === true) {
2772 token.output = '.*?';
2773 if (prev.type === 'bos' || prev.type === 'slash') {
2774 token.output = nodot + token.output;
2775 }
2776 push(token);
2777 continue;
2778 }
2779
2780 if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
2781 token.output = value;
2782 push(token);
2783 continue;
2784 }
2785
2786 if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
2787 if (prev.type === 'dot') {
2788 state.output += NO_DOT_SLASH;
2789 prev.output += NO_DOT_SLASH;
2790
2791 } else if (opts.dot === true) {
2792 state.output += NO_DOTS_SLASH;
2793 prev.output += NO_DOTS_SLASH;
2794
2795 } else {
2796 state.output += nodot;
2797 prev.output += nodot;
2798 }
2799
2800 if (peek() !== '*') {
2801 state.output += ONE_CHAR;
2802 prev.output += ONE_CHAR;
2803 }
2804 }
2805
2806 push(token);
2807 }
2808
2809 while (state.brackets > 0) {
2810 if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
2811 state.output = utils$1.escapeLast(state.output, '[');
2812 decrement('brackets');
2813 }
2814
2815 while (state.parens > 0) {
2816 if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
2817 state.output = utils$1.escapeLast(state.output, '(');
2818 decrement('parens');
2819 }
2820
2821 while (state.braces > 0) {
2822 if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
2823 state.output = utils$1.escapeLast(state.output, '{');
2824 decrement('braces');
2825 }
2826
2827 if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
2828 push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
2829 }
2830
2831 // rebuild the output if we had to backtrack at any point
2832 if (state.backtrack === true) {
2833 state.output = '';
2834
2835 for (const token of state.tokens) {
2836 state.output += token.output != null ? token.output : token.value;
2837
2838 if (token.suffix) {
2839 state.output += token.suffix;
2840 }
2841 }
2842 }
2843
2844 return state;
2845};
2846
2847/**
2848 * Fast paths for creating regular expressions for common glob patterns.
2849 * This can significantly speed up processing and has very little downside
2850 * impact when none of the fast paths match.
2851 */
2852
2853parse$2.fastpaths = (input, options) => {
2854 const opts = { ...options };
2855 const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
2856 const len = input.length;
2857 if (len > max) {
2858 throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
2859 }
2860
2861 input = REPLACEMENTS[input] || input;
2862 const win32 = utils$1.isWindows(options);
2863
2864 // create constants based on platform, for windows or posix
2865 const {
2866 DOT_LITERAL,
2867 SLASH_LITERAL,
2868 ONE_CHAR,
2869 DOTS_SLASH,
2870 NO_DOT,
2871 NO_DOTS,
2872 NO_DOTS_SLASH,
2873 STAR,
2874 START_ANCHOR
2875 } = constants$1.globChars(win32);
2876
2877 const nodot = opts.dot ? NO_DOTS : NO_DOT;
2878 const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
2879 const capture = opts.capture ? '' : '?:';
2880 const state = { negated: false, prefix: '' };
2881 let star = opts.bash === true ? '.*?' : STAR;
2882
2883 if (opts.capture) {
2884 star = `(${star})`;
2885 }
2886
2887 const globstar = opts => {
2888 if (opts.noglobstar === true) return star;
2889 return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
2890 };
2891
2892 const create = str => {
2893 switch (str) {
2894 case '*':
2895 return `${nodot}${ONE_CHAR}${star}`;
2896
2897 case '.*':
2898 return `${DOT_LITERAL}${ONE_CHAR}${star}`;
2899
2900 case '*.*':
2901 return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
2902
2903 case '*/*':
2904 return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
2905
2906 case '**':
2907 return nodot + globstar(opts);
2908
2909 case '**/*':
2910 return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
2911
2912 case '**/*.*':
2913 return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
2914
2915 case '**/.*':
2916 return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
2917
2918 default: {
2919 const match = /^(.*?)\.(\w+)$/.exec(str);
2920 if (!match) return;
2921
2922 const source = create(match[1]);
2923 if (!source) return;
2924
2925 return source + DOT_LITERAL + match[2];
2926 }
2927 }
2928 };
2929
2930 const output = utils$1.removePrefix(input, state);
2931 let source = create(output);
2932
2933 if (source && opts.strictSlashes !== true) {
2934 source += `${SLASH_LITERAL}?`;
2935 }
2936
2937 return source;
2938};
2939
2940var parse_1$1 = parse$2;
2941
2942const path$1 = require$$0$1;
2943const scan = scan_1;
2944const parse$1 = parse_1$1;
2945const utils = utils$3;
2946const constants = constants$2;
2947const isObject$2 = val => val && typeof val === 'object' && !Array.isArray(val);
2948
2949/**
2950 * Creates a matcher function from one or more glob patterns. The
2951 * returned function takes a string to match as its first argument,
2952 * and returns true if the string is a match. The returned matcher
2953 * function also takes a boolean as the second argument that, when true,
2954 * returns an object with additional information.
2955 *
2956 * ```js
2957 * const picomatch = require('picomatch');
2958 * // picomatch(glob[, options]);
2959 *
2960 * const isMatch = picomatch('*.!(*a)');
2961 * console.log(isMatch('a.a')); //=> false
2962 * console.log(isMatch('a.b')); //=> true
2963 * ```
2964 * @name picomatch
2965 * @param {String|Array} `globs` One or more glob patterns.
2966 * @param {Object=} `options`
2967 * @return {Function=} Returns a matcher function.
2968 * @api public
2969 */
2970
2971const picomatch$1 = (glob, options, returnState = false) => {
2972 if (Array.isArray(glob)) {
2973 const fns = glob.map(input => picomatch$1(input, options, returnState));
2974 const arrayMatcher = str => {
2975 for (const isMatch of fns) {
2976 const state = isMatch(str);
2977 if (state) return state;
2978 }
2979 return false;
2980 };
2981 return arrayMatcher;
2982 }
2983
2984 const isState = isObject$2(glob) && glob.tokens && glob.input;
2985
2986 if (glob === '' || (typeof glob !== 'string' && !isState)) {
2987 throw new TypeError('Expected pattern to be a non-empty string');
2988 }
2989
2990 const opts = options || {};
2991 const posix = utils.isWindows(options);
2992 const regex = isState
2993 ? picomatch$1.compileRe(glob, options)
2994 : picomatch$1.makeRe(glob, options, false, true);
2995
2996 const state = regex.state;
2997 delete regex.state;
2998
2999 let isIgnored = () => false;
3000 if (opts.ignore) {
3001 const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
3002 isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
3003 }
3004
3005 const matcher = (input, returnObject = false) => {
3006 const { isMatch, match, output } = picomatch$1.test(input, regex, options, { glob, posix });
3007 const result = { glob, state, regex, posix, input, output, match, isMatch };
3008
3009 if (typeof opts.onResult === 'function') {
3010 opts.onResult(result);
3011 }
3012
3013 if (isMatch === false) {
3014 result.isMatch = false;
3015 return returnObject ? result : false;
3016 }
3017
3018 if (isIgnored(input)) {
3019 if (typeof opts.onIgnore === 'function') {
3020 opts.onIgnore(result);
3021 }
3022 result.isMatch = false;
3023 return returnObject ? result : false;
3024 }
3025
3026 if (typeof opts.onMatch === 'function') {
3027 opts.onMatch(result);
3028 }
3029 return returnObject ? result : true;
3030 };
3031
3032 if (returnState) {
3033 matcher.state = state;
3034 }
3035
3036 return matcher;
3037};
3038
3039/**
3040 * Test `input` with the given `regex`. This is used by the main
3041 * `picomatch()` function to test the input string.
3042 *
3043 * ```js
3044 * const picomatch = require('picomatch');
3045 * // picomatch.test(input, regex[, options]);
3046 *
3047 * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
3048 * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
3049 * ```
3050 * @param {String} `input` String to test.
3051 * @param {RegExp} `regex`
3052 * @return {Object} Returns an object with matching info.
3053 * @api public
3054 */
3055
3056picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
3057 if (typeof input !== 'string') {
3058 throw new TypeError('Expected input to be a string');
3059 }
3060
3061 if (input === '') {
3062 return { isMatch: false, output: '' };
3063 }
3064
3065 const opts = options || {};
3066 const format = opts.format || (posix ? utils.toPosixSlashes : null);
3067 let match = input === glob;
3068 let output = (match && format) ? format(input) : input;
3069
3070 if (match === false) {
3071 output = format ? format(input) : input;
3072 match = output === glob;
3073 }
3074
3075 if (match === false || opts.capture === true) {
3076 if (opts.matchBase === true || opts.basename === true) {
3077 match = picomatch$1.matchBase(input, regex, options, posix);
3078 } else {
3079 match = regex.exec(output);
3080 }
3081 }
3082
3083 return { isMatch: Boolean(match), match, output };
3084};
3085
3086/**
3087 * Match the basename of a filepath.
3088 *
3089 * ```js
3090 * const picomatch = require('picomatch');
3091 * // picomatch.matchBase(input, glob[, options]);
3092 * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
3093 * ```
3094 * @param {String} `input` String to test.
3095 * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
3096 * @return {Boolean}
3097 * @api public
3098 */
3099
3100picomatch$1.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
3101 const regex = glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options);
3102 return regex.test(path$1.basename(input));
3103};
3104
3105/**
3106 * Returns true if **any** of the given glob `patterns` match the specified `string`.
3107 *
3108 * ```js
3109 * const picomatch = require('picomatch');
3110 * // picomatch.isMatch(string, patterns[, options]);
3111 *
3112 * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
3113 * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
3114 * ```
3115 * @param {String|Array} str The string to test.
3116 * @param {String|Array} patterns One or more glob patterns to use for matching.
3117 * @param {Object} [options] See available [options](#options).
3118 * @return {Boolean} Returns true if any patterns match `str`
3119 * @api public
3120 */
3121
3122picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
3123
3124/**
3125 * Parse a glob pattern to create the source string for a regular
3126 * expression.
3127 *
3128 * ```js
3129 * const picomatch = require('picomatch');
3130 * const result = picomatch.parse(pattern[, options]);
3131 * ```
3132 * @param {String} `pattern`
3133 * @param {Object} `options`
3134 * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
3135 * @api public
3136 */
3137
3138picomatch$1.parse = (pattern, options) => {
3139 if (Array.isArray(pattern)) return pattern.map(p => picomatch$1.parse(p, options));
3140 return parse$1(pattern, { ...options, fastpaths: false });
3141};
3142
3143/**
3144 * Scan a glob pattern to separate the pattern into segments.
3145 *
3146 * ```js
3147 * const picomatch = require('picomatch');
3148 * // picomatch.scan(input[, options]);
3149 *
3150 * const result = picomatch.scan('!./foo/*.js');
3151 * console.log(result);
3152 * { prefix: '!./',
3153 * input: '!./foo/*.js',
3154 * start: 3,
3155 * base: 'foo',
3156 * glob: '*.js',
3157 * isBrace: false,
3158 * isBracket: false,
3159 * isGlob: true,
3160 * isExtglob: false,
3161 * isGlobstar: false,
3162 * negated: true }
3163 * ```
3164 * @param {String} `input` Glob pattern to scan.
3165 * @param {Object} `options`
3166 * @return {Object} Returns an object with
3167 * @api public
3168 */
3169
3170picomatch$1.scan = (input, options) => scan(input, options);
3171
3172/**
3173 * Compile a regular expression from the `state` object returned by the
3174 * [parse()](#parse) method.
3175 *
3176 * @param {Object} `state`
3177 * @param {Object} `options`
3178 * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
3179 * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
3180 * @return {RegExp}
3181 * @api public
3182 */
3183
3184picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
3185 if (returnOutput === true) {
3186 return state.output;
3187 }
3188
3189 const opts = options || {};
3190 const prepend = opts.contains ? '' : '^';
3191 const append = opts.contains ? '' : '$';
3192
3193 let source = `${prepend}(?:${state.output})${append}`;
3194 if (state && state.negated === true) {
3195 source = `^(?!${source}).*$`;
3196 }
3197
3198 const regex = picomatch$1.toRegex(source, options);
3199 if (returnState === true) {
3200 regex.state = state;
3201 }
3202
3203 return regex;
3204};
3205
3206/**
3207 * Create a regular expression from a parsed glob pattern.
3208 *
3209 * ```js
3210 * const picomatch = require('picomatch');
3211 * const state = picomatch.parse('*.js');
3212 * // picomatch.compileRe(state[, options]);
3213 *
3214 * console.log(picomatch.compileRe(state));
3215 * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
3216 * ```
3217 * @param {String} `state` The object returned from the `.parse` method.
3218 * @param {Object} `options`
3219 * @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.
3220 * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
3221 * @return {RegExp} Returns a regex created from the given pattern.
3222 * @api public
3223 */
3224
3225picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
3226 if (!input || typeof input !== 'string') {
3227 throw new TypeError('Expected a non-empty string');
3228 }
3229
3230 let parsed = { negated: false, fastpaths: true };
3231
3232 if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
3233 parsed.output = parse$1.fastpaths(input, options);
3234 }
3235
3236 if (!parsed.output) {
3237 parsed = parse$1(input, options);
3238 }
3239
3240 return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
3241};
3242
3243/**
3244 * Create a regular expression from the given regex source string.
3245 *
3246 * ```js
3247 * const picomatch = require('picomatch');
3248 * // picomatch.toRegex(source[, options]);
3249 *
3250 * const { output } = picomatch.parse('*.js');
3251 * console.log(picomatch.toRegex(output));
3252 * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
3253 * ```
3254 * @param {String} `source` Regular expression source string.
3255 * @param {Object} `options`
3256 * @return {RegExp}
3257 * @api public
3258 */
3259
3260picomatch$1.toRegex = (source, options) => {
3261 try {
3262 const opts = options || {};
3263 return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
3264 } catch (err) {
3265 if (options && options.debug === true) throw err;
3266 return /$^/;
3267 }
3268};
3269
3270/**
3271 * Picomatch constants.
3272 * @return {Object}
3273 */
3274
3275picomatch$1.constants = constants;
3276
3277/**
3278 * Expose "picomatch"
3279 */
3280
3281var picomatch_1 = picomatch$1;
3282
3283var picomatch = picomatch_1;
3284
3285var pm = /*@__PURE__*/getDefaultExportFromCjs(picomatch);
3286
3287// Helper since Typescript can't detect readonly arrays with Array.isArray
3288function isArray(arg) {
3289 return Array.isArray(arg);
3290}
3291function ensureArray(thing) {
3292 if (isArray(thing))
3293 return thing;
3294 if (thing == null)
3295 return [];
3296 return [thing];
3297}
3298
3299const normalizePath$1 = function normalizePath(filename) {
3300 return filename.split(require$$0$1.win32.sep).join(require$$0$1.posix.sep);
3301};
3302
3303function getMatcherString(id, resolutionBase) {
3304 if (resolutionBase === false || require$$0$1.isAbsolute(id) || id.startsWith('**')) {
3305 return normalizePath$1(id);
3306 }
3307 // resolve('') is valid and will default to process.cwd()
3308 const basePath = normalizePath$1(require$$0$1.resolve(resolutionBase || ''))
3309 // escape all possible (posix + win) path characters that might interfere with regex
3310 .replace(/[-^$*+?.()|[\]{}]/g, '\\$&');
3311 // Note that we use posix.join because:
3312 // 1. the basePath has been normalized to use /
3313 // 2. the incoming glob (id) matcher, also uses /
3314 // otherwise Node will force backslash (\) on windows
3315 return require$$0$1.posix.join(basePath, normalizePath$1(id));
3316}
3317const createFilter$1 = function createFilter(include, exclude, options) {
3318 const resolutionBase = options && options.resolve;
3319 const getMatcher = (id) => id instanceof RegExp
3320 ? id
3321 : {
3322 test: (what) => {
3323 // this refactor is a tad overly verbose but makes for easy debugging
3324 const pattern = getMatcherString(id, resolutionBase);
3325 const fn = pm(pattern, { dot: true });
3326 const result = fn(what);
3327 return result;
3328 }
3329 };
3330 const includeMatchers = ensureArray(include).map(getMatcher);
3331 const excludeMatchers = ensureArray(exclude).map(getMatcher);
3332 return function result(id) {
3333 if (typeof id !== 'string')
3334 return false;
3335 if (/\0/.test(id))
3336 return false;
3337 const pathId = normalizePath$1(id);
3338 for (let i = 0; i < excludeMatchers.length; ++i) {
3339 const matcher = excludeMatchers[i];
3340 if (matcher.test(pathId))
3341 return false;
3342 }
3343 for (let i = 0; i < includeMatchers.length; ++i) {
3344 const matcher = includeMatchers[i];
3345 if (matcher.test(pathId))
3346 return true;
3347 }
3348 return !includeMatchers.length;
3349 };
3350};
3351
3352const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public';
3353const builtins = 'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl';
3354const forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(' '));
3355forbiddenIdentifiers.add('');
3356
3357const isWindows = typeof process !== "undefined" && process.platform === "win32";
3358const windowsSlashRE = /\\/g;
3359function slash(p) {
3360 return p.replace(windowsSlashRE, "/");
3361}
3362const postfixRE = /[?#].*$/;
3363function cleanUrl(url) {
3364 return url.replace(postfixRE, "");
3365}
3366function withTrailingSlash(path) {
3367 if (path[path.length - 1] !== "/") {
3368 return `${path}/`;
3369 }
3370 return path;
3371}
3372
3373if (process.versions.pnp) {
3374 try {
3375 node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)))("pnpapi");
3376 } catch {
3377 }
3378}
3379
3380const createFilter = createFilter$1;
3381node_module.builtinModules.filter((id) => !id.includes(":"));
3382function isInNodeModules(id) {
3383 return id.includes("node_modules");
3384}
3385const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)));
3386function resolveDependencyVersion(dep, pkgRelativePath = "../../package.json") {
3387 const pkgPath = path$3.resolve(_require.resolve(dep), pkgRelativePath);
3388 return JSON.parse(fs$1.readFileSync(pkgPath, "utf-8")).version;
3389}
3390const rollupVersion = resolveDependencyVersion("rollup");
3391const filter = process.env.VITE_DEBUG_FILTER;
3392const DEBUG = process.env.DEBUG;
3393function createDebugger(namespace, options = {}) {
3394 const log = debug$2(namespace);
3395 const { onlyWhenFocused } = options;
3396 let enabled = log.enabled;
3397 if (enabled && onlyWhenFocused) {
3398 const ns = typeof onlyWhenFocused === "string" ? onlyWhenFocused : namespace;
3399 enabled = !!DEBUG?.includes(ns);
3400 }
3401 if (enabled) {
3402 return (...args) => {
3403 if (!filter || args.some((a) => a?.includes?.(filter))) {
3404 log(...args);
3405 }
3406 };
3407 }
3408}
3409function testCaseInsensitiveFS() {
3410 if (!CLIENT_ENTRY.endsWith("client.mjs")) {
3411 throw new Error(
3412 `cannot test case insensitive FS, CLIENT_ENTRY const doesn't contain client.mjs`
3413 );
3414 }
3415 if (!fs$1.existsSync(CLIENT_ENTRY)) {
3416 throw new Error(
3417 "cannot test case insensitive FS, CLIENT_ENTRY does not point to an existing file: " + CLIENT_ENTRY
3418 );
3419 }
3420 return fs$1.existsSync(CLIENT_ENTRY.replace("client.mjs", "cLiEnT.mjs"));
3421}
3422const isCaseInsensitiveFS = testCaseInsensitiveFS();
3423const VOLUME_RE = /^[A-Z]:/i;
3424function normalizePath(id) {
3425 return path$3.posix.normalize(isWindows ? slash(id) : id);
3426}
3427function fsPathFromId(id) {
3428 const fsPath = normalizePath(
3429 id.startsWith(FS_PREFIX) ? id.slice(FS_PREFIX.length) : id
3430 );
3431 return fsPath[0] === "/" || VOLUME_RE.test(fsPath) ? fsPath : `/${fsPath}`;
3432}
3433function fsPathFromUrl(url) {
3434 return fsPathFromId(cleanUrl(url));
3435}
3436function isParentDirectory(dir, file) {
3437 dir = withTrailingSlash(dir);
3438 return file.startsWith(dir) || isCaseInsensitiveFS && file.toLowerCase().startsWith(dir.toLowerCase());
3439}
3440function isSameFileUri(file1, file2) {
3441 return file1 === file2 || isCaseInsensitiveFS && file1.toLowerCase() === file2.toLowerCase();
3442}
3443const trailingSeparatorRE = /[?&]$/;
3444const timestampRE = /\bt=\d{13}&?\b/;
3445function removeTimestampQuery(url) {
3446 return url.replace(timestampRE, "").replace(trailingSeparatorRE, "");
3447}
3448function isObject$1(value) {
3449 return Object.prototype.toString.call(value) === "[object Object]";
3450}
3451function tryStatSync(file) {
3452 try {
3453 return fs$1.statSync(file, { throwIfNoEntry: false });
3454 } catch {
3455 }
3456}
3457function isFileReadable(filename) {
3458 if (!tryStatSync(filename)) {
3459 return false;
3460 }
3461 try {
3462 fs$1.accessSync(filename, fs$1.constants.R_OK);
3463 return true;
3464 } catch {
3465 return false;
3466 }
3467}
3468function arraify(target) {
3469 return Array.isArray(target) ? target : [target];
3470}
3471path$3.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))));
3472function backwardCompatibleWorkerPlugins(plugins) {
3473 if (Array.isArray(plugins)) {
3474 return plugins;
3475 }
3476 if (typeof plugins === "function") {
3477 return plugins();
3478 }
3479 return [];
3480}
3481function mergeConfigRecursively(defaults, overrides, rootPath) {
3482 const merged = { ...defaults };
3483 for (const key in overrides) {
3484 const value = overrides[key];
3485 if (value == null) {
3486 continue;
3487 }
3488 const existing = merged[key];
3489 if (existing == null) {
3490 merged[key] = value;
3491 continue;
3492 }
3493 if (key === "alias" && (rootPath === "resolve" || rootPath === "")) {
3494 merged[key] = mergeAlias(existing, value);
3495 continue;
3496 } else if (key === "assetsInclude" && rootPath === "") {
3497 merged[key] = [].concat(existing, value);
3498 continue;
3499 } else if (key === "noExternal" && rootPath === "ssr" && (existing === true || value === true)) {
3500 merged[key] = true;
3501 continue;
3502 } else if (key === "plugins" && rootPath === "worker") {
3503 merged[key] = () => [
3504 ...backwardCompatibleWorkerPlugins(existing),
3505 ...backwardCompatibleWorkerPlugins(value)
3506 ];
3507 continue;
3508 }
3509 if (Array.isArray(existing) || Array.isArray(value)) {
3510 merged[key] = [...arraify(existing), ...arraify(value)];
3511 continue;
3512 }
3513 if (isObject$1(existing) && isObject$1(value)) {
3514 merged[key] = mergeConfigRecursively(
3515 existing,
3516 value,
3517 rootPath ? `${rootPath}.${key}` : key
3518 );
3519 continue;
3520 }
3521 merged[key] = value;
3522 }
3523 return merged;
3524}
3525function mergeConfig(defaults, overrides, isRoot = true) {
3526 if (typeof defaults === "function" || typeof overrides === "function") {
3527 throw new Error(`Cannot merge config in form of callback`);
3528 }
3529 return mergeConfigRecursively(defaults, overrides, isRoot ? "" : ".");
3530}
3531function mergeAlias(a, b) {
3532 if (!a) return b;
3533 if (!b) return a;
3534 if (isObject$1(a) && isObject$1(b)) {
3535 return { ...a, ...b };
3536 }
3537 return [...normalizeAlias(b), ...normalizeAlias(a)];
3538}
3539function normalizeAlias(o = []) {
3540 return Array.isArray(o) ? o.map(normalizeSingleAlias) : Object.keys(o).map(
3541 (find) => normalizeSingleAlias({
3542 find,
3543 replacement: o[find]
3544 })
3545 );
3546}
3547function normalizeSingleAlias({
3548 find,
3549 replacement,
3550 customResolver
3551}) {
3552 if (typeof find === "string" && find[find.length - 1] === "/" && replacement[replacement.length - 1] === "/") {
3553 find = find.slice(0, find.length - 1);
3554 replacement = replacement.slice(0, replacement.length - 1);
3555 }
3556 const alias = {
3557 find,
3558 replacement
3559 };
3560 if (customResolver) {
3561 alias.customResolver = customResolver;
3562 }
3563 return alias;
3564}
3565
3566const CSS_LANGS_RE = (
3567 // eslint-disable-next-line regexp/no-unused-capturing-group
3568 /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/
3569);
3570const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
3571class SplitVendorChunkCache {
3572 cache;
3573 constructor() {
3574 this.cache = /* @__PURE__ */ new Map();
3575 }
3576 reset() {
3577 this.cache = /* @__PURE__ */ new Map();
3578 }
3579}
3580function splitVendorChunk(options = {}) {
3581 const cache = options.cache ?? new SplitVendorChunkCache();
3582 return (id, { getModuleInfo }) => {
3583 if (isInNodeModules(id) && !isCSSRequest(id) && staticImportedByEntry(id, getModuleInfo, cache.cache)) {
3584 return "vendor";
3585 }
3586 };
3587}
3588function staticImportedByEntry(id, getModuleInfo, cache, importStack = []) {
3589 if (cache.has(id)) {
3590 return cache.get(id);
3591 }
3592 if (importStack.includes(id)) {
3593 cache.set(id, false);
3594 return false;
3595 }
3596 const mod = getModuleInfo(id);
3597 if (!mod) {
3598 cache.set(id, false);
3599 return false;
3600 }
3601 if (mod.isEntry) {
3602 cache.set(id, true);
3603 return true;
3604 }
3605 const someImporterIs = mod.importers.some(
3606 (importer) => staticImportedByEntry(
3607 importer,
3608 getModuleInfo,
3609 cache,
3610 importStack.concat(id)
3611 )
3612 );
3613 cache.set(id, someImporterIs);
3614 return someImporterIs;
3615}
3616function splitVendorChunkPlugin() {
3617 const caches = [];
3618 function createSplitVendorChunk(output, config) {
3619 const cache = new SplitVendorChunkCache();
3620 caches.push(cache);
3621 const build = config.build ?? {};
3622 const format = output?.format;
3623 if (!build.ssr && !build.lib && format !== "umd" && format !== "iife") {
3624 return splitVendorChunk({ cache });
3625 }
3626 }
3627 return {
3628 name: "vite:split-vendor-chunk",
3629 config(config) {
3630 let outputs = config?.build?.rollupOptions?.output;
3631 if (outputs) {
3632 outputs = arraify(outputs);
3633 for (const output of outputs) {
3634 const viteManualChunks = createSplitVendorChunk(output, config);
3635 if (viteManualChunks) {
3636 if (output.manualChunks) {
3637 if (typeof output.manualChunks === "function") {
3638 const userManualChunks = output.manualChunks;
3639 output.manualChunks = (id, api) => {
3640 return userManualChunks(id, api) ?? viteManualChunks(id, api);
3641 };
3642 } else {
3643 console.warn(
3644 "(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.output.manualChunks`. Consider using the function form instead."
3645 );
3646 }
3647 } else {
3648 output.manualChunks = viteManualChunks;
3649 }
3650 }
3651 }
3652 } else {
3653 return {
3654 build: {
3655 rollupOptions: {
3656 output: {
3657 manualChunks: createSplitVendorChunk({}, config)
3658 }
3659 }
3660 }
3661 };
3662 }
3663 },
3664 buildStart() {
3665 caches.forEach((cache) => cache.reset());
3666 }
3667 };
3668}
3669
3670var convertSourceMap$1 = {};
3671
3672(function (exports) {
3673
3674 Object.defineProperty(exports, 'commentRegex', {
3675 get: function getCommentRegex () {
3676 // Groups: 1: media type, 2: MIME type, 3: charset, 4: encoding, 5: data.
3677 return /^\s*?\/[\/\*][@#]\s+?sourceMappingURL=data:(((?:application|text)\/json)(?:;charset=([^;,]+?)?)?)?(?:;(base64))?,(.*?)$/mg;
3678 }
3679 });
3680
3681
3682 Object.defineProperty(exports, 'mapFileCommentRegex', {
3683 get: function getMapFileCommentRegex () {
3684 // Matches sourceMappingURL in either // or /* comment styles.
3685 return /(?:\/\/[@#][ \t]+?sourceMappingURL=([^\s'"`]+?)[ \t]*?$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*?(?:\*\/){1}[ \t]*?$)/mg;
3686 }
3687 });
3688
3689 var decodeBase64;
3690 if (typeof Buffer !== 'undefined') {
3691 if (typeof Buffer.from === 'function') {
3692 decodeBase64 = decodeBase64WithBufferFrom;
3693 } else {
3694 decodeBase64 = decodeBase64WithNewBuffer;
3695 }
3696 } else {
3697 decodeBase64 = decodeBase64WithAtob;
3698 }
3699
3700 function decodeBase64WithBufferFrom(base64) {
3701 return Buffer.from(base64, 'base64').toString();
3702 }
3703
3704 function decodeBase64WithNewBuffer(base64) {
3705 if (typeof value === 'number') {
3706 throw new TypeError('The value to decode must not be of type number.');
3707 }
3708 return new Buffer(base64, 'base64').toString();
3709 }
3710
3711 function decodeBase64WithAtob(base64) {
3712 return decodeURIComponent(escape(atob(base64)));
3713 }
3714
3715 function stripComment(sm) {
3716 return sm.split(',').pop();
3717 }
3718
3719 function readFromFileMap(sm, read) {
3720 var r = exports.mapFileCommentRegex.exec(sm);
3721 // for some odd reason //# .. captures in 1 and /* .. */ in 2
3722 var filename = r[1] || r[2];
3723
3724 try {
3725 var sm = read(filename);
3726 if (sm != null && typeof sm.catch === 'function') {
3727 return sm.catch(throwError);
3728 } else {
3729 return sm;
3730 }
3731 } catch (e) {
3732 throwError(e);
3733 }
3734
3735 function throwError(e) {
3736 throw new Error('An error occurred while trying to read the map file at ' + filename + '\n' + e.stack);
3737 }
3738 }
3739
3740 function Converter (sm, opts) {
3741 opts = opts || {};
3742
3743 if (opts.hasComment) {
3744 sm = stripComment(sm);
3745 }
3746
3747 if (opts.encoding === 'base64') {
3748 sm = decodeBase64(sm);
3749 } else if (opts.encoding === 'uri') {
3750 sm = decodeURIComponent(sm);
3751 }
3752
3753 if (opts.isJSON || opts.encoding) {
3754 sm = JSON.parse(sm);
3755 }
3756
3757 this.sourcemap = sm;
3758 }
3759
3760 Converter.prototype.toJSON = function (space) {
3761 return JSON.stringify(this.sourcemap, null, space);
3762 };
3763
3764 if (typeof Buffer !== 'undefined') {
3765 if (typeof Buffer.from === 'function') {
3766 Converter.prototype.toBase64 = encodeBase64WithBufferFrom;
3767 } else {
3768 Converter.prototype.toBase64 = encodeBase64WithNewBuffer;
3769 }
3770 } else {
3771 Converter.prototype.toBase64 = encodeBase64WithBtoa;
3772 }
3773
3774 function encodeBase64WithBufferFrom() {
3775 var json = this.toJSON();
3776 return Buffer.from(json, 'utf8').toString('base64');
3777 }
3778
3779 function encodeBase64WithNewBuffer() {
3780 var json = this.toJSON();
3781 if (typeof json === 'number') {
3782 throw new TypeError('The json to encode must not be of type number.');
3783 }
3784 return new Buffer(json, 'utf8').toString('base64');
3785 }
3786
3787 function encodeBase64WithBtoa() {
3788 var json = this.toJSON();
3789 return btoa(unescape(encodeURIComponent(json)));
3790 }
3791
3792 Converter.prototype.toURI = function () {
3793 var json = this.toJSON();
3794 return encodeURIComponent(json);
3795 };
3796
3797 Converter.prototype.toComment = function (options) {
3798 var encoding, content, data;
3799 if (options != null && options.encoding === 'uri') {
3800 encoding = '';
3801 content = this.toURI();
3802 } else {
3803 encoding = ';base64';
3804 content = this.toBase64();
3805 }
3806 data = 'sourceMappingURL=data:application/json;charset=utf-8' + encoding + ',' + content;
3807 return options != null && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
3808 };
3809
3810 // returns copy instead of original
3811 Converter.prototype.toObject = function () {
3812 return JSON.parse(this.toJSON());
3813 };
3814
3815 Converter.prototype.addProperty = function (key, value) {
3816 if (this.sourcemap.hasOwnProperty(key)) throw new Error('property "' + key + '" already exists on the sourcemap, use set property instead');
3817 return this.setProperty(key, value);
3818 };
3819
3820 Converter.prototype.setProperty = function (key, value) {
3821 this.sourcemap[key] = value;
3822 return this;
3823 };
3824
3825 Converter.prototype.getProperty = function (key) {
3826 return this.sourcemap[key];
3827 };
3828
3829 exports.fromObject = function (obj) {
3830 return new Converter(obj);
3831 };
3832
3833 exports.fromJSON = function (json) {
3834 return new Converter(json, { isJSON: true });
3835 };
3836
3837 exports.fromURI = function (uri) {
3838 return new Converter(uri, { encoding: 'uri' });
3839 };
3840
3841 exports.fromBase64 = function (base64) {
3842 return new Converter(base64, { encoding: 'base64' });
3843 };
3844
3845 exports.fromComment = function (comment) {
3846 var m, encoding;
3847 comment = comment
3848 .replace(/^\/\*/g, '//')
3849 .replace(/\*\/$/g, '');
3850 m = exports.commentRegex.exec(comment);
3851 encoding = m && m[4] || 'uri';
3852 return new Converter(comment, { encoding: encoding, hasComment: true });
3853 };
3854
3855 function makeConverter(sm) {
3856 return new Converter(sm, { isJSON: true });
3857 }
3858
3859 exports.fromMapFileComment = function (comment, read) {
3860 if (typeof read === 'string') {
3861 throw new Error(
3862 'String directory paths are no longer supported with `fromMapFileComment`\n' +
3863 'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading'
3864 )
3865 }
3866
3867 var sm = readFromFileMap(comment, read);
3868 if (sm != null && typeof sm.then === 'function') {
3869 return sm.then(makeConverter);
3870 } else {
3871 return makeConverter(sm);
3872 }
3873 };
3874
3875 // Finds last sourcemap comment in file or returns null if none was found
3876 exports.fromSource = function (content) {
3877 var m = content.match(exports.commentRegex);
3878 return m ? exports.fromComment(m.pop()) : null;
3879 };
3880
3881 // Finds last sourcemap comment in file or returns null if none was found
3882 exports.fromMapFileSource = function (content, read) {
3883 if (typeof read === 'string') {
3884 throw new Error(
3885 'String directory paths are no longer supported with `fromMapFileSource`\n' +
3886 'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading'
3887 )
3888 }
3889 var m = content.match(exports.mapFileCommentRegex);
3890 return m ? exports.fromMapFileComment(m.pop(), read) : null;
3891 };
3892
3893 exports.removeComments = function (src) {
3894 return src.replace(exports.commentRegex, '');
3895 };
3896
3897 exports.removeMapFileComments = function (src) {
3898 return src.replace(exports.mapFileCommentRegex, '');
3899 };
3900
3901 exports.generateMapFileComment = function (file, options) {
3902 var data = 'sourceMappingURL=' + file;
3903 return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
3904 };
3905} (convertSourceMap$1));
3906
3907var convertSourceMap = /*@__PURE__*/getDefaultExportFromCjs(convertSourceMap$1);
3908
3909/*!
3910 * etag
3911 * Copyright(c) 2014-2016 Douglas Christopher Wilson
3912 * MIT Licensed
3913 */
3914
3915/**
3916 * Module exports.
3917 * @public
3918 */
3919
3920var etag_1 = etag;
3921
3922/**
3923 * Module dependencies.
3924 * @private
3925 */
3926
3927var crypto$1 = require$$0$2;
3928var Stats = fs$2.Stats;
3929
3930/**
3931 * Module variables.
3932 * @private
3933 */
3934
3935var toString$1 = Object.prototype.toString;
3936
3937/**
3938 * Generate an entity tag.
3939 *
3940 * @param {Buffer|string} entity
3941 * @return {string}
3942 * @private
3943 */
3944
3945function entitytag (entity) {
3946 if (entity.length === 0) {
3947 // fast-path empty
3948 return '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"'
3949 }
3950
3951 // compute hash of entity
3952 var hash = crypto$1
3953 .createHash('sha1')
3954 .update(entity, 'utf8')
3955 .digest('base64')
3956 .substring(0, 27);
3957
3958 // compute length of entity
3959 var len = typeof entity === 'string'
3960 ? Buffer.byteLength(entity, 'utf8')
3961 : entity.length;
3962
3963 return '"' + len.toString(16) + '-' + hash + '"'
3964}
3965
3966/**
3967 * Create a simple ETag.
3968 *
3969 * @param {string|Buffer|Stats} entity
3970 * @param {object} [options]
3971 * @param {boolean} [options.weak]
3972 * @return {String}
3973 * @public
3974 */
3975
3976function etag (entity, options) {
3977 if (entity == null) {
3978 throw new TypeError('argument entity is required')
3979 }
3980
3981 // support fs.Stats object
3982 var isStats = isstats(entity);
3983 var weak = options && typeof options.weak === 'boolean'
3984 ? options.weak
3985 : isStats;
3986
3987 // validate argument
3988 if (!isStats && typeof entity !== 'string' && !Buffer.isBuffer(entity)) {
3989 throw new TypeError('argument entity must be string, Buffer, or fs.Stats')
3990 }
3991
3992 // generate entity tag
3993 var tag = isStats
3994 ? stattag(entity)
3995 : entitytag(entity);
3996
3997 return weak
3998 ? 'W/' + tag
3999 : tag
4000}
4001
4002/**
4003 * Determine if object is a Stats object.
4004 *
4005 * @param {object} obj
4006 * @return {boolean}
4007 * @api private
4008 */
4009
4010function isstats (obj) {
4011 // genuine fs.Stats
4012 if (typeof Stats === 'function' && obj instanceof Stats) {
4013 return true
4014 }
4015
4016 // quack quack
4017 return obj && typeof obj === 'object' &&
4018 'ctime' in obj && toString$1.call(obj.ctime) === '[object Date]' &&
4019 'mtime' in obj && toString$1.call(obj.mtime) === '[object Date]' &&
4020 'ino' in obj && typeof obj.ino === 'number' &&
4021 'size' in obj && typeof obj.size === 'number'
4022}
4023
4024/**
4025 * Generate a tag for a stat.
4026 *
4027 * @param {object} stat
4028 * @return {string}
4029 * @private
4030 */
4031
4032function stattag (stat) {
4033 var mtime = stat.mtime.getTime().toString(16);
4034 var size = stat.size.toString(16);
4035
4036 return '"' + size + '-' + mtime + '"'
4037}
4038
4039var getEtag = /*@__PURE__*/getDefaultExportFromCjs(etag_1);
4040
4041class BitSet {
4042 constructor(arg) {
4043 this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
4044 }
4045
4046 add(n) {
4047 this.bits[n >> 5] |= 1 << (n & 31);
4048 }
4049
4050 has(n) {
4051 return !!(this.bits[n >> 5] & (1 << (n & 31)));
4052 }
4053}
4054
4055class Chunk {
4056 constructor(start, end, content) {
4057 this.start = start;
4058 this.end = end;
4059 this.original = content;
4060
4061 this.intro = '';
4062 this.outro = '';
4063
4064 this.content = content;
4065 this.storeName = false;
4066 this.edited = false;
4067
4068 {
4069 this.previous = null;
4070 this.next = null;
4071 }
4072 }
4073
4074 appendLeft(content) {
4075 this.outro += content;
4076 }
4077
4078 appendRight(content) {
4079 this.intro = this.intro + content;
4080 }
4081
4082 clone() {
4083 const chunk = new Chunk(this.start, this.end, this.original);
4084
4085 chunk.intro = this.intro;
4086 chunk.outro = this.outro;
4087 chunk.content = this.content;
4088 chunk.storeName = this.storeName;
4089 chunk.edited = this.edited;
4090
4091 return chunk;
4092 }
4093
4094 contains(index) {
4095 return this.start < index && index < this.end;
4096 }
4097
4098 eachNext(fn) {
4099 let chunk = this;
4100 while (chunk) {
4101 fn(chunk);
4102 chunk = chunk.next;
4103 }
4104 }
4105
4106 eachPrevious(fn) {
4107 let chunk = this;
4108 while (chunk) {
4109 fn(chunk);
4110 chunk = chunk.previous;
4111 }
4112 }
4113
4114 edit(content, storeName, contentOnly) {
4115 this.content = content;
4116 if (!contentOnly) {
4117 this.intro = '';
4118 this.outro = '';
4119 }
4120 this.storeName = storeName;
4121
4122 this.edited = true;
4123
4124 return this;
4125 }
4126
4127 prependLeft(content) {
4128 this.outro = content + this.outro;
4129 }
4130
4131 prependRight(content) {
4132 this.intro = content + this.intro;
4133 }
4134
4135 reset() {
4136 this.intro = '';
4137 this.outro = '';
4138 if (this.edited) {
4139 this.content = this.original;
4140 this.storeName = false;
4141 this.edited = false;
4142 }
4143 }
4144
4145 split(index) {
4146 const sliceIndex = index - this.start;
4147
4148 const originalBefore = this.original.slice(0, sliceIndex);
4149 const originalAfter = this.original.slice(sliceIndex);
4150
4151 this.original = originalBefore;
4152
4153 const newChunk = new Chunk(index, this.end, originalAfter);
4154 newChunk.outro = this.outro;
4155 this.outro = '';
4156
4157 this.end = index;
4158
4159 if (this.edited) {
4160 // after split we should save the edit content record into the correct chunk
4161 // to make sure sourcemap correct
4162 // For example:
4163 // ' test'.trim()
4164 // split -> ' ' + 'test'
4165 // ✔️ edit -> '' + 'test'
4166 // ✖️ edit -> 'test' + ''
4167 // TODO is this block necessary?...
4168 newChunk.edit('', false);
4169 this.content = '';
4170 } else {
4171 this.content = originalBefore;
4172 }
4173
4174 newChunk.next = this.next;
4175 if (newChunk.next) newChunk.next.previous = newChunk;
4176 newChunk.previous = this;
4177 this.next = newChunk;
4178
4179 return newChunk;
4180 }
4181
4182 toString() {
4183 return this.intro + this.content + this.outro;
4184 }
4185
4186 trimEnd(rx) {
4187 this.outro = this.outro.replace(rx, '');
4188 if (this.outro.length) return true;
4189
4190 const trimmed = this.content.replace(rx, '');
4191
4192 if (trimmed.length) {
4193 if (trimmed !== this.content) {
4194 this.split(this.start + trimmed.length).edit('', undefined, true);
4195 if (this.edited) {
4196 // save the change, if it has been edited
4197 this.edit(trimmed, this.storeName, true);
4198 }
4199 }
4200 return true;
4201 } else {
4202 this.edit('', undefined, true);
4203
4204 this.intro = this.intro.replace(rx, '');
4205 if (this.intro.length) return true;
4206 }
4207 }
4208
4209 trimStart(rx) {
4210 this.intro = this.intro.replace(rx, '');
4211 if (this.intro.length) return true;
4212
4213 const trimmed = this.content.replace(rx, '');
4214
4215 if (trimmed.length) {
4216 if (trimmed !== this.content) {
4217 const newChunk = this.split(this.end - trimmed.length);
4218 if (this.edited) {
4219 // save the change, if it has been edited
4220 newChunk.edit(trimmed, this.storeName, true);
4221 }
4222 this.edit('', undefined, true);
4223 }
4224 return true;
4225 } else {
4226 this.edit('', undefined, true);
4227
4228 this.outro = this.outro.replace(rx, '');
4229 if (this.outro.length) return true;
4230 }
4231 }
4232}
4233
4234function getBtoa() {
4235 if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
4236 return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
4237 } else if (typeof Buffer === 'function') {
4238 return (str) => Buffer.from(str, 'utf-8').toString('base64');
4239 } else {
4240 return () => {
4241 throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
4242 };
4243 }
4244}
4245
4246const btoa$1 = /*#__PURE__*/ getBtoa();
4247
4248class SourceMap {
4249 constructor(properties) {
4250 this.version = 3;
4251 this.file = properties.file;
4252 this.sources = properties.sources;
4253 this.sourcesContent = properties.sourcesContent;
4254 this.names = properties.names;
4255 this.mappings = encode(properties.mappings);
4256 if (typeof properties.x_google_ignoreList !== 'undefined') {
4257 this.x_google_ignoreList = properties.x_google_ignoreList;
4258 }
4259 }
4260
4261 toString() {
4262 return JSON.stringify(this);
4263 }
4264
4265 toUrl() {
4266 return 'data:application/json;charset=utf-8;base64,' + btoa$1(this.toString());
4267 }
4268}
4269
4270function guessIndent(code) {
4271 const lines = code.split('\n');
4272
4273 const tabbed = lines.filter((line) => /^\t+/.test(line));
4274 const spaced = lines.filter((line) => /^ {2,}/.test(line));
4275
4276 if (tabbed.length === 0 && spaced.length === 0) {
4277 return null;
4278 }
4279
4280 // More lines tabbed than spaced? Assume tabs, and
4281 // default to tabs in the case of a tie (or nothing
4282 // to go on)
4283 if (tabbed.length >= spaced.length) {
4284 return '\t';
4285 }
4286
4287 // Otherwise, we need to guess the multiple
4288 const min = spaced.reduce((previous, current) => {
4289 const numSpaces = /^ +/.exec(current)[0].length;
4290 return Math.min(numSpaces, previous);
4291 }, Infinity);
4292
4293 return new Array(min + 1).join(' ');
4294}
4295
4296function getRelativePath(from, to) {
4297 const fromParts = from.split(/[/\\]/);
4298 const toParts = to.split(/[/\\]/);
4299
4300 fromParts.pop(); // get dirname
4301
4302 while (fromParts[0] === toParts[0]) {
4303 fromParts.shift();
4304 toParts.shift();
4305 }
4306
4307 if (fromParts.length) {
4308 let i = fromParts.length;
4309 while (i--) fromParts[i] = '..';
4310 }
4311
4312 return fromParts.concat(toParts).join('/');
4313}
4314
4315const toString = Object.prototype.toString;
4316
4317function isObject(thing) {
4318 return toString.call(thing) === '[object Object]';
4319}
4320
4321function getLocator(source) {
4322 const originalLines = source.split('\n');
4323 const lineOffsets = [];
4324
4325 for (let i = 0, pos = 0; i < originalLines.length; i++) {
4326 lineOffsets.push(pos);
4327 pos += originalLines[i].length + 1;
4328 }
4329
4330 return function locate(index) {
4331 let i = 0;
4332 let j = lineOffsets.length;
4333 while (i < j) {
4334 const m = (i + j) >> 1;
4335 if (index < lineOffsets[m]) {
4336 j = m;
4337 } else {
4338 i = m + 1;
4339 }
4340 }
4341 const line = i - 1;
4342 const column = index - lineOffsets[line];
4343 return { line, column };
4344 };
4345}
4346
4347const wordRegex = /\w/;
4348
4349class Mappings {
4350 constructor(hires) {
4351 this.hires = hires;
4352 this.generatedCodeLine = 0;
4353 this.generatedCodeColumn = 0;
4354 this.raw = [];
4355 this.rawSegments = this.raw[this.generatedCodeLine] = [];
4356 this.pending = null;
4357 }
4358
4359 addEdit(sourceIndex, content, loc, nameIndex) {
4360 if (content.length) {
4361 const contentLengthMinusOne = content.length - 1;
4362 let contentLineEnd = content.indexOf('\n', 0);
4363 let previousContentLineEnd = -1;
4364 // Loop through each line in the content and add a segment, but stop if the last line is empty,
4365 // else code afterwards would fill one line too many
4366 while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
4367 const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
4368 if (nameIndex >= 0) {
4369 segment.push(nameIndex);
4370 }
4371 this.rawSegments.push(segment);
4372
4373 this.generatedCodeLine += 1;
4374 this.raw[this.generatedCodeLine] = this.rawSegments = [];
4375 this.generatedCodeColumn = 0;
4376
4377 previousContentLineEnd = contentLineEnd;
4378 contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
4379 }
4380
4381 const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
4382 if (nameIndex >= 0) {
4383 segment.push(nameIndex);
4384 }
4385 this.rawSegments.push(segment);
4386
4387 this.advance(content.slice(previousContentLineEnd + 1));
4388 } else if (this.pending) {
4389 this.rawSegments.push(this.pending);
4390 this.advance(content);
4391 }
4392
4393 this.pending = null;
4394 }
4395
4396 addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
4397 let originalCharIndex = chunk.start;
4398 let first = true;
4399 // when iterating each char, check if it's in a word boundary
4400 let charInHiresBoundary = false;
4401
4402 while (originalCharIndex < chunk.end) {
4403 if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
4404 const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
4405
4406 if (this.hires === 'boundary') {
4407 // in hires "boundary", group segments per word boundary than per char
4408 if (wordRegex.test(original[originalCharIndex])) {
4409 // for first char in the boundary found, start the boundary by pushing a segment
4410 if (!charInHiresBoundary) {
4411 this.rawSegments.push(segment);
4412 charInHiresBoundary = true;
4413 }
4414 } else {
4415 // for non-word char, end the boundary by pushing a segment
4416 this.rawSegments.push(segment);
4417 charInHiresBoundary = false;
4418 }
4419 } else {
4420 this.rawSegments.push(segment);
4421 }
4422 }
4423
4424 if (original[originalCharIndex] === '\n') {
4425 loc.line += 1;
4426 loc.column = 0;
4427 this.generatedCodeLine += 1;
4428 this.raw[this.generatedCodeLine] = this.rawSegments = [];
4429 this.generatedCodeColumn = 0;
4430 first = true;
4431 } else {
4432 loc.column += 1;
4433 this.generatedCodeColumn += 1;
4434 first = false;
4435 }
4436
4437 originalCharIndex += 1;
4438 }
4439
4440 this.pending = null;
4441 }
4442
4443 advance(str) {
4444 if (!str) return;
4445
4446 const lines = str.split('\n');
4447
4448 if (lines.length > 1) {
4449 for (let i = 0; i < lines.length - 1; i++) {
4450 this.generatedCodeLine++;
4451 this.raw[this.generatedCodeLine] = this.rawSegments = [];
4452 }
4453 this.generatedCodeColumn = 0;
4454 }
4455
4456 this.generatedCodeColumn += lines[lines.length - 1].length;
4457 }
4458}
4459
4460const n = '\n';
4461
4462const warned = {
4463 insertLeft: false,
4464 insertRight: false,
4465 storeName: false,
4466};
4467
4468class MagicString {
4469 constructor(string, options = {}) {
4470 const chunk = new Chunk(0, string.length, string);
4471
4472 Object.defineProperties(this, {
4473 original: { writable: true, value: string },
4474 outro: { writable: true, value: '' },
4475 intro: { writable: true, value: '' },
4476 firstChunk: { writable: true, value: chunk },
4477 lastChunk: { writable: true, value: chunk },
4478 lastSearchedChunk: { writable: true, value: chunk },
4479 byStart: { writable: true, value: {} },
4480 byEnd: { writable: true, value: {} },
4481 filename: { writable: true, value: options.filename },
4482 indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
4483 sourcemapLocations: { writable: true, value: new BitSet() },
4484 storedNames: { writable: true, value: {} },
4485 indentStr: { writable: true, value: undefined },
4486 ignoreList: { writable: true, value: options.ignoreList },
4487 });
4488
4489 this.byStart[0] = chunk;
4490 this.byEnd[string.length] = chunk;
4491 }
4492
4493 addSourcemapLocation(char) {
4494 this.sourcemapLocations.add(char);
4495 }
4496
4497 append(content) {
4498 if (typeof content !== 'string') throw new TypeError('outro content must be a string');
4499
4500 this.outro += content;
4501 return this;
4502 }
4503
4504 appendLeft(index, content) {
4505 if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
4506
4507 this._split(index);
4508
4509 const chunk = this.byEnd[index];
4510
4511 if (chunk) {
4512 chunk.appendLeft(content);
4513 } else {
4514 this.intro += content;
4515 }
4516 return this;
4517 }
4518
4519 appendRight(index, content) {
4520 if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
4521
4522 this._split(index);
4523
4524 const chunk = this.byStart[index];
4525
4526 if (chunk) {
4527 chunk.appendRight(content);
4528 } else {
4529 this.outro += content;
4530 }
4531 return this;
4532 }
4533
4534 clone() {
4535 const cloned = new MagicString(this.original, { filename: this.filename });
4536
4537 let originalChunk = this.firstChunk;
4538 let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
4539
4540 while (originalChunk) {
4541 cloned.byStart[clonedChunk.start] = clonedChunk;
4542 cloned.byEnd[clonedChunk.end] = clonedChunk;
4543
4544 const nextOriginalChunk = originalChunk.next;
4545 const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
4546
4547 if (nextClonedChunk) {
4548 clonedChunk.next = nextClonedChunk;
4549 nextClonedChunk.previous = clonedChunk;
4550
4551 clonedChunk = nextClonedChunk;
4552 }
4553
4554 originalChunk = nextOriginalChunk;
4555 }
4556
4557 cloned.lastChunk = clonedChunk;
4558
4559 if (this.indentExclusionRanges) {
4560 cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
4561 }
4562
4563 cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
4564
4565 cloned.intro = this.intro;
4566 cloned.outro = this.outro;
4567
4568 return cloned;
4569 }
4570
4571 generateDecodedMap(options) {
4572 options = options || {};
4573
4574 const sourceIndex = 0;
4575 const names = Object.keys(this.storedNames);
4576 const mappings = new Mappings(options.hires);
4577
4578 const locate = getLocator(this.original);
4579
4580 if (this.intro) {
4581 mappings.advance(this.intro);
4582 }
4583
4584 this.firstChunk.eachNext((chunk) => {
4585 const loc = locate(chunk.start);
4586
4587 if (chunk.intro.length) mappings.advance(chunk.intro);
4588
4589 if (chunk.edited) {
4590 mappings.addEdit(
4591 sourceIndex,
4592 chunk.content,
4593 loc,
4594 chunk.storeName ? names.indexOf(chunk.original) : -1,
4595 );
4596 } else {
4597 mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
4598 }
4599
4600 if (chunk.outro.length) mappings.advance(chunk.outro);
4601 });
4602
4603 return {
4604 file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
4605 sources: [
4606 options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
4607 ],
4608 sourcesContent: options.includeContent ? [this.original] : undefined,
4609 names,
4610 mappings: mappings.raw,
4611 x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
4612 };
4613 }
4614
4615 generateMap(options) {
4616 return new SourceMap(this.generateDecodedMap(options));
4617 }
4618
4619 _ensureindentStr() {
4620 if (this.indentStr === undefined) {
4621 this.indentStr = guessIndent(this.original);
4622 }
4623 }
4624
4625 _getRawIndentString() {
4626 this._ensureindentStr();
4627 return this.indentStr;
4628 }
4629
4630 getIndentString() {
4631 this._ensureindentStr();
4632 return this.indentStr === null ? '\t' : this.indentStr;
4633 }
4634
4635 indent(indentStr, options) {
4636 const pattern = /^[^\r\n]/gm;
4637
4638 if (isObject(indentStr)) {
4639 options = indentStr;
4640 indentStr = undefined;
4641 }
4642
4643 if (indentStr === undefined) {
4644 this._ensureindentStr();
4645 indentStr = this.indentStr || '\t';
4646 }
4647
4648 if (indentStr === '') return this; // noop
4649
4650 options = options || {};
4651
4652 // Process exclusion ranges
4653 const isExcluded = {};
4654
4655 if (options.exclude) {
4656 const exclusions =
4657 typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
4658 exclusions.forEach((exclusion) => {
4659 for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
4660 isExcluded[i] = true;
4661 }
4662 });
4663 }
4664
4665 let shouldIndentNextCharacter = options.indentStart !== false;
4666 const replacer = (match) => {
4667 if (shouldIndentNextCharacter) return `${indentStr}${match}`;
4668 shouldIndentNextCharacter = true;
4669 return match;
4670 };
4671
4672 this.intro = this.intro.replace(pattern, replacer);
4673
4674 let charIndex = 0;
4675 let chunk = this.firstChunk;
4676
4677 while (chunk) {
4678 const end = chunk.end;
4679
4680 if (chunk.edited) {
4681 if (!isExcluded[charIndex]) {
4682 chunk.content = chunk.content.replace(pattern, replacer);
4683
4684 if (chunk.content.length) {
4685 shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
4686 }
4687 }
4688 } else {
4689 charIndex = chunk.start;
4690
4691 while (charIndex < end) {
4692 if (!isExcluded[charIndex]) {
4693 const char = this.original[charIndex];
4694
4695 if (char === '\n') {
4696 shouldIndentNextCharacter = true;
4697 } else if (char !== '\r' && shouldIndentNextCharacter) {
4698 shouldIndentNextCharacter = false;
4699
4700 if (charIndex === chunk.start) {
4701 chunk.prependRight(indentStr);
4702 } else {
4703 this._splitChunk(chunk, charIndex);
4704 chunk = chunk.next;
4705 chunk.prependRight(indentStr);
4706 }
4707 }
4708 }
4709
4710 charIndex += 1;
4711 }
4712 }
4713
4714 charIndex = chunk.end;
4715 chunk = chunk.next;
4716 }
4717
4718 this.outro = this.outro.replace(pattern, replacer);
4719
4720 return this;
4721 }
4722
4723 insert() {
4724 throw new Error(
4725 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
4726 );
4727 }
4728
4729 insertLeft(index, content) {
4730 if (!warned.insertLeft) {
4731 console.warn(
4732 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
4733 ); // eslint-disable-line no-console
4734 warned.insertLeft = true;
4735 }
4736
4737 return this.appendLeft(index, content);
4738 }
4739
4740 insertRight(index, content) {
4741 if (!warned.insertRight) {
4742 console.warn(
4743 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
4744 ); // eslint-disable-line no-console
4745 warned.insertRight = true;
4746 }
4747
4748 return this.prependRight(index, content);
4749 }
4750
4751 move(start, end, index) {
4752 if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
4753
4754 this._split(start);
4755 this._split(end);
4756 this._split(index);
4757
4758 const first = this.byStart[start];
4759 const last = this.byEnd[end];
4760
4761 const oldLeft = first.previous;
4762 const oldRight = last.next;
4763
4764 const newRight = this.byStart[index];
4765 if (!newRight && last === this.lastChunk) return this;
4766 const newLeft = newRight ? newRight.previous : this.lastChunk;
4767
4768 if (oldLeft) oldLeft.next = oldRight;
4769 if (oldRight) oldRight.previous = oldLeft;
4770
4771 if (newLeft) newLeft.next = first;
4772 if (newRight) newRight.previous = last;
4773
4774 if (!first.previous) this.firstChunk = last.next;
4775 if (!last.next) {
4776 this.lastChunk = first.previous;
4777 this.lastChunk.next = null;
4778 }
4779
4780 first.previous = newLeft;
4781 last.next = newRight || null;
4782
4783 if (!newLeft) this.firstChunk = first;
4784 if (!newRight) this.lastChunk = last;
4785 return this;
4786 }
4787
4788 overwrite(start, end, content, options) {
4789 options = options || {};
4790 return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
4791 }
4792
4793 update(start, end, content, options) {
4794 if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
4795
4796 while (start < 0) start += this.original.length;
4797 while (end < 0) end += this.original.length;
4798
4799 if (end > this.original.length) throw new Error('end is out of bounds');
4800 if (start === end)
4801 throw new Error(
4802 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
4803 );
4804
4805 this._split(start);
4806 this._split(end);
4807
4808 if (options === true) {
4809 if (!warned.storeName) {
4810 console.warn(
4811 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
4812 ); // eslint-disable-line no-console
4813 warned.storeName = true;
4814 }
4815
4816 options = { storeName: true };
4817 }
4818 const storeName = options !== undefined ? options.storeName : false;
4819 const overwrite = options !== undefined ? options.overwrite : false;
4820
4821 if (storeName) {
4822 const original = this.original.slice(start, end);
4823 Object.defineProperty(this.storedNames, original, {
4824 writable: true,
4825 value: true,
4826 enumerable: true,
4827 });
4828 }
4829
4830 const first = this.byStart[start];
4831 const last = this.byEnd[end];
4832
4833 if (first) {
4834 let chunk = first;
4835 while (chunk !== last) {
4836 if (chunk.next !== this.byStart[chunk.end]) {
4837 throw new Error('Cannot overwrite across a split point');
4838 }
4839 chunk = chunk.next;
4840 chunk.edit('', false);
4841 }
4842
4843 first.edit(content, storeName, !overwrite);
4844 } else {
4845 // must be inserting at the end
4846 const newChunk = new Chunk(start, end, '').edit(content, storeName);
4847
4848 // TODO last chunk in the array may not be the last chunk, if it's moved...
4849 last.next = newChunk;
4850 newChunk.previous = last;
4851 }
4852 return this;
4853 }
4854
4855 prepend(content) {
4856 if (typeof content !== 'string') throw new TypeError('outro content must be a string');
4857
4858 this.intro = content + this.intro;
4859 return this;
4860 }
4861
4862 prependLeft(index, content) {
4863 if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
4864
4865 this._split(index);
4866
4867 const chunk = this.byEnd[index];
4868
4869 if (chunk) {
4870 chunk.prependLeft(content);
4871 } else {
4872 this.intro = content + this.intro;
4873 }
4874 return this;
4875 }
4876
4877 prependRight(index, content) {
4878 if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
4879
4880 this._split(index);
4881
4882 const chunk = this.byStart[index];
4883
4884 if (chunk) {
4885 chunk.prependRight(content);
4886 } else {
4887 this.outro = content + this.outro;
4888 }
4889 return this;
4890 }
4891
4892 remove(start, end) {
4893 while (start < 0) start += this.original.length;
4894 while (end < 0) end += this.original.length;
4895
4896 if (start === end) return this;
4897
4898 if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
4899 if (start > end) throw new Error('end must be greater than start');
4900
4901 this._split(start);
4902 this._split(end);
4903
4904 let chunk = this.byStart[start];
4905
4906 while (chunk) {
4907 chunk.intro = '';
4908 chunk.outro = '';
4909 chunk.edit('');
4910
4911 chunk = end > chunk.end ? this.byStart[chunk.end] : null;
4912 }
4913 return this;
4914 }
4915
4916 reset(start, end) {
4917 while (start < 0) start += this.original.length;
4918 while (end < 0) end += this.original.length;
4919
4920 if (start === end) return this;
4921
4922 if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
4923 if (start > end) throw new Error('end must be greater than start');
4924
4925 this._split(start);
4926 this._split(end);
4927
4928 let chunk = this.byStart[start];
4929
4930 while (chunk) {
4931 chunk.reset();
4932
4933 chunk = end > chunk.end ? this.byStart[chunk.end] : null;
4934 }
4935 return this;
4936 }
4937
4938 lastChar() {
4939 if (this.outro.length) return this.outro[this.outro.length - 1];
4940 let chunk = this.lastChunk;
4941 do {
4942 if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
4943 if (chunk.content.length) return chunk.content[chunk.content.length - 1];
4944 if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
4945 } while ((chunk = chunk.previous));
4946 if (this.intro.length) return this.intro[this.intro.length - 1];
4947 return '';
4948 }
4949
4950 lastLine() {
4951 let lineIndex = this.outro.lastIndexOf(n);
4952 if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
4953 let lineStr = this.outro;
4954 let chunk = this.lastChunk;
4955 do {
4956 if (chunk.outro.length > 0) {
4957 lineIndex = chunk.outro.lastIndexOf(n);
4958 if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
4959 lineStr = chunk.outro + lineStr;
4960 }
4961
4962 if (chunk.content.length > 0) {
4963 lineIndex = chunk.content.lastIndexOf(n);
4964 if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
4965 lineStr = chunk.content + lineStr;
4966 }
4967
4968 if (chunk.intro.length > 0) {
4969 lineIndex = chunk.intro.lastIndexOf(n);
4970 if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
4971 lineStr = chunk.intro + lineStr;
4972 }
4973 } while ((chunk = chunk.previous));
4974 lineIndex = this.intro.lastIndexOf(n);
4975 if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
4976 return this.intro + lineStr;
4977 }
4978
4979 slice(start = 0, end = this.original.length) {
4980 while (start < 0) start += this.original.length;
4981 while (end < 0) end += this.original.length;
4982
4983 let result = '';
4984
4985 // find start chunk
4986 let chunk = this.firstChunk;
4987 while (chunk && (chunk.start > start || chunk.end <= start)) {
4988 // found end chunk before start
4989 if (chunk.start < end && chunk.end >= end) {
4990 return result;
4991 }
4992
4993 chunk = chunk.next;
4994 }
4995
4996 if (chunk && chunk.edited && chunk.start !== start)
4997 throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
4998
4999 const startChunk = chunk;
5000 while (chunk) {
5001 if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
5002 result += chunk.intro;
5003 }
5004
5005 const containsEnd = chunk.start < end && chunk.end >= end;
5006 if (containsEnd && chunk.edited && chunk.end !== end)
5007 throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
5008
5009 const sliceStart = startChunk === chunk ? start - chunk.start : 0;
5010 const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
5011
5012 result += chunk.content.slice(sliceStart, sliceEnd);
5013
5014 if (chunk.outro && (!containsEnd || chunk.end === end)) {
5015 result += chunk.outro;
5016 }
5017
5018 if (containsEnd) {
5019 break;
5020 }
5021
5022 chunk = chunk.next;
5023 }
5024
5025 return result;
5026 }
5027
5028 // TODO deprecate this? not really very useful
5029 snip(start, end) {
5030 const clone = this.clone();
5031 clone.remove(0, start);
5032 clone.remove(end, clone.original.length);
5033
5034 return clone;
5035 }
5036
5037 _split(index) {
5038 if (this.byStart[index] || this.byEnd[index]) return;
5039
5040 let chunk = this.lastSearchedChunk;
5041 const searchForward = index > chunk.end;
5042
5043 while (chunk) {
5044 if (chunk.contains(index)) return this._splitChunk(chunk, index);
5045
5046 chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
5047 }
5048 }
5049
5050 _splitChunk(chunk, index) {
5051 if (chunk.edited && chunk.content.length) {
5052 // zero-length edited chunks are a special case (overlapping replacements)
5053 const loc = getLocator(this.original)(index);
5054 throw new Error(
5055 `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
5056 );
5057 }
5058
5059 const newChunk = chunk.split(index);
5060
5061 this.byEnd[index] = chunk;
5062 this.byStart[index] = newChunk;
5063 this.byEnd[newChunk.end] = newChunk;
5064
5065 if (chunk === this.lastChunk) this.lastChunk = newChunk;
5066
5067 this.lastSearchedChunk = chunk;
5068 return true;
5069 }
5070
5071 toString() {
5072 let str = this.intro;
5073
5074 let chunk = this.firstChunk;
5075 while (chunk) {
5076 str += chunk.toString();
5077 chunk = chunk.next;
5078 }
5079
5080 return str + this.outro;
5081 }
5082
5083 isEmpty() {
5084 let chunk = this.firstChunk;
5085 do {
5086 if (
5087 (chunk.intro.length && chunk.intro.trim()) ||
5088 (chunk.content.length && chunk.content.trim()) ||
5089 (chunk.outro.length && chunk.outro.trim())
5090 )
5091 return false;
5092 } while ((chunk = chunk.next));
5093 return true;
5094 }
5095
5096 length() {
5097 let chunk = this.firstChunk;
5098 let length = 0;
5099 do {
5100 length += chunk.intro.length + chunk.content.length + chunk.outro.length;
5101 } while ((chunk = chunk.next));
5102 return length;
5103 }
5104
5105 trimLines() {
5106 return this.trim('[\\r\\n]');
5107 }
5108
5109 trim(charType) {
5110 return this.trimStart(charType).trimEnd(charType);
5111 }
5112
5113 trimEndAborted(charType) {
5114 const rx = new RegExp((charType || '\\s') + '+$');
5115
5116 this.outro = this.outro.replace(rx, '');
5117 if (this.outro.length) return true;
5118
5119 let chunk = this.lastChunk;
5120
5121 do {
5122 const end = chunk.end;
5123 const aborted = chunk.trimEnd(rx);
5124
5125 // if chunk was trimmed, we have a new lastChunk
5126 if (chunk.end !== end) {
5127 if (this.lastChunk === chunk) {
5128 this.lastChunk = chunk.next;
5129 }
5130
5131 this.byEnd[chunk.end] = chunk;
5132 this.byStart[chunk.next.start] = chunk.next;
5133 this.byEnd[chunk.next.end] = chunk.next;
5134 }
5135
5136 if (aborted) return true;
5137 chunk = chunk.previous;
5138 } while (chunk);
5139
5140 return false;
5141 }
5142
5143 trimEnd(charType) {
5144 this.trimEndAborted(charType);
5145 return this;
5146 }
5147 trimStartAborted(charType) {
5148 const rx = new RegExp('^' + (charType || '\\s') + '+');
5149
5150 this.intro = this.intro.replace(rx, '');
5151 if (this.intro.length) return true;
5152
5153 let chunk = this.firstChunk;
5154
5155 do {
5156 const end = chunk.end;
5157 const aborted = chunk.trimStart(rx);
5158
5159 if (chunk.end !== end) {
5160 // special case...
5161 if (chunk === this.lastChunk) this.lastChunk = chunk.next;
5162
5163 this.byEnd[chunk.end] = chunk;
5164 this.byStart[chunk.next.start] = chunk.next;
5165 this.byEnd[chunk.next.end] = chunk.next;
5166 }
5167
5168 if (aborted) return true;
5169 chunk = chunk.next;
5170 } while (chunk);
5171
5172 return false;
5173 }
5174
5175 trimStart(charType) {
5176 this.trimStartAborted(charType);
5177 return this;
5178 }
5179
5180 hasChanged() {
5181 return this.original !== this.toString();
5182 }
5183
5184 _replaceRegexp(searchValue, replacement) {
5185 function getReplacement(match, str) {
5186 if (typeof replacement === 'string') {
5187 return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
5188 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
5189 if (i === '$') return '$';
5190 if (i === '&') return match[0];
5191 const num = +i;
5192 if (num < match.length) return match[+i];
5193 return `$${i}`;
5194 });
5195 } else {
5196 return replacement(...match, match.index, str, match.groups);
5197 }
5198 }
5199 function matchAll(re, str) {
5200 let match;
5201 const matches = [];
5202 while ((match = re.exec(str))) {
5203 matches.push(match);
5204 }
5205 return matches;
5206 }
5207 if (searchValue.global) {
5208 const matches = matchAll(searchValue, this.original);
5209 matches.forEach((match) => {
5210 if (match.index != null) {
5211 const replacement = getReplacement(match, this.original);
5212 if (replacement !== match[0]) {
5213 this.overwrite(
5214 match.index,
5215 match.index + match[0].length,
5216 replacement
5217 );
5218 }
5219 }
5220 });
5221 } else {
5222 const match = this.original.match(searchValue);
5223 if (match && match.index != null) {
5224 const replacement = getReplacement(match, this.original);
5225 if (replacement !== match[0]) {
5226 this.overwrite(
5227 match.index,
5228 match.index + match[0].length,
5229 replacement
5230 );
5231 }
5232 }
5233 }
5234 return this;
5235 }
5236
5237 _replaceString(string, replacement) {
5238 const { original } = this;
5239 const index = original.indexOf(string);
5240
5241 if (index !== -1) {
5242 this.overwrite(index, index + string.length, replacement);
5243 }
5244
5245 return this;
5246 }
5247
5248 replace(searchValue, replacement) {
5249 if (typeof searchValue === 'string') {
5250 return this._replaceString(searchValue, replacement);
5251 }
5252
5253 return this._replaceRegexp(searchValue, replacement);
5254 }
5255
5256 _replaceAllString(string, replacement) {
5257 const { original } = this;
5258 const stringLength = string.length;
5259 for (
5260 let index = original.indexOf(string);
5261 index !== -1;
5262 index = original.indexOf(string, index + stringLength)
5263 ) {
5264 const previous = original.slice(index, index + stringLength);
5265 if (previous !== replacement)
5266 this.overwrite(index, index + stringLength, replacement);
5267 }
5268
5269 return this;
5270 }
5271
5272 replaceAll(searchValue, replacement) {
5273 if (typeof searchValue === 'string') {
5274 return this._replaceAllString(searchValue, replacement);
5275 }
5276
5277 if (!searchValue.global) {
5278 throw new TypeError(
5279 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
5280 );
5281 }
5282
5283 return this._replaceRegexp(searchValue, replacement);
5284 }
5285}
5286
5287const debug$1 = createDebugger("vite:sourcemap", {
5288 onlyWhenFocused: true
5289});
5290function genSourceMapUrl(map) {
5291 if (typeof map !== "string") {
5292 map = JSON.stringify(map);
5293 }
5294 return `data:application/json;base64,${Buffer.from(map).toString("base64")}`;
5295}
5296function getCodeWithSourcemap(type, code, map) {
5297 if (debug$1) {
5298 code += `
5299/*${JSON.stringify(map, null, 2).replace(/\*\//g, "*\\/")}*/
5300`;
5301 }
5302 if (type === "js") {
5303 code += `
5304//# sourceMappingURL=${genSourceMapUrl(map)}`;
5305 } else if (type === "css") {
5306 code += `
5307/*# sourceMappingURL=${genSourceMapUrl(map)} */`;
5308 }
5309 return code;
5310}
5311
5312const debug = createDebugger("vite:send", {
5313 onlyWhenFocused: true
5314});
5315const alias = {
5316 js: "text/javascript",
5317 css: "text/css",
5318 html: "text/html",
5319 json: "application/json"
5320};
5321function send(req, res, content, type, options) {
5322 const {
5323 etag = getEtag(content, { weak: true }),
5324 cacheControl = "no-cache",
5325 headers,
5326 map
5327 } = options;
5328 if (res.writableEnded) {
5329 return;
5330 }
5331 if (req.headers["if-none-match"] === etag) {
5332 res.statusCode = 304;
5333 res.end();
5334 return;
5335 }
5336 res.setHeader("Content-Type", alias[type] || type);
5337 res.setHeader("Cache-Control", cacheControl);
5338 res.setHeader("Etag", etag);
5339 if (headers) {
5340 for (const name in headers) {
5341 res.setHeader(name, headers[name]);
5342 }
5343 }
5344 if (map && "version" in map && map.mappings) {
5345 if (type === "js" || type === "css") {
5346 content = getCodeWithSourcemap(type, content.toString(), map);
5347 }
5348 } else if (type === "js" && (!map || map.mappings !== "")) {
5349 const code = content.toString();
5350 if (convertSourceMap.mapFileCommentRegex.test(code)) {
5351 debug?.(`Skipped injecting fallback sourcemap for ${req.url}`);
5352 } else {
5353 const urlWithoutTimestamp = removeTimestampQuery(req.url);
5354 const ms = new MagicString(code);
5355 content = getCodeWithSourcemap(
5356 type,
5357 code,
5358 ms.generateMap({
5359 source: path$3.basename(urlWithoutTimestamp),
5360 hires: "boundary",
5361 includeContent: true
5362 })
5363 );
5364 }
5365 }
5366 res.statusCode = 200;
5367 res.end(content);
5368 return;
5369}
5370
5371const LogLevels = {
5372 silent: 0,
5373 error: 1,
5374 warn: 2,
5375 info: 3
5376};
5377let lastType;
5378let lastMsg;
5379let sameCount = 0;
5380function clearScreen() {
5381 const repeatCount = process.stdout.rows - 2;
5382 const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
5383 console.log(blank);
5384 readline.cursorTo(process.stdout, 0, 0);
5385 readline.clearScreenDown(process.stdout);
5386}
5387let timeFormatter;
5388function getTimeFormatter() {
5389 timeFormatter ??= new Intl.DateTimeFormat(void 0, {
5390 hour: "numeric",
5391 minute: "numeric",
5392 second: "numeric"
5393 });
5394 return timeFormatter;
5395}
5396function createLogger(level = "info", options = {}) {
5397 if (options.customLogger) {
5398 return options.customLogger;
5399 }
5400 const loggedErrors = /* @__PURE__ */ new WeakSet();
5401 const { prefix = "[vite]", allowClearScreen = true } = options;
5402 const thresh = LogLevels[level];
5403 const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
5404 const clear = canClearScreen ? clearScreen : () => {
5405 };
5406 function format(type, msg, options2 = {}) {
5407 if (options2.timestamp) {
5408 let tag = "";
5409 if (type === "info") {
5410 tag = colors.cyan(colors.bold(prefix));
5411 } else if (type === "warn") {
5412 tag = colors.yellow(colors.bold(prefix));
5413 } else {
5414 tag = colors.red(colors.bold(prefix));
5415 }
5416 return `${colors.dim(getTimeFormatter().format(/* @__PURE__ */ new Date()))} ${tag} ${msg}`;
5417 } else {
5418 return msg;
5419 }
5420 }
5421 function output(type, msg, options2 = {}) {
5422 if (thresh >= LogLevels[type]) {
5423 const method = type === "info" ? "log" : type;
5424 if (options2.error) {
5425 loggedErrors.add(options2.error);
5426 }
5427 if (canClearScreen) {
5428 if (type === lastType && msg === lastMsg) {
5429 sameCount++;
5430 clear();
5431 console[method](
5432 format(type, msg, options2),
5433 colors.yellow(`(x${sameCount + 1})`)
5434 );
5435 } else {
5436 sameCount = 0;
5437 lastMsg = msg;
5438 lastType = type;
5439 if (options2.clear) {
5440 clear();
5441 }
5442 console[method](format(type, msg, options2));
5443 }
5444 } else {
5445 console[method](format(type, msg, options2));
5446 }
5447 }
5448 }
5449 const warnedMessages = /* @__PURE__ */ new Set();
5450 const logger = {
5451 hasWarned: false,
5452 info(msg, opts) {
5453 output("info", msg, opts);
5454 },
5455 warn(msg, opts) {
5456 logger.hasWarned = true;
5457 output("warn", msg, opts);
5458 },
5459 warnOnce(msg, opts) {
5460 if (warnedMessages.has(msg)) return;
5461 logger.hasWarned = true;
5462 output("warn", msg, opts);
5463 warnedMessages.add(msg);
5464 },
5465 error(msg, opts) {
5466 logger.hasWarned = true;
5467 output("error", msg, opts);
5468 },
5469 clearScreen(type) {
5470 if (thresh >= LogLevels[type]) {
5471 clear();
5472 }
5473 },
5474 hasErrorLogged(error) {
5475 return loggedErrors.has(error);
5476 }
5477 };
5478 return logger;
5479}
5480
5481const ROOT_FILES = [
5482 // '.git',
5483 // https://pnpm.io/workspaces/
5484 "pnpm-workspace.yaml",
5485 // https://rushjs.io/pages/advanced/config_files/
5486 // 'rush.json',
5487 // https://nx.dev/latest/react/getting-started/nx-setup
5488 // 'workspace.json',
5489 // 'nx.json',
5490 // https://github.com/lerna/lerna#lernajson
5491 "lerna.json"
5492];
5493function hasWorkspacePackageJSON(root) {
5494 const path = path$3.join(root, "package.json");
5495 if (!isFileReadable(path)) {
5496 return false;
5497 }
5498 try {
5499 const content = JSON.parse(fs$1.readFileSync(path, "utf-8")) || {};
5500 return !!content.workspaces;
5501 } catch {
5502 return false;
5503 }
5504}
5505function hasRootFile(root) {
5506 return ROOT_FILES.some((file) => fs$1.existsSync(path$3.join(root, file)));
5507}
5508function hasPackageJSON(root) {
5509 const path = path$3.join(root, "package.json");
5510 return fs$1.existsSync(path);
5511}
5512function searchForPackageRoot(current, root = current) {
5513 if (hasPackageJSON(current)) return current;
5514 const dir = path$3.dirname(current);
5515 if (!dir || dir === current) return root;
5516 return searchForPackageRoot(dir, root);
5517}
5518function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
5519 if (hasRootFile(current)) return current;
5520 if (hasWorkspacePackageJSON(current)) return current;
5521 const dir = path$3.dirname(current);
5522 if (!dir || dir === current) return root;
5523 return searchForWorkspaceRoot(dir, root);
5524}
5525
5526function isFileServingAllowed(url, server) {
5527 if (!server.config.server.fs.strict) return true;
5528 const file = fsPathFromUrl(url);
5529 if (server._fsDenyGlob(file)) return false;
5530 if (server.moduleGraph.safeModulesPath.has(file)) return true;
5531 if (server.config.server.fs.allow.some(
5532 (uri) => isSameFileUri(uri, file) || isParentDirectory(uri, file)
5533 ))
5534 return true;
5535 return false;
5536}
5537
5538var main$1 = {exports: {}};
5539
5540var name = "dotenv";
5541var version$1 = "16.4.5";
5542var description = "Loads environment variables from .env file";
5543var main = "lib/main.js";
5544var types = "lib/main.d.ts";
5545var exports$1 = {
5546 ".": {
5547 types: "./lib/main.d.ts",
5548 require: "./lib/main.js",
5549 "default": "./lib/main.js"
5550 },
5551 "./config": "./config.js",
5552 "./config.js": "./config.js",
5553 "./lib/env-options": "./lib/env-options.js",
5554 "./lib/env-options.js": "./lib/env-options.js",
5555 "./lib/cli-options": "./lib/cli-options.js",
5556 "./lib/cli-options.js": "./lib/cli-options.js",
5557 "./package.json": "./package.json"
5558};
5559var scripts = {
5560 "dts-check": "tsc --project tests/types/tsconfig.json",
5561 lint: "standard",
5562 "lint-readme": "standard-markdown",
5563 pretest: "npm run lint && npm run dts-check",
5564 test: "tap tests/*.js --100 -Rspec",
5565 "test:coverage": "tap --coverage-report=lcov",
5566 prerelease: "npm test",
5567 release: "standard-version"
5568};
5569var repository = {
5570 type: "git",
5571 url: "git://github.com/motdotla/dotenv.git"
5572};
5573var funding = "https://dotenvx.com";
5574var keywords = [
5575 "dotenv",
5576 "env",
5577 ".env",
5578 "environment",
5579 "variables",
5580 "config",
5581 "settings"
5582];
5583var readmeFilename = "README.md";
5584var license = "BSD-2-Clause";
5585var devDependencies = {
5586 "@definitelytyped/dtslint": "^0.0.133",
5587 "@types/node": "^18.11.3",
5588 decache: "^4.6.1",
5589 sinon: "^14.0.1",
5590 standard: "^17.0.0",
5591 "standard-markdown": "^7.1.0",
5592 "standard-version": "^9.5.0",
5593 tap: "^16.3.0",
5594 tar: "^6.1.11",
5595 typescript: "^4.8.4"
5596};
5597var engines = {
5598 node: ">=12"
5599};
5600var browser = {
5601 fs: false
5602};
5603var require$$4 = {
5604 name: name,
5605 version: version$1,
5606 description: description,
5607 main: main,
5608 types: types,
5609 exports: exports$1,
5610 scripts: scripts,
5611 repository: repository,
5612 funding: funding,
5613 keywords: keywords,
5614 readmeFilename: readmeFilename,
5615 license: license,
5616 devDependencies: devDependencies,
5617 engines: engines,
5618 browser: browser
5619};
5620
5621const fs = fs$2;
5622const path = require$$0$1;
5623const os = require$$2;
5624const crypto = require$$0$2;
5625const packageJson = require$$4;
5626
5627const version = packageJson.version;
5628
5629const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
5630
5631// Parse src into an Object
5632function parse (src) {
5633 const obj = {};
5634
5635 // Convert buffer to string
5636 let lines = src.toString();
5637
5638 // Convert line breaks to same format
5639 lines = lines.replace(/\r\n?/mg, '\n');
5640
5641 let match;
5642 while ((match = LINE.exec(lines)) != null) {
5643 const key = match[1];
5644
5645 // Default undefined or null to empty string
5646 let value = (match[2] || '');
5647
5648 // Remove whitespace
5649 value = value.trim();
5650
5651 // Check if double quoted
5652 const maybeQuote = value[0];
5653
5654 // Remove surrounding quotes
5655 value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2');
5656
5657 // Expand newlines if double quoted
5658 if (maybeQuote === '"') {
5659 value = value.replace(/\\n/g, '\n');
5660 value = value.replace(/\\r/g, '\r');
5661 }
5662
5663 // Add to object
5664 obj[key] = value;
5665 }
5666
5667 return obj
5668}
5669
5670function _parseVault (options) {
5671 const vaultPath = _vaultPath(options);
5672
5673 // Parse .env.vault
5674 const result = DotenvModule.configDotenv({ path: vaultPath });
5675 if (!result.parsed) {
5676 const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
5677 err.code = 'MISSING_DATA';
5678 throw err
5679 }
5680
5681 // handle scenario for comma separated keys - for use with key rotation
5682 // example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
5683 const keys = _dotenvKey(options).split(',');
5684 const length = keys.length;
5685
5686 let decrypted;
5687 for (let i = 0; i < length; i++) {
5688 try {
5689 // Get full key
5690 const key = keys[i].trim();
5691
5692 // Get instructions for decrypt
5693 const attrs = _instructions(result, key);
5694
5695 // Decrypt
5696 decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
5697
5698 break
5699 } catch (error) {
5700 // last key
5701 if (i + 1 >= length) {
5702 throw error
5703 }
5704 // try next key
5705 }
5706 }
5707
5708 // Parse decrypted .env string
5709 return DotenvModule.parse(decrypted)
5710}
5711
5712function _log (message) {
5713 console.log(`[dotenv@${version}][INFO] ${message}`);
5714}
5715
5716function _warn (message) {
5717 console.log(`[dotenv@${version}][WARN] ${message}`);
5718}
5719
5720function _debug (message) {
5721 console.log(`[dotenv@${version}][DEBUG] ${message}`);
5722}
5723
5724function _dotenvKey (options) {
5725 // prioritize developer directly setting options.DOTENV_KEY
5726 if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
5727 return options.DOTENV_KEY
5728 }
5729
5730 // secondary infra already contains a DOTENV_KEY environment variable
5731 if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
5732 return process.env.DOTENV_KEY
5733 }
5734
5735 // fallback to empty string
5736 return ''
5737}
5738
5739function _instructions (result, dotenvKey) {
5740 // Parse DOTENV_KEY. Format is a URI
5741 let uri;
5742 try {
5743 uri = new URL(dotenvKey);
5744 } catch (error) {
5745 if (error.code === 'ERR_INVALID_URL') {
5746 const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development');
5747 err.code = 'INVALID_DOTENV_KEY';
5748 throw err
5749 }
5750
5751 throw error
5752 }
5753
5754 // Get decrypt key
5755 const key = uri.password;
5756 if (!key) {
5757 const err = new Error('INVALID_DOTENV_KEY: Missing key part');
5758 err.code = 'INVALID_DOTENV_KEY';
5759 throw err
5760 }
5761
5762 // Get environment
5763 const environment = uri.searchParams.get('environment');
5764 if (!environment) {
5765 const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
5766 err.code = 'INVALID_DOTENV_KEY';
5767 throw err
5768 }
5769
5770 // Get ciphertext payload
5771 const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
5772 const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
5773 if (!ciphertext) {
5774 const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
5775 err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
5776 throw err
5777 }
5778
5779 return { ciphertext, key }
5780}
5781
5782function _vaultPath (options) {
5783 let possibleVaultPath = null;
5784
5785 if (options && options.path && options.path.length > 0) {
5786 if (Array.isArray(options.path)) {
5787 for (const filepath of options.path) {
5788 if (fs.existsSync(filepath)) {
5789 possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
5790 }
5791 }
5792 } else {
5793 possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
5794 }
5795 } else {
5796 possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
5797 }
5798
5799 if (fs.existsSync(possibleVaultPath)) {
5800 return possibleVaultPath
5801 }
5802
5803 return null
5804}
5805
5806function _resolveHome (envPath) {
5807 return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
5808}
5809
5810function _configVault (options) {
5811 _log('Loading env from encrypted .env.vault');
5812
5813 const parsed = DotenvModule._parseVault(options);
5814
5815 let processEnv = process.env;
5816 if (options && options.processEnv != null) {
5817 processEnv = options.processEnv;
5818 }
5819
5820 DotenvModule.populate(processEnv, parsed, options);
5821
5822 return { parsed }
5823}
5824
5825function configDotenv (options) {
5826 const dotenvPath = path.resolve(process.cwd(), '.env');
5827 let encoding = 'utf8';
5828 const debug = Boolean(options && options.debug);
5829
5830 if (options && options.encoding) {
5831 encoding = options.encoding;
5832 } else {
5833 if (debug) {
5834 _debug('No encoding is specified. UTF-8 is used by default');
5835 }
5836 }
5837
5838 let optionPaths = [dotenvPath]; // default, look for .env
5839 if (options && options.path) {
5840 if (!Array.isArray(options.path)) {
5841 optionPaths = [_resolveHome(options.path)];
5842 } else {
5843 optionPaths = []; // reset default
5844 for (const filepath of options.path) {
5845 optionPaths.push(_resolveHome(filepath));
5846 }
5847 }
5848 }
5849
5850 // Build the parsed data in a temporary object (because we need to return it). Once we have the final
5851 // parsed data, we will combine it with process.env (or options.processEnv if provided).
5852 let lastError;
5853 const parsedAll = {};
5854 for (const path of optionPaths) {
5855 try {
5856 // Specifying an encoding returns a string instead of a buffer
5857 const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }));
5858
5859 DotenvModule.populate(parsedAll, parsed, options);
5860 } catch (e) {
5861 if (debug) {
5862 _debug(`Failed to load ${path} ${e.message}`);
5863 }
5864 lastError = e;
5865 }
5866 }
5867
5868 let processEnv = process.env;
5869 if (options && options.processEnv != null) {
5870 processEnv = options.processEnv;
5871 }
5872
5873 DotenvModule.populate(processEnv, parsedAll, options);
5874
5875 if (lastError) {
5876 return { parsed: parsedAll, error: lastError }
5877 } else {
5878 return { parsed: parsedAll }
5879 }
5880}
5881
5882// Populates process.env from .env file
5883function config (options) {
5884 // fallback to original dotenv if DOTENV_KEY is not set
5885 if (_dotenvKey(options).length === 0) {
5886 return DotenvModule.configDotenv(options)
5887 }
5888
5889 const vaultPath = _vaultPath(options);
5890
5891 // dotenvKey exists but .env.vault file does not exist
5892 if (!vaultPath) {
5893 _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
5894
5895 return DotenvModule.configDotenv(options)
5896 }
5897
5898 return DotenvModule._configVault(options)
5899}
5900
5901function decrypt (encrypted, keyStr) {
5902 const key = Buffer.from(keyStr.slice(-64), 'hex');
5903 let ciphertext = Buffer.from(encrypted, 'base64');
5904
5905 const nonce = ciphertext.subarray(0, 12);
5906 const authTag = ciphertext.subarray(-16);
5907 ciphertext = ciphertext.subarray(12, -16);
5908
5909 try {
5910 const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce);
5911 aesgcm.setAuthTag(authTag);
5912 return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
5913 } catch (error) {
5914 const isRange = error instanceof RangeError;
5915 const invalidKeyLength = error.message === 'Invalid key length';
5916 const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
5917
5918 if (isRange || invalidKeyLength) {
5919 const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
5920 err.code = 'INVALID_DOTENV_KEY';
5921 throw err
5922 } else if (decryptionFailed) {
5923 const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
5924 err.code = 'DECRYPTION_FAILED';
5925 throw err
5926 } else {
5927 throw error
5928 }
5929 }
5930}
5931
5932// Populate process.env with parsed values
5933function populate (processEnv, parsed, options = {}) {
5934 const debug = Boolean(options && options.debug);
5935 const override = Boolean(options && options.override);
5936
5937 if (typeof parsed !== 'object') {
5938 const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
5939 err.code = 'OBJECT_REQUIRED';
5940 throw err
5941 }
5942
5943 // Set process.env
5944 for (const key of Object.keys(parsed)) {
5945 if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
5946 if (override === true) {
5947 processEnv[key] = parsed[key];
5948 }
5949
5950 if (debug) {
5951 if (override === true) {
5952 _debug(`"${key}" is already defined and WAS overwritten`);
5953 } else {
5954 _debug(`"${key}" is already defined and was NOT overwritten`);
5955 }
5956 }
5957 } else {
5958 processEnv[key] = parsed[key];
5959 }
5960 }
5961}
5962
5963const DotenvModule = {
5964 configDotenv,
5965 _configVault,
5966 _parseVault,
5967 config,
5968 decrypt,
5969 parse,
5970 populate
5971};
5972
5973main$1.exports.configDotenv = DotenvModule.configDotenv;
5974main$1.exports._configVault = DotenvModule._configVault;
5975main$1.exports._parseVault = DotenvModule._parseVault;
5976main$1.exports.config = DotenvModule.config;
5977main$1.exports.decrypt = DotenvModule.decrypt;
5978var parse_1 = main$1.exports.parse = DotenvModule.parse;
5979main$1.exports.populate = DotenvModule.populate;
5980
5981main$1.exports = DotenvModule;
5982
5983// * /
5984// * (\\)? # is it escaped with a backslash?
5985// * (\$) # literal $
5986// * (?!\() # shouldnt be followed by parenthesis
5987// * (\{?) # first brace wrap opening
5988// * ([\w.]+) # key
5989// * (?::-((?:\$\{(?:\$\{(?:\$\{[^}]*\}|[^}])*}|[^}])*}|[^}])+))? # optional default nested 3 times
5990// * (\}?) # last brace warp closing
5991// * /xi
5992
5993const DOTENV_SUBSTITUTION_REGEX = /(\\)?(\$)(?!\()(\{?)([\w.]+)(?::?-((?:\$\{(?:\$\{(?:\$\{[^}]*\}|[^}])*}|[^}])*}|[^}])+))?(\}?)/gi;
5994
5995function _resolveEscapeSequences (value) {
5996 return value.replace(/\\\$/g, '$')
5997}
5998
5999function interpolate (value, processEnv, parsed) {
6000 return value.replace(DOTENV_SUBSTITUTION_REGEX, (match, escaped, dollarSign, openBrace, key, defaultValue, closeBrace) => {
6001 if (escaped === '\\') {
6002 return match.slice(1)
6003 } else {
6004 if (processEnv[key]) {
6005 if (processEnv[key] === parsed[key]) {
6006 return processEnv[key]
6007 } else {
6008 // scenario: PASSWORD_EXPAND_NESTED=${PASSWORD_EXPAND}
6009 return interpolate(processEnv[key], processEnv, parsed)
6010 }
6011 }
6012
6013 if (parsed[key]) {
6014 // avoid recursion from EXPAND_SELF=$EXPAND_SELF
6015 if (parsed[key] === value) {
6016 return parsed[key]
6017 } else {
6018 return interpolate(parsed[key], processEnv, parsed)
6019 }
6020 }
6021
6022 if (defaultValue) {
6023 if (defaultValue.startsWith('$')) {
6024 return interpolate(defaultValue, processEnv, parsed)
6025 } else {
6026 return defaultValue
6027 }
6028 }
6029
6030 return ''
6031 }
6032 })
6033}
6034
6035function expand (options) {
6036 let processEnv = process.env;
6037 if (options && options.processEnv != null) {
6038 processEnv = options.processEnv;
6039 }
6040
6041 for (const key in options.parsed) {
6042 let value = options.parsed[key];
6043
6044 const inProcessEnv = Object.prototype.hasOwnProperty.call(processEnv, key);
6045 if (inProcessEnv) {
6046 if (processEnv[key] === options.parsed[key]) {
6047 // assume was set to processEnv from the .env file if the values match and therefore interpolate
6048 value = interpolate(value, processEnv, options.parsed);
6049 } else {
6050 // do not interpolate - assume processEnv had the intended value even if containing a $.
6051 value = processEnv[key];
6052 }
6053 } else {
6054 // not inProcessEnv so assume interpolation for this .env key
6055 value = interpolate(value, processEnv, options.parsed);
6056 }
6057
6058 options.parsed[key] = _resolveEscapeSequences(value);
6059 }
6060
6061 for (const processKey in options.parsed) {
6062 processEnv[processKey] = options.parsed[processKey];
6063 }
6064
6065 return options
6066}
6067
6068var expand_1 = expand;
6069
6070function getEnvFilesForMode(mode, envDir) {
6071 return [
6072 /** default file */
6073 `.env`,
6074 /** local file */
6075 `.env.local`,
6076 /** mode file */
6077 `.env.${mode}`,
6078 /** mode local file */
6079 `.env.${mode}.local`
6080 ].map((file) => normalizePath(path$3.join(envDir, file)));
6081}
6082function loadEnv(mode, envDir, prefixes = "VITE_") {
6083 if (mode === "local") {
6084 throw new Error(
6085 `"local" cannot be used as a mode name because it conflicts with the .local postfix for .env files.`
6086 );
6087 }
6088 prefixes = arraify(prefixes);
6089 const env = {};
6090 const envFiles = getEnvFilesForMode(mode, envDir);
6091 const parsed = Object.fromEntries(
6092 envFiles.flatMap((filePath) => {
6093 if (!tryStatSync(filePath)?.isFile()) return [];
6094 return Object.entries(parse_1(fs$1.readFileSync(filePath)));
6095 })
6096 );
6097 if (parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === void 0) {
6098 process.env.VITE_USER_NODE_ENV = parsed.NODE_ENV;
6099 }
6100 if (parsed.BROWSER && process.env.BROWSER === void 0) {
6101 process.env.BROWSER = parsed.BROWSER;
6102 }
6103 if (parsed.BROWSER_ARGS && process.env.BROWSER_ARGS === void 0) {
6104 process.env.BROWSER_ARGS = parsed.BROWSER_ARGS;
6105 }
6106 const processEnv = { ...process.env };
6107 expand_1({ parsed, processEnv });
6108 for (const [key, value] of Object.entries(parsed)) {
6109 if (prefixes.some((prefix) => key.startsWith(prefix))) {
6110 env[key] = value;
6111 }
6112 }
6113 for (const key in process.env) {
6114 if (prefixes.some((prefix) => key.startsWith(prefix))) {
6115 env[key] = process.env[key];
6116 }
6117 }
6118 return env;
6119}
6120function resolveEnvPrefix({
6121 envPrefix = "VITE_"
6122}) {
6123 envPrefix = arraify(envPrefix);
6124 if (envPrefix.includes("")) {
6125 throw new Error(
6126 `envPrefix option contains value '', which could lead unexpected exposure of sensitive information.`
6127 );
6128 }
6129 return envPrefix;
6130}
6131
6132exports.esbuildVersion = esbuild.version;
6133exports.createFilter = createFilter;
6134exports.createLogger = createLogger;
6135exports.isCSSRequest = isCSSRequest;
6136exports.isFileServingAllowed = isFileServingAllowed;
6137exports.loadEnv = loadEnv;
6138exports.mergeAlias = mergeAlias;
6139exports.mergeConfig = mergeConfig;
6140exports.normalizePath = normalizePath;
6141exports.resolveEnvPrefix = resolveEnvPrefix;
6142exports.rollupVersion = rollupVersion;
6143exports.searchForWorkspaceRoot = searchForWorkspaceRoot;
6144exports.send = send;
6145exports.splitVendorChunk = splitVendorChunk;
6146exports.splitVendorChunkPlugin = splitVendorChunkPlugin;
6147exports.version = VERSION;
Note: See TracBrowser for help on using the repository browser.