@tinacms/schema-tools 1.4.17 → 1.4.19

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.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("picomatch-browser"), require("yup"), require("url-pattern"), require("zod")) : typeof define === "function" && define.amd ? define(["exports", "picomatch-browser", "yup", "url-pattern", "zod"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@tinacms/schema-tools"] = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
3
- })(this, function(exports2, picomatch, yup, UrlPattern, z) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("yup"), require("url-pattern"), require("zod")) : typeof define === "function" && define.amd ? define(["exports", "yup", "url-pattern", "zod"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@tinacms/schema-tools"] = {}, global.NOOP, global.NOOP, global.NOOP));
3
+ })(this, function(exports2, yup, UrlPattern, z) {
4
4
  "use strict";
5
5
  function _interopNamespaceDefault(e) {
6
6
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -57,6 +57,1504 @@
57
57
  });
58
58
  return { ...newNode, namespace };
59
59
  }
60
+ function getDefaultExportFromCjs(x) {
61
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
62
+ }
63
+ var utils$4 = {};
64
+ const WIN_SLASH = "\\\\/";
65
+ const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
66
+ const DOT_LITERAL = "\\.";
67
+ const PLUS_LITERAL = "\\+";
68
+ const QMARK_LITERAL = "\\?";
69
+ const SLASH_LITERAL = "\\/";
70
+ const ONE_CHAR = "(?=.)";
71
+ const QMARK = "[^/]";
72
+ const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
73
+ const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
74
+ const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
75
+ const NO_DOT = `(?!${DOT_LITERAL})`;
76
+ const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
77
+ const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
78
+ const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
79
+ const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
80
+ const STAR = `${QMARK}*?`;
81
+ const SEP = "/";
82
+ const POSIX_CHARS = {
83
+ DOT_LITERAL,
84
+ PLUS_LITERAL,
85
+ QMARK_LITERAL,
86
+ SLASH_LITERAL,
87
+ ONE_CHAR,
88
+ QMARK,
89
+ END_ANCHOR,
90
+ DOTS_SLASH,
91
+ NO_DOT,
92
+ NO_DOTS,
93
+ NO_DOT_SLASH,
94
+ NO_DOTS_SLASH,
95
+ QMARK_NO_DOT,
96
+ STAR,
97
+ START_ANCHOR,
98
+ SEP
99
+ };
100
+ const WINDOWS_CHARS = {
101
+ ...POSIX_CHARS,
102
+ SLASH_LITERAL: `[${WIN_SLASH}]`,
103
+ QMARK: WIN_NO_SLASH,
104
+ STAR: `${WIN_NO_SLASH}*?`,
105
+ DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
106
+ NO_DOT: `(?!${DOT_LITERAL})`,
107
+ NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
108
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
109
+ NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
110
+ QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
111
+ START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
112
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
113
+ SEP: "\\"
114
+ };
115
+ const POSIX_REGEX_SOURCE$1 = {
116
+ alnum: "a-zA-Z0-9",
117
+ alpha: "a-zA-Z",
118
+ ascii: "\\x00-\\x7F",
119
+ blank: " \\t",
120
+ cntrl: "\\x00-\\x1F\\x7F",
121
+ digit: "0-9",
122
+ graph: "\\x21-\\x7E",
123
+ lower: "a-z",
124
+ print: "\\x20-\\x7E ",
125
+ punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
126
+ space: " \\t\\r\\n\\v\\f",
127
+ upper: "A-Z",
128
+ word: "A-Za-z0-9_",
129
+ xdigit: "A-Fa-f0-9"
130
+ };
131
+ var constants$2 = {
132
+ MAX_LENGTH: 1024 * 64,
133
+ POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
134
+ // regular expressions
135
+ REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
136
+ REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
137
+ REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
138
+ REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
139
+ REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
140
+ REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
141
+ // Replace globs with equivalent patterns to reduce parsing time.
142
+ REPLACEMENTS: {
143
+ "***": "*",
144
+ "**/**": "**",
145
+ "**/**/**": "**"
146
+ },
147
+ // Digits
148
+ CHAR_0: 48,
149
+ /* 0 */
150
+ CHAR_9: 57,
151
+ /* 9 */
152
+ // Alphabet chars.
153
+ CHAR_UPPERCASE_A: 65,
154
+ /* A */
155
+ CHAR_LOWERCASE_A: 97,
156
+ /* a */
157
+ CHAR_UPPERCASE_Z: 90,
158
+ /* Z */
159
+ CHAR_LOWERCASE_Z: 122,
160
+ /* z */
161
+ CHAR_LEFT_PARENTHESES: 40,
162
+ /* ( */
163
+ CHAR_RIGHT_PARENTHESES: 41,
164
+ /* ) */
165
+ CHAR_ASTERISK: 42,
166
+ /* * */
167
+ // Non-alphabetic chars.
168
+ CHAR_AMPERSAND: 38,
169
+ /* & */
170
+ CHAR_AT: 64,
171
+ /* @ */
172
+ CHAR_BACKWARD_SLASH: 92,
173
+ /* \ */
174
+ CHAR_CARRIAGE_RETURN: 13,
175
+ /* \r */
176
+ CHAR_CIRCUMFLEX_ACCENT: 94,
177
+ /* ^ */
178
+ CHAR_COLON: 58,
179
+ /* : */
180
+ CHAR_COMMA: 44,
181
+ /* , */
182
+ CHAR_DOT: 46,
183
+ /* . */
184
+ CHAR_DOUBLE_QUOTE: 34,
185
+ /* " */
186
+ CHAR_EQUAL: 61,
187
+ /* = */
188
+ CHAR_EXCLAMATION_MARK: 33,
189
+ /* ! */
190
+ CHAR_FORM_FEED: 12,
191
+ /* \f */
192
+ CHAR_FORWARD_SLASH: 47,
193
+ /* / */
194
+ CHAR_GRAVE_ACCENT: 96,
195
+ /* ` */
196
+ CHAR_HASH: 35,
197
+ /* # */
198
+ CHAR_HYPHEN_MINUS: 45,
199
+ /* - */
200
+ CHAR_LEFT_ANGLE_BRACKET: 60,
201
+ /* < */
202
+ CHAR_LEFT_CURLY_BRACE: 123,
203
+ /* { */
204
+ CHAR_LEFT_SQUARE_BRACKET: 91,
205
+ /* [ */
206
+ CHAR_LINE_FEED: 10,
207
+ /* \n */
208
+ CHAR_NO_BREAK_SPACE: 160,
209
+ /* \u00A0 */
210
+ CHAR_PERCENT: 37,
211
+ /* % */
212
+ CHAR_PLUS: 43,
213
+ /* + */
214
+ CHAR_QUESTION_MARK: 63,
215
+ /* ? */
216
+ CHAR_RIGHT_ANGLE_BRACKET: 62,
217
+ /* > */
218
+ CHAR_RIGHT_CURLY_BRACE: 125,
219
+ /* } */
220
+ CHAR_RIGHT_SQUARE_BRACKET: 93,
221
+ /* ] */
222
+ CHAR_SEMICOLON: 59,
223
+ /* ; */
224
+ CHAR_SINGLE_QUOTE: 39,
225
+ /* ' */
226
+ CHAR_SPACE: 32,
227
+ /* */
228
+ CHAR_TAB: 9,
229
+ /* \t */
230
+ CHAR_UNDERSCORE: 95,
231
+ /* _ */
232
+ CHAR_VERTICAL_LINE: 124,
233
+ /* | */
234
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
235
+ /* \uFEFF */
236
+ /**
237
+ * Create EXTGLOB_CHARS
238
+ */
239
+ extglobChars(chars) {
240
+ return {
241
+ "!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
242
+ "?": { type: "qmark", open: "(?:", close: ")?" },
243
+ "+": { type: "plus", open: "(?:", close: ")+" },
244
+ "*": { type: "star", open: "(?:", close: ")*" },
245
+ "@": { type: "at", open: "(?:", close: ")" }
246
+ };
247
+ },
248
+ /**
249
+ * Create GLOB_CHARS
250
+ */
251
+ globChars(win32) {
252
+ return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
253
+ }
254
+ };
255
+ (function(exports3) {
256
+ const {
257
+ REGEX_BACKSLASH,
258
+ REGEX_REMOVE_BACKSLASH,
259
+ REGEX_SPECIAL_CHARS,
260
+ REGEX_SPECIAL_CHARS_GLOBAL
261
+ } = constants$2;
262
+ exports3.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
263
+ exports3.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
264
+ exports3.isRegexChar = (str) => str.length === 1 && exports3.hasRegexChars(str);
265
+ exports3.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
266
+ exports3.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
267
+ exports3.isWindows = () => {
268
+ if (typeof navigator !== "undefined" && navigator.platform) {
269
+ const platform = navigator.platform.toLowerCase();
270
+ return platform === "win32" || platform === "windows";
271
+ }
272
+ if (typeof process !== "undefined" && process.platform) {
273
+ return process.platform === "win32";
274
+ }
275
+ return false;
276
+ };
277
+ exports3.removeBackslashes = (str) => {
278
+ return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
279
+ return match === "\\" ? "" : match;
280
+ });
281
+ };
282
+ exports3.escapeLast = (input, char, lastIdx) => {
283
+ const idx = input.lastIndexOf(char, lastIdx);
284
+ if (idx === -1)
285
+ return input;
286
+ if (input[idx - 1] === "\\")
287
+ return exports3.escapeLast(input, char, idx - 1);
288
+ return `${input.slice(0, idx)}\\${input.slice(idx)}`;
289
+ };
290
+ exports3.removePrefix = (input, state = {}) => {
291
+ let output = input;
292
+ if (output.startsWith("./")) {
293
+ output = output.slice(2);
294
+ state.prefix = "./";
295
+ }
296
+ return output;
297
+ };
298
+ exports3.wrapOutput = (input, state = {}, options = {}) => {
299
+ const prepend = options.contains ? "" : "^";
300
+ const append = options.contains ? "" : "$";
301
+ let output = `${prepend}(?:${input})${append}`;
302
+ if (state.negated === true) {
303
+ output = `(?:^(?!${output}).*$)`;
304
+ }
305
+ return output;
306
+ };
307
+ exports3.basename = (path, { windows } = {}) => {
308
+ const segs = path.split(windows ? /[\\/]/ : "/");
309
+ const last = segs[segs.length - 1];
310
+ if (last === "") {
311
+ return segs[segs.length - 2];
312
+ }
313
+ return last;
314
+ };
315
+ })(utils$4);
316
+ const utils$3 = utils$4;
317
+ const {
318
+ CHAR_ASTERISK,
319
+ /* * */
320
+ CHAR_AT,
321
+ /* @ */
322
+ CHAR_BACKWARD_SLASH,
323
+ /* \ */
324
+ CHAR_COMMA,
325
+ /* , */
326
+ CHAR_DOT,
327
+ /* . */
328
+ CHAR_EXCLAMATION_MARK,
329
+ /* ! */
330
+ CHAR_FORWARD_SLASH,
331
+ /* / */
332
+ CHAR_LEFT_CURLY_BRACE,
333
+ /* { */
334
+ CHAR_LEFT_PARENTHESES,
335
+ /* ( */
336
+ CHAR_LEFT_SQUARE_BRACKET,
337
+ /* [ */
338
+ CHAR_PLUS,
339
+ /* + */
340
+ CHAR_QUESTION_MARK,
341
+ /* ? */
342
+ CHAR_RIGHT_CURLY_BRACE,
343
+ /* } */
344
+ CHAR_RIGHT_PARENTHESES,
345
+ /* ) */
346
+ CHAR_RIGHT_SQUARE_BRACKET
347
+ /* ] */
348
+ } = constants$2;
349
+ const isPathSeparator = (code) => {
350
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
351
+ };
352
+ const depth = (token) => {
353
+ if (token.isPrefix !== true) {
354
+ token.depth = token.isGlobstar ? Infinity : 1;
355
+ }
356
+ };
357
+ const scan$1 = (input, options) => {
358
+ const opts = options || {};
359
+ const length = input.length - 1;
360
+ const scanToEnd = opts.parts === true || opts.scanToEnd === true;
361
+ const slashes = [];
362
+ const tokens = [];
363
+ const parts = [];
364
+ let str = input;
365
+ let index = -1;
366
+ let start = 0;
367
+ let lastIndex = 0;
368
+ let isBrace = false;
369
+ let isBracket = false;
370
+ let isGlob = false;
371
+ let isExtglob = false;
372
+ let isGlobstar = false;
373
+ let braceEscaped = false;
374
+ let backslashes = false;
375
+ let negated = false;
376
+ let negatedExtglob = false;
377
+ let finished = false;
378
+ let braces = 0;
379
+ let prev;
380
+ let code;
381
+ let token = { value: "", depth: 0, isGlob: false };
382
+ const eos = () => index >= length;
383
+ const peek = () => str.charCodeAt(index + 1);
384
+ const advance = () => {
385
+ prev = code;
386
+ return str.charCodeAt(++index);
387
+ };
388
+ while (index < length) {
389
+ code = advance();
390
+ let next;
391
+ if (code === CHAR_BACKWARD_SLASH) {
392
+ backslashes = token.backslashes = true;
393
+ code = advance();
394
+ if (code === CHAR_LEFT_CURLY_BRACE) {
395
+ braceEscaped = true;
396
+ }
397
+ continue;
398
+ }
399
+ if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
400
+ braces++;
401
+ while (eos() !== true && (code = advance())) {
402
+ if (code === CHAR_BACKWARD_SLASH) {
403
+ backslashes = token.backslashes = true;
404
+ advance();
405
+ continue;
406
+ }
407
+ if (code === CHAR_LEFT_CURLY_BRACE) {
408
+ braces++;
409
+ continue;
410
+ }
411
+ if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
412
+ isBrace = token.isBrace = true;
413
+ isGlob = token.isGlob = true;
414
+ finished = true;
415
+ if (scanToEnd === true) {
416
+ continue;
417
+ }
418
+ break;
419
+ }
420
+ if (braceEscaped !== true && code === CHAR_COMMA) {
421
+ isBrace = token.isBrace = true;
422
+ isGlob = token.isGlob = true;
423
+ finished = true;
424
+ if (scanToEnd === true) {
425
+ continue;
426
+ }
427
+ break;
428
+ }
429
+ if (code === CHAR_RIGHT_CURLY_BRACE) {
430
+ braces--;
431
+ if (braces === 0) {
432
+ braceEscaped = false;
433
+ isBrace = token.isBrace = true;
434
+ finished = true;
435
+ break;
436
+ }
437
+ }
438
+ }
439
+ if (scanToEnd === true) {
440
+ continue;
441
+ }
442
+ break;
443
+ }
444
+ if (code === CHAR_FORWARD_SLASH) {
445
+ slashes.push(index);
446
+ tokens.push(token);
447
+ token = { value: "", depth: 0, isGlob: false };
448
+ if (finished === true)
449
+ continue;
450
+ if (prev === CHAR_DOT && index === start + 1) {
451
+ start += 2;
452
+ continue;
453
+ }
454
+ lastIndex = index + 1;
455
+ continue;
456
+ }
457
+ if (opts.noext !== true) {
458
+ const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
459
+ if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
460
+ isGlob = token.isGlob = true;
461
+ isExtglob = token.isExtglob = true;
462
+ finished = true;
463
+ if (code === CHAR_EXCLAMATION_MARK && index === start) {
464
+ negatedExtglob = true;
465
+ }
466
+ if (scanToEnd === true) {
467
+ while (eos() !== true && (code = advance())) {
468
+ if (code === CHAR_BACKWARD_SLASH) {
469
+ backslashes = token.backslashes = true;
470
+ code = advance();
471
+ continue;
472
+ }
473
+ if (code === CHAR_RIGHT_PARENTHESES) {
474
+ isGlob = token.isGlob = true;
475
+ finished = true;
476
+ break;
477
+ }
478
+ }
479
+ continue;
480
+ }
481
+ break;
482
+ }
483
+ }
484
+ if (code === CHAR_ASTERISK) {
485
+ if (prev === CHAR_ASTERISK)
486
+ isGlobstar = token.isGlobstar = true;
487
+ isGlob = token.isGlob = true;
488
+ finished = true;
489
+ if (scanToEnd === true) {
490
+ continue;
491
+ }
492
+ break;
493
+ }
494
+ if (code === CHAR_QUESTION_MARK) {
495
+ isGlob = token.isGlob = true;
496
+ finished = true;
497
+ if (scanToEnd === true) {
498
+ continue;
499
+ }
500
+ break;
501
+ }
502
+ if (code === CHAR_LEFT_SQUARE_BRACKET) {
503
+ while (eos() !== true && (next = advance())) {
504
+ if (next === CHAR_BACKWARD_SLASH) {
505
+ backslashes = token.backslashes = true;
506
+ advance();
507
+ continue;
508
+ }
509
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
510
+ isBracket = token.isBracket = true;
511
+ isGlob = token.isGlob = true;
512
+ finished = true;
513
+ break;
514
+ }
515
+ }
516
+ if (scanToEnd === true) {
517
+ continue;
518
+ }
519
+ break;
520
+ }
521
+ if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
522
+ negated = token.negated = true;
523
+ start++;
524
+ continue;
525
+ }
526
+ if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
527
+ isGlob = token.isGlob = true;
528
+ if (scanToEnd === true) {
529
+ while (eos() !== true && (code = advance())) {
530
+ if (code === CHAR_LEFT_PARENTHESES) {
531
+ backslashes = token.backslashes = true;
532
+ code = advance();
533
+ continue;
534
+ }
535
+ if (code === CHAR_RIGHT_PARENTHESES) {
536
+ finished = true;
537
+ break;
538
+ }
539
+ }
540
+ continue;
541
+ }
542
+ break;
543
+ }
544
+ if (isGlob === true) {
545
+ finished = true;
546
+ if (scanToEnd === true) {
547
+ continue;
548
+ }
549
+ break;
550
+ }
551
+ }
552
+ if (opts.noext === true) {
553
+ isExtglob = false;
554
+ isGlob = false;
555
+ }
556
+ let base = str;
557
+ let prefix = "";
558
+ let glob = "";
559
+ if (start > 0) {
560
+ prefix = str.slice(0, start);
561
+ str = str.slice(start);
562
+ lastIndex -= start;
563
+ }
564
+ if (base && isGlob === true && lastIndex > 0) {
565
+ base = str.slice(0, lastIndex);
566
+ glob = str.slice(lastIndex);
567
+ } else if (isGlob === true) {
568
+ base = "";
569
+ glob = str;
570
+ } else {
571
+ base = str;
572
+ }
573
+ if (base && base !== "" && base !== "/" && base !== str) {
574
+ if (isPathSeparator(base.charCodeAt(base.length - 1))) {
575
+ base = base.slice(0, -1);
576
+ }
577
+ }
578
+ if (opts.unescape === true) {
579
+ if (glob)
580
+ glob = utils$3.removeBackslashes(glob);
581
+ if (base && backslashes === true) {
582
+ base = utils$3.removeBackslashes(base);
583
+ }
584
+ }
585
+ const state = {
586
+ prefix,
587
+ input,
588
+ start,
589
+ base,
590
+ glob,
591
+ isBrace,
592
+ isBracket,
593
+ isGlob,
594
+ isExtglob,
595
+ isGlobstar,
596
+ negated,
597
+ negatedExtglob
598
+ };
599
+ if (opts.tokens === true) {
600
+ state.maxDepth = 0;
601
+ if (!isPathSeparator(code)) {
602
+ tokens.push(token);
603
+ }
604
+ state.tokens = tokens;
605
+ }
606
+ if (opts.parts === true || opts.tokens === true) {
607
+ let prevIndex;
608
+ for (let idx = 0; idx < slashes.length; idx++) {
609
+ const n = prevIndex ? prevIndex + 1 : start;
610
+ const i = slashes[idx];
611
+ const value = input.slice(n, i);
612
+ if (opts.tokens) {
613
+ if (idx === 0 && start !== 0) {
614
+ tokens[idx].isPrefix = true;
615
+ tokens[idx].value = prefix;
616
+ } else {
617
+ tokens[idx].value = value;
618
+ }
619
+ depth(tokens[idx]);
620
+ state.maxDepth += tokens[idx].depth;
621
+ }
622
+ if (idx !== 0 || value !== "") {
623
+ parts.push(value);
624
+ }
625
+ prevIndex = i;
626
+ }
627
+ if (prevIndex && prevIndex + 1 < input.length) {
628
+ const value = input.slice(prevIndex + 1);
629
+ parts.push(value);
630
+ if (opts.tokens) {
631
+ tokens[tokens.length - 1].value = value;
632
+ depth(tokens[tokens.length - 1]);
633
+ state.maxDepth += tokens[tokens.length - 1].depth;
634
+ }
635
+ }
636
+ state.slashes = slashes;
637
+ state.parts = parts;
638
+ }
639
+ return state;
640
+ };
641
+ var scan_1 = scan$1;
642
+ const constants$1 = constants$2;
643
+ const utils$2 = utils$4;
644
+ const {
645
+ MAX_LENGTH,
646
+ POSIX_REGEX_SOURCE,
647
+ REGEX_NON_SPECIAL_CHARS,
648
+ REGEX_SPECIAL_CHARS_BACKREF,
649
+ REPLACEMENTS
650
+ } = constants$1;
651
+ const expandRange = (args, options) => {
652
+ if (typeof options.expandRange === "function") {
653
+ return options.expandRange(...args, options);
654
+ }
655
+ args.sort();
656
+ const value = `[${args.join("-")}]`;
657
+ try {
658
+ new RegExp(value);
659
+ } catch (ex) {
660
+ return args.map((v) => utils$2.escapeRegex(v)).join("..");
661
+ }
662
+ return value;
663
+ };
664
+ const syntaxError = (type, char) => {
665
+ return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
666
+ };
667
+ const parse$1 = (input, options) => {
668
+ if (typeof input !== "string") {
669
+ throw new TypeError("Expected a string");
670
+ }
671
+ input = REPLACEMENTS[input] || input;
672
+ const opts = { ...options };
673
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
674
+ let len = input.length;
675
+ if (len > max) {
676
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
677
+ }
678
+ const bos = { type: "bos", value: "", output: opts.prepend || "" };
679
+ const tokens = [bos];
680
+ const capture = opts.capture ? "" : "?:";
681
+ const PLATFORM_CHARS = constants$1.globChars(opts.windows);
682
+ const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
683
+ const {
684
+ DOT_LITERAL: DOT_LITERAL2,
685
+ PLUS_LITERAL: PLUS_LITERAL2,
686
+ SLASH_LITERAL: SLASH_LITERAL2,
687
+ ONE_CHAR: ONE_CHAR2,
688
+ DOTS_SLASH: DOTS_SLASH2,
689
+ NO_DOT: NO_DOT2,
690
+ NO_DOT_SLASH: NO_DOT_SLASH2,
691
+ NO_DOTS_SLASH: NO_DOTS_SLASH2,
692
+ QMARK: QMARK2,
693
+ QMARK_NO_DOT: QMARK_NO_DOT2,
694
+ STAR: STAR2,
695
+ START_ANCHOR: START_ANCHOR2
696
+ } = PLATFORM_CHARS;
697
+ const globstar = (opts2) => {
698
+ return `(${capture}(?:(?!${START_ANCHOR2}${opts2.dot ? DOTS_SLASH2 : DOT_LITERAL2}).)*?)`;
699
+ };
700
+ const nodot = opts.dot ? "" : NO_DOT2;
701
+ const qmarkNoDot = opts.dot ? QMARK2 : QMARK_NO_DOT2;
702
+ let star = opts.bash === true ? globstar(opts) : STAR2;
703
+ if (opts.capture) {
704
+ star = `(${star})`;
705
+ }
706
+ if (typeof opts.noext === "boolean") {
707
+ opts.noextglob = opts.noext;
708
+ }
709
+ const state = {
710
+ input,
711
+ index: -1,
712
+ start: 0,
713
+ dot: opts.dot === true,
714
+ consumed: "",
715
+ output: "",
716
+ prefix: "",
717
+ backtrack: false,
718
+ negated: false,
719
+ brackets: 0,
720
+ braces: 0,
721
+ parens: 0,
722
+ quotes: 0,
723
+ globstar: false,
724
+ tokens
725
+ };
726
+ input = utils$2.removePrefix(input, state);
727
+ len = input.length;
728
+ const extglobs = [];
729
+ const braces = [];
730
+ const stack = [];
731
+ let prev = bos;
732
+ let value;
733
+ const eos = () => state.index === len - 1;
734
+ const peek = state.peek = (n = 1) => input[state.index + n];
735
+ const advance = state.advance = () => input[++state.index] || "";
736
+ const remaining = () => input.slice(state.index + 1);
737
+ const consume = (value2 = "", num = 0) => {
738
+ state.consumed += value2;
739
+ state.index += num;
740
+ };
741
+ const append = (token) => {
742
+ state.output += token.output != null ? token.output : token.value;
743
+ consume(token.value);
744
+ };
745
+ const negate = () => {
746
+ let count = 1;
747
+ while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
748
+ advance();
749
+ state.start++;
750
+ count++;
751
+ }
752
+ if (count % 2 === 0) {
753
+ return false;
754
+ }
755
+ state.negated = true;
756
+ state.start++;
757
+ return true;
758
+ };
759
+ const increment = (type) => {
760
+ state[type]++;
761
+ stack.push(type);
762
+ };
763
+ const decrement = (type) => {
764
+ state[type]--;
765
+ stack.pop();
766
+ };
767
+ const push = (tok) => {
768
+ if (prev.type === "globstar") {
769
+ const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
770
+ const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
771
+ if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
772
+ state.output = state.output.slice(0, -prev.output.length);
773
+ prev.type = "star";
774
+ prev.value = "*";
775
+ prev.output = star;
776
+ state.output += prev.output;
777
+ }
778
+ }
779
+ if (extglobs.length && tok.type !== "paren") {
780
+ extglobs[extglobs.length - 1].inner += tok.value;
781
+ }
782
+ if (tok.value || tok.output)
783
+ append(tok);
784
+ if (prev && prev.type === "text" && tok.type === "text") {
785
+ prev.output = (prev.output || prev.value) + tok.value;
786
+ prev.value += tok.value;
787
+ return;
788
+ }
789
+ tok.prev = prev;
790
+ tokens.push(tok);
791
+ prev = tok;
792
+ };
793
+ const extglobOpen = (type, value2) => {
794
+ const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
795
+ token.prev = prev;
796
+ token.parens = state.parens;
797
+ token.output = state.output;
798
+ const output = (opts.capture ? "(" : "") + token.open;
799
+ increment("parens");
800
+ push({ type, value: value2, output: state.output ? "" : ONE_CHAR2 });
801
+ push({ type: "paren", extglob: true, value: advance(), output });
802
+ extglobs.push(token);
803
+ };
804
+ const extglobClose = (token) => {
805
+ let output = token.close + (opts.capture ? ")" : "");
806
+ let rest;
807
+ if (token.type === "negate") {
808
+ let extglobStar = star;
809
+ if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
810
+ extglobStar = globstar(opts);
811
+ }
812
+ if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
813
+ output = token.close = `)$))${extglobStar}`;
814
+ }
815
+ if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
816
+ const expression = parse$1(rest, { ...options, fastpaths: false }).output;
817
+ output = token.close = `)${expression})${extglobStar})`;
818
+ }
819
+ if (token.prev.type === "bos") {
820
+ state.negatedExtglob = true;
821
+ }
822
+ }
823
+ push({ type: "paren", extglob: true, value, output });
824
+ decrement("parens");
825
+ };
826
+ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
827
+ let backslashes = false;
828
+ let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
829
+ if (first === "\\") {
830
+ backslashes = true;
831
+ return m;
832
+ }
833
+ if (first === "?") {
834
+ if (esc) {
835
+ return esc + first + (rest ? QMARK2.repeat(rest.length) : "");
836
+ }
837
+ if (index === 0) {
838
+ return qmarkNoDot + (rest ? QMARK2.repeat(rest.length) : "");
839
+ }
840
+ return QMARK2.repeat(chars.length);
841
+ }
842
+ if (first === ".") {
843
+ return DOT_LITERAL2.repeat(chars.length);
844
+ }
845
+ if (first === "*") {
846
+ if (esc) {
847
+ return esc + first + (rest ? star : "");
848
+ }
849
+ return star;
850
+ }
851
+ return esc ? m : `\\${m}`;
852
+ });
853
+ if (backslashes === true) {
854
+ if (opts.unescape === true) {
855
+ output = output.replace(/\\/g, "");
856
+ } else {
857
+ output = output.replace(/\\+/g, (m) => {
858
+ return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
859
+ });
860
+ }
861
+ }
862
+ if (output === input && opts.contains === true) {
863
+ state.output = input;
864
+ return state;
865
+ }
866
+ state.output = utils$2.wrapOutput(output, state, options);
867
+ return state;
868
+ }
869
+ while (!eos()) {
870
+ value = advance();
871
+ if (value === "\0") {
872
+ continue;
873
+ }
874
+ if (value === "\\") {
875
+ const next = peek();
876
+ if (next === "/" && opts.bash !== true) {
877
+ continue;
878
+ }
879
+ if (next === "." || next === ";") {
880
+ continue;
881
+ }
882
+ if (!next) {
883
+ value += "\\";
884
+ push({ type: "text", value });
885
+ continue;
886
+ }
887
+ const match = /^\\+/.exec(remaining());
888
+ let slashes = 0;
889
+ if (match && match[0].length > 2) {
890
+ slashes = match[0].length;
891
+ state.index += slashes;
892
+ if (slashes % 2 !== 0) {
893
+ value += "\\";
894
+ }
895
+ }
896
+ if (opts.unescape === true) {
897
+ value = advance();
898
+ } else {
899
+ value += advance();
900
+ }
901
+ if (state.brackets === 0) {
902
+ push({ type: "text", value });
903
+ continue;
904
+ }
905
+ }
906
+ if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
907
+ if (opts.posix !== false && value === ":") {
908
+ const inner = prev.value.slice(1);
909
+ if (inner.includes("[")) {
910
+ prev.posix = true;
911
+ if (inner.includes(":")) {
912
+ const idx = prev.value.lastIndexOf("[");
913
+ const pre = prev.value.slice(0, idx);
914
+ const rest2 = prev.value.slice(idx + 2);
915
+ const posix = POSIX_REGEX_SOURCE[rest2];
916
+ if (posix) {
917
+ prev.value = pre + posix;
918
+ state.backtrack = true;
919
+ advance();
920
+ if (!bos.output && tokens.indexOf(prev) === 1) {
921
+ bos.output = ONE_CHAR2;
922
+ }
923
+ continue;
924
+ }
925
+ }
926
+ }
927
+ }
928
+ if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
929
+ value = `\\${value}`;
930
+ }
931
+ if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
932
+ value = `\\${value}`;
933
+ }
934
+ if (opts.posix === true && value === "!" && prev.value === "[") {
935
+ value = "^";
936
+ }
937
+ prev.value += value;
938
+ append({ value });
939
+ continue;
940
+ }
941
+ if (state.quotes === 1 && value !== '"') {
942
+ value = utils$2.escapeRegex(value);
943
+ prev.value += value;
944
+ append({ value });
945
+ continue;
946
+ }
947
+ if (value === '"') {
948
+ state.quotes = state.quotes === 1 ? 0 : 1;
949
+ if (opts.keepQuotes === true) {
950
+ push({ type: "text", value });
951
+ }
952
+ continue;
953
+ }
954
+ if (value === "(") {
955
+ increment("parens");
956
+ push({ type: "paren", value });
957
+ continue;
958
+ }
959
+ if (value === ")") {
960
+ if (state.parens === 0 && opts.strictBrackets === true) {
961
+ throw new SyntaxError(syntaxError("opening", "("));
962
+ }
963
+ const extglob = extglobs[extglobs.length - 1];
964
+ if (extglob && state.parens === extglob.parens + 1) {
965
+ extglobClose(extglobs.pop());
966
+ continue;
967
+ }
968
+ push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
969
+ decrement("parens");
970
+ continue;
971
+ }
972
+ if (value === "[") {
973
+ if (opts.nobracket === true || !remaining().includes("]")) {
974
+ if (opts.nobracket !== true && opts.strictBrackets === true) {
975
+ throw new SyntaxError(syntaxError("closing", "]"));
976
+ }
977
+ value = `\\${value}`;
978
+ } else {
979
+ increment("brackets");
980
+ }
981
+ push({ type: "bracket", value });
982
+ continue;
983
+ }
984
+ if (value === "]") {
985
+ if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
986
+ push({ type: "text", value, output: `\\${value}` });
987
+ continue;
988
+ }
989
+ if (state.brackets === 0) {
990
+ if (opts.strictBrackets === true) {
991
+ throw new SyntaxError(syntaxError("opening", "["));
992
+ }
993
+ push({ type: "text", value, output: `\\${value}` });
994
+ continue;
995
+ }
996
+ decrement("brackets");
997
+ const prevValue = prev.value.slice(1);
998
+ if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
999
+ value = `/${value}`;
1000
+ }
1001
+ prev.value += value;
1002
+ append({ value });
1003
+ if (opts.literalBrackets === false || utils$2.hasRegexChars(prevValue)) {
1004
+ continue;
1005
+ }
1006
+ const escaped = utils$2.escapeRegex(prev.value);
1007
+ state.output = state.output.slice(0, -prev.value.length);
1008
+ if (opts.literalBrackets === true) {
1009
+ state.output += escaped;
1010
+ prev.value = escaped;
1011
+ continue;
1012
+ }
1013
+ prev.value = `(${capture}${escaped}|${prev.value})`;
1014
+ state.output += prev.value;
1015
+ continue;
1016
+ }
1017
+ if (value === "{" && opts.nobrace !== true) {
1018
+ increment("braces");
1019
+ const open = {
1020
+ type: "brace",
1021
+ value,
1022
+ output: "(",
1023
+ outputIndex: state.output.length,
1024
+ tokensIndex: state.tokens.length
1025
+ };
1026
+ braces.push(open);
1027
+ push(open);
1028
+ continue;
1029
+ }
1030
+ if (value === "}") {
1031
+ const brace = braces[braces.length - 1];
1032
+ if (opts.nobrace === true || !brace) {
1033
+ push({ type: "text", value, output: value });
1034
+ continue;
1035
+ }
1036
+ let output = ")";
1037
+ if (brace.dots === true) {
1038
+ const arr = tokens.slice();
1039
+ const range = [];
1040
+ for (let i = arr.length - 1; i >= 0; i--) {
1041
+ tokens.pop();
1042
+ if (arr[i].type === "brace") {
1043
+ break;
1044
+ }
1045
+ if (arr[i].type !== "dots") {
1046
+ range.unshift(arr[i].value);
1047
+ }
1048
+ }
1049
+ output = expandRange(range, opts);
1050
+ state.backtrack = true;
1051
+ }
1052
+ if (brace.comma !== true && brace.dots !== true) {
1053
+ const out = state.output.slice(0, brace.outputIndex);
1054
+ const toks = state.tokens.slice(brace.tokensIndex);
1055
+ brace.value = brace.output = "\\{";
1056
+ value = output = "\\}";
1057
+ state.output = out;
1058
+ for (const t of toks) {
1059
+ state.output += t.output || t.value;
1060
+ }
1061
+ }
1062
+ push({ type: "brace", value, output });
1063
+ decrement("braces");
1064
+ braces.pop();
1065
+ continue;
1066
+ }
1067
+ if (value === "|") {
1068
+ if (extglobs.length > 0) {
1069
+ extglobs[extglobs.length - 1].conditions++;
1070
+ }
1071
+ push({ type: "text", value });
1072
+ continue;
1073
+ }
1074
+ if (value === ",") {
1075
+ let output = value;
1076
+ const brace = braces[braces.length - 1];
1077
+ if (brace && stack[stack.length - 1] === "braces") {
1078
+ brace.comma = true;
1079
+ output = "|";
1080
+ }
1081
+ push({ type: "comma", value, output });
1082
+ continue;
1083
+ }
1084
+ if (value === "/") {
1085
+ if (prev.type === "dot" && state.index === state.start + 1) {
1086
+ state.start = state.index + 1;
1087
+ state.consumed = "";
1088
+ state.output = "";
1089
+ tokens.pop();
1090
+ prev = bos;
1091
+ continue;
1092
+ }
1093
+ push({ type: "slash", value, output: SLASH_LITERAL2 });
1094
+ continue;
1095
+ }
1096
+ if (value === ".") {
1097
+ if (state.braces > 0 && prev.type === "dot") {
1098
+ if (prev.value === ".")
1099
+ prev.output = DOT_LITERAL2;
1100
+ const brace = braces[braces.length - 1];
1101
+ prev.type = "dots";
1102
+ prev.output += value;
1103
+ prev.value += value;
1104
+ brace.dots = true;
1105
+ continue;
1106
+ }
1107
+ if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
1108
+ push({ type: "text", value, output: DOT_LITERAL2 });
1109
+ continue;
1110
+ }
1111
+ push({ type: "dot", value, output: DOT_LITERAL2 });
1112
+ continue;
1113
+ }
1114
+ if (value === "?") {
1115
+ const isGroup = prev && prev.value === "(";
1116
+ if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1117
+ extglobOpen("qmark", value);
1118
+ continue;
1119
+ }
1120
+ if (prev && prev.type === "paren") {
1121
+ const next = peek();
1122
+ let output = value;
1123
+ if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
1124
+ output = `\\${value}`;
1125
+ }
1126
+ push({ type: "text", value, output });
1127
+ continue;
1128
+ }
1129
+ if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
1130
+ push({ type: "qmark", value, output: QMARK_NO_DOT2 });
1131
+ continue;
1132
+ }
1133
+ push({ type: "qmark", value, output: QMARK2 });
1134
+ continue;
1135
+ }
1136
+ if (value === "!") {
1137
+ if (opts.noextglob !== true && peek() === "(") {
1138
+ if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
1139
+ extglobOpen("negate", value);
1140
+ continue;
1141
+ }
1142
+ }
1143
+ if (opts.nonegate !== true && state.index === 0) {
1144
+ negate();
1145
+ continue;
1146
+ }
1147
+ }
1148
+ if (value === "+") {
1149
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1150
+ extglobOpen("plus", value);
1151
+ continue;
1152
+ }
1153
+ if (prev && prev.value === "(" || opts.regex === false) {
1154
+ push({ type: "plus", value, output: PLUS_LITERAL2 });
1155
+ continue;
1156
+ }
1157
+ if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
1158
+ push({ type: "plus", value });
1159
+ continue;
1160
+ }
1161
+ push({ type: "plus", value: PLUS_LITERAL2 });
1162
+ continue;
1163
+ }
1164
+ if (value === "@") {
1165
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1166
+ push({ type: "at", extglob: true, value, output: "" });
1167
+ continue;
1168
+ }
1169
+ push({ type: "text", value });
1170
+ continue;
1171
+ }
1172
+ if (value !== "*") {
1173
+ if (value === "$" || value === "^") {
1174
+ value = `\\${value}`;
1175
+ }
1176
+ const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
1177
+ if (match) {
1178
+ value += match[0];
1179
+ state.index += match[0].length;
1180
+ }
1181
+ push({ type: "text", value });
1182
+ continue;
1183
+ }
1184
+ if (prev && (prev.type === "globstar" || prev.star === true)) {
1185
+ prev.type = "star";
1186
+ prev.star = true;
1187
+ prev.value += value;
1188
+ prev.output = star;
1189
+ state.backtrack = true;
1190
+ state.globstar = true;
1191
+ consume(value);
1192
+ continue;
1193
+ }
1194
+ let rest = remaining();
1195
+ if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
1196
+ extglobOpen("star", value);
1197
+ continue;
1198
+ }
1199
+ if (prev.type === "star") {
1200
+ if (opts.noglobstar === true) {
1201
+ consume(value);
1202
+ continue;
1203
+ }
1204
+ const prior = prev.prev;
1205
+ const before = prior.prev;
1206
+ const isStart = prior.type === "slash" || prior.type === "bos";
1207
+ const afterStar = before && (before.type === "star" || before.type === "globstar");
1208
+ if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
1209
+ push({ type: "star", value, output: "" });
1210
+ continue;
1211
+ }
1212
+ const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
1213
+ const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
1214
+ if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
1215
+ push({ type: "star", value, output: "" });
1216
+ continue;
1217
+ }
1218
+ while (rest.slice(0, 3) === "/**") {
1219
+ const after = input[state.index + 4];
1220
+ if (after && after !== "/") {
1221
+ break;
1222
+ }
1223
+ rest = rest.slice(3);
1224
+ consume("/**", 3);
1225
+ }
1226
+ if (prior.type === "bos" && eos()) {
1227
+ prev.type = "globstar";
1228
+ prev.value += value;
1229
+ prev.output = globstar(opts);
1230
+ state.output = prev.output;
1231
+ state.globstar = true;
1232
+ consume(value);
1233
+ continue;
1234
+ }
1235
+ if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
1236
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1237
+ prior.output = `(?:${prior.output}`;
1238
+ prev.type = "globstar";
1239
+ prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
1240
+ prev.value += value;
1241
+ state.globstar = true;
1242
+ state.output += prior.output + prev.output;
1243
+ consume(value);
1244
+ continue;
1245
+ }
1246
+ if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
1247
+ const end = rest[1] !== void 0 ? "|$" : "";
1248
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1249
+ prior.output = `(?:${prior.output}`;
1250
+ prev.type = "globstar";
1251
+ prev.output = `${globstar(opts)}${SLASH_LITERAL2}|${SLASH_LITERAL2}${end})`;
1252
+ prev.value += value;
1253
+ state.output += prior.output + prev.output;
1254
+ state.globstar = true;
1255
+ consume(value + advance());
1256
+ push({ type: "slash", value: "/", output: "" });
1257
+ continue;
1258
+ }
1259
+ if (prior.type === "bos" && rest[0] === "/") {
1260
+ prev.type = "globstar";
1261
+ prev.value += value;
1262
+ prev.output = `(?:^|${SLASH_LITERAL2}|${globstar(opts)}${SLASH_LITERAL2})`;
1263
+ state.output = prev.output;
1264
+ state.globstar = true;
1265
+ consume(value + advance());
1266
+ push({ type: "slash", value: "/", output: "" });
1267
+ continue;
1268
+ }
1269
+ state.output = state.output.slice(0, -prev.output.length);
1270
+ prev.type = "globstar";
1271
+ prev.output = globstar(opts);
1272
+ prev.value += value;
1273
+ state.output += prev.output;
1274
+ state.globstar = true;
1275
+ consume(value);
1276
+ continue;
1277
+ }
1278
+ const token = { type: "star", value, output: star };
1279
+ if (opts.bash === true) {
1280
+ token.output = ".*?";
1281
+ if (prev.type === "bos" || prev.type === "slash") {
1282
+ token.output = nodot + token.output;
1283
+ }
1284
+ push(token);
1285
+ continue;
1286
+ }
1287
+ if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
1288
+ token.output = value;
1289
+ push(token);
1290
+ continue;
1291
+ }
1292
+ if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
1293
+ if (prev.type === "dot") {
1294
+ state.output += NO_DOT_SLASH2;
1295
+ prev.output += NO_DOT_SLASH2;
1296
+ } else if (opts.dot === true) {
1297
+ state.output += NO_DOTS_SLASH2;
1298
+ prev.output += NO_DOTS_SLASH2;
1299
+ } else {
1300
+ state.output += nodot;
1301
+ prev.output += nodot;
1302
+ }
1303
+ if (peek() !== "*") {
1304
+ state.output += ONE_CHAR2;
1305
+ prev.output += ONE_CHAR2;
1306
+ }
1307
+ }
1308
+ push(token);
1309
+ }
1310
+ while (state.brackets > 0) {
1311
+ if (opts.strictBrackets === true)
1312
+ throw new SyntaxError(syntaxError("closing", "]"));
1313
+ state.output = utils$2.escapeLast(state.output, "[");
1314
+ decrement("brackets");
1315
+ }
1316
+ while (state.parens > 0) {
1317
+ if (opts.strictBrackets === true)
1318
+ throw new SyntaxError(syntaxError("closing", ")"));
1319
+ state.output = utils$2.escapeLast(state.output, "(");
1320
+ decrement("parens");
1321
+ }
1322
+ while (state.braces > 0) {
1323
+ if (opts.strictBrackets === true)
1324
+ throw new SyntaxError(syntaxError("closing", "}"));
1325
+ state.output = utils$2.escapeLast(state.output, "{");
1326
+ decrement("braces");
1327
+ }
1328
+ if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
1329
+ push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL2}?` });
1330
+ }
1331
+ if (state.backtrack === true) {
1332
+ state.output = "";
1333
+ for (const token of state.tokens) {
1334
+ state.output += token.output != null ? token.output : token.value;
1335
+ if (token.suffix) {
1336
+ state.output += token.suffix;
1337
+ }
1338
+ }
1339
+ }
1340
+ return state;
1341
+ };
1342
+ parse$1.fastpaths = (input, options) => {
1343
+ const opts = { ...options };
1344
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1345
+ const len = input.length;
1346
+ if (len > max) {
1347
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1348
+ }
1349
+ input = REPLACEMENTS[input] || input;
1350
+ const {
1351
+ DOT_LITERAL: DOT_LITERAL2,
1352
+ SLASH_LITERAL: SLASH_LITERAL2,
1353
+ ONE_CHAR: ONE_CHAR2,
1354
+ DOTS_SLASH: DOTS_SLASH2,
1355
+ NO_DOT: NO_DOT2,
1356
+ NO_DOTS: NO_DOTS2,
1357
+ NO_DOTS_SLASH: NO_DOTS_SLASH2,
1358
+ STAR: STAR2,
1359
+ START_ANCHOR: START_ANCHOR2
1360
+ } = constants$1.globChars(opts.windows);
1361
+ const nodot = opts.dot ? NO_DOTS2 : NO_DOT2;
1362
+ const slashDot = opts.dot ? NO_DOTS_SLASH2 : NO_DOT2;
1363
+ const capture = opts.capture ? "" : "?:";
1364
+ const state = { negated: false, prefix: "" };
1365
+ let star = opts.bash === true ? ".*?" : STAR2;
1366
+ if (opts.capture) {
1367
+ star = `(${star})`;
1368
+ }
1369
+ const globstar = (opts2) => {
1370
+ if (opts2.noglobstar === true)
1371
+ return star;
1372
+ return `(${capture}(?:(?!${START_ANCHOR2}${opts2.dot ? DOTS_SLASH2 : DOT_LITERAL2}).)*?)`;
1373
+ };
1374
+ const create = (str) => {
1375
+ switch (str) {
1376
+ case "*":
1377
+ return `${nodot}${ONE_CHAR2}${star}`;
1378
+ case ".*":
1379
+ return `${DOT_LITERAL2}${ONE_CHAR2}${star}`;
1380
+ case "*.*":
1381
+ return `${nodot}${star}${DOT_LITERAL2}${ONE_CHAR2}${star}`;
1382
+ case "*/*":
1383
+ return `${nodot}${star}${SLASH_LITERAL2}${ONE_CHAR2}${slashDot}${star}`;
1384
+ case "**":
1385
+ return nodot + globstar(opts);
1386
+ case "**/*":
1387
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL2})?${slashDot}${ONE_CHAR2}${star}`;
1388
+ case "**/*.*":
1389
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL2})?${slashDot}${star}${DOT_LITERAL2}${ONE_CHAR2}${star}`;
1390
+ case "**/.*":
1391
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL2})?${DOT_LITERAL2}${ONE_CHAR2}${star}`;
1392
+ default: {
1393
+ const match = /^(.*?)\.(\w+)$/.exec(str);
1394
+ if (!match)
1395
+ return;
1396
+ const source2 = create(match[1]);
1397
+ if (!source2)
1398
+ return;
1399
+ return source2 + DOT_LITERAL2 + match[2];
1400
+ }
1401
+ }
1402
+ };
1403
+ const output = utils$2.removePrefix(input, state);
1404
+ let source = create(output);
1405
+ if (source && opts.strictSlashes !== true) {
1406
+ source += `${SLASH_LITERAL2}?`;
1407
+ }
1408
+ return source;
1409
+ };
1410
+ var parse_1 = parse$1;
1411
+ const scan = scan_1;
1412
+ const parse = parse_1;
1413
+ const utils$1 = utils$4;
1414
+ const constants = constants$2;
1415
+ const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
1416
+ const picomatch$2 = (glob, options, returnState = false) => {
1417
+ if (Array.isArray(glob)) {
1418
+ const fns = glob.map((input) => picomatch$2(input, options, returnState));
1419
+ const arrayMatcher = (str) => {
1420
+ for (const isMatch of fns) {
1421
+ const state2 = isMatch(str);
1422
+ if (state2)
1423
+ return state2;
1424
+ }
1425
+ return false;
1426
+ };
1427
+ return arrayMatcher;
1428
+ }
1429
+ const isState = isObject(glob) && glob.tokens && glob.input;
1430
+ if (glob === "" || typeof glob !== "string" && !isState) {
1431
+ throw new TypeError("Expected pattern to be a non-empty string");
1432
+ }
1433
+ const opts = options || {};
1434
+ const posix = opts.windows;
1435
+ const regex = isState ? picomatch$2.compileRe(glob, options) : picomatch$2.makeRe(glob, options, false, true);
1436
+ const state = regex.state;
1437
+ delete regex.state;
1438
+ let isIgnored = () => false;
1439
+ if (opts.ignore) {
1440
+ const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
1441
+ isIgnored = picomatch$2(opts.ignore, ignoreOpts, returnState);
1442
+ }
1443
+ const matcher = (input, returnObject = false) => {
1444
+ const { isMatch, match, output } = picomatch$2.test(input, regex, options, { glob, posix });
1445
+ const result = { glob, state, regex, posix, input, output, match, isMatch };
1446
+ if (typeof opts.onResult === "function") {
1447
+ opts.onResult(result);
1448
+ }
1449
+ if (isMatch === false) {
1450
+ result.isMatch = false;
1451
+ return returnObject ? result : false;
1452
+ }
1453
+ if (isIgnored(input)) {
1454
+ if (typeof opts.onIgnore === "function") {
1455
+ opts.onIgnore(result);
1456
+ }
1457
+ result.isMatch = false;
1458
+ return returnObject ? result : false;
1459
+ }
1460
+ if (typeof opts.onMatch === "function") {
1461
+ opts.onMatch(result);
1462
+ }
1463
+ return returnObject ? result : true;
1464
+ };
1465
+ if (returnState) {
1466
+ matcher.state = state;
1467
+ }
1468
+ return matcher;
1469
+ };
1470
+ picomatch$2.test = (input, regex, options, { glob, posix } = {}) => {
1471
+ if (typeof input !== "string") {
1472
+ throw new TypeError("Expected input to be a string");
1473
+ }
1474
+ if (input === "") {
1475
+ return { isMatch: false, output: "" };
1476
+ }
1477
+ const opts = options || {};
1478
+ const format = opts.format || (posix ? utils$1.toPosixSlashes : null);
1479
+ let match = input === glob;
1480
+ let output = match && format ? format(input) : input;
1481
+ if (match === false) {
1482
+ output = format ? format(input) : input;
1483
+ match = output === glob;
1484
+ }
1485
+ if (match === false || opts.capture === true) {
1486
+ if (opts.matchBase === true || opts.basename === true) {
1487
+ match = picomatch$2.matchBase(input, regex, options, posix);
1488
+ } else {
1489
+ match = regex.exec(output);
1490
+ }
1491
+ }
1492
+ return { isMatch: Boolean(match), match, output };
1493
+ };
1494
+ picomatch$2.matchBase = (input, glob, options) => {
1495
+ const regex = glob instanceof RegExp ? glob : picomatch$2.makeRe(glob, options);
1496
+ return regex.test(utils$1.basename(input));
1497
+ };
1498
+ picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)(str);
1499
+ picomatch$2.parse = (pattern, options) => {
1500
+ if (Array.isArray(pattern))
1501
+ return pattern.map((p) => picomatch$2.parse(p, options));
1502
+ return parse(pattern, { ...options, fastpaths: false });
1503
+ };
1504
+ picomatch$2.scan = (input, options) => scan(input, options);
1505
+ picomatch$2.compileRe = (state, options, returnOutput = false, returnState = false) => {
1506
+ if (returnOutput === true) {
1507
+ return state.output;
1508
+ }
1509
+ const opts = options || {};
1510
+ const prepend = opts.contains ? "" : "^";
1511
+ const append = opts.contains ? "" : "$";
1512
+ let source = `${prepend}(?:${state.output})${append}`;
1513
+ if (state && state.negated === true) {
1514
+ source = `^(?!${source}).*$`;
1515
+ }
1516
+ const regex = picomatch$2.toRegex(source, options);
1517
+ if (returnState === true) {
1518
+ regex.state = state;
1519
+ }
1520
+ return regex;
1521
+ };
1522
+ picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
1523
+ if (!input || typeof input !== "string") {
1524
+ throw new TypeError("Expected a non-empty string");
1525
+ }
1526
+ let parsed = { negated: false, fastpaths: true };
1527
+ if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
1528
+ parsed.output = parse.fastpaths(input, options);
1529
+ }
1530
+ if (!parsed.output) {
1531
+ parsed = parse(input, options);
1532
+ }
1533
+ return picomatch$2.compileRe(parsed, options, returnOutput, returnState);
1534
+ };
1535
+ picomatch$2.toRegex = (source, options) => {
1536
+ try {
1537
+ const opts = options || {};
1538
+ return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
1539
+ } catch (err) {
1540
+ if (options && options.debug === true)
1541
+ throw err;
1542
+ return /$^/;
1543
+ }
1544
+ };
1545
+ picomatch$2.constants = constants;
1546
+ var picomatch_1$1 = picomatch$2;
1547
+ const pico = picomatch_1$1;
1548
+ const utils = utils$4;
1549
+ function picomatch(glob, options, returnState = false) {
1550
+ if (options && (options.windows === null || options.windows === void 0)) {
1551
+ options = { ...options, windows: utils.isWindows() };
1552
+ }
1553
+ return pico(glob, options, returnState);
1554
+ }
1555
+ Object.assign(picomatch, pico);
1556
+ var picomatch_1 = picomatch;
1557
+ const picomatch$1 = /* @__PURE__ */ getDefaultExportFromCjs(picomatch_1);
60
1558
  function assertShape(value, yupSchema, errorMessage) {
61
1559
  const shape = yupSchema(yup__namespace);
62
1560
  try {
@@ -210,10 +1708,10 @@
210
1708
  const templateInfo = this.getTemplatesForCollectable(collection);
211
1709
  switch (templateInfo.type) {
212
1710
  case "object":
213
- extraFields["fields"] = templateInfo.template.fields;
1711
+ extraFields.fields = templateInfo.template.fields;
214
1712
  break;
215
1713
  case "union":
216
- extraFields["templates"] = templateInfo.templates;
1714
+ extraFields.templates = templateInfo.templates;
217
1715
  break;
218
1716
  }
219
1717
  return {
@@ -239,7 +1737,7 @@
239
1737
  }
240
1738
  if (((_a = collection == null ? void 0 : collection.match) == null ? void 0 : _a.include) || ((_b = collection == null ? void 0 : collection.match) == null ? void 0 : _b.exclude)) {
241
1739
  const matches = this.getMatches({ collection });
242
- const match = picomatch.isMatch(normalizedPath, matches);
1740
+ const match = picomatch$1.isMatch(normalizedPath, matches);
243
1741
  if (!match) {
244
1742
  return false;
245
1743
  }
@@ -264,8 +1762,11 @@
264
1762
  }
265
1763
  };
266
1764
  this.getCollectionAndTemplateByFullPath = (filepath, templateName) => {
267
- let template;
268
1765
  const collection = this.getCollectionByFullPath(filepath);
1766
+ if (!collection) {
1767
+ return void 0;
1768
+ }
1769
+ let template;
269
1770
  const templates = this.getTemplatesForCollectable(collection);
270
1771
  if (templates.type === "union") {
271
1772
  if (templateName) {
@@ -301,7 +1802,7 @@
301
1802
  switch (templateInfo.type) {
302
1803
  case "object":
303
1804
  return templateInfo.template;
304
- case "union":
1805
+ case "union": {
305
1806
  assertShape(
306
1807
  data,
307
1808
  (yup2) => yup2.object({ _template: yup2.string().required() })
@@ -315,6 +1816,7 @@
315
1816
  );
316
1817
  }
317
1818
  return template;
1819
+ }
318
1820
  }
319
1821
  };
320
1822
  this.transformPayload = (collectionName, payload) => {
@@ -324,11 +1826,11 @@
324
1826
  if (typeof template2 === "string") {
325
1827
  throw new Error("Global templates not supported");
326
1828
  }
327
- return payload["_template"] === template2.name;
1829
+ return (payload == null ? void 0 : payload._template) === template2.name;
328
1830
  });
329
1831
  if (!template) {
330
1832
  console.error(payload);
331
- throw new Error(`Unable to find template for payload`);
1833
+ throw new Error("Unable to find template for payload");
332
1834
  }
333
1835
  if (typeof template === "string") {
334
1836
  throw new Error("Global templates not supported");
@@ -338,19 +1840,19 @@
338
1840
  [template.name]: this.transformCollectablePayload(payload, template)
339
1841
  }
340
1842
  };
