@drupal-canvas/eslint-config 0.1.4 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +4537 -122
  2. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -4,155 +4,4565 @@ import reactHooks from 'eslint-plugin-react-hooks';
4
4
  import eslintPluginYml from 'eslint-plugin-yml';
5
5
  import { defineConfig, globalIgnores } from 'eslint/config';
6
6
  import tseslint from 'typescript-eslint';
7
- import js from '@eslint/js';
7
+ import js2 from '@eslint/js';
8
8
  import globals from 'globals';
9
- import { dirname, basename } from 'path';
10
- import { existsSync, readdirSync } from 'fs';
9
+ import { win32, posix, dirname, basename, resolve } from 'path';
10
+ import * as xi from 'fs';
11
+ import { realpathSync, readlinkSync, readdirSync, readdir as readdir$1, lstatSync, existsSync, readFileSync } from 'fs';
12
+ import 'crypto';
13
+ import { fileURLToPath } from 'url';
14
+ import { realpath, readlink, readdir, lstat } from 'fs/promises';
15
+ import { EventEmitter } from 'events';
16
+ import Pe from 'stream';
17
+ import { StringDecoder } from 'string_decoder';
11
18
  import { camelCase } from 'lodash-es';
12
19
 
13
- // src/configs/recommended.ts
20
+ var __create = Object.create;
21
+ var __defProp = Object.defineProperty;
22
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
23
+ var __getOwnPropNames = Object.getOwnPropertyNames;
24
+ var __getProtoOf = Object.getPrototypeOf;
25
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
26
+ var __commonJS = (cb, mod) => function __require() {
27
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ __defProp(target, "default", { value: mod, enumerable: true }) ,
43
+ mod
44
+ ));
45
+
46
+ // ../discovery/node_modules/ignore/index.js
47
+ var require_ignore = __commonJS({
48
+ "../discovery/node_modules/ignore/index.js"(exports$1, module) {
49
+ function makeArray(subject) {
50
+ return Array.isArray(subject) ? subject : [subject];
51
+ }
52
+ var UNDEFINED = void 0;
53
+ var EMPTY = "";
54
+ var SPACE = " ";
55
+ var ESCAPE = "\\";
56
+ var REGEX_TEST_BLANK_LINE = /^\s+$/;
57
+ var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
58
+ var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
59
+ var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
60
+ var REGEX_SPLITALL_CRLF = /\r?\n/g;
61
+ var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
62
+ var REGEX_TEST_TRAILING_SLASH = /\/$/;
63
+ var SLASH = "/";
64
+ var TMP_KEY_IGNORE = "node-ignore";
65
+ if (typeof Symbol !== "undefined") {
66
+ TMP_KEY_IGNORE = /* @__PURE__ */ Symbol.for("node-ignore");
67
+ }
68
+ var KEY_IGNORE = TMP_KEY_IGNORE;
69
+ var define = (object, key, value) => {
70
+ Object.defineProperty(object, key, { value });
71
+ return value;
72
+ };
73
+ var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
74
+ var RETURN_FALSE = () => false;
75
+ var sanitizeRange = (range) => range.replace(
76
+ REGEX_REGEXP_RANGE,
77
+ (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY
78
+ );
79
+ var cleanRangeBackSlash = (slashes) => {
80
+ const { length } = slashes;
81
+ return slashes.slice(0, length - length % 2);
82
+ };
83
+ var REPLACERS = [
84
+ [
85
+ // Remove BOM
86
+ // TODO:
87
+ // Other similar zero-width characters?
88
+ /^\uFEFF/,
89
+ () => EMPTY
90
+ ],
91
+ // > Trailing spaces are ignored unless they are quoted with backslash ("\")
92
+ [
93
+ // (a\ ) -> (a )
94
+ // (a ) -> (a)
95
+ // (a ) -> (a)
96
+ // (a \ ) -> (a )
97
+ /((?:\\\\)*?)(\\?\s+)$/,
98
+ (_2, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
99
+ ],
100
+ // Replace (\ ) with ' '
101
+ // (\ ) -> ' '
102
+ // (\\ ) -> '\\ '
103
+ // (\\\ ) -> '\\ '
104
+ [
105
+ /(\\+?)\s/g,
106
+ (_2, m1) => {
107
+ const { length } = m1;
108
+ return m1.slice(0, length - length % 2) + SPACE;
109
+ }
110
+ ],
111
+ // Escape metacharacters
112
+ // which is written down by users but means special for regular expressions.
113
+ // > There are 12 characters with special meanings:
114
+ // > - the backslash \,
115
+ // > - the caret ^,
116
+ // > - the dollar sign $,
117
+ // > - the period or dot .,
118
+ // > - the vertical bar or pipe symbol |,
119
+ // > - the question mark ?,
120
+ // > - the asterisk or star *,
121
+ // > - the plus sign +,
122
+ // > - the opening parenthesis (,
123
+ // > - the closing parenthesis ),
124
+ // > - and the opening square bracket [,
125
+ // > - the opening curly brace {,
126
+ // > These special characters are often called "metacharacters".
127
+ [
128
+ /[\\$.|*+(){^]/g,
129
+ (match) => `\\${match}`
130
+ ],
131
+ [
132
+ // > a question mark (?) matches a single character
133
+ /(?!\\)\?/g,
134
+ () => "[^/]"
135
+ ],
136
+ // leading slash
137
+ [
138
+ // > A leading slash matches the beginning of the pathname.
139
+ // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
140
+ // A leading slash matches the beginning of the pathname
141
+ /^\//,
142
+ () => "^"
143
+ ],
144
+ // replace special metacharacter slash after the leading slash
145
+ [
146
+ /\//g,
147
+ () => "\\/"
148
+ ],
149
+ [
150
+ // > A leading "**" followed by a slash means match in all directories.
151
+ // > For example, "**/foo" matches file or directory "foo" anywhere,
152
+ // > the same as pattern "foo".
153
+ // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
154
+ // > under directory "foo".
155
+ // Notice that the '*'s have been replaced as '\\*'
156
+ /^\^*\\\*\\\*\\\//,
157
+ // '**/foo' <-> 'foo'
158
+ () => "^(?:.*\\/)?"
159
+ ],
160
+ // starting
161
+ [
162
+ // there will be no leading '/'
163
+ // (which has been replaced by section "leading slash")
164
+ // If starts with '**', adding a '^' to the regular expression also works
165
+ /^(?=[^^])/,
166
+ function startingReplacer() {
167
+ return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
168
+ }
169
+ ],
170
+ // two globstars
171
+ [
172
+ // Use lookahead assertions so that we could match more than one `'/**'`
173
+ /\\\/\\\*\\\*(?=\\\/|$)/g,
174
+ // Zero, one or several directories
175
+ // should not use '*', or it will be replaced by the next replacer
176
+ // Check if it is not the last `'/**'`
177
+ (_2, index, str2) => index + 6 < str2.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
178
+ ],
179
+ // normal intermediate wildcards
180
+ [
181
+ // Never replace escaped '*'
182
+ // ignore rule '\*' will match the path '*'
183
+ // 'abc.*/' -> go
184
+ // 'abc.*' -> skip this rule,
185
+ // coz trailing single wildcard will be handed by [trailing wildcard]
186
+ /(^|[^\\]+)(\\\*)+(?=.+)/g,
187
+ // '*.js' matches '.js'
188
+ // '*.js' doesn't match 'abc'
189
+ (_2, p1, p2) => {
190
+ const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
191
+ return p1 + unescaped;
192
+ }
193
+ ],
194
+ [
195
+ // unescape, revert step 3 except for back slash
196
+ // For example, if a user escape a '\\*',
197
+ // after step 3, the result will be '\\\\\\*'
198
+ /\\\\\\(?=[$.|*+(){^])/g,
199
+ () => ESCAPE
200
+ ],
201
+ [
202
+ // '\\\\' -> '\\'
203
+ /\\\\/g,
204
+ () => ESCAPE
205
+ ],
206
+ [
207
+ // > The range notation, e.g. [a-zA-Z],
208
+ // > can be used to match one of the characters in a range.
209
+ // `\` is escaped by step 3
210
+ /(\\)?\[([^\]/]*?)(\\*)($|\])/g,
211
+ (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]"
212
+ ],
213
+ // ending
214
+ [
215
+ // 'js' will not match 'js.'
216
+ // 'ab' will not match 'abc'
217
+ /(?:[^*])$/,
218
+ // WTF!
219
+ // https://git-scm.com/docs/gitignore
220
+ // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
221
+ // which re-fixes #24, #38
222
+ // > If there is a separator at the end of the pattern then the pattern
223
+ // > will only match directories, otherwise the pattern can match both
224
+ // > files and directories.
225
+ // 'js*' will not match 'a.js'
226
+ // 'js/' will not match 'a.js'
227
+ // 'js' will match 'a.js' and 'a.js/'
228
+ (match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
229
+ ]
230
+ ];
231
+ var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
232
+ var MODE_IGNORE = "regex";
233
+ var MODE_CHECK_IGNORE = "checkRegex";
234
+ var UNDERSCORE = "_";
235
+ var TRAILING_WILD_CARD_REPLACERS = {
236
+ [MODE_IGNORE](_2, p1) {
237
+ const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
238
+ return `${prefix}(?=$|\\/$)`;
239
+ },
240
+ [MODE_CHECK_IGNORE](_2, p1) {
241
+ const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
242
+ return `${prefix}(?=$|\\/$)`;
243
+ }
244
+ };
245
+ var makeRegexPrefix = (pattern) => REPLACERS.reduce(
246
+ (prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)),
247
+ pattern
248
+ );
249
+ var isString = (subject) => typeof subject === "string";
250
+ var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
251
+ var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
252
+ var IgnoreRule = class {
253
+ constructor(pattern, mark, body, ignoreCase, negative, prefix) {
254
+ this.pattern = pattern;
255
+ this.mark = mark;
256
+ this.negative = negative;
257
+ define(this, "body", body);
258
+ define(this, "ignoreCase", ignoreCase);
259
+ define(this, "regexPrefix", prefix);
260
+ }
261
+ get regex() {
262
+ const key = UNDERSCORE + MODE_IGNORE;
263
+ if (this[key]) {
264
+ return this[key];
265
+ }
266
+ return this._make(MODE_IGNORE, key);
267
+ }
268
+ get checkRegex() {
269
+ const key = UNDERSCORE + MODE_CHECK_IGNORE;
270
+ if (this[key]) {
271
+ return this[key];
272
+ }
273
+ return this._make(MODE_CHECK_IGNORE, key);
274
+ }
275
+ _make(mode, key) {
276
+ const str2 = this.regexPrefix.replace(
277
+ REGEX_REPLACE_TRAILING_WILDCARD,
278
+ // It does not need to bind pattern
279
+ TRAILING_WILD_CARD_REPLACERS[mode]
280
+ );
281
+ const regex = this.ignoreCase ? new RegExp(str2, "i") : new RegExp(str2);
282
+ return define(this, key, regex);
283
+ }
284
+ };
285
+ var createRule = ({
286
+ pattern,
287
+ mark
288
+ }, ignoreCase) => {
289
+ let negative = false;
290
+ let body = pattern;
291
+ if (body.indexOf("!") === 0) {
292
+ negative = true;
293
+ body = body.substr(1);
294
+ }
295
+ body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
296
+ const regexPrefix = makeRegexPrefix(body);
297
+ return new IgnoreRule(
298
+ pattern,
299
+ mark,
300
+ body,
301
+ ignoreCase,
302
+ negative,
303
+ regexPrefix
304
+ );
305
+ };
306
+ var RuleManager = class {
307
+ constructor(ignoreCase) {
308
+ this._ignoreCase = ignoreCase;
309
+ this._rules = [];
310
+ }
311
+ _add(pattern) {
312
+ if (pattern && pattern[KEY_IGNORE]) {
313
+ this._rules = this._rules.concat(pattern._rules._rules);
314
+ this._added = true;
315
+ return;
316
+ }
317
+ if (isString(pattern)) {
318
+ pattern = {
319
+ pattern
320
+ };
321
+ }
322
+ if (checkPattern(pattern.pattern)) {
323
+ const rule8 = createRule(pattern, this._ignoreCase);
324
+ this._added = true;
325
+ this._rules.push(rule8);
326
+ }
327
+ }
328
+ // @param {Array<string> | string | Ignore} pattern
329
+ add(pattern) {
330
+ this._added = false;
331
+ makeArray(
332
+ isString(pattern) ? splitPattern(pattern) : pattern
333
+ ).forEach(this._add, this);
334
+ return this._added;
335
+ }
336
+ // Test one single path without recursively checking parent directories
337
+ //
338
+ // - checkUnignored `boolean` whether should check if the path is unignored,
339
+ // setting `checkUnignored` to `false` could reduce additional
340
+ // path matching.
341
+ // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
342
+ // @returns {TestResult} true if a file is ignored
343
+ test(path2, checkUnignored, mode) {
344
+ let ignored = false;
345
+ let unignored = false;
346
+ let matchedRule;
347
+ this._rules.forEach((rule8) => {
348
+ const { negative } = rule8;
349
+ if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
350
+ return;
351
+ }
352
+ const matched = rule8[mode].test(path2);
353
+ if (!matched) {
354
+ return;
355
+ }
356
+ ignored = !negative;
357
+ unignored = negative;
358
+ matchedRule = negative ? UNDEFINED : rule8;
359
+ });
360
+ const ret = {
361
+ ignored,
362
+ unignored
363
+ };
364
+ if (matchedRule) {
365
+ ret.rule = matchedRule;
366
+ }
367
+ return ret;
368
+ }
369
+ };
370
+ var throwError2 = (message, Ctor) => {
371
+ throw new Ctor(message);
372
+ };
373
+ var checkPath = (path2, originalPath, doThrow) => {
374
+ if (!isString(path2)) {
375
+ return doThrow(
376
+ `path must be a string, but got \`${originalPath}\``,
377
+ TypeError
378
+ );
379
+ }
380
+ if (!path2) {
381
+ return doThrow(`path must not be empty`, TypeError);
382
+ }
383
+ if (checkPath.isNotRelative(path2)) {
384
+ const r = "`path.relative()`d";
385
+ return doThrow(
386
+ `path should be a ${r} string, but got "${originalPath}"`,
387
+ RangeError
388
+ );
389
+ }
390
+ return true;
391
+ };
392
+ var isNotRelative = (path2) => REGEX_TEST_INVALID_PATH.test(path2);
393
+ checkPath.isNotRelative = isNotRelative;
394
+ checkPath.convert = (p) => p;
395
+ var Ignore = class {
396
+ constructor({
397
+ ignorecase = true,
398
+ ignoreCase = ignorecase,
399
+ allowRelativePaths = false
400
+ } = {}) {
401
+ define(this, KEY_IGNORE, true);
402
+ this._rules = new RuleManager(ignoreCase);
403
+ this._strictPathCheck = !allowRelativePaths;
404
+ this._initCache();
405
+ }
406
+ _initCache() {
407
+ this._ignoreCache = /* @__PURE__ */ Object.create(null);
408
+ this._testCache = /* @__PURE__ */ Object.create(null);
409
+ }
410
+ add(pattern) {
411
+ if (this._rules.add(pattern)) {
412
+ this._initCache();
413
+ }
414
+ return this;
415
+ }
416
+ // legacy
417
+ addPattern(pattern) {
418
+ return this.add(pattern);
419
+ }
420
+ // @returns {TestResult}
421
+ _test(originalPath, cache, checkUnignored, slices) {
422
+ const path2 = originalPath && checkPath.convert(originalPath);
423
+ checkPath(
424
+ path2,
425
+ originalPath,
426
+ this._strictPathCheck ? throwError2 : RETURN_FALSE
427
+ );
428
+ return this._t(path2, cache, checkUnignored, slices);
429
+ }
430
+ checkIgnore(path2) {
431
+ if (!REGEX_TEST_TRAILING_SLASH.test(path2)) {
432
+ return this.test(path2);
433
+ }
434
+ const slices = path2.split(SLASH).filter(Boolean);
435
+ slices.pop();
436
+ if (slices.length) {
437
+ const parent = this._t(
438
+ slices.join(SLASH) + SLASH,
439
+ this._testCache,
440
+ true,
441
+ slices
442
+ );
443
+ if (parent.ignored) {
444
+ return parent;
445
+ }
446
+ }
447
+ return this._rules.test(path2, false, MODE_CHECK_IGNORE);
448
+ }
449
+ _t(path2, cache, checkUnignored, slices) {
450
+ if (path2 in cache) {
451
+ return cache[path2];
452
+ }
453
+ if (!slices) {
454
+ slices = path2.split(SLASH).filter(Boolean);
455
+ }
456
+ slices.pop();
457
+ if (!slices.length) {
458
+ return cache[path2] = this._rules.test(path2, checkUnignored, MODE_IGNORE);
459
+ }
460
+ const parent = this._t(
461
+ slices.join(SLASH) + SLASH,
462
+ cache,
463
+ checkUnignored,
464
+ slices
465
+ );
466
+ return cache[path2] = parent.ignored ? parent : this._rules.test(path2, checkUnignored, MODE_IGNORE);
467
+ }
468
+ ignores(path2) {
469
+ return this._test(path2, this._ignoreCache, false).ignored;
470
+ }
471
+ createFilter() {
472
+ return (path2) => !this.ignores(path2);
473
+ }
474
+ filter(paths) {
475
+ return makeArray(paths).filter(this.createFilter());
476
+ }
477
+ // @returns {TestResult}
478
+ test(path2) {
479
+ return this._test(path2, this._testCache, true);
480
+ }
481
+ };
482
+ var factory = (options) => new Ignore(options);
483
+ var isPathValid = (path2) => checkPath(path2 && checkPath.convert(path2), path2, RETURN_FALSE);
484
+ var setupWindows = () => {
485
+ const makePosix = (str2) => /^\\\\\?\\/.test(str2) || /["<>|\u0000-\u001F]+/u.test(str2) ? str2 : str2.replace(/\\/g, "/");
486
+ checkPath.convert = makePosix;
487
+ const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
488
+ checkPath.isNotRelative = (path2) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path2) || isNotRelative(path2);
489
+ };
490
+ if (
491
+ // Detect `process` so that it can run in browsers.
492
+ typeof process !== "undefined" && process.platform === "win32"
493
+ ) {
494
+ setupWindows();
495
+ }
496
+ module.exports = factory;
497
+ factory.default = factory;
498
+ module.exports.isPathValid = isPathValid;
499
+ define(module.exports, /* @__PURE__ */ Symbol.for("setupWindows"), setupWindows);
500
+ }
501
+ });
14
502
  var JS_EXTENSIONS = ["ts", "tsx", "js", "jsx"];
15
503
  var NAMED_SUFFIX = ".component.yml";
16
504
  function isComponentEntrypoint(context) {
17
- if (!isInComponentDir(context)) {
505
+ const componentDir = dirname(context.filename);
506
+ if (!isComponentDir(componentDir)) {
507
+ return false;
508
+ }
509
+ const files = getFilesInDirectory(componentDir);
510
+ const namedMetadataFile = files.find((file) => file.endsWith(NAMED_SUFFIX));
511
+ const componentBaseName = namedMetadataFile ? namedMetadataFile.slice(0, -NAMED_SUFFIX.length) : "index";
512
+ return JS_EXTENSIONS.some(
513
+ (ext) => basename(context.filename) === componentBaseName + "." + ext
514
+ );
515
+ }
516
+ function isComponentDir(dirPath) {
517
+ try {
518
+ const files = getFilesInDirectory(dirPath);
519
+ return files.some((file) => isComponentYmlFile(file));
520
+ } catch {
521
+ return false;
522
+ }
523
+ }
524
+ function isComponentYmlFile(filePath) {
525
+ const fileName = basename(filePath);
526
+ return fileName === "component.yml" || fileName.endsWith(NAMED_SUFFIX);
527
+ }
528
+ function isNonComponentImportFromComponentDir(resolvedPath, aliasBaseDir) {
529
+ try {
530
+ const dir = dirname(resolvedPath);
531
+ if (isComponentDir(dir)) {
532
+ const files = getFilesInDirectory(dir);
533
+ const namedMetadataFile = files.find(
534
+ (file) => file !== "component.yml" && file.endsWith(NAMED_SUFFIX)
535
+ );
536
+ const entryBaseName = namedMetadataFile ? namedMetadataFile.slice(0, -NAMED_SUFFIX.length) : "index";
537
+ const importBaseName = basename(resolvedPath);
538
+ if (importBaseName === entryBaseName) {
539
+ return false;
540
+ }
541
+ if (JS_EXTENSIONS.some(
542
+ (ext) => importBaseName === entryBaseName + "." + ext
543
+ )) {
544
+ return false;
545
+ }
546
+ return true;
547
+ }
548
+ let current = dir;
549
+ let parent = dirname(current);
550
+ while (parent !== current && parent.startsWith(aliasBaseDir)) {
551
+ if (isComponentDir(parent)) {
552
+ return true;
553
+ }
554
+ current = parent;
555
+ parent = dirname(current);
556
+ }
18
557
  return false;
558
+ } catch {
559
+ return false;
560
+ }
561
+ }
562
+ function getFilesInDirectory(dirPath) {
563
+ if (!existsSync(dirPath)) {
564
+ return [];
565
+ }
566
+ try {
567
+ return readdirSync(dirPath);
568
+ } catch {
569
+ return [];
570
+ }
571
+ }
572
+
573
+ // src/utils/yaml.ts
574
+ function getYAMLStringValue(node) {
575
+ if (node && node.type === "YAMLScalar" && typeof node.value === "string") {
576
+ return node.value;
577
+ }
578
+ return null;
579
+ }
580
+
581
+ // src/rules/component-dir-name.ts
582
+ var NAMED_SUFFIX2 = ".component.yml";
583
+ function getExpectedMachineName(filename) {
584
+ const fileName = basename(filename);
585
+ if (fileName !== "component.yml" && fileName.endsWith(NAMED_SUFFIX2)) {
586
+ return {
587
+ name: fileName.slice(0, -NAMED_SUFFIX2.length),
588
+ source: `metadata filename "${fileName}"`
589
+ };
590
+ }
591
+ const dirName = basename(dirname(filename));
592
+ return { name: dirName, source: `directory name "${dirName}"` };
593
+ }
594
+ var rule = {
595
+ meta: {
596
+ type: "problem",
597
+ docs: {
598
+ description: "Validates that the machineName in component metadata matches the component directory name (index-style) or filename prefix (named-style)"
599
+ }
600
+ },
601
+ create(context) {
602
+ if (!isComponentYmlFile(context.filename)) {
603
+ return {};
604
+ }
605
+ let hasMachineName = false;
606
+ const { name: expectedName, source: expectedSource } = getExpectedMachineName(context.filename);
607
+ return {
608
+ YAMLPair(node) {
609
+ const keyName = getYAMLStringValue(node.key);
610
+ if (keyName !== "machineName") {
611
+ return;
612
+ }
613
+ hasMachineName = true;
614
+ const machineName = getYAMLStringValue(node.value);
615
+ if (!node.value || !machineName) {
616
+ context.report({
617
+ node,
618
+ message: "machineName must be a string."
619
+ });
620
+ return;
621
+ }
622
+ if (expectedName !== machineName) {
623
+ context.report({
624
+ node: node.value,
625
+ message: `${expectedSource[0].toUpperCase()}${expectedSource.slice(1)} does not match machineName "${machineName}".`
626
+ });
627
+ }
628
+ },
629
+ "Program:exit"() {
630
+ if (!hasMachineName) {
631
+ context.report({
632
+ loc: { line: 1, column: 0 },
633
+ message: `machineName key is missing. Its value should be "${expectedName}" based on ${expectedSource.toLowerCase()}.`
634
+ });
635
+ }
636
+ }
637
+ };
638
+ }
639
+ };
640
+ var component_dir_name_default = rule;
641
+
642
+ // src/rules/component-exports.ts
643
+ var rule2 = {
644
+ meta: {
645
+ type: "problem",
646
+ docs: {
647
+ description: "Validates that component has a default export"
648
+ }
649
+ },
650
+ create(context) {
651
+ if (!isComponentEntrypoint(context)) {
652
+ return {};
653
+ }
654
+ let hasDefaultExport = false;
655
+ return {
656
+ ExportDefaultDeclaration() {
657
+ hasDefaultExport = true;
658
+ },
659
+ "Program:exit"(node) {
660
+ if (!hasDefaultExport) {
661
+ context.report({
662
+ node,
663
+ message: "Component must have a default export"
664
+ });
665
+ }
666
+ }
667
+ };
668
+ }
669
+ };
670
+ var component_exports_default = rule2;
671
+ var Gt = (n7, t, e) => {
672
+ let s = n7 instanceof RegExp ? ce(n7, e) : n7, i = t instanceof RegExp ? ce(t, e) : t, r = s !== null && i != null && ss(s, i, e);
673
+ return r && { start: r[0], end: r[1], pre: e.slice(0, r[0]), body: e.slice(r[0] + s.length, r[1]), post: e.slice(r[1] + i.length) };
674
+ };
675
+ var ce = (n7, t) => {
676
+ let e = t.match(n7);
677
+ return e ? e[0] : null;
678
+ };
679
+ var ss = (n7, t, e) => {
680
+ let s, i, r, o, h, a = e.indexOf(n7), l = e.indexOf(t, a + 1), u = a;
681
+ if (a >= 0 && l > 0) {
682
+ if (n7 === t) return [a, l];
683
+ for (s = [], r = e.length; u >= 0 && !h; ) {
684
+ if (u === a) s.push(u), a = e.indexOf(n7, u + 1);
685
+ else if (s.length === 1) {
686
+ let c = s.pop();
687
+ c !== void 0 && (h = [c, l]);
688
+ } else i = s.pop(), i !== void 0 && i < r && (r = i, o = l), l = e.indexOf(t, u + 1);
689
+ u = a < l && a >= 0 ? a : l;
690
+ }
691
+ s.length && o !== void 0 && (h = [r, o]);
692
+ }
693
+ return h;
694
+ };
695
+ var fe = "\0SLASH" + Math.random() + "\0";
696
+ var ue = "\0OPEN" + Math.random() + "\0";
697
+ var qt = "\0CLOSE" + Math.random() + "\0";
698
+ var de = "\0COMMA" + Math.random() + "\0";
699
+ var pe = "\0PERIOD" + Math.random() + "\0";
700
+ var is = new RegExp(fe, "g");
701
+ var rs = new RegExp(ue, "g");
702
+ var ns = new RegExp(qt, "g");
703
+ var os = new RegExp(de, "g");
704
+ var hs = new RegExp(pe, "g");
705
+ var as = /\\\\/g;
706
+ var ls = /\\{/g;
707
+ var cs = /\\}/g;
708
+ var fs = /\\,/g;
709
+ var us = /\\./g;
710
+ var ds = 1e5;
711
+ function Ht(n7) {
712
+ return isNaN(n7) ? n7.charCodeAt(0) : parseInt(n7, 10);
713
+ }
714
+ function ps(n7) {
715
+ return n7.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(fs, de).replace(us, pe);
716
+ }
717
+ function ms(n7) {
718
+ return n7.replace(is, "\\").replace(rs, "{").replace(ns, "}").replace(os, ",").replace(hs, ".");
719
+ }
720
+ function me(n7) {
721
+ if (!n7) return [""];
722
+ let t = [], e = Gt("{", "}", n7);
723
+ if (!e) return n7.split(",");
724
+ let { pre: s, body: i, post: r } = e, o = s.split(",");
725
+ o[o.length - 1] += "{" + i + "}";
726
+ let h = me(r);
727
+ return r.length && (o[o.length - 1] += h.shift(), o.push.apply(o, h)), t.push.apply(t, o), t;
728
+ }
729
+ function ge(n7, t = {}) {
730
+ if (!n7) return [];
731
+ let { max: e = ds } = t;
732
+ return n7.slice(0, 2) === "{}" && (n7 = "\\{\\}" + n7.slice(2)), ht(ps(n7), e, true).map(ms);
733
+ }
734
+ function gs(n7) {
735
+ return "{" + n7 + "}";
736
+ }
737
+ function ws(n7) {
738
+ return /^-?0\d/.test(n7);
739
+ }
740
+ function ys(n7, t) {
741
+ return n7 <= t;
742
+ }
743
+ function bs(n7, t) {
744
+ return n7 >= t;
745
+ }
746
+ function ht(n7, t, e) {
747
+ let s = [], i = Gt("{", "}", n7);
748
+ if (!i) return [n7];
749
+ let r = i.pre, o = i.post.length ? ht(i.post, t, false) : [""];
750
+ if (/\$$/.test(i.pre)) for (let h = 0; h < o.length && h < t; h++) {
751
+ let a = r + "{" + i.body + "}" + o[h];
752
+ s.push(a);
753
+ }
754
+ else {
755
+ let h = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body), a = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body), l = h || a, u = i.body.indexOf(",") >= 0;
756
+ if (!l && !u) return i.post.match(/,(?!,).*\}/) ? (n7 = i.pre + "{" + i.body + qt + i.post, ht(n7, t, true)) : [n7];
757
+ let c;
758
+ if (l) c = i.body.split(/\.\./);
759
+ else if (c = me(i.body), c.length === 1 && c[0] !== void 0 && (c = ht(c[0], t, false).map(gs), c.length === 1)) return o.map((f) => i.pre + c[0] + f);
760
+ let d;
761
+ if (l && c[0] !== void 0 && c[1] !== void 0) {
762
+ let f = Ht(c[0]), m = Ht(c[1]), p = Math.max(c[0].length, c[1].length), w = c.length === 3 && c[2] !== void 0 ? Math.abs(Ht(c[2])) : 1, g = ys;
763
+ m < f && (w *= -1, g = bs);
764
+ let E = c.some(ws);
765
+ d = [];
766
+ for (let y = f; g(y, m); y += w) {
767
+ let b;
768
+ if (a) b = String.fromCharCode(y), b === "\\" && (b = "");
769
+ else if (b = String(y), E) {
770
+ let z = p - b.length;
771
+ if (z > 0) {
772
+ let $ = new Array(z + 1).join("0");
773
+ y < 0 ? b = "-" + $ + b.slice(1) : b = $ + b;
774
+ }
775
+ }
776
+ d.push(b);
777
+ }
778
+ } else {
779
+ d = [];
780
+ for (let f = 0; f < c.length; f++) d.push.apply(d, ht(c[f], t, false));
781
+ }
782
+ for (let f = 0; f < d.length; f++) for (let m = 0; m < o.length && s.length < t; m++) {
783
+ let p = r + d[f] + o[m];
784
+ (!e || l || p) && s.push(p);
785
+ }
786
+ }
787
+ return s;
788
+ }
789
+ var at = (n7) => {
790
+ if (typeof n7 != "string") throw new TypeError("invalid pattern");
791
+ if (n7.length > 65536) throw new TypeError("pattern is too long");
792
+ };
793
+ var Ss = { "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true], "[:alpha:]": ["\\p{L}\\p{Nl}", true], "[:ascii:]": ["\\x00-\\x7f", false], "[:blank:]": ["\\p{Zs}\\t", true], "[:cntrl:]": ["\\p{Cc}", true], "[:digit:]": ["\\p{Nd}", true], "[:graph:]": ["\\p{Z}\\p{C}", true, true], "[:lower:]": ["\\p{Ll}", true], "[:print:]": ["\\p{C}", true], "[:punct:]": ["\\p{P}", true], "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true], "[:upper:]": ["\\p{Lu}", true], "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true], "[:xdigit:]": ["A-Fa-f0-9", false] };
794
+ var lt = (n7) => n7.replace(/[[\]\\-]/g, "\\$&");
795
+ var Es = (n7) => n7.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
796
+ var we = (n7) => n7.join("");
797
+ var ye = (n7, t) => {
798
+ let e = t;
799
+ if (n7.charAt(e) !== "[") throw new Error("not in a brace expression");
800
+ let s = [], i = [], r = e + 1, o = false, h = false, a = false, l = false, u = e, c = "";
801
+ t: for (; r < n7.length; ) {
802
+ let p = n7.charAt(r);
803
+ if ((p === "!" || p === "^") && r === e + 1) {
804
+ l = true, r++;
805
+ continue;
806
+ }
807
+ if (p === "]" && o && !a) {
808
+ u = r + 1;
809
+ break;
810
+ }
811
+ if (o = true, p === "\\" && !a) {
812
+ a = true, r++;
813
+ continue;
814
+ }
815
+ if (p === "[" && !a) {
816
+ for (let [w, [g, S, E]] of Object.entries(Ss)) if (n7.startsWith(w, r)) {
817
+ if (c) return ["$.", false, n7.length - e, true];
818
+ r += w.length, E ? i.push(g) : s.push(g), h = h || S;
819
+ continue t;
820
+ }
821
+ }
822
+ if (a = false, c) {
823
+ p > c ? s.push(lt(c) + "-" + lt(p)) : p === c && s.push(lt(p)), c = "", r++;
824
+ continue;
825
+ }
826
+ if (n7.startsWith("-]", r + 1)) {
827
+ s.push(lt(p + "-")), r += 2;
828
+ continue;
829
+ }
830
+ if (n7.startsWith("-", r + 1)) {
831
+ c = p, r += 2;
832
+ continue;
833
+ }
834
+ s.push(lt(p)), r++;
835
+ }
836
+ if (u < r) return ["", false, 0, false];
837
+ if (!s.length && !i.length) return ["$.", false, n7.length - e, true];
838
+ if (i.length === 0 && s.length === 1 && /^\\?.$/.test(s[0]) && !l) {
839
+ let p = s[0].length === 2 ? s[0].slice(-1) : s[0];
840
+ return [Es(p), false, u - e, false];
841
+ }
842
+ let d = "[" + (l ? "^" : "") + we(s) + "]", f = "[" + (l ? "" : "^") + we(i) + "]";
843
+ return [s.length && i.length ? "(" + d + "|" + f + ")" : s.length ? d : f, h, u - e, true];
844
+ };
845
+ var W = (n7, { windowsPathsNoEscape: t = false, magicalBraces: e = true } = {}) => e ? t ? n7.replace(/\[([^\/\\])\]/g, "$1") : n7.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1") : t ? n7.replace(/\[([^\/\\{}])\]/g, "$1") : n7.replace(/((?!\\).|^)\[([^\/\\{}])\]/g, "$1$2").replace(/\\([^\/{}])/g, "$1");
846
+ var xs = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
847
+ var be = (n7) => xs.has(n7);
848
+ var vs = "(?!(?:^|/)\\.\\.?(?:$|/))";
849
+ var Ct = "(?!\\.)";
850
+ var Cs = /* @__PURE__ */ new Set(["[", "."]);
851
+ var Ts = /* @__PURE__ */ new Set(["..", "."]);
852
+ var As = new Set("().*{}+?[]^$\\!");
853
+ var ks = (n7) => n7.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
854
+ var Kt = "[^/]";
855
+ var Se = Kt + "*?";
856
+ var Ee = Kt + "+?";
857
+ var Q = class n {
858
+ type;
859
+ #t;
860
+ #s;
861
+ #n = false;
862
+ #r = [];
863
+ #o;
864
+ #S;
865
+ #w;
866
+ #c = false;
867
+ #h;
868
+ #u;
869
+ #f = false;
870
+ constructor(t, e, s = {}) {
871
+ this.type = t, t && (this.#s = true), this.#o = e, this.#t = this.#o ? this.#o.#t : this, this.#h = this.#t === this ? s : this.#t.#h, this.#w = this.#t === this ? [] : this.#t.#w, t === "!" && !this.#t.#c && this.#w.push(this), this.#S = this.#o ? this.#o.#r.length : 0;
872
+ }
873
+ get hasMagic() {
874
+ if (this.#s !== void 0) return this.#s;
875
+ for (let t of this.#r) if (typeof t != "string" && (t.type || t.hasMagic)) return this.#s = true;
876
+ return this.#s;
877
+ }
878
+ toString() {
879
+ return this.#u !== void 0 ? this.#u : this.type ? this.#u = this.type + "(" + this.#r.map((t) => String(t)).join("|") + ")" : this.#u = this.#r.map((t) => String(t)).join("");
880
+ }
881
+ #a() {
882
+ if (this !== this.#t) throw new Error("should only call on root");
883
+ if (this.#c) return this;
884
+ this.toString(), this.#c = true;
885
+ let t;
886
+ for (; t = this.#w.pop(); ) {
887
+ if (t.type !== "!") continue;
888
+ let e = t, s = e.#o;
889
+ for (; s; ) {
890
+ for (let i = e.#S + 1; !s.type && i < s.#r.length; i++) for (let r of t.#r) {
891
+ if (typeof r == "string") throw new Error("string part in extglob AST??");
892
+ r.copyIn(s.#r[i]);
893
+ }
894
+ e = s, s = e.#o;
895
+ }
896
+ }
897
+ return this;
898
+ }
899
+ push(...t) {
900
+ for (let e of t) if (e !== "") {
901
+ if (typeof e != "string" && !(e instanceof n && e.#o === this)) throw new Error("invalid part: " + e);
902
+ this.#r.push(e);
903
+ }
904
+ }
905
+ toJSON() {
906
+ let t = this.type === null ? this.#r.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#r.map((e) => e.toJSON())];
907
+ return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#t || this.#t.#c && this.#o?.type === "!") && t.push({}), t;
908
+ }
909
+ isStart() {
910
+ if (this.#t === this) return true;
911
+ if (!this.#o?.isStart()) return false;
912
+ if (this.#S === 0) return true;
913
+ let t = this.#o;
914
+ for (let e = 0; e < this.#S; e++) {
915
+ let s = t.#r[e];
916
+ if (!(s instanceof n && s.type === "!")) return false;
917
+ }
918
+ return true;
919
+ }
920
+ isEnd() {
921
+ if (this.#t === this || this.#o?.type === "!") return true;
922
+ if (!this.#o?.isEnd()) return false;
923
+ if (!this.type) return this.#o?.isEnd();
924
+ let t = this.#o ? this.#o.#r.length : 0;
925
+ return this.#S === t - 1;
926
+ }
927
+ copyIn(t) {
928
+ typeof t == "string" ? this.push(t) : this.push(t.clone(this));
929
+ }
930
+ clone(t) {
931
+ let e = new n(this.type, t);
932
+ for (let s of this.#r) e.copyIn(s);
933
+ return e;
934
+ }
935
+ static #i(t, e, s, i) {
936
+ let r = false, o = false, h = -1, a = false;
937
+ if (e.type === null) {
938
+ let f = s, m = "";
939
+ for (; f < t.length; ) {
940
+ let p = t.charAt(f++);
941
+ if (r || p === "\\") {
942
+ r = !r, m += p;
943
+ continue;
944
+ }
945
+ if (o) {
946
+ f === h + 1 ? (p === "^" || p === "!") && (a = true) : p === "]" && !(f === h + 2 && a) && (o = false), m += p;
947
+ continue;
948
+ } else if (p === "[") {
949
+ o = true, h = f, a = false, m += p;
950
+ continue;
951
+ }
952
+ if (!i.noext && be(p) && t.charAt(f) === "(") {
953
+ e.push(m), m = "";
954
+ let w = new n(p, e);
955
+ f = n.#i(t, w, f, i), e.push(w);
956
+ continue;
957
+ }
958
+ m += p;
959
+ }
960
+ return e.push(m), f;
961
+ }
962
+ let l = s + 1, u = new n(null, e), c = [], d = "";
963
+ for (; l < t.length; ) {
964
+ let f = t.charAt(l++);
965
+ if (r || f === "\\") {
966
+ r = !r, d += f;
967
+ continue;
968
+ }
969
+ if (o) {
970
+ l === h + 1 ? (f === "^" || f === "!") && (a = true) : f === "]" && !(l === h + 2 && a) && (o = false), d += f;
971
+ continue;
972
+ } else if (f === "[") {
973
+ o = true, h = l, a = false, d += f;
974
+ continue;
975
+ }
976
+ if (be(f) && t.charAt(l) === "(") {
977
+ u.push(d), d = "";
978
+ let m = new n(f, u);
979
+ u.push(m), l = n.#i(t, m, l, i);
980
+ continue;
981
+ }
982
+ if (f === "|") {
983
+ u.push(d), d = "", c.push(u), u = new n(null, e);
984
+ continue;
985
+ }
986
+ if (f === ")") return d === "" && e.#r.length === 0 && (e.#f = true), u.push(d), d = "", e.push(...c, u), l;
987
+ d += f;
988
+ }
989
+ return e.type = null, e.#s = void 0, e.#r = [t.substring(s - 1)], l;
990
+ }
991
+ static fromGlob(t, e = {}) {
992
+ let s = new n(null, void 0, e);
993
+ return n.#i(t, s, 0, e), s;
994
+ }
995
+ toMMPattern() {
996
+ if (this !== this.#t) return this.#t.toMMPattern();
997
+ let t = this.toString(), [e, s, i, r] = this.toRegExpSource();
998
+ if (!(i || this.#s || this.#h.nocase && !this.#h.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase())) return s;
999
+ let h = (this.#h.nocase ? "i" : "") + (r ? "u" : "");
1000
+ return Object.assign(new RegExp(`^${e}$`, h), { _src: e, _glob: t });
1001
+ }
1002
+ get options() {
1003
+ return this.#h;
1004
+ }
1005
+ toRegExpSource(t) {
1006
+ let e = t ?? !!this.#h.dot;
1007
+ if (this.#t === this && this.#a(), !this.type) {
1008
+ let a = this.isStart() && this.isEnd() && !this.#r.some((f) => typeof f != "string"), l = this.#r.map((f) => {
1009
+ let [m, p, w, g] = typeof f == "string" ? n.#E(f, this.#s, a) : f.toRegExpSource(t);
1010
+ return this.#s = this.#s || w, this.#n = this.#n || g, m;
1011
+ }).join(""), u = "";
1012
+ if (this.isStart() && typeof this.#r[0] == "string" && !(this.#r.length === 1 && Ts.has(this.#r[0]))) {
1013
+ let m = Cs, p = e && m.has(l.charAt(0)) || l.startsWith("\\.") && m.has(l.charAt(2)) || l.startsWith("\\.\\.") && m.has(l.charAt(4)), w = !e && !t && m.has(l.charAt(0));
1014
+ u = p ? vs : w ? Ct : "";
1015
+ }
1016
+ let c = "";
1017
+ return this.isEnd() && this.#t.#c && this.#o?.type === "!" && (c = "(?:$|\\/)"), [u + l + c, W(l), this.#s = !!this.#s, this.#n];
1018
+ }
1019
+ let s = this.type === "*" || this.type === "+", i = this.type === "!" ? "(?:(?!(?:" : "(?:", r = this.#d(e);
1020
+ if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
1021
+ let a = this.toString();
1022
+ return this.#r = [a], this.type = null, this.#s = void 0, [a, W(this.toString()), false, false];
1023
+ }
1024
+ let o = !s || t || e || !Ct ? "" : this.#d(true);
1025
+ o === r && (o = ""), o && (r = `(?:${r})(?:${o})*?`);
1026
+ let h = "";
1027
+ if (this.type === "!" && this.#f) h = (this.isStart() && !e ? Ct : "") + Ee;
1028
+ else {
1029
+ let a = this.type === "!" ? "))" + (this.isStart() && !e && !t ? Ct : "") + Se + ")" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : `)${this.type}`;
1030
+ h = i + r + a;
1031
+ }
1032
+ return [h, W(r), this.#s = !!this.#s, this.#n];
1033
+ }
1034
+ #d(t) {
1035
+ return this.#r.map((e) => {
1036
+ if (typeof e == "string") throw new Error("string type in extglob ast??");
1037
+ let [s, i, r, o] = e.toRegExpSource(t);
1038
+ return this.#n = this.#n || o, s;
1039
+ }).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
1040
+ }
1041
+ static #E(t, e, s = false) {
1042
+ let i = false, r = "", o = false, h = false;
1043
+ for (let a = 0; a < t.length; a++) {
1044
+ let l = t.charAt(a);
1045
+ if (i) {
1046
+ i = false, r += (As.has(l) ? "\\" : "") + l;
1047
+ continue;
1048
+ }
1049
+ if (l === "*") {
1050
+ if (h) continue;
1051
+ h = true, r += s && /^[*]+$/.test(t) ? Ee : Se, e = true;
1052
+ continue;
1053
+ } else h = false;
1054
+ if (l === "\\") {
1055
+ a === t.length - 1 ? r += "\\\\" : i = true;
1056
+ continue;
1057
+ }
1058
+ if (l === "[") {
1059
+ let [u, c, d, f] = ye(t, a);
1060
+ if (d) {
1061
+ r += u, o = o || c, a += d - 1, e = e || f;
1062
+ continue;
1063
+ }
1064
+ }
1065
+ if (l === "?") {
1066
+ r += Kt, e = true;
1067
+ continue;
1068
+ }
1069
+ r += ks(l);
1070
+ }
1071
+ return [r, W(t), !!e, o];
1072
+ }
1073
+ };
1074
+ var tt = (n7, { windowsPathsNoEscape: t = false, magicalBraces: e = false } = {}) => e ? t ? n7.replace(/[?*()[\]{}]/g, "[$&]") : n7.replace(/[?*()[\]\\{}]/g, "\\$&") : t ? n7.replace(/[?*()[\]]/g, "[$&]") : n7.replace(/[?*()[\]\\]/g, "\\$&");
1075
+ var O = (n7, t, e = {}) => (at(t), !e.nocomment && t.charAt(0) === "#" ? false : new D(t, e).match(n7));
1076
+ var Rs = /^\*+([^+@!?\*\[\(]*)$/;
1077
+ var Os = (n7) => (t) => !t.startsWith(".") && t.endsWith(n7);
1078
+ var Fs = (n7) => (t) => t.endsWith(n7);
1079
+ var Ds = (n7) => (n7 = n7.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(n7));
1080
+ var Ms = (n7) => (n7 = n7.toLowerCase(), (t) => t.toLowerCase().endsWith(n7));
1081
+ var Ns = /^\*+\.\*+$/;
1082
+ var _s = (n7) => !n7.startsWith(".") && n7.includes(".");
1083
+ var Ls = (n7) => n7 !== "." && n7 !== ".." && n7.includes(".");
1084
+ var Ws = /^\.\*+$/;
1085
+ var Ps = (n7) => n7 !== "." && n7 !== ".." && n7.startsWith(".");
1086
+ var js = /^\*+$/;
1087
+ var Is = (n7) => n7.length !== 0 && !n7.startsWith(".");
1088
+ var zs = (n7) => n7.length !== 0 && n7 !== "." && n7 !== "..";
1089
+ var Bs = /^\?+([^+@!?\*\[\(]*)?$/;
1090
+ var Us = ([n7, t = ""]) => {
1091
+ let e = Ce([n7]);
1092
+ return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
1093
+ };
1094
+ var $s = ([n7, t = ""]) => {
1095
+ let e = Te([n7]);
1096
+ return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
1097
+ };
1098
+ var Gs = ([n7, t = ""]) => {
1099
+ let e = Te([n7]);
1100
+ return t ? (s) => e(s) && s.endsWith(t) : e;
1101
+ };
1102
+ var Hs = ([n7, t = ""]) => {
1103
+ let e = Ce([n7]);
1104
+ return t ? (s) => e(s) && s.endsWith(t) : e;
1105
+ };
1106
+ var Ce = ([n7]) => {
1107
+ let t = n7.length;
1108
+ return (e) => e.length === t && !e.startsWith(".");
1109
+ };
1110
+ var Te = ([n7]) => {
1111
+ let t = n7.length;
1112
+ return (e) => e.length === t && e !== "." && e !== "..";
1113
+ };
1114
+ var Ae = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
1115
+ var xe = { win32: { sep: "\\" }, posix: { sep: "/" } };
1116
+ var qs = Ae === "win32" ? xe.win32.sep : xe.posix.sep;
1117
+ O.sep = qs;
1118
+ var A = /* @__PURE__ */ Symbol("globstar **");
1119
+ O.GLOBSTAR = A;
1120
+ var Ks = "[^/]";
1121
+ var Vs = Ks + "*?";
1122
+ var Ys = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
1123
+ var Xs = "(?:(?!(?:\\/|^)\\.).)*?";
1124
+ var Js = (n7, t = {}) => (e) => O(e, n7, t);
1125
+ O.filter = Js;
1126
+ var N = (n7, t = {}) => Object.assign({}, n7, t);
1127
+ var Zs = (n7) => {
1128
+ if (!n7 || typeof n7 != "object" || !Object.keys(n7).length) return O;
1129
+ let t = O;
1130
+ return Object.assign((s, i, r = {}) => t(s, i, N(n7, r)), { Minimatch: class extends t.Minimatch {
1131
+ constructor(i, r = {}) {
1132
+ super(i, N(n7, r));
1133
+ }
1134
+ static defaults(i) {
1135
+ return t.defaults(N(n7, i)).Minimatch;
1136
+ }
1137
+ }, AST: class extends t.AST {
1138
+ constructor(i, r, o = {}) {
1139
+ super(i, r, N(n7, o));
1140
+ }
1141
+ static fromGlob(i, r = {}) {
1142
+ return t.AST.fromGlob(i, N(n7, r));
1143
+ }
1144
+ }, unescape: (s, i = {}) => t.unescape(s, N(n7, i)), escape: (s, i = {}) => t.escape(s, N(n7, i)), filter: (s, i = {}) => t.filter(s, N(n7, i)), defaults: (s) => t.defaults(N(n7, s)), makeRe: (s, i = {}) => t.makeRe(s, N(n7, i)), braceExpand: (s, i = {}) => t.braceExpand(s, N(n7, i)), match: (s, i, r = {}) => t.match(s, i, N(n7, r)), sep: t.sep, GLOBSTAR: A });
1145
+ };
1146
+ O.defaults = Zs;
1147
+ var ke = (n7, t = {}) => (at(n7), t.nobrace || !/\{(?:(?!\{).)*\}/.test(n7) ? [n7] : ge(n7, { max: t.braceExpandMax }));
1148
+ O.braceExpand = ke;
1149
+ var Qs = (n7, t = {}) => new D(n7, t).makeRe();
1150
+ O.makeRe = Qs;
1151
+ var ti = (n7, t, e = {}) => {
1152
+ let s = new D(t, e);
1153
+ return n7 = n7.filter((i) => s.match(i)), s.options.nonull && !n7.length && n7.push(t), n7;
1154
+ };
1155
+ O.match = ti;
1156
+ var ve = /[?*]|[+@!]\(.*?\)|\[|\]/;
1157
+ var ei = (n7) => n7.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
1158
+ var D = class {
1159
+ options;
1160
+ set;
1161
+ pattern;
1162
+ windowsPathsNoEscape;
1163
+ nonegate;
1164
+ negate;
1165
+ comment;
1166
+ empty;
1167
+ preserveMultipleSlashes;
1168
+ partial;
1169
+ globSet;
1170
+ globParts;
1171
+ nocase;
1172
+ isWindows;
1173
+ platform;
1174
+ windowsNoMagicRoot;
1175
+ regexp;
1176
+ constructor(t, e = {}) {
1177
+ at(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ae, this.isWindows = this.platform === "win32";
1178
+ let s = "allowWindowsEscape";
1179
+ this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e[s] === false, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = false, this.nonegate = !!e.nonegate, this.comment = false, this.empty = false, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
1180
+ }
1181
+ hasMagic() {
1182
+ if (this.options.magicalBraces && this.set.length > 1) return true;
1183
+ for (let t of this.set) for (let e of t) if (typeof e != "string") return true;
1184
+ return false;
1185
+ }
1186
+ debug(...t) {
1187
+ }
1188
+ make() {
1189
+ let t = this.pattern, e = this.options;
1190
+ if (!e.nocomment && t.charAt(0) === "#") {
1191
+ this.comment = true;
1192
+ return;
1193
+ }
1194
+ if (!t) {
1195
+ this.empty = true;
1196
+ return;
1197
+ }
1198
+ this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...r) => console.error(...r)), this.debug(this.pattern, this.globSet);
1199
+ let s = this.globSet.map((r) => this.slashSplit(r));
1200
+ this.globParts = this.preprocess(s), this.debug(this.pattern, this.globParts);
1201
+ let i = this.globParts.map((r, o, h) => {
1202
+ if (this.isWindows && this.windowsNoMagicRoot) {
1203
+ let a = r[0] === "" && r[1] === "" && (r[2] === "?" || !ve.test(r[2])) && !ve.test(r[3]), l = /^[a-z]:/i.test(r[0]);
1204
+ if (a) return [...r.slice(0, 4), ...r.slice(4).map((u) => this.parse(u))];
1205
+ if (l) return [r[0], ...r.slice(1).map((u) => this.parse(u))];
1206
+ }
1207
+ return r.map((a) => this.parse(a));
1208
+ });
1209
+ if (this.debug(this.pattern, i), this.set = i.filter((r) => r.indexOf(false) === -1), this.isWindows) for (let r = 0; r < this.set.length; r++) {
1210
+ let o = this.set[r];
1211
+ o[0] === "" && o[1] === "" && this.globParts[r][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
1212
+ }
1213
+ this.debug(this.pattern, this.set);
1214
+ }
1215
+ preprocess(t) {
1216
+ if (this.options.noglobstar) for (let s = 0; s < t.length; s++) for (let i = 0; i < t[s].length; i++) t[s][i] === "**" && (t[s][i] = "*");
1217
+ let { optimizationLevel: e = 1 } = this.options;
1218
+ return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
1219
+ }
1220
+ adjascentGlobstarOptimize(t) {
1221
+ return t.map((e) => {
1222
+ let s = -1;
1223
+ for (; (s = e.indexOf("**", s + 1)) !== -1; ) {
1224
+ let i = s;
1225
+ for (; e[i + 1] === "**"; ) i++;
1226
+ i !== s && e.splice(s, i - s);
1227
+ }
1228
+ return e;
1229
+ });
1230
+ }
1231
+ levelOneOptimize(t) {
1232
+ return t.map((e) => (e = e.reduce((s, i) => {
1233
+ let r = s[s.length - 1];
1234
+ return i === "**" && r === "**" ? s : i === ".." && r && r !== ".." && r !== "." && r !== "**" ? (s.pop(), s) : (s.push(i), s);
1235
+ }, []), e.length === 0 ? [""] : e));
1236
+ }
1237
+ levelTwoFileOptimize(t) {
1238
+ Array.isArray(t) || (t = this.slashSplit(t));
1239
+ let e = false;
1240
+ do {
1241
+ if (e = false, !this.preserveMultipleSlashes) {
1242
+ for (let i = 1; i < t.length - 1; i++) {
1243
+ let r = t[i];
1244
+ i === 1 && r === "" && t[0] === "" || (r === "." || r === "") && (e = true, t.splice(i, 1), i--);
1245
+ }
1246
+ t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = true, t.pop());
1247
+ }
1248
+ let s = 0;
1249
+ for (; (s = t.indexOf("..", s + 1)) !== -1; ) {
1250
+ let i = t[s - 1];
1251
+ i && i !== "." && i !== ".." && i !== "**" && (e = true, t.splice(s - 1, 2), s -= 2);
1252
+ }
1253
+ } while (e);
1254
+ return t.length === 0 ? [""] : t;
1255
+ }
1256
+ firstPhasePreProcess(t) {
1257
+ let e = false;
1258
+ do {
1259
+ e = false;
1260
+ for (let s of t) {
1261
+ let i = -1;
1262
+ for (; (i = s.indexOf("**", i + 1)) !== -1; ) {
1263
+ let o = i;
1264
+ for (; s[o + 1] === "**"; ) o++;
1265
+ o > i && s.splice(i + 1, o - i);
1266
+ let h = s[i + 1], a = s[i + 2], l = s[i + 3];
1267
+ if (h !== ".." || !a || a === "." || a === ".." || !l || l === "." || l === "..") continue;
1268
+ e = true, s.splice(i, 1);
1269
+ let u = s.slice(0);
1270
+ u[i] = "**", t.push(u), i--;
1271
+ }
1272
+ if (!this.preserveMultipleSlashes) {
1273
+ for (let o = 1; o < s.length - 1; o++) {
1274
+ let h = s[o];
1275
+ o === 1 && h === "" && s[0] === "" || (h === "." || h === "") && (e = true, s.splice(o, 1), o--);
1276
+ }
1277
+ s[0] === "." && s.length === 2 && (s[1] === "." || s[1] === "") && (e = true, s.pop());
1278
+ }
1279
+ let r = 0;
1280
+ for (; (r = s.indexOf("..", r + 1)) !== -1; ) {
1281
+ let o = s[r - 1];
1282
+ if (o && o !== "." && o !== ".." && o !== "**") {
1283
+ e = true;
1284
+ let a = r === 1 && s[r + 1] === "**" ? ["."] : [];
1285
+ s.splice(r - 1, 2, ...a), s.length === 0 && s.push(""), r -= 2;
1286
+ }
1287
+ }
1288
+ }
1289
+ } while (e);
1290
+ return t;
1291
+ }
1292
+ secondPhasePreProcess(t) {
1293
+ for (let e = 0; e < t.length - 1; e++) for (let s = e + 1; s < t.length; s++) {
1294
+ let i = this.partsMatch(t[e], t[s], !this.preserveMultipleSlashes);
1295
+ if (i) {
1296
+ t[e] = [], t[s] = i;
1297
+ break;
1298
+ }
1299
+ }
1300
+ return t.filter((e) => e.length);
1301
+ }
1302
+ partsMatch(t, e, s = false) {
1303
+ let i = 0, r = 0, o = [], h = "";
1304
+ for (; i < t.length && r < e.length; ) if (t[i] === e[r]) o.push(h === "b" ? e[r] : t[i]), i++, r++;
1305
+ else if (s && t[i] === "**" && e[r] === t[i + 1]) o.push(t[i]), i++;
1306
+ else if (s && e[r] === "**" && t[i] === e[r + 1]) o.push(e[r]), r++;
1307
+ else if (t[i] === "*" && e[r] && (this.options.dot || !e[r].startsWith(".")) && e[r] !== "**") {
1308
+ if (h === "b") return false;
1309
+ h = "a", o.push(t[i]), i++, r++;
1310
+ } else if (e[r] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
1311
+ if (h === "a") return false;
1312
+ h = "b", o.push(e[r]), i++, r++;
1313
+ } else return false;
1314
+ return t.length === e.length && o;
1315
+ }
1316
+ parseNegate() {
1317
+ if (this.nonegate) return;
1318
+ let t = this.pattern, e = false, s = 0;
1319
+ for (let i = 0; i < t.length && t.charAt(i) === "!"; i++) e = !e, s++;
1320
+ s && (this.pattern = t.slice(s)), this.negate = e;
1321
+ }
1322
+ matchOne(t, e, s = false) {
1323
+ let i = this.options;
1324
+ if (this.isWindows) {
1325
+ let p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), w = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), g = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), S = !g && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), E = w ? 3 : p ? 0 : void 0, y = S ? 3 : g ? 0 : void 0;
1326
+ if (typeof E == "number" && typeof y == "number") {
1327
+ let [b, z] = [t[E], e[y]];
1328
+ b.toLowerCase() === z.toLowerCase() && (e[y] = b, y > E ? e = e.slice(y) : E > y && (t = t.slice(E)));
1329
+ }
1330
+ }
1331
+ let { optimizationLevel: r = 1 } = this.options;
1332
+ r >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
1333
+ for (var o = 0, h = 0, a = t.length, l = e.length; o < a && h < l; o++, h++) {
1334
+ this.debug("matchOne loop");
1335
+ var u = e[h], c = t[o];
1336
+ if (this.debug(e, u, c), u === false) return false;
1337
+ if (u === A) {
1338
+ this.debug("GLOBSTAR", [e, u, c]);
1339
+ var d = o, f = h + 1;
1340
+ if (f === l) {
1341
+ for (this.debug("** at the end"); o < a; o++) if (t[o] === "." || t[o] === ".." || !i.dot && t[o].charAt(0) === ".") return false;
1342
+ return true;
1343
+ }
1344
+ for (; d < a; ) {
1345
+ var m = t[d];
1346
+ if (this.debug(`
1347
+ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) return this.debug("globstar found match!", d, a, m), true;
1348
+ if (m === "." || m === ".." || !i.dot && m.charAt(0) === ".") {
1349
+ this.debug("dot detected!", t, d, e, f);
1350
+ break;
1351
+ }
1352
+ this.debug("globstar swallow a segment, and continue"), d++;
1353
+ }
1354
+ return !!(s && (this.debug(`
1355
+ >>> no match, partial?`, t, d, e, f), d === a));
1356
+ }
1357
+ let p;
1358
+ if (typeof u == "string" ? (p = c === u, this.debug("string match", u, c, p)) : (p = u.test(c), this.debug("pattern match", u, c, p)), !p) return false;
1359
+ }
1360
+ if (o === a && h === l) return true;
1361
+ if (o === a) return s;
1362
+ if (h === l) return o === a - 1 && t[o] === "";
1363
+ throw new Error("wtf?");
1364
+ }
1365
+ braceExpand() {
1366
+ return ke(this.pattern, this.options);
1367
+ }
1368
+ parse(t) {
1369
+ at(t);
1370
+ let e = this.options;
1371
+ if (t === "**") return A;
1372
+ if (t === "") return "";
1373
+ let s, i = null;
1374
+ (s = t.match(js)) ? i = e.dot ? zs : Is : (s = t.match(Rs)) ? i = (e.nocase ? e.dot ? Ms : Ds : e.dot ? Fs : Os)(s[1]) : (s = t.match(Bs)) ? i = (e.nocase ? e.dot ? $s : Us : e.dot ? Gs : Hs)(s) : (s = t.match(Ns)) ? i = e.dot ? Ls : _s : (s = t.match(Ws)) && (i = Ps);
1375
+ let r = Q.fromGlob(t, this.options).toMMPattern();
1376
+ return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
1377
+ }
1378
+ makeRe() {
1379
+ if (this.regexp || this.regexp === false) return this.regexp;
1380
+ let t = this.set;
1381
+ if (!t.length) return this.regexp = false, this.regexp;
1382
+ let e = this.options, s = e.noglobstar ? Vs : e.dot ? Ys : Xs, i = new Set(e.nocase ? ["i"] : []), r = t.map((a) => {
1383
+ let l = a.map((c) => {
1384
+ if (c instanceof RegExp) for (let d of c.flags.split("")) i.add(d);
1385
+ return typeof c == "string" ? ei(c) : c === A ? A : c._src;
1386
+ });
1387
+ l.forEach((c, d) => {
1388
+ let f = l[d + 1], m = l[d - 1];
1389
+ c !== A || m === A || (m === void 0 ? f !== void 0 && f !== A ? l[d + 1] = "(?:\\/|" + s + "\\/)?" + f : l[d] = s : f === void 0 ? l[d - 1] = m + "(?:\\/|\\/" + s + ")?" : f !== A && (l[d - 1] = m + "(?:\\/|\\/" + s + "\\/)" + f, l[d + 1] = A));
1390
+ });
1391
+ let u = l.filter((c) => c !== A);
1392
+ if (this.partial && u.length >= 1) {
1393
+ let c = [];
1394
+ for (let d = 1; d <= u.length; d++) c.push(u.slice(0, d).join("/"));
1395
+ return "(?:" + c.join("|") + ")";
1396
+ }
1397
+ return u.join("/");
1398
+ }).join("|"), [o, h] = t.length > 1 ? ["(?:", ")"] : ["", ""];
1399
+ r = "^" + o + r + h + "$", this.partial && (r = "^(?:\\/|" + o + r.slice(1, -1) + h + ")$"), this.negate && (r = "^(?!" + r + ").+$");
1400
+ try {
1401
+ this.regexp = new RegExp(r, [...i].join(""));
1402
+ } catch {
1403
+ this.regexp = false;
1404
+ }
1405
+ return this.regexp;
1406
+ }
1407
+ slashSplit(t) {
1408
+ return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^\/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
1409
+ }
1410
+ match(t, e = this.partial) {
1411
+ if (this.debug("match", t, this.pattern), this.comment) return false;
1412
+ if (this.empty) return t === "";
1413
+ if (t === "/" && e) return true;
1414
+ let s = this.options;
1415
+ this.isWindows && (t = t.split("\\").join("/"));
1416
+ let i = this.slashSplit(t);
1417
+ this.debug(this.pattern, "split", i);
1418
+ let r = this.set;
1419
+ this.debug(this.pattern, "set", r);
1420
+ let o = i[i.length - 1];
1421
+ if (!o) for (let h = i.length - 2; !o && h >= 0; h--) o = i[h];
1422
+ for (let h = 0; h < r.length; h++) {
1423
+ let a = r[h], l = i;
1424
+ if (s.matchBase && a.length === 1 && (l = [o]), this.matchOne(l, a, e)) return s.flipNegate ? true : !this.negate;
1425
+ }
1426
+ return s.flipNegate ? false : this.negate;
1427
+ }
1428
+ static defaults(t) {
1429
+ return O.defaults(t).Minimatch;
1430
+ }
1431
+ };
1432
+ O.AST = Q;
1433
+ O.Minimatch = D;
1434
+ O.escape = tt;
1435
+ O.unescape = W;
1436
+ var si = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
1437
+ var Oe = /* @__PURE__ */ new Set();
1438
+ var Vt = typeof process == "object" && process ? process : {};
1439
+ var Fe = (n7, t, e, s) => {
1440
+ typeof Vt.emitWarning == "function" ? Vt.emitWarning(n7, t, e, s) : console.error(`[${e}] ${t}: ${n7}`);
1441
+ };
1442
+ var At = globalThis.AbortController;
1443
+ var Re = globalThis.AbortSignal;
1444
+ if (typeof At > "u") {
1445
+ Re = class {
1446
+ onabort;
1447
+ _onabort = [];
1448
+ reason;
1449
+ aborted = false;
1450
+ addEventListener(e, s) {
1451
+ this._onabort.push(s);
1452
+ }
1453
+ }, At = class {
1454
+ constructor() {
1455
+ t();
1456
+ }
1457
+ signal = new Re();
1458
+ abort(e) {
1459
+ if (!this.signal.aborted) {
1460
+ this.signal.reason = e, this.signal.aborted = true;
1461
+ for (let s of this.signal._onabort) s(e);
1462
+ this.signal.onabort?.(e);
1463
+ }
1464
+ }
1465
+ };
1466
+ let n7 = Vt.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
1467
+ n7 && (n7 = false, Fe("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", t));
1468
+ };
1469
+ }
1470
+ var ii = (n7) => !Oe.has(n7);
1471
+ var q = (n7) => n7 && n7 === Math.floor(n7) && n7 > 0 && isFinite(n7);
1472
+ var De = (n7) => q(n7) ? n7 <= Math.pow(2, 8) ? Uint8Array : n7 <= Math.pow(2, 16) ? Uint16Array : n7 <= Math.pow(2, 32) ? Uint32Array : n7 <= Number.MAX_SAFE_INTEGER ? Tt : null : null;
1473
+ var Tt = class extends Array {
1474
+ constructor(n7) {
1475
+ super(n7), this.fill(0);
1476
+ }
1477
+ };
1478
+ var ri = class ct {
1479
+ heap;
1480
+ length;
1481
+ static #t = false;
1482
+ static create(t) {
1483
+ let e = De(t);
1484
+ if (!e) return [];
1485
+ ct.#t = true;
1486
+ let s = new ct(t, e);
1487
+ return ct.#t = false, s;
1488
+ }
1489
+ constructor(t, e) {
1490
+ if (!ct.#t) throw new TypeError("instantiate Stack using Stack.create(n)");
1491
+ this.heap = new e(t), this.length = 0;
1492
+ }
1493
+ push(t) {
1494
+ this.heap[this.length++] = t;
1495
+ }
1496
+ pop() {
1497
+ return this.heap[--this.length];
1498
+ }
1499
+ };
1500
+ var ft = class Me {
1501
+ #t;
1502
+ #s;
1503
+ #n;
1504
+ #r;
1505
+ #o;
1506
+ #S;
1507
+ #w;
1508
+ #c;
1509
+ get perf() {
1510
+ return this.#c;
1511
+ }
1512
+ ttl;
1513
+ ttlResolution;
1514
+ ttlAutopurge;
1515
+ updateAgeOnGet;
1516
+ updateAgeOnHas;
1517
+ allowStale;
1518
+ noDisposeOnSet;
1519
+ noUpdateTTL;
1520
+ maxEntrySize;
1521
+ sizeCalculation;
1522
+ noDeleteOnFetchRejection;
1523
+ noDeleteOnStaleGet;
1524
+ allowStaleOnFetchAbort;
1525
+ allowStaleOnFetchRejection;
1526
+ ignoreFetchAbort;
1527
+ #h;
1528
+ #u;
1529
+ #f;
1530
+ #a;
1531
+ #i;
1532
+ #d;
1533
+ #E;
1534
+ #b;
1535
+ #p;
1536
+ #R;
1537
+ #m;
1538
+ #C;
1539
+ #T;
1540
+ #g;
1541
+ #y;
1542
+ #x;
1543
+ #A;
1544
+ #e;
1545
+ #_;
1546
+ static unsafeExposeInternals(t) {
1547
+ return { starts: t.#T, ttls: t.#g, autopurgeTimers: t.#y, sizes: t.#C, keyMap: t.#f, keyList: t.#a, valList: t.#i, next: t.#d, prev: t.#E, get head() {
1548
+ return t.#b;
1549
+ }, get tail() {
1550
+ return t.#p;
1551
+ }, free: t.#R, isBackgroundFetch: (e) => t.#l(e), backgroundFetch: (e, s, i, r) => t.#U(e, s, i, r), moveToTail: (e) => t.#W(e), indexes: (e) => t.#F(e), rindexes: (e) => t.#D(e), isStale: (e) => t.#v(e) };
1552
+ }
1553
+ get max() {
1554
+ return this.#t;
1555
+ }
1556
+ get maxSize() {
1557
+ return this.#s;
1558
+ }
1559
+ get calculatedSize() {
1560
+ return this.#u;
1561
+ }
1562
+ get size() {
1563
+ return this.#h;
1564
+ }
1565
+ get fetchMethod() {
1566
+ return this.#S;
1567
+ }
1568
+ get memoMethod() {
1569
+ return this.#w;
1570
+ }
1571
+ get dispose() {
1572
+ return this.#n;
1573
+ }
1574
+ get onInsert() {
1575
+ return this.#r;
1576
+ }
1577
+ get disposeAfter() {
1578
+ return this.#o;
1579
+ }
1580
+ constructor(t) {
1581
+ let { max: e = 0, ttl: s, ttlResolution: i = 1, ttlAutopurge: r, updateAgeOnGet: o, updateAgeOnHas: h, allowStale: a, dispose: l, onInsert: u, disposeAfter: c, noDisposeOnSet: d, noUpdateTTL: f, maxSize: m = 0, maxEntrySize: p = 0, sizeCalculation: w, fetchMethod: g, memoMethod: S, noDeleteOnFetchRejection: E, noDeleteOnStaleGet: y, allowStaleOnFetchRejection: b, allowStaleOnFetchAbort: z, ignoreFetchAbort: $, perf: J } = t;
1582
+ if (J !== void 0 && typeof J?.now != "function") throw new TypeError("perf option must have a now() method if specified");
1583
+ if (this.#c = J ?? si, e !== 0 && !q(e)) throw new TypeError("max option must be a nonnegative integer");
1584
+ let Z = e ? De(e) : Array;
1585
+ if (!Z) throw new Error("invalid max value: " + e);
1586
+ if (this.#t = e, this.#s = m, this.maxEntrySize = p || this.#s, this.sizeCalculation = w, this.sizeCalculation) {
1587
+ if (!this.#s && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
1588
+ if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
1589
+ }
1590
+ if (S !== void 0 && typeof S != "function") throw new TypeError("memoMethod must be a function if defined");
1591
+ if (this.#w = S, g !== void 0 && typeof g != "function") throw new TypeError("fetchMethod must be a function if specified");
1592
+ if (this.#S = g, this.#A = !!g, this.#f = /* @__PURE__ */ new Map(), this.#a = new Array(e).fill(void 0), this.#i = new Array(e).fill(void 0), this.#d = new Z(e), this.#E = new Z(e), this.#b = 0, this.#p = 0, this.#R = ri.create(e), this.#h = 0, this.#u = 0, typeof l == "function" && (this.#n = l), typeof u == "function" && (this.#r = u), typeof c == "function" ? (this.#o = c, this.#m = []) : (this.#o = void 0, this.#m = void 0), this.#x = !!this.#n, this.#_ = !!this.#r, this.#e = !!this.#o, this.noDisposeOnSet = !!d, this.noUpdateTTL = !!f, this.noDeleteOnFetchRejection = !!E, this.allowStaleOnFetchRejection = !!b, this.allowStaleOnFetchAbort = !!z, this.ignoreFetchAbort = !!$, this.maxEntrySize !== 0) {
1593
+ if (this.#s !== 0 && !q(this.#s)) throw new TypeError("maxSize must be a positive integer if specified");
1594
+ if (!q(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
1595
+ this.#G();
1596
+ }
1597
+ if (this.allowStale = !!a, this.noDeleteOnStaleGet = !!y, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!h, this.ttlResolution = q(i) || i === 0 ? i : 1, this.ttlAutopurge = !!r, this.ttl = s || 0, this.ttl) {
1598
+ if (!q(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
1599
+ this.#M();
1600
+ }
1601
+ if (this.#t === 0 && this.ttl === 0 && this.#s === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
1602
+ if (!this.ttlAutopurge && !this.#t && !this.#s) {
1603
+ let $t = "LRU_CACHE_UNBOUNDED";
1604
+ ii($t) && (Oe.add($t), Fe("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", $t, Me));
1605
+ }
1606
+ }
1607
+ getRemainingTTL(t) {
1608
+ return this.#f.has(t) ? 1 / 0 : 0;
1609
+ }
1610
+ #M() {
1611
+ let t = new Tt(this.#t), e = new Tt(this.#t);
1612
+ this.#g = t, this.#T = e;
1613
+ let s = this.ttlAutopurge ? new Array(this.#t) : void 0;
1614
+ this.#y = s, this.#j = (o, h, a = this.#c.now()) => {
1615
+ if (e[o] = h !== 0 ? a : 0, t[o] = h, s?.[o] && (clearTimeout(s[o]), s[o] = void 0), h !== 0 && s) {
1616
+ let l = setTimeout(() => {
1617
+ this.#v(o) && this.#O(this.#a[o], "expire");
1618
+ }, h + 1);
1619
+ l.unref && l.unref(), s[o] = l;
1620
+ }
1621
+ }, this.#k = (o) => {
1622
+ e[o] = t[o] !== 0 ? this.#c.now() : 0;
1623
+ }, this.#N = (o, h) => {
1624
+ if (t[h]) {
1625
+ let a = t[h], l = e[h];
1626
+ if (!a || !l) return;
1627
+ o.ttl = a, o.start = l, o.now = i || r();
1628
+ let u = o.now - l;
1629
+ o.remainingTTL = a - u;
1630
+ }
1631
+ };
1632
+ let i = 0, r = () => {
1633
+ let o = this.#c.now();
1634
+ if (this.ttlResolution > 0) {
1635
+ i = o;
1636
+ let h = setTimeout(() => i = 0, this.ttlResolution);
1637
+ h.unref && h.unref();
1638
+ }
1639
+ return o;
1640
+ };
1641
+ this.getRemainingTTL = (o) => {
1642
+ let h = this.#f.get(o);
1643
+ if (h === void 0) return 0;
1644
+ let a = t[h], l = e[h];
1645
+ if (!a || !l) return 1 / 0;
1646
+ let u = (i || r()) - l;
1647
+ return a - u;
1648
+ }, this.#v = (o) => {
1649
+ let h = e[o], a = t[o];
1650
+ return !!a && !!h && (i || r()) - h > a;
1651
+ };
1652
+ }
1653
+ #k = () => {
1654
+ };
1655
+ #N = () => {
1656
+ };
1657
+ #j = () => {
1658
+ };
1659
+ #v = () => false;
1660
+ #G() {
1661
+ let t = new Tt(this.#t);
1662
+ this.#u = 0, this.#C = t, this.#P = (e) => {
1663
+ this.#u -= t[e], t[e] = 0;
1664
+ }, this.#I = (e, s, i, r) => {
1665
+ if (this.#l(s)) return 0;
1666
+ if (!q(i)) if (r) {
1667
+ if (typeof r != "function") throw new TypeError("sizeCalculation must be a function");
1668
+ if (i = r(s, e), !q(i)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
1669
+ } else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
1670
+ return i;
1671
+ }, this.#L = (e, s, i) => {
1672
+ if (t[e] = s, this.#s) {
1673
+ let r = this.#s - t[e];
1674
+ for (; this.#u > r; ) this.#B(true);
1675
+ }
1676
+ this.#u += t[e], i && (i.entrySize = s, i.totalCalculatedSize = this.#u);
1677
+ };
1678
+ }
1679
+ #P = (t) => {
1680
+ };
1681
+ #L = (t, e, s) => {
1682
+ };
1683
+ #I = (t, e, s, i) => {
1684
+ if (s || i) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
1685
+ return 0;
1686
+ };
1687
+ *#F({ allowStale: t = this.allowStale } = {}) {
1688
+ if (this.#h) for (let e = this.#p; !(!this.#z(e) || ((t || !this.#v(e)) && (yield e), e === this.#b)); ) e = this.#E[e];
1689
+ }
1690
+ *#D({ allowStale: t = this.allowStale } = {}) {
1691
+ if (this.#h) for (let e = this.#b; !(!this.#z(e) || ((t || !this.#v(e)) && (yield e), e === this.#p)); ) e = this.#d[e];
1692
+ }
1693
+ #z(t) {
1694
+ return t !== void 0 && this.#f.get(this.#a[t]) === t;
1695
+ }
1696
+ *entries() {
1697
+ for (let t of this.#F()) this.#i[t] !== void 0 && this.#a[t] !== void 0 && !this.#l(this.#i[t]) && (yield [this.#a[t], this.#i[t]]);
1698
+ }
1699
+ *rentries() {
1700
+ for (let t of this.#D()) this.#i[t] !== void 0 && this.#a[t] !== void 0 && !this.#l(this.#i[t]) && (yield [this.#a[t], this.#i[t]]);
1701
+ }
1702
+ *keys() {
1703
+ for (let t of this.#F()) {
1704
+ let e = this.#a[t];
1705
+ e !== void 0 && !this.#l(this.#i[t]) && (yield e);
1706
+ }
1707
+ }
1708
+ *rkeys() {
1709
+ for (let t of this.#D()) {
1710
+ let e = this.#a[t];
1711
+ e !== void 0 && !this.#l(this.#i[t]) && (yield e);
1712
+ }
1713
+ }
1714
+ *values() {
1715
+ for (let t of this.#F()) this.#i[t] !== void 0 && !this.#l(this.#i[t]) && (yield this.#i[t]);
1716
+ }
1717
+ *rvalues() {
1718
+ for (let t of this.#D()) this.#i[t] !== void 0 && !this.#l(this.#i[t]) && (yield this.#i[t]);
1719
+ }
1720
+ [Symbol.iterator]() {
1721
+ return this.entries();
1722
+ }
1723
+ [Symbol.toStringTag] = "LRUCache";
1724
+ find(t, e = {}) {
1725
+ for (let s of this.#F()) {
1726
+ let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
1727
+ if (r !== void 0 && t(r, this.#a[s], this)) return this.get(this.#a[s], e);
1728
+ }
1729
+ }
1730
+ forEach(t, e = this) {
1731
+ for (let s of this.#F()) {
1732
+ let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
1733
+ r !== void 0 && t.call(e, r, this.#a[s], this);
1734
+ }
1735
+ }
1736
+ rforEach(t, e = this) {
1737
+ for (let s of this.#D()) {
1738
+ let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
1739
+ r !== void 0 && t.call(e, r, this.#a[s], this);
1740
+ }
1741
+ }
1742
+ purgeStale() {
1743
+ let t = false;
1744
+ for (let e of this.#D({ allowStale: true })) this.#v(e) && (this.#O(this.#a[e], "expire"), t = true);
1745
+ return t;
1746
+ }
1747
+ info(t) {
1748
+ let e = this.#f.get(t);
1749
+ if (e === void 0) return;
1750
+ let s = this.#i[e], i = this.#l(s) ? s.__staleWhileFetching : s;
1751
+ if (i === void 0) return;
1752
+ let r = { value: i };
1753
+ if (this.#g && this.#T) {
1754
+ let o = this.#g[e], h = this.#T[e];
1755
+ if (o && h) {
1756
+ let a = o - (this.#c.now() - h);
1757
+ r.ttl = a, r.start = Date.now();
1758
+ }
1759
+ }
1760
+ return this.#C && (r.size = this.#C[e]), r;
1761
+ }
1762
+ dump() {
1763
+ let t = [];
1764
+ for (let e of this.#F({ allowStale: true })) {
1765
+ let s = this.#a[e], i = this.#i[e], r = this.#l(i) ? i.__staleWhileFetching : i;
1766
+ if (r === void 0 || s === void 0) continue;
1767
+ let o = { value: r };
1768
+ if (this.#g && this.#T) {
1769
+ o.ttl = this.#g[e];
1770
+ let h = this.#c.now() - this.#T[e];
1771
+ o.start = Math.floor(Date.now() - h);
1772
+ }
1773
+ this.#C && (o.size = this.#C[e]), t.unshift([s, o]);
1774
+ }
1775
+ return t;
1776
+ }
1777
+ load(t) {
1778
+ this.clear();
1779
+ for (let [e, s] of t) {
1780
+ if (s.start) {
1781
+ let i = Date.now() - s.start;
1782
+ s.start = this.#c.now() - i;
1783
+ }
1784
+ this.set(e, s.value, s);
1785
+ }
1786
+ }
1787
+ set(t, e, s = {}) {
1788
+ if (e === void 0) return this.delete(t), this;
1789
+ let { ttl: i = this.ttl, start: r, noDisposeOnSet: o = this.noDisposeOnSet, sizeCalculation: h = this.sizeCalculation, status: a } = s, { noUpdateTTL: l = this.noUpdateTTL } = s, u = this.#I(t, e, s.size || 0, h);
1790
+ if (this.maxEntrySize && u > this.maxEntrySize) return a && (a.set = "miss", a.maxEntrySizeExceeded = true), this.#O(t, "set"), this;
1791
+ let c = this.#h === 0 ? void 0 : this.#f.get(t);
1792
+ if (c === void 0) c = this.#h === 0 ? this.#p : this.#R.length !== 0 ? this.#R.pop() : this.#h === this.#t ? this.#B(false) : this.#h, this.#a[c] = t, this.#i[c] = e, this.#f.set(t, c), this.#d[this.#p] = c, this.#E[c] = this.#p, this.#p = c, this.#h++, this.#L(c, u, a), a && (a.set = "add"), l = false, this.#_ && this.#r?.(e, t, "add");
1793
+ else {
1794
+ this.#W(c);
1795
+ let d = this.#i[c];
1796
+ if (e !== d) {
1797
+ if (this.#A && this.#l(d)) {
1798
+ d.__abortController.abort(new Error("replaced"));
1799
+ let { __staleWhileFetching: f } = d;
1800
+ f !== void 0 && !o && (this.#x && this.#n?.(f, t, "set"), this.#e && this.#m?.push([f, t, "set"]));
1801
+ } else o || (this.#x && this.#n?.(d, t, "set"), this.#e && this.#m?.push([d, t, "set"]));
1802
+ if (this.#P(c), this.#L(c, u, a), this.#i[c] = e, a) {
1803
+ a.set = "replace";
1804
+ let f = d && this.#l(d) ? d.__staleWhileFetching : d;
1805
+ f !== void 0 && (a.oldValue = f);
1806
+ }
1807
+ } else a && (a.set = "update");
1808
+ this.#_ && this.onInsert?.(e, t, e === d ? "update" : "replace");
1809
+ }
1810
+ if (i !== 0 && !this.#g && this.#M(), this.#g && (l || this.#j(c, i, r), a && this.#N(a, c)), !o && this.#e && this.#m) {
1811
+ let d = this.#m, f;
1812
+ for (; f = d?.shift(); ) this.#o?.(...f);
1813
+ }
1814
+ return this;
1815
+ }
1816
+ pop() {
1817
+ try {
1818
+ for (; this.#h; ) {
1819
+ let t = this.#i[this.#b];
1820
+ if (this.#B(true), this.#l(t)) {
1821
+ if (t.__staleWhileFetching) return t.__staleWhileFetching;
1822
+ } else if (t !== void 0) return t;
1823
+ }
1824
+ } finally {
1825
+ if (this.#e && this.#m) {
1826
+ let t = this.#m, e;
1827
+ for (; e = t?.shift(); ) this.#o?.(...e);
1828
+ }
1829
+ }
1830
+ }
1831
+ #B(t) {
1832
+ let e = this.#b, s = this.#a[e], i = this.#i[e];
1833
+ return this.#A && this.#l(i) ? i.__abortController.abort(new Error("evicted")) : (this.#x || this.#e) && (this.#x && this.#n?.(i, s, "evict"), this.#e && this.#m?.push([i, s, "evict"])), this.#P(e), this.#y?.[e] && (clearTimeout(this.#y[e]), this.#y[e] = void 0), t && (this.#a[e] = void 0, this.#i[e] = void 0, this.#R.push(e)), this.#h === 1 ? (this.#b = this.#p = 0, this.#R.length = 0) : this.#b = this.#d[e], this.#f.delete(s), this.#h--, e;
1834
+ }
1835
+ has(t, e = {}) {
1836
+ let { updateAgeOnHas: s = this.updateAgeOnHas, status: i } = e, r = this.#f.get(t);
1837
+ if (r !== void 0) {
1838
+ let o = this.#i[r];
1839
+ if (this.#l(o) && o.__staleWhileFetching === void 0) return false;
1840
+ if (this.#v(r)) i && (i.has = "stale", this.#N(i, r));
1841
+ else return s && this.#k(r), i && (i.has = "hit", this.#N(i, r)), true;
1842
+ } else i && (i.has = "miss");
1843
+ return false;
1844
+ }
1845
+ peek(t, e = {}) {
1846
+ let { allowStale: s = this.allowStale } = e, i = this.#f.get(t);
1847
+ if (i === void 0 || !s && this.#v(i)) return;
1848
+ let r = this.#i[i];
1849
+ return this.#l(r) ? r.__staleWhileFetching : r;
1850
+ }
1851
+ #U(t, e, s, i) {
1852
+ let r = e === void 0 ? void 0 : this.#i[e];
1853
+ if (this.#l(r)) return r;
1854
+ let o = new At(), { signal: h } = s;
1855
+ h?.addEventListener("abort", () => o.abort(h.reason), { signal: o.signal });
1856
+ let a = { signal: o.signal, options: s, context: i }, l = (p, w = false) => {
1857
+ let { aborted: g } = o.signal, S = s.ignoreFetchAbort && p !== void 0, E = s.ignoreFetchAbort || !!(s.allowStaleOnFetchAbort && p !== void 0);
1858
+ if (s.status && (g && !w ? (s.status.fetchAborted = true, s.status.fetchError = o.signal.reason, S && (s.status.fetchAbortIgnored = true)) : s.status.fetchResolved = true), g && !S && !w) return c(o.signal.reason, E);
1859
+ let y = f, b = this.#i[e];
1860
+ return (b === f || S && w && b === void 0) && (p === void 0 ? y.__staleWhileFetching !== void 0 ? this.#i[e] = y.__staleWhileFetching : this.#O(t, "fetch") : (s.status && (s.status.fetchUpdated = true), this.set(t, p, a.options))), p;
1861
+ }, u = (p) => (s.status && (s.status.fetchRejected = true, s.status.fetchError = p), c(p, false)), c = (p, w) => {
1862
+ let { aborted: g } = o.signal, S = g && s.allowStaleOnFetchAbort, E = S || s.allowStaleOnFetchRejection, y = E || s.noDeleteOnFetchRejection, b = f;
1863
+ if (this.#i[e] === f && (!y || !w && b.__staleWhileFetching === void 0 ? this.#O(t, "fetch") : S || (this.#i[e] = b.__staleWhileFetching)), E) return s.status && b.__staleWhileFetching !== void 0 && (s.status.returnedStale = true), b.__staleWhileFetching;
1864
+ if (b.__returned === b) throw p;
1865
+ }, d = (p, w) => {
1866
+ let g = this.#S?.(t, r, a);
1867
+ g && g instanceof Promise && g.then((S) => p(S === void 0 ? void 0 : S), w), o.signal.addEventListener("abort", () => {
1868
+ (!s.ignoreFetchAbort || s.allowStaleOnFetchAbort) && (p(void 0), s.allowStaleOnFetchAbort && (p = (S) => l(S, true)));
1869
+ });
1870
+ };
1871
+ s.status && (s.status.fetchDispatched = true);
1872
+ let f = new Promise(d).then(l, u), m = Object.assign(f, { __abortController: o, __staleWhileFetching: r, __returned: void 0 });
1873
+ return e === void 0 ? (this.set(t, m, { ...a.options, status: void 0 }), e = this.#f.get(t)) : this.#i[e] = m, m;
1874
+ }
1875
+ #l(t) {
1876
+ if (!this.#A) return false;
1877
+ let e = t;
1878
+ return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof At;
1879
+ }
1880
+ async fetch(t, e = {}) {
1881
+ let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: r = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: h = this.noDisposeOnSet, size: a = 0, sizeCalculation: l = this.sizeCalculation, noUpdateTTL: u = this.noUpdateTTL, noDeleteOnFetchRejection: c = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: d = this.allowStaleOnFetchRejection, ignoreFetchAbort: f = this.ignoreFetchAbort, allowStaleOnFetchAbort: m = this.allowStaleOnFetchAbort, context: p, forceRefresh: w = false, status: g, signal: S } = e;
1882
+ if (!this.#A) return g && (g.fetch = "get"), this.get(t, { allowStale: s, updateAgeOnGet: i, noDeleteOnStaleGet: r, status: g });
1883
+ let E = { allowStale: s, updateAgeOnGet: i, noDeleteOnStaleGet: r, ttl: o, noDisposeOnSet: h, size: a, sizeCalculation: l, noUpdateTTL: u, noDeleteOnFetchRejection: c, allowStaleOnFetchRejection: d, allowStaleOnFetchAbort: m, ignoreFetchAbort: f, status: g, signal: S }, y = this.#f.get(t);
1884
+ if (y === void 0) {
1885
+ g && (g.fetch = "miss");
1886
+ let b = this.#U(t, y, E, p);
1887
+ return b.__returned = b;
1888
+ } else {
1889
+ let b = this.#i[y];
1890
+ if (this.#l(b)) {
1891
+ let Z = s && b.__staleWhileFetching !== void 0;
1892
+ return g && (g.fetch = "inflight", Z && (g.returnedStale = true)), Z ? b.__staleWhileFetching : b.__returned = b;
1893
+ }
1894
+ let z = this.#v(y);
1895
+ if (!w && !z) return g && (g.fetch = "hit"), this.#W(y), i && this.#k(y), g && this.#N(g, y), b;
1896
+ let $ = this.#U(t, y, E, p), J = $.__staleWhileFetching !== void 0 && s;
1897
+ return g && (g.fetch = z ? "stale" : "refresh", J && z && (g.returnedStale = true)), J ? $.__staleWhileFetching : $.__returned = $;
1898
+ }
1899
+ }
1900
+ async forceFetch(t, e = {}) {
1901
+ let s = await this.fetch(t, e);
1902
+ if (s === void 0) throw new Error("fetch() returned undefined");
1903
+ return s;
1904
+ }
1905
+ memo(t, e = {}) {
1906
+ let s = this.#w;
1907
+ if (!s) throw new Error("no memoMethod provided to constructor");
1908
+ let { context: i, forceRefresh: r, ...o } = e, h = this.get(t, o);
1909
+ if (!r && h !== void 0) return h;
1910
+ let a = s(t, h, { options: o, context: i });
1911
+ return this.set(t, a, o), a;
1912
+ }
1913
+ get(t, e = {}) {
1914
+ let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: r = this.noDeleteOnStaleGet, status: o } = e, h = this.#f.get(t);
1915
+ if (h !== void 0) {
1916
+ let a = this.#i[h], l = this.#l(a);
1917
+ return o && this.#N(o, h), this.#v(h) ? (o && (o.get = "stale"), l ? (o && s && a.__staleWhileFetching !== void 0 && (o.returnedStale = true), s ? a.__staleWhileFetching : void 0) : (r || this.#O(t, "expire"), o && s && (o.returnedStale = true), s ? a : void 0)) : (o && (o.get = "hit"), l ? a.__staleWhileFetching : (this.#W(h), i && this.#k(h), a));
1918
+ } else o && (o.get = "miss");
1919
+ }
1920
+ #$(t, e) {
1921
+ this.#E[e] = t, this.#d[t] = e;
1922
+ }
1923
+ #W(t) {
1924
+ t !== this.#p && (t === this.#b ? this.#b = this.#d[t] : this.#$(this.#E[t], this.#d[t]), this.#$(this.#p, t), this.#p = t);
1925
+ }
1926
+ delete(t) {
1927
+ return this.#O(t, "delete");
1928
+ }
1929
+ #O(t, e) {
1930
+ let s = false;
1931
+ if (this.#h !== 0) {
1932
+ let i = this.#f.get(t);
1933
+ if (i !== void 0) if (this.#y?.[i] && (clearTimeout(this.#y?.[i]), this.#y[i] = void 0), s = true, this.#h === 1) this.#H(e);
1934
+ else {
1935
+ this.#P(i);
1936
+ let r = this.#i[i];
1937
+ if (this.#l(r) ? r.__abortController.abort(new Error("deleted")) : (this.#x || this.#e) && (this.#x && this.#n?.(r, t, e), this.#e && this.#m?.push([r, t, e])), this.#f.delete(t), this.#a[i] = void 0, this.#i[i] = void 0, i === this.#p) this.#p = this.#E[i];
1938
+ else if (i === this.#b) this.#b = this.#d[i];
1939
+ else {
1940
+ let o = this.#E[i];
1941
+ this.#d[o] = this.#d[i];
1942
+ let h = this.#d[i];
1943
+ this.#E[h] = this.#E[i];
1944
+ }
1945
+ this.#h--, this.#R.push(i);
1946
+ }
1947
+ }
1948
+ if (this.#e && this.#m?.length) {
1949
+ let i = this.#m, r;
1950
+ for (; r = i?.shift(); ) this.#o?.(...r);
1951
+ }
1952
+ return s;
1953
+ }
1954
+ clear() {
1955
+ return this.#H("delete");
1956
+ }
1957
+ #H(t) {
1958
+ for (let e of this.#D({ allowStale: true })) {
1959
+ let s = this.#i[e];
1960
+ if (this.#l(s)) s.__abortController.abort(new Error("deleted"));
1961
+ else {
1962
+ let i = this.#a[e];
1963
+ this.#x && this.#n?.(s, i, t), this.#e && this.#m?.push([s, i, t]);
1964
+ }
1965
+ }
1966
+ if (this.#f.clear(), this.#i.fill(void 0), this.#a.fill(void 0), this.#g && this.#T) {
1967
+ this.#g.fill(0), this.#T.fill(0);
1968
+ for (let e of this.#y ?? []) e !== void 0 && clearTimeout(e);
1969
+ this.#y?.fill(void 0);
1970
+ }
1971
+ if (this.#C && this.#C.fill(0), this.#b = 0, this.#p = 0, this.#R.length = 0, this.#u = 0, this.#h = 0, this.#e && this.#m) {
1972
+ let e = this.#m, s;
1973
+ for (; s = e?.shift(); ) this.#o?.(...s);
1974
+ }
1975
+ }
1976
+ };
1977
+ var Ne = typeof process == "object" && process ? process : { stdout: null, stderr: null };
1978
+ var oi = (n7) => !!n7 && typeof n7 == "object" && (n7 instanceof V || n7 instanceof Pe || hi(n7) || ai(n7));
1979
+ var hi = (n7) => !!n7 && typeof n7 == "object" && n7 instanceof EventEmitter && typeof n7.pipe == "function" && n7.pipe !== Pe.Writable.prototype.pipe;
1980
+ var ai = (n7) => !!n7 && typeof n7 == "object" && n7 instanceof EventEmitter && typeof n7.write == "function" && typeof n7.end == "function";
1981
+ var G = /* @__PURE__ */ Symbol("EOF");
1982
+ var H = /* @__PURE__ */ Symbol("maybeEmitEnd");
1983
+ var K = /* @__PURE__ */ Symbol("emittedEnd");
1984
+ var kt = /* @__PURE__ */ Symbol("emittingEnd");
1985
+ var ut = /* @__PURE__ */ Symbol("emittedError");
1986
+ var Rt = /* @__PURE__ */ Symbol("closed");
1987
+ var _e = /* @__PURE__ */ Symbol("read");
1988
+ var Ot = /* @__PURE__ */ Symbol("flush");
1989
+ var Le = /* @__PURE__ */ Symbol("flushChunk");
1990
+ var P = /* @__PURE__ */ Symbol("encoding");
1991
+ var et = /* @__PURE__ */ Symbol("decoder");
1992
+ var v = /* @__PURE__ */ Symbol("flowing");
1993
+ var dt = /* @__PURE__ */ Symbol("paused");
1994
+ var st = /* @__PURE__ */ Symbol("resume");
1995
+ var C = /* @__PURE__ */ Symbol("buffer");
1996
+ var F = /* @__PURE__ */ Symbol("pipes");
1997
+ var T = /* @__PURE__ */ Symbol("bufferLength");
1998
+ var Yt = /* @__PURE__ */ Symbol("bufferPush");
1999
+ var Ft = /* @__PURE__ */ Symbol("bufferShift");
2000
+ var k = /* @__PURE__ */ Symbol("objectMode");
2001
+ var x = /* @__PURE__ */ Symbol("destroyed");
2002
+ var Xt = /* @__PURE__ */ Symbol("error");
2003
+ var Jt = /* @__PURE__ */ Symbol("emitData");
2004
+ var We = /* @__PURE__ */ Symbol("emitEnd");
2005
+ var Zt = /* @__PURE__ */ Symbol("emitEnd2");
2006
+ var B = /* @__PURE__ */ Symbol("async");
2007
+ var Qt = /* @__PURE__ */ Symbol("abort");
2008
+ var Dt = /* @__PURE__ */ Symbol("aborted");
2009
+ var pt = /* @__PURE__ */ Symbol("signal");
2010
+ var Y = /* @__PURE__ */ Symbol("dataListeners");
2011
+ var M = /* @__PURE__ */ Symbol("discarded");
2012
+ var mt = (n7) => Promise.resolve().then(n7);
2013
+ var li = (n7) => n7();
2014
+ var ci = (n7) => n7 === "end" || n7 === "finish" || n7 === "prefinish";
2015
+ var fi = (n7) => n7 instanceof ArrayBuffer || !!n7 && typeof n7 == "object" && n7.constructor && n7.constructor.name === "ArrayBuffer" && n7.byteLength >= 0;
2016
+ var ui = (n7) => !Buffer.isBuffer(n7) && ArrayBuffer.isView(n7);
2017
+ var Mt = class {
2018
+ src;
2019
+ dest;
2020
+ opts;
2021
+ ondrain;
2022
+ constructor(t, e, s) {
2023
+ this.src = t, this.dest = e, this.opts = s, this.ondrain = () => t[st](), this.dest.on("drain", this.ondrain);
2024
+ }
2025
+ unpipe() {
2026
+ this.dest.removeListener("drain", this.ondrain);
2027
+ }
2028
+ proxyErrors(t) {
2029
+ }
2030
+ end() {
2031
+ this.unpipe(), this.opts.end && this.dest.end();
2032
+ }
2033
+ };
2034
+ var te = class extends Mt {
2035
+ unpipe() {
2036
+ this.src.removeListener("error", this.proxyErrors), super.unpipe();
2037
+ }
2038
+ constructor(t, e, s) {
2039
+ super(t, e, s), this.proxyErrors = (i) => this.dest.emit("error", i), t.on("error", this.proxyErrors);
2040
+ }
2041
+ };
2042
+ var di = (n7) => !!n7.objectMode;
2043
+ var pi = (n7) => !n7.objectMode && !!n7.encoding && n7.encoding !== "buffer";
2044
+ var V = class extends EventEmitter {
2045
+ [v] = false;
2046
+ [dt] = false;
2047
+ [F] = [];
2048
+ [C] = [];
2049
+ [k];
2050
+ [P];
2051
+ [B];
2052
+ [et];
2053
+ [G] = false;
2054
+ [K] = false;
2055
+ [kt] = false;
2056
+ [Rt] = false;
2057
+ [ut] = null;
2058
+ [T] = 0;
2059
+ [x] = false;
2060
+ [pt];
2061
+ [Dt] = false;
2062
+ [Y] = 0;
2063
+ [M] = false;
2064
+ writable = true;
2065
+ readable = true;
2066
+ constructor(...t) {
2067
+ let e = t[0] || {};
2068
+ if (super(), e.objectMode && typeof e.encoding == "string") throw new TypeError("Encoding and objectMode may not be used together");
2069
+ di(e) ? (this[k] = true, this[P] = null) : pi(e) ? (this[P] = e.encoding, this[k] = false) : (this[k] = false, this[P] = null), this[B] = !!e.async, this[et] = this[P] ? new StringDecoder(this[P]) : null, e && e.debugExposeBuffer === true && Object.defineProperty(this, "buffer", { get: () => this[C] }), e && e.debugExposePipes === true && Object.defineProperty(this, "pipes", { get: () => this[F] });
2070
+ let { signal: s } = e;
2071
+ s && (this[pt] = s, s.aborted ? this[Qt]() : s.addEventListener("abort", () => this[Qt]()));
2072
+ }
2073
+ get bufferLength() {
2074
+ return this[T];
2075
+ }
2076
+ get encoding() {
2077
+ return this[P];
2078
+ }
2079
+ set encoding(t) {
2080
+ throw new Error("Encoding must be set at instantiation time");
2081
+ }
2082
+ setEncoding(t) {
2083
+ throw new Error("Encoding must be set at instantiation time");
2084
+ }
2085
+ get objectMode() {
2086
+ return this[k];
2087
+ }
2088
+ set objectMode(t) {
2089
+ throw new Error("objectMode must be set at instantiation time");
2090
+ }
2091
+ get async() {
2092
+ return this[B];
2093
+ }
2094
+ set async(t) {
2095
+ this[B] = this[B] || !!t;
2096
+ }
2097
+ [Qt]() {
2098
+ this[Dt] = true, this.emit("abort", this[pt]?.reason), this.destroy(this[pt]?.reason);
2099
+ }
2100
+ get aborted() {
2101
+ return this[Dt];
2102
+ }
2103
+ set aborted(t) {
2104
+ }
2105
+ write(t, e, s) {
2106
+ if (this[Dt]) return false;
2107
+ if (this[G]) throw new Error("write after end");
2108
+ if (this[x]) return this.emit("error", Object.assign(new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), true;
2109
+ typeof e == "function" && (s = e, e = "utf8"), e || (e = "utf8");
2110
+ let i = this[B] ? mt : li;
2111
+ if (!this[k] && !Buffer.isBuffer(t)) {
2112
+ if (ui(t)) t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
2113
+ else if (fi(t)) t = Buffer.from(t);
2114
+ else if (typeof t != "string") throw new Error("Non-contiguous data written to non-objectMode stream");
2115
+ }
2116
+ return this[k] ? (this[v] && this[T] !== 0 && this[Ot](true), this[v] ? this.emit("data", t) : this[Yt](t), this[T] !== 0 && this.emit("readable"), s && i(s), this[v]) : t.length ? (typeof t == "string" && !(e === this[P] && !this[et]?.lastNeed) && (t = Buffer.from(t, e)), Buffer.isBuffer(t) && this[P] && (t = this[et].write(t)), this[v] && this[T] !== 0 && this[Ot](true), this[v] ? this.emit("data", t) : this[Yt](t), this[T] !== 0 && this.emit("readable"), s && i(s), this[v]) : (this[T] !== 0 && this.emit("readable"), s && i(s), this[v]);
2117
+ }
2118
+ read(t) {
2119
+ if (this[x]) return null;
2120
+ if (this[M] = false, this[T] === 0 || t === 0 || t && t > this[T]) return this[H](), null;
2121
+ this[k] && (t = null), this[C].length > 1 && !this[k] && (this[C] = [this[P] ? this[C].join("") : Buffer.concat(this[C], this[T])]);
2122
+ let e = this[_e](t || null, this[C][0]);
2123
+ return this[H](), e;
2124
+ }
2125
+ [_e](t, e) {
2126
+ if (this[k]) this[Ft]();
2127
+ else {
2128
+ let s = e;
2129
+ t === s.length || t === null ? this[Ft]() : typeof s == "string" ? (this[C][0] = s.slice(t), e = s.slice(0, t), this[T] -= t) : (this[C][0] = s.subarray(t), e = s.subarray(0, t), this[T] -= t);
2130
+ }
2131
+ return this.emit("data", e), !this[C].length && !this[G] && this.emit("drain"), e;
2132
+ }
2133
+ end(t, e, s) {
2134
+ return typeof t == "function" && (s = t, t = void 0), typeof e == "function" && (s = e, e = "utf8"), t !== void 0 && this.write(t, e), s && this.once("end", s), this[G] = true, this.writable = false, (this[v] || !this[dt]) && this[H](), this;
2135
+ }
2136
+ [st]() {
2137
+ this[x] || (!this[Y] && !this[F].length && (this[M] = true), this[dt] = false, this[v] = true, this.emit("resume"), this[C].length ? this[Ot]() : this[G] ? this[H]() : this.emit("drain"));
2138
+ }
2139
+ resume() {
2140
+ return this[st]();
2141
+ }
2142
+ pause() {
2143
+ this[v] = false, this[dt] = true, this[M] = false;
2144
+ }
2145
+ get destroyed() {
2146
+ return this[x];
2147
+ }
2148
+ get flowing() {
2149
+ return this[v];
2150
+ }
2151
+ get paused() {
2152
+ return this[dt];
2153
+ }
2154
+ [Yt](t) {
2155
+ this[k] ? this[T] += 1 : this[T] += t.length, this[C].push(t);
2156
+ }
2157
+ [Ft]() {
2158
+ return this[k] ? this[T] -= 1 : this[T] -= this[C][0].length, this[C].shift();
2159
+ }
2160
+ [Ot](t = false) {
2161
+ do
2162
+ ;
2163
+ while (this[Le](this[Ft]()) && this[C].length);
2164
+ !t && !this[C].length && !this[G] && this.emit("drain");
2165
+ }
2166
+ [Le](t) {
2167
+ return this.emit("data", t), this[v];
2168
+ }
2169
+ pipe(t, e) {
2170
+ if (this[x]) return t;
2171
+ this[M] = false;
2172
+ let s = this[K];
2173
+ return e = e || {}, t === Ne.stdout || t === Ne.stderr ? e.end = false : e.end = e.end !== false, e.proxyErrors = !!e.proxyErrors, s ? e.end && t.end() : (this[F].push(e.proxyErrors ? new te(this, t, e) : new Mt(this, t, e)), this[B] ? mt(() => this[st]()) : this[st]()), t;
2174
+ }
2175
+ unpipe(t) {
2176
+ let e = this[F].find((s) => s.dest === t);
2177
+ e && (this[F].length === 1 ? (this[v] && this[Y] === 0 && (this[v] = false), this[F] = []) : this[F].splice(this[F].indexOf(e), 1), e.unpipe());
2178
+ }
2179
+ addListener(t, e) {
2180
+ return this.on(t, e);
2181
+ }
2182
+ on(t, e) {
2183
+ let s = super.on(t, e);
2184
+ if (t === "data") this[M] = false, this[Y]++, !this[F].length && !this[v] && this[st]();
2185
+ else if (t === "readable" && this[T] !== 0) super.emit("readable");
2186
+ else if (ci(t) && this[K]) super.emit(t), this.removeAllListeners(t);
2187
+ else if (t === "error" && this[ut]) {
2188
+ let i = e;
2189
+ this[B] ? mt(() => i.call(this, this[ut])) : i.call(this, this[ut]);
2190
+ }
2191
+ return s;
2192
+ }
2193
+ removeListener(t, e) {
2194
+ return this.off(t, e);
2195
+ }
2196
+ off(t, e) {
2197
+ let s = super.off(t, e);
2198
+ return t === "data" && (this[Y] = this.listeners("data").length, this[Y] === 0 && !this[M] && !this[F].length && (this[v] = false)), s;
2199
+ }
2200
+ removeAllListeners(t) {
2201
+ let e = super.removeAllListeners(t);
2202
+ return (t === "data" || t === void 0) && (this[Y] = 0, !this[M] && !this[F].length && (this[v] = false)), e;
2203
+ }
2204
+ get emittedEnd() {
2205
+ return this[K];
2206
+ }
2207
+ [H]() {
2208
+ !this[kt] && !this[K] && !this[x] && this[C].length === 0 && this[G] && (this[kt] = true, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[Rt] && this.emit("close"), this[kt] = false);
2209
+ }
2210
+ emit(t, ...e) {
2211
+ let s = e[0];
2212
+ if (t !== "error" && t !== "close" && t !== x && this[x]) return false;
2213
+ if (t === "data") return !this[k] && !s ? false : this[B] ? (mt(() => this[Jt](s)), true) : this[Jt](s);
2214
+ if (t === "end") return this[We]();
2215
+ if (t === "close") {
2216
+ if (this[Rt] = true, !this[K] && !this[x]) return false;
2217
+ let r = super.emit("close");
2218
+ return this.removeAllListeners("close"), r;
2219
+ } else if (t === "error") {
2220
+ this[ut] = s, super.emit(Xt, s);
2221
+ let r = !this[pt] || this.listeners("error").length ? super.emit("error", s) : false;
2222
+ return this[H](), r;
2223
+ } else if (t === "resume") {
2224
+ let r = super.emit("resume");
2225
+ return this[H](), r;
2226
+ } else if (t === "finish" || t === "prefinish") {
2227
+ let r = super.emit(t);
2228
+ return this.removeAllListeners(t), r;
2229
+ }
2230
+ let i = super.emit(t, ...e);
2231
+ return this[H](), i;
2232
+ }
2233
+ [Jt](t) {
2234
+ for (let s of this[F]) s.dest.write(t) === false && this.pause();
2235
+ let e = this[M] ? false : super.emit("data", t);
2236
+ return this[H](), e;
2237
+ }
2238
+ [We]() {
2239
+ return this[K] ? false : (this[K] = true, this.readable = false, this[B] ? (mt(() => this[Zt]()), true) : this[Zt]());
2240
+ }
2241
+ [Zt]() {
2242
+ if (this[et]) {
2243
+ let e = this[et].end();
2244
+ if (e) {
2245
+ for (let s of this[F]) s.dest.write(e);
2246
+ this[M] || super.emit("data", e);
2247
+ }
2248
+ }
2249
+ for (let e of this[F]) e.end();
2250
+ let t = super.emit("end");
2251
+ return this.removeAllListeners("end"), t;
2252
+ }
2253
+ async collect() {
2254
+ let t = Object.assign([], { dataLength: 0 });
2255
+ this[k] || (t.dataLength = 0);
2256
+ let e = this.promise();
2257
+ return this.on("data", (s) => {
2258
+ t.push(s), this[k] || (t.dataLength += s.length);
2259
+ }), await e, t;
2260
+ }
2261
+ async concat() {
2262
+ if (this[k]) throw new Error("cannot concat in objectMode");
2263
+ let t = await this.collect();
2264
+ return this[P] ? t.join("") : Buffer.concat(t, t.dataLength);
2265
+ }
2266
+ async promise() {
2267
+ return new Promise((t, e) => {
2268
+ this.on(x, () => e(new Error("stream destroyed"))), this.on("error", (s) => e(s)), this.on("end", () => t());
2269
+ });
2270
+ }
2271
+ [Symbol.asyncIterator]() {
2272
+ this[M] = false;
2273
+ let t = false, e = async () => (this.pause(), t = true, { value: void 0, done: true });
2274
+ return { next: () => {
2275
+ if (t) return e();
2276
+ let i = this.read();
2277
+ if (i !== null) return Promise.resolve({ done: false, value: i });
2278
+ if (this[G]) return e();
2279
+ let r, o, h = (c) => {
2280
+ this.off("data", a), this.off("end", l), this.off(x, u), e(), o(c);
2281
+ }, a = (c) => {
2282
+ this.off("error", h), this.off("end", l), this.off(x, u), this.pause(), r({ value: c, done: !!this[G] });
2283
+ }, l = () => {
2284
+ this.off("error", h), this.off("data", a), this.off(x, u), e(), r({ done: true, value: void 0 });
2285
+ }, u = () => h(new Error("stream destroyed"));
2286
+ return new Promise((c, d) => {
2287
+ o = d, r = c, this.once(x, u), this.once("error", h), this.once("end", l), this.once("data", a);
2288
+ });
2289
+ }, throw: e, return: e, [Symbol.asyncIterator]() {
2290
+ return this;
2291
+ }, [Symbol.asyncDispose]: async () => {
2292
+ } };
2293
+ }
2294
+ [Symbol.iterator]() {
2295
+ this[M] = false;
2296
+ let t = false, e = () => (this.pause(), this.off(Xt, e), this.off(x, e), this.off("end", e), t = true, { done: true, value: void 0 }), s = () => {
2297
+ if (t) return e();
2298
+ let i = this.read();
2299
+ return i === null ? e() : { done: false, value: i };
2300
+ };
2301
+ return this.once("end", e), this.once(Xt, e), this.once(x, e), { next: s, throw: e, return: e, [Symbol.iterator]() {
2302
+ return this;
2303
+ }, [Symbol.dispose]: () => {
2304
+ } };
2305
+ }
2306
+ destroy(t) {
2307
+ if (this[x]) return t ? this.emit("error", t) : this.emit(x), this;
2308
+ this[x] = true, this[M] = true, this[C].length = 0, this[T] = 0;
2309
+ let e = this;
2310
+ return typeof e.close == "function" && !this[Rt] && e.close(), t ? this.emit("error", t) : this.emit(x), this;
2311
+ }
2312
+ static get isStream() {
2313
+ return oi;
2314
+ }
2315
+ };
2316
+ var vi = realpathSync.native;
2317
+ var wt = { lstatSync: lstatSync, readdir: readdir$1, readdirSync: readdirSync, readlinkSync: readlinkSync, realpathSync: vi, promises: { lstat: lstat, readdir: readdir, readlink: readlink, realpath: realpath } };
2318
+ var Ue = (n7) => !n7 || n7 === wt || n7 === xi ? wt : { ...wt, ...n7, promises: { ...wt.promises, ...n7.promises || {} } };
2319
+ var $e = /^\\\\\?\\([a-z]:)\\?$/i;
2320
+ var Ri = (n7) => n7.replace(/\//g, "\\").replace($e, "$1\\");
2321
+ var Oi = /[\\\/]/;
2322
+ var L = 0;
2323
+ var Ge = 1;
2324
+ var He = 2;
2325
+ var U = 4;
2326
+ var qe = 6;
2327
+ var Ke = 8;
2328
+ var X = 10;
2329
+ var Ve = 12;
2330
+ var _ = 15;
2331
+ var gt = ~_;
2332
+ var se = 16;
2333
+ var je = 32;
2334
+ var yt = 64;
2335
+ var j = 128;
2336
+ var Nt = 256;
2337
+ var Lt = 512;
2338
+ var Ie = yt | j | Lt;
2339
+ var Fi = 1023;
2340
+ var ie = (n7) => n7.isFile() ? Ke : n7.isDirectory() ? U : n7.isSymbolicLink() ? X : n7.isCharacterDevice() ? He : n7.isBlockDevice() ? qe : n7.isSocket() ? Ve : n7.isFIFO() ? Ge : L;
2341
+ var ze = new ft({ max: 2 ** 12 });
2342
+ var bt = (n7) => {
2343
+ let t = ze.get(n7);
2344
+ if (t) return t;
2345
+ let e = n7.normalize("NFKD");
2346
+ return ze.set(n7, e), e;
2347
+ };
2348
+ var Be = new ft({ max: 2 ** 12 });
2349
+ var _t = (n7) => {
2350
+ let t = Be.get(n7);
2351
+ if (t) return t;
2352
+ let e = bt(n7.toLowerCase());
2353
+ return Be.set(n7, e), e;
2354
+ };
2355
+ var Wt = class extends ft {
2356
+ constructor() {
2357
+ super({ max: 256 });
2358
+ }
2359
+ };
2360
+ var ne = class extends ft {
2361
+ constructor(t = 16 * 1024) {
2362
+ super({ maxSize: t, sizeCalculation: (e) => e.length + 1 });
2363
+ }
2364
+ };
2365
+ var Ye = /* @__PURE__ */ Symbol("PathScurry setAsCwd");
2366
+ var R = class {
2367
+ name;
2368
+ root;
2369
+ roots;
2370
+ parent;
2371
+ nocase;
2372
+ isCWD = false;
2373
+ #t;
2374
+ #s;
2375
+ get dev() {
2376
+ return this.#s;
2377
+ }
2378
+ #n;
2379
+ get mode() {
2380
+ return this.#n;
2381
+ }
2382
+ #r;
2383
+ get nlink() {
2384
+ return this.#r;
2385
+ }
2386
+ #o;
2387
+ get uid() {
2388
+ return this.#o;
2389
+ }
2390
+ #S;
2391
+ get gid() {
2392
+ return this.#S;
2393
+ }
2394
+ #w;
2395
+ get rdev() {
2396
+ return this.#w;
2397
+ }
2398
+ #c;
2399
+ get blksize() {
2400
+ return this.#c;
2401
+ }
2402
+ #h;
2403
+ get ino() {
2404
+ return this.#h;
2405
+ }
2406
+ #u;
2407
+ get size() {
2408
+ return this.#u;
2409
+ }
2410
+ #f;
2411
+ get blocks() {
2412
+ return this.#f;
2413
+ }
2414
+ #a;
2415
+ get atimeMs() {
2416
+ return this.#a;
2417
+ }
2418
+ #i;
2419
+ get mtimeMs() {
2420
+ return this.#i;
2421
+ }
2422
+ #d;
2423
+ get ctimeMs() {
2424
+ return this.#d;
2425
+ }
2426
+ #E;
2427
+ get birthtimeMs() {
2428
+ return this.#E;
2429
+ }
2430
+ #b;
2431
+ get atime() {
2432
+ return this.#b;
2433
+ }
2434
+ #p;
2435
+ get mtime() {
2436
+ return this.#p;
2437
+ }
2438
+ #R;
2439
+ get ctime() {
2440
+ return this.#R;
2441
+ }
2442
+ #m;
2443
+ get birthtime() {
2444
+ return this.#m;
2445
+ }
2446
+ #C;
2447
+ #T;
2448
+ #g;
2449
+ #y;
2450
+ #x;
2451
+ #A;
2452
+ #e;
2453
+ #_;
2454
+ #M;
2455
+ #k;
2456
+ get parentPath() {
2457
+ return (this.parent || this).fullpath();
2458
+ }
2459
+ get path() {
2460
+ return this.parentPath;
2461
+ }
2462
+ constructor(t, e = L, s, i, r, o, h) {
2463
+ this.name = t, this.#C = r ? _t(t) : bt(t), this.#e = e & Fi, this.nocase = r, this.roots = i, this.root = s || this, this.#_ = o, this.#g = h.fullpath, this.#x = h.relative, this.#A = h.relativePosix, this.parent = h.parent, this.parent ? this.#t = this.parent.#t : this.#t = Ue(h.fs);
2464
+ }
2465
+ depth() {
2466
+ return this.#T !== void 0 ? this.#T : this.parent ? this.#T = this.parent.depth() + 1 : this.#T = 0;
2467
+ }
2468
+ childrenCache() {
2469
+ return this.#_;
2470
+ }
2471
+ resolve(t) {
2472
+ if (!t) return this;
2473
+ let e = this.getRootString(t), i = t.substring(e.length).split(this.splitSep);
2474
+ return e ? this.getRoot(e).#N(i) : this.#N(i);
2475
+ }
2476
+ #N(t) {
2477
+ let e = this;
2478
+ for (let s of t) e = e.child(s);
2479
+ return e;
2480
+ }
2481
+ children() {
2482
+ let t = this.#_.get(this);
2483
+ if (t) return t;
2484
+ let e = Object.assign([], { provisional: 0 });
2485
+ return this.#_.set(this, e), this.#e &= ~se, e;
2486
+ }
2487
+ child(t, e) {
2488
+ if (t === "" || t === ".") return this;
2489
+ if (t === "..") return this.parent || this;
2490
+ let s = this.children(), i = this.nocase ? _t(t) : bt(t);
2491
+ for (let a of s) if (a.#C === i) return a;
2492
+ let r = this.parent ? this.sep : "", o = this.#g ? this.#g + r + t : void 0, h = this.newChild(t, L, { ...e, parent: this, fullpath: o });
2493
+ return this.canReaddir() || (h.#e |= j), s.push(h), h;
2494
+ }
2495
+ relative() {
2496
+ if (this.isCWD) return "";
2497
+ if (this.#x !== void 0) return this.#x;
2498
+ let t = this.name, e = this.parent;
2499
+ if (!e) return this.#x = this.name;
2500
+ let s = e.relative();
2501
+ return s + (!s || !e.parent ? "" : this.sep) + t;
2502
+ }
2503
+ relativePosix() {
2504
+ if (this.sep === "/") return this.relative();
2505
+ if (this.isCWD) return "";
2506
+ if (this.#A !== void 0) return this.#A;
2507
+ let t = this.name, e = this.parent;
2508
+ if (!e) return this.#A = this.fullpathPosix();
2509
+ let s = e.relativePosix();
2510
+ return s + (!s || !e.parent ? "" : "/") + t;
2511
+ }
2512
+ fullpath() {
2513
+ if (this.#g !== void 0) return this.#g;
2514
+ let t = this.name, e = this.parent;
2515
+ if (!e) return this.#g = this.name;
2516
+ let i = e.fullpath() + (e.parent ? this.sep : "") + t;
2517
+ return this.#g = i;
2518
+ }
2519
+ fullpathPosix() {
2520
+ if (this.#y !== void 0) return this.#y;
2521
+ if (this.sep === "/") return this.#y = this.fullpath();
2522
+ if (!this.parent) {
2523
+ let i = this.fullpath().replace(/\\/g, "/");
2524
+ return /^[a-z]:\//i.test(i) ? this.#y = `//?/${i}` : this.#y = i;
2525
+ }
2526
+ let t = this.parent, e = t.fullpathPosix(), s = e + (!e || !t.parent ? "" : "/") + this.name;
2527
+ return this.#y = s;
2528
+ }
2529
+ isUnknown() {
2530
+ return (this.#e & _) === L;
2531
+ }
2532
+ isType(t) {
2533
+ return this[`is${t}`]();
2534
+ }
2535
+ getType() {
2536
+ return this.isUnknown() ? "Unknown" : this.isDirectory() ? "Directory" : this.isFile() ? "File" : this.isSymbolicLink() ? "SymbolicLink" : this.isFIFO() ? "FIFO" : this.isCharacterDevice() ? "CharacterDevice" : this.isBlockDevice() ? "BlockDevice" : this.isSocket() ? "Socket" : "Unknown";
2537
+ }
2538
+ isFile() {
2539
+ return (this.#e & _) === Ke;
2540
+ }
2541
+ isDirectory() {
2542
+ return (this.#e & _) === U;
2543
+ }
2544
+ isCharacterDevice() {
2545
+ return (this.#e & _) === He;
2546
+ }
2547
+ isBlockDevice() {
2548
+ return (this.#e & _) === qe;
2549
+ }
2550
+ isFIFO() {
2551
+ return (this.#e & _) === Ge;
2552
+ }
2553
+ isSocket() {
2554
+ return (this.#e & _) === Ve;
2555
+ }
2556
+ isSymbolicLink() {
2557
+ return (this.#e & X) === X;
2558
+ }
2559
+ lstatCached() {
2560
+ return this.#e & je ? this : void 0;
2561
+ }
2562
+ readlinkCached() {
2563
+ return this.#M;
2564
+ }
2565
+ realpathCached() {
2566
+ return this.#k;
2567
+ }
2568
+ readdirCached() {
2569
+ let t = this.children();
2570
+ return t.slice(0, t.provisional);
2571
+ }
2572
+ canReadlink() {
2573
+ if (this.#M) return true;
2574
+ if (!this.parent) return false;
2575
+ let t = this.#e & _;
2576
+ return !(t !== L && t !== X || this.#e & Nt || this.#e & j);
2577
+ }
2578
+ calledReaddir() {
2579
+ return !!(this.#e & se);
2580
+ }
2581
+ isENOENT() {
2582
+ return !!(this.#e & j);
2583
+ }
2584
+ isNamed(t) {
2585
+ return this.nocase ? this.#C === _t(t) : this.#C === bt(t);
2586
+ }
2587
+ async readlink() {
2588
+ let t = this.#M;
2589
+ if (t) return t;
2590
+ if (this.canReadlink() && this.parent) try {
2591
+ let e = await this.#t.promises.readlink(this.fullpath()), s = (await this.parent.realpath())?.resolve(e);
2592
+ if (s) return this.#M = s;
2593
+ } catch (e) {
2594
+ this.#D(e.code);
2595
+ return;
2596
+ }
2597
+ }
2598
+ readlinkSync() {
2599
+ let t = this.#M;
2600
+ if (t) return t;
2601
+ if (this.canReadlink() && this.parent) try {
2602
+ let e = this.#t.readlinkSync(this.fullpath()), s = this.parent.realpathSync()?.resolve(e);
2603
+ if (s) return this.#M = s;
2604
+ } catch (e) {
2605
+ this.#D(e.code);
2606
+ return;
2607
+ }
2608
+ }
2609
+ #j(t) {
2610
+ this.#e |= se;
2611
+ for (let e = t.provisional; e < t.length; e++) {
2612
+ let s = t[e];
2613
+ s && s.#v();
2614
+ }
2615
+ }
2616
+ #v() {
2617
+ this.#e & j || (this.#e = (this.#e | j) & gt, this.#G());
2618
+ }
2619
+ #G() {
2620
+ let t = this.children();
2621
+ t.provisional = 0;
2622
+ for (let e of t) e.#v();
2623
+ }
2624
+ #P() {
2625
+ this.#e |= Lt, this.#L();
2626
+ }
2627
+ #L() {
2628
+ if (this.#e & yt) return;
2629
+ let t = this.#e;
2630
+ (t & _) === U && (t &= gt), this.#e = t | yt, this.#G();
2631
+ }
2632
+ #I(t = "") {
2633
+ t === "ENOTDIR" || t === "EPERM" ? this.#L() : t === "ENOENT" ? this.#v() : this.children().provisional = 0;
2634
+ }
2635
+ #F(t = "") {
2636
+ t === "ENOTDIR" ? this.parent.#L() : t === "ENOENT" && this.#v();
2637
+ }
2638
+ #D(t = "") {
2639
+ let e = this.#e;
2640
+ e |= Nt, t === "ENOENT" && (e |= j), (t === "EINVAL" || t === "UNKNOWN") && (e &= gt), this.#e = e, t === "ENOTDIR" && this.parent && this.parent.#L();
2641
+ }
2642
+ #z(t, e) {
2643
+ return this.#U(t, e) || this.#B(t, e);
2644
+ }
2645
+ #B(t, e) {
2646
+ let s = ie(t), i = this.newChild(t.name, s, { parent: this }), r = i.#e & _;
2647
+ return r !== U && r !== X && r !== L && (i.#e |= yt), e.unshift(i), e.provisional++, i;
2648
+ }
2649
+ #U(t, e) {
2650
+ for (let s = e.provisional; s < e.length; s++) {
2651
+ let i = e[s];
2652
+ if ((this.nocase ? _t(t.name) : bt(t.name)) === i.#C) return this.#l(t, i, s, e);
2653
+ }
2654
+ }
2655
+ #l(t, e, s, i) {
2656
+ let r = e.name;
2657
+ return e.#e = e.#e & gt | ie(t), r !== t.name && (e.name = t.name), s !== i.provisional && (s === i.length - 1 ? i.pop() : i.splice(s, 1), i.unshift(e)), i.provisional++, e;
2658
+ }
2659
+ async lstat() {
2660
+ if ((this.#e & j) === 0) try {
2661
+ return this.#$(await this.#t.promises.lstat(this.fullpath())), this;
2662
+ } catch (t) {
2663
+ this.#F(t.code);
2664
+ }
2665
+ }
2666
+ lstatSync() {
2667
+ if ((this.#e & j) === 0) try {
2668
+ return this.#$(this.#t.lstatSync(this.fullpath())), this;
2669
+ } catch (t) {
2670
+ this.#F(t.code);
2671
+ }
2672
+ }
2673
+ #$(t) {
2674
+ let { atime: e, atimeMs: s, birthtime: i, birthtimeMs: r, blksize: o, blocks: h, ctime: a, ctimeMs: l, dev: u, gid: c, ino: d, mode: f, mtime: m, mtimeMs: p, nlink: w, rdev: g, size: S, uid: E } = t;
2675
+ this.#b = e, this.#a = s, this.#m = i, this.#E = r, this.#c = o, this.#f = h, this.#R = a, this.#d = l, this.#s = u, this.#S = c, this.#h = d, this.#n = f, this.#p = m, this.#i = p, this.#r = w, this.#w = g, this.#u = S, this.#o = E;
2676
+ let y = ie(t);
2677
+ this.#e = this.#e & gt | y | je, y !== L && y !== U && y !== X && (this.#e |= yt);
2678
+ }
2679
+ #W = [];
2680
+ #O = false;
2681
+ #H(t) {
2682
+ this.#O = false;
2683
+ let e = this.#W.slice();
2684
+ this.#W.length = 0, e.forEach((s) => s(null, t));
2685
+ }
2686
+ readdirCB(t, e = false) {
2687
+ if (!this.canReaddir()) {
2688
+ e ? t(null, []) : queueMicrotask(() => t(null, []));
2689
+ return;
2690
+ }
2691
+ let s = this.children();
2692
+ if (this.calledReaddir()) {
2693
+ let r = s.slice(0, s.provisional);
2694
+ e ? t(null, r) : queueMicrotask(() => t(null, r));
2695
+ return;
2696
+ }
2697
+ if (this.#W.push(t), this.#O) return;
2698
+ this.#O = true;
2699
+ let i = this.fullpath();
2700
+ this.#t.readdir(i, { withFileTypes: true }, (r, o) => {
2701
+ if (r) this.#I(r.code), s.provisional = 0;
2702
+ else {
2703
+ for (let h of o) this.#z(h, s);
2704
+ this.#j(s);
2705
+ }
2706
+ this.#H(s.slice(0, s.provisional));
2707
+ });
2708
+ }
2709
+ #q;
2710
+ async readdir() {
2711
+ if (!this.canReaddir()) return [];
2712
+ let t = this.children();
2713
+ if (this.calledReaddir()) return t.slice(0, t.provisional);
2714
+ let e = this.fullpath();
2715
+ if (this.#q) await this.#q;
2716
+ else {
2717
+ let s = () => {
2718
+ };
2719
+ this.#q = new Promise((i) => s = i);
2720
+ try {
2721
+ for (let i of await this.#t.promises.readdir(e, { withFileTypes: true })) this.#z(i, t);
2722
+ this.#j(t);
2723
+ } catch (i) {
2724
+ this.#I(i.code), t.provisional = 0;
2725
+ }
2726
+ this.#q = void 0, s();
2727
+ }
2728
+ return t.slice(0, t.provisional);
2729
+ }
2730
+ readdirSync() {
2731
+ if (!this.canReaddir()) return [];
2732
+ let t = this.children();
2733
+ if (this.calledReaddir()) return t.slice(0, t.provisional);
2734
+ let e = this.fullpath();
2735
+ try {
2736
+ for (let s of this.#t.readdirSync(e, { withFileTypes: true })) this.#z(s, t);
2737
+ this.#j(t);
2738
+ } catch (s) {
2739
+ this.#I(s.code), t.provisional = 0;
2740
+ }
2741
+ return t.slice(0, t.provisional);
2742
+ }
2743
+ canReaddir() {
2744
+ if (this.#e & Ie) return false;
2745
+ let t = _ & this.#e;
2746
+ return t === L || t === U || t === X;
2747
+ }
2748
+ shouldWalk(t, e) {
2749
+ return (this.#e & U) === U && !(this.#e & Ie) && !t.has(this) && (!e || e(this));
2750
+ }
2751
+ async realpath() {
2752
+ if (this.#k) return this.#k;
2753
+ if (!((Lt | Nt | j) & this.#e)) try {
2754
+ let t = await this.#t.promises.realpath(this.fullpath());
2755
+ return this.#k = this.resolve(t);
2756
+ } catch {
2757
+ this.#P();
2758
+ }
2759
+ }
2760
+ realpathSync() {
2761
+ if (this.#k) return this.#k;
2762
+ if (!((Lt | Nt | j) & this.#e)) try {
2763
+ let t = this.#t.realpathSync(this.fullpath());
2764
+ return this.#k = this.resolve(t);
2765
+ } catch {
2766
+ this.#P();
2767
+ }
2768
+ }
2769
+ [Ye](t) {
2770
+ if (t === this) return;
2771
+ t.isCWD = false, this.isCWD = true;
2772
+ let e = /* @__PURE__ */ new Set([]), s = [], i = this;
2773
+ for (; i && i.parent; ) e.add(i), i.#x = s.join(this.sep), i.#A = s.join("/"), i = i.parent, s.push("..");
2774
+ for (i = t; i && i.parent && !e.has(i); ) i.#x = void 0, i.#A = void 0, i = i.parent;
2775
+ }
2776
+ };
2777
+ var Pt = class n2 extends R {
2778
+ sep = "\\";
2779
+ splitSep = Oi;
2780
+ constructor(t, e = L, s, i, r, o, h) {
2781
+ super(t, e, s, i, r, o, h);
2782
+ }
2783
+ newChild(t, e = L, s = {}) {
2784
+ return new n2(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
2785
+ }
2786
+ getRootString(t) {
2787
+ return win32.parse(t).root;
2788
+ }
2789
+ getRoot(t) {
2790
+ if (t = Ri(t.toUpperCase()), t === this.root.name) return this.root;
2791
+ for (let [e, s] of Object.entries(this.roots)) if (this.sameRoot(t, e)) return this.roots[t] = s;
2792
+ return this.roots[t] = new it(t, this).root;
2793
+ }
2794
+ sameRoot(t, e = this.root.name) {
2795
+ return t = t.toUpperCase().replace(/\//g, "\\").replace($e, "$1\\"), t === e;
2796
+ }
2797
+ };
2798
+ var jt = class n3 extends R {
2799
+ splitSep = "/";
2800
+ sep = "/";
2801
+ constructor(t, e = L, s, i, r, o, h) {
2802
+ super(t, e, s, i, r, o, h);
2803
+ }
2804
+ getRootString(t) {
2805
+ return t.startsWith("/") ? "/" : "";
2806
+ }
2807
+ getRoot(t) {
2808
+ return this.root;
2809
+ }
2810
+ newChild(t, e = L, s = {}) {
2811
+ return new n3(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
2812
+ }
2813
+ };
2814
+ var It = class {
2815
+ root;
2816
+ rootPath;
2817
+ roots;
2818
+ cwd;
2819
+ #t;
2820
+ #s;
2821
+ #n;
2822
+ nocase;
2823
+ #r;
2824
+ constructor(t = process.cwd(), e, s, { nocase: i, childrenCacheSize: r = 16 * 1024, fs: o = wt } = {}) {
2825
+ this.#r = Ue(o), (t instanceof URL || t.startsWith("file://")) && (t = fileURLToPath(t));
2826
+ let h = e.resolve(t);
2827
+ this.roots = /* @__PURE__ */ Object.create(null), this.rootPath = this.parseRootPath(h), this.#t = new Wt(), this.#s = new Wt(), this.#n = new ne(r);
2828
+ let a = h.substring(this.rootPath.length).split(s);
2829
+ if (a.length === 1 && !a[0] && a.pop(), i === void 0) throw new TypeError("must provide nocase setting to PathScurryBase ctor");
2830
+ this.nocase = i, this.root = this.newRoot(this.#r), this.roots[this.rootPath] = this.root;
2831
+ let l = this.root, u = a.length - 1, c = e.sep, d = this.rootPath, f = false;
2832
+ for (let m of a) {
2833
+ let p = u--;
2834
+ l = l.child(m, { relative: new Array(p).fill("..").join(c), relativePosix: new Array(p).fill("..").join("/"), fullpath: d += (f ? "" : c) + m }), f = true;
2835
+ }
2836
+ this.cwd = l;
2837
+ }
2838
+ depth(t = this.cwd) {
2839
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.depth();
2840
+ }
2841
+ childrenCache() {
2842
+ return this.#n;
2843
+ }
2844
+ resolve(...t) {
2845
+ let e = "";
2846
+ for (let r = t.length - 1; r >= 0; r--) {
2847
+ let o = t[r];
2848
+ if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o))) break;
2849
+ }
2850
+ let s = this.#t.get(e);
2851
+ if (s !== void 0) return s;
2852
+ let i = this.cwd.resolve(e).fullpath();
2853
+ return this.#t.set(e, i), i;
2854
+ }
2855
+ resolvePosix(...t) {
2856
+ let e = "";
2857
+ for (let r = t.length - 1; r >= 0; r--) {
2858
+ let o = t[r];
2859
+ if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o))) break;
2860
+ }
2861
+ let s = this.#s.get(e);
2862
+ if (s !== void 0) return s;
2863
+ let i = this.cwd.resolve(e).fullpathPosix();
2864
+ return this.#s.set(e, i), i;
2865
+ }
2866
+ relative(t = this.cwd) {
2867
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.relative();
2868
+ }
2869
+ relativePosix(t = this.cwd) {
2870
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.relativePosix();
2871
+ }
2872
+ basename(t = this.cwd) {
2873
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.name;
2874
+ }
2875
+ dirname(t = this.cwd) {
2876
+ return typeof t == "string" && (t = this.cwd.resolve(t)), (t.parent || t).fullpath();
2877
+ }
2878
+ async readdir(t = this.cwd, e = { withFileTypes: true }) {
2879
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
2880
+ let { withFileTypes: s } = e;
2881
+ if (t.canReaddir()) {
2882
+ let i = await t.readdir();
2883
+ return s ? i : i.map((r) => r.name);
2884
+ } else return [];
2885
+ }
2886
+ readdirSync(t = this.cwd, e = { withFileTypes: true }) {
2887
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
2888
+ let { withFileTypes: s = true } = e;
2889
+ return t.canReaddir() ? s ? t.readdirSync() : t.readdirSync().map((i) => i.name) : [];
2890
+ }
2891
+ async lstat(t = this.cwd) {
2892
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstat();
2893
+ }
2894
+ lstatSync(t = this.cwd) {
2895
+ return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstatSync();
2896
+ }
2897
+ async readlink(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
2898
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
2899
+ let s = await t.readlink();
2900
+ return e ? s : s?.fullpath();
2901
+ }
2902
+ readlinkSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
2903
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
2904
+ let s = t.readlinkSync();
2905
+ return e ? s : s?.fullpath();
2906
+ }
2907
+ async realpath(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
2908
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
2909
+ let s = await t.realpath();
2910
+ return e ? s : s?.fullpath();
2911
+ }
2912
+ realpathSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: false }) {
2913
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
2914
+ let s = t.realpathSync();
2915
+ return e ? s : s?.fullpath();
2916
+ }
2917
+ async walk(t = this.cwd, e = {}) {
2918
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
2919
+ let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = [];
2920
+ (!r || r(t)) && h.push(s ? t : t.fullpath());
2921
+ let a = /* @__PURE__ */ new Set(), l = (c, d) => {
2922
+ a.add(c), c.readdirCB((f, m) => {
2923
+ if (f) return d(f);
2924
+ let p = m.length;
2925
+ if (!p) return d();
2926
+ let w = () => {
2927
+ --p === 0 && d();
2928
+ };
2929
+ for (let g of m) (!r || r(g)) && h.push(s ? g : g.fullpath()), i && g.isSymbolicLink() ? g.realpath().then((S) => S?.isUnknown() ? S.lstat() : S).then((S) => S?.shouldWalk(a, o) ? l(S, w) : w()) : g.shouldWalk(a, o) ? l(g, w) : w();
2930
+ }, true);
2931
+ }, u = t;
2932
+ return new Promise((c, d) => {
2933
+ l(u, (f) => {
2934
+ if (f) return d(f);
2935
+ c(h);
2936
+ });
2937
+ });
2938
+ }
2939
+ walkSync(t = this.cwd, e = {}) {
2940
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
2941
+ let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = [];
2942
+ (!r || r(t)) && h.push(s ? t : t.fullpath());
2943
+ let a = /* @__PURE__ */ new Set([t]);
2944
+ for (let l of a) {
2945
+ let u = l.readdirSync();
2946
+ for (let c of u) {
2947
+ (!r || r(c)) && h.push(s ? c : c.fullpath());
2948
+ let d = c;
2949
+ if (c.isSymbolicLink()) {
2950
+ if (!(i && (d = c.realpathSync()))) continue;
2951
+ d.isUnknown() && d.lstatSync();
2952
+ }
2953
+ d.shouldWalk(a, o) && a.add(d);
2954
+ }
2955
+ }
2956
+ return h;
2957
+ }
2958
+ [Symbol.asyncIterator]() {
2959
+ return this.iterate();
2960
+ }
2961
+ iterate(t = this.cwd, e = {}) {
2962
+ return typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd), this.stream(t, e)[Symbol.asyncIterator]();
2963
+ }
2964
+ [Symbol.iterator]() {
2965
+ return this.iterateSync();
2966
+ }
2967
+ *iterateSync(t = this.cwd, e = {}) {
2968
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
2969
+ let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e;
2970
+ (!r || r(t)) && (yield s ? t : t.fullpath());
2971
+ let h = /* @__PURE__ */ new Set([t]);
2972
+ for (let a of h) {
2973
+ let l = a.readdirSync();
2974
+ for (let u of l) {
2975
+ (!r || r(u)) && (yield s ? u : u.fullpath());
2976
+ let c = u;
2977
+ if (u.isSymbolicLink()) {
2978
+ if (!(i && (c = u.realpathSync()))) continue;
2979
+ c.isUnknown() && c.lstatSync();
2980
+ }
2981
+ c.shouldWalk(h, o) && h.add(c);
2982
+ }
2983
+ }
2984
+ }
2985
+ stream(t = this.cwd, e = {}) {
2986
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
2987
+ let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = new V({ objectMode: true });
2988
+ (!r || r(t)) && h.write(s ? t : t.fullpath());
2989
+ let a = /* @__PURE__ */ new Set(), l = [t], u = 0, c = () => {
2990
+ let d = false;
2991
+ for (; !d; ) {
2992
+ let f = l.shift();
2993
+ if (!f) {
2994
+ u === 0 && h.end();
2995
+ return;
2996
+ }
2997
+ u++, a.add(f);
2998
+ let m = (w, g, S = false) => {
2999
+ if (w) return h.emit("error", w);
3000
+ if (i && !S) {
3001
+ let E = [];
3002
+ for (let y of g) y.isSymbolicLink() && E.push(y.realpath().then((b) => b?.isUnknown() ? b.lstat() : b));
3003
+ if (E.length) {
3004
+ Promise.all(E).then(() => m(null, g, true));
3005
+ return;
3006
+ }
3007
+ }
3008
+ for (let E of g) E && (!r || r(E)) && (h.write(s ? E : E.fullpath()) || (d = true));
3009
+ u--;
3010
+ for (let E of g) {
3011
+ let y = E.realpathCached() || E;
3012
+ y.shouldWalk(a, o) && l.push(y);
3013
+ }
3014
+ d && !h.flowing ? h.once("drain", c) : p || c();
3015
+ }, p = true;
3016
+ f.readdirCB(m, true), p = false;
3017
+ }
3018
+ };
3019
+ return c(), h;
3020
+ }
3021
+ streamSync(t = this.cwd, e = {}) {
3022
+ typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
3023
+ let { withFileTypes: s = true, follow: i = false, filter: r, walkFilter: o } = e, h = new V({ objectMode: true }), a = /* @__PURE__ */ new Set();
3024
+ (!r || r(t)) && h.write(s ? t : t.fullpath());
3025
+ let l = [t], u = 0, c = () => {
3026
+ let d = false;
3027
+ for (; !d; ) {
3028
+ let f = l.shift();
3029
+ if (!f) {
3030
+ u === 0 && h.end();
3031
+ return;
3032
+ }
3033
+ u++, a.add(f);
3034
+ let m = f.readdirSync();
3035
+ for (let p of m) (!r || r(p)) && (h.write(s ? p : p.fullpath()) || (d = true));
3036
+ u--;
3037
+ for (let p of m) {
3038
+ let w = p;
3039
+ if (p.isSymbolicLink()) {
3040
+ if (!(i && (w = p.realpathSync()))) continue;
3041
+ w.isUnknown() && w.lstatSync();
3042
+ }
3043
+ w.shouldWalk(a, o) && l.push(w);
3044
+ }
3045
+ }
3046
+ d && !h.flowing && h.once("drain", c);
3047
+ };
3048
+ return c(), h;
3049
+ }
3050
+ chdir(t = this.cwd) {
3051
+ let e = this.cwd;
3052
+ this.cwd = typeof t == "string" ? this.cwd.resolve(t) : t, this.cwd[Ye](e);
3053
+ }
3054
+ };
3055
+ var it = class extends It {
3056
+ sep = "\\";
3057
+ constructor(t = process.cwd(), e = {}) {
3058
+ let { nocase: s = true } = e;
3059
+ super(t, win32, "\\", { ...e, nocase: s }), this.nocase = s;
3060
+ for (let i = this.cwd; i; i = i.parent) i.nocase = this.nocase;
3061
+ }
3062
+ parseRootPath(t) {
3063
+ return win32.parse(t).root.toUpperCase();
3064
+ }
3065
+ newRoot(t) {
3066
+ return new Pt(this.rootPath, U, void 0, this.roots, this.nocase, this.childrenCache(), { fs: t });
3067
+ }
3068
+ isAbsolute(t) {
3069
+ return t.startsWith("/") || t.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(t);
3070
+ }
3071
+ };
3072
+ var rt = class extends It {
3073
+ sep = "/";
3074
+ constructor(t = process.cwd(), e = {}) {
3075
+ let { nocase: s = false } = e;
3076
+ super(t, posix, "/", { ...e, nocase: s }), this.nocase = s;
3077
+ }
3078
+ parseRootPath(t) {
3079
+ return "/";
3080
+ }
3081
+ newRoot(t) {
3082
+ return new jt(this.rootPath, U, void 0, this.roots, this.nocase, this.childrenCache(), { fs: t });
3083
+ }
3084
+ isAbsolute(t) {
3085
+ return t.startsWith("/");
3086
+ }
3087
+ };
3088
+ var St = class extends rt {
3089
+ constructor(t = process.cwd(), e = {}) {
3090
+ let { nocase: s = true } = e;
3091
+ super(t, { ...e, nocase: s });
3092
+ }
3093
+ };
3094
+ process.platform === "win32" ? Pt : jt;
3095
+ var Xe = process.platform === "win32" ? it : process.platform === "darwin" ? St : rt;
3096
+ var Di = (n7) => n7.length >= 1;
3097
+ var Mi = (n7) => n7.length >= 1;
3098
+ var Ni = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
3099
+ var nt = class n4 {
3100
+ #t;
3101
+ #s;
3102
+ #n;
3103
+ length;
3104
+ #r;
3105
+ #o;
3106
+ #S;
3107
+ #w;
3108
+ #c;
3109
+ #h;
3110
+ #u = true;
3111
+ constructor(t, e, s, i) {
3112
+ if (!Di(t)) throw new TypeError("empty pattern list");
3113
+ if (!Mi(e)) throw new TypeError("empty glob list");
3114
+ if (e.length !== t.length) throw new TypeError("mismatched pattern list and glob list lengths");
3115
+ if (this.length = t.length, s < 0 || s >= this.length) throw new TypeError("index out of range");
3116
+ if (this.#t = t, this.#s = e, this.#n = s, this.#r = i, this.#n === 0) {
3117
+ if (this.isUNC()) {
3118
+ let [r, o, h, a, ...l] = this.#t, [u, c, d, f, ...m] = this.#s;
3119
+ l[0] === "" && (l.shift(), m.shift());
3120
+ let p = [r, o, h, a, ""].join("/"), w = [u, c, d, f, ""].join("/");
3121
+ this.#t = [p, ...l], this.#s = [w, ...m], this.length = this.#t.length;
3122
+ } else if (this.isDrive() || this.isAbsolute()) {
3123
+ let [r, ...o] = this.#t, [h, ...a] = this.#s;
3124
+ o[0] === "" && (o.shift(), a.shift());
3125
+ let l = r + "/", u = h + "/";
3126
+ this.#t = [l, ...o], this.#s = [u, ...a], this.length = this.#t.length;
3127
+ }
3128
+ }
3129
+ }
3130
+ [Ni]() {
3131
+ return "Pattern <" + this.#s.slice(this.#n).join("/") + ">";
3132
+ }
3133
+ pattern() {
3134
+ return this.#t[this.#n];
3135
+ }
3136
+ isString() {
3137
+ return typeof this.#t[this.#n] == "string";
3138
+ }
3139
+ isGlobstar() {
3140
+ return this.#t[this.#n] === A;
3141
+ }
3142
+ isRegExp() {
3143
+ return this.#t[this.#n] instanceof RegExp;
3144
+ }
3145
+ globString() {
3146
+ return this.#S = this.#S || (this.#n === 0 ? this.isAbsolute() ? this.#s[0] + this.#s.slice(1).join("/") : this.#s.join("/") : this.#s.slice(this.#n).join("/"));
3147
+ }
3148
+ hasMore() {
3149
+ return this.length > this.#n + 1;
3150
+ }
3151
+ rest() {
3152
+ return this.#o !== void 0 ? this.#o : this.hasMore() ? (this.#o = new n4(this.#t, this.#s, this.#n + 1, this.#r), this.#o.#h = this.#h, this.#o.#c = this.#c, this.#o.#w = this.#w, this.#o) : this.#o = null;
3153
+ }
3154
+ isUNC() {
3155
+ let t = this.#t;
3156
+ return this.#c !== void 0 ? this.#c : this.#c = this.#r === "win32" && this.#n === 0 && t[0] === "" && t[1] === "" && typeof t[2] == "string" && !!t[2] && typeof t[3] == "string" && !!t[3];
3157
+ }
3158
+ isDrive() {
3159
+ let t = this.#t;
3160
+ return this.#w !== void 0 ? this.#w : this.#w = this.#r === "win32" && this.#n === 0 && this.length > 1 && typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]);
3161
+ }
3162
+ isAbsolute() {
3163
+ let t = this.#t;
3164
+ return this.#h !== void 0 ? this.#h : this.#h = t[0] === "" && t.length > 1 || this.isDrive() || this.isUNC();
3165
+ }
3166
+ root() {
3167
+ let t = this.#t[0];
3168
+ return typeof t == "string" && this.isAbsolute() && this.#n === 0 ? t : "";
3169
+ }
3170
+ checkFollowGlobstar() {
3171
+ return !(this.#n === 0 || !this.isGlobstar() || !this.#u);
3172
+ }
3173
+ markFollowGlobstar() {
3174
+ return this.#n === 0 || !this.isGlobstar() || !this.#u ? false : (this.#u = false, true);
3175
+ }
3176
+ };
3177
+ var _i = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
3178
+ var ot = class {
3179
+ relative;
3180
+ relativeChildren;
3181
+ absolute;
3182
+ absoluteChildren;
3183
+ platform;
3184
+ mmopts;
3185
+ constructor(t, { nobrace: e, nocase: s, noext: i, noglobstar: r, platform: o = _i }) {
3186
+ this.relative = [], this.absolute = [], this.relativeChildren = [], this.absoluteChildren = [], this.platform = o, this.mmopts = { dot: true, nobrace: e, nocase: s, noext: i, noglobstar: r, optimizationLevel: 2, platform: o, nocomment: true, nonegate: true };
3187
+ for (let h of t) this.add(h);
3188
+ }
3189
+ add(t) {
3190
+ let e = new D(t, this.mmopts);
3191
+ for (let s = 0; s < e.set.length; s++) {
3192
+ let i = e.set[s], r = e.globParts[s];
3193
+ if (!i || !r) throw new Error("invalid pattern object");
3194
+ for (; i[0] === "." && r[0] === "."; ) i.shift(), r.shift();
3195
+ let o = new nt(i, r, 0, this.platform), h = new D(o.globString(), this.mmopts), a = r[r.length - 1] === "**", l = o.isAbsolute();
3196
+ l ? this.absolute.push(h) : this.relative.push(h), a && (l ? this.absoluteChildren.push(h) : this.relativeChildren.push(h));
3197
+ }
3198
+ }
3199
+ ignored(t) {
3200
+ let e = t.fullpath(), s = `${e}/`, i = t.relative() || ".", r = `${i}/`;
3201
+ for (let o of this.relative) if (o.match(i) || o.match(r)) return true;
3202
+ for (let o of this.absolute) if (o.match(e) || o.match(s)) return true;
3203
+ return false;
3204
+ }
3205
+ childrenIgnored(t) {
3206
+ let e = t.fullpath() + "/", s = (t.relative() || ".") + "/";
3207
+ for (let i of this.relativeChildren) if (i.match(s)) return true;
3208
+ for (let i of this.absoluteChildren) if (i.match(e)) return true;
3209
+ return false;
3210
+ }
3211
+ };
3212
+ var oe = class n5 {
3213
+ store;
3214
+ constructor(t = /* @__PURE__ */ new Map()) {
3215
+ this.store = t;
3216
+ }
3217
+ copy() {
3218
+ return new n5(new Map(this.store));
3219
+ }
3220
+ hasWalked(t, e) {
3221
+ return this.store.get(t.fullpath())?.has(e.globString());
3222
+ }
3223
+ storeWalked(t, e) {
3224
+ let s = t.fullpath(), i = this.store.get(s);
3225
+ i ? i.add(e.globString()) : this.store.set(s, /* @__PURE__ */ new Set([e.globString()]));
3226
+ }
3227
+ };
3228
+ var he = class {
3229
+ store = /* @__PURE__ */ new Map();
3230
+ add(t, e, s) {
3231
+ let i = (e ? 2 : 0) | (s ? 1 : 0), r = this.store.get(t);
3232
+ this.store.set(t, r === void 0 ? i : i & r);
3233
+ }
3234
+ entries() {
3235
+ return [...this.store.entries()].map(([t, e]) => [t, !!(e & 2), !!(e & 1)]);
3236
+ }
3237
+ };
3238
+ var ae = class {
3239
+ store = /* @__PURE__ */ new Map();
3240
+ add(t, e) {
3241
+ if (!t.canReaddir()) return;
3242
+ let s = this.store.get(t);
3243
+ s ? s.find((i) => i.globString() === e.globString()) || s.push(e) : this.store.set(t, [e]);
3244
+ }
3245
+ get(t) {
3246
+ let e = this.store.get(t);
3247
+ if (!e) throw new Error("attempting to walk unknown path");
3248
+ return e;
3249
+ }
3250
+ entries() {
3251
+ return this.keys().map((t) => [t, this.store.get(t)]);
3252
+ }
3253
+ keys() {
3254
+ return [...this.store.keys()].filter((t) => t.canReaddir());
3255
+ }
3256
+ };
3257
+ var Et = class n6 {
3258
+ hasWalkedCache;
3259
+ matches = new he();
3260
+ subwalks = new ae();
3261
+ patterns;
3262
+ follow;
3263
+ dot;
3264
+ opts;
3265
+ constructor(t, e) {
3266
+ this.opts = t, this.follow = !!t.follow, this.dot = !!t.dot, this.hasWalkedCache = e ? e.copy() : new oe();
3267
+ }
3268
+ processPatterns(t, e) {
3269
+ this.patterns = e;
3270
+ let s = e.map((i) => [t, i]);
3271
+ for (let [i, r] of s) {
3272
+ this.hasWalkedCache.storeWalked(i, r);
3273
+ let o = r.root(), h = r.isAbsolute() && this.opts.absolute !== false;
3274
+ if (o) {
3275
+ i = i.resolve(o === "/" && this.opts.root !== void 0 ? this.opts.root : o);
3276
+ let c = r.rest();
3277
+ if (c) r = c;
3278
+ else {
3279
+ this.matches.add(i, true, false);
3280
+ continue;
3281
+ }
3282
+ }
3283
+ if (i.isENOENT()) continue;
3284
+ let a, l, u = false;
3285
+ for (; typeof (a = r.pattern()) == "string" && (l = r.rest()); ) i = i.resolve(a), r = l, u = true;
3286
+ if (a = r.pattern(), l = r.rest(), u) {
3287
+ if (this.hasWalkedCache.hasWalked(i, r)) continue;
3288
+ this.hasWalkedCache.storeWalked(i, r);
3289
+ }
3290
+ if (typeof a == "string") {
3291
+ let c = a === ".." || a === "" || a === ".";
3292
+ this.matches.add(i.resolve(a), h, c);
3293
+ continue;
3294
+ } else if (a === A) {
3295
+ (!i.isSymbolicLink() || this.follow || r.checkFollowGlobstar()) && this.subwalks.add(i, r);
3296
+ let c = l?.pattern(), d = l?.rest();
3297
+ if (!l || (c === "" || c === ".") && !d) this.matches.add(i, h, c === "" || c === ".");
3298
+ else if (c === "..") {
3299
+ let f = i.parent || i;
3300
+ d ? this.hasWalkedCache.hasWalked(f, d) || this.subwalks.add(f, d) : this.matches.add(f, h, true);
3301
+ }
3302
+ } else a instanceof RegExp && this.subwalks.add(i, r);
3303
+ }
3304
+ return this;
3305
+ }
3306
+ subwalkTargets() {
3307
+ return this.subwalks.keys();
3308
+ }
3309
+ child() {
3310
+ return new n6(this.opts, this.hasWalkedCache);
3311
+ }
3312
+ filterEntries(t, e) {
3313
+ let s = this.subwalks.get(t), i = this.child();
3314
+ for (let r of e) for (let o of s) {
3315
+ let h = o.isAbsolute(), a = o.pattern(), l = o.rest();
3316
+ a === A ? i.testGlobstar(r, o, l, h) : a instanceof RegExp ? i.testRegExp(r, a, l, h) : i.testString(r, a, l, h);
3317
+ }
3318
+ return i;
3319
+ }
3320
+ testGlobstar(t, e, s, i) {
3321
+ if ((this.dot || !t.name.startsWith(".")) && (e.hasMore() || this.matches.add(t, i, false), t.canReaddir() && (this.follow || !t.isSymbolicLink() ? this.subwalks.add(t, e) : t.isSymbolicLink() && (s && e.checkFollowGlobstar() ? this.subwalks.add(t, s) : e.markFollowGlobstar() && this.subwalks.add(t, e)))), s) {
3322
+ let r = s.pattern();
3323
+ if (typeof r == "string" && r !== ".." && r !== "" && r !== ".") this.testString(t, r, s.rest(), i);
3324
+ else if (r === "..") {
3325
+ let o = t.parent || t;
3326
+ this.subwalks.add(o, s);
3327
+ } else r instanceof RegExp && this.testRegExp(t, r, s.rest(), i);
3328
+ }
3329
+ }
3330
+ testRegExp(t, e, s, i) {
3331
+ e.test(t.name) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, false));
3332
+ }
3333
+ testString(t, e, s, i) {
3334
+ t.isNamed(e) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, false));
3335
+ }
3336
+ };
3337
+ var Li = (n7, t) => typeof n7 == "string" ? new ot([n7], t) : Array.isArray(n7) ? new ot(n7, t) : n7;
3338
+ var zt = class {
3339
+ path;
3340
+ patterns;
3341
+ opts;
3342
+ seen = /* @__PURE__ */ new Set();
3343
+ paused = false;
3344
+ aborted = false;
3345
+ #t = [];
3346
+ #s;
3347
+ #n;
3348
+ signal;
3349
+ maxDepth;
3350
+ includeChildMatches;
3351
+ constructor(t, e, s) {
3352
+ if (this.patterns = t, this.path = e, this.opts = s, this.#n = !s.posix && s.platform === "win32" ? "\\" : "/", this.includeChildMatches = s.includeChildMatches !== false, (s.ignore || !this.includeChildMatches) && (this.#s = Li(s.ignore ?? [], s), !this.includeChildMatches && typeof this.#s.add != "function")) {
3353
+ let i = "cannot ignore child matches, ignore lacks add() method.";
3354
+ throw new Error(i);
3355
+ }
3356
+ this.maxDepth = s.maxDepth || 1 / 0, s.signal && (this.signal = s.signal, this.signal.addEventListener("abort", () => {
3357
+ this.#t.length = 0;
3358
+ }));
3359
+ }
3360
+ #r(t) {
3361
+ return this.seen.has(t) || !!this.#s?.ignored?.(t);
3362
+ }
3363
+ #o(t) {
3364
+ return !!this.#s?.childrenIgnored?.(t);
3365
+ }
3366
+ pause() {
3367
+ this.paused = true;
3368
+ }
3369
+ resume() {
3370
+ if (this.signal?.aborted) return;
3371
+ this.paused = false;
3372
+ let t;
3373
+ for (; !this.paused && (t = this.#t.shift()); ) t();
3374
+ }
3375
+ onResume(t) {
3376
+ this.signal?.aborted || (this.paused ? this.#t.push(t) : t());
3377
+ }
3378
+ async matchCheck(t, e) {
3379
+ if (e && this.opts.nodir) return;
3380
+ let s;
3381
+ if (this.opts.realpath) {
3382
+ if (s = t.realpathCached() || await t.realpath(), !s) return;
3383
+ t = s;
3384
+ }
3385
+ let r = t.isUnknown() || this.opts.stat ? await t.lstat() : t;
3386
+ if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
3387
+ let o = await r.realpath();
3388
+ o && (o.isUnknown() || this.opts.stat) && await o.lstat();
3389
+ }
3390
+ return this.matchCheckTest(r, e);
3391
+ }
3392
+ matchCheckTest(t, e) {
3393
+ return t && (this.maxDepth === 1 / 0 || t.depth() <= this.maxDepth) && (!e || t.canReaddir()) && (!this.opts.nodir || !t.isDirectory()) && (!this.opts.nodir || !this.opts.follow || !t.isSymbolicLink() || !t.realpathCached()?.isDirectory()) && !this.#r(t) ? t : void 0;
3394
+ }
3395
+ matchCheckSync(t, e) {
3396
+ if (e && this.opts.nodir) return;
3397
+ let s;
3398
+ if (this.opts.realpath) {
3399
+ if (s = t.realpathCached() || t.realpathSync(), !s) return;
3400
+ t = s;
3401
+ }
3402
+ let r = t.isUnknown() || this.opts.stat ? t.lstatSync() : t;
3403
+ if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
3404
+ let o = r.realpathSync();
3405
+ o && (o?.isUnknown() || this.opts.stat) && o.lstatSync();
3406
+ }
3407
+ return this.matchCheckTest(r, e);
3408
+ }
3409
+ matchFinish(t, e) {
3410
+ if (this.#r(t)) return;
3411
+ if (!this.includeChildMatches && this.#s?.add) {
3412
+ let r = `${t.relativePosix()}/**`;
3413
+ this.#s.add(r);
3414
+ }
3415
+ let s = this.opts.absolute === void 0 ? e : this.opts.absolute;
3416
+ this.seen.add(t);
3417
+ let i = this.opts.mark && t.isDirectory() ? this.#n : "";
3418
+ if (this.opts.withFileTypes) this.matchEmit(t);
3419
+ else if (s) {
3420
+ let r = this.opts.posix ? t.fullpathPosix() : t.fullpath();
3421
+ this.matchEmit(r + i);
3422
+ } else {
3423
+ let r = this.opts.posix ? t.relativePosix() : t.relative(), o = this.opts.dotRelative && !r.startsWith(".." + this.#n) ? "." + this.#n : "";
3424
+ this.matchEmit(r ? o + r + i : "." + i);
3425
+ }
3426
+ }
3427
+ async match(t, e, s) {
3428
+ let i = await this.matchCheck(t, s);
3429
+ i && this.matchFinish(i, e);
3430
+ }
3431
+ matchSync(t, e, s) {
3432
+ let i = this.matchCheckSync(t, s);
3433
+ i && this.matchFinish(i, e);
3434
+ }
3435
+ walkCB(t, e, s) {
3436
+ this.signal?.aborted && s(), this.walkCB2(t, e, new Et(this.opts), s);
3437
+ }
3438
+ walkCB2(t, e, s, i) {
3439
+ if (this.#o(t)) return i();
3440
+ if (this.signal?.aborted && i(), this.paused) {
3441
+ this.onResume(() => this.walkCB2(t, e, s, i));
3442
+ return;
3443
+ }
3444
+ s.processPatterns(t, e);
3445
+ let r = 1, o = () => {
3446
+ --r === 0 && i();
3447
+ };
3448
+ for (let [h, a, l] of s.matches.entries()) this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
3449
+ for (let h of s.subwalkTargets()) {
3450
+ if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth) continue;
3451
+ r++;
3452
+ let a = h.readdirCached();
3453
+ h.calledReaddir() ? this.walkCB3(h, a, s, o) : h.readdirCB((l, u) => this.walkCB3(h, u, s, o), true);
3454
+ }
3455
+ o();
3456
+ }
3457
+ walkCB3(t, e, s, i) {
3458
+ s = s.filterEntries(t, e);
3459
+ let r = 1, o = () => {
3460
+ --r === 0 && i();
3461
+ };
3462
+ for (let [h, a, l] of s.matches.entries()) this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
3463
+ for (let [h, a] of s.subwalks.entries()) r++, this.walkCB2(h, a, s.child(), o);
3464
+ o();
3465
+ }
3466
+ walkCBSync(t, e, s) {
3467
+ this.signal?.aborted && s(), this.walkCB2Sync(t, e, new Et(this.opts), s);
3468
+ }
3469
+ walkCB2Sync(t, e, s, i) {
3470
+ if (this.#o(t)) return i();
3471
+ if (this.signal?.aborted && i(), this.paused) {
3472
+ this.onResume(() => this.walkCB2Sync(t, e, s, i));
3473
+ return;
3474
+ }
3475
+ s.processPatterns(t, e);
3476
+ let r = 1, o = () => {
3477
+ --r === 0 && i();
3478
+ };
3479
+ for (let [h, a, l] of s.matches.entries()) this.#r(h) || this.matchSync(h, a, l);
3480
+ for (let h of s.subwalkTargets()) {
3481
+ if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth) continue;
3482
+ r++;
3483
+ let a = h.readdirSync();
3484
+ this.walkCB3Sync(h, a, s, o);
3485
+ }
3486
+ o();
3487
+ }
3488
+ walkCB3Sync(t, e, s, i) {
3489
+ s = s.filterEntries(t, e);
3490
+ let r = 1, o = () => {
3491
+ --r === 0 && i();
3492
+ };
3493
+ for (let [h, a, l] of s.matches.entries()) this.#r(h) || this.matchSync(h, a, l);
3494
+ for (let [h, a] of s.subwalks.entries()) r++, this.walkCB2Sync(h, a, s.child(), o);
3495
+ o();
3496
+ }
3497
+ };
3498
+ var xt = class extends zt {
3499
+ matches = /* @__PURE__ */ new Set();
3500
+ constructor(t, e, s) {
3501
+ super(t, e, s);
3502
+ }
3503
+ matchEmit(t) {
3504
+ this.matches.add(t);
3505
+ }
3506
+ async walk() {
3507
+ if (this.signal?.aborted) throw this.signal.reason;
3508
+ return this.path.isUnknown() && await this.path.lstat(), await new Promise((t, e) => {
3509
+ this.walkCB(this.path, this.patterns, () => {
3510
+ this.signal?.aborted ? e(this.signal.reason) : t(this.matches);
3511
+ });
3512
+ }), this.matches;
3513
+ }
3514
+ walkSync() {
3515
+ if (this.signal?.aborted) throw this.signal.reason;
3516
+ return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => {
3517
+ if (this.signal?.aborted) throw this.signal.reason;
3518
+ }), this.matches;
3519
+ }
3520
+ };
3521
+ var vt = class extends zt {
3522
+ results;
3523
+ constructor(t, e, s) {
3524
+ super(t, e, s), this.results = new V({ signal: this.signal, objectMode: true }), this.results.on("drain", () => this.resume()), this.results.on("resume", () => this.resume());
3525
+ }
3526
+ matchEmit(t) {
3527
+ this.results.write(t), this.results.flowing || this.pause();
3528
+ }
3529
+ stream() {
3530
+ let t = this.path;
3531
+ return t.isUnknown() ? t.lstat().then(() => {
3532
+ this.walkCB(t, this.patterns, () => this.results.end());
3533
+ }) : this.walkCB(t, this.patterns, () => this.results.end()), this.results;
3534
+ }
3535
+ streamSync() {
3536
+ return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => this.results.end()), this.results;
3537
+ }
3538
+ };
3539
+ var Pi = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
3540
+ var I = class {
3541
+ absolute;
3542
+ cwd;
3543
+ root;
3544
+ dot;
3545
+ dotRelative;
3546
+ follow;
3547
+ ignore;
3548
+ magicalBraces;
3549
+ mark;
3550
+ matchBase;
3551
+ maxDepth;
3552
+ nobrace;
3553
+ nocase;
3554
+ nodir;
3555
+ noext;
3556
+ noglobstar;
3557
+ pattern;
3558
+ platform;
3559
+ realpath;
3560
+ scurry;
3561
+ stat;
3562
+ signal;
3563
+ windowsPathsNoEscape;
3564
+ withFileTypes;
3565
+ includeChildMatches;
3566
+ opts;
3567
+ patterns;
3568
+ constructor(t, e) {
3569
+ if (!e) throw new TypeError("glob options required");
3570
+ if (this.withFileTypes = !!e.withFileTypes, this.signal = e.signal, this.follow = !!e.follow, this.dot = !!e.dot, this.dotRelative = !!e.dotRelative, this.nodir = !!e.nodir, this.mark = !!e.mark, e.cwd ? (e.cwd instanceof URL || e.cwd.startsWith("file://")) && (e.cwd = fileURLToPath(e.cwd)) : this.cwd = "", this.cwd = e.cwd || "", this.root = e.root, this.magicalBraces = !!e.magicalBraces, this.nobrace = !!e.nobrace, this.noext = !!e.noext, this.realpath = !!e.realpath, this.absolute = e.absolute, this.includeChildMatches = e.includeChildMatches !== false, this.noglobstar = !!e.noglobstar, this.matchBase = !!e.matchBase, this.maxDepth = typeof e.maxDepth == "number" ? e.maxDepth : 1 / 0, this.stat = !!e.stat, this.ignore = e.ignore, this.withFileTypes && this.absolute !== void 0) throw new Error("cannot set absolute and withFileTypes:true");
3571
+ if (typeof t == "string" && (t = [t]), this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === false, this.windowsPathsNoEscape && (t = t.map((a) => a.replace(/\\/g, "/"))), this.matchBase) {
3572
+ if (e.noglobstar) throw new TypeError("base matching requires globstar");
3573
+ t = t.map((a) => a.includes("/") ? a : `./**/${a}`);
3574
+ }
3575
+ if (this.pattern = t, this.platform = e.platform || Pi, this.opts = { ...e, platform: this.platform }, e.scurry) {
3576
+ if (this.scurry = e.scurry, e.nocase !== void 0 && e.nocase !== e.scurry.nocase) throw new Error("nocase option contradicts provided scurry option");
3577
+ } else {
3578
+ let a = e.platform === "win32" ? it : e.platform === "darwin" ? St : e.platform ? rt : Xe;
3579
+ this.scurry = new a(this.cwd, { nocase: e.nocase, fs: e.fs });
3580
+ }
3581
+ this.nocase = this.scurry.nocase;
3582
+ let s = this.platform === "darwin" || this.platform === "win32", i = { braceExpandMax: 1e4, ...e, dot: this.dot, matchBase: this.matchBase, nobrace: this.nobrace, nocase: this.nocase, nocaseMagicOnly: s, nocomment: true, noext: this.noext, nonegate: true, optimizationLevel: 2, platform: this.platform, windowsPathsNoEscape: this.windowsPathsNoEscape, debug: !!this.opts.debug }, r = this.pattern.map((a) => new D(a, i)), [o, h] = r.reduce((a, l) => (a[0].push(...l.set), a[1].push(...l.globParts), a), [[], []]);
3583
+ this.patterns = o.map((a, l) => {
3584
+ let u = h[l];
3585
+ if (!u) throw new Error("invalid pattern object");
3586
+ return new nt(a, u, 0, this.platform);
3587
+ });
3588
+ }
3589
+ async walk() {
3590
+ return [...await new xt(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches }).walk()];
3591
+ }
3592
+ walkSync() {
3593
+ return [...new xt(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches }).walkSync()];
3594
+ }
3595
+ stream() {
3596
+ return new vt(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches }).stream();
3597
+ }
3598
+ streamSync() {
3599
+ return new vt(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches }).streamSync();
3600
+ }
3601
+ iterateSync() {
3602
+ return this.streamSync()[Symbol.iterator]();
3603
+ }
3604
+ [Symbol.iterator]() {
3605
+ return this.iterateSync();
3606
+ }
3607
+ iterate() {
3608
+ return this.stream()[Symbol.asyncIterator]();
3609
+ }
3610
+ [Symbol.asyncIterator]() {
3611
+ return this.iterate();
3612
+ }
3613
+ };
3614
+ var le = (n7, t = {}) => {
3615
+ Array.isArray(n7) || (n7 = [n7]);
3616
+ for (let e of n7) if (new D(e, t).hasMagic()) return true;
3617
+ return false;
3618
+ };
3619
+ function Bt(n7, t = {}) {
3620
+ return new I(n7, t).streamSync();
3621
+ }
3622
+ function Qe(n7, t = {}) {
3623
+ return new I(n7, t).stream();
3624
+ }
3625
+ function ts(n7, t = {}) {
3626
+ return new I(n7, t).walkSync();
3627
+ }
3628
+ async function Je(n7, t = {}) {
3629
+ return new I(n7, t).walk();
3630
+ }
3631
+ function Ut(n7, t = {}) {
3632
+ return new I(n7, t).iterateSync();
3633
+ }
3634
+ function es(n7, t = {}) {
3635
+ return new I(n7, t).iterate();
3636
+ }
3637
+ var ji = Bt;
3638
+ var Ii = Object.assign(Qe, { sync: Bt });
3639
+ var zi = Ut;
3640
+ var Bi = Object.assign(es, { sync: Ut });
3641
+ var Ui = Object.assign(ts, { stream: Bt, iterate: Ut });
3642
+ var Ze = Object.assign(Je, { glob: Je, globSync: ts, sync: Ui, globStream: Qe, stream: Ii, globStreamSync: Bt, streamSync: ji, globIterate: es, iterate: Bi, globIterateSync: Ut, iterateSync: zi, Glob: I, hasMagic: le, escape: tt, unescape: W });
3643
+ Ze.glob = Ze;
3644
+
3645
+ // ../discovery/src/discover.ts
3646
+ __toESM(require_ignore());
3647
+
3648
+ // ../../node_modules/js-yaml/dist/js-yaml.mjs
3649
+ function isNothing(subject) {
3650
+ return typeof subject === "undefined" || subject === null;
3651
+ }
3652
+ function isObject(subject) {
3653
+ return typeof subject === "object" && subject !== null;
3654
+ }
3655
+ function toArray(sequence) {
3656
+ if (Array.isArray(sequence)) return sequence;
3657
+ else if (isNothing(sequence)) return [];
3658
+ return [sequence];
3659
+ }
3660
+ function extend(target, source) {
3661
+ var index, length, key, sourceKeys;
3662
+ if (source) {
3663
+ sourceKeys = Object.keys(source);
3664
+ for (index = 0, length = sourceKeys.length; index < length; index += 1) {
3665
+ key = sourceKeys[index];
3666
+ target[key] = source[key];
3667
+ }
3668
+ }
3669
+ return target;
3670
+ }
3671
+ function repeat(string, count) {
3672
+ var result = "", cycle;
3673
+ for (cycle = 0; cycle < count; cycle += 1) {
3674
+ result += string;
3675
+ }
3676
+ return result;
3677
+ }
3678
+ function isNegativeZero(number) {
3679
+ return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
3680
+ }
3681
+ var isNothing_1 = isNothing;
3682
+ var isObject_1 = isObject;
3683
+ var toArray_1 = toArray;
3684
+ var repeat_1 = repeat;
3685
+ var isNegativeZero_1 = isNegativeZero;
3686
+ var extend_1 = extend;
3687
+ var common = {
3688
+ isNothing: isNothing_1,
3689
+ isObject: isObject_1,
3690
+ toArray: toArray_1,
3691
+ repeat: repeat_1,
3692
+ isNegativeZero: isNegativeZero_1,
3693
+ extend: extend_1
3694
+ };
3695
+ function formatError(exception2, compact) {
3696
+ var where = "", message = exception2.reason || "(unknown reason)";
3697
+ if (!exception2.mark) return message;
3698
+ if (exception2.mark.name) {
3699
+ where += 'in "' + exception2.mark.name + '" ';
3700
+ }
3701
+ where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
3702
+ if (!compact && exception2.mark.snippet) {
3703
+ where += "\n\n" + exception2.mark.snippet;
3704
+ }
3705
+ return message + " " + where;
3706
+ }
3707
+ function YAMLException$1(reason, mark) {
3708
+ Error.call(this);
3709
+ this.name = "YAMLException";
3710
+ this.reason = reason;
3711
+ this.mark = mark;
3712
+ this.message = formatError(this, false);
3713
+ if (Error.captureStackTrace) {
3714
+ Error.captureStackTrace(this, this.constructor);
3715
+ } else {
3716
+ this.stack = new Error().stack || "";
3717
+ }
3718
+ }
3719
+ YAMLException$1.prototype = Object.create(Error.prototype);
3720
+ YAMLException$1.prototype.constructor = YAMLException$1;
3721
+ YAMLException$1.prototype.toString = function toString(compact) {
3722
+ return this.name + ": " + formatError(this, compact);
3723
+ };
3724
+ var exception = YAMLException$1;
3725
+ var TYPE_CONSTRUCTOR_OPTIONS = [
3726
+ "kind",
3727
+ "multi",
3728
+ "resolve",
3729
+ "construct",
3730
+ "instanceOf",
3731
+ "predicate",
3732
+ "represent",
3733
+ "representName",
3734
+ "defaultStyle",
3735
+ "styleAliases"
3736
+ ];
3737
+ var YAML_NODE_KINDS = [
3738
+ "scalar",
3739
+ "sequence",
3740
+ "mapping"
3741
+ ];
3742
+ function compileStyleAliases(map2) {
3743
+ var result = {};
3744
+ if (map2 !== null) {
3745
+ Object.keys(map2).forEach(function(style) {
3746
+ map2[style].forEach(function(alias) {
3747
+ result[String(alias)] = style;
3748
+ });
3749
+ });
3750
+ }
3751
+ return result;
3752
+ }
3753
+ function Type$1(tag, options) {
3754
+ options = options || {};
3755
+ Object.keys(options).forEach(function(name) {
3756
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
3757
+ throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
3758
+ }
3759
+ });
3760
+ this.options = options;
3761
+ this.tag = tag;
3762
+ this.kind = options["kind"] || null;
3763
+ this.resolve = options["resolve"] || function() {
3764
+ return true;
3765
+ };
3766
+ this.construct = options["construct"] || function(data) {
3767
+ return data;
3768
+ };
3769
+ this.instanceOf = options["instanceOf"] || null;
3770
+ this.predicate = options["predicate"] || null;
3771
+ this.represent = options["represent"] || null;
3772
+ this.representName = options["representName"] || null;
3773
+ this.defaultStyle = options["defaultStyle"] || null;
3774
+ this.multi = options["multi"] || false;
3775
+ this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
3776
+ if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
3777
+ throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
3778
+ }
3779
+ }
3780
+ var type = Type$1;
3781
+ function compileList(schema2, name) {
3782
+ var result = [];
3783
+ schema2[name].forEach(function(currentType) {
3784
+ var newIndex = result.length;
3785
+ result.forEach(function(previousType, previousIndex) {
3786
+ if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
3787
+ newIndex = previousIndex;
3788
+ }
3789
+ });
3790
+ result[newIndex] = currentType;
3791
+ });
3792
+ return result;
3793
+ }
3794
+ function compileMap() {
3795
+ var result = {
3796
+ scalar: {},
3797
+ sequence: {},
3798
+ mapping: {},
3799
+ fallback: {},
3800
+ multi: {
3801
+ scalar: [],
3802
+ sequence: [],
3803
+ mapping: [],
3804
+ fallback: []
3805
+ }
3806
+ }, index, length;
3807
+ function collectType(type2) {
3808
+ if (type2.multi) {
3809
+ result.multi[type2.kind].push(type2);
3810
+ result.multi["fallback"].push(type2);
3811
+ } else {
3812
+ result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
3813
+ }
3814
+ }
3815
+ for (index = 0, length = arguments.length; index < length; index += 1) {
3816
+ arguments[index].forEach(collectType);
3817
+ }
3818
+ return result;
3819
+ }
3820
+ function Schema$1(definition) {
3821
+ return this.extend(definition);
3822
+ }
3823
+ Schema$1.prototype.extend = function extend2(definition) {
3824
+ var implicit = [];
3825
+ var explicit = [];
3826
+ if (definition instanceof type) {
3827
+ explicit.push(definition);
3828
+ } else if (Array.isArray(definition)) {
3829
+ explicit = explicit.concat(definition);
3830
+ } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
3831
+ if (definition.implicit) implicit = implicit.concat(definition.implicit);
3832
+ if (definition.explicit) explicit = explicit.concat(definition.explicit);
3833
+ } else {
3834
+ throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
3835
+ }
3836
+ implicit.forEach(function(type$1) {
3837
+ if (!(type$1 instanceof type)) {
3838
+ throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
3839
+ }
3840
+ if (type$1.loadKind && type$1.loadKind !== "scalar") {
3841
+ throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
3842
+ }
3843
+ if (type$1.multi) {
3844
+ throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
3845
+ }
3846
+ });
3847
+ explicit.forEach(function(type$1) {
3848
+ if (!(type$1 instanceof type)) {
3849
+ throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
3850
+ }
3851
+ });
3852
+ var result = Object.create(Schema$1.prototype);
3853
+ result.implicit = (this.implicit || []).concat(implicit);
3854
+ result.explicit = (this.explicit || []).concat(explicit);
3855
+ result.compiledImplicit = compileList(result, "implicit");
3856
+ result.compiledExplicit = compileList(result, "explicit");
3857
+ result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
3858
+ return result;
3859
+ };
3860
+ var schema = Schema$1;
3861
+ var str = new type("tag:yaml.org,2002:str", {
3862
+ kind: "scalar",
3863
+ construct: function(data) {
3864
+ return data !== null ? data : "";
3865
+ }
3866
+ });
3867
+ var seq = new type("tag:yaml.org,2002:seq", {
3868
+ kind: "sequence",
3869
+ construct: function(data) {
3870
+ return data !== null ? data : [];
3871
+ }
3872
+ });
3873
+ var map = new type("tag:yaml.org,2002:map", {
3874
+ kind: "mapping",
3875
+ construct: function(data) {
3876
+ return data !== null ? data : {};
3877
+ }
3878
+ });
3879
+ var failsafe = new schema({
3880
+ explicit: [
3881
+ str,
3882
+ seq,
3883
+ map
3884
+ ]
3885
+ });
3886
+ function resolveYamlNull(data) {
3887
+ if (data === null) return true;
3888
+ var max = data.length;
3889
+ return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
3890
+ }
3891
+ function constructYamlNull() {
3892
+ return null;
3893
+ }
3894
+ function isNull(object) {
3895
+ return object === null;
3896
+ }
3897
+ var _null = new type("tag:yaml.org,2002:null", {
3898
+ kind: "scalar",
3899
+ resolve: resolveYamlNull,
3900
+ construct: constructYamlNull,
3901
+ predicate: isNull,
3902
+ represent: {
3903
+ canonical: function() {
3904
+ return "~";
3905
+ },
3906
+ lowercase: function() {
3907
+ return "null";
3908
+ },
3909
+ uppercase: function() {
3910
+ return "NULL";
3911
+ },
3912
+ camelcase: function() {
3913
+ return "Null";
3914
+ },
3915
+ empty: function() {
3916
+ return "";
3917
+ }
3918
+ },
3919
+ defaultStyle: "lowercase"
3920
+ });
3921
+ function resolveYamlBoolean(data) {
3922
+ if (data === null) return false;
3923
+ var max = data.length;
3924
+ return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
3925
+ }
3926
+ function constructYamlBoolean(data) {
3927
+ return data === "true" || data === "True" || data === "TRUE";
3928
+ }
3929
+ function isBoolean(object) {
3930
+ return Object.prototype.toString.call(object) === "[object Boolean]";
3931
+ }
3932
+ var bool = new type("tag:yaml.org,2002:bool", {
3933
+ kind: "scalar",
3934
+ resolve: resolveYamlBoolean,
3935
+ construct: constructYamlBoolean,
3936
+ predicate: isBoolean,
3937
+ represent: {
3938
+ lowercase: function(object) {
3939
+ return object ? "true" : "false";
3940
+ },
3941
+ uppercase: function(object) {
3942
+ return object ? "TRUE" : "FALSE";
3943
+ },
3944
+ camelcase: function(object) {
3945
+ return object ? "True" : "False";
3946
+ }
3947
+ },
3948
+ defaultStyle: "lowercase"
3949
+ });
3950
+ function isHexCode(c) {
3951
+ return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
3952
+ }
3953
+ function isOctCode(c) {
3954
+ return 48 <= c && c <= 55;
3955
+ }
3956
+ function isDecCode(c) {
3957
+ return 48 <= c && c <= 57;
3958
+ }
3959
+ function resolveYamlInteger(data) {
3960
+ if (data === null) return false;
3961
+ var max = data.length, index = 0, hasDigits = false, ch;
3962
+ if (!max) return false;
3963
+ ch = data[index];
3964
+ if (ch === "-" || ch === "+") {
3965
+ ch = data[++index];
19
3966
  }
20
- const componentDir = dirname(context.filename);
21
- const files = getFilesInDirectory(componentDir);
22
- const namedMetadataFile = files.find((file) => file.endsWith(NAMED_SUFFIX));
23
- const componentBaseName = namedMetadataFile ? namedMetadataFile.slice(0, -NAMED_SUFFIX.length) : "index";
24
- return JS_EXTENSIONS.some(
25
- (ext) => basename(context.filename) === componentBaseName + "." + ext
26
- );
3967
+ if (ch === "0") {
3968
+ if (index + 1 === max) return true;
3969
+ ch = data[++index];
3970
+ if (ch === "b") {
3971
+ index++;
3972
+ for (; index < max; index++) {
3973
+ ch = data[index];
3974
+ if (ch === "_") continue;
3975
+ if (ch !== "0" && ch !== "1") return false;
3976
+ hasDigits = true;
3977
+ }
3978
+ return hasDigits && ch !== "_";
3979
+ }
3980
+ if (ch === "x") {
3981
+ index++;
3982
+ for (; index < max; index++) {
3983
+ ch = data[index];
3984
+ if (ch === "_") continue;
3985
+ if (!isHexCode(data.charCodeAt(index))) return false;
3986
+ hasDigits = true;
3987
+ }
3988
+ return hasDigits && ch !== "_";
3989
+ }
3990
+ if (ch === "o") {
3991
+ index++;
3992
+ for (; index < max; index++) {
3993
+ ch = data[index];
3994
+ if (ch === "_") continue;
3995
+ if (!isOctCode(data.charCodeAt(index))) return false;
3996
+ hasDigits = true;
3997
+ }
3998
+ return hasDigits && ch !== "_";
3999
+ }
4000
+ }
4001
+ if (ch === "_") return false;
4002
+ for (; index < max; index++) {
4003
+ ch = data[index];
4004
+ if (ch === "_") continue;
4005
+ if (!isDecCode(data.charCodeAt(index))) {
4006
+ return false;
4007
+ }
4008
+ hasDigits = true;
4009
+ }
4010
+ if (!hasDigits || ch === "_") return false;
4011
+ return true;
27
4012
  }
28
- function isInComponentDir(context) {
29
- try {
30
- const componentDir = dirname(context.filename);
31
- const files = getFilesInDirectory(componentDir);
32
- return files.filter(
33
- (file) => basename(file) === "component.yml" || file.endsWith(NAMED_SUFFIX)
34
- ).length > 0;
35
- } catch {
36
- return false;
4013
+ function constructYamlInteger(data) {
4014
+ var value = data, sign = 1, ch;
4015
+ if (value.indexOf("_") !== -1) {
4016
+ value = value.replace(/_/g, "");
37
4017
  }
4018
+ ch = value[0];
4019
+ if (ch === "-" || ch === "+") {
4020
+ if (ch === "-") sign = -1;
4021
+ value = value.slice(1);
4022
+ ch = value[0];
4023
+ }
4024
+ if (value === "0") return 0;
4025
+ if (ch === "0") {
4026
+ if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
4027
+ if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
4028
+ if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
4029
+ }
4030
+ return sign * parseInt(value, 10);
38
4031
  }
39
- function isComponentYmlFile(context) {
40
- try {
41
- const fileName = basename(context.filename);
42
- return fileName === "component.yml" || fileName.endsWith(NAMED_SUFFIX);
43
- } catch {
4032
+ function isInteger(object) {
4033
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
4034
+ }
4035
+ var int = new type("tag:yaml.org,2002:int", {
4036
+ kind: "scalar",
4037
+ resolve: resolveYamlInteger,
4038
+ construct: constructYamlInteger,
4039
+ predicate: isInteger,
4040
+ represent: {
4041
+ binary: function(obj) {
4042
+ return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
4043
+ },
4044
+ octal: function(obj) {
4045
+ return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
4046
+ },
4047
+ decimal: function(obj) {
4048
+ return obj.toString(10);
4049
+ },
4050
+ /* eslint-disable max-len */
4051
+ hexadecimal: function(obj) {
4052
+ return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
4053
+ }
4054
+ },
4055
+ defaultStyle: "decimal",
4056
+ styleAliases: {
4057
+ binary: [2, "bin"],
4058
+ octal: [8, "oct"],
4059
+ decimal: [10, "dec"],
4060
+ hexadecimal: [16, "hex"]
4061
+ }
4062
+ });
4063
+ var YAML_FLOAT_PATTERN = new RegExp(
4064
+ // 2.5e4, 2.5 and integers
4065
+ "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
4066
+ );
4067
+ function resolveYamlFloat(data) {
4068
+ if (data === null) return false;
4069
+ if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
4070
+ // Probably should update regexp & check speed
4071
+ data[data.length - 1] === "_") {
44
4072
  return false;
45
4073
  }
4074
+ return true;
46
4075
  }
47
- function getFilesInDirectory(dirPath) {
48
- if (!existsSync(dirPath)) {
49
- return [];
4076
+ function constructYamlFloat(data) {
4077
+ var value, sign;
4078
+ value = data.replace(/_/g, "").toLowerCase();
4079
+ sign = value[0] === "-" ? -1 : 1;
4080
+ if ("+-".indexOf(value[0]) >= 0) {
4081
+ value = value.slice(1);
50
4082
  }
51
- try {
52
- return readdirSync(dirPath);
53
- } catch {
54
- return [];
4083
+ if (value === ".inf") {
4084
+ return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
4085
+ } else if (value === ".nan") {
4086
+ return NaN;
55
4087
  }
4088
+ return sign * parseFloat(value, 10);
56
4089
  }
57
-
58
- // src/utils/yaml.ts
59
- function getYAMLStringValue(node) {
60
- if (node && node.type === "YAMLScalar" && typeof node.value === "string") {
61
- return node.value;
4090
+ var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
4091
+ function representYamlFloat(object, style) {
4092
+ var res;
4093
+ if (isNaN(object)) {
4094
+ switch (style) {
4095
+ case "lowercase":
4096
+ return ".nan";
4097
+ case "uppercase":
4098
+ return ".NAN";
4099
+ case "camelcase":
4100
+ return ".NaN";
4101
+ }
4102
+ } else if (Number.POSITIVE_INFINITY === object) {
4103
+ switch (style) {
4104
+ case "lowercase":
4105
+ return ".inf";
4106
+ case "uppercase":
4107
+ return ".INF";
4108
+ case "camelcase":
4109
+ return ".Inf";
4110
+ }
4111
+ } else if (Number.NEGATIVE_INFINITY === object) {
4112
+ switch (style) {
4113
+ case "lowercase":
4114
+ return "-.inf";
4115
+ case "uppercase":
4116
+ return "-.INF";
4117
+ case "camelcase":
4118
+ return "-.Inf";
4119
+ }
4120
+ } else if (common.isNegativeZero(object)) {
4121
+ return "-0.0";
62
4122
  }
63
- return null;
4123
+ res = object.toString(10);
4124
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
64
4125
  }
65
-
66
- // src/rules/component-dir-name.ts
67
- var NAMED_SUFFIX2 = ".component.yml";
68
- function getExpectedMachineName(filename) {
69
- const fileName = basename(filename);
70
- if (fileName !== "component.yml" && fileName.endsWith(NAMED_SUFFIX2)) {
71
- return {
72
- name: fileName.slice(0, -NAMED_SUFFIX2.length),
73
- source: `metadata filename "${fileName}"`
74
- };
4126
+ function isFloat(object) {
4127
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
4128
+ }
4129
+ var float = new type("tag:yaml.org,2002:float", {
4130
+ kind: "scalar",
4131
+ resolve: resolveYamlFloat,
4132
+ construct: constructYamlFloat,
4133
+ predicate: isFloat,
4134
+ represent: representYamlFloat,
4135
+ defaultStyle: "lowercase"
4136
+ });
4137
+ var json = failsafe.extend({
4138
+ implicit: [
4139
+ _null,
4140
+ bool,
4141
+ int,
4142
+ float
4143
+ ]
4144
+ });
4145
+ var core = json;
4146
+ var YAML_DATE_REGEXP = new RegExp(
4147
+ "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
4148
+ );
4149
+ var YAML_TIMESTAMP_REGEXP = new RegExp(
4150
+ "^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"
4151
+ );
4152
+ function resolveYamlTimestamp(data) {
4153
+ if (data === null) return false;
4154
+ if (YAML_DATE_REGEXP.exec(data) !== null) return true;
4155
+ if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
4156
+ return false;
4157
+ }
4158
+ function constructYamlTimestamp(data) {
4159
+ var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
4160
+ match = YAML_DATE_REGEXP.exec(data);
4161
+ if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
4162
+ if (match === null) throw new Error("Date resolve error");
4163
+ year = +match[1];
4164
+ month = +match[2] - 1;
4165
+ day = +match[3];
4166
+ if (!match[4]) {
4167
+ return new Date(Date.UTC(year, month, day));
75
4168
  }
76
- const dirName = basename(dirname(filename));
77
- return { name: dirName, source: `directory name "${dirName}"` };
4169
+ hour = +match[4];
4170
+ minute = +match[5];
4171
+ second = +match[6];
4172
+ if (match[7]) {
4173
+ fraction = match[7].slice(0, 3);
4174
+ while (fraction.length < 3) {
4175
+ fraction += "0";
4176
+ }
4177
+ fraction = +fraction;
4178
+ }
4179
+ if (match[9]) {
4180
+ tz_hour = +match[10];
4181
+ tz_minute = +(match[11] || 0);
4182
+ delta = (tz_hour * 60 + tz_minute) * 6e4;
4183
+ if (match[9] === "-") delta = -delta;
4184
+ }
4185
+ date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
4186
+ if (delta) date.setTime(date.getTime() - delta);
4187
+ return date;
78
4188
  }
79
- var rule = {
80
- meta: {
81
- type: "problem",
82
- docs: {
83
- description: "Validates that the machineName in component metadata matches the component directory name (index-style) or filename prefix (named-style)"
4189
+ function representYamlTimestamp(object) {
4190
+ return object.toISOString();
4191
+ }
4192
+ var timestamp = new type("tag:yaml.org,2002:timestamp", {
4193
+ kind: "scalar",
4194
+ resolve: resolveYamlTimestamp,
4195
+ construct: constructYamlTimestamp,
4196
+ instanceOf: Date,
4197
+ represent: representYamlTimestamp
4198
+ });
4199
+ function resolveYamlMerge(data) {
4200
+ return data === "<<" || data === null;
4201
+ }
4202
+ var merge = new type("tag:yaml.org,2002:merge", {
4203
+ kind: "scalar",
4204
+ resolve: resolveYamlMerge
4205
+ });
4206
+ var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
4207
+ function resolveYamlBinary(data) {
4208
+ if (data === null) return false;
4209
+ var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
4210
+ for (idx = 0; idx < max; idx++) {
4211
+ code = map2.indexOf(data.charAt(idx));
4212
+ if (code > 64) continue;
4213
+ if (code < 0) return false;
4214
+ bitlen += 6;
4215
+ }
4216
+ return bitlen % 8 === 0;
4217
+ }
4218
+ function constructYamlBinary(data) {
4219
+ var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
4220
+ for (idx = 0; idx < max; idx++) {
4221
+ if (idx % 4 === 0 && idx) {
4222
+ result.push(bits >> 16 & 255);
4223
+ result.push(bits >> 8 & 255);
4224
+ result.push(bits & 255);
84
4225
  }
85
- },
86
- create(context) {
87
- if (!isComponentYmlFile(context)) {
88
- return {};
4226
+ bits = bits << 6 | map2.indexOf(input.charAt(idx));
4227
+ }
4228
+ tailbits = max % 4 * 6;
4229
+ if (tailbits === 0) {
4230
+ result.push(bits >> 16 & 255);
4231
+ result.push(bits >> 8 & 255);
4232
+ result.push(bits & 255);
4233
+ } else if (tailbits === 18) {
4234
+ result.push(bits >> 10 & 255);
4235
+ result.push(bits >> 2 & 255);
4236
+ } else if (tailbits === 12) {
4237
+ result.push(bits >> 4 & 255);
4238
+ }
4239
+ return new Uint8Array(result);
4240
+ }
4241
+ function representYamlBinary(object) {
4242
+ var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
4243
+ for (idx = 0; idx < max; idx++) {
4244
+ if (idx % 3 === 0 && idx) {
4245
+ result += map2[bits >> 18 & 63];
4246
+ result += map2[bits >> 12 & 63];
4247
+ result += map2[bits >> 6 & 63];
4248
+ result += map2[bits & 63];
89
4249
  }
90
- let hasMachineName = false;
91
- const { name: expectedName, source: expectedSource } = getExpectedMachineName(context.filename);
4250
+ bits = (bits << 8) + object[idx];
4251
+ }
4252
+ tail = max % 3;
4253
+ if (tail === 0) {
4254
+ result += map2[bits >> 18 & 63];
4255
+ result += map2[bits >> 12 & 63];
4256
+ result += map2[bits >> 6 & 63];
4257
+ result += map2[bits & 63];
4258
+ } else if (tail === 2) {
4259
+ result += map2[bits >> 10 & 63];
4260
+ result += map2[bits >> 4 & 63];
4261
+ result += map2[bits << 2 & 63];
4262
+ result += map2[64];
4263
+ } else if (tail === 1) {
4264
+ result += map2[bits >> 2 & 63];
4265
+ result += map2[bits << 4 & 63];
4266
+ result += map2[64];
4267
+ result += map2[64];
4268
+ }
4269
+ return result;
4270
+ }
4271
+ function isBinary(obj) {
4272
+ return Object.prototype.toString.call(obj) === "[object Uint8Array]";
4273
+ }
4274
+ var binary = new type("tag:yaml.org,2002:binary", {
4275
+ kind: "scalar",
4276
+ resolve: resolveYamlBinary,
4277
+ construct: constructYamlBinary,
4278
+ predicate: isBinary,
4279
+ represent: representYamlBinary
4280
+ });
4281
+ var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
4282
+ var _toString$2 = Object.prototype.toString;
4283
+ function resolveYamlOmap(data) {
4284
+ if (data === null) return true;
4285
+ var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
4286
+ for (index = 0, length = object.length; index < length; index += 1) {
4287
+ pair = object[index];
4288
+ pairHasKey = false;
4289
+ if (_toString$2.call(pair) !== "[object Object]") return false;
4290
+ for (pairKey in pair) {
4291
+ if (_hasOwnProperty$3.call(pair, pairKey)) {
4292
+ if (!pairHasKey) pairHasKey = true;
4293
+ else return false;
4294
+ }
4295
+ }
4296
+ if (!pairHasKey) return false;
4297
+ if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
4298
+ else return false;
4299
+ }
4300
+ return true;
4301
+ }
4302
+ function constructYamlOmap(data) {
4303
+ return data !== null ? data : [];
4304
+ }
4305
+ var omap = new type("tag:yaml.org,2002:omap", {
4306
+ kind: "sequence",
4307
+ resolve: resolveYamlOmap,
4308
+ construct: constructYamlOmap
4309
+ });
4310
+ var _toString$1 = Object.prototype.toString;
4311
+ function resolveYamlPairs(data) {
4312
+ if (data === null) return true;
4313
+ var index, length, pair, keys, result, object = data;
4314
+ result = new Array(object.length);
4315
+ for (index = 0, length = object.length; index < length; index += 1) {
4316
+ pair = object[index];
4317
+ if (_toString$1.call(pair) !== "[object Object]") return false;
4318
+ keys = Object.keys(pair);
4319
+ if (keys.length !== 1) return false;
4320
+ result[index] = [keys[0], pair[keys[0]]];
4321
+ }
4322
+ return true;
4323
+ }
4324
+ function constructYamlPairs(data) {
4325
+ if (data === null) return [];
4326
+ var index, length, pair, keys, result, object = data;
4327
+ result = new Array(object.length);
4328
+ for (index = 0, length = object.length; index < length; index += 1) {
4329
+ pair = object[index];
4330
+ keys = Object.keys(pair);
4331
+ result[index] = [keys[0], pair[keys[0]]];
4332
+ }
4333
+ return result;
4334
+ }
4335
+ var pairs = new type("tag:yaml.org,2002:pairs", {
4336
+ kind: "sequence",
4337
+ resolve: resolveYamlPairs,
4338
+ construct: constructYamlPairs
4339
+ });
4340
+ var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
4341
+ function resolveYamlSet(data) {
4342
+ if (data === null) return true;
4343
+ var key, object = data;
4344
+ for (key in object) {
4345
+ if (_hasOwnProperty$2.call(object, key)) {
4346
+ if (object[key] !== null) return false;
4347
+ }
4348
+ }
4349
+ return true;
4350
+ }
4351
+ function constructYamlSet(data) {
4352
+ return data !== null ? data : {};
4353
+ }
4354
+ var set = new type("tag:yaml.org,2002:set", {
4355
+ kind: "mapping",
4356
+ resolve: resolveYamlSet,
4357
+ construct: constructYamlSet
4358
+ });
4359
+ core.extend({
4360
+ implicit: [
4361
+ timestamp,
4362
+ merge
4363
+ ],
4364
+ explicit: [
4365
+ binary,
4366
+ omap,
4367
+ pairs,
4368
+ set
4369
+ ]
4370
+ });
4371
+ function simpleEscapeSequence(c) {
4372
+ return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
4373
+ }
4374
+ var simpleEscapeCheck = new Array(256);
4375
+ var simpleEscapeMap = new Array(256);
4376
+ for (i = 0; i < 256; i++) {
4377
+ simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
4378
+ simpleEscapeMap[i] = simpleEscapeSequence(i);
4379
+ }
4380
+ var i;
4381
+
4382
+ // ../discovery/src/asset-extensions.ts
4383
+ var IMAGE_EXTENSIONS = [
4384
+ ".jpg",
4385
+ ".jpeg",
4386
+ ".png",
4387
+ ".gif",
4388
+ ".webp",
4389
+ ".avif",
4390
+ ".ico"
4391
+ ];
4392
+ var SVG_EXTENSIONS = [".svg"];
4393
+ var AUDIO_EXTENSIONS = [
4394
+ ".mp3",
4395
+ ".wav",
4396
+ ".ogg",
4397
+ ".flac",
4398
+ ".aac",
4399
+ ".m4a"
4400
+ ];
4401
+ var VIDEO_EXTENSIONS = [".mp4", ".webm", ".mov", ".avi"];
4402
+ var FONT_EXTENSIONS = [
4403
+ ".woff",
4404
+ ".woff2",
4405
+ ".ttf",
4406
+ ".otf",
4407
+ ".eot"
4408
+ ];
4409
+ var ASSET_EXTENSIONS = [
4410
+ ...IMAGE_EXTENSIONS,
4411
+ ...SVG_EXTENSIONS,
4412
+ ...AUDIO_EXTENSIONS,
4413
+ ...VIDEO_EXTENSIONS,
4414
+ ...FONT_EXTENSIONS
4415
+ ];
4416
+ function resolveCanvasConfig(options) {
4417
+ const DEFAULT_CANVAS_CONFIG = {
4418
+ aliasBaseDir: "src",
4419
+ outputDir: "dist",
4420
+ componentDir: options.hostRoot,
4421
+ pagesDir: "./pages",
4422
+ deprecatedComponentDir: "./components",
4423
+ globalCssPath: "./src/components/global.css"
4424
+ };
4425
+ const configPath = resolve(options.hostRoot, "canvas.config.json");
4426
+ if (!existsSync(configPath)) {
4427
+ return { ...DEFAULT_CANVAS_CONFIG };
4428
+ }
4429
+ try {
4430
+ const raw = readFileSync(configPath, "utf-8");
4431
+ const parsed = JSON.parse(raw);
92
4432
  return {
93
- YAMLPair(node) {
94
- const keyName = getYAMLStringValue(node.key);
95
- if (keyName !== "machineName") {
96
- return;
97
- }
98
- hasMachineName = true;
99
- const machineName = getYAMLStringValue(node.value);
100
- if (!node.value || !machineName) {
101
- context.report({
4433
+ aliasBaseDir: parsed.aliasBaseDir ?? DEFAULT_CANVAS_CONFIG.aliasBaseDir,
4434
+ outputDir: parsed.outputDir ?? DEFAULT_CANVAS_CONFIG.outputDir,
4435
+ componentDir: parsed.componentDir ?? DEFAULT_CANVAS_CONFIG.componentDir,
4436
+ pagesDir: parsed.pagesDir ?? DEFAULT_CANVAS_CONFIG.pagesDir,
4437
+ deprecatedComponentDir: parsed.componentDir ?? DEFAULT_CANVAS_CONFIG.deprecatedComponentDir,
4438
+ globalCssPath: parsed.globalCssPath ?? DEFAULT_CANVAS_CONFIG.globalCssPath
4439
+ };
4440
+ } catch {
4441
+ return { ...DEFAULT_CANVAS_CONFIG };
4442
+ }
4443
+ }
4444
+
4445
+ // src/rules/component-imports.ts
4446
+ function checkImportSource(context, node, source) {
4447
+ if (source.startsWith("@fontsource")) {
4448
+ context.report({
4449
+ node,
4450
+ message: `Importing font packages ("${source}") is not supported in components. Configure fonts in the Brand kit instead.`
4451
+ });
4452
+ return;
4453
+ }
4454
+ if (ASSET_EXTENSIONS.some((ext) => source.endsWith(ext))) {
4455
+ context.report({
4456
+ node,
4457
+ message: `Importing asset files ("${source}") is not supported in components.`
4458
+ });
4459
+ return;
4460
+ }
4461
+ if (source.endsWith(".css") || /\/css(\/|$)/.test(source)) {
4462
+ context.report({
4463
+ node,
4464
+ message: `CSS side-effect imports are not supported in components. Remove "${source}" and use the component's CSS file instead.`
4465
+ });
4466
+ return;
4467
+ }
4468
+ if (source.startsWith("./") || source.startsWith("../")) {
4469
+ context.report({
4470
+ node,
4471
+ message: `Relative imports are not supported. Use '@/...' alias instead of '${source}' to import other components or helpers/utilities from shared locations outside component dir.`
4472
+ });
4473
+ return;
4474
+ }
4475
+ if (source === "next-image-standalone") {
4476
+ context.report({
4477
+ node,
4478
+ message: "Using `next-image-standalone` directly is deprecated. Use the `Image` component from the `drupal-canvas` package instead.",
4479
+ fix(fixer) {
4480
+ if (node.type === "ImportDeclaration" && node.specifiers.length === 1 && node.specifiers[0].local.name === "Image") {
4481
+ return fixer.replaceText(
102
4482
  node,
103
- message: "machineName must be a string."
104
- });
105
- return;
4483
+ "import { Image } from 'drupal-canvas';"
4484
+ );
106
4485
  }
107
- if (expectedName !== machineName) {
4486
+ return null;
4487
+ }
4488
+ });
4489
+ return;
4490
+ }
4491
+ if (source === "@drupal-api-client/json-api-client") {
4492
+ if (node.type === "ImportDeclaration") {
4493
+ for (const specifier of node.specifiers) {
4494
+ if (specifier.local.name === "JsonApiClient") {
108
4495
  context.report({
109
- node: node.value,
110
- message: `${expectedSource[0].toUpperCase()}${expectedSource.slice(1)} does not match machineName "${machineName}".`
4496
+ node: specifier.local,
4497
+ message: "The preconfigured `JsonApiClient` was moved into the `drupal-canvas` package.",
4498
+ fix(fixer) {
4499
+ return fixer.replaceText(node.source, "'drupal-canvas'");
4500
+ }
111
4501
  });
4502
+ return;
112
4503
  }
113
- },
114
- "Program:exit"() {
115
- if (!hasMachineName) {
116
- context.report({
117
- loc: { line: 1, column: 0 },
118
- message: `machineName key is missing. Its value should be "${expectedName}" based on ${expectedSource.toLowerCase()}.`
119
- });
4504
+ }
4505
+ }
4506
+ return;
4507
+ }
4508
+ if (source === "@/lib/FormattedText") {
4509
+ context.report({
4510
+ node,
4511
+ message: "The `FormattedText` component was moved into the `drupal-canvas` package.",
4512
+ fix(fixer) {
4513
+ if (node.type === "ImportDeclaration" && node.specifiers.length === 1 && node.specifiers[0].local.name === "FormattedText") {
4514
+ return fixer.replaceText(
4515
+ node,
4516
+ "import { FormattedText } from 'drupal-canvas';"
4517
+ );
120
4518
  }
4519
+ return null;
121
4520
  }
122
- };
4521
+ });
4522
+ return;
123
4523
  }
124
- };
125
- var component_dir_name_default = rule;
126
-
127
- // src/rules/component-exports.ts
128
- var rule2 = {
4524
+ if (source.startsWith("@/")) {
4525
+ const suffix = source.slice(2);
4526
+ const config = resolveCanvasConfig({ hostRoot: context.cwd });
4527
+ const aliasBase = resolve(context.cwd, config.aliasBaseDir);
4528
+ const resolvedPath = resolve(aliasBase, suffix);
4529
+ if (isNonComponentImportFromComponentDir(resolvedPath, aliasBase)) {
4530
+ context.report({
4531
+ node,
4532
+ message: `Importing "${source}" from a component directory is not supported. Use "@/" alias to import other components or helpers/utilities from shared locations outside component directories.`
4533
+ });
4534
+ return;
4535
+ }
4536
+ return;
4537
+ }
4538
+ }
4539
+ var rule3 = {
129
4540
  meta: {
130
4541
  type: "problem",
131
4542
  docs: {
132
- description: "Validates that component has a default export"
133
- }
4543
+ description: "Validates that component imports only from supported import sources and patterns"
4544
+ },
4545
+ fixable: "code"
134
4546
  },
135
4547
  create(context) {
136
- if (!isComponentEntrypoint(context)) {
4548
+ if (!isComponentDir(dirname(context.filename))) {
137
4549
  return {};
138
4550
  }
139
- let hasDefaultExport = false;
140
4551
  return {
141
- ExportDefaultDeclaration() {
142
- hasDefaultExport = true;
4552
+ ImportDeclaration(node) {
4553
+ if (node.source && typeof node.source.value === "string") {
4554
+ checkImportSource(context, node, node.source.value);
4555
+ }
143
4556
  },
144
- "Program:exit"(node) {
145
- if (!hasDefaultExport) {
146
- context.report({
147
- node,
148
- message: "Component must have a default export"
149
- });
4557
+ ImportExpression(node) {
4558
+ if (node.source.type === "Literal" && typeof node.source.value === "string") {
4559
+ checkImportSource(context, node, node.source.value);
150
4560
  }
151
4561
  }
152
4562
  };
153
4563
  }
154
4564
  };
155
- var component_exports_default = rule2;
4565
+ var component_imports_default = rule3;
156
4566
  function extractProps(propsNode) {
157
4567
  if (!propsNode.value || propsNode.value.type !== "YAMLMapping") {
158
4568
  return [];
@@ -186,7 +4596,7 @@ function extractProps(propsNode) {
186
4596
  }
187
4597
  return props;
188
4598
  }
189
- var rule3 = {
4599
+ var rule4 = {
190
4600
  meta: {
191
4601
  type: "problem",
192
4602
  docs: {
@@ -194,7 +4604,7 @@ var rule3 = {
194
4604
  }
195
4605
  },
196
4606
  create(context) {
197
- if (!isComponentYmlFile(context)) {
4607
+ if (!isComponentYmlFile(context.filename)) {
198
4608
  return {};
199
4609
  }
200
4610
  return {
@@ -227,7 +4637,7 @@ var rule3 = {
227
4637
  };
228
4638
  }
229
4639
  };
230
- var component_prop_names_default = rule3;
4640
+ var component_prop_names_default = rule4;
231
4641
 
232
4642
  // src/configs/required.ts
233
4643
  var required = defineConfig([
@@ -253,6 +4663,7 @@ var required = defineConfig([
253
4663
  rules: {
254
4664
  "component-dir-name": component_dir_name_default,
255
4665
  "component-exports": component_exports_default,
4666
+ "component-imports": component_imports_default,
256
4667
  "component-prop-names": component_prop_names_default
257
4668
  }
258
4669
  }
@@ -260,6 +4671,7 @@ var required = defineConfig([
260
4671
  rules: {
261
4672
  "drupal-canvas/component-dir-name": "error",
262
4673
  "drupal-canvas/component-exports": "error",
4674
+ "drupal-canvas/component-imports": "error",
263
4675
  "drupal-canvas/component-prop-names": "error"
264
4676
  }
265
4677
  }
@@ -284,7 +4696,7 @@ var recommended = defineConfig([
284
4696
  }
285
4697
  },
286
4698
  rules: {
287
- ...js.configs.recommended.rules,
4699
+ ...js2.configs.recommended.rules,
288
4700
  ...react.configs.recommended.rules,
289
4701
  ...react.configs["jsx-runtime"].rules,
290
4702
  ...reactHooks.configs.recommended.rules,
@@ -306,7 +4718,7 @@ var IGNORED_FILES = [
306
4718
  function isFileAllowed(fileName, allowedFiles) {
307
4719
  return allowedFiles.some((allowedFile) => allowedFile === fileName);
308
4720
  }
309
- var rule4 = {
4721
+ var rule5 = {
310
4722
  meta: {
311
4723
  type: "problem",
312
4724
  docs: {
@@ -315,7 +4727,7 @@ var rule4 = {
315
4727
  deprecated: true
316
4728
  },
317
4729
  create(context) {
318
- if (!isComponentYmlFile(context)) {
4730
+ if (!isComponentYmlFile(context.filename)) {
319
4731
  return {};
320
4732
  }
321
4733
  return {
@@ -345,10 +4757,8 @@ var rule4 = {
345
4757
  };
346
4758
  }
347
4759
  };
348
- var component_files_default = rule4;
349
-
350
- // src/rules/component-imports.ts
351
- function checkImportSource(context, node, source) {
4760
+ var component_files_default = rule5;
4761
+ function checkImportSource2(context, node, source) {
352
4762
  if (source.startsWith("./") || source.startsWith("../")) {
353
4763
  context.report({
354
4764
  node,
@@ -476,7 +4886,7 @@ function checkImportSource(context, node, source) {
476
4886
  message: `Importing "${source}" is not supported. If this is a local import via a path alias, use the "@/components/" alias instead. If you are importing a third-party package, see the list of supported packages at https://project.pages.drupalcode.org/canvas/code-components/packages. (The status of supporting any third-party package can be tracked at https://drupal.org/i/3560197.)`
477
4887
  });
478
4888
  }
479
- var rule5 = {
4889
+ var rule6 = {
480
4890
  meta: {
481
4891
  type: "problem",
482
4892
  docs: {
@@ -486,24 +4896,24 @@ var rule5 = {
486
4896
  deprecated: true
487
4897
  },
488
4898
  create(context) {
489
- if (!isInComponentDir(context)) {
4899
+ if (!isComponentDir(dirname(context.filename))) {
490
4900
  return {};
491
4901
  }
492
4902
  return {
493
4903
  ImportDeclaration(node) {
494
4904
  if (node.source && typeof node.source.value === "string") {
495
- checkImportSource(context, node, node.source.value);
4905
+ checkImportSource2(context, node, node.source.value);
496
4906
  }
497
4907
  },
498
4908
  ImportExpression(node) {
499
4909
  if (node.source.type === "Literal" && typeof node.source.value === "string") {
500
- checkImportSource(context, node, node.source.value);
4910
+ checkImportSource2(context, node, node.source.value);
501
4911
  }
502
4912
  }
503
4913
  };
504
4914
  }
505
4915
  };
506
- var component_imports_default = rule5;
4916
+ var component_imports_deprecated_default = rule6;
507
4917
  function findTopmostComponentsParentDir(currentParentDir, rootDir) {
508
4918
  if (currentParentDir === rootDir) {
509
4919
  return currentParentDir;
@@ -524,7 +4934,7 @@ function hasComponentSubdirectories(dirPath) {
524
4934
  }
525
4935
  return false;
526
4936
  }
527
- var rule6 = {
4937
+ var rule7 = {
528
4938
  meta: {
529
4939
  type: "problem",
530
4940
  docs: {
@@ -533,7 +4943,7 @@ var rule6 = {
533
4943
  deprecated: true
534
4944
  },
535
4945
  create(context) {
536
- if (!isComponentYmlFile(context)) {
4946
+ if (!isComponentYmlFile(context.filename)) {
537
4947
  return {};
538
4948
  }
539
4949
  return {
@@ -559,7 +4969,7 @@ var rule6 = {
559
4969
  };
560
4970
  }
561
4971
  };
562
- var component_no_hierarchy_default = rule6;
4972
+ var component_no_hierarchy_default = rule7;
563
4973
 
564
4974
  // src/configs/requiredDeprecated.ts
565
4975
  var required2 = defineConfig([
@@ -585,7 +4995,7 @@ var required2 = defineConfig([
585
4995
  "component-dir-name": component_dir_name_default,
586
4996
  "component-exports": component_exports_default,
587
4997
  "component-files": component_files_default,
588
- "component-imports": component_imports_default,
4998
+ "component-imports": component_imports_deprecated_default,
589
4999
  "component-no-hierarchy": component_no_hierarchy_default,
590
5000
  "component-prop-names": component_prop_names_default
591
5001
  }
@@ -613,5 +5023,10 @@ var strict = defineConfig([
613
5023
  ...tseslint.configs.strict
614
5024
  ]);
615
5025
  var strict_default = strict;
5026
+ /*! Bundled license information:
5027
+
5028
+ js-yaml/dist/js-yaml.mjs:
5029
+ (*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT *)
5030
+ */
616
5031
 
617
5032
  export { recommended_default as recommended, required_default as required, requiredDeprecated_default as requiredDeprecated, strict_default as strict };