@soda-gql/codegen 0.11.13 → 0.11.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2696 @@
1
+ import "node:module";
2
+ import { Kind } from "graphql";
3
+
4
+ //#region rolldown:runtime
5
+ var __create = Object.create;
6
+ var __defProp = Object.defineProperty;
7
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
+ var __getOwnPropNames = Object.getOwnPropertyNames;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) {
17
+ __defProp(to, key, {
18
+ get: ((k) => from[k]).bind(null, key),
19
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
+ });
21
+ }
22
+ }
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
27
+ value: mod,
28
+ enumerable: true
29
+ }) : target, mod));
30
+
31
+ //#endregion
32
+ //#region node_modules/picomatch/lib/constants.js
33
+ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
34
+ const WIN_SLASH = "\\\\/";
35
+ const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
36
+ /**
37
+ * Posix glob regex
38
+ */
39
+ const DOT_LITERAL = "\\.";
40
+ const PLUS_LITERAL = "\\+";
41
+ const QMARK_LITERAL = "\\?";
42
+ const SLASH_LITERAL = "\\/";
43
+ const ONE_CHAR = "(?=.)";
44
+ const QMARK = "[^/]";
45
+ const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
46
+ const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
47
+ const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
48
+ const NO_DOT = `(?!${DOT_LITERAL})`;
49
+ const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
50
+ const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
51
+ const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
52
+ const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
53
+ const STAR = `${QMARK}*?`;
54
+ const SEP = "/";
55
+ const POSIX_CHARS = {
56
+ DOT_LITERAL,
57
+ PLUS_LITERAL,
58
+ QMARK_LITERAL,
59
+ SLASH_LITERAL,
60
+ ONE_CHAR,
61
+ QMARK,
62
+ END_ANCHOR,
63
+ DOTS_SLASH,
64
+ NO_DOT,
65
+ NO_DOTS,
66
+ NO_DOT_SLASH,
67
+ NO_DOTS_SLASH,
68
+ QMARK_NO_DOT,
69
+ STAR,
70
+ START_ANCHOR,
71
+ SEP
72
+ };
73
+ /**
74
+ * Windows glob regex
75
+ */
76
+ const WINDOWS_CHARS = {
77
+ ...POSIX_CHARS,
78
+ SLASH_LITERAL: `[${WIN_SLASH}]`,
79
+ QMARK: WIN_NO_SLASH,
80
+ STAR: `${WIN_NO_SLASH}*?`,
81
+ DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
82
+ NO_DOT: `(?!${DOT_LITERAL})`,
83
+ NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
84
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
85
+ NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
86
+ QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
87
+ START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
88
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
89
+ SEP: "\\"
90
+ };
91
+ /**
92
+ * POSIX Bracket Regex
93
+ */
94
+ const POSIX_REGEX_SOURCE$1 = {
95
+ alnum: "a-zA-Z0-9",
96
+ alpha: "a-zA-Z",
97
+ ascii: "\\x00-\\x7F",
98
+ blank: " \\t",
99
+ cntrl: "\\x00-\\x1F\\x7F",
100
+ digit: "0-9",
101
+ graph: "\\x21-\\x7E",
102
+ lower: "a-z",
103
+ print: "\\x20-\\x7E ",
104
+ punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
105
+ space: " \\t\\r\\n\\v\\f",
106
+ upper: "A-Z",
107
+ word: "A-Za-z0-9_",
108
+ xdigit: "A-Fa-f0-9"
109
+ };
110
+ module.exports = {
111
+ MAX_LENGTH: 1024 * 64,
112
+ POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
113
+ REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
114
+ REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
115
+ REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
116
+ REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
117
+ REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
118
+ REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
119
+ REPLACEMENTS: {
120
+ __proto__: null,
121
+ "***": "*",
122
+ "**/**": "**",
123
+ "**/**/**": "**"
124
+ },
125
+ CHAR_0: 48,
126
+ CHAR_9: 57,
127
+ CHAR_UPPERCASE_A: 65,
128
+ CHAR_LOWERCASE_A: 97,
129
+ CHAR_UPPERCASE_Z: 90,
130
+ CHAR_LOWERCASE_Z: 122,
131
+ CHAR_LEFT_PARENTHESES: 40,
132
+ CHAR_RIGHT_PARENTHESES: 41,
133
+ CHAR_ASTERISK: 42,
134
+ CHAR_AMPERSAND: 38,
135
+ CHAR_AT: 64,
136
+ CHAR_BACKWARD_SLASH: 92,
137
+ CHAR_CARRIAGE_RETURN: 13,
138
+ CHAR_CIRCUMFLEX_ACCENT: 94,
139
+ CHAR_COLON: 58,
140
+ CHAR_COMMA: 44,
141
+ CHAR_DOT: 46,
142
+ CHAR_DOUBLE_QUOTE: 34,
143
+ CHAR_EQUAL: 61,
144
+ CHAR_EXCLAMATION_MARK: 33,
145
+ CHAR_FORM_FEED: 12,
146
+ CHAR_FORWARD_SLASH: 47,
147
+ CHAR_GRAVE_ACCENT: 96,
148
+ CHAR_HASH: 35,
149
+ CHAR_HYPHEN_MINUS: 45,
150
+ CHAR_LEFT_ANGLE_BRACKET: 60,
151
+ CHAR_LEFT_CURLY_BRACE: 123,
152
+ CHAR_LEFT_SQUARE_BRACKET: 91,
153
+ CHAR_LINE_FEED: 10,
154
+ CHAR_NO_BREAK_SPACE: 160,
155
+ CHAR_PERCENT: 37,
156
+ CHAR_PLUS: 43,
157
+ CHAR_QUESTION_MARK: 63,
158
+ CHAR_RIGHT_ANGLE_BRACKET: 62,
159
+ CHAR_RIGHT_CURLY_BRACE: 125,
160
+ CHAR_RIGHT_SQUARE_BRACKET: 93,
161
+ CHAR_SEMICOLON: 59,
162
+ CHAR_SINGLE_QUOTE: 39,
163
+ CHAR_SPACE: 32,
164
+ CHAR_TAB: 9,
165
+ CHAR_UNDERSCORE: 95,
166
+ CHAR_VERTICAL_LINE: 124,
167
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
168
+ extglobChars(chars) {
169
+ return {
170
+ "!": {
171
+ type: "negate",
172
+ open: "(?:(?!(?:",
173
+ close: `))${chars.STAR})`
174
+ },
175
+ "?": {
176
+ type: "qmark",
177
+ open: "(?:",
178
+ close: ")?"
179
+ },
180
+ "+": {
181
+ type: "plus",
182
+ open: "(?:",
183
+ close: ")+"
184
+ },
185
+ "*": {
186
+ type: "star",
187
+ open: "(?:",
188
+ close: ")*"
189
+ },
190
+ "@": {
191
+ type: "at",
192
+ open: "(?:",
193
+ close: ")"
194
+ }
195
+ };
196
+ },
197
+ globChars(win32) {
198
+ return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
199
+ }
200
+ };
201
+ }));
202
+
203
+ //#endregion
204
+ //#region node_modules/picomatch/lib/utils.js
205
+ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
206
+ const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
207
+ exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
208
+ exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
209
+ exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
210
+ exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
211
+ exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
212
+ exports.isWindows = () => {
213
+ if (typeof navigator !== "undefined" && navigator.platform) {
214
+ const platform = navigator.platform.toLowerCase();
215
+ return platform === "win32" || platform === "windows";
216
+ }
217
+ if (typeof process !== "undefined" && process.platform) {
218
+ return process.platform === "win32";
219
+ }
220
+ return false;
221
+ };
222
+ exports.removeBackslashes = (str) => {
223
+ return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
224
+ return match === "\\" ? "" : match;
225
+ });
226
+ };
227
+ exports.escapeLast = (input, char, lastIdx) => {
228
+ const idx = input.lastIndexOf(char, lastIdx);
229
+ if (idx === -1) return input;
230
+ if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
231
+ return `${input.slice(0, idx)}\\${input.slice(idx)}`;
232
+ };
233
+ exports.removePrefix = (input, state = {}) => {
234
+ let output = input;
235
+ if (output.startsWith("./")) {
236
+ output = output.slice(2);
237
+ state.prefix = "./";
238
+ }
239
+ return output;
240
+ };
241
+ exports.wrapOutput = (input, state = {}, options = {}) => {
242
+ const prepend = options.contains ? "" : "^";
243
+ const append = options.contains ? "" : "$";
244
+ let output = `${prepend}(?:${input})${append}`;
245
+ if (state.negated === true) {
246
+ output = `(?:^(?!${output}).*$)`;
247
+ }
248
+ return output;
249
+ };
250
+ exports.basename = (path, { windows } = {}) => {
251
+ const segs = path.split(windows ? /[\\/]/ : "/");
252
+ const last = segs[segs.length - 1];
253
+ if (last === "") {
254
+ return segs[segs.length - 2];
255
+ }
256
+ return last;
257
+ };
258
+ }));
259
+
260
+ //#endregion
261
+ //#region node_modules/picomatch/lib/scan.js
262
+ var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
263
+ const utils$3 = require_utils();
264
+ 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();
265
+ const isPathSeparator = (code) => {
266
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
267
+ };
268
+ const depth = (token) => {
269
+ if (token.isPrefix !== true) {
270
+ token.depth = token.isGlobstar ? Infinity : 1;
271
+ }
272
+ };
273
+ /**
274
+ * Quickly scans a glob pattern and returns an object with a handful of
275
+ * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
276
+ * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
277
+ * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
278
+ *
279
+ * ```js
280
+ * const pm = require('picomatch');
281
+ * console.log(pm.scan('foo/bar/*.js'));
282
+ * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
283
+ * ```
284
+ * @param {String} `str`
285
+ * @param {Object} `options`
286
+ * @return {Object} Returns an object with tokens and regex source string.
287
+ * @api public
288
+ */
289
+ const scan$1 = (input, options) => {
290
+ const opts = options || {};
291
+ const length = input.length - 1;
292
+ const scanToEnd = opts.parts === true || opts.scanToEnd === true;
293
+ const slashes = [];
294
+ const tokens = [];
295
+ const parts = [];
296
+ let str = input;
297
+ let index = -1;
298
+ let start = 0;
299
+ let lastIndex = 0;
300
+ let isBrace = false;
301
+ let isBracket = false;
302
+ let isGlob = false;
303
+ let isExtglob = false;
304
+ let isGlobstar = false;
305
+ let braceEscaped = false;
306
+ let backslashes = false;
307
+ let negated = false;
308
+ let negatedExtglob = false;
309
+ let finished = false;
310
+ let braces = 0;
311
+ let prev;
312
+ let code;
313
+ let token = {
314
+ value: "",
315
+ depth: 0,
316
+ isGlob: false
317
+ };
318
+ const eos = () => index >= length;
319
+ const peek = () => str.charCodeAt(index + 1);
320
+ const advance = () => {
321
+ prev = code;
322
+ return str.charCodeAt(++index);
323
+ };
324
+ while (index < length) {
325
+ code = advance();
326
+ let next;
327
+ if (code === CHAR_BACKWARD_SLASH) {
328
+ backslashes = token.backslashes = true;
329
+ code = advance();
330
+ if (code === CHAR_LEFT_CURLY_BRACE) {
331
+ braceEscaped = true;
332
+ }
333
+ continue;
334
+ }
335
+ if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
336
+ braces++;
337
+ while (eos() !== true && (code = advance())) {
338
+ if (code === CHAR_BACKWARD_SLASH) {
339
+ backslashes = token.backslashes = true;
340
+ advance();
341
+ continue;
342
+ }
343
+ if (code === CHAR_LEFT_CURLY_BRACE) {
344
+ braces++;
345
+ continue;
346
+ }
347
+ if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
348
+ isBrace = token.isBrace = true;
349
+ isGlob = token.isGlob = true;
350
+ finished = true;
351
+ if (scanToEnd === true) {
352
+ continue;
353
+ }
354
+ break;
355
+ }
356
+ if (braceEscaped !== true && code === CHAR_COMMA) {
357
+ isBrace = token.isBrace = true;
358
+ isGlob = token.isGlob = true;
359
+ finished = true;
360
+ if (scanToEnd === true) {
361
+ continue;
362
+ }
363
+ break;
364
+ }
365
+ if (code === CHAR_RIGHT_CURLY_BRACE) {
366
+ braces--;
367
+ if (braces === 0) {
368
+ braceEscaped = false;
369
+ isBrace = token.isBrace = true;
370
+ finished = true;
371
+ break;
372
+ }
373
+ }
374
+ }
375
+ if (scanToEnd === true) {
376
+ continue;
377
+ }
378
+ break;
379
+ }
380
+ if (code === CHAR_FORWARD_SLASH) {
381
+ slashes.push(index);
382
+ tokens.push(token);
383
+ token = {
384
+ value: "",
385
+ depth: 0,
386
+ isGlob: false
387
+ };
388
+ if (finished === true) continue;
389
+ if (prev === CHAR_DOT && index === start + 1) {
390
+ start += 2;
391
+ continue;
392
+ }
393
+ lastIndex = index + 1;
394
+ continue;
395
+ }
396
+ if (opts.noext !== true) {
397
+ const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
398
+ if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
399
+ isGlob = token.isGlob = true;
400
+ isExtglob = token.isExtglob = true;
401
+ finished = true;
402
+ if (code === CHAR_EXCLAMATION_MARK && index === start) {
403
+ negatedExtglob = true;
404
+ }
405
+ if (scanToEnd === true) {
406
+ while (eos() !== true && (code = advance())) {
407
+ if (code === CHAR_BACKWARD_SLASH) {
408
+ backslashes = token.backslashes = true;
409
+ code = advance();
410
+ continue;
411
+ }
412
+ if (code === CHAR_RIGHT_PARENTHESES) {
413
+ isGlob = token.isGlob = true;
414
+ finished = true;
415
+ break;
416
+ }
417
+ }
418
+ continue;
419
+ }
420
+ break;
421
+ }
422
+ }
423
+ if (code === CHAR_ASTERISK) {
424
+ if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
425
+ isGlob = token.isGlob = true;
426
+ finished = true;
427
+ if (scanToEnd === true) {
428
+ continue;
429
+ }
430
+ break;
431
+ }
432
+ if (code === CHAR_QUESTION_MARK) {
433
+ isGlob = token.isGlob = true;
434
+ finished = true;
435
+ if (scanToEnd === true) {
436
+ continue;
437
+ }
438
+ break;
439
+ }
440
+ if (code === CHAR_LEFT_SQUARE_BRACKET) {
441
+ while (eos() !== true && (next = advance())) {
442
+ if (next === CHAR_BACKWARD_SLASH) {
443
+ backslashes = token.backslashes = true;
444
+ advance();
445
+ continue;
446
+ }
447
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
448
+ isBracket = token.isBracket = true;
449
+ isGlob = token.isGlob = true;
450
+ finished = true;
451
+ break;
452
+ }
453
+ }
454
+ if (scanToEnd === true) {
455
+ continue;
456
+ }
457
+ break;
458
+ }
459
+ if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
460
+ negated = token.negated = true;
461
+ start++;
462
+ continue;
463
+ }
464
+ if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
465
+ isGlob = token.isGlob = true;
466
+ if (scanToEnd === true) {
467
+ while (eos() !== true && (code = advance())) {
468
+ if (code === CHAR_LEFT_PARENTHESES) {
469
+ backslashes = token.backslashes = true;
470
+ code = advance();
471
+ continue;
472
+ }
473
+ if (code === CHAR_RIGHT_PARENTHESES) {
474
+ finished = true;
475
+ break;
476
+ }
477
+ }
478
+ continue;
479
+ }
480
+ break;
481
+ }
482
+ if (isGlob === true) {
483
+ finished = true;
484
+ if (scanToEnd === true) {
485
+ continue;
486
+ }
487
+ break;
488
+ }
489
+ }
490
+ if (opts.noext === true) {
491
+ isExtglob = false;
492
+ isGlob = false;
493
+ }
494
+ let base = str;
495
+ let prefix = "";
496
+ let glob = "";
497
+ if (start > 0) {
498
+ prefix = str.slice(0, start);
499
+ str = str.slice(start);
500
+ lastIndex -= start;
501
+ }
502
+ if (base && isGlob === true && lastIndex > 0) {
503
+ base = str.slice(0, lastIndex);
504
+ glob = str.slice(lastIndex);
505
+ } else if (isGlob === true) {
506
+ base = "";
507
+ glob = str;
508
+ } else {
509
+ base = str;
510
+ }
511
+ if (base && base !== "" && base !== "/" && base !== str) {
512
+ if (isPathSeparator(base.charCodeAt(base.length - 1))) {
513
+ base = base.slice(0, -1);
514
+ }
515
+ }
516
+ if (opts.unescape === true) {
517
+ if (glob) glob = utils$3.removeBackslashes(glob);
518
+ if (base && backslashes === true) {
519
+ base = utils$3.removeBackslashes(base);
520
+ }
521
+ }
522
+ const state = {
523
+ prefix,
524
+ input,
525
+ start,
526
+ base,
527
+ glob,
528
+ isBrace,
529
+ isBracket,
530
+ isGlob,
531
+ isExtglob,
532
+ isGlobstar,
533
+ negated,
534
+ negatedExtglob
535
+ };
536
+ if (opts.tokens === true) {
537
+ state.maxDepth = 0;
538
+ if (!isPathSeparator(code)) {
539
+ tokens.push(token);
540
+ }
541
+ state.tokens = tokens;
542
+ }
543
+ if (opts.parts === true || opts.tokens === true) {
544
+ let prevIndex;
545
+ for (let idx = 0; idx < slashes.length; idx++) {
546
+ const n = prevIndex ? prevIndex + 1 : start;
547
+ const i = slashes[idx];
548
+ const value = input.slice(n, i);
549
+ if (opts.tokens) {
550
+ if (idx === 0 && start !== 0) {
551
+ tokens[idx].isPrefix = true;
552
+ tokens[idx].value = prefix;
553
+ } else {
554
+ tokens[idx].value = value;
555
+ }
556
+ depth(tokens[idx]);
557
+ state.maxDepth += tokens[idx].depth;
558
+ }
559
+ if (idx !== 0 || value !== "") {
560
+ parts.push(value);
561
+ }
562
+ prevIndex = i;
563
+ }
564
+ if (prevIndex && prevIndex + 1 < input.length) {
565
+ const value = input.slice(prevIndex + 1);
566
+ parts.push(value);
567
+ if (opts.tokens) {
568
+ tokens[tokens.length - 1].value = value;
569
+ depth(tokens[tokens.length - 1]);
570
+ state.maxDepth += tokens[tokens.length - 1].depth;
571
+ }
572
+ }
573
+ state.slashes = slashes;
574
+ state.parts = parts;
575
+ }
576
+ return state;
577
+ };
578
+ module.exports = scan$1;
579
+ }));
580
+
581
+ //#endregion
582
+ //#region node_modules/picomatch/lib/parse.js
583
+ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
584
+ const constants$1 = require_constants();
585
+ const utils$2 = require_utils();
586
+ /**
587
+ * Constants
588
+ */
589
+ const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants$1;
590
+ /**
591
+ * Helpers
592
+ */
593
+ const expandRange = (args, options) => {
594
+ if (typeof options.expandRange === "function") {
595
+ return options.expandRange(...args, options);
596
+ }
597
+ args.sort();
598
+ const value = `[${args.join("-")}]`;
599
+ try {
600
+ new RegExp(value);
601
+ } catch (ex) {
602
+ return args.map((v) => utils$2.escapeRegex(v)).join("..");
603
+ }
604
+ return value;
605
+ };
606
+ /**
607
+ * Create the message for a syntax error
608
+ */
609
+ const syntaxError = (type, char) => {
610
+ return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
611
+ };
612
+ /**
613
+ * Parse the given input string.
614
+ * @param {String} input
615
+ * @param {Object} options
616
+ * @return {Object}
617
+ */
618
+ const parse$2 = (input, options) => {
619
+ if (typeof input !== "string") {
620
+ throw new TypeError("Expected a string");
621
+ }
622
+ input = REPLACEMENTS[input] || input;
623
+ const opts = { ...options };
624
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
625
+ let len = input.length;
626
+ if (len > max) {
627
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
628
+ }
629
+ const bos = {
630
+ type: "bos",
631
+ value: "",
632
+ output: opts.prepend || ""
633
+ };
634
+ const tokens = [bos];
635
+ const capture = opts.capture ? "" : "?:";
636
+ const PLATFORM_CHARS = constants$1.globChars(opts.windows);
637
+ const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
638
+ 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$1, NO_DOT_SLASH: NO_DOT_SLASH$1, NO_DOTS_SLASH: NO_DOTS_SLASH$1, QMARK: QMARK$1, QMARK_NO_DOT: QMARK_NO_DOT$1, STAR: STAR$1, START_ANCHOR: START_ANCHOR$1 } = PLATFORM_CHARS;
639
+ const globstar = (opts$1) => {
640
+ return `(${capture}(?:(?!${START_ANCHOR$1}${opts$1.dot ? DOTS_SLASH$1 : DOT_LITERAL$1}).)*?)`;
641
+ };
642
+ const nodot = opts.dot ? "" : NO_DOT$1;
643
+ const qmarkNoDot = opts.dot ? QMARK$1 : QMARK_NO_DOT$1;
644
+ let star = opts.bash === true ? globstar(opts) : STAR$1;
645
+ if (opts.capture) {
646
+ star = `(${star})`;
647
+ }
648
+ if (typeof opts.noext === "boolean") {
649
+ opts.noextglob = opts.noext;
650
+ }
651
+ const state = {
652
+ input,
653
+ index: -1,
654
+ start: 0,
655
+ dot: opts.dot === true,
656
+ consumed: "",
657
+ output: "",
658
+ prefix: "",
659
+ backtrack: false,
660
+ negated: false,
661
+ brackets: 0,
662
+ braces: 0,
663
+ parens: 0,
664
+ quotes: 0,
665
+ globstar: false,
666
+ tokens
667
+ };
668
+ input = utils$2.removePrefix(input, state);
669
+ len = input.length;
670
+ const extglobs = [];
671
+ const braces = [];
672
+ const stack = [];
673
+ let prev = bos;
674
+ let value;
675
+ /**
676
+ * Tokenizing helpers
677
+ */
678
+ const eos = () => state.index === len - 1;
679
+ const peek = state.peek = (n = 1) => input[state.index + n];
680
+ const advance = state.advance = () => input[++state.index] || "";
681
+ const remaining = () => input.slice(state.index + 1);
682
+ const consume = (value$1 = "", num = 0) => {
683
+ state.consumed += value$1;
684
+ state.index += num;
685
+ };
686
+ const append = (token) => {
687
+ state.output += token.output != null ? token.output : token.value;
688
+ consume(token.value);
689
+ };
690
+ const negate = () => {
691
+ let count = 1;
692
+ while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
693
+ advance();
694
+ state.start++;
695
+ count++;
696
+ }
697
+ if (count % 2 === 0) {
698
+ return false;
699
+ }
700
+ state.negated = true;
701
+ state.start++;
702
+ return true;
703
+ };
704
+ const increment = (type) => {
705
+ state[type]++;
706
+ stack.push(type);
707
+ };
708
+ const decrement = (type) => {
709
+ state[type]--;
710
+ stack.pop();
711
+ };
712
+ /**
713
+ * Push tokens onto the tokens array. This helper speeds up
714
+ * tokenizing by 1) helping us avoid backtracking as much as possible,
715
+ * and 2) helping us avoid creating extra tokens when consecutive
716
+ * characters are plain text. This improves performance and simplifies
717
+ * lookbehinds.
718
+ */
719
+ const push = (tok) => {
720
+ if (prev.type === "globstar") {
721
+ const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
722
+ const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
723
+ if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
724
+ state.output = state.output.slice(0, -prev.output.length);
725
+ prev.type = "star";
726
+ prev.value = "*";
727
+ prev.output = star;
728
+ state.output += prev.output;
729
+ }
730
+ }
731
+ if (extglobs.length && tok.type !== "paren") {
732
+ extglobs[extglobs.length - 1].inner += tok.value;
733
+ }
734
+ if (tok.value || tok.output) append(tok);
735
+ if (prev && prev.type === "text" && tok.type === "text") {
736
+ prev.output = (prev.output || prev.value) + tok.value;
737
+ prev.value += tok.value;
738
+ return;
739
+ }
740
+ tok.prev = prev;
741
+ tokens.push(tok);
742
+ prev = tok;
743
+ };
744
+ const extglobOpen = (type, value$1) => {
745
+ const token = {
746
+ ...EXTGLOB_CHARS[value$1],
747
+ conditions: 1,
748
+ inner: ""
749
+ };
750
+ token.prev = prev;
751
+ token.parens = state.parens;
752
+ token.output = state.output;
753
+ const output = (opts.capture ? "(" : "") + token.open;
754
+ increment("parens");
755
+ push({
756
+ type,
757
+ value: value$1,
758
+ output: state.output ? "" : ONE_CHAR$1
759
+ });
760
+ push({
761
+ type: "paren",
762
+ extglob: true,
763
+ value: advance(),
764
+ output
765
+ });
766
+ extglobs.push(token);
767
+ };
768
+ const extglobClose = (token) => {
769
+ let output = token.close + (opts.capture ? ")" : "");
770
+ let rest;
771
+ if (token.type === "negate") {
772
+ let extglobStar = star;
773
+ if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
774
+ extglobStar = globstar(opts);
775
+ }
776
+ if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
777
+ output = token.close = `)$))${extglobStar}`;
778
+ }
779
+ if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
780
+ const expression = parse$2(rest, {
781
+ ...options,
782
+ fastpaths: false
783
+ }).output;
784
+ output = token.close = `)${expression})${extglobStar})`;
785
+ }
786
+ if (token.prev.type === "bos") {
787
+ state.negatedExtglob = true;
788
+ }
789
+ }
790
+ push({
791
+ type: "paren",
792
+ extglob: true,
793
+ value,
794
+ output
795
+ });
796
+ decrement("parens");
797
+ };
798
+ /**
799
+ * Fast paths
800
+ */
801
+ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
802
+ let backslashes = false;
803
+ let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
804
+ if (first === "\\") {
805
+ backslashes = true;
806
+ return m;
807
+ }
808
+ if (first === "?") {
809
+ if (esc) {
810
+ return esc + first + (rest ? QMARK$1.repeat(rest.length) : "");
811
+ }
812
+ if (index === 0) {
813
+ return qmarkNoDot + (rest ? QMARK$1.repeat(rest.length) : "");
814
+ }
815
+ return QMARK$1.repeat(chars.length);
816
+ }
817
+ if (first === ".") {
818
+ return DOT_LITERAL$1.repeat(chars.length);
819
+ }
820
+ if (first === "*") {
821
+ if (esc) {
822
+ return esc + first + (rest ? star : "");
823
+ }
824
+ return star;
825
+ }
826
+ return esc ? m : `\\${m}`;
827
+ });
828
+ if (backslashes === true) {
829
+ if (opts.unescape === true) {
830
+ output = output.replace(/\\/g, "");
831
+ } else {
832
+ output = output.replace(/\\+/g, (m) => {
833
+ return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
834
+ });
835
+ }
836
+ }
837
+ if (output === input && opts.contains === true) {
838
+ state.output = input;
839
+ return state;
840
+ }
841
+ state.output = utils$2.wrapOutput(output, state, options);
842
+ return state;
843
+ }
844
+ /**
845
+ * Tokenize input until we reach end-of-string
846
+ */
847
+ while (!eos()) {
848
+ value = advance();
849
+ if (value === "\0") {
850
+ continue;
851
+ }
852
+ /**
853
+ * Escaped characters
854
+ */
855
+ if (value === "\\") {
856
+ const next = peek();
857
+ if (next === "/" && opts.bash !== true) {
858
+ continue;
859
+ }
860
+ if (next === "." || next === ";") {
861
+ continue;
862
+ }
863
+ if (!next) {
864
+ value += "\\";
865
+ push({
866
+ type: "text",
867
+ value
868
+ });
869
+ continue;
870
+ }
871
+ const match = /^\\+/.exec(remaining());
872
+ let slashes = 0;
873
+ if (match && match[0].length > 2) {
874
+ slashes = match[0].length;
875
+ state.index += slashes;
876
+ if (slashes % 2 !== 0) {
877
+ value += "\\";
878
+ }
879
+ }
880
+ if (opts.unescape === true) {
881
+ value = advance();
882
+ } else {
883
+ value += advance();
884
+ }
885
+ if (state.brackets === 0) {
886
+ push({
887
+ type: "text",
888
+ value
889
+ });
890
+ continue;
891
+ }
892
+ }
893
+ /**
894
+ * If we're inside a regex character class, continue
895
+ * until we reach the closing bracket.
896
+ */
897
+ if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
898
+ if (opts.posix !== false && value === ":") {
899
+ const inner = prev.value.slice(1);
900
+ if (inner.includes("[")) {
901
+ prev.posix = true;
902
+ if (inner.includes(":")) {
903
+ const idx = prev.value.lastIndexOf("[");
904
+ const pre = prev.value.slice(0, idx);
905
+ const rest$1 = prev.value.slice(idx + 2);
906
+ const posix = POSIX_REGEX_SOURCE[rest$1];
907
+ if (posix) {
908
+ prev.value = pre + posix;
909
+ state.backtrack = true;
910
+ advance();
911
+ if (!bos.output && tokens.indexOf(prev) === 1) {
912
+ bos.output = ONE_CHAR$1;
913
+ }
914
+ continue;
915
+ }
916
+ }
917
+ }
918
+ }
919
+ if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
920
+ value = `\\${value}`;
921
+ }
922
+ if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
923
+ value = `\\${value}`;
924
+ }
925
+ if (opts.posix === true && value === "!" && prev.value === "[") {
926
+ value = "^";
927
+ }
928
+ prev.value += value;
929
+ append({ value });
930
+ continue;
931
+ }
932
+ /**
933
+ * If we're inside a quoted string, continue
934
+ * until we reach the closing double quote.
935
+ */
936
+ if (state.quotes === 1 && value !== "\"") {
937
+ value = utils$2.escapeRegex(value);
938
+ prev.value += value;
939
+ append({ value });
940
+ continue;
941
+ }
942
+ /**
943
+ * Double quotes
944
+ */
945
+ if (value === "\"") {
946
+ state.quotes = state.quotes === 1 ? 0 : 1;
947
+ if (opts.keepQuotes === true) {
948
+ push({
949
+ type: "text",
950
+ value
951
+ });
952
+ }
953
+ continue;
954
+ }
955
+ /**
956
+ * Parentheses
957
+ */
958
+ if (value === "(") {
959
+ increment("parens");
960
+ push({
961
+ type: "paren",
962
+ value
963
+ });
964
+ continue;
965
+ }
966
+ if (value === ")") {
967
+ if (state.parens === 0 && opts.strictBrackets === true) {
968
+ throw new SyntaxError(syntaxError("opening", "("));
969
+ }
970
+ const extglob = extglobs[extglobs.length - 1];
971
+ if (extglob && state.parens === extglob.parens + 1) {
972
+ extglobClose(extglobs.pop());
973
+ continue;
974
+ }
975
+ push({
976
+ type: "paren",
977
+ value,
978
+ output: state.parens ? ")" : "\\)"
979
+ });
980
+ decrement("parens");
981
+ continue;
982
+ }
983
+ /**
984
+ * Square brackets
985
+ */
986
+ if (value === "[") {
987
+ if (opts.nobracket === true || !remaining().includes("]")) {
988
+ if (opts.nobracket !== true && opts.strictBrackets === true) {
989
+ throw new SyntaxError(syntaxError("closing", "]"));
990
+ }
991
+ value = `\\${value}`;
992
+ } else {
993
+ increment("brackets");
994
+ }
995
+ push({
996
+ type: "bracket",
997
+ value
998
+ });
999
+ continue;
1000
+ }
1001
+ if (value === "]") {
1002
+ if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
1003
+ push({
1004
+ type: "text",
1005
+ value,
1006
+ output: `\\${value}`
1007
+ });
1008
+ continue;
1009
+ }
1010
+ if (state.brackets === 0) {
1011
+ if (opts.strictBrackets === true) {
1012
+ throw new SyntaxError(syntaxError("opening", "["));
1013
+ }
1014
+ push({
1015
+ type: "text",
1016
+ value,
1017
+ output: `\\${value}`
1018
+ });
1019
+ continue;
1020
+ }
1021
+ decrement("brackets");
1022
+ const prevValue = prev.value.slice(1);
1023
+ if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
1024
+ value = `/${value}`;
1025
+ }
1026
+ prev.value += value;
1027
+ append({ value });
1028
+ if (opts.literalBrackets === false || utils$2.hasRegexChars(prevValue)) {
1029
+ continue;
1030
+ }
1031
+ const escaped = utils$2.escapeRegex(prev.value);
1032
+ state.output = state.output.slice(0, -prev.value.length);
1033
+ if (opts.literalBrackets === true) {
1034
+ state.output += escaped;
1035
+ prev.value = escaped;
1036
+ continue;
1037
+ }
1038
+ prev.value = `(${capture}${escaped}|${prev.value})`;
1039
+ state.output += prev.value;
1040
+ continue;
1041
+ }
1042
+ /**
1043
+ * Braces
1044
+ */
1045
+ if (value === "{" && opts.nobrace !== true) {
1046
+ increment("braces");
1047
+ const open = {
1048
+ type: "brace",
1049
+ value,
1050
+ output: "(",
1051
+ outputIndex: state.output.length,
1052
+ tokensIndex: state.tokens.length
1053
+ };
1054
+ braces.push(open);
1055
+ push(open);
1056
+ continue;
1057
+ }
1058
+ if (value === "}") {
1059
+ const brace = braces[braces.length - 1];
1060
+ if (opts.nobrace === true || !brace) {
1061
+ push({
1062
+ type: "text",
1063
+ value,
1064
+ output: value
1065
+ });
1066
+ continue;
1067
+ }
1068
+ let output = ")";
1069
+ if (brace.dots === true) {
1070
+ const arr = tokens.slice();
1071
+ const range = [];
1072
+ for (let i = arr.length - 1; i >= 0; i--) {
1073
+ tokens.pop();
1074
+ if (arr[i].type === "brace") {
1075
+ break;
1076
+ }
1077
+ if (arr[i].type !== "dots") {
1078
+ range.unshift(arr[i].value);
1079
+ }
1080
+ }
1081
+ output = expandRange(range, opts);
1082
+ state.backtrack = true;
1083
+ }
1084
+ if (brace.comma !== true && brace.dots !== true) {
1085
+ const out = state.output.slice(0, brace.outputIndex);
1086
+ const toks = state.tokens.slice(brace.tokensIndex);
1087
+ brace.value = brace.output = "\\{";
1088
+ value = output = "\\}";
1089
+ state.output = out;
1090
+ for (const t of toks) {
1091
+ state.output += t.output || t.value;
1092
+ }
1093
+ }
1094
+ push({
1095
+ type: "brace",
1096
+ value,
1097
+ output
1098
+ });
1099
+ decrement("braces");
1100
+ braces.pop();
1101
+ continue;
1102
+ }
1103
+ /**
1104
+ * Pipes
1105
+ */
1106
+ if (value === "|") {
1107
+ if (extglobs.length > 0) {
1108
+ extglobs[extglobs.length - 1].conditions++;
1109
+ }
1110
+ push({
1111
+ type: "text",
1112
+ value
1113
+ });
1114
+ continue;
1115
+ }
1116
+ /**
1117
+ * Commas
1118
+ */
1119
+ if (value === ",") {
1120
+ let output = value;
1121
+ const brace = braces[braces.length - 1];
1122
+ if (brace && stack[stack.length - 1] === "braces") {
1123
+ brace.comma = true;
1124
+ output = "|";
1125
+ }
1126
+ push({
1127
+ type: "comma",
1128
+ value,
1129
+ output
1130
+ });
1131
+ continue;
1132
+ }
1133
+ /**
1134
+ * Slashes
1135
+ */
1136
+ if (value === "/") {
1137
+ if (prev.type === "dot" && state.index === state.start + 1) {
1138
+ state.start = state.index + 1;
1139
+ state.consumed = "";
1140
+ state.output = "";
1141
+ tokens.pop();
1142
+ prev = bos;
1143
+ continue;
1144
+ }
1145
+ push({
1146
+ type: "slash",
1147
+ value,
1148
+ output: SLASH_LITERAL$1
1149
+ });
1150
+ continue;
1151
+ }
1152
+ /**
1153
+ * Dots
1154
+ */
1155
+ if (value === ".") {
1156
+ if (state.braces > 0 && prev.type === "dot") {
1157
+ if (prev.value === ".") prev.output = DOT_LITERAL$1;
1158
+ const brace = braces[braces.length - 1];
1159
+ prev.type = "dots";
1160
+ prev.output += value;
1161
+ prev.value += value;
1162
+ brace.dots = true;
1163
+ continue;
1164
+ }
1165
+ if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
1166
+ push({
1167
+ type: "text",
1168
+ value,
1169
+ output: DOT_LITERAL$1
1170
+ });
1171
+ continue;
1172
+ }
1173
+ push({
1174
+ type: "dot",
1175
+ value,
1176
+ output: DOT_LITERAL$1
1177
+ });
1178
+ continue;
1179
+ }
1180
+ /**
1181
+ * Question marks
1182
+ */
1183
+ if (value === "?") {
1184
+ const isGroup = prev && prev.value === "(";
1185
+ if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1186
+ extglobOpen("qmark", value);
1187
+ continue;
1188
+ }
1189
+ if (prev && prev.type === "paren") {
1190
+ const next = peek();
1191
+ let output = value;
1192
+ if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
1193
+ output = `\\${value}`;
1194
+ }
1195
+ push({
1196
+ type: "text",
1197
+ value,
1198
+ output
1199
+ });
1200
+ continue;
1201
+ }
1202
+ if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
1203
+ push({
1204
+ type: "qmark",
1205
+ value,
1206
+ output: QMARK_NO_DOT$1
1207
+ });
1208
+ continue;
1209
+ }
1210
+ push({
1211
+ type: "qmark",
1212
+ value,
1213
+ output: QMARK$1
1214
+ });
1215
+ continue;
1216
+ }
1217
+ /**
1218
+ * Exclamation
1219
+ */
1220
+ if (value === "!") {
1221
+ if (opts.noextglob !== true && peek() === "(") {
1222
+ if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
1223
+ extglobOpen("negate", value);
1224
+ continue;
1225
+ }
1226
+ }
1227
+ if (opts.nonegate !== true && state.index === 0) {
1228
+ negate();
1229
+ continue;
1230
+ }
1231
+ }
1232
+ /**
1233
+ * Plus
1234
+ */
1235
+ if (value === "+") {
1236
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1237
+ extglobOpen("plus", value);
1238
+ continue;
1239
+ }
1240
+ if (prev && prev.value === "(" || opts.regex === false) {
1241
+ push({
1242
+ type: "plus",
1243
+ value,
1244
+ output: PLUS_LITERAL$1
1245
+ });
1246
+ continue;
1247
+ }
1248
+ if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
1249
+ push({
1250
+ type: "plus",
1251
+ value
1252
+ });
1253
+ continue;
1254
+ }
1255
+ push({
1256
+ type: "plus",
1257
+ value: PLUS_LITERAL$1
1258
+ });
1259
+ continue;
1260
+ }
1261
+ /**
1262
+ * Plain text
1263
+ */
1264
+ if (value === "@") {
1265
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1266
+ push({
1267
+ type: "at",
1268
+ extglob: true,
1269
+ value,
1270
+ output: ""
1271
+ });
1272
+ continue;
1273
+ }
1274
+ push({
1275
+ type: "text",
1276
+ value
1277
+ });
1278
+ continue;
1279
+ }
1280
+ /**
1281
+ * Plain text
1282
+ */
1283
+ if (value !== "*") {
1284
+ if (value === "$" || value === "^") {
1285
+ value = `\\${value}`;
1286
+ }
1287
+ const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
1288
+ if (match) {
1289
+ value += match[0];
1290
+ state.index += match[0].length;
1291
+ }
1292
+ push({
1293
+ type: "text",
1294
+ value
1295
+ });
1296
+ continue;
1297
+ }
1298
+ /**
1299
+ * Stars
1300
+ */
1301
+ if (prev && (prev.type === "globstar" || prev.star === true)) {
1302
+ prev.type = "star";
1303
+ prev.star = true;
1304
+ prev.value += value;
1305
+ prev.output = star;
1306
+ state.backtrack = true;
1307
+ state.globstar = true;
1308
+ consume(value);
1309
+ continue;
1310
+ }
1311
+ let rest = remaining();
1312
+ if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
1313
+ extglobOpen("star", value);
1314
+ continue;
1315
+ }
1316
+ if (prev.type === "star") {
1317
+ if (opts.noglobstar === true) {
1318
+ consume(value);
1319
+ continue;
1320
+ }
1321
+ const prior = prev.prev;
1322
+ const before = prior.prev;
1323
+ const isStart = prior.type === "slash" || prior.type === "bos";
1324
+ const afterStar = before && (before.type === "star" || before.type === "globstar");
1325
+ if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
1326
+ push({
1327
+ type: "star",
1328
+ value,
1329
+ output: ""
1330
+ });
1331
+ continue;
1332
+ }
1333
+ const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
1334
+ const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
1335
+ if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
1336
+ push({
1337
+ type: "star",
1338
+ value,
1339
+ output: ""
1340
+ });
1341
+ continue;
1342
+ }
1343
+ while (rest.slice(0, 3) === "/**") {
1344
+ const after = input[state.index + 4];
1345
+ if (after && after !== "/") {
1346
+ break;
1347
+ }
1348
+ rest = rest.slice(3);
1349
+ consume("/**", 3);
1350
+ }
1351
+ if (prior.type === "bos" && eos()) {
1352
+ prev.type = "globstar";
1353
+ prev.value += value;
1354
+ prev.output = globstar(opts);
1355
+ state.output = prev.output;
1356
+ state.globstar = true;
1357
+ consume(value);
1358
+ continue;
1359
+ }
1360
+ if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
1361
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1362
+ prior.output = `(?:${prior.output}`;
1363
+ prev.type = "globstar";
1364
+ prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
1365
+ prev.value += value;
1366
+ state.globstar = true;
1367
+ state.output += prior.output + prev.output;
1368
+ consume(value);
1369
+ continue;
1370
+ }
1371
+ if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
1372
+ const end = rest[1] !== void 0 ? "|$" : "";
1373
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1374
+ prior.output = `(?:${prior.output}`;
1375
+ prev.type = "globstar";
1376
+ prev.output = `${globstar(opts)}${SLASH_LITERAL$1}|${SLASH_LITERAL$1}${end})`;
1377
+ prev.value += value;
1378
+ state.output += prior.output + prev.output;
1379
+ state.globstar = true;
1380
+ consume(value + advance());
1381
+ push({
1382
+ type: "slash",
1383
+ value: "/",
1384
+ output: ""
1385
+ });
1386
+ continue;
1387
+ }
1388
+ if (prior.type === "bos" && rest[0] === "/") {
1389
+ prev.type = "globstar";
1390
+ prev.value += value;
1391
+ prev.output = `(?:^|${SLASH_LITERAL$1}|${globstar(opts)}${SLASH_LITERAL$1})`;
1392
+ state.output = prev.output;
1393
+ state.globstar = true;
1394
+ consume(value + advance());
1395
+ push({
1396
+ type: "slash",
1397
+ value: "/",
1398
+ output: ""
1399
+ });
1400
+ continue;
1401
+ }
1402
+ state.output = state.output.slice(0, -prev.output.length);
1403
+ prev.type = "globstar";
1404
+ prev.output = globstar(opts);
1405
+ prev.value += value;
1406
+ state.output += prev.output;
1407
+ state.globstar = true;
1408
+ consume(value);
1409
+ continue;
1410
+ }
1411
+ const token = {
1412
+ type: "star",
1413
+ value,
1414
+ output: star
1415
+ };
1416
+ if (opts.bash === true) {
1417
+ token.output = ".*?";
1418
+ if (prev.type === "bos" || prev.type === "slash") {
1419
+ token.output = nodot + token.output;
1420
+ }
1421
+ push(token);
1422
+ continue;
1423
+ }
1424
+ if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
1425
+ token.output = value;
1426
+ push(token);
1427
+ continue;
1428
+ }
1429
+ if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
1430
+ if (prev.type === "dot") {
1431
+ state.output += NO_DOT_SLASH$1;
1432
+ prev.output += NO_DOT_SLASH$1;
1433
+ } else if (opts.dot === true) {
1434
+ state.output += NO_DOTS_SLASH$1;
1435
+ prev.output += NO_DOTS_SLASH$1;
1436
+ } else {
1437
+ state.output += nodot;
1438
+ prev.output += nodot;
1439
+ }
1440
+ if (peek() !== "*") {
1441
+ state.output += ONE_CHAR$1;
1442
+ prev.output += ONE_CHAR$1;
1443
+ }
1444
+ }
1445
+ push(token);
1446
+ }
1447
+ while (state.brackets > 0) {
1448
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
1449
+ state.output = utils$2.escapeLast(state.output, "[");
1450
+ decrement("brackets");
1451
+ }
1452
+ while (state.parens > 0) {
1453
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
1454
+ state.output = utils$2.escapeLast(state.output, "(");
1455
+ decrement("parens");
1456
+ }
1457
+ while (state.braces > 0) {
1458
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
1459
+ state.output = utils$2.escapeLast(state.output, "{");
1460
+ decrement("braces");
1461
+ }
1462
+ if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
1463
+ push({
1464
+ type: "maybe_slash",
1465
+ value: "",
1466
+ output: `${SLASH_LITERAL$1}?`
1467
+ });
1468
+ }
1469
+ if (state.backtrack === true) {
1470
+ state.output = "";
1471
+ for (const token of state.tokens) {
1472
+ state.output += token.output != null ? token.output : token.value;
1473
+ if (token.suffix) {
1474
+ state.output += token.suffix;
1475
+ }
1476
+ }
1477
+ }
1478
+ return state;
1479
+ };
1480
+ /**
1481
+ * Fast paths for creating regular expressions for common glob patterns.
1482
+ * This can significantly speed up processing and has very little downside
1483
+ * impact when none of the fast paths match.
1484
+ */
1485
+ parse$2.fastpaths = (input, options) => {
1486
+ const opts = { ...options };
1487
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1488
+ const len = input.length;
1489
+ if (len > max) {
1490
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1491
+ }
1492
+ input = REPLACEMENTS[input] || input;
1493
+ const { DOT_LITERAL: DOT_LITERAL$1, SLASH_LITERAL: SLASH_LITERAL$1, ONE_CHAR: ONE_CHAR$1, DOTS_SLASH: DOTS_SLASH$1, NO_DOT: NO_DOT$1, NO_DOTS: NO_DOTS$1, NO_DOTS_SLASH: NO_DOTS_SLASH$1, STAR: STAR$1, START_ANCHOR: START_ANCHOR$1 } = constants$1.globChars(opts.windows);
1494
+ const nodot = opts.dot ? NO_DOTS$1 : NO_DOT$1;
1495
+ const slashDot = opts.dot ? NO_DOTS_SLASH$1 : NO_DOT$1;
1496
+ const capture = opts.capture ? "" : "?:";
1497
+ const state = {
1498
+ negated: false,
1499
+ prefix: ""
1500
+ };
1501
+ let star = opts.bash === true ? ".*?" : STAR$1;
1502
+ if (opts.capture) {
1503
+ star = `(${star})`;
1504
+ }
1505
+ const globstar = (opts$1) => {
1506
+ if (opts$1.noglobstar === true) return star;
1507
+ return `(${capture}(?:(?!${START_ANCHOR$1}${opts$1.dot ? DOTS_SLASH$1 : DOT_LITERAL$1}).)*?)`;
1508
+ };
1509
+ const create = (str) => {
1510
+ switch (str) {
1511
+ case "*": return `${nodot}${ONE_CHAR$1}${star}`;
1512
+ case ".*": return `${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1513
+ case "*.*": return `${nodot}${star}${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1514
+ case "*/*": return `${nodot}${star}${SLASH_LITERAL$1}${ONE_CHAR$1}${slashDot}${star}`;
1515
+ case "**": return nodot + globstar(opts);
1516
+ case "**/*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL$1})?${slashDot}${ONE_CHAR$1}${star}`;
1517
+ case "**/*.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL$1})?${slashDot}${star}${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1518
+ case "**/.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL$1})?${DOT_LITERAL$1}${ONE_CHAR$1}${star}`;
1519
+ default: {
1520
+ const match = /^(.*?)\.(\w+)$/.exec(str);
1521
+ if (!match) return;
1522
+ const source$1 = create(match[1]);
1523
+ if (!source$1) return;
1524
+ return source$1 + DOT_LITERAL$1 + match[2];
1525
+ }
1526
+ }
1527
+ };
1528
+ const output = utils$2.removePrefix(input, state);
1529
+ let source = create(output);
1530
+ if (source && opts.strictSlashes !== true) {
1531
+ source += `${SLASH_LITERAL$1}?`;
1532
+ }
1533
+ return source;
1534
+ };
1535
+ module.exports = parse$2;
1536
+ }));
1537
+
1538
+ //#endregion
1539
+ //#region node_modules/picomatch/lib/picomatch.js
1540
+ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1541
+ const scan = require_scan();
1542
+ const parse$1 = require_parse();
1543
+ const utils$1 = require_utils();
1544
+ const constants = require_constants();
1545
+ const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
1546
+ /**
1547
+ * Creates a matcher function from one or more glob patterns. The
1548
+ * returned function takes a string to match as its first argument,
1549
+ * and returns true if the string is a match. The returned matcher
1550
+ * function also takes a boolean as the second argument that, when true,
1551
+ * returns an object with additional information.
1552
+ *
1553
+ * ```js
1554
+ * const picomatch = require('picomatch');
1555
+ * // picomatch(glob[, options]);
1556
+ *
1557
+ * const isMatch = picomatch('*.!(*a)');
1558
+ * console.log(isMatch('a.a')); //=> false
1559
+ * console.log(isMatch('a.b')); //=> true
1560
+ * ```
1561
+ * @name picomatch
1562
+ * @param {String|Array} `globs` One or more glob patterns.
1563
+ * @param {Object=} `options`
1564
+ * @return {Function=} Returns a matcher function.
1565
+ * @api public
1566
+ */
1567
+ const picomatch$2 = (glob, options, returnState = false) => {
1568
+ if (Array.isArray(glob)) {
1569
+ const fns = glob.map((input) => picomatch$2(input, options, returnState));
1570
+ const arrayMatcher = (str) => {
1571
+ for (const isMatch of fns) {
1572
+ const state$1 = isMatch(str);
1573
+ if (state$1) return state$1;
1574
+ }
1575
+ return false;
1576
+ };
1577
+ return arrayMatcher;
1578
+ }
1579
+ const isState = isObject(glob) && glob.tokens && glob.input;
1580
+ if (glob === "" || typeof glob !== "string" && !isState) {
1581
+ throw new TypeError("Expected pattern to be a non-empty string");
1582
+ }
1583
+ const opts = options || {};
1584
+ const posix = opts.windows;
1585
+ const regex = isState ? picomatch$2.compileRe(glob, options) : picomatch$2.makeRe(glob, options, false, true);
1586
+ const state = regex.state;
1587
+ delete regex.state;
1588
+ let isIgnored = () => false;
1589
+ if (opts.ignore) {
1590
+ const ignoreOpts = {
1591
+ ...options,
1592
+ ignore: null,
1593
+ onMatch: null,
1594
+ onResult: null
1595
+ };
1596
+ isIgnored = picomatch$2(opts.ignore, ignoreOpts, returnState);
1597
+ }
1598
+ const matcher = (input, returnObject = false) => {
1599
+ const { isMatch, match, output } = picomatch$2.test(input, regex, options, {
1600
+ glob,
1601
+ posix
1602
+ });
1603
+ const result = {
1604
+ glob,
1605
+ state,
1606
+ regex,
1607
+ posix,
1608
+ input,
1609
+ output,
1610
+ match,
1611
+ isMatch
1612
+ };
1613
+ if (typeof opts.onResult === "function") {
1614
+ opts.onResult(result);
1615
+ }
1616
+ if (isMatch === false) {
1617
+ result.isMatch = false;
1618
+ return returnObject ? result : false;
1619
+ }
1620
+ if (isIgnored(input)) {
1621
+ if (typeof opts.onIgnore === "function") {
1622
+ opts.onIgnore(result);
1623
+ }
1624
+ result.isMatch = false;
1625
+ return returnObject ? result : false;
1626
+ }
1627
+ if (typeof opts.onMatch === "function") {
1628
+ opts.onMatch(result);
1629
+ }
1630
+ return returnObject ? result : true;
1631
+ };
1632
+ if (returnState) {
1633
+ matcher.state = state;
1634
+ }
1635
+ return matcher;
1636
+ };
1637
+ /**
1638
+ * Test `input` with the given `regex`. This is used by the main
1639
+ * `picomatch()` function to test the input string.
1640
+ *
1641
+ * ```js
1642
+ * const picomatch = require('picomatch');
1643
+ * // picomatch.test(input, regex[, options]);
1644
+ *
1645
+ * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
1646
+ * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
1647
+ * ```
1648
+ * @param {String} `input` String to test.
1649
+ * @param {RegExp} `regex`
1650
+ * @return {Object} Returns an object with matching info.
1651
+ * @api public
1652
+ */
1653
+ picomatch$2.test = (input, regex, options, { glob, posix } = {}) => {
1654
+ if (typeof input !== "string") {
1655
+ throw new TypeError("Expected input to be a string");
1656
+ }
1657
+ if (input === "") {
1658
+ return {
1659
+ isMatch: false,
1660
+ output: ""
1661
+ };
1662
+ }
1663
+ const opts = options || {};
1664
+ const format = opts.format || (posix ? utils$1.toPosixSlashes : null);
1665
+ let match = input === glob;
1666
+ let output = match && format ? format(input) : input;
1667
+ if (match === false) {
1668
+ output = format ? format(input) : input;
1669
+ match = output === glob;
1670
+ }
1671
+ if (match === false || opts.capture === true) {
1672
+ if (opts.matchBase === true || opts.basename === true) {
1673
+ match = picomatch$2.matchBase(input, regex, options, posix);
1674
+ } else {
1675
+ match = regex.exec(output);
1676
+ }
1677
+ }
1678
+ return {
1679
+ isMatch: Boolean(match),
1680
+ match,
1681
+ output
1682
+ };
1683
+ };
1684
+ /**
1685
+ * Match the basename of a filepath.
1686
+ *
1687
+ * ```js
1688
+ * const picomatch = require('picomatch');
1689
+ * // picomatch.matchBase(input, glob[, options]);
1690
+ * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
1691
+ * ```
1692
+ * @param {String} `input` String to test.
1693
+ * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
1694
+ * @return {Boolean}
1695
+ * @api public
1696
+ */
1697
+ picomatch$2.matchBase = (input, glob, options) => {
1698
+ const regex = glob instanceof RegExp ? glob : picomatch$2.makeRe(glob, options);
1699
+ return regex.test(utils$1.basename(input));
1700
+ };
1701
+ /**
1702
+ * Returns true if **any** of the given glob `patterns` match the specified `string`.
1703
+ *
1704
+ * ```js
1705
+ * const picomatch = require('picomatch');
1706
+ * // picomatch.isMatch(string, patterns[, options]);
1707
+ *
1708
+ * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
1709
+ * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
1710
+ * ```
1711
+ * @param {String|Array} str The string to test.
1712
+ * @param {String|Array} patterns One or more glob patterns to use for matching.
1713
+ * @param {Object} [options] See available [options](#options).
1714
+ * @return {Boolean} Returns true if any patterns match `str`
1715
+ * @api public
1716
+ */
1717
+ picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)(str);
1718
+ /**
1719
+ * Parse a glob pattern to create the source string for a regular
1720
+ * expression.
1721
+ *
1722
+ * ```js
1723
+ * const picomatch = require('picomatch');
1724
+ * const result = picomatch.parse(pattern[, options]);
1725
+ * ```
1726
+ * @param {String} `pattern`
1727
+ * @param {Object} `options`
1728
+ * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
1729
+ * @api public
1730
+ */
1731
+ picomatch$2.parse = (pattern, options) => {
1732
+ if (Array.isArray(pattern)) return pattern.map((p) => picomatch$2.parse(p, options));
1733
+ return parse$1(pattern, {
1734
+ ...options,
1735
+ fastpaths: false
1736
+ });
1737
+ };
1738
+ /**
1739
+ * Scan a glob pattern to separate the pattern into segments.
1740
+ *
1741
+ * ```js
1742
+ * const picomatch = require('picomatch');
1743
+ * // picomatch.scan(input[, options]);
1744
+ *
1745
+ * const result = picomatch.scan('!./foo/*.js');
1746
+ * console.log(result);
1747
+ * { prefix: '!./',
1748
+ * input: '!./foo/*.js',
1749
+ * start: 3,
1750
+ * base: 'foo',
1751
+ * glob: '*.js',
1752
+ * isBrace: false,
1753
+ * isBracket: false,
1754
+ * isGlob: true,
1755
+ * isExtglob: false,
1756
+ * isGlobstar: false,
1757
+ * negated: true }
1758
+ * ```
1759
+ * @param {String} `input` Glob pattern to scan.
1760
+ * @param {Object} `options`
1761
+ * @return {Object} Returns an object with
1762
+ * @api public
1763
+ */
1764
+ picomatch$2.scan = (input, options) => scan(input, options);
1765
+ /**
1766
+ * Compile a regular expression from the `state` object returned by the
1767
+ * [parse()](#parse) method.
1768
+ *
1769
+ * @param {Object} `state`
1770
+ * @param {Object} `options`
1771
+ * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
1772
+ * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
1773
+ * @return {RegExp}
1774
+ * @api public
1775
+ */
1776
+ picomatch$2.compileRe = (state, options, returnOutput = false, returnState = false) => {
1777
+ if (returnOutput === true) {
1778
+ return state.output;
1779
+ }
1780
+ const opts = options || {};
1781
+ const prepend = opts.contains ? "" : "^";
1782
+ const append = opts.contains ? "" : "$";
1783
+ let source = `${prepend}(?:${state.output})${append}`;
1784
+ if (state && state.negated === true) {
1785
+ source = `^(?!${source}).*$`;
1786
+ }
1787
+ const regex = picomatch$2.toRegex(source, options);
1788
+ if (returnState === true) {
1789
+ regex.state = state;
1790
+ }
1791
+ return regex;
1792
+ };
1793
+ /**
1794
+ * Create a regular expression from a parsed glob pattern.
1795
+ *
1796
+ * ```js
1797
+ * const picomatch = require('picomatch');
1798
+ * const state = picomatch.parse('*.js');
1799
+ * // picomatch.compileRe(state[, options]);
1800
+ *
1801
+ * console.log(picomatch.compileRe(state));
1802
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
1803
+ * ```
1804
+ * @param {String} `state` The object returned from the `.parse` method.
1805
+ * @param {Object} `options`
1806
+ * @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.
1807
+ * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
1808
+ * @return {RegExp} Returns a regex created from the given pattern.
1809
+ * @api public
1810
+ */
1811
+ picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
1812
+ if (!input || typeof input !== "string") {
1813
+ throw new TypeError("Expected a non-empty string");
1814
+ }
1815
+ let parsed = {
1816
+ negated: false,
1817
+ fastpaths: true
1818
+ };
1819
+ if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
1820
+ parsed.output = parse$1.fastpaths(input, options);
1821
+ }
1822
+ if (!parsed.output) {
1823
+ parsed = parse$1(input, options);
1824
+ }
1825
+ return picomatch$2.compileRe(parsed, options, returnOutput, returnState);
1826
+ };
1827
+ /**
1828
+ * Create a regular expression from the given regex source string.
1829
+ *
1830
+ * ```js
1831
+ * const picomatch = require('picomatch');
1832
+ * // picomatch.toRegex(source[, options]);
1833
+ *
1834
+ * const { output } = picomatch.parse('*.js');
1835
+ * console.log(picomatch.toRegex(output));
1836
+ * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
1837
+ * ```
1838
+ * @param {String} `source` Regular expression source string.
1839
+ * @param {Object} `options`
1840
+ * @return {RegExp}
1841
+ * @api public
1842
+ */
1843
+ picomatch$2.toRegex = (source, options) => {
1844
+ try {
1845
+ const opts = options || {};
1846
+ return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
1847
+ } catch (err) {
1848
+ if (options && options.debug === true) throw err;
1849
+ return /$^/;
1850
+ }
1851
+ };
1852
+ /**
1853
+ * Picomatch constants.
1854
+ * @return {Object}
1855
+ */
1856
+ picomatch$2.constants = constants;
1857
+ /**
1858
+ * Expose "picomatch"
1859
+ */
1860
+ module.exports = picomatch$2;
1861
+ }));
1862
+
1863
+ //#endregion
1864
+ //#region node_modules/picomatch/index.js
1865
+ var require_picomatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1866
+ const pico = require_picomatch$1();
1867
+ const utils = require_utils();
1868
+ function picomatch$1(glob, options, returnState = false) {
1869
+ if (options && (options.windows === null || options.windows === undefined)) {
1870
+ options = {
1871
+ ...options,
1872
+ windows: utils.isWindows()
1873
+ };
1874
+ }
1875
+ return pico(glob, options, returnState);
1876
+ }
1877
+ Object.assign(picomatch$1, pico);
1878
+ module.exports = picomatch$1;
1879
+ }));
1880
+
1881
+ //#endregion
1882
+ //#region packages/codegen/src/type-filter.ts
1883
+ var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
1884
+ const compileRule = (rule) => {
1885
+ const matcher = (0, import_picomatch.default)(rule.pattern);
1886
+ const categories = rule.category ? Array.isArray(rule.category) ? rule.category : [rule.category] : null;
1887
+ return (context) => {
1888
+ if (categories && !categories.includes(context.category)) {
1889
+ return true;
1890
+ }
1891
+ return !matcher(context.name);
1892
+ };
1893
+ };
1894
+ const compileTypeFilter = (config) => {
1895
+ if (!config) {
1896
+ return () => true;
1897
+ }
1898
+ if (typeof config === "function") {
1899
+ return config;
1900
+ }
1901
+ const rules = config.exclude.map(compileRule);
1902
+ return (context) => rules.every((rule) => rule(context));
1903
+ };
1904
+ const buildExclusionSet = (filter, typeNames) => {
1905
+ const excluded = new Set();
1906
+ for (const [category, names] of typeNames) {
1907
+ for (const name of names) {
1908
+ if (!filter({
1909
+ name,
1910
+ category
1911
+ })) {
1912
+ excluded.add(name);
1913
+ }
1914
+ }
1915
+ }
1916
+ return excluded;
1917
+ };
1918
+
1919
+ //#endregion
1920
+ //#region packages/codegen/src/generator.ts
1921
+ const builtinScalarTypes = new Map([
1922
+ ["ID", {
1923
+ input: "string",
1924
+ output: "string"
1925
+ }],
1926
+ ["String", {
1927
+ input: "string",
1928
+ output: "string"
1929
+ }],
1930
+ ["Int", {
1931
+ input: "number",
1932
+ output: "number"
1933
+ }],
1934
+ ["Float", {
1935
+ input: "number",
1936
+ output: "number"
1937
+ }],
1938
+ ["Boolean", {
1939
+ input: "boolean",
1940
+ output: "boolean"
1941
+ }]
1942
+ ]);
1943
+ const ensureRecord = (collection, key, factory) => {
1944
+ const existing = collection.get(key);
1945
+ if (existing) {
1946
+ return existing;
1947
+ }
1948
+ const created = factory(key);
1949
+ collection.set(key, created);
1950
+ return created;
1951
+ };
1952
+ const addObjectFields = (target, fields) => {
1953
+ if (!fields) {
1954
+ return;
1955
+ }
1956
+ for (const field of fields) {
1957
+ target.set(field.name.value, field);
1958
+ }
1959
+ };
1960
+ const addInputFields = (target, fields) => {
1961
+ if (!fields) {
1962
+ return;
1963
+ }
1964
+ for (const field of fields) {
1965
+ target.set(field.name.value, field);
1966
+ }
1967
+ };
1968
+ const addEnumValues = (target, values) => {
1969
+ if (!values) {
1970
+ return;
1971
+ }
1972
+ for (const value of values) {
1973
+ target.set(value.name.value, value);
1974
+ }
1975
+ };
1976
+ const addUnionMembers = (target, members) => {
1977
+ if (!members) {
1978
+ return;
1979
+ }
1980
+ for (const member of members) {
1981
+ target.set(member.name.value, member);
1982
+ }
1983
+ };
1984
+ const mergeDirectives = (existing, incoming, precedence) => {
1985
+ const current = existing ?? [];
1986
+ const next = incoming ? Array.from(incoming) : [];
1987
+ return precedence === "definition" ? [...next, ...current] : [...current, ...next];
1988
+ };
1989
+ const updateOperationTypes = (operationTypes, definition) => {
1990
+ for (const operation of definition.operationTypes ?? []) {
1991
+ const typeName = operation.type.name.value;
1992
+ switch (operation.operation) {
1993
+ case "query":
1994
+ operationTypes.query = typeName;
1995
+ break;
1996
+ case "mutation":
1997
+ operationTypes.mutation = typeName;
1998
+ break;
1999
+ case "subscription":
2000
+ operationTypes.subscription = typeName;
2001
+ break;
2002
+ default: break;
2003
+ }
2004
+ }
2005
+ };
2006
+ const addDirectiveArgs = (target, args) => {
2007
+ if (!args) {
2008
+ return;
2009
+ }
2010
+ for (const arg of args) {
2011
+ target.set(arg.name.value, arg);
2012
+ }
2013
+ };
2014
+ const createSchemaIndex = (document) => {
2015
+ const objects = new Map();
2016
+ const inputs = new Map();
2017
+ const enums = new Map();
2018
+ const unions = new Map();
2019
+ const scalars = new Map();
2020
+ const directives = new Map();
2021
+ const operationTypes = {};
2022
+ for (const definition of document.definitions) {
2023
+ switch (definition.kind) {
2024
+ case Kind.OBJECT_TYPE_DEFINITION:
2025
+ case Kind.OBJECT_TYPE_EXTENSION: {
2026
+ const precedence = definition.kind === Kind.OBJECT_TYPE_DEFINITION ? "definition" : "extension";
2027
+ const record = ensureRecord(objects, definition.name.value, (name) => ({
2028
+ name,
2029
+ fields: new Map(),
2030
+ directives: []
2031
+ }));
2032
+ addObjectFields(record.fields, definition.fields);
2033
+ record.directives = mergeDirectives(record.directives, definition.directives, precedence);
2034
+ break;
2035
+ }
2036
+ case Kind.INPUT_OBJECT_TYPE_DEFINITION:
2037
+ case Kind.INPUT_OBJECT_TYPE_EXTENSION: {
2038
+ const precedence = definition.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ? "definition" : "extension";
2039
+ const record = ensureRecord(inputs, definition.name.value, (name) => ({
2040
+ name,
2041
+ fields: new Map(),
2042
+ directives: []
2043
+ }));
2044
+ addInputFields(record.fields, definition.fields);
2045
+ record.directives = mergeDirectives(record.directives, definition.directives, precedence);
2046
+ break;
2047
+ }
2048
+ case Kind.ENUM_TYPE_DEFINITION:
2049
+ case Kind.ENUM_TYPE_EXTENSION: {
2050
+ const precedence = definition.kind === Kind.ENUM_TYPE_DEFINITION ? "definition" : "extension";
2051
+ const record = ensureRecord(enums, definition.name.value, (name) => ({
2052
+ name,
2053
+ values: new Map(),
2054
+ directives: []
2055
+ }));
2056
+ addEnumValues(record.values, definition.values);
2057
+ record.directives = mergeDirectives(record.directives, definition.directives, precedence);
2058
+ break;
2059
+ }
2060
+ case Kind.UNION_TYPE_DEFINITION:
2061
+ case Kind.UNION_TYPE_EXTENSION: {
2062
+ const precedence = definition.kind === Kind.UNION_TYPE_DEFINITION ? "definition" : "extension";
2063
+ const record = ensureRecord(unions, definition.name.value, (name) => ({
2064
+ name,
2065
+ members: new Map(),
2066
+ directives: []
2067
+ }));
2068
+ addUnionMembers(record.members, definition.types);
2069
+ record.directives = mergeDirectives(record.directives, definition.directives, precedence);
2070
+ break;
2071
+ }
2072
+ case Kind.SCALAR_TYPE_DEFINITION:
2073
+ case Kind.SCALAR_TYPE_EXTENSION: {
2074
+ const precedence = definition.kind === Kind.SCALAR_TYPE_DEFINITION ? "definition" : "extension";
2075
+ const record = ensureRecord(scalars, definition.name.value, (name) => ({
2076
+ name,
2077
+ directives: []
2078
+ }));
2079
+ record.directives = mergeDirectives(record.directives, definition.directives, precedence);
2080
+ break;
2081
+ }
2082
+ case Kind.DIRECTIVE_DEFINITION: {
2083
+ const name = definition.name.value;
2084
+ if (name === "skip" || name === "include" || name === "deprecated" || name === "specifiedBy") {
2085
+ break;
2086
+ }
2087
+ const args = new Map();
2088
+ addDirectiveArgs(args, definition.arguments);
2089
+ directives.set(name, {
2090
+ name,
2091
+ locations: definition.locations.map((loc) => loc.value),
2092
+ args,
2093
+ isRepeatable: definition.repeatable
2094
+ });
2095
+ break;
2096
+ }
2097
+ case Kind.SCHEMA_DEFINITION:
2098
+ case Kind.SCHEMA_EXTENSION:
2099
+ updateOperationTypes(operationTypes, definition);
2100
+ break;
2101
+ default: break;
2102
+ }
2103
+ }
2104
+ if (!operationTypes.query && objects.has("Query")) {
2105
+ operationTypes.query = "Query";
2106
+ }
2107
+ if (!operationTypes.mutation && objects.has("Mutation")) {
2108
+ operationTypes.mutation = "Mutation";
2109
+ }
2110
+ if (!operationTypes.subscription && objects.has("Subscription")) {
2111
+ operationTypes.subscription = "Subscription";
2112
+ }
2113
+ return {
2114
+ objects,
2115
+ inputs,
2116
+ enums,
2117
+ unions,
2118
+ scalars,
2119
+ directives,
2120
+ operationTypes
2121
+ };
2122
+ };
2123
+ const collectTypeLevels = (type, nonNull = false, levels = []) => {
2124
+ if (type.kind === Kind.NON_NULL_TYPE) {
2125
+ return collectTypeLevels(type.type, true, levels);
2126
+ }
2127
+ if (type.kind === Kind.LIST_TYPE) {
2128
+ levels.push({
2129
+ kind: "list",
2130
+ nonNull
2131
+ });
2132
+ return collectTypeLevels(type.type, false, levels);
2133
+ }
2134
+ levels.push({
2135
+ kind: "named",
2136
+ nonNull
2137
+ });
2138
+ return {
2139
+ name: type.name.value,
2140
+ levels
2141
+ };
2142
+ };
2143
+ const buildTypeModifier = (levels) => {
2144
+ let modifier = "?";
2145
+ for (const level of levels.slice().reverse()) {
2146
+ if (level.kind === "named") {
2147
+ modifier = level.nonNull ? "!" : "?";
2148
+ continue;
2149
+ }
2150
+ const listSuffix = level.nonNull ? "[]!" : "[]?";
2151
+ modifier = `${modifier}${listSuffix}`;
2152
+ }
2153
+ return modifier;
2154
+ };
2155
+ const parseTypeReference = (type) => {
2156
+ const { name, levels } = collectTypeLevels(type);
2157
+ return {
2158
+ name,
2159
+ modifier: buildTypeModifier(levels)
2160
+ };
2161
+ };
2162
+ const isScalarName = (schema, name) => builtinScalarTypes.has(name) || schema.scalars.has(name);
2163
+ const isEnumName = (schema, name) => schema.enums.has(name);
2164
+ const _isInputName = (schema, name) => schema.inputs.has(name);
2165
+ const isUnionName = (schema, name) => schema.unions.has(name);
2166
+ const isObjectName = (schema, name) => schema.objects.has(name);
2167
+ const renderConstValue = (value) => {
2168
+ switch (value.kind) {
2169
+ case Kind.NULL: return "null";
2170
+ case Kind.INT:
2171
+ case Kind.FLOAT: return value.value;
2172
+ case Kind.STRING:
2173
+ case Kind.ENUM: return JSON.stringify(value.value);
2174
+ case Kind.BOOLEAN: return value.value ? "true" : "false";
2175
+ case Kind.LIST: return `[${value.values.map((item) => renderConstValue(item)).join(", ")}]`;
2176
+ case Kind.OBJECT: {
2177
+ if (value.fields.length === 0) {
2178
+ return "{}";
2179
+ }
2180
+ const entries = value.fields.map((field) => `${field.name.value}: ${renderConstValue(field.value)}`);
2181
+ return `{ ${entries.join(", ")} }`;
2182
+ }
2183
+ }
2184
+ };
2185
+ const renderInputRef = (schema, definition, excluded) => {
2186
+ const { name, modifier } = parseTypeReference(definition.type);
2187
+ const defaultValue = definition.defaultValue;
2188
+ if (excluded.has(name)) {
2189
+ if (defaultValue) {
2190
+ return `{ kind: "excluded", name: "${name}", modifier: "${modifier}", defaultValue: { default: ${renderConstValue(defaultValue)} } }`;
2191
+ }
2192
+ return `{ kind: "excluded", name: "${name}", modifier: "${modifier}" }`;
2193
+ }
2194
+ let kind;
2195
+ if (isScalarName(schema, name)) {
2196
+ kind = "scalar";
2197
+ } else if (isEnumName(schema, name)) {
2198
+ kind = "enum";
2199
+ } else {
2200
+ kind = "input";
2201
+ }
2202
+ if (defaultValue) {
2203
+ return `{ kind: "${kind}", name: "${name}", modifier: "${modifier}", defaultValue: { default: ${renderConstValue(defaultValue)} } }`;
2204
+ }
2205
+ return `{ kind: "${kind}", name: "${name}", modifier: "${modifier}" }`;
2206
+ };
2207
+ const renderArgumentMap = (schema, args, excluded) => {
2208
+ const entries = [...args ?? []].sort((left, right) => left.name.value.localeCompare(right.name.value)).map((arg) => `${arg.name.value}: ${renderInputRef(schema, arg, excluded)}`);
2209
+ return renderPropertyLines({
2210
+ entries,
2211
+ indentSize: 8
2212
+ });
2213
+ };
2214
+ const renderOutputRef = (schema, type, args, excluded) => {
2215
+ const { name, modifier } = parseTypeReference(type);
2216
+ const argumentMap = renderArgumentMap(schema, args, excluded);
2217
+ if (excluded.has(name)) {
2218
+ return `{ kind: "excluded", name: "${name}", modifier: "${modifier}", arguments: ${argumentMap} }`;
2219
+ }
2220
+ let kind;
2221
+ if (isScalarName(schema, name)) {
2222
+ kind = "scalar";
2223
+ } else if (isEnumName(schema, name)) {
2224
+ kind = "enum";
2225
+ } else if (isUnionName(schema, name)) {
2226
+ kind = "union";
2227
+ } else if (isObjectName(schema, name)) {
2228
+ kind = "object";
2229
+ } else {
2230
+ kind = "scalar";
2231
+ }
2232
+ return `{ kind: "${kind}", name: "${name}", modifier: "${modifier}", arguments: ${argumentMap} }`;
2233
+ };
2234
+ const renderPropertyLines = ({ entries, indentSize }) => {
2235
+ if (entries.length === 0) {
2236
+ return "{}";
2237
+ }
2238
+ const indent = " ".repeat(indentSize);
2239
+ const lastIndent = " ".repeat(indentSize - 2);
2240
+ return [
2241
+ "{",
2242
+ `${indent}${entries.join(`,\n${indent}`)},`,
2243
+ `${lastIndent}}`
2244
+ ].join(`\n`);
2245
+ };
2246
+ const renderObjectFields = (schema, fields, excluded) => {
2247
+ const entries = Array.from(fields.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((field) => `${field.name.value}: ${renderOutputRef(schema, field.type, field.arguments, excluded)}`);
2248
+ return renderPropertyLines({
2249
+ entries,
2250
+ indentSize: 6
2251
+ });
2252
+ };
2253
+ const renderInputFields = (schema, fields, excluded) => {
2254
+ const entries = Array.from(fields.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((field) => `${field.name.value}: ${renderInputRef(schema, field, excluded)}`);
2255
+ return renderPropertyLines({
2256
+ entries,
2257
+ indentSize: 6
2258
+ });
2259
+ };
2260
+ const renderScalarVar = (schemaName, record) => {
2261
+ const typeInfo = builtinScalarTypes.get(record.name) ?? {
2262
+ input: "string",
2263
+ output: "string"
2264
+ };
2265
+ return `const scalar_${schemaName}_${record.name} = { name: "${record.name}", $type: {} as { input: ${typeInfo.input}; output: ${typeInfo.output}; inputProfile: { kind: "scalar"; name: "${record.name}"; value: ${typeInfo.input} }; outputProfile: { kind: "scalar"; name: "${record.name}"; value: ${typeInfo.output} } } } as const;`;
2266
+ };
2267
+ const renderEnumVar = (schemaName, record) => {
2268
+ const valueNames = Array.from(record.values.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((value) => value.name.value);
2269
+ const valuesObj = valueNames.length === 0 ? "{}" : `{ ${valueNames.map((v) => `${v}: true`).join(", ")} }`;
2270
+ const valueUnion = valueNames.length === 0 ? "never" : valueNames.map((v) => `"${v}"`).join(" | ");
2271
+ return `const enum_${schemaName}_${record.name} = defineEnum<"${record.name}", ${valueUnion}>("${record.name}", ${valuesObj});`;
2272
+ };
2273
+ const renderInputVar = (schemaName, schema, record, excluded) => {
2274
+ const fields = renderInputFields(schema, record.fields, excluded);
2275
+ return `const input_${schemaName}_${record.name} = { name: "${record.name}", fields: ${fields} } as const;`;
2276
+ };
2277
+ const renderObjectVar = (schemaName, schema, record, excluded) => {
2278
+ const fields = renderObjectFields(schema, record.fields, excluded);
2279
+ return `const object_${schemaName}_${record.name} = { name: "${record.name}", fields: ${fields} } as const;`;
2280
+ };
2281
+ const renderUnionVar = (schemaName, record, excluded) => {
2282
+ const memberNames = Array.from(record.members.values()).filter((member) => !excluded.has(member.name.value)).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((member) => member.name.value);
2283
+ const typesObj = memberNames.length === 0 ? "{}" : `{ ${memberNames.map((m) => `${m}: true`).join(", ")} }`;
2284
+ return `const union_${schemaName}_${record.name} = { name: "${record.name}", types: ${typesObj} } as const;`;
2285
+ };
2286
+ const collectObjectTypeNames = (schema) => Array.from(schema.objects.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
2287
+ const renderFragmentBuildersType = (objectTypeNames, schemaName, adapterTypeName) => {
2288
+ if (objectTypeNames.length === 0) {
2289
+ return `type FragmentBuilders_${schemaName} = Record<string, never>;`;
2290
+ }
2291
+ const adapterPart = adapterTypeName ? `, ExtractMetadataAdapter<${adapterTypeName}>` : "";
2292
+ const entries = objectTypeNames.map((name) => ` readonly ${name}: FragmentBuilderFor<Schema_${schemaName}, "${name}"${adapterPart}>`);
2293
+ return `type FragmentBuilders_${schemaName} = {\n${entries.join(";\n")};\n};`;
2294
+ };
2295
+ const collectInputTypeNames = (schema) => Array.from(schema.inputs.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
2296
+ const collectEnumTypeNames = (schema) => Array.from(schema.enums.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
2297
+ const collectUnionTypeNames = (schema) => Array.from(schema.unions.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
2298
+ const collectScalarNames = (schema) => Array.from(schema.scalars.keys()).filter((name) => !name.startsWith("__")).sort((left, right) => left.localeCompare(right));
2299
+ const collectDirectiveNames = (schema) => Array.from(schema.directives.keys()).sort((left, right) => left.localeCompare(right));
2300
+ const renderInputTypeMethod = (factoryVar, kind, typeName) => `${typeName}: ${factoryVar}("${kind}", "${typeName}")`;
2301
+ const renderInputTypeMethods = (schema, factoryVar, excluded) => {
2302
+ const scalarMethods = Array.from(builtinScalarTypes.keys()).concat(collectScalarNames(schema).filter((name) => !builtinScalarTypes.has(name))).filter((name) => !excluded.has(name)).map((name) => renderInputTypeMethod(factoryVar, "scalar", name));
2303
+ const enumMethods = collectEnumTypeNames(schema).filter((name) => !excluded.has(name)).map((name) => renderInputTypeMethod(factoryVar, "enum", name));
2304
+ const inputMethods = collectInputTypeNames(schema).filter((name) => !excluded.has(name)).map((name) => renderInputTypeMethod(factoryVar, "input", name));
2305
+ const allMethods = [
2306
+ ...scalarMethods,
2307
+ ...enumMethods,
2308
+ ...inputMethods
2309
+ ].sort((left, right) => {
2310
+ const leftName = left.split(":")[0] ?? "";
2311
+ const rightName = right.split(":")[0] ?? "";
2312
+ return leftName.localeCompare(rightName);
2313
+ });
2314
+ return renderPropertyLines({
2315
+ entries: allMethods,
2316
+ indentSize: 2
2317
+ });
2318
+ };
2319
+ /**
2320
+ * Renders argument specifiers for a directive.
2321
+ * Returns null if the directive has no arguments.
2322
+ */
2323
+ const renderDirectiveArgsSpec = (schema, args, excluded) => {
2324
+ if (args.size === 0) return null;
2325
+ const entries = Array.from(args.values()).sort((left, right) => left.name.value.localeCompare(right.name.value)).map((arg) => `${arg.name.value}: ${renderInputRef(schema, arg, excluded)}`);
2326
+ return renderPropertyLines({
2327
+ entries,
2328
+ indentSize: 4
2329
+ });
2330
+ };
2331
+ const renderDirectiveMethod = (schema, record, excluded) => {
2332
+ const locationsJson = JSON.stringify(record.locations);
2333
+ const argsSpec = renderDirectiveArgsSpec(schema, record.args, excluded);
2334
+ if (argsSpec === null) {
2335
+ return `${record.name}: createDirectiveMethod("${record.name}", ${locationsJson} as const)`;
2336
+ }
2337
+ return `${record.name}: createTypedDirectiveMethod("${record.name}", ${locationsJson} as const, ${argsSpec})`;
2338
+ };
2339
+ const renderDirectiveMethods = (schema, excluded) => {
2340
+ const directiveNames = collectDirectiveNames(schema);
2341
+ if (directiveNames.length === 0) {
2342
+ return "{}";
2343
+ }
2344
+ const methods = directiveNames.map((name) => {
2345
+ const record = schema.directives.get(name);
2346
+ return record ? renderDirectiveMethod(schema, record, excluded) : null;
2347
+ }).filter((method) => method !== null);
2348
+ return renderPropertyLines({
2349
+ entries: methods,
2350
+ indentSize: 2
2351
+ });
2352
+ };
2353
+ /**
2354
+ * Generates the _internal-injects.ts module code.
2355
+ * This file contains only adapter imports (scalar, adapter) to keep it lightweight.
2356
+ * The heavy schema types remain in _internal.ts.
2357
+ */
2358
+ const generateInjectsCode = (injection) => {
2359
+ const imports = [];
2360
+ const exports$1 = [];
2361
+ const typeExports = [];
2362
+ const importsByPath = new Map();
2363
+ for (const [schemaName, config] of injection) {
2364
+ const scalarAlias = `scalar_${schemaName}`;
2365
+ const scalarSpecifiers = importsByPath.get(config.scalarImportPath) ?? [];
2366
+ if (!importsByPath.has(config.scalarImportPath)) {
2367
+ importsByPath.set(config.scalarImportPath, scalarSpecifiers);
2368
+ }
2369
+ scalarSpecifiers.push(`scalar as ${scalarAlias}`);
2370
+ exports$1.push(`export { ${scalarAlias} };`);
2371
+ typeExports.push(`export type Scalar_${schemaName} = typeof ${scalarAlias};`);
2372
+ if (config.adapterImportPath) {
2373
+ const adapterAlias = `adapter_${schemaName}`;
2374
+ const adapterSpecifiers = importsByPath.get(config.adapterImportPath) ?? [];
2375
+ if (!importsByPath.has(config.adapterImportPath)) {
2376
+ importsByPath.set(config.adapterImportPath, adapterSpecifiers);
2377
+ }
2378
+ adapterSpecifiers.push(`adapter as ${adapterAlias}`);
2379
+ exports$1.push(`export { ${adapterAlias} };`);
2380
+ typeExports.push(`export type Adapter_${schemaName} = typeof ${adapterAlias} & { _?: never };`);
2381
+ }
2382
+ }
2383
+ for (const [path, specifiers] of importsByPath) {
2384
+ if (specifiers.length === 1) {
2385
+ imports.push(`import { ${specifiers[0]} } from "${path}";`);
2386
+ } else {
2387
+ imports.push(`import {\n ${specifiers.join(",\n ")},\n} from "${path}";`);
2388
+ }
2389
+ }
2390
+ return `\
2391
+ /**
2392
+ * Adapter injections for schema.
2393
+ * Separated to allow lightweight imports for prebuilt module.
2394
+ * @generated by @soda-gql/codegen
2395
+ */
2396
+
2397
+ ${imports.join("\n")}
2398
+
2399
+ // Value exports
2400
+ ${exports$1.join("\n")}
2401
+
2402
+ // Type exports
2403
+ ${typeExports.join("\n")}
2404
+ `;
2405
+ };
2406
+ const multiRuntimeTemplate = ($$) => {
2407
+ const imports = [];
2408
+ const scalarAliases = new Map();
2409
+ const adapterAliases = new Map();
2410
+ if ($$.injection.mode === "inject") {
2411
+ const injectsImports = [];
2412
+ for (const [schemaName, injection] of $$.injection.perSchema) {
2413
+ const scalarAlias = `scalar_${schemaName}`;
2414
+ scalarAliases.set(schemaName, scalarAlias);
2415
+ injectsImports.push(scalarAlias);
2416
+ if (injection.adapterImportPath) {
2417
+ const adapterAlias = `adapter_${schemaName}`;
2418
+ adapterAliases.set(schemaName, adapterAlias);
2419
+ injectsImports.push(adapterAlias);
2420
+ }
2421
+ }
2422
+ imports.push(`import { ${injectsImports.join(", ")} } from "${$$.injection.injectsModulePath}";`);
2423
+ }
2424
+ {
2425
+ const { importPaths } = $$.splitting;
2426
+ for (const [name, config] of Object.entries($$.schemas)) {
2427
+ if (config.enumNames.length > 0) {
2428
+ const enumImports = config.enumNames.map((n) => `enum_${name}_${n}`).join(", ");
2429
+ imports.push(`import { ${enumImports} } from "${importPaths.enums}";`);
2430
+ }
2431
+ if (config.inputNames.length > 0) {
2432
+ const inputImports = config.inputNames.map((n) => `input_${name}_${n}`).join(", ");
2433
+ imports.push(`import { ${inputImports} } from "${importPaths.inputs}";`);
2434
+ }
2435
+ if (config.objectNames.length > 0) {
2436
+ const objectImports = config.objectNames.map((n) => `object_${name}_${n}`).join(", ");
2437
+ imports.push(`import { ${objectImports} } from "${importPaths.objects}";`);
2438
+ }
2439
+ if (config.unionNames.length > 0) {
2440
+ const unionImports = config.unionNames.map((n) => `union_${name}_${n}`).join(", ");
2441
+ imports.push(`import { ${unionImports} } from "${importPaths.unions}";`);
2442
+ }
2443
+ }
2444
+ }
2445
+ const extraImports = imports.length > 0 ? `${imports.join("\n")}\n` : "";
2446
+ const schemaBlocks = [];
2447
+ const gqlEntries = [];
2448
+ for (const [name, config] of Object.entries($$.schemas)) {
2449
+ const schemaVar = `${name}Schema`;
2450
+ const adapterVar = adapterAliases.get(name);
2451
+ const typeExports = [`export type Schema_${name} = typeof ${schemaVar} & { _?: never };`];
2452
+ if (adapterVar) {
2453
+ typeExports.push(`export type Adapter_${name} = typeof ${adapterVar} & { _?: never };`);
2454
+ }
2455
+ typeExports.push(config.fragmentBuildersTypeBlock);
2456
+ const inputTypeMethodsVar = `inputTypeMethods_${name}`;
2457
+ const factoryVar = `createMethod_${name}`;
2458
+ const customDirectivesVar = `customDirectives_${name}`;
2459
+ const defaultDepthBlock = config.defaultInputDepth !== undefined && config.defaultInputDepth !== 3 ? `\n __defaultInputDepth: ${config.defaultInputDepth},` : "";
2460
+ const depthOverridesBlock = config.inputDepthOverrides && Object.keys(config.inputDepthOverrides).length > 0 ? `\n __inputDepthOverrides: ${JSON.stringify(config.inputDepthOverrides)},` : "";
2461
+ const isSplitMode = true;
2462
+ const scalarVarsBlock = config.scalarVars.join("\n");
2463
+ const enumVarsBlock = isSplitMode ? "// (enums imported)" : config.enumVars.length > 0 ? config.enumVars.join("\n") : "// (no enums)";
2464
+ const inputVarsBlock = isSplitMode ? "// (inputs imported)" : config.inputVars.length > 0 ? config.inputVars.join("\n") : "// (no inputs)";
2465
+ const objectVarsBlock = isSplitMode ? "// (objects imported)" : config.objectVars.length > 0 ? config.objectVars.join("\n") : "// (no objects)";
2466
+ const unionVarsBlock = isSplitMode ? "// (unions imported)" : config.unionVars.length > 0 ? config.unionVars.join("\n") : "// (no unions)";
2467
+ const scalarAssembly = $$.injection.mode === "inject" ? scalarAliases.get(name) ?? "{}" : config.scalarNames.length > 0 ? `{ ${config.scalarNames.map((n) => `${n}: scalar_${name}_${n}`).join(", ")} }` : "{}";
2468
+ const enumAssembly = config.enumNames.length > 0 ? `{ ${config.enumNames.map((n) => `${n}: enum_${name}_${n}`).join(", ")} }` : "{}";
2469
+ const inputAssembly = config.inputNames.length > 0 ? `{ ${config.inputNames.map((n) => `${n}: input_${name}_${n}`).join(", ")} }` : "{}";
2470
+ const objectAssembly = config.objectNames.length > 0 ? `{ ${config.objectNames.map((n) => `${n}: object_${name}_${n}`).join(", ")} }` : "{}";
2471
+ const unionAssembly = config.unionNames.length > 0 ? `{ ${config.unionNames.map((n) => `${n}: union_${name}_${n}`).join(", ")} }` : "{}";
2472
+ const scalarVarsSection = $$.injection.mode === "inject" ? "// (scalars imported)" : scalarVarsBlock;
2473
+ const scalarAssemblyLine = $$.injection.mode === "inject" ? `// scalar_${name} is imported directly` : `const scalar_${name} = ${scalarAssembly} as const;`;
2474
+ const scalarRef = $$.injection.mode === "inject" ? scalarAliases.get(name) ?? `scalar_${name}` : `scalar_${name}`;
2475
+ schemaBlocks.push(`
2476
+ // Individual scalar definitions
2477
+ ${scalarVarsSection}
2478
+
2479
+ // Individual enum definitions
2480
+ ${enumVarsBlock}
2481
+
2482
+ // Individual input definitions
2483
+ ${inputVarsBlock}
2484
+
2485
+ // Individual object definitions
2486
+ ${objectVarsBlock}
2487
+
2488
+ // Individual union definitions
2489
+ ${unionVarsBlock}
2490
+
2491
+ // Category assembly
2492
+ ${scalarAssemblyLine}
2493
+ const enum_${name} = ${enumAssembly} as const;
2494
+ const input_${name} = ${inputAssembly} as const;
2495
+ const object_${name} = ${objectAssembly} as const;
2496
+ const union_${name} = ${unionAssembly} as const;
2497
+
2498
+ // Schema assembly
2499
+ const ${schemaVar} = {
2500
+ label: "${name}" as const,
2501
+ operations: { query: "${config.queryType}", mutation: "${config.mutationType}", subscription: "${config.subscriptionType}" } as const,
2502
+ scalar: ${scalarRef},
2503
+ enum: enum_${name},
2504
+ input: input_${name},
2505
+ object: object_${name},
2506
+ union: union_${name},${defaultDepthBlock}${depthOverridesBlock}
2507
+ } as const;
2508
+
2509
+ const ${factoryVar} = createVarMethodFactory<typeof ${schemaVar}>();
2510
+ const ${inputTypeMethodsVar} = ${config.inputTypeMethodsBlock};
2511
+ const ${customDirectivesVar} = { ...createStandardDirectives(), ...${config.directiveMethodsBlock} };
2512
+
2513
+ ${typeExports.join("\n")}`);
2514
+ const gqlVarName = `gql_${name}`;
2515
+ if (adapterVar) {
2516
+ const typeParams = `<Schema_${name}, FragmentBuilders_${name}, typeof ${customDirectivesVar}, Adapter_${name}>`;
2517
+ schemaBlocks.push(`const ${gqlVarName} = createGqlElementComposer${typeParams}(${schemaVar}, { adapter: ${adapterVar}, inputTypeMethods: ${inputTypeMethodsVar}, directiveMethods: ${customDirectivesVar} });`);
2518
+ } else {
2519
+ const typeParams = `<Schema_${name}, FragmentBuilders_${name}, typeof ${customDirectivesVar}>`;
2520
+ schemaBlocks.push(`const ${gqlVarName} = createGqlElementComposer${typeParams}(${schemaVar}, { inputTypeMethods: ${inputTypeMethodsVar}, directiveMethods: ${customDirectivesVar} });`);
2521
+ }
2522
+ schemaBlocks.push(`export type Context_${name} = Parameters<typeof ${gqlVarName}>[0] extends (ctx: infer C) => unknown ? C : never;`);
2523
+ const prebuiltExports = [
2524
+ `export { ${schemaVar} as __schema_${name} }`,
2525
+ `export { ${inputTypeMethodsVar} as __inputTypeMethods_${name} }`,
2526
+ `export { ${customDirectivesVar} as __directiveMethods_${name} }`
2527
+ ];
2528
+ if (adapterVar) {
2529
+ prebuiltExports.push(`export { ${adapterVar} as __adapter_${name} }`);
2530
+ }
2531
+ schemaBlocks.push(`${prebuiltExports.join(";\n")};`);
2532
+ gqlEntries.push(` ${name}: ${gqlVarName}`);
2533
+ }
2534
+ const needsDefineEnum = false;
2535
+ return `\
2536
+ import {${needsDefineEnum ? "\n defineEnum," : ""}
2537
+ type ExtractMetadataAdapter,
2538
+ type FragmentBuilderFor,
2539
+ createDirectiveMethod,
2540
+ createTypedDirectiveMethod,
2541
+ createGqlElementComposer,
2542
+ createStandardDirectives,
2543
+ createVarMethodFactory,
2544
+ } from "@soda-gql/core";
2545
+ ${extraImports}
2546
+ ${schemaBlocks.join("\n")}
2547
+
2548
+ export const gql = {
2549
+ ${gqlEntries.join(",\n")}
2550
+ };
2551
+ `;
2552
+ };
2553
+ const generateMultiSchemaModule = (schemas, options) => {
2554
+ const schemaConfigs = {};
2555
+ const allStats = {
2556
+ objects: 0,
2557
+ enums: 0,
2558
+ inputs: 0,
2559
+ unions: 0
2560
+ };
2561
+ for (const [name, document] of schemas.entries()) {
2562
+ const schema = createSchemaIndex(document);
2563
+ const typeFilterConfig = options?.typeFilters?.get(name);
2564
+ const typeFilter = compileTypeFilter(typeFilterConfig);
2565
+ const allTypeNames = new Map([
2566
+ ["object", Array.from(schema.objects.keys()).filter((n) => !n.startsWith("__"))],
2567
+ ["input", Array.from(schema.inputs.keys()).filter((n) => !n.startsWith("__"))],
2568
+ ["enum", Array.from(schema.enums.keys()).filter((n) => !n.startsWith("__"))],
2569
+ ["union", Array.from(schema.unions.keys()).filter((n) => !n.startsWith("__"))],
2570
+ ["scalar", Array.from(schema.scalars.keys()).filter((n) => !n.startsWith("__"))]
2571
+ ]);
2572
+ const excluded = buildExclusionSet(typeFilter, allTypeNames);
2573
+ const objectTypeNames = collectObjectTypeNames(schema).filter((n) => !excluded.has(n));
2574
+ const enumTypeNames = collectEnumTypeNames(schema).filter((n) => !excluded.has(n));
2575
+ const inputTypeNames = collectInputTypeNames(schema).filter((n) => !excluded.has(n));
2576
+ const unionTypeNames = collectUnionTypeNames(schema).filter((n) => !excluded.has(n));
2577
+ const customScalarNames = collectScalarNames(schema).filter((n) => !builtinScalarTypes.has(n) && !excluded.has(n));
2578
+ const scalarVars = [];
2579
+ const enumVars = [];
2580
+ const inputVars = [];
2581
+ const objectVars = [];
2582
+ const unionVars = [];
2583
+ for (const scalarName of builtinScalarTypes.keys()) {
2584
+ const record = schema.scalars.get(scalarName) ?? {
2585
+ name: scalarName,
2586
+ directives: []
2587
+ };
2588
+ scalarVars.push(renderScalarVar(name, record));
2589
+ }
2590
+ for (const scalarName of customScalarNames) {
2591
+ const record = schema.scalars.get(scalarName);
2592
+ if (record) {
2593
+ scalarVars.push(renderScalarVar(name, record));
2594
+ }
2595
+ }
2596
+ for (const enumName of enumTypeNames) {
2597
+ const record = schema.enums.get(enumName);
2598
+ if (record) {
2599
+ enumVars.push(renderEnumVar(name, record));
2600
+ }
2601
+ }
2602
+ for (const inputName of inputTypeNames) {
2603
+ const record = schema.inputs.get(inputName);
2604
+ if (record) {
2605
+ inputVars.push(renderInputVar(name, schema, record, excluded));
2606
+ }
2607
+ }
2608
+ for (const objectName of objectTypeNames) {
2609
+ const record = schema.objects.get(objectName);
2610
+ if (record) {
2611
+ objectVars.push(renderObjectVar(name, schema, record, excluded));
2612
+ }
2613
+ }
2614
+ for (const unionName of unionTypeNames) {
2615
+ const record = schema.unions.get(unionName);
2616
+ if (record) {
2617
+ unionVars.push(renderUnionVar(name, record, excluded));
2618
+ }
2619
+ }
2620
+ const allScalarNames = [...builtinScalarTypes.keys(), ...customScalarNames];
2621
+ const factoryVar = `createMethod_${name}`;
2622
+ const inputTypeMethodsBlock = renderInputTypeMethods(schema, factoryVar, excluded);
2623
+ const directiveMethodsBlock = renderDirectiveMethods(schema, excluded);
2624
+ const adapterTypeName = options?.injection?.get(name)?.adapterImportPath ? `Adapter_${name}` : undefined;
2625
+ const fragmentBuildersTypeBlock = renderFragmentBuildersType(objectTypeNames, name, adapterTypeName);
2626
+ const queryType = schema.operationTypes.query ?? "Query";
2627
+ const mutationType = schema.operationTypes.mutation ?? "Mutation";
2628
+ const subscriptionType = schema.operationTypes.subscription ?? "Subscription";
2629
+ schemaConfigs[name] = {
2630
+ queryType,
2631
+ mutationType,
2632
+ subscriptionType,
2633
+ scalarVars,
2634
+ enumVars,
2635
+ inputVars,
2636
+ objectVars,
2637
+ unionVars,
2638
+ scalarNames: allScalarNames,
2639
+ enumNames: enumTypeNames,
2640
+ inputNames: inputTypeNames,
2641
+ objectNames: objectTypeNames,
2642
+ unionNames: unionTypeNames,
2643
+ inputTypeMethodsBlock,
2644
+ directiveMethodsBlock,
2645
+ fragmentBuildersTypeBlock,
2646
+ defaultInputDepth: options?.defaultInputDepth?.get(name),
2647
+ inputDepthOverrides: options?.inputDepthOverrides?.get(name)
2648
+ };
2649
+ allStats.objects += objectVars.length;
2650
+ allStats.enums += enumVars.length;
2651
+ allStats.inputs += inputVars.length;
2652
+ allStats.unions += unionVars.length;
2653
+ }
2654
+ const injection = options?.injection ? {
2655
+ mode: "inject",
2656
+ perSchema: options.injection,
2657
+ injectsModulePath: "./_internal-injects"
2658
+ } : { mode: "inline" };
2659
+ const splitting = { importPaths: {
2660
+ enums: "./_defs/enums",
2661
+ inputs: "./_defs/inputs",
2662
+ objects: "./_defs/objects",
2663
+ unions: "./_defs/unions"
2664
+ } };
2665
+ const code = multiRuntimeTemplate({
2666
+ schemas: schemaConfigs,
2667
+ injection,
2668
+ splitting
2669
+ });
2670
+ const injectsCode = options?.injection ? generateInjectsCode(options.injection) : undefined;
2671
+ const categoryVarsResult = Object.fromEntries(Object.entries(schemaConfigs).map(([schemaName, config]) => {
2672
+ const toDefVar = (code$1, prefix) => {
2673
+ const match = code$1.match(new RegExp(`const (${prefix}_${schemaName}_(\\w+))`));
2674
+ return {
2675
+ name: match?.[1] ?? "",
2676
+ code: code$1
2677
+ };
2678
+ };
2679
+ return [schemaName, {
2680
+ enums: config.enumVars.map((c) => toDefVar(c, "enum")),
2681
+ inputs: config.inputVars.map((c) => toDefVar(c, "input")),
2682
+ objects: config.objectVars.map((c) => toDefVar(c, "object")),
2683
+ unions: config.unionVars.map((c) => toDefVar(c, "union"))
2684
+ }];
2685
+ }));
2686
+ return {
2687
+ code,
2688
+ injectsCode,
2689
+ categoryVars: categoryVarsResult,
2690
+ stats: allStats
2691
+ };
2692
+ };
2693
+
2694
+ //#endregion
2695
+ export { generateMultiSchemaModule as n, createSchemaIndex as t };
2696
+ //# sourceMappingURL=generator-DfM1bY76.mjs.map