@tinacms/schema-tools 2.8.2 → 2.9.0

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