@tscircuit/cli 0.1.777 → 0.1.779

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2746 @@
1
+ import { createRequire } from "node:module";
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
18
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
+
21
+ // node_modules/make-vfs/dist/index.js
22
+ var require_dist = __commonJS((exports, module) => {
23
+ var __create2 = Object.create;
24
+ var __defProp2 = Object.defineProperty;
25
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
26
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
27
+ var __getProtoOf2 = Object.getPrototypeOf;
28
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
29
+ var __commonJS2 = (cb, mod) => function __require() {
30
+ return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
31
+ };
32
+ var __export = (target, all) => {
33
+ for (var name in all)
34
+ __defProp2(target, name, { get: all[name], enumerable: true });
35
+ };
36
+ var __copyProps = (to, from, except, desc) => {
37
+ if (from && typeof from === "object" || typeof from === "function") {
38
+ for (let key of __getOwnPropNames2(from))
39
+ if (!__hasOwnProp2.call(to, key) && key !== except)
40
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
41
+ }
42
+ return to;
43
+ };
44
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, mod));
45
+ var __toCommonJS = (mod) => __copyProps(__defProp2({}, "__esModule", { value: true }), mod);
46
+ var require_old = __commonJS2({
47
+ "node_modules/fs.realpath/old.js"(exports2) {
48
+ var pathModule = __require("path");
49
+ var isWindows = process.platform === "win32";
50
+ var fs2 = __require("fs");
51
+ var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
52
+ function rethrow() {
53
+ var callback;
54
+ if (DEBUG) {
55
+ var backtrace = new Error;
56
+ callback = debugCallback;
57
+ } else
58
+ callback = missingCallback;
59
+ return callback;
60
+ function debugCallback(err) {
61
+ if (err) {
62
+ backtrace.message = err.message;
63
+ err = backtrace;
64
+ missingCallback(err);
65
+ }
66
+ }
67
+ function missingCallback(err) {
68
+ if (err) {
69
+ if (process.throwDeprecation)
70
+ throw err;
71
+ else if (!process.noDeprecation) {
72
+ var msg = "fs: missing callback " + (err.stack || err.message);
73
+ if (process.traceDeprecation)
74
+ console.trace(msg);
75
+ else
76
+ console.error(msg);
77
+ }
78
+ }
79
+ }
80
+ }
81
+ function maybeCallback(cb) {
82
+ return typeof cb === "function" ? cb : rethrow();
83
+ }
84
+ var normalize = pathModule.normalize;
85
+ if (isWindows) {
86
+ nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
87
+ } else {
88
+ nextPartRe = /(.*?)(?:[\/]+|$)/g;
89
+ }
90
+ var nextPartRe;
91
+ if (isWindows) {
92
+ splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
93
+ } else {
94
+ splitRootRe = /^[\/]*/;
95
+ }
96
+ var splitRootRe;
97
+ exports2.realpathSync = function realpathSync(p, cache) {
98
+ p = pathModule.resolve(p);
99
+ if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
100
+ return cache[p];
101
+ }
102
+ var original = p, seenLinks = {}, knownHard = {};
103
+ var pos;
104
+ var current;
105
+ var base;
106
+ var previous;
107
+ start();
108
+ function start() {
109
+ var m = splitRootRe.exec(p);
110
+ pos = m[0].length;
111
+ current = m[0];
112
+ base = m[0];
113
+ previous = "";
114
+ if (isWindows && !knownHard[base]) {
115
+ fs2.lstatSync(base);
116
+ knownHard[base] = true;
117
+ }
118
+ }
119
+ while (pos < p.length) {
120
+ nextPartRe.lastIndex = pos;
121
+ var result = nextPartRe.exec(p);
122
+ previous = current;
123
+ current += result[0];
124
+ base = previous + result[1];
125
+ pos = nextPartRe.lastIndex;
126
+ if (knownHard[base] || cache && cache[base] === base) {
127
+ continue;
128
+ }
129
+ var resolvedLink;
130
+ if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
131
+ resolvedLink = cache[base];
132
+ } else {
133
+ var stat = fs2.lstatSync(base);
134
+ if (!stat.isSymbolicLink()) {
135
+ knownHard[base] = true;
136
+ if (cache)
137
+ cache[base] = base;
138
+ continue;
139
+ }
140
+ var linkTarget = null;
141
+ if (!isWindows) {
142
+ var id = stat.dev.toString(32) + ":" + stat.ino.toString(32);
143
+ if (seenLinks.hasOwnProperty(id)) {
144
+ linkTarget = seenLinks[id];
145
+ }
146
+ }
147
+ if (linkTarget === null) {
148
+ fs2.statSync(base);
149
+ linkTarget = fs2.readlinkSync(base);
150
+ }
151
+ resolvedLink = pathModule.resolve(previous, linkTarget);
152
+ if (cache)
153
+ cache[base] = resolvedLink;
154
+ if (!isWindows)
155
+ seenLinks[id] = linkTarget;
156
+ }
157
+ p = pathModule.resolve(resolvedLink, p.slice(pos));
158
+ start();
159
+ }
160
+ if (cache)
161
+ cache[original] = p;
162
+ return p;
163
+ };
164
+ exports2.realpath = function realpath(p, cache, cb) {
165
+ if (typeof cb !== "function") {
166
+ cb = maybeCallback(cache);
167
+ cache = null;
168
+ }
169
+ p = pathModule.resolve(p);
170
+ if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
171
+ return process.nextTick(cb.bind(null, null, cache[p]));
172
+ }
173
+ var original = p, seenLinks = {}, knownHard = {};
174
+ var pos;
175
+ var current;
176
+ var base;
177
+ var previous;
178
+ start();
179
+ function start() {
180
+ var m = splitRootRe.exec(p);
181
+ pos = m[0].length;
182
+ current = m[0];
183
+ base = m[0];
184
+ previous = "";
185
+ if (isWindows && !knownHard[base]) {
186
+ fs2.lstat(base, function(err) {
187
+ if (err)
188
+ return cb(err);
189
+ knownHard[base] = true;
190
+ LOOP();
191
+ });
192
+ } else {
193
+ process.nextTick(LOOP);
194
+ }
195
+ }
196
+ function LOOP() {
197
+ if (pos >= p.length) {
198
+ if (cache)
199
+ cache[original] = p;
200
+ return cb(null, p);
201
+ }
202
+ nextPartRe.lastIndex = pos;
203
+ var result = nextPartRe.exec(p);
204
+ previous = current;
205
+ current += result[0];
206
+ base = previous + result[1];
207
+ pos = nextPartRe.lastIndex;
208
+ if (knownHard[base] || cache && cache[base] === base) {
209
+ return process.nextTick(LOOP);
210
+ }
211
+ if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
212
+ return gotResolvedLink(cache[base]);
213
+ }
214
+ return fs2.lstat(base, gotStat);
215
+ }
216
+ function gotStat(err, stat) {
217
+ if (err)
218
+ return cb(err);
219
+ if (!stat.isSymbolicLink()) {
220
+ knownHard[base] = true;
221
+ if (cache)
222
+ cache[base] = base;
223
+ return process.nextTick(LOOP);
224
+ }
225
+ if (!isWindows) {
226
+ var id = stat.dev.toString(32) + ":" + stat.ino.toString(32);
227
+ if (seenLinks.hasOwnProperty(id)) {
228
+ return gotTarget(null, seenLinks[id], base);
229
+ }
230
+ }
231
+ fs2.stat(base, function(err2) {
232
+ if (err2)
233
+ return cb(err2);
234
+ fs2.readlink(base, function(err3, target) {
235
+ if (!isWindows)
236
+ seenLinks[id] = target;
237
+ gotTarget(err3, target);
238
+ });
239
+ });
240
+ }
241
+ function gotTarget(err, target, base2) {
242
+ if (err)
243
+ return cb(err);
244
+ var resolvedLink = pathModule.resolve(previous, target);
245
+ if (cache)
246
+ cache[base2] = resolvedLink;
247
+ gotResolvedLink(resolvedLink);
248
+ }
249
+ function gotResolvedLink(resolvedLink) {
250
+ p = pathModule.resolve(resolvedLink, p.slice(pos));
251
+ start();
252
+ }
253
+ };
254
+ }
255
+ });
256
+ var require_fs = __commonJS2({
257
+ "node_modules/fs.realpath/index.js"(exports2, module2) {
258
+ module2.exports = realpath;
259
+ realpath.realpath = realpath;
260
+ realpath.sync = realpathSync;
261
+ realpath.realpathSync = realpathSync;
262
+ realpath.monkeypatch = monkeypatch;
263
+ realpath.unmonkeypatch = unmonkeypatch;
264
+ var fs2 = __require("fs");
265
+ var origRealpath = fs2.realpath;
266
+ var origRealpathSync = fs2.realpathSync;
267
+ var version = process.version;
268
+ var ok = /^v[0-5]\./.test(version);
269
+ var old = require_old();
270
+ function newError(er) {
271
+ return er && er.syscall === "realpath" && (er.code === "ELOOP" || er.code === "ENOMEM" || er.code === "ENAMETOOLONG");
272
+ }
273
+ function realpath(p, cache, cb) {
274
+ if (ok) {
275
+ return origRealpath(p, cache, cb);
276
+ }
277
+ if (typeof cache === "function") {
278
+ cb = cache;
279
+ cache = null;
280
+ }
281
+ origRealpath(p, cache, function(er, result) {
282
+ if (newError(er)) {
283
+ old.realpath(p, cache, cb);
284
+ } else {
285
+ cb(er, result);
286
+ }
287
+ });
288
+ }
289
+ function realpathSync(p, cache) {
290
+ if (ok) {
291
+ return origRealpathSync(p, cache);
292
+ }
293
+ try {
294
+ return origRealpathSync(p, cache);
295
+ } catch (er) {
296
+ if (newError(er)) {
297
+ return old.realpathSync(p, cache);
298
+ } else {
299
+ throw er;
300
+ }
301
+ }
302
+ }
303
+ function monkeypatch() {
304
+ fs2.realpath = realpath;
305
+ fs2.realpathSync = realpathSync;
306
+ }
307
+ function unmonkeypatch() {
308
+ fs2.realpath = origRealpath;
309
+ fs2.realpathSync = origRealpathSync;
310
+ }
311
+ }
312
+ });
313
+ var require_path = __commonJS2({
314
+ "node_modules/minimatch/lib/path.js"(exports2, module2) {
315
+ var isWindows = typeof process === "object" && process && process.platform === "win32";
316
+ module2.exports = isWindows ? { sep: "\\" } : { sep: "/" };
317
+ }
318
+ });
319
+ var require_balanced_match = __commonJS2({
320
+ "node_modules/balanced-match/index.js"(exports2, module2) {
321
+ module2.exports = balanced;
322
+ function balanced(a, b, str) {
323
+ if (a instanceof RegExp)
324
+ a = maybeMatch(a, str);
325
+ if (b instanceof RegExp)
326
+ b = maybeMatch(b, str);
327
+ var r = range(a, b, str);
328
+ return r && {
329
+ start: r[0],
330
+ end: r[1],
331
+ pre: str.slice(0, r[0]),
332
+ body: str.slice(r[0] + a.length, r[1]),
333
+ post: str.slice(r[1] + b.length)
334
+ };
335
+ }
336
+ function maybeMatch(reg, str) {
337
+ var m = str.match(reg);
338
+ return m ? m[0] : null;
339
+ }
340
+ balanced.range = range;
341
+ function range(a, b, str) {
342
+ var begs, beg, left, right, result;
343
+ var ai = str.indexOf(a);
344
+ var bi = str.indexOf(b, ai + 1);
345
+ var i = ai;
346
+ if (ai >= 0 && bi > 0) {
347
+ if (a === b) {
348
+ return [ai, bi];
349
+ }
350
+ begs = [];
351
+ left = str.length;
352
+ while (i >= 0 && !result) {
353
+ if (i == ai) {
354
+ begs.push(i);
355
+ ai = str.indexOf(a, i + 1);
356
+ } else if (begs.length == 1) {
357
+ result = [begs.pop(), bi];
358
+ } else {
359
+ beg = begs.pop();
360
+ if (beg < left) {
361
+ left = beg;
362
+ right = bi;
363
+ }
364
+ bi = str.indexOf(b, i + 1);
365
+ }
366
+ i = ai < bi && ai >= 0 ? ai : bi;
367
+ }
368
+ if (begs.length) {
369
+ result = [left, right];
370
+ }
371
+ }
372
+ return result;
373
+ }
374
+ }
375
+ });
376
+ var require_brace_expansion = __commonJS2({
377
+ "node_modules/brace-expansion/index.js"(exports2, module2) {
378
+ var balanced = require_balanced_match();
379
+ module2.exports = expandTop;
380
+ var escSlash = "\x00SLASH" + Math.random() + "\x00";
381
+ var escOpen = "\x00OPEN" + Math.random() + "\x00";
382
+ var escClose = "\x00CLOSE" + Math.random() + "\x00";
383
+ var escComma = "\x00COMMA" + Math.random() + "\x00";
384
+ var escPeriod = "\x00PERIOD" + Math.random() + "\x00";
385
+ function numeric(str) {
386
+ return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
387
+ }
388
+ function escapeBraces(str) {
389
+ return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
390
+ }
391
+ function unescapeBraces(str) {
392
+ return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
393
+ }
394
+ function parseCommaParts(str) {
395
+ if (!str)
396
+ return [""];
397
+ var parts = [];
398
+ var m = balanced("{", "}", str);
399
+ if (!m)
400
+ return str.split(",");
401
+ var pre = m.pre;
402
+ var body = m.body;
403
+ var post = m.post;
404
+ var p = pre.split(",");
405
+ p[p.length - 1] += "{" + body + "}";
406
+ var postParts = parseCommaParts(post);
407
+ if (post.length) {
408
+ p[p.length - 1] += postParts.shift();
409
+ p.push.apply(p, postParts);
410
+ }
411
+ parts.push.apply(parts, p);
412
+ return parts;
413
+ }
414
+ function expandTop(str) {
415
+ if (!str)
416
+ return [];
417
+ if (str.substr(0, 2) === "{}") {
418
+ str = "\\{\\}" + str.substr(2);
419
+ }
420
+ return expand(escapeBraces(str), true).map(unescapeBraces);
421
+ }
422
+ function embrace(str) {
423
+ return "{" + str + "}";
424
+ }
425
+ function isPadded(el) {
426
+ return /^-?0\d/.test(el);
427
+ }
428
+ function lte(i, y) {
429
+ return i <= y;
430
+ }
431
+ function gte(i, y) {
432
+ return i >= y;
433
+ }
434
+ function expand(str, isTop) {
435
+ var expansions = [];
436
+ var m = balanced("{", "}", str);
437
+ if (!m)
438
+ return [str];
439
+ var pre = m.pre;
440
+ var post = m.post.length ? expand(m.post, false) : [""];
441
+ if (/\$$/.test(m.pre)) {
442
+ for (var k = 0;k < post.length; k++) {
443
+ var expansion = pre + "{" + m.body + "}" + post[k];
444
+ expansions.push(expansion);
445
+ }
446
+ } else {
447
+ var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
448
+ var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
449
+ var isSequence = isNumericSequence || isAlphaSequence;
450
+ var isOptions = m.body.indexOf(",") >= 0;
451
+ if (!isSequence && !isOptions) {
452
+ if (m.post.match(/,.*\}/)) {
453
+ str = m.pre + "{" + m.body + escClose + m.post;
454
+ return expand(str);
455
+ }
456
+ return [str];
457
+ }
458
+ var n;
459
+ if (isSequence) {
460
+ n = m.body.split(/\.\./);
461
+ } else {
462
+ n = parseCommaParts(m.body);
463
+ if (n.length === 1) {
464
+ n = expand(n[0], false).map(embrace);
465
+ if (n.length === 1) {
466
+ return post.map(function(p) {
467
+ return m.pre + n[0] + p;
468
+ });
469
+ }
470
+ }
471
+ }
472
+ var N;
473
+ if (isSequence) {
474
+ var x = numeric(n[0]);
475
+ var y = numeric(n[1]);
476
+ var width = Math.max(n[0].length, n[1].length);
477
+ var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
478
+ var test = lte;
479
+ var reverse = y < x;
480
+ if (reverse) {
481
+ incr *= -1;
482
+ test = gte;
483
+ }
484
+ var pad = n.some(isPadded);
485
+ N = [];
486
+ for (var i = x;test(i, y); i += incr) {
487
+ var c;
488
+ if (isAlphaSequence) {
489
+ c = String.fromCharCode(i);
490
+ if (c === "\\")
491
+ c = "";
492
+ } else {
493
+ c = String(i);
494
+ if (pad) {
495
+ var need = width - c.length;
496
+ if (need > 0) {
497
+ var z = new Array(need + 1).join("0");
498
+ if (i < 0)
499
+ c = "-" + z + c.slice(1);
500
+ else
501
+ c = z + c;
502
+ }
503
+ }
504
+ }
505
+ N.push(c);
506
+ }
507
+ } else {
508
+ N = [];
509
+ for (var j = 0;j < n.length; j++) {
510
+ N.push.apply(N, expand(n[j], false));
511
+ }
512
+ }
513
+ for (var j = 0;j < N.length; j++) {
514
+ for (var k = 0;k < post.length; k++) {
515
+ var expansion = pre + N[j] + post[k];
516
+ if (!isTop || isSequence || expansion)
517
+ expansions.push(expansion);
518
+ }
519
+ }
520
+ }
521
+ return expansions;
522
+ }
523
+ }
524
+ });
525
+ var require_minimatch = __commonJS2({
526
+ "node_modules/minimatch/minimatch.js"(exports2, module2) {
527
+ var minimatch = module2.exports = (p, pattern, options = {}) => {
528
+ assertValidPattern(pattern);
529
+ if (!options.nocomment && pattern.charAt(0) === "#") {
530
+ return false;
531
+ }
532
+ return new Minimatch(pattern, options).match(p);
533
+ };
534
+ module2.exports = minimatch;
535
+ var path2 = require_path();
536
+ minimatch.sep = path2.sep;
537
+ var GLOBSTAR = Symbol("globstar **");
538
+ minimatch.GLOBSTAR = GLOBSTAR;
539
+ var expand = require_brace_expansion();
540
+ var plTypes = {
541
+ "!": { open: "(?:(?!(?:", close: "))[^/]*?)" },
542
+ "?": { open: "(?:", close: ")?" },
543
+ "+": { open: "(?:", close: ")+" },
544
+ "*": { open: "(?:", close: ")*" },
545
+ "@": { open: "(?:", close: ")" }
546
+ };
547
+ var qmark = "[^/]";
548
+ var star = qmark + "*?";
549
+ var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
550
+ var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
551
+ var charSet = (s) => s.split("").reduce((set, c) => {
552
+ set[c] = true;
553
+ return set;
554
+ }, {});
555
+ var reSpecials = charSet("().*{}+?[]^$\\!");
556
+ var addPatternStartSet = charSet("[.(");
557
+ var slashSplit = /\/+/;
558
+ minimatch.filter = (pattern, options = {}) => (p, i, list) => minimatch(p, pattern, options);
559
+ var ext = (a, b = {}) => {
560
+ const t = {};
561
+ Object.keys(a).forEach((k) => t[k] = a[k]);
562
+ Object.keys(b).forEach((k) => t[k] = b[k]);
563
+ return t;
564
+ };
565
+ minimatch.defaults = (def) => {
566
+ if (!def || typeof def !== "object" || !Object.keys(def).length) {
567
+ return minimatch;
568
+ }
569
+ const orig = minimatch;
570
+ const m = (p, pattern, options) => orig(p, pattern, ext(def, options));
571
+ m.Minimatch = class Minimatch2 extends orig.Minimatch {
572
+ constructor(pattern, options) {
573
+ super(pattern, ext(def, options));
574
+ }
575
+ };
576
+ m.Minimatch.defaults = (options) => orig.defaults(ext(def, options)).Minimatch;
577
+ m.filter = (pattern, options) => orig.filter(pattern, ext(def, options));
578
+ m.defaults = (options) => orig.defaults(ext(def, options));
579
+ m.makeRe = (pattern, options) => orig.makeRe(pattern, ext(def, options));
580
+ m.braceExpand = (pattern, options) => orig.braceExpand(pattern, ext(def, options));
581
+ m.match = (list, pattern, options) => orig.match(list, pattern, ext(def, options));
582
+ return m;
583
+ };
584
+ minimatch.braceExpand = (pattern, options) => braceExpand(pattern, options);
585
+ var braceExpand = (pattern, options = {}) => {
586
+ assertValidPattern(pattern);
587
+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
588
+ return [pattern];
589
+ }
590
+ return expand(pattern);
591
+ };
592
+ var MAX_PATTERN_LENGTH = 1024 * 64;
593
+ var assertValidPattern = (pattern) => {
594
+ if (typeof pattern !== "string") {
595
+ throw new TypeError("invalid pattern");
596
+ }
597
+ if (pattern.length > MAX_PATTERN_LENGTH) {
598
+ throw new TypeError("pattern is too long");
599
+ }
600
+ };
601
+ var SUBPARSE = Symbol("subparse");
602
+ minimatch.makeRe = (pattern, options) => new Minimatch(pattern, options || {}).makeRe();
603
+ minimatch.match = (list, pattern, options = {}) => {
604
+ const mm = new Minimatch(pattern, options);
605
+ list = list.filter((f) => mm.match(f));
606
+ if (mm.options.nonull && !list.length) {
607
+ list.push(pattern);
608
+ }
609
+ return list;
610
+ };
611
+ var globUnescape = (s) => s.replace(/\\(.)/g, "$1");
612
+ var charUnescape = (s) => s.replace(/\\([^-\]])/g, "$1");
613
+ var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
614
+ var braExpEscape = (s) => s.replace(/[[\]\\]/g, "\\$&");
615
+ var Minimatch = class {
616
+ constructor(pattern, options) {
617
+ assertValidPattern(pattern);
618
+ if (!options)
619
+ options = {};
620
+ this.options = options;
621
+ this.set = [];
622
+ this.pattern = pattern;
623
+ this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
624
+ if (this.windowsPathsNoEscape) {
625
+ this.pattern = this.pattern.replace(/\\/g, "/");
626
+ }
627
+ this.regexp = null;
628
+ this.negate = false;
629
+ this.comment = false;
630
+ this.empty = false;
631
+ this.partial = !!options.partial;
632
+ this.make();
633
+ }
634
+ debug() {}
635
+ make() {
636
+ const pattern = this.pattern;
637
+ const options = this.options;
638
+ if (!options.nocomment && pattern.charAt(0) === "#") {
639
+ this.comment = true;
640
+ return;
641
+ }
642
+ if (!pattern) {
643
+ this.empty = true;
644
+ return;
645
+ }
646
+ this.parseNegate();
647
+ let set = this.globSet = this.braceExpand();
648
+ if (options.debug)
649
+ this.debug = (...args) => console.error(...args);
650
+ this.debug(this.pattern, set);
651
+ set = this.globParts = set.map((s) => s.split(slashSplit));
652
+ this.debug(this.pattern, set);
653
+ set = set.map((s, si, set2) => s.map(this.parse, this));
654
+ this.debug(this.pattern, set);
655
+ set = set.filter((s) => s.indexOf(false) === -1);
656
+ this.debug(this.pattern, set);
657
+ this.set = set;
658
+ }
659
+ parseNegate() {
660
+ if (this.options.nonegate)
661
+ return;
662
+ const pattern = this.pattern;
663
+ let negate = false;
664
+ let negateOffset = 0;
665
+ for (let i = 0;i < pattern.length && pattern.charAt(i) === "!"; i++) {
666
+ negate = !negate;
667
+ negateOffset++;
668
+ }
669
+ if (negateOffset)
670
+ this.pattern = pattern.slice(negateOffset);
671
+ this.negate = negate;
672
+ }
673
+ matchOne(file, pattern, partial) {
674
+ var options = this.options;
675
+ this.debug("matchOne", { this: this, file, pattern });
676
+ this.debug("matchOne", file.length, pattern.length);
677
+ for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length;fi < fl && pi < pl; fi++, pi++) {
678
+ this.debug("matchOne loop");
679
+ var p = pattern[pi];
680
+ var f = file[fi];
681
+ this.debug(pattern, p, f);
682
+ if (p === false)
683
+ return false;
684
+ if (p === GLOBSTAR) {
685
+ this.debug("GLOBSTAR", [pattern, p, f]);
686
+ var fr = fi;
687
+ var pr = pi + 1;
688
+ if (pr === pl) {
689
+ this.debug("** at the end");
690
+ for (;fi < fl; fi++) {
691
+ if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
692
+ return false;
693
+ }
694
+ return true;
695
+ }
696
+ while (fr < fl) {
697
+ var swallowee = file[fr];
698
+ this.debug(`
699
+ globstar while`, file, fr, pattern, pr, swallowee);
700
+ if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
701
+ this.debug("globstar found match!", fr, fl, swallowee);
702
+ return true;
703
+ } else {
704
+ if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
705
+ this.debug("dot detected!", file, fr, pattern, pr);
706
+ break;
707
+ }
708
+ this.debug("globstar swallow a segment, and continue");
709
+ fr++;
710
+ }
711
+ }
712
+ if (partial) {
713
+ this.debug(`
714
+ >>> no match, partial?`, file, fr, pattern, pr);
715
+ if (fr === fl)
716
+ return true;
717
+ }
718
+ return false;
719
+ }
720
+ var hit;
721
+ if (typeof p === "string") {
722
+ hit = f === p;
723
+ this.debug("string match", p, f, hit);
724
+ } else {
725
+ hit = f.match(p);
726
+ this.debug("pattern match", p, f, hit);
727
+ }
728
+ if (!hit)
729
+ return false;
730
+ }
731
+ if (fi === fl && pi === pl) {
732
+ return true;
733
+ } else if (fi === fl) {
734
+ return partial;
735
+ } else if (pi === pl) {
736
+ return fi === fl - 1 && file[fi] === "";
737
+ }
738
+ throw new Error("wtf?");
739
+ }
740
+ braceExpand() {
741
+ return braceExpand(this.pattern, this.options);
742
+ }
743
+ parse(pattern, isSub) {
744
+ assertValidPattern(pattern);
745
+ const options = this.options;
746
+ if (pattern === "**") {
747
+ if (!options.noglobstar)
748
+ return GLOBSTAR;
749
+ else
750
+ pattern = "*";
751
+ }
752
+ if (pattern === "")
753
+ return "";
754
+ let re = "";
755
+ let hasMagic = !!options.nocase;
756
+ let escaping = false;
757
+ const patternListStack = [];
758
+ const negativeLists = [];
759
+ let stateChar;
760
+ let inClass = false;
761
+ let reClassStart = -1;
762
+ let classStart = -1;
763
+ let cs;
764
+ let pl;
765
+ let sp;
766
+ const patternStart = pattern.charAt(0) === "." ? "" : options.dot ? "(?!(?:^|\\/)\\.{1,2}(?:$|\\/))" : "(?!\\.)";
767
+ const clearStateChar = () => {
768
+ if (stateChar) {
769
+ switch (stateChar) {
770
+ case "*":
771
+ re += star;
772
+ hasMagic = true;
773
+ break;
774
+ case "?":
775
+ re += qmark;
776
+ hasMagic = true;
777
+ break;
778
+ default:
779
+ re += "\\" + stateChar;
780
+ break;
781
+ }
782
+ this.debug("clearStateChar %j %j", stateChar, re);
783
+ stateChar = false;
784
+ }
785
+ };
786
+ for (let i = 0, c;i < pattern.length && (c = pattern.charAt(i)); i++) {
787
+ this.debug("%s\t%s %s %j", pattern, i, re, c);
788
+ if (escaping) {
789
+ if (c === "/") {
790
+ return false;
791
+ }
792
+ if (reSpecials[c]) {
793
+ re += "\\";
794
+ }
795
+ re += c;
796
+ escaping = false;
797
+ continue;
798
+ }
799
+ switch (c) {
800
+ case "/": {
801
+ return false;
802
+ }
803
+ case "\\":
804
+ if (inClass && pattern.charAt(i + 1) === "-") {
805
+ re += c;
806
+ continue;
807
+ }
808
+ clearStateChar();
809
+ escaping = true;
810
+ continue;
811
+ case "?":
812
+ case "*":
813
+ case "+":
814
+ case "@":
815
+ case "!":
816
+ this.debug("%s\t%s %s %j <-- stateChar", pattern, i, re, c);
817
+ if (inClass) {
818
+ this.debug(" in class");
819
+ if (c === "!" && i === classStart + 1)
820
+ c = "^";
821
+ re += c;
822
+ continue;
823
+ }
824
+ this.debug("call clearStateChar %j", stateChar);
825
+ clearStateChar();
826
+ stateChar = c;
827
+ if (options.noext)
828
+ clearStateChar();
829
+ continue;
830
+ case "(":
831
+ if (inClass) {
832
+ re += "(";
833
+ continue;
834
+ }
835
+ if (!stateChar) {
836
+ re += "\\(";
837
+ continue;
838
+ }
839
+ patternListStack.push({
840
+ type: stateChar,
841
+ start: i - 1,
842
+ reStart: re.length,
843
+ open: plTypes[stateChar].open,
844
+ close: plTypes[stateChar].close
845
+ });
846
+ re += stateChar === "!" ? "(?:(?!(?:" : "(?:";
847
+ this.debug("plType %j %j", stateChar, re);
848
+ stateChar = false;
849
+ continue;
850
+ case ")":
851
+ if (inClass || !patternListStack.length) {
852
+ re += "\\)";
853
+ continue;
854
+ }
855
+ clearStateChar();
856
+ hasMagic = true;
857
+ pl = patternListStack.pop();
858
+ re += pl.close;
859
+ if (pl.type === "!") {
860
+ negativeLists.push(pl);
861
+ }
862
+ pl.reEnd = re.length;
863
+ continue;
864
+ case "|":
865
+ if (inClass || !patternListStack.length) {
866
+ re += "\\|";
867
+ continue;
868
+ }
869
+ clearStateChar();
870
+ re += "|";
871
+ continue;
872
+ case "[":
873
+ clearStateChar();
874
+ if (inClass) {
875
+ re += "\\" + c;
876
+ continue;
877
+ }
878
+ inClass = true;
879
+ classStart = i;
880
+ reClassStart = re.length;
881
+ re += c;
882
+ continue;
883
+ case "]":
884
+ if (i === classStart + 1 || !inClass) {
885
+ re += "\\" + c;
886
+ continue;
887
+ }
888
+ cs = pattern.substring(classStart + 1, i);
889
+ try {
890
+ RegExp("[" + braExpEscape(charUnescape(cs)) + "]");
891
+ re += c;
892
+ } catch (er) {
893
+ re = re.substring(0, reClassStart) + "(?:$.)";
894
+ }
895
+ hasMagic = true;
896
+ inClass = false;
897
+ continue;
898
+ default:
899
+ clearStateChar();
900
+ if (reSpecials[c] && !(c === "^" && inClass)) {
901
+ re += "\\";
902
+ }
903
+ re += c;
904
+ break;
905
+ }
906
+ }
907
+ if (inClass) {
908
+ cs = pattern.slice(classStart + 1);
909
+ sp = this.parse(cs, SUBPARSE);
910
+ re = re.substring(0, reClassStart) + "\\[" + sp[0];
911
+ hasMagic = hasMagic || sp[1];
912
+ }
913
+ for (pl = patternListStack.pop();pl; pl = patternListStack.pop()) {
914
+ let tail;
915
+ tail = re.slice(pl.reStart + pl.open.length);
916
+ this.debug("setting tail", re, pl);
917
+ tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, (_, $1, $2) => {
918
+ if (!$2) {
919
+ $2 = "\\";
920
+ }
921
+ return $1 + $1 + $2 + "|";
922
+ });
923
+ this.debug(`tail=%j
924
+ %s`, tail, tail, pl, re);
925
+ const t = pl.type === "*" ? star : pl.type === "?" ? qmark : "\\" + pl.type;
926
+ hasMagic = true;
927
+ re = re.slice(0, pl.reStart) + t + "\\(" + tail;
928
+ }
929
+ clearStateChar();
930
+ if (escaping) {
931
+ re += "\\\\";
932
+ }
933
+ const addPatternStart = addPatternStartSet[re.charAt(0)];
934
+ for (let n = negativeLists.length - 1;n > -1; n--) {
935
+ const nl = negativeLists[n];
936
+ const nlBefore = re.slice(0, nl.reStart);
937
+ const nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
938
+ let nlAfter = re.slice(nl.reEnd);
939
+ const nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + nlAfter;
940
+ const openParensBefore = nlBefore.split("(").length - 1;
941
+ let cleanAfter = nlAfter;
942
+ for (let i = 0;i < openParensBefore; i++) {
943
+ cleanAfter = cleanAfter.replace(/\)[+*?]?/, "");
944
+ }
945
+ nlAfter = cleanAfter;
946
+ const dollar = nlAfter === "" && isSub !== SUBPARSE ? "$" : "";
947
+ re = nlBefore + nlFirst + nlAfter + dollar + nlLast;
948
+ }
949
+ if (re !== "" && hasMagic) {
950
+ re = "(?=.)" + re;
951
+ }
952
+ if (addPatternStart) {
953
+ re = patternStart + re;
954
+ }
955
+ if (isSub === SUBPARSE) {
956
+ return [re, hasMagic];
957
+ }
958
+ if (!hasMagic) {
959
+ return globUnescape(pattern);
960
+ }
961
+ const flags = options.nocase ? "i" : "";
962
+ try {
963
+ return Object.assign(new RegExp("^" + re + "$", flags), {
964
+ _glob: pattern,
965
+ _src: re
966
+ });
967
+ } catch (er) {
968
+ return new RegExp("$.");
969
+ }
970
+ }
971
+ makeRe() {
972
+ if (this.regexp || this.regexp === false)
973
+ return this.regexp;
974
+ const set = this.set;
975
+ if (!set.length) {
976
+ this.regexp = false;
977
+ return this.regexp;
978
+ }
979
+ const options = this.options;
980
+ const twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
981
+ const flags = options.nocase ? "i" : "";
982
+ let re = set.map((pattern) => {
983
+ pattern = pattern.map((p) => typeof p === "string" ? regExpEscape(p) : p === GLOBSTAR ? GLOBSTAR : p._src).reduce((set2, p) => {
984
+ if (!(set2[set2.length - 1] === GLOBSTAR && p === GLOBSTAR)) {
985
+ set2.push(p);
986
+ }
987
+ return set2;
988
+ }, []);
989
+ pattern.forEach((p, i) => {
990
+ if (p !== GLOBSTAR || pattern[i - 1] === GLOBSTAR) {
991
+ return;
992
+ }
993
+ if (i === 0) {
994
+ if (pattern.length > 1) {
995
+ pattern[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + pattern[i + 1];
996
+ } else {
997
+ pattern[i] = twoStar;
998
+ }
999
+ } else if (i === pattern.length - 1) {
1000
+ pattern[i - 1] += "(?:\\/|" + twoStar + ")?";
1001
+ } else {
1002
+ pattern[i - 1] += "(?:\\/|\\/" + twoStar + "\\/)" + pattern[i + 1];
1003
+ pattern[i + 1] = GLOBSTAR;
1004
+ }
1005
+ });
1006
+ return pattern.filter((p) => p !== GLOBSTAR).join("/");
1007
+ }).join("|");
1008
+ re = "^(?:" + re + ")$";
1009
+ if (this.negate)
1010
+ re = "^(?!" + re + ").*$";
1011
+ try {
1012
+ this.regexp = new RegExp(re, flags);
1013
+ } catch (ex) {
1014
+ this.regexp = false;
1015
+ }
1016
+ return this.regexp;
1017
+ }
1018
+ match(f, partial = this.partial) {
1019
+ this.debug("match", f, this.pattern);
1020
+ if (this.comment)
1021
+ return false;
1022
+ if (this.empty)
1023
+ return f === "";
1024
+ if (f === "/" && partial)
1025
+ return true;
1026
+ const options = this.options;
1027
+ if (path2.sep !== "/") {
1028
+ f = f.split(path2.sep).join("/");
1029
+ }
1030
+ f = f.split(slashSplit);
1031
+ this.debug(this.pattern, "split", f);
1032
+ const set = this.set;
1033
+ this.debug(this.pattern, "set", set);
1034
+ let filename;
1035
+ for (let i = f.length - 1;i >= 0; i--) {
1036
+ filename = f[i];
1037
+ if (filename)
1038
+ break;
1039
+ }
1040
+ for (let i = 0;i < set.length; i++) {
1041
+ const pattern = set[i];
1042
+ let file = f;
1043
+ if (options.matchBase && pattern.length === 1) {
1044
+ file = [filename];
1045
+ }
1046
+ const hit = this.matchOne(file, pattern, partial);
1047
+ if (hit) {
1048
+ if (options.flipNegate)
1049
+ return true;
1050
+ return !this.negate;
1051
+ }
1052
+ }
1053
+ if (options.flipNegate)
1054
+ return false;
1055
+ return this.negate;
1056
+ }
1057
+ static defaults(def) {
1058
+ return minimatch.defaults(def).Minimatch;
1059
+ }
1060
+ };
1061
+ minimatch.Minimatch = Minimatch;
1062
+ }
1063
+ });
1064
+ var require_inherits_browser = __commonJS2({
1065
+ "node_modules/inherits/inherits_browser.js"(exports2, module2) {
1066
+ if (typeof Object.create === "function") {
1067
+ module2.exports = function inherits(ctor, superCtor) {
1068
+ if (superCtor) {
1069
+ ctor.super_ = superCtor;
1070
+ ctor.prototype = Object.create(superCtor.prototype, {
1071
+ constructor: {
1072
+ value: ctor,
1073
+ enumerable: false,
1074
+ writable: true,
1075
+ configurable: true
1076
+ }
1077
+ });
1078
+ }
1079
+ };
1080
+ } else {
1081
+ module2.exports = function inherits(ctor, superCtor) {
1082
+ if (superCtor) {
1083
+ ctor.super_ = superCtor;
1084
+ var TempCtor = function() {};
1085
+ TempCtor.prototype = superCtor.prototype;
1086
+ ctor.prototype = new TempCtor;
1087
+ ctor.prototype.constructor = ctor;
1088
+ }
1089
+ };
1090
+ }
1091
+ }
1092
+ });
1093
+ var require_inherits = __commonJS2({
1094
+ "node_modules/inherits/inherits.js"(exports2, module2) {
1095
+ try {
1096
+ util = __require("util");
1097
+ if (typeof util.inherits !== "function")
1098
+ throw "";
1099
+ module2.exports = util.inherits;
1100
+ } catch (e) {
1101
+ module2.exports = require_inherits_browser();
1102
+ }
1103
+ var util;
1104
+ }
1105
+ });
1106
+ var require_common = __commonJS2({
1107
+ "node_modules/glob/common.js"(exports2) {
1108
+ exports2.setopts = setopts;
1109
+ exports2.ownProp = ownProp;
1110
+ exports2.makeAbs = makeAbs;
1111
+ exports2.finish = finish;
1112
+ exports2.mark = mark;
1113
+ exports2.isIgnored = isIgnored;
1114
+ exports2.childrenIgnored = childrenIgnored;
1115
+ function ownProp(obj, field) {
1116
+ return Object.prototype.hasOwnProperty.call(obj, field);
1117
+ }
1118
+ var fs2 = __require("fs");
1119
+ var path2 = __require("path");
1120
+ var minimatch = require_minimatch();
1121
+ var isAbsolute = __require("path").isAbsolute;
1122
+ var Minimatch = minimatch.Minimatch;
1123
+ function alphasort(a, b) {
1124
+ return a.localeCompare(b, "en");
1125
+ }
1126
+ function setupIgnores(self, options) {
1127
+ self.ignore = options.ignore || [];
1128
+ if (!Array.isArray(self.ignore))
1129
+ self.ignore = [self.ignore];
1130
+ if (self.ignore.length) {
1131
+ self.ignore = self.ignore.map(ignoreMap);
1132
+ }
1133
+ }
1134
+ function ignoreMap(pattern) {
1135
+ var gmatcher = null;
1136
+ if (pattern.slice(-3) === "/**") {
1137
+ var gpattern = pattern.replace(/(\/\*\*)+$/, "");
1138
+ gmatcher = new Minimatch(gpattern, { dot: true });
1139
+ }
1140
+ return {
1141
+ matcher: new Minimatch(pattern, { dot: true }),
1142
+ gmatcher
1143
+ };
1144
+ }
1145
+ function setopts(self, pattern, options) {
1146
+ if (!options)
1147
+ options = {};
1148
+ if (options.matchBase && pattern.indexOf("/") === -1) {
1149
+ if (options.noglobstar) {
1150
+ throw new Error("base matching requires globstar");
1151
+ }
1152
+ pattern = "**/" + pattern;
1153
+ }
1154
+ self.silent = !!options.silent;
1155
+ self.pattern = pattern;
1156
+ self.strict = options.strict !== false;
1157
+ self.realpath = !!options.realpath;
1158
+ self.realpathCache = options.realpathCache || /* @__PURE__ */ Object.create(null);
1159
+ self.follow = !!options.follow;
1160
+ self.dot = !!options.dot;
1161
+ self.mark = !!options.mark;
1162
+ self.nodir = !!options.nodir;
1163
+ if (self.nodir)
1164
+ self.mark = true;
1165
+ self.sync = !!options.sync;
1166
+ self.nounique = !!options.nounique;
1167
+ self.nonull = !!options.nonull;
1168
+ self.nosort = !!options.nosort;
1169
+ self.nocase = !!options.nocase;
1170
+ self.stat = !!options.stat;
1171
+ self.noprocess = !!options.noprocess;
1172
+ self.absolute = !!options.absolute;
1173
+ self.fs = options.fs || fs2;
1174
+ self.maxLength = options.maxLength || Infinity;
1175
+ self.cache = options.cache || /* @__PURE__ */ Object.create(null);
1176
+ self.statCache = options.statCache || /* @__PURE__ */ Object.create(null);
1177
+ self.symlinks = options.symlinks || /* @__PURE__ */ Object.create(null);
1178
+ setupIgnores(self, options);
1179
+ self.changedCwd = false;
1180
+ var cwd = process.cwd();
1181
+ if (!ownProp(options, "cwd"))
1182
+ self.cwd = path2.resolve(cwd);
1183
+ else {
1184
+ self.cwd = path2.resolve(options.cwd);
1185
+ self.changedCwd = self.cwd !== cwd;
1186
+ }
1187
+ self.root = options.root || path2.resolve(self.cwd, "/");
1188
+ self.root = path2.resolve(self.root);
1189
+ self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd);
1190
+ self.nomount = !!options.nomount;
1191
+ if (process.platform === "win32") {
1192
+ self.root = self.root.replace(/\\/g, "/");
1193
+ self.cwd = self.cwd.replace(/\\/g, "/");
1194
+ self.cwdAbs = self.cwdAbs.replace(/\\/g, "/");
1195
+ }
1196
+ options.nonegate = true;
1197
+ options.nocomment = true;
1198
+ options.allowWindowsEscape = true;
1199
+ self.minimatch = new Minimatch(pattern, options);
1200
+ self.options = self.minimatch.options;
1201
+ }
1202
+ function finish(self) {
1203
+ var nou = self.nounique;
1204
+ var all = nou ? [] : /* @__PURE__ */ Object.create(null);
1205
+ for (var i = 0, l = self.matches.length;i < l; i++) {
1206
+ var matches = self.matches[i];
1207
+ if (!matches || Object.keys(matches).length === 0) {
1208
+ if (self.nonull) {
1209
+ var literal = self.minimatch.globSet[i];
1210
+ if (nou)
1211
+ all.push(literal);
1212
+ else
1213
+ all[literal] = true;
1214
+ }
1215
+ } else {
1216
+ var m = Object.keys(matches);
1217
+ if (nou)
1218
+ all.push.apply(all, m);
1219
+ else
1220
+ m.forEach(function(m2) {
1221
+ all[m2] = true;
1222
+ });
1223
+ }
1224
+ }
1225
+ if (!nou)
1226
+ all = Object.keys(all);
1227
+ if (!self.nosort)
1228
+ all = all.sort(alphasort);
1229
+ if (self.mark) {
1230
+ for (var i = 0;i < all.length; i++) {
1231
+ all[i] = self._mark(all[i]);
1232
+ }
1233
+ if (self.nodir) {
1234
+ all = all.filter(function(e) {
1235
+ var notDir = !/\/$/.test(e);
1236
+ var c = self.cache[e] || self.cache[makeAbs(self, e)];
1237
+ if (notDir && c)
1238
+ notDir = c !== "DIR" && !Array.isArray(c);
1239
+ return notDir;
1240
+ });
1241
+ }
1242
+ }
1243
+ if (self.ignore.length)
1244
+ all = all.filter(function(m2) {
1245
+ return !isIgnored(self, m2);
1246
+ });
1247
+ self.found = all;
1248
+ }
1249
+ function mark(self, p) {
1250
+ var abs = makeAbs(self, p);
1251
+ var c = self.cache[abs];
1252
+ var m = p;
1253
+ if (c) {
1254
+ var isDir = c === "DIR" || Array.isArray(c);
1255
+ var slash = p.slice(-1) === "/";
1256
+ if (isDir && !slash)
1257
+ m += "/";
1258
+ else if (!isDir && slash)
1259
+ m = m.slice(0, -1);
1260
+ if (m !== p) {
1261
+ var mabs = makeAbs(self, m);
1262
+ self.statCache[mabs] = self.statCache[abs];
1263
+ self.cache[mabs] = self.cache[abs];
1264
+ }
1265
+ }
1266
+ return m;
1267
+ }
1268
+ function makeAbs(self, f) {
1269
+ var abs = f;
1270
+ if (f.charAt(0) === "/") {
1271
+ abs = path2.join(self.root, f);
1272
+ } else if (isAbsolute(f) || f === "") {
1273
+ abs = f;
1274
+ } else if (self.changedCwd) {
1275
+ abs = path2.resolve(self.cwd, f);
1276
+ } else {
1277
+ abs = path2.resolve(f);
1278
+ }
1279
+ if (process.platform === "win32")
1280
+ abs = abs.replace(/\\/g, "/");
1281
+ return abs;
1282
+ }
1283
+ function isIgnored(self, path3) {
1284
+ if (!self.ignore.length)
1285
+ return false;
1286
+ return self.ignore.some(function(item) {
1287
+ return item.matcher.match(path3) || !!(item.gmatcher && item.gmatcher.match(path3));
1288
+ });
1289
+ }
1290
+ function childrenIgnored(self, path3) {
1291
+ if (!self.ignore.length)
1292
+ return false;
1293
+ return self.ignore.some(function(item) {
1294
+ return !!(item.gmatcher && item.gmatcher.match(path3));
1295
+ });
1296
+ }
1297
+ }
1298
+ });
1299
+ var require_sync = __commonJS2({
1300
+ "node_modules/glob/sync.js"(exports2, module2) {
1301
+ module2.exports = globSync;
1302
+ globSync.GlobSync = GlobSync;
1303
+ var rp = require_fs();
1304
+ var minimatch = require_minimatch();
1305
+ var Minimatch = minimatch.Minimatch;
1306
+ var Glob = require_glob().Glob;
1307
+ var util = __require("util");
1308
+ var path2 = __require("path");
1309
+ var assert = __require("assert");
1310
+ var isAbsolute = __require("path").isAbsolute;
1311
+ var common = require_common();
1312
+ var setopts = common.setopts;
1313
+ var ownProp = common.ownProp;
1314
+ var childrenIgnored = common.childrenIgnored;
1315
+ var isIgnored = common.isIgnored;
1316
+ function globSync(pattern, options) {
1317
+ if (typeof options === "function" || arguments.length === 3)
1318
+ throw new TypeError(`callback provided to sync glob
1319
+ See: https://github.com/isaacs/node-glob/issues/167`);
1320
+ return new GlobSync(pattern, options).found;
1321
+ }
1322
+ function GlobSync(pattern, options) {
1323
+ if (!pattern)
1324
+ throw new Error("must provide pattern");
1325
+ if (typeof options === "function" || arguments.length === 3)
1326
+ throw new TypeError(`callback provided to sync glob
1327
+ See: https://github.com/isaacs/node-glob/issues/167`);
1328
+ if (!(this instanceof GlobSync))
1329
+ return new GlobSync(pattern, options);
1330
+ setopts(this, pattern, options);
1331
+ if (this.noprocess)
1332
+ return this;
1333
+ var n = this.minimatch.set.length;
1334
+ this.matches = new Array(n);
1335
+ for (var i = 0;i < n; i++) {
1336
+ this._process(this.minimatch.set[i], i, false);
1337
+ }
1338
+ this._finish();
1339
+ }
1340
+ GlobSync.prototype._finish = function() {
1341
+ assert.ok(this instanceof GlobSync);
1342
+ if (this.realpath) {
1343
+ var self = this;
1344
+ this.matches.forEach(function(matchset, index) {
1345
+ var set = self.matches[index] = /* @__PURE__ */ Object.create(null);
1346
+ for (var p in matchset) {
1347
+ try {
1348
+ p = self._makeAbs(p);
1349
+ var real = rp.realpathSync(p, self.realpathCache);
1350
+ set[real] = true;
1351
+ } catch (er) {
1352
+ if (er.syscall === "stat")
1353
+ set[self._makeAbs(p)] = true;
1354
+ else
1355
+ throw er;
1356
+ }
1357
+ }
1358
+ });
1359
+ }
1360
+ common.finish(this);
1361
+ };
1362
+ GlobSync.prototype._process = function(pattern, index, inGlobStar) {
1363
+ assert.ok(this instanceof GlobSync);
1364
+ var n = 0;
1365
+ while (typeof pattern[n] === "string") {
1366
+ n++;
1367
+ }
1368
+ var prefix;
1369
+ switch (n) {
1370
+ case pattern.length:
1371
+ this._processSimple(pattern.join("/"), index);
1372
+ return;
1373
+ case 0:
1374
+ prefix = null;
1375
+ break;
1376
+ default:
1377
+ prefix = pattern.slice(0, n).join("/");
1378
+ break;
1379
+ }
1380
+ var remain = pattern.slice(n);
1381
+ var read;
1382
+ if (prefix === null)
1383
+ read = ".";
1384
+ else if (isAbsolute(prefix) || isAbsolute(pattern.map(function(p) {
1385
+ return typeof p === "string" ? p : "[*]";
1386
+ }).join("/"))) {
1387
+ if (!prefix || !isAbsolute(prefix))
1388
+ prefix = "/" + prefix;
1389
+ read = prefix;
1390
+ } else
1391
+ read = prefix;
1392
+ var abs = this._makeAbs(read);
1393
+ if (childrenIgnored(this, read))
1394
+ return;
1395
+ var isGlobStar = remain[0] === minimatch.GLOBSTAR;
1396
+ if (isGlobStar)
1397
+ this._processGlobStar(prefix, read, abs, remain, index, inGlobStar);
1398
+ else
1399
+ this._processReaddir(prefix, read, abs, remain, index, inGlobStar);
1400
+ };
1401
+ GlobSync.prototype._processReaddir = function(prefix, read, abs, remain, index, inGlobStar) {
1402
+ var entries = this._readdir(abs, inGlobStar);
1403
+ if (!entries)
1404
+ return;
1405
+ var pn = remain[0];
1406
+ var negate = !!this.minimatch.negate;
1407
+ var rawGlob = pn._glob;
1408
+ var dotOk = this.dot || rawGlob.charAt(0) === ".";
1409
+ var matchedEntries = [];
1410
+ for (var i = 0;i < entries.length; i++) {
1411
+ var e = entries[i];
1412
+ if (e.charAt(0) !== "." || dotOk) {
1413
+ var m;
1414
+ if (negate && !prefix) {
1415
+ m = !e.match(pn);
1416
+ } else {
1417
+ m = e.match(pn);
1418
+ }
1419
+ if (m)
1420
+ matchedEntries.push(e);
1421
+ }
1422
+ }
1423
+ var len = matchedEntries.length;
1424
+ if (len === 0)
1425
+ return;
1426
+ if (remain.length === 1 && !this.mark && !this.stat) {
1427
+ if (!this.matches[index])
1428
+ this.matches[index] = /* @__PURE__ */ Object.create(null);
1429
+ for (var i = 0;i < len; i++) {
1430
+ var e = matchedEntries[i];
1431
+ if (prefix) {
1432
+ if (prefix.slice(-1) !== "/")
1433
+ e = prefix + "/" + e;
1434
+ else
1435
+ e = prefix + e;
1436
+ }
1437
+ if (e.charAt(0) === "/" && !this.nomount) {
1438
+ e = path2.join(this.root, e);
1439
+ }
1440
+ this._emitMatch(index, e);
1441
+ }
1442
+ return;
1443
+ }
1444
+ remain.shift();
1445
+ for (var i = 0;i < len; i++) {
1446
+ var e = matchedEntries[i];
1447
+ var newPattern;
1448
+ if (prefix)
1449
+ newPattern = [prefix, e];
1450
+ else
1451
+ newPattern = [e];
1452
+ this._process(newPattern.concat(remain), index, inGlobStar);
1453
+ }
1454
+ };
1455
+ GlobSync.prototype._emitMatch = function(index, e) {
1456
+ if (isIgnored(this, e))
1457
+ return;
1458
+ var abs = this._makeAbs(e);
1459
+ if (this.mark)
1460
+ e = this._mark(e);
1461
+ if (this.absolute) {
1462
+ e = abs;
1463
+ }
1464
+ if (this.matches[index][e])
1465
+ return;
1466
+ if (this.nodir) {
1467
+ var c = this.cache[abs];
1468
+ if (c === "DIR" || Array.isArray(c))
1469
+ return;
1470
+ }
1471
+ this.matches[index][e] = true;
1472
+ if (this.stat)
1473
+ this._stat(e);
1474
+ };
1475
+ GlobSync.prototype._readdirInGlobStar = function(abs) {
1476
+ if (this.follow)
1477
+ return this._readdir(abs, false);
1478
+ var entries;
1479
+ var lstat;
1480
+ var stat;
1481
+ try {
1482
+ lstat = this.fs.lstatSync(abs);
1483
+ } catch (er) {
1484
+ if (er.code === "ENOENT") {
1485
+ return null;
1486
+ }
1487
+ }
1488
+ var isSym = lstat && lstat.isSymbolicLink();
1489
+ this.symlinks[abs] = isSym;
1490
+ if (!isSym && lstat && !lstat.isDirectory())
1491
+ this.cache[abs] = "FILE";
1492
+ else
1493
+ entries = this._readdir(abs, false);
1494
+ return entries;
1495
+ };
1496
+ GlobSync.prototype._readdir = function(abs, inGlobStar) {
1497
+ var entries;
1498
+ if (inGlobStar && !ownProp(this.symlinks, abs))
1499
+ return this._readdirInGlobStar(abs);
1500
+ if (ownProp(this.cache, abs)) {
1501
+ var c = this.cache[abs];
1502
+ if (!c || c === "FILE")
1503
+ return null;
1504
+ if (Array.isArray(c))
1505
+ return c;
1506
+ }
1507
+ try {
1508
+ return this._readdirEntries(abs, this.fs.readdirSync(abs));
1509
+ } catch (er) {
1510
+ this._readdirError(abs, er);
1511
+ return null;
1512
+ }
1513
+ };
1514
+ GlobSync.prototype._readdirEntries = function(abs, entries) {
1515
+ if (!this.mark && !this.stat) {
1516
+ for (var i = 0;i < entries.length; i++) {
1517
+ var e = entries[i];
1518
+ if (abs === "/")
1519
+ e = abs + e;
1520
+ else
1521
+ e = abs + "/" + e;
1522
+ this.cache[e] = true;
1523
+ }
1524
+ }
1525
+ this.cache[abs] = entries;
1526
+ return entries;
1527
+ };
1528
+ GlobSync.prototype._readdirError = function(f, er) {
1529
+ switch (er.code) {
1530
+ case "ENOTSUP":
1531
+ case "ENOTDIR":
1532
+ var abs = this._makeAbs(f);
1533
+ this.cache[abs] = "FILE";
1534
+ if (abs === this.cwdAbs) {
1535
+ var error = new Error(er.code + " invalid cwd " + this.cwd);
1536
+ error.path = this.cwd;
1537
+ error.code = er.code;
1538
+ throw error;
1539
+ }
1540
+ break;
1541
+ case "ENOENT":
1542
+ case "ELOOP":
1543
+ case "ENAMETOOLONG":
1544
+ case "UNKNOWN":
1545
+ this.cache[this._makeAbs(f)] = false;
1546
+ break;
1547
+ default:
1548
+ this.cache[this._makeAbs(f)] = false;
1549
+ if (this.strict)
1550
+ throw er;
1551
+ if (!this.silent)
1552
+ console.error("glob error", er);
1553
+ break;
1554
+ }
1555
+ };
1556
+ GlobSync.prototype._processGlobStar = function(prefix, read, abs, remain, index, inGlobStar) {
1557
+ var entries = this._readdir(abs, inGlobStar);
1558
+ if (!entries)
1559
+ return;
1560
+ var remainWithoutGlobStar = remain.slice(1);
1561
+ var gspref = prefix ? [prefix] : [];
1562
+ var noGlobStar = gspref.concat(remainWithoutGlobStar);
1563
+ this._process(noGlobStar, index, false);
1564
+ var len = entries.length;
1565
+ var isSym = this.symlinks[abs];
1566
+ if (isSym && inGlobStar)
1567
+ return;
1568
+ for (var i = 0;i < len; i++) {
1569
+ var e = entries[i];
1570
+ if (e.charAt(0) === "." && !this.dot)
1571
+ continue;
1572
+ var instead = gspref.concat(entries[i], remainWithoutGlobStar);
1573
+ this._process(instead, index, true);
1574
+ var below = gspref.concat(entries[i], remain);
1575
+ this._process(below, index, true);
1576
+ }
1577
+ };
1578
+ GlobSync.prototype._processSimple = function(prefix, index) {
1579
+ var exists = this._stat(prefix);
1580
+ if (!this.matches[index])
1581
+ this.matches[index] = /* @__PURE__ */ Object.create(null);
1582
+ if (!exists)
1583
+ return;
1584
+ if (prefix && isAbsolute(prefix) && !this.nomount) {
1585
+ var trail = /[\/\\]$/.test(prefix);
1586
+ if (prefix.charAt(0) === "/") {
1587
+ prefix = path2.join(this.root, prefix);
1588
+ } else {
1589
+ prefix = path2.resolve(this.root, prefix);
1590
+ if (trail)
1591
+ prefix += "/";
1592
+ }
1593
+ }
1594
+ if (process.platform === "win32")
1595
+ prefix = prefix.replace(/\\/g, "/");
1596
+ this._emitMatch(index, prefix);
1597
+ };
1598
+ GlobSync.prototype._stat = function(f) {
1599
+ var abs = this._makeAbs(f);
1600
+ var needDir = f.slice(-1) === "/";
1601
+ if (f.length > this.maxLength)
1602
+ return false;
1603
+ if (!this.stat && ownProp(this.cache, abs)) {
1604
+ var c = this.cache[abs];
1605
+ if (Array.isArray(c))
1606
+ c = "DIR";
1607
+ if (!needDir || c === "DIR")
1608
+ return c;
1609
+ if (needDir && c === "FILE")
1610
+ return false;
1611
+ }
1612
+ var exists;
1613
+ var stat = this.statCache[abs];
1614
+ if (!stat) {
1615
+ var lstat;
1616
+ try {
1617
+ lstat = this.fs.lstatSync(abs);
1618
+ } catch (er) {
1619
+ if (er && (er.code === "ENOENT" || er.code === "ENOTDIR")) {
1620
+ this.statCache[abs] = false;
1621
+ return false;
1622
+ }
1623
+ }
1624
+ if (lstat && lstat.isSymbolicLink()) {
1625
+ try {
1626
+ stat = this.fs.statSync(abs);
1627
+ } catch (er) {
1628
+ stat = lstat;
1629
+ }
1630
+ } else {
1631
+ stat = lstat;
1632
+ }
1633
+ }
1634
+ this.statCache[abs] = stat;
1635
+ var c = true;
1636
+ if (stat)
1637
+ c = stat.isDirectory() ? "DIR" : "FILE";
1638
+ this.cache[abs] = this.cache[abs] || c;
1639
+ if (needDir && c === "FILE")
1640
+ return false;
1641
+ return c;
1642
+ };
1643
+ GlobSync.prototype._mark = function(p) {
1644
+ return common.mark(this, p);
1645
+ };
1646
+ GlobSync.prototype._makeAbs = function(f) {
1647
+ return common.makeAbs(this, f);
1648
+ };
1649
+ }
1650
+ });
1651
+ var require_wrappy = __commonJS2({
1652
+ "node_modules/wrappy/wrappy.js"(exports2, module2) {
1653
+ module2.exports = wrappy;
1654
+ function wrappy(fn, cb) {
1655
+ if (fn && cb)
1656
+ return wrappy(fn)(cb);
1657
+ if (typeof fn !== "function")
1658
+ throw new TypeError("need wrapper function");
1659
+ Object.keys(fn).forEach(function(k) {
1660
+ wrapper[k] = fn[k];
1661
+ });
1662
+ return wrapper;
1663
+ function wrapper() {
1664
+ var args = new Array(arguments.length);
1665
+ for (var i = 0;i < args.length; i++) {
1666
+ args[i] = arguments[i];
1667
+ }
1668
+ var ret = fn.apply(this, args);
1669
+ var cb2 = args[args.length - 1];
1670
+ if (typeof ret === "function" && ret !== cb2) {
1671
+ Object.keys(cb2).forEach(function(k) {
1672
+ ret[k] = cb2[k];
1673
+ });
1674
+ }
1675
+ return ret;
1676
+ }
1677
+ }
1678
+ }
1679
+ });
1680
+ var require_once = __commonJS2({
1681
+ "node_modules/once/once.js"(exports2, module2) {
1682
+ var wrappy = require_wrappy();
1683
+ module2.exports = wrappy(once);
1684
+ module2.exports.strict = wrappy(onceStrict);
1685
+ once.proto = once(function() {
1686
+ Object.defineProperty(Function.prototype, "once", {
1687
+ value: function() {
1688
+ return once(this);
1689
+ },
1690
+ configurable: true
1691
+ });
1692
+ Object.defineProperty(Function.prototype, "onceStrict", {
1693
+ value: function() {
1694
+ return onceStrict(this);
1695
+ },
1696
+ configurable: true
1697
+ });
1698
+ });
1699
+ function once(fn) {
1700
+ var f = function() {
1701
+ if (f.called)
1702
+ return f.value;
1703
+ f.called = true;
1704
+ return f.value = fn.apply(this, arguments);
1705
+ };
1706
+ f.called = false;
1707
+ return f;
1708
+ }
1709
+ function onceStrict(fn) {
1710
+ var f = function() {
1711
+ if (f.called)
1712
+ throw new Error(f.onceError);
1713
+ f.called = true;
1714
+ return f.value = fn.apply(this, arguments);
1715
+ };
1716
+ var name = fn.name || "Function wrapped with `once`";
1717
+ f.onceError = name + " shouldn't be called more than once";
1718
+ f.called = false;
1719
+ return f;
1720
+ }
1721
+ }
1722
+ });
1723
+ var require_inflight = __commonJS2({
1724
+ "node_modules/inflight/inflight.js"(exports2, module2) {
1725
+ var wrappy = require_wrappy();
1726
+ var reqs = /* @__PURE__ */ Object.create(null);
1727
+ var once = require_once();
1728
+ module2.exports = wrappy(inflight);
1729
+ function inflight(key, cb) {
1730
+ if (reqs[key]) {
1731
+ reqs[key].push(cb);
1732
+ return null;
1733
+ } else {
1734
+ reqs[key] = [cb];
1735
+ return makeres(key);
1736
+ }
1737
+ }
1738
+ function makeres(key) {
1739
+ return once(function RES() {
1740
+ var cbs = reqs[key];
1741
+ var len = cbs.length;
1742
+ var args = slice(arguments);
1743
+ try {
1744
+ for (var i = 0;i < len; i++) {
1745
+ cbs[i].apply(null, args);
1746
+ }
1747
+ } finally {
1748
+ if (cbs.length > len) {
1749
+ cbs.splice(0, len);
1750
+ process.nextTick(function() {
1751
+ RES.apply(null, args);
1752
+ });
1753
+ } else {
1754
+ delete reqs[key];
1755
+ }
1756
+ }
1757
+ });
1758
+ }
1759
+ function slice(args) {
1760
+ var length = args.length;
1761
+ var array = [];
1762
+ for (var i = 0;i < length; i++)
1763
+ array[i] = args[i];
1764
+ return array;
1765
+ }
1766
+ }
1767
+ });
1768
+ var require_glob = __commonJS2({
1769
+ "node_modules/glob/glob.js"(exports2, module2) {
1770
+ module2.exports = glob2;
1771
+ var rp = require_fs();
1772
+ var minimatch = require_minimatch();
1773
+ var Minimatch = minimatch.Minimatch;
1774
+ var inherits = require_inherits();
1775
+ var EE = __require("events").EventEmitter;
1776
+ var path2 = __require("path");
1777
+ var assert = __require("assert");
1778
+ var isAbsolute = __require("path").isAbsolute;
1779
+ var globSync = require_sync();
1780
+ var common = require_common();
1781
+ var setopts = common.setopts;
1782
+ var ownProp = common.ownProp;
1783
+ var inflight = require_inflight();
1784
+ var util = __require("util");
1785
+ var childrenIgnored = common.childrenIgnored;
1786
+ var isIgnored = common.isIgnored;
1787
+ var once = require_once();
1788
+ function glob2(pattern, options, cb) {
1789
+ if (typeof options === "function")
1790
+ cb = options, options = {};
1791
+ if (!options)
1792
+ options = {};
1793
+ if (options.sync) {
1794
+ if (cb)
1795
+ throw new TypeError("callback provided to sync glob");
1796
+ return globSync(pattern, options);
1797
+ }
1798
+ return new Glob(pattern, options, cb);
1799
+ }
1800
+ glob2.sync = globSync;
1801
+ var GlobSync = glob2.GlobSync = globSync.GlobSync;
1802
+ glob2.glob = glob2;
1803
+ function extend(origin, add) {
1804
+ if (add === null || typeof add !== "object") {
1805
+ return origin;
1806
+ }
1807
+ var keys = Object.keys(add);
1808
+ var i = keys.length;
1809
+ while (i--) {
1810
+ origin[keys[i]] = add[keys[i]];
1811
+ }
1812
+ return origin;
1813
+ }
1814
+ glob2.hasMagic = function(pattern, options_) {
1815
+ var options = extend({}, options_);
1816
+ options.noprocess = true;
1817
+ var g = new Glob(pattern, options);
1818
+ var set = g.minimatch.set;
1819
+ if (!pattern)
1820
+ return false;
1821
+ if (set.length > 1)
1822
+ return true;
1823
+ for (var j = 0;j < set[0].length; j++) {
1824
+ if (typeof set[0][j] !== "string")
1825
+ return true;
1826
+ }
1827
+ return false;
1828
+ };
1829
+ glob2.Glob = Glob;
1830
+ inherits(Glob, EE);
1831
+ function Glob(pattern, options, cb) {
1832
+ if (typeof options === "function") {
1833
+ cb = options;
1834
+ options = null;
1835
+ }
1836
+ if (options && options.sync) {
1837
+ if (cb)
1838
+ throw new TypeError("callback provided to sync glob");
1839
+ return new GlobSync(pattern, options);
1840
+ }
1841
+ if (!(this instanceof Glob))
1842
+ return new Glob(pattern, options, cb);
1843
+ setopts(this, pattern, options);
1844
+ this._didRealPath = false;
1845
+ var n = this.minimatch.set.length;
1846
+ this.matches = new Array(n);
1847
+ if (typeof cb === "function") {
1848
+ cb = once(cb);
1849
+ this.on("error", cb);
1850
+ this.on("end", function(matches) {
1851
+ cb(null, matches);
1852
+ });
1853
+ }
1854
+ var self = this;
1855
+ this._processing = 0;
1856
+ this._emitQueue = [];
1857
+ this._processQueue = [];
1858
+ this.paused = false;
1859
+ if (this.noprocess)
1860
+ return this;
1861
+ if (n === 0)
1862
+ return done();
1863
+ var sync = true;
1864
+ for (var i = 0;i < n; i++) {
1865
+ this._process(this.minimatch.set[i], i, false, done);
1866
+ }
1867
+ sync = false;
1868
+ function done() {
1869
+ --self._processing;
1870
+ if (self._processing <= 0) {
1871
+ if (sync) {
1872
+ process.nextTick(function() {
1873
+ self._finish();
1874
+ });
1875
+ } else {
1876
+ self._finish();
1877
+ }
1878
+ }
1879
+ }
1880
+ }
1881
+ Glob.prototype._finish = function() {
1882
+ assert(this instanceof Glob);
1883
+ if (this.aborted)
1884
+ return;
1885
+ if (this.realpath && !this._didRealpath)
1886
+ return this._realpath();
1887
+ common.finish(this);
1888
+ this.emit("end", this.found);
1889
+ };
1890
+ Glob.prototype._realpath = function() {
1891
+ if (this._didRealpath)
1892
+ return;
1893
+ this._didRealpath = true;
1894
+ var n = this.matches.length;
1895
+ if (n === 0)
1896
+ return this._finish();
1897
+ var self = this;
1898
+ for (var i = 0;i < this.matches.length; i++)
1899
+ this._realpathSet(i, next);
1900
+ function next() {
1901
+ if (--n === 0)
1902
+ self._finish();
1903
+ }
1904
+ };
1905
+ Glob.prototype._realpathSet = function(index, cb) {
1906
+ var matchset = this.matches[index];
1907
+ if (!matchset)
1908
+ return cb();
1909
+ var found = Object.keys(matchset);
1910
+ var self = this;
1911
+ var n = found.length;
1912
+ if (n === 0)
1913
+ return cb();
1914
+ var set = this.matches[index] = /* @__PURE__ */ Object.create(null);
1915
+ found.forEach(function(p, i) {
1916
+ p = self._makeAbs(p);
1917
+ rp.realpath(p, self.realpathCache, function(er, real) {
1918
+ if (!er)
1919
+ set[real] = true;
1920
+ else if (er.syscall === "stat")
1921
+ set[p] = true;
1922
+ else
1923
+ self.emit("error", er);
1924
+ if (--n === 0) {
1925
+ self.matches[index] = set;
1926
+ cb();
1927
+ }
1928
+ });
1929
+ });
1930
+ };
1931
+ Glob.prototype._mark = function(p) {
1932
+ return common.mark(this, p);
1933
+ };
1934
+ Glob.prototype._makeAbs = function(f) {
1935
+ return common.makeAbs(this, f);
1936
+ };
1937
+ Glob.prototype.abort = function() {
1938
+ this.aborted = true;
1939
+ this.emit("abort");
1940
+ };
1941
+ Glob.prototype.pause = function() {
1942
+ if (!this.paused) {
1943
+ this.paused = true;
1944
+ this.emit("pause");
1945
+ }
1946
+ };
1947
+ Glob.prototype.resume = function() {
1948
+ if (this.paused) {
1949
+ this.emit("resume");
1950
+ this.paused = false;
1951
+ if (this._emitQueue.length) {
1952
+ var eq = this._emitQueue.slice(0);
1953
+ this._emitQueue.length = 0;
1954
+ for (var i = 0;i < eq.length; i++) {
1955
+ var e = eq[i];
1956
+ this._emitMatch(e[0], e[1]);
1957
+ }
1958
+ }
1959
+ if (this._processQueue.length) {
1960
+ var pq = this._processQueue.slice(0);
1961
+ this._processQueue.length = 0;
1962
+ for (var i = 0;i < pq.length; i++) {
1963
+ var p = pq[i];
1964
+ this._processing--;
1965
+ this._process(p[0], p[1], p[2], p[3]);
1966
+ }
1967
+ }
1968
+ }
1969
+ };
1970
+ Glob.prototype._process = function(pattern, index, inGlobStar, cb) {
1971
+ assert(this instanceof Glob);
1972
+ assert(typeof cb === "function");
1973
+ if (this.aborted)
1974
+ return;
1975
+ this._processing++;
1976
+ if (this.paused) {
1977
+ this._processQueue.push([pattern, index, inGlobStar, cb]);
1978
+ return;
1979
+ }
1980
+ var n = 0;
1981
+ while (typeof pattern[n] === "string") {
1982
+ n++;
1983
+ }
1984
+ var prefix;
1985
+ switch (n) {
1986
+ case pattern.length:
1987
+ this._processSimple(pattern.join("/"), index, cb);
1988
+ return;
1989
+ case 0:
1990
+ prefix = null;
1991
+ break;
1992
+ default:
1993
+ prefix = pattern.slice(0, n).join("/");
1994
+ break;
1995
+ }
1996
+ var remain = pattern.slice(n);
1997
+ var read;
1998
+ if (prefix === null)
1999
+ read = ".";
2000
+ else if (isAbsolute(prefix) || isAbsolute(pattern.map(function(p) {
2001
+ return typeof p === "string" ? p : "[*]";
2002
+ }).join("/"))) {
2003
+ if (!prefix || !isAbsolute(prefix))
2004
+ prefix = "/" + prefix;
2005
+ read = prefix;
2006
+ } else
2007
+ read = prefix;
2008
+ var abs = this._makeAbs(read);
2009
+ if (childrenIgnored(this, read))
2010
+ return cb();
2011
+ var isGlobStar = remain[0] === minimatch.GLOBSTAR;
2012
+ if (isGlobStar)
2013
+ this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb);
2014
+ else
2015
+ this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb);
2016
+ };
2017
+ Glob.prototype._processReaddir = function(prefix, read, abs, remain, index, inGlobStar, cb) {
2018
+ var self = this;
2019
+ this._readdir(abs, inGlobStar, function(er, entries) {
2020
+ return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
2021
+ });
2022
+ };
2023
+ Glob.prototype._processReaddir2 = function(prefix, read, abs, remain, index, inGlobStar, entries, cb) {
2024
+ if (!entries)
2025
+ return cb();
2026
+ var pn = remain[0];
2027
+ var negate = !!this.minimatch.negate;
2028
+ var rawGlob = pn._glob;
2029
+ var dotOk = this.dot || rawGlob.charAt(0) === ".";
2030
+ var matchedEntries = [];
2031
+ for (var i = 0;i < entries.length; i++) {
2032
+ var e = entries[i];
2033
+ if (e.charAt(0) !== "." || dotOk) {
2034
+ var m;
2035
+ if (negate && !prefix) {
2036
+ m = !e.match(pn);
2037
+ } else {
2038
+ m = e.match(pn);
2039
+ }
2040
+ if (m)
2041
+ matchedEntries.push(e);
2042
+ }
2043
+ }
2044
+ var len = matchedEntries.length;
2045
+ if (len === 0)
2046
+ return cb();
2047
+ if (remain.length === 1 && !this.mark && !this.stat) {
2048
+ if (!this.matches[index])
2049
+ this.matches[index] = /* @__PURE__ */ Object.create(null);
2050
+ for (var i = 0;i < len; i++) {
2051
+ var e = matchedEntries[i];
2052
+ if (prefix) {
2053
+ if (prefix !== "/")
2054
+ e = prefix + "/" + e;
2055
+ else
2056
+ e = prefix + e;
2057
+ }
2058
+ if (e.charAt(0) === "/" && !this.nomount) {
2059
+ e = path2.join(this.root, e);
2060
+ }
2061
+ this._emitMatch(index, e);
2062
+ }
2063
+ return cb();
2064
+ }
2065
+ remain.shift();
2066
+ for (var i = 0;i < len; i++) {
2067
+ var e = matchedEntries[i];
2068
+ var newPattern;
2069
+ if (prefix) {
2070
+ if (prefix !== "/")
2071
+ e = prefix + "/" + e;
2072
+ else
2073
+ e = prefix + e;
2074
+ }
2075
+ this._process([e].concat(remain), index, inGlobStar, cb);
2076
+ }
2077
+ cb();
2078
+ };
2079
+ Glob.prototype._emitMatch = function(index, e) {
2080
+ if (this.aborted)
2081
+ return;
2082
+ if (isIgnored(this, e))
2083
+ return;
2084
+ if (this.paused) {
2085
+ this._emitQueue.push([index, e]);
2086
+ return;
2087
+ }
2088
+ var abs = isAbsolute(e) ? e : this._makeAbs(e);
2089
+ if (this.mark)
2090
+ e = this._mark(e);
2091
+ if (this.absolute)
2092
+ e = abs;
2093
+ if (this.matches[index][e])
2094
+ return;
2095
+ if (this.nodir) {
2096
+ var c = this.cache[abs];
2097
+ if (c === "DIR" || Array.isArray(c))
2098
+ return;
2099
+ }
2100
+ this.matches[index][e] = true;
2101
+ var st = this.statCache[abs];
2102
+ if (st)
2103
+ this.emit("stat", e, st);
2104
+ this.emit("match", e);
2105
+ };
2106
+ Glob.prototype._readdirInGlobStar = function(abs, cb) {
2107
+ if (this.aborted)
2108
+ return;
2109
+ if (this.follow)
2110
+ return this._readdir(abs, false, cb);
2111
+ var lstatkey = "lstat\x00" + abs;
2112
+ var self = this;
2113
+ var lstatcb = inflight(lstatkey, lstatcb_);
2114
+ if (lstatcb)
2115
+ self.fs.lstat(abs, lstatcb);
2116
+ function lstatcb_(er, lstat) {
2117
+ if (er && er.code === "ENOENT")
2118
+ return cb();
2119
+ var isSym = lstat && lstat.isSymbolicLink();
2120
+ self.symlinks[abs] = isSym;
2121
+ if (!isSym && lstat && !lstat.isDirectory()) {
2122
+ self.cache[abs] = "FILE";
2123
+ cb();
2124
+ } else
2125
+ self._readdir(abs, false, cb);
2126
+ }
2127
+ };
2128
+ Glob.prototype._readdir = function(abs, inGlobStar, cb) {
2129
+ if (this.aborted)
2130
+ return;
2131
+ cb = inflight("readdir\x00" + abs + "\x00" + inGlobStar, cb);
2132
+ if (!cb)
2133
+ return;
2134
+ if (inGlobStar && !ownProp(this.symlinks, abs))
2135
+ return this._readdirInGlobStar(abs, cb);
2136
+ if (ownProp(this.cache, abs)) {
2137
+ var c = this.cache[abs];
2138
+ if (!c || c === "FILE")
2139
+ return cb();
2140
+ if (Array.isArray(c))
2141
+ return cb(null, c);
2142
+ }
2143
+ var self = this;
2144
+ self.fs.readdir(abs, readdirCb(this, abs, cb));
2145
+ };
2146
+ function readdirCb(self, abs, cb) {
2147
+ return function(er, entries) {
2148
+ if (er)
2149
+ self._readdirError(abs, er, cb);
2150
+ else
2151
+ self._readdirEntries(abs, entries, cb);
2152
+ };
2153
+ }
2154
+ Glob.prototype._readdirEntries = function(abs, entries, cb) {
2155
+ if (this.aborted)
2156
+ return;
2157
+ if (!this.mark && !this.stat) {
2158
+ for (var i = 0;i < entries.length; i++) {
2159
+ var e = entries[i];
2160
+ if (abs === "/")
2161
+ e = abs + e;
2162
+ else
2163
+ e = abs + "/" + e;
2164
+ this.cache[e] = true;
2165
+ }
2166
+ }
2167
+ this.cache[abs] = entries;
2168
+ return cb(null, entries);
2169
+ };
2170
+ Glob.prototype._readdirError = function(f, er, cb) {
2171
+ if (this.aborted)
2172
+ return;
2173
+ switch (er.code) {
2174
+ case "ENOTSUP":
2175
+ case "ENOTDIR":
2176
+ var abs = this._makeAbs(f);
2177
+ this.cache[abs] = "FILE";
2178
+ if (abs === this.cwdAbs) {
2179
+ var error = new Error(er.code + " invalid cwd " + this.cwd);
2180
+ error.path = this.cwd;
2181
+ error.code = er.code;
2182
+ this.emit("error", error);
2183
+ this.abort();
2184
+ }
2185
+ break;
2186
+ case "ENOENT":
2187
+ case "ELOOP":
2188
+ case "ENAMETOOLONG":
2189
+ case "UNKNOWN":
2190
+ this.cache[this._makeAbs(f)] = false;
2191
+ break;
2192
+ default:
2193
+ this.cache[this._makeAbs(f)] = false;
2194
+ if (this.strict) {
2195
+ this.emit("error", er);
2196
+ this.abort();
2197
+ }
2198
+ if (!this.silent)
2199
+ console.error("glob error", er);
2200
+ break;
2201
+ }
2202
+ return cb();
2203
+ };
2204
+ Glob.prototype._processGlobStar = function(prefix, read, abs, remain, index, inGlobStar, cb) {
2205
+ var self = this;
2206
+ this._readdir(abs, inGlobStar, function(er, entries) {
2207
+ self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
2208
+ });
2209
+ };
2210
+ Glob.prototype._processGlobStar2 = function(prefix, read, abs, remain, index, inGlobStar, entries, cb) {
2211
+ if (!entries)
2212
+ return cb();
2213
+ var remainWithoutGlobStar = remain.slice(1);
2214
+ var gspref = prefix ? [prefix] : [];
2215
+ var noGlobStar = gspref.concat(remainWithoutGlobStar);
2216
+ this._process(noGlobStar, index, false, cb);
2217
+ var isSym = this.symlinks[abs];
2218
+ var len = entries.length;
2219
+ if (isSym && inGlobStar)
2220
+ return cb();
2221
+ for (var i = 0;i < len; i++) {
2222
+ var e = entries[i];
2223
+ if (e.charAt(0) === "." && !this.dot)
2224
+ continue;
2225
+ var instead = gspref.concat(entries[i], remainWithoutGlobStar);
2226
+ this._process(instead, index, true, cb);
2227
+ var below = gspref.concat(entries[i], remain);
2228
+ this._process(below, index, true, cb);
2229
+ }
2230
+ cb();
2231
+ };
2232
+ Glob.prototype._processSimple = function(prefix, index, cb) {
2233
+ var self = this;
2234
+ this._stat(prefix, function(er, exists) {
2235
+ self._processSimple2(prefix, index, er, exists, cb);
2236
+ });
2237
+ };
2238
+ Glob.prototype._processSimple2 = function(prefix, index, er, exists, cb) {
2239
+ if (!this.matches[index])
2240
+ this.matches[index] = /* @__PURE__ */ Object.create(null);
2241
+ if (!exists)
2242
+ return cb();
2243
+ if (prefix && isAbsolute(prefix) && !this.nomount) {
2244
+ var trail = /[\/\\]$/.test(prefix);
2245
+ if (prefix.charAt(0) === "/") {
2246
+ prefix = path2.join(this.root, prefix);
2247
+ } else {
2248
+ prefix = path2.resolve(this.root, prefix);
2249
+ if (trail)
2250
+ prefix += "/";
2251
+ }
2252
+ }
2253
+ if (process.platform === "win32")
2254
+ prefix = prefix.replace(/\\/g, "/");
2255
+ this._emitMatch(index, prefix);
2256
+ cb();
2257
+ };
2258
+ Glob.prototype._stat = function(f, cb) {
2259
+ var abs = this._makeAbs(f);
2260
+ var needDir = f.slice(-1) === "/";
2261
+ if (f.length > this.maxLength)
2262
+ return cb();
2263
+ if (!this.stat && ownProp(this.cache, abs)) {
2264
+ var c = this.cache[abs];
2265
+ if (Array.isArray(c))
2266
+ c = "DIR";
2267
+ if (!needDir || c === "DIR")
2268
+ return cb(null, c);
2269
+ if (needDir && c === "FILE")
2270
+ return cb();
2271
+ }
2272
+ var exists;
2273
+ var stat = this.statCache[abs];
2274
+ if (stat !== undefined) {
2275
+ if (stat === false)
2276
+ return cb(null, stat);
2277
+ else {
2278
+ var type = stat.isDirectory() ? "DIR" : "FILE";
2279
+ if (needDir && type === "FILE")
2280
+ return cb();
2281
+ else
2282
+ return cb(null, type, stat);
2283
+ }
2284
+ }
2285
+ var self = this;
2286
+ var statcb = inflight("stat\x00" + abs, lstatcb_);
2287
+ if (statcb)
2288
+ self.fs.lstat(abs, statcb);
2289
+ function lstatcb_(er, lstat) {
2290
+ if (lstat && lstat.isSymbolicLink()) {
2291
+ return self.fs.stat(abs, function(er2, stat2) {
2292
+ if (er2)
2293
+ self._stat2(f, abs, null, lstat, cb);
2294
+ else
2295
+ self._stat2(f, abs, er2, stat2, cb);
2296
+ });
2297
+ } else {
2298
+ self._stat2(f, abs, er, lstat, cb);
2299
+ }
2300
+ }
2301
+ };
2302
+ Glob.prototype._stat2 = function(f, abs, er, stat, cb) {
2303
+ if (er && (er.code === "ENOENT" || er.code === "ENOTDIR")) {
2304
+ this.statCache[abs] = false;
2305
+ return cb();
2306
+ }
2307
+ var needDir = f.slice(-1) === "/";
2308
+ this.statCache[abs] = stat;
2309
+ if (abs.slice(-1) === "/" && stat && !stat.isDirectory())
2310
+ return cb(null, false, stat);
2311
+ var c = true;
2312
+ if (stat)
2313
+ c = stat.isDirectory() ? "DIR" : "FILE";
2314
+ this.cache[abs] = this.cache[abs] || c;
2315
+ if (needDir && c === "FILE")
2316
+ return cb();
2317
+ return cb(null, c, stat);
2318
+ };
2319
+ }
2320
+ });
2321
+ var require_lib = __commonJS2({
2322
+ "node_modules/glob-promise/lib/index.js"(exports2, module2) {
2323
+ var glob2 = require_glob();
2324
+ var promise = function(pattern, options) {
2325
+ return new Promise((resolve, reject) => {
2326
+ glob2(pattern, options, (err, files) => err === null ? resolve(files) : reject(err));
2327
+ });
2328
+ };
2329
+ module2.exports = promise;
2330
+ module2.exports.glob = glob2;
2331
+ module2.exports.Glob = glob2.Glob;
2332
+ module2.exports.hasMagic = glob2.hasMagic;
2333
+ module2.exports.promise = promise;
2334
+ module2.exports.sync = glob2.sync;
2335
+ }
2336
+ });
2337
+ var src_exports = {};
2338
+ __export(src_exports, {
2339
+ getMatchingFilePaths: () => getMatchingFilePaths,
2340
+ getVirtualFileSystemFromDirPath: () => getVirtualFileSystemFromDirPath,
2341
+ getVirtualFilesystemModuleFromDirPath: () => getVirtualFilesystemModuleFromDirPath
2342
+ });
2343
+ module.exports = __toCommonJS(src_exports);
2344
+ var import_glob_promise = __toESM2(require_lib());
2345
+ var import_path = __toESM2(__require("path"));
2346
+ var import_promises = __toESM2(__require("fs/promises"));
2347
+ var charsSafeToLeaveEncoded = "{}.,<>?/:'[]!@#$^&*() -_=+".split("");
2348
+ var replaceSafeEncodedChars = (s) => {
2349
+ for (const char of charsSafeToLeaveEncoded) {
2350
+ if (char === encodeURIComponent(char))
2351
+ continue;
2352
+ s = s.replace(new RegExp(encodeURIComponent(char), "g"), char);
2353
+ }
2354
+ return s;
2355
+ };
2356
+ function idsafe(s) {
2357
+ return "_" + s.replace(/[^a-zA-Z0-9]/g, "_");
2358
+ }
2359
+ var toPosixPath = (pathStr) => {
2360
+ if (!pathStr)
2361
+ return pathStr;
2362
+ pathStr = pathStr.replace(/^[A-Za-z]:/, "");
2363
+ return pathStr.split(import_path.default.sep).join("/");
2364
+ };
2365
+ var getMatchingFilePaths = async ({
2366
+ dirPath,
2367
+ extensions,
2368
+ fileMatchFn
2369
+ }) => {
2370
+ if (extensions && fileMatchFn)
2371
+ throw new Error(`Cannot provide extensions and fileMatchFn`);
2372
+ if (extensions) {
2373
+ fileMatchFn = (filename) => extensions.some((ext) => filename.endsWith(`.${ext}`));
2374
+ }
2375
+ if (!fileMatchFn)
2376
+ fileMatchFn = () => true;
2377
+ const files = await (0, import_glob_promise.default)("**/*", {
2378
+ cwd: dirPath,
2379
+ nodir: true,
2380
+ dot: true,
2381
+ absolute: false,
2382
+ windowsPathsNoEscape: true
2383
+ });
2384
+ return files.map((f) => toPosixPath(f)).filter((filename) => fileMatchFn(filename, import_path.default.join(dirPath, filename)));
2385
+ };
2386
+ var getVirtualFileSystemFromDirPath = async (opts) => {
2387
+ const { dirPath, contentFormat = "string" } = opts;
2388
+ const filePaths = await getMatchingFilePaths(opts);
2389
+ const vfs = {};
2390
+ for (const filePath of filePaths) {
2391
+ const fullPath = import_path.default.join(dirPath, filePath);
2392
+ const content = await import_promises.default.readFile(fullPath);
2393
+ const normalizedPath = toPosixPath(filePath);
2394
+ vfs[normalizedPath] = content.toString();
2395
+ }
2396
+ return vfs;
2397
+ };
2398
+ var getVirtualFilesystemModuleFromDirPath = async (opts) => {
2399
+ const vfs = await getVirtualFileSystemFromDirPath(opts);
2400
+ const cf = opts.contentFormat;
2401
+ switch (cf ?? "buffer") {
2402
+ case "buffer":
2403
+ case "string": {
2404
+ return `export default {
2405
+ ` + Object.entries(vfs).map(([filePath, content]) => cf === "buffer" ? ` "${toPosixPath(filePath)}": Buffer.from("${content.toString("base64")}", "base64")` : ` "${toPosixPath(filePath)}": decodeURIComponent("${replaceSafeEncodedChars(encodeURIComponent(content.toString()))}")`).join(`,
2406
+ `) + `
2407
+ }`;
2408
+ }
2409
+ case "require":
2410
+ case "import-default":
2411
+ case "import-star": {
2412
+ if (!opts.targetPath)
2413
+ throw new Error(`targetPath is required when using content-format of require,import-default,import-star`);
2414
+ const basePath = import_path.default.relative(import_path.default.dirname(opts.targetPath), opts.dirPath);
2415
+ let fps = Object.keys(vfs);
2416
+ if (opts.noImportExt) {
2417
+ fps = fps.map((fp) => fp.replace(/\.[^.]+$/, ""));
2418
+ }
2419
+ return `${fps.map((fp) => cf === "require" ? `const ${idsafe(fp)} = require("./${import_path.default.join(basePath, fp)}")` : cf === "import-default" ? `import ${idsafe(fp)} from "./${import_path.default.join(basePath, fp)}"` : `import * as ${idsafe(fp)} from "./${import_path.default.join(basePath, fp)}"`).join(`
2420
+ `)}
2421
+
2422
+ export default {
2423
+ ` + fps.map((fp) => ` "${fp}": ${idsafe(fp)}`).join(`,
2424
+ `) + `
2425
+ }`;
2426
+ }
2427
+ case "arraybuffer": {
2428
+ throw new Error(`arraybuffer not yet implemented, contributions welcome`);
2429
+ }
2430
+ case "export-pathlist": {
2431
+ return `export default [
2432
+ ` + Object.keys(vfs).map((path2) => ` "${path2}"`).join(`,
2433
+ `) + `
2434
+ ]`;
2435
+ }
2436
+ case "import-bunfile": {
2437
+ if (!opts.targetPath)
2438
+ throw new Error(`targetPath is required when using content-format of require,import-default,import-star`);
2439
+ const basePath = import_path.default.relative(import_path.default.dirname(opts.targetPath), opts.dirPath);
2440
+ let fps = Object.keys(vfs);
2441
+ return `${fps.map((fp) => `import ${idsafe(fp)} from "./${import_path.default.join(basePath, fp)}" with { type: "file" };`).join(`
2442
+ `)}
2443
+
2444
+ import { file } from "bun";
2445
+
2446
+ export default {
2447
+ ` + fps.map((fp) => ` "${fp}": file(${idsafe(fp)})`).join(`,
2448
+ `) + `
2449
+ }`;
2450
+ }
2451
+ }
2452
+ throw new Error(`Unknown content format: ${cf}`);
2453
+ };
2454
+ });
2455
+
2456
+ // cli/build/build-worker-entrypoint.ts
2457
+ import path3 from "node:path";
2458
+ import fs3 from "node:fs";
2459
+ import { parentPort } from "node:worker_threads";
2460
+
2461
+ // lib/shared/generate-circuit-json.tsx
2462
+ var import_make_vfs = __toESM(require_dist(), 1);
2463
+ import path2 from "node:path";
2464
+ import fs2 from "node:fs";
2465
+ import { pathToFileURL } from "node:url";
2466
+ import Debug from "debug";
2467
+
2468
+ // lib/utils/abbreviate-stringify-object.ts
2469
+ var abbreviateStringifyObject = (obj) => {
2470
+ if (obj === null || obj === undefined)
2471
+ return obj;
2472
+ if (typeof obj !== "object")
2473
+ return obj;
2474
+ return JSON.stringify(Object.fromEntries(Object.entries(obj).map(([k, v]) => {
2475
+ return [
2476
+ k,
2477
+ typeof v === "string" ? v.slice(0, 100) : typeof v === "object" && v !== null ? abbreviateStringifyObject(v) : v
2478
+ ];
2479
+ })));
2480
+ };
2481
+
2482
+ // lib/shared/importFromUserLand.ts
2483
+ import { createRequire as createRequire2 } from "node:module";
2484
+ import fs from "node:fs";
2485
+ import path from "node:path";
2486
+ async function importFromUserLand(moduleName) {
2487
+ const userModulePath = path.join(process.cwd(), "node_modules", moduleName);
2488
+ if (fs.existsSync(userModulePath)) {
2489
+ const userRequire = createRequire2(path.join(process.cwd(), "noop.js"));
2490
+ try {
2491
+ const resolvedUserPath = userRequire.resolve(moduleName);
2492
+ return await import(resolvedUserPath);
2493
+ } catch (error) {
2494
+ if (error?.code !== "MODULE_NOT_FOUND") {
2495
+ throw error;
2496
+ }
2497
+ }
2498
+ }
2499
+ const cliRequire = createRequire2(import.meta.url);
2500
+ try {
2501
+ const resolvedCliPath = cliRequire.resolve(moduleName);
2502
+ return await import(resolvedCliPath);
2503
+ } catch (error) {
2504
+ if (error?.code !== "MODULE_NOT_FOUND") {
2505
+ throw error;
2506
+ }
2507
+ }
2508
+ return import(moduleName);
2509
+ }
2510
+
2511
+ // lib/shared/generate-circuit-json.tsx
2512
+ import { jsxDEV } from "react/jsx-dev-runtime";
2513
+ var debug = Debug("tsci:generate-circuit-json");
2514
+ var ALLOWED_FILE_EXTENSIONS = [
2515
+ ".tsx",
2516
+ ".ts",
2517
+ ".jsx",
2518
+ ".js",
2519
+ ".json",
2520
+ ".txt",
2521
+ ".md",
2522
+ ".obj",
2523
+ ".kicad_mod"
2524
+ ];
2525
+ async function generateCircuitJson({
2526
+ filePath,
2527
+ outputDir,
2528
+ outputFileName,
2529
+ saveToFile = false,
2530
+ platformConfig
2531
+ }) {
2532
+ debug(`Generating circuit JSON for ${filePath}`);
2533
+ const React = await importFromUserLand("react");
2534
+ globalThis.React = React;
2535
+ const userLandTscircuit = await importFromUserLand("tscircuit");
2536
+ const runner = new userLandTscircuit.RootCircuit({
2537
+ platform: platformConfig
2538
+ });
2539
+ const absoluteFilePath = path2.isAbsolute(filePath) ? filePath : path2.resolve(process.cwd(), filePath);
2540
+ const projectDir = path2.dirname(absoluteFilePath);
2541
+ const resolvedOutputDir = outputDir ?? projectDir;
2542
+ const relativeComponentPath = path2.relative(projectDir, absoluteFilePath);
2543
+ const baseFileName = outputFileName || path2.basename(absoluteFilePath).replace(/\.[^.]+$/, "");
2544
+ const outputPath = path2.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
2545
+ debug(`Project directory: ${projectDir}`);
2546
+ debug(`Relative component path: ${relativeComponentPath}`);
2547
+ debug(`Output path: ${outputPath}`);
2548
+ const fsMap = {
2549
+ ...await import_make_vfs.getVirtualFileSystemFromDirPath({
2550
+ dirPath: projectDir,
2551
+ fileMatchFn: (filePath2) => {
2552
+ const normalizedFilePath = filePath2.replace(/\\/g, "/");
2553
+ if (normalizedFilePath.endsWith(".kicad_mod")) {
2554
+ return true;
2555
+ }
2556
+ if (normalizedFilePath.includes("node_modules/"))
2557
+ return false;
2558
+ if (normalizedFilePath.includes("dist/"))
2559
+ return false;
2560
+ if (normalizedFilePath.includes("build/"))
2561
+ return false;
2562
+ if (normalizedFilePath.match(/^\.[^/]/))
2563
+ return false;
2564
+ if (!ALLOWED_FILE_EXTENSIONS.includes(path2.extname(normalizedFilePath)))
2565
+ return false;
2566
+ return true;
2567
+ },
2568
+ contentFormat: "string"
2569
+ })
2570
+ };
2571
+ debug(`fsMap: ${abbreviateStringifyObject(fsMap)}`);
2572
+ const MainComponent = await import(pathToFileURL(absoluteFilePath).href);
2573
+ const Component = MainComponent.default || (Object.keys(MainComponent).find((k) => k[0] === k[0].toUpperCase()) !== undefined ? MainComponent[Object.keys(MainComponent).find((k) => k[0] === k[0].toUpperCase())] : undefined);
2574
+ if (!Component) {
2575
+ throw new Error(`No component found in "${absoluteFilePath}". Make sure you export a component.`);
2576
+ }
2577
+ runner.add(/* @__PURE__ */ jsxDEV(Component, {}, undefined, false, undefined, this));
2578
+ await runner.renderUntilSettled();
2579
+ const circuitJson = await runner.getCircuitJson();
2580
+ if (saveToFile) {
2581
+ debug(`Saving circuit JSON to ${outputPath}`);
2582
+ fs2.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
2583
+ }
2584
+ return {
2585
+ circuitJson,
2586
+ outputPath
2587
+ };
2588
+ }
2589
+
2590
+ // lib/shared/circuit-json-diagnostics.ts
2591
+ function analyzeCircuitJson(circuitJson) {
2592
+ const errors = [];
2593
+ const warnings = [];
2594
+ for (const item of circuitJson) {
2595
+ if (!item || typeof item !== "object")
2596
+ continue;
2597
+ const t = item.type;
2598
+ if (typeof t === "string") {
2599
+ if (t.endsWith("_error"))
2600
+ errors.push(item);
2601
+ else if (t.endsWith("_warning"))
2602
+ warnings.push(item);
2603
+ }
2604
+ if ("error_type" in item)
2605
+ errors.push(item);
2606
+ if ("warning_type" in item)
2607
+ warnings.push(item);
2608
+ }
2609
+ return { errors, warnings };
2610
+ }
2611
+
2612
+ // lib/shared/get-complete-platform-config.ts
2613
+ import { getPlatformConfig } from "@tscircuit/eval/platform-config";
2614
+ function getCompletePlatformConfig(userConfig) {
2615
+ const basePlatformConfig = getPlatformConfig();
2616
+ const defaultConfig = {
2617
+ ...basePlatformConfig,
2618
+ footprintFileParserMap: {
2619
+ ...basePlatformConfig.footprintFileParserMap,
2620
+ kicad_mod: {
2621
+ loadFromUrl: async (url) => {
2622
+ const fetchUrl = url.startsWith("/") ? `file://${url}` : url;
2623
+ return basePlatformConfig.footprintFileParserMap.kicad_mod.loadFromUrl(fetchUrl);
2624
+ }
2625
+ }
2626
+ }
2627
+ };
2628
+ if (!userConfig) {
2629
+ return defaultConfig;
2630
+ }
2631
+ return {
2632
+ ...defaultConfig,
2633
+ ...userConfig,
2634
+ footprintFileParserMap: {
2635
+ ...defaultConfig.footprintFileParserMap,
2636
+ ...userConfig.footprintFileParserMap
2637
+ }
2638
+ };
2639
+ }
2640
+
2641
+ // lib/shared/register-static-asset-loaders.ts
2642
+ var TEXT_STATIC_ASSET_EXTENSIONS = [
2643
+ ".gltf",
2644
+ ".step",
2645
+ ".kicad_mod",
2646
+ ".kicad_pcb",
2647
+ ".kicad_pro",
2648
+ ".kicad_sch"
2649
+ ];
2650
+ var staticAssetFilter = new RegExp(`(${TEXT_STATIC_ASSET_EXTENSIONS.map((ext) => ext.replace(".", "\\.")).join("|")})$`, "i");
2651
+ var registered = false;
2652
+ var registerStaticAssetLoaders = () => {
2653
+ if (registered)
2654
+ return;
2655
+ registered = true;
2656
+ if (typeof Bun !== "undefined" && typeof Bun.plugin === "function") {
2657
+ Bun.plugin({
2658
+ name: "tsci-static-assets",
2659
+ setup(build) {
2660
+ build.onLoad({ filter: staticAssetFilter }, (args) => {
2661
+ return {
2662
+ contents: `export default ${JSON.stringify(args.path)};`,
2663
+ loader: "js"
2664
+ };
2665
+ });
2666
+ }
2667
+ });
2668
+ }
2669
+ };
2670
+
2671
+ // cli/build/build-worker-entrypoint.ts
2672
+ if (!parentPort) {
2673
+ throw new Error("This file must be run as a worker thread");
2674
+ }
2675
+ var sendMessage = (message) => {
2676
+ parentPort.postMessage(message);
2677
+ };
2678
+ var workerLog = (...args) => {
2679
+ const line = args.map((arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)).join(" ");
2680
+ const message = {
2681
+ message_type: "worker_log",
2682
+ log_lines: [line]
2683
+ };
2684
+ sendMessage(message);
2685
+ };
2686
+ var handleBuildFile = async (filePath, outputPath, projectDir, options) => {
2687
+ const errors = [];
2688
+ const warnings = [];
2689
+ try {
2690
+ process.chdir(projectDir);
2691
+ workerLog(`Generating circuit JSON for ${path3.relative(projectDir, filePath)}...`);
2692
+ await registerStaticAssetLoaders();
2693
+ const completePlatformConfig = getCompletePlatformConfig(options?.platformConfig);
2694
+ const result = await generateCircuitJson({
2695
+ filePath,
2696
+ platformConfig: completePlatformConfig
2697
+ });
2698
+ fs3.mkdirSync(path3.dirname(outputPath), { recursive: true });
2699
+ fs3.writeFileSync(outputPath, JSON.stringify(result.circuitJson, null, 2));
2700
+ workerLog(`Circuit JSON written to ${path3.relative(projectDir, outputPath)}`);
2701
+ const diagnostics = analyzeCircuitJson(result.circuitJson);
2702
+ if (!options?.ignoreWarnings) {
2703
+ for (const warn of diagnostics.warnings) {
2704
+ const msg = warn.message || JSON.stringify(warn);
2705
+ warnings.push(msg);
2706
+ workerLog(`Warning: ${msg}`);
2707
+ }
2708
+ }
2709
+ if (!options?.ignoreErrors) {
2710
+ for (const err of diagnostics.errors) {
2711
+ const msg = err.message || JSON.stringify(err);
2712
+ errors.push(msg);
2713
+ workerLog(`Error: ${msg}`);
2714
+ }
2715
+ }
2716
+ const hasErrors = diagnostics.errors.length > 0 && !options?.ignoreErrors;
2717
+ return {
2718
+ message_type: "build_completed",
2719
+ file_path: filePath,
2720
+ output_path: outputPath,
2721
+ circuit_json_path: outputPath,
2722
+ ok: !hasErrors,
2723
+ errors,
2724
+ warnings
2725
+ };
2726
+ } catch (err) {
2727
+ const errorMsg = err instanceof Error ? err.message : String(err);
2728
+ errors.push(errorMsg);
2729
+ workerLog(`Build error: ${errorMsg}`);
2730
+ return {
2731
+ message_type: "build_completed",
2732
+ file_path: filePath,
2733
+ output_path: outputPath,
2734
+ circuit_json_path: outputPath,
2735
+ ok: false,
2736
+ errors,
2737
+ warnings
2738
+ };
2739
+ }
2740
+ };
2741
+ parentPort.on("message", async (msg) => {
2742
+ if (msg.message_type === "build_file") {
2743
+ const result = await handleBuildFile(msg.file_path, msg.output_path, msg.project_dir, msg.options);
2744
+ sendMessage(result);
2745
+ }
2746
+ });