@better-fullstack/template-generator 1.0.0-canary.c9b74dcc

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 (37) hide show
  1. package/dist/core/template-reader.d.mts +11 -0
  2. package/dist/core/template-reader.d.mts.map +1 -0
  3. package/dist/core/template-reader.mjs +4 -0
  4. package/dist/fs-writer.d.mts +8 -0
  5. package/dist/fs-writer.d.mts.map +1 -0
  6. package/dist/fs-writer.mjs +51 -0
  7. package/dist/fs-writer.mjs.map +1 -0
  8. package/dist/index.d.mts +442 -0
  9. package/dist/index.d.mts.map +1 -0
  10. package/dist/index.mjs +46568 -0
  11. package/dist/index.mjs.map +1 -0
  12. package/dist/is-binary-path-BN88l03c.mjs +282 -0
  13. package/dist/is-binary-path-BN88l03c.mjs.map +1 -0
  14. package/dist/template-reader-DOXCnctl.mjs +2564 -0
  15. package/dist/template-reader-DOXCnctl.mjs.map +1 -0
  16. package/dist/types-4RpstO2l.d.mts +37 -0
  17. package/dist/types-4RpstO2l.d.mts.map +1 -0
  18. package/package.json +68 -0
  19. package/templates-binary/addons/pwa/apps/web/next/public/favicon/apple-touch-icon.png +0 -0
  20. package/templates-binary/addons/pwa/apps/web/next/public/favicon/favicon-96x96.png +0 -0
  21. package/templates-binary/addons/pwa/apps/web/next/public/favicon/web-app-manifest-192x192.png +0 -0
  22. package/templates-binary/addons/pwa/apps/web/next/public/favicon/web-app-manifest-512x512.png +0 -0
  23. package/templates-binary/addons/pwa/apps/web/vite/public/logo.png +0 -0
  24. package/templates-binary/frontend/native/base/assets/images/android-icon-background.png +0 -0
  25. package/templates-binary/frontend/native/base/assets/images/android-icon-foreground.png +0 -0
  26. package/templates-binary/frontend/native/base/assets/images/android-icon-monochrome.png +0 -0
  27. package/templates-binary/frontend/native/base/assets/images/favicon.png +0 -0
  28. package/templates-binary/frontend/native/base/assets/images/icon.png +0 -0
  29. package/templates-binary/frontend/native/base/assets/images/partial-react-logo.png +0 -0
  30. package/templates-binary/frontend/native/base/assets/images/react-logo.png +0 -0
  31. package/templates-binary/frontend/native/base/assets/images/react-logo@2x.png +0 -0
  32. package/templates-binary/frontend/native/base/assets/images/react-logo@3x.png +0 -0
  33. package/templates-binary/frontend/native/base/assets/images/splash-icon.png +0 -0
  34. package/templates-binary/frontend/nuxt/public/favicon.ico +0 -0
  35. package/templates-binary/frontend/react/next/src/app/favicon.ico +0 -0
  36. package/templates-binary/frontend/react/react-router/public/favicon.ico +0 -0
  37. package/templates-binary/frontend/svelte/static/favicon.png +0 -0