341
- } else {
342
- return {
343
- [collectionName]: this.transformCollectablePayload(payload, collection)
344
- };
345
1843
  }
1844
+ return {
1845
+ [collectionName]: this.transformCollectablePayload(payload, collection)
1846
+ };
346
1847
  };
347
1848
  this.transformCollectablePayload = (payload, collection) => {
348
1849
  const accumulator = {};
349
1850
  Object.entries(payload).forEach(([key, value]) => {
1851
+ var _a;
350
1852
  if (typeof collection.fields === "string") {
351
1853
  throw new Error("Global templates not supported");
352
1854
  }
353
- const field = collection.fields.find((field2) => {
1855
+ const field = (_a = collection == null ? void 0 : collection.fields) == null ? void 0 : _a.find((field2) => {
354
1856
  if (typeof field2 === "string") {
355
1857
  throw new Error("Global templates not supported");
356
1858
  }
@@ -381,6 +1883,9 @@
381
1883
  if (typeof template === "string") {
382
1884
  throw new Error("Global templates not supported");
383
1885
  }
1886
+ if (!template) {
1887
+ throw new Error(`Expected to find template named '${_template}'`);
1888
+ }
384
1889
  return {
385
1890
  [_template]: this.transformCollectablePayload(rest, template)
386
1891
  };
@@ -529,7 +2034,8 @@
529
2034
  files
530
2035
  }) {
531
2036
  const matches = this.getMatches({ collection });
532
- const matchedFiles = picomatch(files, matches);
2037
+ const matcher = picomatch$1(matches);
2038
+ const matchedFiles = files.filter((file) => matcher(file));
533
2039
  return matchedFiles;
534
2040
  }
535
2041
  }
@@ -594,7 +2100,7 @@
594
2100
  component: "select",
595
2101
  ...field,
596
2102
  ...extraFields,
597
- options: field.ui && field.ui.component !== "select" ? field.options : [{ label: `Choose an option`, value: "" }, ...field.options]
2103
+ options: field.ui && field.ui.component !== "select" ? field.options : [{ label: "Choose an option", value: "" }, ...field.options]
598
2104
  };
599
2105
  }
600
2106
  if (field.list) {
@@ -614,7 +2120,7 @@
614
2120
  ...field,
615
2121
  ...extraFields
616
2122
  };
617
- case "object":
2123
+ case "object": {
618
2124
  const templateInfo = schema.getTemplatesForCollectable(field);
619
2125
  if (templateInfo.type === "object") {
620
2126
  return {
@@ -652,6 +2158,7 @@
652
2158
  } else {
653
2159
  throw new Error(`Unknown object for resolveField function`);
654
2160
  }
2161
+ }
655
2162
  case "rich-text":
656
2163
  const templates = {};
657
2164
  (_a = field.templates) == null ? void 0 : _a.forEach((template) => {
@@ -921,7 +2428,7 @@ If you need to use this value in your content you can use the \`nameOverride\` p
921
2428
  };
922
2429
  }
923
2430
  return {
924
- message: issue.message
2431
+ message: issue.message || ""
925
2432
  };
926
2433
  }
927
2434
  }
@@ -1188,9 +2695,8 @@ ${JSON.stringify(
1188
2695
  if (e instanceof z.ZodError) {
1189
2696
  const errors = parseZodError({ zodError: e });
1190
2697
  throw new TinaSchemaValidationError(errors.join(", \n"));
1191
- } else {
1192
- throw new Error(e);
1193
2698
  }
2699
+ throw new Error(e);
1194
2700
  }
1195
2701
  };
1196
2702
  exports2.NAMER = NAMER;