@@ -0,0 +1,2564 @@
1
+ import { t as isBinaryPath } from "./is-binary-path-BN88l03c.mjs";
2
+ import { dirname, join } from "pathe";
3
+ import fs from "node:fs";
4
+ import { fileURLToPath } from "node:url";
5
+ import * as nativeFs$1 from "fs";
6
+ import nativeFs from "fs";
7
+ import path, { basename, dirname as dirname$1, normalize as normalize$1, posix, relative, resolve, sep } from "path";
8
+ import { fileURLToPath as fileURLToPath$1 } from "url";
9
+ import { createRequire } from "module";
10
+
11
+ //#region rolldown:runtime
12
+ var __create = Object.create;
13
+ var __defProp = Object.defineProperty;
14
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
+ var __getOwnPropNames = Object.getOwnPropertyNames;
16
+ var __getProtoOf = Object.getPrototypeOf;
17
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
18
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
22
+ key = keys[i];
23
+ if (!__hasOwnProp.call(to, key) && key !== except) {
24
+ __defProp(to, key, {
25
+ get: ((k) => from[k]).bind(null, key),
26
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
27
+ });
28
+ }
29
+ }
30
+ }
31
+ return to;
32
+ };
33
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
34
+ value: mod,
35
+ enumerable: true
36
+ }) : target, mod));
37
+
38
+ //#endregion
39
+ //#region ../../node_modules/.bun/fdir@6.5.0+a185e370e160e74e/node_modules/fdir/dist/index.mjs
40
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
41
+ function cleanPath(path$1) {
42
+ let normalized = normalize$1(path$1);
43
+ if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
44
+ return normalized;
45
+ }
46
+ const SLASHES_REGEX = /[\\/]/g;
47
+ function convertSlashes(path$1, separator) {
48
+ return path$1.replace(SLASHES_REGEX, separator);
49
+ }
50
+ const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
51
+ function isRootDirectory(path$1) {
52
+ return path$1 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path$1);
53
+ }
54
+ function normalizePath(path$1, options) {
55
+ const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
56
+ const pathNeedsCleaning = process.platform === "win32" && path$1.includes("/") || path$1.startsWith(".");
57
+ if (resolvePaths) path$1 = resolve(path$1);
58
+ if (normalizePath$1 || pathNeedsCleaning) path$1 = cleanPath(path$1);
59
+ if (path$1 === ".") return "";
60
+ return convertSlashes(path$1[path$1.length - 1] !== pathSeparator ? path$1 + pathSeparator : path$1, pathSeparator);
61
+ }
62
+ function joinPathWithBasePath(filename, directoryPath) {
63
+ return directoryPath + filename;
64
+ }
65
+ function joinPathWithRelativePath(root, options) {
66
+ return function(filename, directoryPath) {
67
+ if (directoryPath.startsWith(root)) return directoryPath.slice(root.length) + filename;
68
+ else return convertSlashes(relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
69
+ };
70
+ }
71
+ function joinPath(filename) {
72
+ return filename;
73
+ }
74
+ function joinDirectoryPath(filename, directoryPath, separator) {
75
+ return directoryPath + filename + separator;
76
+ }
77
+ function build$7(root, options) {
78
+ const { relativePaths, includeBasePath } = options;
79
+ return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
80
+ }
81
+ function pushDirectoryWithRelativePath(root) {
82
+ return function(directoryPath, paths) {
83
+ paths.push(directoryPath.substring(root.length) || ".");
84
+ };
85
+ }
86
+ function pushDirectoryFilterWithRelativePath(root) {
87
+ return function(directoryPath, paths, filters) {
88
+ const relativePath = directoryPath.substring(root.length) || ".";
89
+ if (filters.every((filter) => filter(relativePath, true))) paths.push(relativePath);
90
+ };
91
+ }
92
+ const pushDirectory = (directoryPath, paths) => {
93
+ paths.push(directoryPath || ".");
94
+ };
95
+ const pushDirectoryFilter = (directoryPath, paths, filters) => {
96
+ const path$1 = directoryPath || ".";
97
+ if (filters.every((filter) => filter(path$1, true))) paths.push(path$1);
98
+ };
99
+ const empty$2 = () => {};
100
+ function build$6(root, options) {
101
+ const { includeDirs, filters, relativePaths } = options;
102
+ if (!includeDirs) return empty$2;
103
+ if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
104
+ return filters && filters.length ? pushDirectoryFilter : pushDirectory;
105
+ }
106
+ const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
107
+ if (filters.every((filter) => filter(filename, false))) counts.files++;
108
+ };
109
+ const pushFileFilter = (filename, paths, _counts, filters) => {
110
+ if (filters.every((filter) => filter(filename, false))) paths.push(filename);
111
+ };
112
+ const pushFileCount = (_filename, _paths, counts, _filters) => {
113
+ counts.files++;
114
+ };
115
+ const pushFile = (filename, paths) => {
116
+ paths.push(filename);
117
+ };
118
+ const empty$1 = () => {};
119
+ function build$5(options) {
120
+ const { excludeFiles, filters, onlyCounts } = options;
121
+ if (excludeFiles) return empty$1;
122
+ if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
123
+ else if (onlyCounts) return pushFileCount;
124
+ else return pushFile;
125
+ }
126
+ const getArray = (paths) => {
127
+ return paths;
128
+ };
129
+ const getArrayGroup = () => {
130
+ return [""].slice(0, 0);
131
+ };
132
+ function build$4(options) {
133
+ return options.group ? getArrayGroup : getArray;
134
+ }
135
+ const groupFiles = (groups, directory, files) => {
136
+ groups.push({
137
+ directory,
138
+ files,
139
+ dir: directory
140
+ });
141
+ };
142
+ const empty = () => {};
143
+ function build$3(options) {
144
+ return options.group ? groupFiles : empty;
145
+ }
146
+ const resolveSymlinksAsync = function(path$1, state, callback$1) {
147
+ const { queue, fs: fs$1, options: { suppressErrors } } = state;
148
+ queue.enqueue();
149
+ fs$1.realpath(path$1, (error, resolvedPath) => {
150
+ if (error) return queue.dequeue(suppressErrors ? null : error, state);
151
+ fs$1.stat(resolvedPath, (error$1, stat) => {
152
+ if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
153
+ if (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return queue.dequeue(null, state);
154
+ callback$1(stat, resolvedPath);
155
+ queue.dequeue(null, state);
156
+ });
157
+ });
158
+ };
159
+ const resolveSymlinks = function(path$1, state, callback$1) {
160
+ const { queue, fs: fs$1, options: { suppressErrors } } = state;
161
+ queue.enqueue();
162
+ try {
163
+ const resolvedPath = fs$1.realpathSync(path$1);
164
+ const stat = fs$1.statSync(resolvedPath);
165
+ if (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return;
166
+ callback$1(stat, resolvedPath);
167
+ } catch (e) {
168
+ if (!suppressErrors) throw e;
169
+ }
170
+ };
171
+ function build$2(options, isSynchronous) {
172
+ if (!options.resolveSymlinks || options.excludeSymlinks) return null;
173
+ return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
174
+ }
175
+ function isRecursive(path$1, resolved, state) {
176
+ if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
177
+ let parent = dirname$1(path$1);
178
+ let depth$1 = 1;
179
+ while (parent !== state.root && depth$1 < 2) {
180
+ const resolvedPath = state.symlinks.get(parent);
181
+ if (!!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath))) depth$1++;
182
+ else parent = dirname$1(parent);
183
+ }
184
+ state.symlinks.set(path$1, resolved);
185
+ return depth$1 > 1;
186
+ }
187
+ function isRecursiveUsingRealPaths(resolved, state) {
188
+ return state.visited.includes(resolved + state.options.pathSeparator);
189
+ }
190
+ const onlyCountsSync = (state) => {
191
+ return state.counts;
192
+ };
193
+ const groupsSync = (state) => {
194
+ return state.groups;
195
+ };
196
+ const defaultSync = (state) => {
197
+ return state.paths;
198
+ };
199
+ const limitFilesSync = (state) => {
200
+ return state.paths.slice(0, state.options.maxFiles);
201
+ };
202
+ const onlyCountsAsync = (state, error, callback$1) => {
203
+ report(error, callback$1, state.counts, state.options.suppressErrors);
204
+ return null;
205
+ };
206
+ const defaultAsync = (state, error, callback$1) => {
207
+ report(error, callback$1, state.paths, state.options.suppressErrors);
208
+ return null;
209
+ };
210
+ const limitFilesAsync = (state, error, callback$1) => {
211
+ report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
212
+ return null;
213
+ };
214
+ const groupsAsync = (state, error, callback$1) => {
215
+ report(error, callback$1, state.groups, state.options.suppressErrors);
216
+ return null;
217
+ };
218
+ function report(error, callback$1, output, suppressErrors) {
219
+ if (error && !suppressErrors) callback$1(error, output);
220
+ else callback$1(null, output);
221
+ }
222
+ function build$1(options, isSynchronous) {
223
+ const { onlyCounts, group, maxFiles } = options;
224
+ if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
225
+ else if (group) return isSynchronous ? groupsSync : groupsAsync;
226
+ else if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
227
+ else return isSynchronous ? defaultSync : defaultAsync;
228
+ }
229
+ const readdirOpts = { withFileTypes: true };
230
+ const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
231
+ state.queue.enqueue();
232
+ if (currentDepth < 0) return state.queue.dequeue(null, state);
233
+ const { fs: fs$1 } = state;
234
+ state.visited.push(crawlPath);
235
+ state.counts.directories++;
236
+ fs$1.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
237
+ callback$1(entries, directoryPath, currentDepth);
238
+ state.queue.dequeue(state.options.suppressErrors ? null : error, state);
239
+ });
240
+ };
241
+ const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
242
+ const { fs: fs$1 } = state;
243
+ if (currentDepth < 0) return;
244
+ state.visited.push(crawlPath);
245
+ state.counts.directories++;
246
+ let entries = [];
247
+ try {
248
+ entries = fs$1.readdirSync(crawlPath || ".", readdirOpts);
249
+ } catch (e) {
250
+ if (!state.options.suppressErrors) throw e;
251
+ }
252
+ callback$1(entries, directoryPath, currentDepth);
253
+ };
254
+ function build(isSynchronous) {
255
+ return isSynchronous ? walkSync : walkAsync;
256
+ }
257
+ /**
258
+ * This is a custom stateless queue to track concurrent async fs calls.
259
+ * It increments a counter whenever a call is queued and decrements it
260
+ * as soon as it completes. When the counter hits 0, it calls onQueueEmpty.
261
+ */
262
+ var Queue = class {
263
+ count = 0;
264
+ constructor(onQueueEmpty) {
265
+ this.onQueueEmpty = onQueueEmpty;
266
+ }
267
+ enqueue() {
268
+ this.count++;
269
+ return this.count;
270
+ }
271
+ dequeue(error, output) {
272
+ if (this.onQueueEmpty && (--this.count <= 0 || error)) {
273
+ this.onQueueEmpty(error, output);
274
+ if (error) {
275
+ output.controller.abort();
276
+ this.onQueueEmpty = void 0;
277
+ }
278
+ }
279
+ }
280
+ };
281
+ var Counter = class {
282
+ _files = 0;
283
+ _directories = 0;
284
+ set files(num) {
285
+ this._files = num;
286
+ }
287
+ get files() {
288
+ return this._files;
289
+ }
290
+ set directories(num) {
291
+ this._directories = num;
292
+ }
293
+ get directories() {
294
+ return this._directories;
295
+ }
296
+ /**
297
+ * @deprecated use `directories` instead
298
+ */
299
+ /* c8 ignore next 3 */
300
+ get dirs() {
301
+ return this._directories;
302
+ }
303
+ };
304
+ /**
305
+ * AbortController is not supported on Node 14 so we use this until we can drop
306
+ * support for Node 14.
307
+ */
308
+ var Aborter = class {
309
+ aborted = false;
310
+ abort() {
311
+ this.aborted = true;
312
+ }
313
+ };
314
+ var Walker = class {
315
+ root;
316
+ isSynchronous;
317
+ state;
318
+ joinPath;
319
+ pushDirectory;
320
+ pushFile;
321
+ getArray;
322
+ groupFiles;
323
+ resolveSymlink;
324
+ walkDirectory;
325
+ callbackInvoker;
326
+ constructor(root, options, callback$1) {
327
+ this.isSynchronous = !callback$1;
328
+ this.callbackInvoker = build$1(options, this.isSynchronous);
329
+ this.root = normalizePath(root, options);
330
+ this.state = {
331
+ root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
332
+ paths: [""].slice(0, 0),
333
+ groups: [],
334
+ counts: new Counter(),
335
+ options,
336
+ queue: new Queue((error, state) => this.callbackInvoker(state, error, callback$1)),
337
+ symlinks: /* @__PURE__ */ new Map(),
338
+ visited: [""].slice(0, 0),
339
+ controller: new Aborter(),
340
+ fs: options.fs || nativeFs$1
341
+ };
342
+ this.joinPath = build$7(this.root, options);
343
+ this.pushDirectory = build$6(this.root, options);
344
+ this.pushFile = build$5(options);
345
+ this.getArray = build$4(options);
346
+ this.groupFiles = build$3(options);
347
+ this.resolveSymlink = build$2(options, this.isSynchronous);
348
+ this.walkDirectory = build(this.isSynchronous);
349
+ }
350
+ start() {
351
+ this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
352
+ this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
353
+ return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
354
+ }
355
+ walk = (entries, directoryPath, depth$1) => {
356
+ const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
357
+ if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
358
+ const files = this.getArray(this.state.paths);
359
+ for (let i = 0; i < entries.length; ++i) {
360
+ const entry = entries[i];
361
+ if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
362
+ const filename = this.joinPath(entry.name, directoryPath);
363
+ this.pushFile(filename, files, this.state.counts, filters);
364
+ } else if (entry.isDirectory()) {
365
+ let path$1 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
366
+ if (exclude && exclude(entry.name, path$1)) continue;
367
+ this.pushDirectory(path$1, paths, filters);
368
+ this.walkDirectory(this.state, path$1, path$1, depth$1 - 1, this.walk);
369
+ } else if (this.resolveSymlink && entry.isSymbolicLink()) {
370
+ let path$1 = joinPathWithBasePath(entry.name, directoryPath);
371
+ this.resolveSymlink(path$1, this.state, (stat, resolvedPath) => {
372
+ if (stat.isDirectory()) {
373
+ resolvedPath = normalizePath(resolvedPath, this.state.options);
374
+ if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$1 + pathSeparator)) return;
375
+ this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$1 + pathSeparator, depth$1 - 1, this.walk);
376
+ } else {
377
+ resolvedPath = useRealPaths ? resolvedPath : path$1;
378
+ const filename = basename(resolvedPath);
379
+ const directoryPath$1 = normalizePath(dirname$1(resolvedPath), this.state.options);
380
+ resolvedPath = this.joinPath(filename, directoryPath$1);
381
+ this.pushFile(resolvedPath, files, this.state.counts, filters);
382
+ }
383
+ });
384
+ }
385
+ }
386
+ this.groupFiles(this.state.groups, directoryPath, files);
387
+ };
388
+ };
389
+ function promise(root, options) {
390
+ return new Promise((resolve$1, reject) => {
391
+ callback(root, options, (err, output) => {
392
+ if (err) return reject(err);
393
+ resolve$1(output);
394
+ });
395
+ });
396
+ }
397
+ function callback(root, options, callback$1) {
398
+ new Walker(root, options, callback$1).start();
399
+ }
400
+ function sync(root, options) {
401
+ return new Walker(root, options).start();
402
+ }
403
+ var APIBuilder = class {
404
+ constructor(root, options) {
405
+ this.root = root;
406
+ this.options = options;
407
+ }
408
+ withPromise() {
409
+ return promise(this.root, this.options);
410
+ }
411
+ withCallback(cb) {
412
+ callback(this.root, this.options, cb);
413
+ }
414
+ sync() {
415
+ return sync(this.root, this.options);
416
+ }
417
+ };
418
+ let pm = null;
419
+ /* c8 ignore next 6 */
420
+ try {
421
+ __require.resolve("picomatch");
422
+ pm = __require("picomatch");
423
+ } catch {}
424
+ var Builder = class {
425
+ globCache = {};
426
+ options = {
427
+ maxDepth: Infinity,
428
+ suppressErrors: true,
429
+ pathSeparator: sep,
430
+ filters: []
431
+ };
432
+ globFunction;
433
+ constructor(options) {
434
+ this.options = {
435
+ ...this.options,
436
+ ...options
437
+ };
438
+ this.globFunction = this.options.globFunction;
439
+ }
440
+ group() {
441
+ this.options.group = true;
442
+ return this;
443
+ }
444
+ withPathSeparator(separator) {
445
+ this.options.pathSeparator = separator;
446
+ return this;
447
+ }
448
+ withBasePath() {
449
+ this.options.includeBasePath = true;
450
+ return this;
451
+ }
452
+ withRelativePaths() {
453
+ this.options.relativePaths = true;
454
+ return this;
455
+ }
456
+ withDirs() {
457
+ this.options.includeDirs = true;
458
+ return this;
459
+ }
460
+ withMaxDepth(depth$1) {
461
+ this.options.maxDepth = depth$1;
462
+ return this;
463
+ }
464
+ withMaxFiles(limit) {
465
+ this.options.maxFiles = limit;
466
+ return this;
467
+ }
468
+ withFullPaths() {
469
+ this.options.resolvePaths = true;
470
+ this.options.includeBasePath = true;
471
+ return this;
472
+ }
473
+ withErrors() {
474
+ this.options.suppressErrors = false;
475
+ return this;
476
+ }
477
+ withSymlinks({ resolvePaths = true } = {}) {
478
+ this.options.resolveSymlinks = true;
479
+ this.options.useRealPaths = resolvePaths;
480
+ return this.withFullPaths();
481
+ }
482
+ withAbortSignal(signal) {
483
+ this.options.signal = signal;
484
+ return this;
485
+ }
486
+ normalize() {
487
+ this.options.normalizePath = true;
488
+ return this;
489
+ }
490
+ filter(predicate) {
491
+ this.options.filters.push(predicate);
492
+ return this;
493
+ }
494
+ onlyDirs() {
495
+ this.options.excludeFiles = true;
496
+ this.options.includeDirs = true;
497
+ return this;
498
+ }
499
+ exclude(predicate) {
500
+ this.options.exclude = predicate;
501
+ return this;
502
+ }
503
+ onlyCounts() {
504
+ this.options.onlyCounts = true;
505
+ return this;
506
+ }
507
+ crawl(root) {
508
+ return new APIBuilder(root || ".", this.options);
509
+ }
510
+ withGlobFunction(fn) {
511
+ this.globFunction = fn;
512
+ return this;
513
+ }
514
+ /**
515
+ * @deprecated Pass options using the constructor instead:
516
+ * ```ts
517
+ * new fdir(options).crawl("/path/to/root");
518
+ * ```
519
+ * This method will be removed in v7.0
520
+ */
521
+ /* c8 ignore next 4 */
522
+ crawlWithOptions(root, options) {
523
+ this.options = {
524
+ ...this.options,
525
+ ...options
526
+ };
527
+ return new APIBuilder(root || ".", this.options);
528
+ }
529
+ glob(...patterns) {
530
+ if (this.globFunction) return this.globWithOptions(patterns);
531
+ return this.globWithOptions(patterns, ...[{ dot: true }]);
532
+ }
533
+ globWithOptions(patterns, ...options) {
534
+ const globFn = this.globFunction || pm;
535
+ /* c8 ignore next 5 */
536
+ if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
537
+ var isMatch = this.globCache[patterns.join("\0")];
538
+ if (!isMatch) {
539
+ isMatch = globFn(patterns, ...options);
540
+ this.globCache[patterns.join("\0")] = isMatch;
541
+ }
542
+ this.options.filters.push((path$1) => isMatch(path$1));
543
+ return this;
544
+ }
545
+ };
546
+
547
+ //#endregion
548
+ //#region ../../node_modules/.bun/picomatch@4.0.3/node_modules/picomatch/lib/constants.js
549
+ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
550
+ const WIN_SLASH = "\\\\/";
551
+ const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
552
+ /**
553
+ * Posix glob regex
554
+ */
555
+ const DOT_LITERAL = "\\.";
556
+ const PLUS_LITERAL = "\\+";
557
+ const QMARK_LITERAL = "\\?";
558
+ const SLASH_LITERAL = "\\/";
559
+ const ONE_CHAR = "(?=.)";
560
+ const QMARK = "[^/]";
561
+ const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
562
+ const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
563
+ const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
564
+ const POSIX_CHARS = {
565
+ DOT_LITERAL,
566
+ PLUS_LITERAL,
567
+ QMARK_LITERAL,
568
+ SLASH_LITERAL,
569
+ ONE_CHAR,
570
+ QMARK,
571
+ END_ANCHOR,
572
+ DOTS_SLASH,
573
+ NO_DOT: `(?!${DOT_LITERAL})`,
574
+ NO_DOTS: `(?!${START_ANCHOR}${DOTS_SLASH})`,
575
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`,
576
+ NO_DOTS_SLASH: `(?!${DOTS_SLASH})`,
577
+ QMARK_NO_DOT: `[^.${SLASH_LITERAL}]`,
578
+ STAR: `${QMARK}*?`,
579
+ START_ANCHOR,
580
+ SEP: "/"
581
+ };
582
+ /**
583
+ * Windows glob regex
584
+ */
585
+ const WINDOWS_CHARS = {
586
+ ...POSIX_CHARS,
587
+ SLASH_LITERAL: `[${WIN_SLASH}]`,
588
+ QMARK: WIN_NO_SLASH,
589
+ STAR: `${WIN_NO_SLASH}*?`,
590
+ DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
591
+ NO_DOT: `(?!${DOT_LITERAL})`,
592
+ NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
593
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
594
+ NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
595
+ QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
596
+ START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
597
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
598
+ SEP: "\\"
599
+ };
600
+ /**
601
+ * POSIX Bracket Regex
602
+ */
603
+ const POSIX_REGEX_SOURCE$1 = {
604
+ alnum: "a-zA-Z0-9",
605
+ alpha: "a-zA-Z",
606
+ ascii: "\\x00-\\x7F",
607
+ blank: " \\t",
608
+ cntrl: "\\x00-\\x1F\\x7F",
609
+ digit: "0-9",
610
+ graph: "\\x21-\\x7E",
611
+ lower: "a-z",
612
+ print: "\\x20-\\x7E ",
613
+ punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
614
+ space: " \\t\\r\\n\\v\\f",
615
+ upper: "A-Z",
616
+ word: "A-Za-z0-9_",
617
+ xdigit: "A-Fa-f0-9"
618
+ };
619
+ module.exports = {
620
+ MAX_LENGTH: 1024 * 64,
621
+ POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
622
+ REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
623
+ REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
624
+ REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
625
+ REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
626
+ REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
627
+ REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
628
+ REPLACEMENTS: {
629
+ __proto__: null,
630
+ "***": "*",
631
+ "**/**": "**",
632
+ "**/**/**": "**"
633
+ },
634
+ CHAR_0: 48,
635
+ CHAR_9: 57,
636
+ CHAR_UPPERCASE_A: 65,
637
+ CHAR_LOWERCASE_A: 97,
638
+ CHAR_UPPERCASE_Z: 90,
639
+ CHAR_LOWERCASE_Z: 122,
640
+ CHAR_LEFT_PARENTHESES: 40,
641
+ CHAR_RIGHT_PARENTHESES: 41,
642
+ CHAR_ASTERISK: 42,
643
+ CHAR_AMPERSAND: 38,
644
+ CHAR_AT: 64,
645
+ CHAR_BACKWARD_SLASH: 92,
646
+ CHAR_CARRIAGE_RETURN: 13,
647
+ CHAR_CIRCUMFLEX_ACCENT: 94,
648
+ CHAR_COLON: 58,
649
+ CHAR_COMMA: 44,
650
+ CHAR_DOT: 46,
651
+ CHAR_DOUBLE_QUOTE: 34,
652
+ CHAR_EQUAL: 61,
653
+ CHAR_EXCLAMATION_MARK: 33,
654
+ CHAR_FORM_FEED: 12,
655
+ CHAR_FORWARD_SLASH: 47,
656
+ CHAR_GRAVE_ACCENT: 96,
657
+ CHAR_HASH: 35,
658
+ CHAR_HYPHEN_MINUS: 45,
659
+ CHAR_LEFT_ANGLE_BRACKET: 60,
660
+ CHAR_LEFT_CURLY_BRACE: 123,
661
+ CHAR_LEFT_SQUARE_BRACKET: 91,
662
+ CHAR_LINE_FEED: 10,
663
+ CHAR_NO_BREAK_SPACE: 160,
664
+ CHAR_PERCENT: 37,
665
+ CHAR_PLUS: 43,
666
+ CHAR_QUESTION_MARK: 63,
667
+ CHAR_RIGHT_ANGLE_BRACKET: 62,
668
+ CHAR_RIGHT_CURLY_BRACE: 125,
669
+ CHAR_RIGHT_SQUARE_BRACKET: 93,
670
+ CHAR_SEMICOLON: 59,
671
+ CHAR_SINGLE_QUOTE: 39,
672
+ CHAR_SPACE: 32,
673
+ CHAR_TAB: 9,
674
+ CHAR_UNDERSCORE: 95,
675
+ CHAR_VERTICAL_LINE: 124,
676
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
677
+ extglobChars(chars) {
678
+ return {
679
+ "!": {
680
+ type: "negate",
681
+ open: "(?:(?!(?:",
682
+ close: `))${chars.STAR})`
683
+ },
684
+ "?": {
685
+ type: "qmark",
686
+ open: "(?:",
687
+ close: ")?"
688
+ },
689
+ "+": {
690
+ type: "plus",
691
+ open: "(?:",
692
+ close: ")+"
693
+ },
694
+ "*": {
695
+ type: "star",
696
+ open: "(?:",
697
+ close: ")*"
698
+ },
699
+ "@": {
700
+ type: "at",
701
+ open: "(?:",
702
+ close: ")"
703
+ }
704
+ };
705
+ },
706
+ globChars(win32) {
707
+ return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
708
+ }
709
+ };
710
+ }));
711
+
712
+ //#endregion
713
+ //#region ../../node_modules/.bun/picomatch@4.0.3/node_modules/picomatch/lib/utils.js
714
+ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
715
+ const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
716
+ exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
717
+ exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
718
+ exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
719
+ exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
720
+ exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
721
+ exports.isWindows = () => {
722
+ if (typeof navigator !== "undefined" && navigator.platform) {
723
+ const platform = navigator.platform.toLowerCase();
724
+ return platform === "win32" || platform === "windows";
725
+ }
726
+ if (typeof process !== "undefined" && process.platform) return process.platform === "win32";
727
+ return false;
728
+ };
729
+ exports.removeBackslashes = (str) => {
730
+ return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
731
+ return match === "\\" ? "" : match;
732
+ });
733
+ };
734
+ exports.escapeLast = (input, char, lastIdx) => {
735
+ const idx = input.lastIndexOf(char, lastIdx);
736
+ if (idx === -1) return input;
737
+ if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
738
+ return `${input.slice(0, idx)}\\${input.slice(idx)}`;
739
+ };
740
+ exports.removePrefix = (input, state = {}) => {
741
+ let output = input;
742
+ if (output.startsWith("./")) {
743
+ output = output.slice(2);
744
+ state.prefix = "./";
745
+ }
746
+ return output;
747
+ };
748
+ exports.wrapOutput = (input, state = {}, options = {}) => {
749
+ let output = `${options.contains ? "" : "^"}(?:${input})${options.contains ? "" : "$"}`;
750
+ if (state.negated === true) output = `(?:^(?!${output}).*$)`;
751
+ return output;
752
+ };
753
+ exports.basename = (path$1, { windows } = {}) => {
754
+ const segs = path$1.split(windows ? /[\\/]/ : "/");
755
+ const last = segs[segs.length - 1];
756
+ if (last === "") return segs[segs.length - 2];
757
+ return last;
758
+ };
759
+ }));
760
+
761
+ //#endregion
762
+ //#region ../../node_modules/.bun/picomatch@4.0.3/node_modules/picomatch/lib/scan.js
763
+ var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
764
+ const utils$3 = require_utils();
765
+ const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = require_constants();
766
+ const isPathSeparator = (code) => {
767
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
768
+ };
769
+ const depth = (token) => {
770
+ if (token.isPrefix !== true) token.depth = token.isGlobstar ? Infinity : 1;
771
+ };
772
+ /**
773
+ * Quickly scans a glob pattern and returns an object with a handful of
774
+ * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
775
+ * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
776
+ * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
777
+ *
778
+ * ```js
779
+ * const pm = require('picomatch');
780
+ * console.log(pm.scan('foo/bar/*.js'));
781
+ * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
782
+ * ```
783
+ * @param {String} `str`
784
+ * @param {Object} `options`
785
+ * @return {Object} Returns an object with tokens and regex source string.
786
+ * @api public
787
+ */
788
+ const scan$1 = (input, options) => {
789
+ const opts = options || {};
790
+ const length = input.length - 1;
791
+ const scanToEnd = opts.parts === true || opts.scanToEnd === true;
792
+ const slashes = [];
793
+ const tokens = [];
794
+ const parts = [];
795
+ let str = input;
796
+ let index = -1;
797
+ let start = 0;
798
+ let lastIndex = 0;
799
+ let isBrace = false;
800
+ let isBracket = false;
801
+ let isGlob = false;
802
+ let isExtglob = false;
803
+ let isGlobstar = false;
804
+ let braceEscaped = false;
805
+ let backslashes = false;
806
+ let negated = false;
807
+ let negatedExtglob = false;
808
+ let finished = false;
809
+ let braces = 0;
810
+ let prev;
811
+ let code;
812
+ let token = {
813
+ value: "",
814
+ depth: 0,
815
+ isGlob: false
816
+ };
817
+ const eos = () => index >= length;
818
+ const peek = () => str.charCodeAt(index + 1);
819
+ const advance = () => {
820
+ prev = code;
821
+ return str.charCodeAt(++index);
822
+ };
823
+ while (index < length) {
824
+ code = advance();
825
+ let next;
826
+ if (code === CHAR_BACKWARD_SLASH) {
827
+ backslashes = token.backslashes = true;
828
+ code = advance();
829
+ if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true;
830
+ continue;
831
+ }
832
+ if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
833
+ braces++;
834
+ while (eos() !== true && (code = advance())) {
835
+ if (code === CHAR_BACKWARD_SLASH) {
836
+ backslashes = token.backslashes = true;
837
+ advance();
838
+ continue;
839
+ }
840
+ if (code === CHAR_LEFT_CURLY_BRACE) {
841
+ braces++;
842
+ continue;
843
+ }
844
+ if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
845
+ isBrace = token.isBrace = true;
846
+ isGlob = token.isGlob = true;
847
+ finished = true;
848
+ if (scanToEnd === true) continue;
849
+ break;
850
+ }
851
+ if (braceEscaped !== true && code === CHAR_COMMA) {
852
+ isBrace = token.isBrace = true;
853
+ isGlob = token.isGlob = true;
854
+ finished = true;
855
+ if (scanToEnd === true) continue;
856
+ break;
857
+ }
858
+ if (code === CHAR_RIGHT_CURLY_BRACE) {
859
+ braces--;
860
+ if (braces === 0) {
861
+ braceEscaped = false;
862
+ isBrace = token.isBrace = true;
863
+ finished = true;
864
+ break;
865
+ }
866
+ }
867
+ }
868
+ if (scanToEnd === true) continue;
869
+ break;
870
+ }
871
+ if (code === CHAR_FORWARD_SLASH) {
872
+ slashes.push(index);
873
+ tokens.push(token);
874
+ token = {
875
+ value: "",
876
+ depth: 0,
877
+ isGlob: false
878
+ };
879
+ if (finished === true) continue;
880
+ if (prev === CHAR_DOT && index === start + 1) {
881
+ start += 2;
882
+ continue;
883
+ }
884
+ lastIndex = index + 1;
885
+ continue;
886
+ }
887
+ if (opts.noext !== true) {
888
+ if ((code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK) === true && peek() === CHAR_LEFT_PARENTHESES) {
889
+ isGlob = token.isGlob = true;
890
+ isExtglob = token.isExtglob = true;
891
+ finished = true;
892
+ if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
893
+ if (scanToEnd === true) {
894
+ while (eos() !== true && (code = advance())) {
895
+ if (code === CHAR_BACKWARD_SLASH) {
896
+ backslashes = token.backslashes = true;
897
+ code = advance();
898
+ continue;
899
+ }
900
+ if (code === CHAR_RIGHT_PARENTHESES) {
901
+ isGlob = token.isGlob = true;
902
+ finished = true;
903
+ break;
904
+ }
905
+ }
906
+ continue;
907
+ }
908
+ break;
909
+ }
910
+ }
911
+ if (code === CHAR_ASTERISK) {
912
+ if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
913
+ isGlob = token.isGlob = true;
914
+ finished = true;
915
+ if (scanToEnd === true) continue;
916
+ break;
917
+ }
918
+ if (code === CHAR_QUESTION_MARK) {
919
+ isGlob = token.isGlob = true;
920
+ finished = true;
921
+ if (scanToEnd === true) continue;
922
+ break;
923
+ }
924
+ if (code === CHAR_LEFT_SQUARE_BRACKET) {
925
+ while (eos() !== true && (next = advance())) {
926
+ if (next === CHAR_BACKWARD_SLASH) {
927
+ backslashes = token.backslashes = true;
928
+ advance();
929
+ continue;
930
+ }
931
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
932
+ isBracket = token.isBracket = true;
933
+ isGlob = token.isGlob = true;
934
+ finished = true;
935
+ break;
936
+ }
937
+ }
938
+ if (scanToEnd === true) continue;
939
+ break;
940
+ }
941
+ if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
942
+ negated = token.negated = true;
943
+ start++;
944
+ continue;
945
+ }
946
+ if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
947
+ isGlob = token.isGlob = true;
948
+ if (scanToEnd === true) {
949
+ while (eos() !== true && (code = advance())) {
950
+ if (code === CHAR_LEFT_PARENTHESES) {
951
+ backslashes = token.backslashes = true;
952
+ code = advance();
953
+ continue;
954
+ }
955
+ if (code === CHAR_RIGHT_PARENTHESES) {
956
+ finished = true;
957
+ break;
958
+ }
959
+ }
960
+ continue;
961
+ }
962
+ break;
963
+ }
964
+ if (isGlob === true) {
965
+ finished = true;
966
+ if (scanToEnd === true) continue;
967
+ break;
968
+ }
969
+ }
970
+ if (opts.noext === true) {
971
+ isExtglob = false;
972
+ isGlob = false;
973
+ }
974
+ let base = str;
975
+ let prefix = "";
976
+ let glob$1 = "";
977
+ if (start > 0) {
978
+ prefix = str.slice(0, start);
979
+ str = str.slice(start);
980
+ lastIndex -= start;
981
+ }
982
+ if (base && isGlob === true && lastIndex > 0) {
983
+ base = str.slice(0, lastIndex);
984
+ glob$1 = str.slice(lastIndex);
985
+ } else if (isGlob === true) {
986
+ base = "";
987
+ glob$1 = str;
988
+ } else base = str;
989
+ if (base && base !== "" && base !== "/" && base !== str) {
990
+ if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
991
+ }
992
+ if (opts.unescape === true) {
993
+ if (glob$1) glob$1 = utils$3.removeBackslashes(glob$1);
994
+ if (base && backslashes === true) base = utils$3.removeBackslashes(base);
995
+ }
996
+ const state = {
997
+ prefix,
998
+ input,
999
+ start,
1000
+ base,
1001
+ glob: glob$1,
1002
+ isBrace,
1003
+ isBracket,
1004
+ isGlob,
1005
+ isExtglob,
1006
+ isGlobstar,
1007
+ negated,
1008
+ negatedExtglob
1009
+ };
1010
+ if (opts.tokens === true) {
1011
+ state.maxDepth = 0;
1012
+ if (!isPathSeparator(code)) tokens.push(token);
1013
+ state.tokens = tokens;
1014
+ }
1015
+ if (opts.parts === true || opts.tokens === true) {
1016
+ let prevIndex;
1017
+ for (let idx = 0; idx < slashes.length; idx++) {
1018
+ const n = prevIndex ? prevIndex + 1 : start;
1019
+ const i = slashes[idx];
1020
+ const value = input.slice(n, i);
1021
+ if (opts.tokens) {
1022
+ if (idx === 0 && start !== 0) {
1023
+ tokens[idx].isPrefix = true;
1024
+ tokens[idx].value = prefix;
1025
+ } else tokens[idx].value = value;
1026
+ depth(tokens[idx]);
1027
+ state.maxDepth += tokens[idx].depth;
1028
+ }
1029
+ if (idx !== 0 || value !== "") parts.push(value);
1030
+ prevIndex = i;
1031
+ }
1032
+ if (prevIndex && prevIndex + 1 < input.length) {
1033
+ const value = input.slice(prevIndex + 1);
1034
+ parts.push(value);
1035
+ if (opts.tokens) {
1036
+ tokens[tokens.length - 1].value = value;
1037
+ depth(tokens[tokens.length - 1]);
1038
+ state.maxDepth += tokens[tokens.length - 1].depth;
1039
+ }
1040
+ }
1041
+ state.slashes = slashes;
1042
+ state.parts = parts;
1043
+ }
1044
+ return state;
1045
+ };
1046
+ module.exports = scan$1;
1047
+ }));
1048
+
1049
+ //#endregion
1050
+ //#region ../../node_modules/.bun/picomatch@4.0.3/node_modules/picomatch/lib/parse.js
1051
+ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1052
+ const constants$1 = require_constants();
1053
+ const utils$2 = require_utils();
1054
+ /**
1055
+ * Constants
1056
+ */
1057
+ const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants$1;
1058
+ /**
1059
+ * Helpers
1060
+ */
1061
+ const expandRange = (args, options) => {
1062
+ if (typeof options.expandRange === "function") return options.expandRange(...args, options);
1063
+ args.sort();
1064
+ const value = `[${args.join("-")}]`;
1065
+ try {
1066
+ new RegExp(value);
1067
+ } catch (ex) {
1068
+ return args.map((v) => utils$2.escapeRegex(v)).join("..");
1069
+ }
1070
+ return value;
1071
+ };
1072
+ /**
1073
+ * Create the message for a syntax error
1074
+ */
1075
+ const syntaxError = (type, char) => {
1076
+ return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
1077
+ };
1078
+ /**
1079
+ * Parse the given input string.
1080
+ * @param {String} input
1081
+ * @param {Object} options
1082
+ * @return {Object}
1083
+ */
1084
+ const parse$1 = (input, options) => {
1085
+ if (typeof input !== "string") throw new TypeError("Expected a string");
1086
+ input = REPLACEMENTS[input] || input;
1087
+ const opts = { ...options };
1088
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1089
+ let len = input.length;
1090
+ if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1091
+ const bos = {
1092
+ type: "bos",
1093
+ value: "",
1094
+ output: opts.prepend || ""
1095
+ };
1096
+ const tokens = [bos];
1097
+ const capture = opts.capture ? "" : "?:";
1098
+ const PLATFORM_CHARS = constants$1.globChars(opts.windows);
1099
+ const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
1100
+ const { DOT_LITERAL: DOT_LITERAL$1, PLUS_LITERAL: PLUS_LITERAL$1, SLASH_LITERAL: SLASH_LITERAL$1, ONE_CHAR: ONE_CHAR$1, DOTS_SLASH: DOTS_SLASH$1, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK: QMARK$1, QMARK_NO_DOT, STAR, START_ANCHOR: START_ANCHOR$1 } = PLATFORM_CHARS;
1101
+ const globstar = (opts$1) => {
1102
+ return `(${capture}(?:(?!${START_ANCHOR$1}${opts$1.dot ? DOTS_SLASH$1 : DOT_LITERAL$1}).)*?)`;
1103
+ };
1104
+ const nodot = opts.dot ? "" : NO_DOT;
1105
+ const qmarkNoDot = opts.dot ? QMARK$1 : QMARK_NO_DOT;
1106
+ let star = opts.bash === true ? globstar(opts) : STAR;
1107
+ if (opts.capture) star = `(${star})`;
1108
+ if (typeof opts.noext === "boolean") opts.noextglob = opts.noext;
1109
+ const state = {
1110
+ input,
1111
+ index: -1,
1112
+ start: 0,
1113
+ dot: opts.dot === true,
1114
+ consumed: "",
1115
+ output: "",
1116
+ prefix: "",
1117
+ backtrack: false,
1118
+ negated: false,
1119
+ brackets: 0,
1120
+ braces: 0,
1121
+ parens: 0,
1122
+ quotes: 0,
1123
+ globstar: false,
1124
+ tokens
1125
+ };
1126
+ input = utils$2.removePrefix(input, state);
1127
+ len = input.length;
1128
+ const extglobs = [];
1129
+ const braces = [];
1130
+ const stack = [];
1131
+ let prev = bos;
1132
+ let value;
1133
+ /**
1134
+ * Tokenizing helpers
1135
+ */
1136
+ const eos = () => state.index === len - 1;
1137
+ const peek = state.peek = (n = 1) => input[state.index + n];
1138
+ const advance = state.advance = () => input[++state.index] || "";
1139
+ const remaining = () => input.slice(state.index + 1);
1140
+ const consume = (value$1 = "", num = 0) => {
1141
+ state.consumed += value$1;
1142
+ state.index += num;
1143
+ };
1144
+ const append = (token) => {
1145
+ state.output += token.output != null ? token.output : token.value;
1146
+ consume(token.value);
1147
+ };
1148
+ const negate = () => {
1149
+ let count = 1;
1150
+ while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
1151
+ advance();
1152
+ state.start++;
1153
+ count++;
1154
+ }
1155
+ if (count % 2 === 0) return false;
1156
+ state.negated = true;
1157
+ state.start++;
1158
+ return true;
1159
+ };
1160
+ const increment = (type) => {
1161
+ state[type]++;
1162
+ stack.push(type);
1163
+ };
1164
+ const decrement = (type) => {
1165
+ state[type]--;
1166
+ stack.pop();
1167
+ };
1168
+ /**
1169
+ * Push tokens onto the tokens array. This helper speeds up
1170
+ * tokenizing by 1) helping us avoid backtracking as much as possible,
1171
+ * and 2) helping us avoid creating extra tokens when consecutive
1172
+ * characters are plain text. This improves performance and simplifies
1173
+ * lookbehinds.
1174
+ */
1175
+ const push = (tok) => {
1176
+ if (prev.type === "globstar") {
1177
+ const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
1178
+ const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
1179
+ if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
1180
+ state.output = state.output.slice(0, -prev.output.length);
1181
+ prev.type = "star";
1182
+ prev.value = "*";
1183
+ prev.output = star;
1184
+ state.output += prev.output;
1185
+ }
1186
+ }
1187
+ if (extglobs.length && tok.type !== "paren") extglobs[extglobs.length - 1].inner += tok.value;
1188
+ if (tok.value || tok.output) append(tok);
1189
+ if (prev && prev.type === "text" && tok.type === "text") {
1190
+ prev.output = (prev.output || prev.value) + tok.value;
1191
+ prev.value += tok.value;
1192
+ return;
1193
+ }
1194
+ tok.prev = prev;
1195
+ tokens.push(tok);
1196
+ prev = tok;
1197
+ };
1198
+ const extglobOpen = (type, value$1) => {
1199
+ const token = {
1200
+ ...EXTGLOB_CHARS[value$1],
1201
+ conditions: 1,
1202
+ inner: ""
1203
+ };
1204
+ token.prev = prev;
1205
+ token.parens = state.parens;
1206
+ token.output = state.output;
1207
+ const output = (opts.capture ? "(" : "") + token.open;
1208
+ increment("parens");
1209
+ push({
1210
+ type,
1211
+ value: value$1,
1212
+ output: state.output ? "" : ONE_CHAR$1
1213
+ });
1214
+ push({
1215
+ type: "paren",
1216
+ extglob: true,
1217
+ value: advance(),
1218
+ output
1219
+ });
1220
+ extglobs.push(token);
1221
+ };
1222
+ const extglobClose = (token) => {
1223
+ let output = token.close + (opts.capture ? ")" : "");
1224
+ let rest;
1225
+ if (token.type === "negate") {
1226
+ let extglobStar = star;
1227
+ if (token.inner && token.inner.length > 1 && token.inner.includes("/")) extglobStar = globstar(opts);
1228
+ if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
1229
+ if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) output = token.close = `)${parse$1(rest, {
1230
+ ...options,
1231
+ fastpaths: false
1232
+ }).output})${extglobStar})`;
1233
+ if (token.prev.type === "bos") state.negatedExtglob = true;
1234
+ }
1235
+ push({
1236
+ type: "paren",
1237
+ extglob: true,
1238
+ value,
1239
+ output
1240
+ });
1241
+ decrement("parens");
1242
+ };
1243
+ /**
1244
+ * Fast paths
1245
+ */
1246
+ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
1247
+ let backslashes = false;
1248
+ let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
1249
+ if (first === "\\") {
1250
+ backslashes = true;
1251
+ return m;
1252
+ }
1253
+ if (first === "?") {
1254
+ if (esc) return esc + first + (rest ? QMARK$1.repeat(rest.length) : "");
1255
+ if (index === 0) return qmarkNoDot + (rest ? QMARK$1.repeat(rest.length) : "");
1256
+ return QMARK$1.repeat(chars.length);
1257
+ }
1258
+ if (first === ".") return DOT_LITERAL$1.repeat(chars.length);
1259
+ if (first === "*") {
1260
+ if (esc) return esc + first + (rest ? star : "");
1261
+ return star;
1262
+ }
1263
+ return esc ? m : `\\${m}`;
1264
+ });
1265
+ if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, "");
1266
+ else output = output.replace(/\\+/g, (m) => {
1267
+ return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
1268
+ });
1269
+ if (output === input && opts.contains === true) {
1270
+ state.output = input;
1271
+ return state;
1272
+ }
1273
+ state.output = utils$2.wrapOutput(output, state, options);
1274
+ return state;
1275
+ }
1276
+ /**
1277
+ * Tokenize input until we reach end-of-string
1278
+ */
1279
+ while (!eos()) {
1280
+ value = advance();
1281
+ if (value === "\0") continue;
1282
+ /**
1283
+ * Escaped characters
1284
+ */
1285
+ if (value === "\\") {
1286
+ const next = peek();
1287
+ if (next === "/" && opts.bash !== true) continue;
1288
+ if (next === "." || next === ";") continue;
1289
+ if (!next) {
1290
+ value += "\\";
1291
+ push({
1292
+ type: "text",
1293
+ value
1294
+ });
1295
+ continue;
1296
+ }
1297
+ const match = /^\\+/.exec(remaining());
1298
+ let slashes = 0;
1299
+ if (match && match[0].length > 2) {
1300
+ slashes = match[0].length;
1301
+ state.index += slashes;
1302
+ if (slashes % 2 !== 0) value += "\\";
1303
+ }
1304
+ if (opts.unescape === true) value = advance();
1305
+ else value += advance();
1306
+ if (state.brackets === 0) {
1307
+ push({
1308
+ type: "text",
1309
+ value
1310
+ });
1311
+ continue;
1312
+ }
1313
+ }
1314
+ /**
1315
+ * If we're inside a regex character class, continue
1316
+ * until we reach the closing bracket.
1317
+ */
1318
+ if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
1319
+ if (opts.posix !== false && value === ":") {
1320
+ const inner = prev.value.slice(1);
1321
+ if (inner.includes("[")) {
1322
+ prev.posix = true;
1323
+ if (inner.includes(":")) {
1324
+ const idx = prev.value.lastIndexOf("[");
1325
+ const pre = prev.value.slice(0, idx);
1326
+ const posix$1 = POSIX_REGEX_SOURCE[prev.value.slice(idx + 2)];
1327
+ if (posix$1) {
1328
+ prev.value = pre + posix$1;
1329
+ state.backtrack = true;
1330
+ advance();
1331
+ if (!bos.output && tokens.indexOf(prev) === 1) bos.output = ONE_CHAR$1;
1332
+ continue;
1333
+ }
1334
+ }
1335
+ }
1336
+ }
1337
+ if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") value = `\\${value}`;
1338
+ if (value === "]" && (prev.value === "[" || prev.value === "[^")) value = `\\${value}`;
1339
+ if (opts.posix === true && value === "!" && prev.value === "[") value = "^";
1340
+ prev.value += value;
1341
+ append({ value });
1342
+ continue;
1343
+ }
1344
+ /**
1345
+ * If we're inside a quoted string, continue
1346
+ * until we reach the closing double quote.
1347
+ */
1348
+ if (state.quotes === 1 && value !== "\"") {
1349
+ value = utils$2.escapeRegex(value);
1350
+ prev.value += value;
1351
+ append({ value });
1352
+ continue;
1353
+ }
1354
+ /**
1355
+ * Double quotes
1356
+ */
1357
+ if (value === "\"") {
1358
+ state.quotes = state.quotes === 1 ? 0 : 1;
1359
+ if (opts.keepQuotes === true) push({
1360
+ type: "text",
1361
+ value
1362
+ });
1363
+ continue;
1364
+ }
1365
+ /**
1366
+ * Parentheses
1367
+ */
1368
+ if (value === "(") {
1369
+ increment("parens");
1370
+ push({
1371
+ type: "paren",
1372
+ value
1373
+ });
1374
+ continue;
1375
+ }
1376
+ if (value === ")") {
1377
+ if (state.parens === 0 && opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "("));
1378
+ const extglob = extglobs[extglobs.length - 1];
1379
+ if (extglob && state.parens === extglob.parens + 1) {
1380
+ extglobClose(extglobs.pop());
1381
+ continue;
1382
+ }
1383
+ push({
1384
+ type: "paren",
1385
+ value,
1386
+ output: state.parens ? ")" : "\\)"
1387
+ });
1388
+ decrement("parens");
1389
+ continue;
1390
+ }
1391
+ /**
1392
+ * Square brackets
1393
+ */
1394
+ if (value === "[") {
1395
+ if (opts.nobracket === true || !remaining().includes("]")) {
1396
+ if (opts.nobracket !== true && opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
1397
+ value = `\\${value}`;
1398
+ } else increment("brackets");
1399
+ push({
1400
+ type: "bracket",
1401
+ value
1402
+ });
1403
+ continue;
1404
+ }
1405
+ if (value === "]") {
1406
+ if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
1407
+ push({
1408
+ type: "text",
1409
+ value,
1410
+ output: `\\${value}`
1411
+ });
1412
+ continue;
1413
+ }
1414
+ if (state.brackets === 0) {
1415
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "["));
1416
+ push({
1417
+ type: "text",
1418
+ value,
1419
+ output: `\\${value}`
1420
+ });
1421
+ continue;
1422
+ }
1423
+ decrement("brackets");
1424
+ const prevValue = prev.value.slice(1);
1425
+ if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) value = `/${value}`;
1426
+ prev.value += value;
1427
+ append({ value });
1428
+ if (opts.literalBrackets === false || utils$2.hasRegexChars(prevValue)) continue;
1429
+ const escaped = utils$2.escapeRegex(prev.value);
1430
+ state.output = state.output.slice(0, -prev.value.length);
1431
+ if (opts.literalBrackets === true) {
1432
+ state.output += escaped;
1433
+ prev.value = escaped;
1434
+ continue;
1435
+ }
1436
+ prev.value = `(${capture}${escaped}|${prev.value})`;
1437
+ state.output += prev.value;
1438
+ continue;
1439
+ }
1440
+ /**
1441
+ * Braces
1442
+ */
1443
+ if (value === "{" && opts.nobrace !== true) {
1444
+ increment("braces");
1445
+ const open = {
1446
+ type: "brace",
1447
+ value,
1448
+ output: "(",
1449
+ outputIndex: state.output.length,
1450
+ tokensIndex: state.tokens.length
1451
+ };
1452
+ braces.push(open);
1453
+ push(open);
1454
+ continue;
1455
+ }
1456
+ if (value === "}") {
1457
+ const brace = braces[braces.length - 1];
1458
+ if (opts.nobrace === true || !brace) {
1459
+ push({
1460
+ type: "text",
1461
+ value,
1462
+ output: value
1463
+ });
1464
+ continue;
1465
+ }
1466
+ let output = ")";
1467
+ if (brace.dots === true) {
1468
+ const arr = tokens.slice();
1469
+ const range = [];
1470
+ for (let i = arr.length - 1; i >= 0; i--) {
1471
+ tokens.pop();
1472
+ if (arr[i].type === "brace") break;
1473
+ if (arr[i].type !== "dots") range.unshift(arr[i].value);
1474
+ }
1475
+ output = expandRange(range, opts);
1476
+ state.backtrack = true;
1477
+ }
1478
+ if (brace.comma !== true && brace.dots !== true) {
1479
+ const out = state.output.slice(0, brace.outputIndex);
1480
+ const toks = state.tokens.slice(brace.tokensIndex);
1481
+ brace.value = brace.output = "\\{";
1482
+ value = output = "\\}";
1483
+ state.output = out;
1484
+ for (const t of toks) state.output += t.output || t.value;
1485
+ }
1486
+ push({
1487
+ type: "brace",
1488
+ value,
1489
+ output
1490
+ });
1491
+ decrement("braces");
1492
+ braces.pop();
1493
+ continue;
1494
+ }
1495
+ /**
1496
+ * Pipes
1497
+ */
1498
+ if (value === "|") {
1499
+ if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
1500
+ push({
1501
+ type: "text",
1502
+ value
1503
+ });
1504
+ continue;
1505
+ }
1506
+ /**
1507
+ * Commas
1508
+ */
1509
+ if (value === ",") {
1510
+ let output = value;
1511
+ const brace = braces[braces.length - 1];
1512
+ if (brace && stack[stack.length - 1] === "braces") {
1513
+ brace.comma = true;
1514
+ output = "|";
1515
+ }
1516
+ push({
1517
+ type: "comma",
1518
+ value,
1519
+ output
1520
+ });
1521
+ continue;
1522
+ }
1523
+ /**
1524
+ * Slashes
1525
+ */
1526
+ if (value === "/") {
1527
+ if (prev.type === "dot" && state.index === state.start + 1) {
1528
+ state.start = state.index + 1;
1529
+ state.consumed = "";
1530
+ state.output = "";
1531
+ tokens.pop();
1532
+ prev = bos;
1533
+ continue;
1534
+ }
1535
+ push({
1536
+ type: "slash",
1537
+ value,
1538
+ output: SLASH_LITERAL$1
1539
+ });
1540
+ continue;
1541
+ }
1542
+ /**
1543
+ * Dots
1544
+ */
1545
+ if (value === ".") {
1546
+ if (state.braces > 0 && prev.type === "dot") {
1547
+ if (prev.value === ".") prev.output = DOT_LITERAL$1;
1548
+ const brace = braces[braces.length - 1];
1549
+ prev.type = "dots";
1550
+ prev.output += value;
1551
+ prev.value += value;
1552
+ brace.dots = true;
1553
+ continue;
1554
+ }
1555
+ if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
1556
+ push({
1557
+ type: "text",
1558
+ value,
1559
+ output: DOT_LITERAL$1
1560
+ });
1561
+ continue;
1562
+ }
1563
+ push({
1564
+ type: "dot",
1565
+ value,
1566
+ output: DOT_LITERAL$1
1567
+ });
1568
+ continue;
1569
+ }
1570
+ /**
1571
+ * Question marks
1572
+ */
1573
+ if (value === "?") {
1574
+ if (!(prev && prev.value === "(") && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1575
+ extglobOpen("qmark", value);
1576
+ continue;
1577
+ }
1578
+ if (prev && prev.type === "paren") {
1579
+ const next = peek();
1580
+ let output = value;
1581
+ if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
1582
+ push({
1583
+ type: "text",
1584
+ value,
1585
+ output
1586
+ });
1587
+ continue;
1588
+ }
1589
+ if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
1590
+ push({
1591
+ type: "qmark",
1592
+ value,
1593
+ output: QMARK_NO_DOT
1594
+ });
1595
+ continue;
1596
+ }
1597
+ push({
1598
+ type: "qmark",
1599
+ value,
1600
+ output: QMARK$1
1601
+ });
1602
+ continue;
1603
+ }
1604
+ /**
1605
+ * Exclamation
1606
+ */
1607
+ if (value === "!") {
1608
+ if (opts.noextglob !== true && peek() === "(") {
1609
+ if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
1610
+ extglobOpen("negate", value);
1611
+ continue;
1612
+ }
1613
+ }
1614
+ if (opts.nonegate !== true && state.index === 0) {
1615
+ negate();
1616
+ continue;
1617
+ }
1618
+ }
1619
+ /**
1620
+ * Plus
1621
+ */
1622
+ if (value === "+") {
1623
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1624
+ extglobOpen("plus", value);
1625
+ continue;
1626
+ }
1627
+ if (prev && prev.value === "(" || opts.regex === false) {
1628
+ push({
1629
+ type: "plus",
1630
+ value,
1631
+ output: PLUS_LITERAL$1
1632
+ });
1633
+ continue;
1634
+ }
1635
+ if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
1636
+ push({
1637
+ type: "plus",
1638
+ value
1639
+ });
1640
+ continue;
1641
+ }
1642
+ push({
1643
+ type: "plus",
1644
+ value: PLUS_LITERAL$1
1645
+ });
1646
+ continue;
1647
+ }
1648
+ /**
1649
+ * Plain text
1650
+ */
1651
+ if (value === "@") {
1652
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1653
+ push({
1654
+ type: "at",
1655
+ extglob: true,
1656
+ value,
1657
+ output: ""
1658
+ });
1659
+ continue;
1660
+ }
1661
+ push({
1662
+ type: "text",
1663
+ value
1664
+ });
1665
+ continue;
1666
+ }
1667
+ /**
1668
+ * Plain text
1669
+ */
1670
+ if (value !== "*") {
1671
+ if (value === "$" || value === "^") value = `\\${value}`;
1672
+ const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
1673
+ if (match) {
1674
+ value += match[0];
1675
+ state.index += match[0].length;
1676
+ }
1677
+ push({
1678
+ type: "text",
1679
+ value
1680
+ });
1681
+ continue;
1682
+ }
1683
+ /**
1684
+ * Stars
1685
+ */
1686
+ if (prev && (prev.type === "globstar" || prev.star === true)) {
1687
+ prev.type = "star";
1688
+ prev.star = true;
1689
+ prev.value += value;
1690
+ prev.output = star;
1691
+ state.backtrack = true;
1692
+ state.globstar = true;
1693
+ consume(value);
1694
+ continue;
1695
+ }
1696
+ let rest = remaining();
1697
+ if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
1698
+ extglobOpen("star", value);
1699
+ continue;
1700
+ }
1701
+ if (prev.type === "star") {
1702
+ if (opts.noglobstar === true) {
1703
+ consume(value);
1704
+ continue;
1705
+ }
1706
+ const prior = prev.prev;
1707
+ const before = prior.prev;
1708
+ const isStart = prior.type === "slash" || prior.type === "bos";
1709
+ const afterStar = before && (before.type === "star" || before.type === "globstar");
1710
+ if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
1711
+ push({
1712
+ type: "star",
1713
+ value,
1714
+ output: ""
1715
+ });
1716
+ continue;
1717
+ }
1718
+ const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
1719
+ const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
1720
+ if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
1721
+ push({
1722
+ type: "star",
1723
+ value,
1724
+ output: ""
1725
+ });
1726
+ continue;
1727
+ }
1728
+ while (rest.slice(0, 3) === "/**") {
1729
+ const after = input[state.index + 4];
1730
+ if (after && after !== "/") break;
1731
+ rest = rest.slice(3);
1732
+ consume("/**", 3);
1733
+ }
1734
+ if (prior.type === "bos" && eos()) {
1735
+ prev.type = "globstar";
1736
+ prev.value += value;
1737
+ prev.output = globstar(opts);
1738
+ state.output = prev.output;
1739
+ state.globstar = true;
1740
+ consume(value);
1741
+ continue;
1742
+ }
1743
+ if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
1744
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1745
+ prior.output = `(?:${prior.output}`;
1746
+ prev.type = "globstar";
1747
+ prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
1748
+ prev.value += value;
1749
+ state.globstar = true;
1750
+ state.output += prior.output + prev.output;
1751
+ consume(value);
1752
+ continue;
1753
+ }
1754
+ if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
1755
+ const end = rest[1] !== void 0 ? "|$" : "";
1756
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1757
+ prior.output = `(?:${prior.output}`;
1758
+ prev.type = "globstar";
1759
+ prev.output = `${globstar(opts)}${SLASH_LITERAL$1}|${SLASH_LITERAL$1}${end})`;
1760
+ prev.value += value;
1761
+ state.output += prior.output + prev.output;
1762
+ state.globstar = true;
1763
+ consume(value + advance());
1764
+ push({
1765
+ type: "slash",
1766
+ value: "/",
1767
+ output: ""
1768
+ });
1769
+ continue;
1770
+ }
1771
+ if (prior.type === "bos" && rest[0] === "/") {
1772
+ prev.type = "globstar";
1773
+ prev.value += value;
1774
+ prev.output = `(?:^|${SLASH_LITERAL$1}|${globstar(opts)}${SLASH_LITERAL$1})`;
1775
+ state.output = prev.output;
1776
+ state.globstar = true;
1777
+ consume(value + advance());
1778
+ push({
1779
+ type: "slash",
1780
+ value: "/",
1781
+ output: ""
1782
+ });
1783
+ continue;
1784
+ }
1785
+ state.output = state.output.slice(0, -prev.output.length);
1786
+ prev.type = "globstar";
1787
+ prev.output = globstar(opts);
1788
+ prev.value += value;
1789
+ state.output += prev.output;
1790
+ state.globstar = true;
1791
+ consume(value);
1792
+ continue;
1793
+ }
1794
+ const token = {
1795
+ type: "star",
1796
+ value,
1797
+ output: star
1798
+ };
1799
+ if (opts.bash === true) {
1800
+ token.output = ".*?";
1801
+ if (prev.type === "bos" || prev.type === "slash") token.output = nodot + token.output;
1802
+ push(token);
1803
+ continue;
1804
+ }
1805
+ if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
1806
+ token.output = value;
1807
+ push(token);
1808
+ continue;
1809
+ }
1810
+ if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
1811
+ if (prev.type === "dot") {
1812
+ state.output += NO_DOT_SLASH;
1813
+ prev.output += NO_DOT_SLASH;
1814
+ } else if (opts.dot === true) {
1815
+ state.output += NO_DOTS_SLASH;
1816
+ prev.output += NO_DOTS_SLASH;
1817
+ } else {
1818
+ state.output += nodot;
1819
+ prev.output += nodot;
1820
+ }
1821
+ if (peek() !== "*") {
1822
+ state.output += ONE_CHAR$1;
1823
+ prev.output += ONE_CHAR$1;
1824
+ }
1825
+ }
1826
+ push(token);
1827
+ }
1828
+ while (state.brackets > 0) {
1829
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
1830
+ state.output = utils$2.escapeLast(state.output, "[");
1831
+ decrement("brackets");
1832
+ }
1833
+ while (state.parens > 0) {
1834
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
1835
+ state.output = utils$2.escapeLast(state.output, "(");
1836
+ decrement("parens");
1837
+ }
1838
+ while (state.braces > 0) {
1839
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
1840
+ state.output = utils$2.escapeLast(state.output, "{");
1841
+ decrement("braces");
1842
+ }
1843
+ if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) push({
1844
+ type: "maybe_slash",
1845
+ value: "",
1846
+ output: `${SLASH_LITERAL$1}?`
1847
+ });
1848
+ if (state.backtrack === true) {
1849
+ state.output = "";
1850
+ for (const token of state.tokens) {
1851
+ state.output += token.output != null ? token.output : token.value;
1852
+ if (token.suffix) state.output += token.suffix;
1853
+ }
1854
+ }
1855
+ return state;
1856
+ };
1857
+ /**
1858
+ * Fast paths for creating regular expressions for common glob patterns.
1859
+ * This can significantly speed up processing and has very little downside
1860
+ * impact when none of the fast paths match.
1861
+ */
1862
+ parse$1.fastpaths = (input, options) => {
1863
+ const opts = { ...options };
1864
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1865
+ const len = input.length;
1866
+ if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1867
+ input = REPLACEMENTS[input] || input;
1868
+ const { DOT_LITERAL: DOT_LITERAL$1, SLASH_LITERAL: SLASH_LITERAL$1, ONE_CHAR: ONE_CHAR$1, DOTS_SLASH: DOTS_SLASH$1, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR: START_ANCHOR$1 } = constants$1.globChars(opts.windows);
1869
+ const nodot = opts.dot ? NO_DOTS : NO_DOT;
1870
+ const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
1871
+ const capture = opts.capture ? "" : "?:";
1872
+ const state = {
1873
+ negated: false,
1874
+ prefix: ""
1875
+ };
1876
+ let star = opts.bash === true ? ".*?" : STAR;
1877
+ if (opts.capture) star = `(${star})`;
1878
+ const globstar = (opts$1) => {
1879
+ if (opts$1.noglobstar === true) return star;
1880
+ return `(${capture}(?:(?!${START_ANCHOR$1}${opts$1.dot ? DOTS_SLASH$1 : DOT_LITERAL$1}).)*?)`;
1881
+ };
1882
+ const create = (str) => {
1883
+ switch (str) {
1884
+ case "*": return `${nodot}${ONE_CHAR$1}${star}`;
1885
+ case ".*": return `${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1886
+ case "*.*": return `${nodot}${star}${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1887
+ case "*/*": return `${nodot}${star}${SLASH_LITERAL$1}${ONE_CHAR$1}${slashDot}${star}`;
1888
+ case "**": return nodot + globstar(opts);
1889
+ case "**/*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL$1})?${slashDot}${ONE_CHAR$1}${star}`;
1890
+ case "**/*.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL$1})?${slashDot}${star}${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1891
+ case "**/.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL$1})?${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1892
+ default: {
1893
+ const match = /^(.*?)\.(\w+)$/.exec(str);
1894
+ if (!match) return;
1895
+ const source$1 = create(match[1]);
1896
+ if (!source$1) return;
1897
+ return source$1 + DOT_LITERAL$1 + match[2];
1898
+ }
1899
+ }
1900
+ };
1901
+ let source = create(utils$2.removePrefix(input, state));
1902
+ if (source && opts.strictSlashes !== true) source += `${SLASH_LITERAL$1}?`;
1903
+ return source;
1904
+ };
1905
+ module.exports = parse$1;
1906
+ }));
1907
+
1908
+ //#endregion
1909
+ //#region ../../node_modules/.bun/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js
1910
+ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1911
+ const scan = require_scan();
1912
+ const parse = require_parse();
1913
+ const utils$1 = require_utils();
1914
+ const constants = require_constants();
1915
+ const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
1916
+ /**
1917
+ * Creates a matcher function from one or more glob patterns. The
1918
+ * returned function takes a string to match as its first argument,
1919
+ * and returns true if the string is a match. The returned matcher
1920
+ * function also takes a boolean as the second argument that, when true,
1921
+ * returns an object with additional information.
1922
+ *
1923
+ * ```js
1924
+ * const picomatch = require('picomatch');
1925
+ * // picomatch(glob[, options]);
1926
+ *
1927
+ * const isMatch = picomatch('*.!(*a)');
1928
+ * console.log(isMatch('a.a')); //=> false
1929
+ * console.log(isMatch('a.b')); //=> true
1930
+ * ```
1931
+ * @name picomatch
1932
+ * @param {String|Array} `globs` One or more glob patterns.
1933
+ * @param {Object=} `options`
1934
+ * @return {Function=} Returns a matcher function.
1935
+ * @api public
1936
+ */
1937
+ const picomatch$2 = (glob$1, options, returnState = false) => {
1938
+ if (Array.isArray(glob$1)) {
1939
+ const fns = glob$1.map((input) => picomatch$2(input, options, returnState));
1940
+ const arrayMatcher = (str) => {
1941
+ for (const isMatch of fns) {
1942
+ const state$1 = isMatch(str);
1943
+ if (state$1) return state$1;
1944
+ }
1945
+ return false;
1946
+ };
1947
+ return arrayMatcher;
1948
+ }
1949
+ const isState = isObject(glob$1) && glob$1.tokens && glob$1.input;
1950
+ if (glob$1 === "" || typeof glob$1 !== "string" && !isState) throw new TypeError("Expected pattern to be a non-empty string");
1951
+ const opts = options || {};
1952
+ const posix$1 = opts.windows;
1953
+ const regex = isState ? picomatch$2.compileRe(glob$1, options) : picomatch$2.makeRe(glob$1, options, false, true);
1954
+ const state = regex.state;
1955
+ delete regex.state;
1956
+ let isIgnored = () => false;
1957
+ if (opts.ignore) {
1958
+ const ignoreOpts = {
1959
+ ...options,
1960
+ ignore: null,
1961
+ onMatch: null,
1962
+ onResult: null
1963
+ };
1964
+ isIgnored = picomatch$2(opts.ignore, ignoreOpts, returnState);
1965
+ }
1966
+ const matcher = (input, returnObject = false) => {
1967
+ const { isMatch, match, output } = picomatch$2.test(input, regex, options, {
1968
+ glob: glob$1,
1969
+ posix: posix$1
1970
+ });
1971
+ const result = {
1972
+ glob: glob$1,
1973
+ state,
1974
+ regex,
1975
+ posix: posix$1,
1976
+ input,
1977
+ output,
1978
+ match,
1979
+ isMatch
1980
+ };
1981
+ if (typeof opts.onResult === "function") opts.onResult(result);
1982
+ if (isMatch === false) {
1983
+ result.isMatch = false;
1984
+ return returnObject ? result : false;
1985
+ }
1986
+ if (isIgnored(input)) {
1987
+ if (typeof opts.onIgnore === "function") opts.onIgnore(result);
1988
+ result.isMatch = false;
1989
+ return returnObject ? result : false;
1990
+ }
1991
+ if (typeof opts.onMatch === "function") opts.onMatch(result);
1992
+ return returnObject ? result : true;
1993
+ };
1994
+ if (returnState) matcher.state = state;
1995
+ return matcher;
1996
+ };
1997
+ /**
1998
+ * Test `input` with the given `regex`. This is used by the main
1999
+ * `picomatch()` function to test the input string.
2000
+ *
2001
+ * ```js
2002
+ * const picomatch = require('picomatch');
2003
+ * // picomatch.test(input, regex[, options]);
2004
+ *
2005
+ * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
2006
+ * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
2007
+ * ```
2008
+ * @param {String} `input` String to test.
2009
+ * @param {RegExp} `regex`
2010
+ * @return {Object} Returns an object with matching info.
2011
+ * @api public
2012
+ */
2013
+ picomatch$2.test = (input, regex, options, { glob: glob$1, posix: posix$1 } = {}) => {
2014
+ if (typeof input !== "string") throw new TypeError("Expected input to be a string");
2015
+ if (input === "") return {
2016
+ isMatch: false,
2017
+ output: ""
2018
+ };
2019
+ const opts = options || {};
2020
+ const format = opts.format || (posix$1 ? utils$1.toPosixSlashes : null);
2021
+ let match = input === glob$1;
2022
+ let output = match && format ? format(input) : input;
2023
+ if (match === false) {
2024
+ output = format ? format(input) : input;
2025
+ match = output === glob$1;
2026
+ }
2027
+ if (match === false || opts.capture === true) if (opts.matchBase === true || opts.basename === true) match = picomatch$2.matchBase(input, regex, options, posix$1);
2028
+ else match = regex.exec(output);
2029
+ return {
2030
+ isMatch: Boolean(match),
2031
+ match,
2032
+ output
2033
+ };
2034
+ };
2035
+ /**
2036
+ * Match the basename of a filepath.
2037
+ *
2038
+ * ```js
2039
+ * const picomatch = require('picomatch');
2040
+ * // picomatch.matchBase(input, glob[, options]);
2041
+ * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
2042
+ * ```
2043
+ * @param {String} `input` String to test.
2044
+ * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
2045
+ * @return {Boolean}
2046
+ * @api public
2047
+ */
2048
+ picomatch$2.matchBase = (input, glob$1, options) => {
2049
+ return (glob$1 instanceof RegExp ? glob$1 : picomatch$2.makeRe(glob$1, options)).test(utils$1.basename(input));
2050
+ };
2051
+ /**
2052
+ * Returns true if **any** of the given glob `patterns` match the specified `string`.
2053
+ *
2054
+ * ```js
2055
+ * const picomatch = require('picomatch');
2056
+ * // picomatch.isMatch(string, patterns[, options]);
2057
+ *
2058
+ * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
2059
+ * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
2060
+ * ```
2061
+ * @param {String|Array} str The string to test.
2062
+ * @param {String|Array} patterns One or more glob patterns to use for matching.
2063
+ * @param {Object} [options] See available [options](#options).
2064
+ * @return {Boolean} Returns true if any patterns match `str`
2065
+ * @api public
2066
+ */
2067
+ picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)(str);
2068
+ /**
2069
+ * Parse a glob pattern to create the source string for a regular
2070
+ * expression.
2071
+ *
2072
+ * ```js
2073
+ * const picomatch = require('picomatch');
2074
+ * const result = picomatch.parse(pattern[, options]);
2075
+ * ```
2076
+ * @param {String} `pattern`
2077
+ * @param {Object} `options`
2078
+ * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
2079
+ * @api public
2080
+ */
2081
+ picomatch$2.parse = (pattern, options) => {
2082
+ if (Array.isArray(pattern)) return pattern.map((p) => picomatch$2.parse(p, options));
2083
+ return parse(pattern, {
2084
+ ...options,
2085
+ fastpaths: false
2086
+ });
2087
+ };
2088
+ /**
2089
+ * Scan a glob pattern to separate the pattern into segments.
2090
+ *
2091
+ * ```js
2092
+ * const picomatch = require('picomatch');
2093
+ * // picomatch.scan(input[, options]);
2094
+ *
2095
+ * const result = picomatch.scan('!./foo/*.js');
2096
+ * console.log(result);
2097
+ * { prefix: '!./',
2098
+ * input: '!./foo/*.js',
2099
+ * start: 3,
2100
+ * base: 'foo',
2101
+ * glob: '*.js',
2102
+ * isBrace: false,
2103
+ * isBracket: false,
2104
+ * isGlob: true,
2105
+ * isExtglob: false,
2106
+ * isGlobstar: false,
2107
+ * negated: true }
2108
+ * ```
2109
+ * @param {String} `input` Glob pattern to scan.
2110
+ * @param {Object} `options`
2111
+ * @return {Object} Returns an object with
2112
+ * @api public
2113
+ */
2114
+ picomatch$2.scan = (input, options) => scan(input, options);
2115
+ /**
2116
+ * Compile a regular expression from the `state` object returned by the
2117
+ * [parse()](#parse) method.
2118
+ *
2119
+ * @param {Object} `state`
2120
+ * @param {Object} `options`
2121
+ * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
2122
+ * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
2123
+ * @return {RegExp}
2124
+ * @api public
2125
+ */
2126
+ picomatch$2.compileRe = (state, options, returnOutput = false, returnState = false) => {
2127
+ if (returnOutput === true) return state.output;
2128
+ const opts = options || {};
2129
+ const prepend = opts.contains ? "" : "^";
2130
+ const append = opts.contains ? "" : "$";
2131
+ let source = `${prepend}(?:${state.output})${append}`;
2132
+ if (state && state.negated === true) source = `^(?!${source}).*$`;
2133
+ const regex = picomatch$2.toRegex(source, options);
2134
+ if (returnState === true) regex.state = state;
2135
+ return regex;
2136
+ };
2137
+ /**
2138
+ * Create a regular expression from a parsed glob pattern.
2139
+ *
2140
+ * ```js
2141
+ * const picomatch = require('picomatch');
2142
+ * const state = picomatch.parse('*.js');
2143
+ * // picomatch.compileRe(state[, options]);
2144
+ *
2145
+ * console.log(picomatch.compileRe(state));
2146
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
2147
+ * ```
2148
+ * @param {String} `state` The object returned from the `.parse` method.
2149
+ * @param {Object} `options`
2150
+ * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
2151
+ * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
2152
+ * @return {RegExp} Returns a regex created from the given pattern.
2153
+ * @api public
2154
+ */
2155
+ picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
2156
+ if (!input || typeof input !== "string") throw new TypeError("Expected a non-empty string");
2157
+ let parsed = {
2158
+ negated: false,
2159
+ fastpaths: true
2160
+ };
2161
+ if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) parsed.output = parse.fastpaths(input, options);
2162
+ if (!parsed.output) parsed = parse(input, options);
2163
+ return picomatch$2.compileRe(parsed, options, returnOutput, returnState);
2164
+ };
2165
+ /**
2166
+ * Create a regular expression from the given regex source string.
2167
+ *
2168
+ * ```js
2169
+ * const picomatch = require('picomatch');
2170
+ * // picomatch.toRegex(source[, options]);
2171
+ *
2172
+ * const { output } = picomatch.parse('*.js');
2173
+ * console.log(picomatch.toRegex(output));
2174
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
2175
+ * ```
2176
+ * @param {String} `source` Regular expression source string.
2177
+ * @param {Object} `options`
2178
+ * @return {RegExp}
2179
+ * @api public
2180
+ */
2181
+ picomatch$2.toRegex = (source, options) => {
2182
+ try {
2183
+ const opts = options || {};
2184
+ return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
2185
+ } catch (err) {
2186
+ if (options && options.debug === true) throw err;
2187
+ return /$^/;
2188
+ }
2189
+ };
2190
+ /**
2191
+ * Picomatch constants.
2192
+ * @return {Object}
2193
+ */
2194
+ picomatch$2.constants = constants;
2195
+ /**
2196
+ * Expose "picomatch"
2197
+ */
2198
+ module.exports = picomatch$2;
2199
+ }));
2200
+
2201
+ //#endregion
2202
+ //#region ../../node_modules/.bun/picomatch@4.0.3/node_modules/picomatch/index.js
2203
+ var require_picomatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2204
+ const pico = require_picomatch$1();
2205
+ const utils = require_utils();
2206
+ function picomatch$1(glob$1, options, returnState = false) {
2207
+ if (options && (options.windows === null || options.windows === void 0)) options = {
2208
+ ...options,
2209
+ windows: utils.isWindows()
2210
+ };
2211
+ return pico(glob$1, options, returnState);
2212
+ }
2213
+ Object.assign(picomatch$1, pico);
2214
+ module.exports = picomatch$1;
2215
+ }));
2216
+
2217
+ //#endregion
2218
+ //#region ../../node_modules/.bun/tinyglobby@0.2.15/node_modules/tinyglobby/dist/index.mjs
2219
+ var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
2220
+ const isReadonlyArray = Array.isArray;
2221
+ const isWin = process.platform === "win32";
2222
+ const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
2223
+ function getPartialMatcher(patterns, options = {}) {
2224
+ const patternsCount = patterns.length;
2225
+ const patternsParts = Array(patternsCount);
2226
+ const matchers = Array(patternsCount);
2227
+ const globstarEnabled = !options.noglobstar;
2228
+ for (let i = 0; i < patternsCount; i++) {
2229
+ const parts = splitPattern(patterns[i]);
2230
+ patternsParts[i] = parts;
2231
+ const partsCount = parts.length;
2232
+ const partMatchers = Array(partsCount);
2233
+ for (let j = 0; j < partsCount; j++) partMatchers[j] = (0, import_picomatch.default)(parts[j], options);
2234
+ matchers[i] = partMatchers;
2235
+ }
2236
+ return (input) => {
2237
+ const inputParts = input.split("/");
2238
+ if (inputParts[0] === ".." && ONLY_PARENT_DIRECTORIES.test(input)) return true;
2239
+ for (let i = 0; i < patterns.length; i++) {
2240
+ const patternParts = patternsParts[i];
2241
+ const matcher = matchers[i];
2242
+ const inputPatternCount = inputParts.length;
2243
+ const minParts = Math.min(inputPatternCount, patternParts.length);
2244
+ let j = 0;
2245
+ while (j < minParts) {
2246
+ const part = patternParts[j];
2247
+ if (part.includes("/")) return true;
2248
+ if (!matcher[j](inputParts[j])) break;
2249
+ if (globstarEnabled && part === "**") return true;
2250
+ j++;
2251
+ }
2252
+ if (j === inputPatternCount) return true;
2253
+ }
2254
+ return false;
2255
+ };
2256
+ }
2257
+ /* node:coverage ignore next 2 */
2258
+ const WIN32_ROOT_DIR = /^[A-Z]:\/$/i;
2259
+ const isRoot = isWin ? (p) => WIN32_ROOT_DIR.test(p) : (p) => p === "/";
2260
+ function buildFormat(cwd, root, absolute) {
2261
+ if (cwd === root || root.startsWith(`${cwd}/`)) {
2262
+ if (absolute) {
2263
+ const start = isRoot(cwd) ? cwd.length : cwd.length + 1;
2264
+ return (p, isDir) => p.slice(start, isDir ? -1 : void 0) || ".";
2265
+ }
2266
+ const prefix = root.slice(cwd.length + 1);
2267
+ if (prefix) return (p, isDir) => {
2268
+ if (p === ".") return prefix;
2269
+ const result = `${prefix}/${p}`;
2270
+ return isDir ? result.slice(0, -1) : result;
2271
+ };
2272
+ return (p, isDir) => isDir && p !== "." ? p.slice(0, -1) : p;
2273
+ }
2274
+ if (absolute) return (p) => posix.relative(cwd, p) || ".";
2275
+ return (p) => posix.relative(cwd, `${root}/${p}`) || ".";
2276
+ }
2277
+ function buildRelative(cwd, root) {
2278
+ if (root.startsWith(`${cwd}/`)) {
2279
+ const prefix = root.slice(cwd.length + 1);
2280
+ return (p) => `${prefix}/${p}`;
2281
+ }
2282
+ return (p) => {
2283
+ const result = posix.relative(cwd, `${root}/${p}`);
2284
+ if (p.endsWith("/") && result !== "") return `${result}/`;
2285
+ return result || ".";
2286
+ };
2287
+ }
2288
+ const splitPatternOptions = { parts: true };
2289
+ function splitPattern(path$1) {
2290
+ var _result$parts;
2291
+ const result = import_picomatch.default.scan(path$1, splitPatternOptions);
2292
+ return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$1];
2293
+ }
2294
+ const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
2295
+ const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
2296
+ const escapePosixPath = (path$1) => path$1.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
2297
+ const escapeWin32Path = (path$1) => path$1.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
2298
+ /**
2299
+ * Escapes a path's special characters depending on the platform.
2300
+ * @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
2301
+ */
2302
+ /* node:coverage ignore next */
2303
+ const escapePath = isWin ? escapeWin32Path : escapePosixPath;
2304
+ /**
2305
+ * Checks if a pattern has dynamic parts.
2306
+ *
2307
+ * Has a few minor differences with [`fast-glob`](https://github.com/mrmlnc/fast-glob) for better accuracy:
2308
+ *
2309
+ * - Doesn't necessarily return `false` on patterns that include `\`.
2310
+ * - Returns `true` if the pattern includes parentheses, regardless of them representing one single pattern or not.
2311
+ * - Returns `true` for unfinished glob extensions i.e. `(h`, `+(h`.
2312
+ * - Returns `true` for unfinished brace expansions as long as they include `,` or `..`.
2313
+ *
2314
+ * @see {@link https://superchupu.dev/tinyglobby/documentation#isDynamicPattern}
2315
+ */
2316
+ function isDynamicPattern(pattern, options) {
2317
+ if ((options === null || options === void 0 ? void 0 : options.caseSensitiveMatch) === false) return true;
2318
+ const scan$2 = import_picomatch.default.scan(pattern);
2319
+ return scan$2.isGlob || scan$2.negated;
2320
+ }
2321
+ function log(...tasks) {
2322
+ console.log(`[tinyglobby ${(/* @__PURE__ */ new Date()).toLocaleTimeString("es")}]`, ...tasks);
2323
+ }
2324
+ const PARENT_DIRECTORY = /^(\/?\.\.)+/;
2325
+ const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
2326
+ const BACKSLASHES = /\\/g;
2327
+ function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
2328
+ let result = pattern;
2329
+ if (pattern.endsWith("/")) result = pattern.slice(0, -1);
2330
+ if (!result.endsWith("*") && expandDirectories) result += "/**";
2331
+ const escapedCwd = escapePath(cwd);
2332
+ if (path.isAbsolute(result.replace(ESCAPING_BACKSLASHES, ""))) result = posix.relative(escapedCwd, result);
2333
+ else result = posix.normalize(result);
2334
+ const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
2335
+ const parts = splitPattern(result);
2336
+ if (parentDirectoryMatch === null || parentDirectoryMatch === void 0 ? void 0 : parentDirectoryMatch[0]) {
2337
+ const n = (parentDirectoryMatch[0].length + 1) / 3;
2338
+ let i = 0;
2339
+ const cwdParts = escapedCwd.split("/");
2340
+ while (i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]) {
2341
+ result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
2342
+ i++;
2343
+ }
2344
+ const potentialRoot = posix.join(cwd, parentDirectoryMatch[0].slice(i * 3));
2345
+ if (!potentialRoot.startsWith(".") && props.root.length > potentialRoot.length) {
2346
+ props.root = potentialRoot;
2347
+ props.depthOffset = -n + i;
2348
+ }
2349
+ }
2350
+ if (!isIgnore && props.depthOffset >= 0) {
2351
+ var _props$commonPath;
2352
+ (_props$commonPath = props.commonPath) !== null && _props$commonPath !== void 0 || (props.commonPath = parts);
2353
+ const newCommonPath = [];
2354
+ const length = Math.min(props.commonPath.length, parts.length);
2355
+ for (let i = 0; i < length; i++) {
2356
+ const part = parts[i];
2357
+ if (part === "**" && !parts[i + 1]) {
2358
+ newCommonPath.pop();
2359
+ break;
2360
+ }
2361
+ if (part !== props.commonPath[i] || isDynamicPattern(part) || i === parts.length - 1) break;
2362
+ newCommonPath.push(part);
2363
+ }
2364
+ props.depthOffset = newCommonPath.length;
2365
+ props.commonPath = newCommonPath;
2366
+ props.root = newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd;
2367
+ }
2368
+ return result;
2369
+ }
2370
+ function processPatterns({ patterns = ["**/*"], ignore = [], expandDirectories = true }, cwd, props) {
2371
+ if (typeof patterns === "string") patterns = [patterns];
2372
+ if (typeof ignore === "string") ignore = [ignore];
2373
+ const matchPatterns = [];
2374
+ const ignorePatterns = [];
2375
+ for (const pattern of ignore) {
2376
+ if (!pattern) continue;
2377
+ if (pattern[0] !== "!" || pattern[1] === "(") ignorePatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, true));
2378
+ }
2379
+ for (const pattern of patterns) {
2380
+ if (!pattern) continue;
2381
+ if (pattern[0] !== "!" || pattern[1] === "(") matchPatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, false));
2382
+ else if (pattern[1] !== "!" || pattern[2] === "(") ignorePatterns.push(normalizePattern(pattern.slice(1), expandDirectories, cwd, props, true));
2383
+ }
2384
+ return {
2385
+ match: matchPatterns,
2386
+ ignore: ignorePatterns
2387
+ };
2388
+ }
2389
+ function formatPaths(paths, relative$1) {
2390
+ for (let i = paths.length - 1; i >= 0; i--) {
2391
+ const path$1 = paths[i];
2392
+ paths[i] = relative$1(path$1);
2393
+ }
2394
+ return paths;
2395
+ }
2396
+ function normalizeCwd(cwd) {
2397
+ if (!cwd) return process.cwd().replace(BACKSLASHES, "/");
2398
+ if (cwd instanceof URL) return fileURLToPath$1(cwd).replace(BACKSLASHES, "/");
2399
+ return path.resolve(cwd).replace(BACKSLASHES, "/");
2400
+ }
2401
+ function getCrawler(patterns, inputOptions = {}) {
2402
+ const options = process.env.TINYGLOBBY_DEBUG ? {
2403
+ ...inputOptions,
2404
+ debug: true
2405
+ } : inputOptions;
2406
+ const cwd = normalizeCwd(options.cwd);
2407
+ if (options.debug) log("globbing with:", {
2408
+ patterns,
2409
+ options,
2410
+ cwd
2411
+ });
2412
+ if (Array.isArray(patterns) && patterns.length === 0) return [{
2413
+ sync: () => [],
2414
+ withPromise: async () => []
2415
+ }, false];
2416
+ const props = {
2417
+ root: cwd,
2418
+ commonPath: null,
2419
+ depthOffset: 0
2420
+ };
2421
+ const processed = processPatterns({
2422
+ ...options,
2423
+ patterns
2424
+ }, cwd, props);
2425
+ if (options.debug) log("internal processing patterns:", processed);
2426
+ const matchOptions = {
2427
+ dot: options.dot,
2428
+ nobrace: options.braceExpansion === false,
2429
+ nocase: options.caseSensitiveMatch === false,
2430
+ noextglob: options.extglob === false,
2431
+ noglobstar: options.globstar === false,
2432
+ posix: true
2433
+ };
2434
+ const matcher = (0, import_picomatch.default)(processed.match, {
2435
+ ...matchOptions,
2436
+ ignore: processed.ignore
2437
+ });
2438
+ const ignore = (0, import_picomatch.default)(processed.ignore, matchOptions);
2439
+ const partialMatcher = getPartialMatcher(processed.match, matchOptions);
2440
+ const format = buildFormat(cwd, props.root, options.absolute);
2441
+ const formatExclude = options.absolute ? format : buildFormat(cwd, props.root, true);
2442
+ const fdirOptions = {
2443
+ filters: [options.debug ? (p, isDirectory) => {
2444
+ const path$1 = format(p, isDirectory);
2445
+ const matches = matcher(path$1);
2446
+ if (matches) log(`matched ${path$1}`);
2447
+ return matches;
2448
+ } : (p, isDirectory) => matcher(format(p, isDirectory))],
2449
+ exclude: options.debug ? (_, p) => {
2450
+ const relativePath = formatExclude(p, true);
2451
+ const skipped = relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
2452
+ if (skipped) log(`skipped ${p}`);
2453
+ else log(`crawling ${p}`);
2454
+ return skipped;
2455
+ } : (_, p) => {
2456
+ const relativePath = formatExclude(p, true);
2457
+ return relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
2458
+ },
2459
+ fs: options.fs ? {
2460
+ readdir: options.fs.readdir || nativeFs.readdir,
2461
+ readdirSync: options.fs.readdirSync || nativeFs.readdirSync,
2462
+ realpath: options.fs.realpath || nativeFs.realpath,
2463
+ realpathSync: options.fs.realpathSync || nativeFs.realpathSync,
2464
+ stat: options.fs.stat || nativeFs.stat,
2465
+ statSync: options.fs.statSync || nativeFs.statSync
2466
+ } : void 0,
2467
+ pathSeparator: "/",
2468
+ relativePaths: true,
2469
+ resolveSymlinks: true,
2470
+ signal: options.signal
2471
+ };
2472
+ if (options.deep !== void 0) fdirOptions.maxDepth = Math.round(options.deep - props.depthOffset);
2473
+ if (options.absolute) {
2474
+ fdirOptions.relativePaths = false;
2475
+ fdirOptions.resolvePaths = true;
2476
+ fdirOptions.includeBasePath = true;
2477
+ }
2478
+ if (options.followSymbolicLinks === false) {
2479
+ fdirOptions.resolveSymlinks = false;
2480
+ fdirOptions.excludeSymlinks = true;
2481
+ }
2482
+ if (options.onlyDirectories) {
2483
+ fdirOptions.excludeFiles = true;
2484
+ fdirOptions.includeDirs = true;
2485
+ } else if (options.onlyFiles === false) fdirOptions.includeDirs = true;
2486
+ props.root = props.root.replace(BACKSLASHES, "");
2487
+ const root = props.root;
2488
+ if (options.debug) log("internal properties:", props);
2489
+ const relative$1 = cwd !== root && !options.absolute && buildRelative(cwd, props.root);
2490
+ return [new Builder(fdirOptions).crawl(root), relative$1];
2491
+ }
2492
+ async function glob(patternsOrOptions, options) {
2493
+ if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
2494
+ const isModern = isReadonlyArray(patternsOrOptions) || typeof patternsOrOptions === "string";
2495
+ const opts = isModern ? options : patternsOrOptions;
2496
+ const [crawler, relative$1] = getCrawler(isModern ? patternsOrOptions : patternsOrOptions.patterns, opts);
2497
+ if (!relative$1) return crawler.withPromise();
2498
+ return formatPaths(await crawler.withPromise(), relative$1);
2499
+ }
2500
+
2501
+ //#endregion
2502
+ //#region src/core/template-reader.ts
2503
+ const __dirname = dirname(fileURLToPath(import.meta.url));
2504
+ function getTemplatesRoot() {
2505
+ const possiblePaths = [
2506
+ join(__dirname, "../templates"),
2507
+ join(__dirname, "../../templates"),
2508
+ join(__dirname, "../../../templates")
2509
+ ];
2510
+ for (const p of possiblePaths) if (fs.existsSync(p)) return p;
2511
+ throw new Error("Templates directory not found. Checked: " + possiblePaths.join(", "));
2512
+ }
2513
+ function getBinaryTemplatesRoot() {
2514
+ const possiblePaths = [
2515
+ join(__dirname, "../templates-binary"),
2516
+ join(__dirname, "../../templates-binary"),
2517
+ join(__dirname, "../../../templates-binary")
2518
+ ];
2519
+ for (const p of possiblePaths) if (fs.existsSync(p)) return p;
2520
+ throw new Error("Binary templates directory not found. Checked: " + possiblePaths.join(", "));
2521
+ }
2522
+ async function loadTemplates(prefix) {
2523
+ const templatesRoot = getTemplatesRoot();
2524
+ const searchDir = prefix ? join(templatesRoot, prefix) : templatesRoot;
2525
+ if (!fs.existsSync(searchDir)) return /* @__PURE__ */ new Map();
2526
+ const files = await glob("**/*", {
2527
+ cwd: searchDir,
2528
+ dot: true,
2529
+ onlyFiles: true
2530
+ });
2531
+ const templates = /* @__PURE__ */ new Map();
2532
+ for (const file of files) {
2533
+ const fullPath = join(searchDir, file);
2534
+ const relativePath = prefix ? `${prefix}/${file}` : file;
2535
+ try {
2536
+ if (isBinaryPath(file)) templates.set(relativePath, "[Binary file]");
2537
+ else templates.set(relativePath, fs.readFileSync(fullPath, "utf-8"));
2538
+ } catch (error) {
2539
+ console.warn(`Failed to read template: ${relativePath}`, error);
2540
+ }
2541
+ }
2542
+ return templates;
2543
+ }
2544
+ function loadTemplate(relativePath) {
2545
+ const fullPath = join(getTemplatesRoot(), relativePath);
2546
+ if (!fs.existsSync(fullPath)) return void 0;
2547
+ if (isBinaryPath(relativePath)) return "[Binary file]";
2548
+ return fs.readFileSync(fullPath, "utf-8");
2549
+ }
2550
+ async function listTemplates(prefix) {
2551
+ const templatesRoot = getTemplatesRoot();
2552
+ const searchDir = prefix ? join(templatesRoot, prefix) : templatesRoot;
2553
+ if (!fs.existsSync(searchDir)) return [];
2554
+ const files = await glob("**/*", {
2555
+ cwd: searchDir,
2556
+ dot: true,
2557
+ onlyFiles: true
2558
+ });
2559
+ return prefix ? files.map((f) => `${prefix}/${f}`) : files;
2560
+ }
2561
+
2562
+ //#endregion
2563
+ export { loadTemplates as a, loadTemplate as i, getTemplatesRoot as n, listTemplates as r, getBinaryTemplatesRoot as t };
2564
+ //# sourceMappingURL=template-reader-DOXCnctl.mjs.map