vite-plugin-storybook-nextjs 3.0.3--canary.68.b6ee25e.0 → 3.0.4--canary.5f06d44.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
@@ -21,6 +21,7 @@ import nextServerConfig from 'next/dist/server/config.js';
21
21
  import { PHASE_DEVELOPMENT_SERVER, PHASE_TEST, PHASE_PRODUCTION_BUILD } from 'next/dist/shared/lib/constants.js';
22
22
  import MagicString from 'magic-string';
23
23
  import { decode, encode } from 'querystring';
24
+ import { win32 as win32$1, posix as posix$1, isAbsolute as isAbsolute$1, resolve as resolve$1 } from 'path';
24
25
  import { imageSize } from 'image-size';
25
26
 
26
27
  var __create = Object.create;
@@ -49,8 +50,1520 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
49
50
  mod
50
51
  ));
51
52
 
52
- // node_modules/.pnpm/semver@7.7.3/node_modules/semver/internal/constants.js
53
+ // node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js
53
54
  var require_constants = __commonJS({
55
+ "node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js"(exports, module) {
56
+ var WIN_SLASH = "\\\\/";
57
+ var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
58
+ var DOT_LITERAL = "\\.";
59
+ var PLUS_LITERAL = "\\+";
60
+ var QMARK_LITERAL = "\\?";
61
+ var SLASH_LITERAL = "\\/";
62
+ var ONE_CHAR = "(?=.)";
63
+ var QMARK = "[^/]";
64
+ var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
65
+ var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
66
+ var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
67
+ var NO_DOT = `(?!${DOT_LITERAL})`;
68
+ var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
69
+ var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
70
+ var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
71
+ var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
72
+ var STAR = `${QMARK}*?`;
73
+ var SEP = "/";
74
+ var POSIX_CHARS = {
75
+ DOT_LITERAL,
76
+ PLUS_LITERAL,
77
+ QMARK_LITERAL,
78
+ SLASH_LITERAL,
79
+ ONE_CHAR,
80
+ QMARK,
81
+ END_ANCHOR,
82
+ DOTS_SLASH,
83
+ NO_DOT,
84
+ NO_DOTS,
85
+ NO_DOT_SLASH,
86
+ NO_DOTS_SLASH,
87
+ QMARK_NO_DOT,
88
+ STAR,
89
+ START_ANCHOR,
90
+ SEP
91
+ };
92
+ var WINDOWS_CHARS = {
93
+ ...POSIX_CHARS,
94
+ SLASH_LITERAL: `[${WIN_SLASH}]`,
95
+ QMARK: WIN_NO_SLASH,
96
+ STAR: `${WIN_NO_SLASH}*?`,
97
+ DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
98
+ NO_DOT: `(?!${DOT_LITERAL})`,
99
+ NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
100
+ NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
101
+ NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
102
+ QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
103
+ START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
104
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
105
+ SEP: "\\"
106
+ };
107
+ var POSIX_REGEX_SOURCE = {
108
+ alnum: "a-zA-Z0-9",
109
+ alpha: "a-zA-Z",
110
+ ascii: "\\x00-\\x7F",
111
+ blank: " \\t",
112
+ cntrl: "\\x00-\\x1F\\x7F",
113
+ digit: "0-9",
114
+ graph: "\\x21-\\x7E",
115
+ lower: "a-z",
116
+ print: "\\x20-\\x7E ",
117
+ punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
118
+ space: " \\t\\r\\n\\v\\f",
119
+ upper: "A-Z",
120
+ word: "A-Za-z0-9_",
121
+ xdigit: "A-Fa-f0-9"
122
+ };
123
+ module.exports = {
124
+ MAX_LENGTH: 1024 * 64,
125
+ POSIX_REGEX_SOURCE,
126
+ // regular expressions
127
+ REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
128
+ REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
129
+ REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
130
+ REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
131
+ REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
132
+ REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
133
+ // Replace globs with equivalent patterns to reduce parsing time.
134
+ REPLACEMENTS: {
135
+ __proto__: null,
136
+ "***": "*",
137
+ "**/**": "**",
138
+ "**/**/**": "**"
139
+ },
140
+ // Digits
141
+ CHAR_0: 48,
142
+ /* 0 */
143
+ CHAR_9: 57,
144
+ /* 9 */
145
+ // Alphabet chars.
146
+ CHAR_UPPERCASE_A: 65,
147
+ /* A */
148
+ CHAR_LOWERCASE_A: 97,
149
+ /* a */
150
+ CHAR_UPPERCASE_Z: 90,
151
+ /* Z */
152
+ CHAR_LOWERCASE_Z: 122,
153
+ /* z */
154
+ CHAR_LEFT_PARENTHESES: 40,
155
+ /* ( */
156
+ CHAR_RIGHT_PARENTHESES: 41,
157
+ /* ) */
158
+ CHAR_ASTERISK: 42,
159
+ /* * */
160
+ // Non-alphabetic chars.
161
+ CHAR_AMPERSAND: 38,
162
+ /* & */
163
+ CHAR_AT: 64,
164
+ /* @ */
165
+ CHAR_BACKWARD_SLASH: 92,
166
+ /* \ */
167
+ CHAR_CARRIAGE_RETURN: 13,
168
+ /* \r */
169
+ CHAR_CIRCUMFLEX_ACCENT: 94,
170
+ /* ^ */
171
+ CHAR_COLON: 58,
172
+ /* : */
173
+ CHAR_COMMA: 44,
174
+ /* , */
175
+ CHAR_DOT: 46,
176
+ /* . */
177
+ CHAR_DOUBLE_QUOTE: 34,
178
+ /* " */
179
+ CHAR_EQUAL: 61,
180
+ /* = */
181
+ CHAR_EXCLAMATION_MARK: 33,
182
+ /* ! */
183
+ CHAR_FORM_FEED: 12,
184
+ /* \f */
185
+ CHAR_FORWARD_SLASH: 47,
186
+ /* / */
187
+ CHAR_GRAVE_ACCENT: 96,
188
+ /* ` */
189
+ CHAR_HASH: 35,
190
+ /* # */
191
+ CHAR_HYPHEN_MINUS: 45,
192
+ /* - */
193
+ CHAR_LEFT_ANGLE_BRACKET: 60,
194
+ /* < */
195
+ CHAR_LEFT_CURLY_BRACE: 123,
196
+ /* { */
197
+ CHAR_LEFT_SQUARE_BRACKET: 91,
198
+ /* [ */
199
+ CHAR_LINE_FEED: 10,
200
+ /* \n */
201
+ CHAR_NO_BREAK_SPACE: 160,
202
+ /* \u00A0 */
203
+ CHAR_PERCENT: 37,
204
+ /* % */
205
+ CHAR_PLUS: 43,
206
+ /* + */
207
+ CHAR_QUESTION_MARK: 63,
208
+ /* ? */
209
+ CHAR_RIGHT_ANGLE_BRACKET: 62,
210
+ /* > */
211
+ CHAR_RIGHT_CURLY_BRACE: 125,
212
+ /* } */
213
+ CHAR_RIGHT_SQUARE_BRACKET: 93,
214
+ /* ] */
215
+ CHAR_SEMICOLON: 59,
216
+ /* ; */
217
+ CHAR_SINGLE_QUOTE: 39,
218
+ /* ' */
219
+ CHAR_SPACE: 32,
220
+ /* */
221
+ CHAR_TAB: 9,
222
+ /* \t */
223
+ CHAR_UNDERSCORE: 95,
224
+ /* _ */
225
+ CHAR_VERTICAL_LINE: 124,
226
+ /* | */
227
+ CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
228
+ /* \uFEFF */
229
+ /**
230
+ * Create EXTGLOB_CHARS
231
+ */
232
+ extglobChars(chars) {
233
+ return {
234
+ "!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
235
+ "?": { type: "qmark", open: "(?:", close: ")?" },
236
+ "+": { type: "plus", open: "(?:", close: ")+" },
237
+ "*": { type: "star", open: "(?:", close: ")*" },
238
+ "@": { type: "at", open: "(?:", close: ")" }
239
+ };
240
+ },
241
+ /**
242
+ * Create GLOB_CHARS
243
+ */
244
+ globChars(win323) {
245
+ return win323 === true ? WINDOWS_CHARS : POSIX_CHARS;
246
+ }
247
+ };
248
+ }
249
+ });
250
+
251
+ // node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js
252
+ var require_utils = __commonJS({
253
+ "node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js"(exports) {
254
+ var {
255
+ REGEX_BACKSLASH,
256
+ REGEX_REMOVE_BACKSLASH,
257
+ REGEX_SPECIAL_CHARS,
258
+ REGEX_SPECIAL_CHARS_GLOBAL
259
+ } = require_constants();
260
+ exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
261
+ exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
262
+ exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
263
+ exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
264
+ exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
265
+ exports.isWindows = () => {
266
+ if (typeof navigator !== "undefined" && navigator.platform) {
267
+ const platform = navigator.platform.toLowerCase();
268
+ return platform === "win32" || platform === "windows";
269
+ }
270
+ if (typeof process !== "undefined" && process.platform) {
271
+ return process.platform === "win32";
272
+ }
273
+ return false;
274
+ };
275
+ exports.removeBackslashes = (str) => {
276
+ return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
277
+ return match === "\\" ? "" : match;
278
+ });
279
+ };
280
+ exports.escapeLast = (input, char, lastIdx) => {
281
+ const idx = input.lastIndexOf(char, lastIdx);
282
+ if (idx === -1) return input;
283
+ if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
284
+ return `${input.slice(0, idx)}\\${input.slice(idx)}`;
285
+ };
286
+ exports.removePrefix = (input, state = {}) => {
287
+ let output = input;
288
+ if (output.startsWith("./")) {
289
+ output = output.slice(2);
290
+ state.prefix = "./";
291
+ }
292
+ return output;
293
+ };
294
+ exports.wrapOutput = (input, state = {}, options = {}) => {
295
+ const prepend = options.contains ? "" : "^";
296
+ const append = options.contains ? "" : "$";
297
+ let output = `${prepend}(?:${input})${append}`;
298
+ if (state.negated === true) {
299
+ output = `(?:^(?!${output}).*$)`;
300
+ }
301
+ return output;
302
+ };
303
+ exports.basename = (path, { windows } = {}) => {
304
+ const segs = path.split(windows ? /[\\/]/ : "/");
305
+ const last = segs[segs.length - 1];
306
+ if (last === "") {
307
+ return segs[segs.length - 2];
308
+ }
309
+ return last;
310
+ };
311
+ }
312
+ });
313
+
314
+ // node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js
315
+ var require_scan = __commonJS({
316
+ "node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js"(exports, module) {
317
+ var utils = require_utils();
318
+ var {
319
+ CHAR_ASTERISK,
320
+ /* * */
321
+ CHAR_AT,
322
+ /* @ */
323
+ CHAR_BACKWARD_SLASH,
324
+ /* \ */
325
+ CHAR_COMMA,
326
+ /* , */
327
+ CHAR_DOT,
328
+ /* . */
329
+ CHAR_EXCLAMATION_MARK,
330
+ /* ! */
331
+ CHAR_FORWARD_SLASH,
332
+ /* / */
333
+ CHAR_LEFT_CURLY_BRACE,
334
+ /* { */
335
+ CHAR_LEFT_PARENTHESES,
336
+ /* ( */
337
+ CHAR_LEFT_SQUARE_BRACKET,
338
+ /* [ */
339
+ CHAR_PLUS,
340
+ /* + */
341
+ CHAR_QUESTION_MARK,
342
+ /* ? */
343
+ CHAR_RIGHT_CURLY_BRACE,
344
+ /* } */
345
+ CHAR_RIGHT_PARENTHESES,
346
+ /* ) */
347
+ CHAR_RIGHT_SQUARE_BRACKET
348
+ /* ] */
349
+ } = require_constants();
350
+ var isPathSeparator = (code) => {
351
+ return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
352
+ };
353
+ var depth = (token) => {
354
+ if (token.isPrefix !== true) {
355
+ token.depth = token.isGlobstar ? Infinity : 1;
356
+ }
357
+ };
358
+ var scan = (input, options) => {
359
+ const opts = options || {};
360
+ const length = input.length - 1;
361
+ const scanToEnd = opts.parts === true || opts.scanToEnd === true;
362
+ const slashes = [];
363
+ const tokens = [];
364
+ const parts = [];
365
+ let str = input;
366
+ let index = -1;
367
+ let start = 0;
368
+ let lastIndex = 0;
369
+ let isBrace = false;
370
+ let isBracket = false;
371
+ let isGlob = false;
372
+ let isExtglob = false;
373
+ let isGlobstar = false;
374
+ let braceEscaped = false;
375
+ let backslashes = false;
376
+ let negated = false;
377
+ let negatedExtglob = false;
378
+ let finished = false;
379
+ let braces = 0;
380
+ let prev;
381
+ let code;
382
+ let token = { value: "", depth: 0, isGlob: false };
383
+ const eos = () => index >= length;
384
+ const peek = () => str.charCodeAt(index + 1);
385
+ const advance = () => {
386
+ prev = code;
387
+ return str.charCodeAt(++index);
388
+ };
389
+ while (index < length) {
390
+ code = advance();
391
+ let next;
392
+ if (code === CHAR_BACKWARD_SLASH) {
393
+ backslashes = token.backslashes = true;
394
+ code = advance();
395
+ if (code === CHAR_LEFT_CURLY_BRACE) {
396
+ braceEscaped = true;
397
+ }
398
+ continue;
399
+ }
400
+ if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
401
+ braces++;
402
+ while (eos() !== true && (code = advance())) {
403
+ if (code === CHAR_BACKWARD_SLASH) {
404
+ backslashes = token.backslashes = true;
405
+ advance();
406
+ continue;
407
+ }
408
+ if (code === CHAR_LEFT_CURLY_BRACE) {
409
+ braces++;
410
+ continue;
411
+ }
412
+ if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
413
+ isBrace = token.isBrace = true;
414
+ isGlob = token.isGlob = true;
415
+ finished = true;
416
+ if (scanToEnd === true) {
417
+ continue;
418
+ }
419
+ break;
420
+ }
421
+ if (braceEscaped !== true && code === CHAR_COMMA) {
422
+ isBrace = token.isBrace = true;
423
+ isGlob = token.isGlob = true;
424
+ finished = true;
425
+ if (scanToEnd === true) {
426
+ continue;
427
+ }
428
+ break;
429
+ }
430
+ if (code === CHAR_RIGHT_CURLY_BRACE) {
431
+ braces--;
432
+ if (braces === 0) {
433
+ braceEscaped = false;
434
+ isBrace = token.isBrace = true;
435
+ finished = true;
436
+ break;
437
+ }
438
+ }
439
+ }
440
+ if (scanToEnd === true) {
441
+ continue;
442
+ }
443
+ break;
444
+ }
445
+ if (code === CHAR_FORWARD_SLASH) {
446
+ slashes.push(index);
447
+ tokens.push(token);
448
+ token = { value: "", depth: 0, isGlob: false };
449
+ if (finished === true) continue;
450
+ if (prev === CHAR_DOT && index === start + 1) {
451
+ start += 2;
452
+ continue;
453
+ }
454
+ lastIndex = index + 1;
455
+ continue;
456
+ }
457
+ if (opts.noext !== true) {
458
+ const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
459
+ if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
460
+ isGlob = token.isGlob = true;
461
+ isExtglob = token.isExtglob = true;
462
+ finished = true;
463
+ if (code === CHAR_EXCLAMATION_MARK && index === start) {
464
+ negatedExtglob = true;
465
+ }
466
+ if (scanToEnd === true) {
467
+ while (eos() !== true && (code = advance())) {
468
+ if (code === CHAR_BACKWARD_SLASH) {
469
+ backslashes = token.backslashes = true;
470
+ code = advance();
471
+ continue;
472
+ }
473
+ if (code === CHAR_RIGHT_PARENTHESES) {
474
+ isGlob = token.isGlob = true;
475
+ finished = true;
476
+ break;
477
+ }
478
+ }
479
+ continue;
480
+ }
481
+ break;
482
+ }
483
+ }
484
+ if (code === CHAR_ASTERISK) {
485
+ if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
486
+ isGlob = token.isGlob = true;
487
+ finished = true;
488
+ if (scanToEnd === true) {
489
+ continue;
490
+ }
491
+ break;
492
+ }
493
+ if (code === CHAR_QUESTION_MARK) {
494
+ isGlob = token.isGlob = true;
495
+ finished = true;
496
+ if (scanToEnd === true) {
497
+ continue;
498
+ }
499
+ break;
500
+ }
501
+ if (code === CHAR_LEFT_SQUARE_BRACKET) {
502
+ while (eos() !== true && (next = advance())) {
503
+ if (next === CHAR_BACKWARD_SLASH) {
504
+ backslashes = token.backslashes = true;
505
+ advance();
506
+ continue;
507
+ }
508
+ if (next === CHAR_RIGHT_SQUARE_BRACKET) {
509
+ isBracket = token.isBracket = true;
510
+ isGlob = token.isGlob = true;
511
+ finished = true;
512
+ break;
513
+ }
514
+ }
515
+ if (scanToEnd === true) {
516
+ continue;
517
+ }
518
+ break;
519
+ }
520
+ if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
521
+ negated = token.negated = true;
522
+ start++;
523
+ continue;
524
+ }
525
+ if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
526
+ isGlob = token.isGlob = true;
527
+ if (scanToEnd === true) {
528
+ while (eos() !== true && (code = advance())) {
529
+ if (code === CHAR_LEFT_PARENTHESES) {
530
+ backslashes = token.backslashes = true;
531
+ code = advance();
532
+ continue;
533
+ }
534
+ if (code === CHAR_RIGHT_PARENTHESES) {
535
+ finished = true;
536
+ break;
537
+ }
538
+ }
539
+ continue;
540
+ }
541
+ break;
542
+ }
543
+ if (isGlob === true) {
544
+ finished = true;
545
+ if (scanToEnd === true) {
546
+ continue;
547
+ }
548
+ break;
549
+ }
550
+ }
551
+ if (opts.noext === true) {
552
+ isExtglob = false;
553
+ isGlob = false;
554
+ }
555
+ let base = str;
556
+ let prefix = "";
557
+ let glob = "";
558
+ if (start > 0) {
559
+ prefix = str.slice(0, start);
560
+ str = str.slice(start);
561
+ lastIndex -= start;
562
+ }
563
+ if (base && isGlob === true && lastIndex > 0) {
564
+ base = str.slice(0, lastIndex);
565
+ glob = str.slice(lastIndex);
566
+ } else if (isGlob === true) {
567
+ base = "";
568
+ glob = str;
569
+ } else {
570
+ base = str;
571
+ }
572
+ if (base && base !== "" && base !== "/" && base !== str) {
573
+ if (isPathSeparator(base.charCodeAt(base.length - 1))) {
574
+ base = base.slice(0, -1);
575
+ }
576
+ }
577
+ if (opts.unescape === true) {
578
+ if (glob) glob = utils.removeBackslashes(glob);
579
+ if (base && backslashes === true) {
580
+ base = utils.removeBackslashes(base);
581
+ }
582
+ }
583
+ const state = {
584
+ prefix,
585
+ input,
586
+ start,
587
+ base,
588
+ glob,
589
+ isBrace,
590
+ isBracket,
591
+ isGlob,
592
+ isExtglob,
593
+ isGlobstar,
594
+ negated,
595
+ negatedExtglob
596
+ };
597
+ if (opts.tokens === true) {
598
+ state.maxDepth = 0;
599
+ if (!isPathSeparator(code)) {
600
+ tokens.push(token);
601
+ }
602
+ state.tokens = tokens;
603
+ }
604
+ if (opts.parts === true || opts.tokens === true) {
605
+ let prevIndex;
606
+ for (let idx = 0; idx < slashes.length; idx++) {
607
+ const n = prevIndex ? prevIndex + 1 : start;
608
+ const i = slashes[idx];
609
+ const value = input.slice(n, i);
610
+ if (opts.tokens) {
611
+ if (idx === 0 && start !== 0) {
612
+ tokens[idx].isPrefix = true;
613
+ tokens[idx].value = prefix;
614
+ } else {
615
+ tokens[idx].value = value;
616
+ }
617
+ depth(tokens[idx]);
618
+ state.maxDepth += tokens[idx].depth;
619
+ }
620
+ if (idx !== 0 || value !== "") {
621
+ parts.push(value);
622
+ }
623
+ prevIndex = i;
624
+ }
625
+ if (prevIndex && prevIndex + 1 < input.length) {
626
+ const value = input.slice(prevIndex + 1);
627
+ parts.push(value);
628
+ if (opts.tokens) {
629
+ tokens[tokens.length - 1].value = value;
630
+ depth(tokens[tokens.length - 1]);
631
+ state.maxDepth += tokens[tokens.length - 1].depth;
632
+ }
633
+ }
634
+ state.slashes = slashes;
635
+ state.parts = parts;
636
+ }
637
+ return state;
638
+ };
639
+ module.exports = scan;
640
+ }
641
+ });
642
+
643
+ // node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js
644
+ var require_parse = __commonJS({
645
+ "node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js"(exports, module) {
646
+ var constants = require_constants();
647
+ var utils = require_utils();
648
+ var {
649
+ MAX_LENGTH,
650
+ POSIX_REGEX_SOURCE,
651
+ REGEX_NON_SPECIAL_CHARS,
652
+ REGEX_SPECIAL_CHARS_BACKREF,
653
+ REPLACEMENTS
654
+ } = constants;
655
+ var expandRange = (args, options) => {
656
+ if (typeof options.expandRange === "function") {
657
+ return options.expandRange(...args, options);
658
+ }
659
+ args.sort();
660
+ const value = `[${args.join("-")}]`;
661
+ try {
662
+ new RegExp(value);
663
+ } catch (ex) {
664
+ return args.map((v) => utils.escapeRegex(v)).join("..");
665
+ }
666
+ return value;
667
+ };
668
+ var syntaxError = (type, char) => {
669
+ return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
670
+ };
671
+ var parse2 = (input, options) => {
672
+ if (typeof input !== "string") {
673
+ throw new TypeError("Expected a string");
674
+ }
675
+ input = REPLACEMENTS[input] || input;
676
+ const opts = { ...options };
677
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
678
+ let len = input.length;
679
+ if (len > max) {
680
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
681
+ }
682
+ const bos = { type: "bos", value: "", output: opts.prepend || "" };
683
+ const tokens = [bos];
684
+ const capture = opts.capture ? "" : "?:";
685
+ const PLATFORM_CHARS = constants.globChars(opts.windows);
686
+ const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
687
+ const {
688
+ DOT_LITERAL,
689
+ PLUS_LITERAL,
690
+ SLASH_LITERAL,
691
+ ONE_CHAR,
692
+ DOTS_SLASH,
693
+ NO_DOT,
694
+ NO_DOT_SLASH,
695
+ NO_DOTS_SLASH,
696
+ QMARK,
697
+ QMARK_NO_DOT,
698
+ STAR,
699
+ START_ANCHOR
700
+ } = PLATFORM_CHARS;
701
+ const globstar = (opts2) => {
702
+ return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
703
+ };
704
+ const nodot = opts.dot ? "" : NO_DOT;
705
+ const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
706
+ let star = opts.bash === true ? globstar(opts) : STAR;
707
+ if (opts.capture) {
708
+ star = `(${star})`;
709
+ }
710
+ if (typeof opts.noext === "boolean") {
711
+ opts.noextglob = opts.noext;
712
+ }
713
+ const state = {
714
+ input,
715
+ index: -1,
716
+ start: 0,
717
+ dot: opts.dot === true,
718
+ consumed: "",
719
+ output: "",
720
+ prefix: "",
721
+ backtrack: false,
722
+ negated: false,
723
+ brackets: 0,
724
+ braces: 0,
725
+ parens: 0,
726
+ quotes: 0,
727
+ globstar: false,
728
+ tokens
729
+ };
730
+ input = utils.removePrefix(input, state);
731
+ len = input.length;
732
+ const extglobs = [];
733
+ const braces = [];
734
+ const stack = [];
735
+ let prev = bos;
736
+ let value;
737
+ const eos = () => state.index === len - 1;
738
+ const peek = state.peek = (n = 1) => input[state.index + n];
739
+ const advance = state.advance = () => input[++state.index] || "";
740
+ const remaining = () => input.slice(state.index + 1);
741
+ const consume = (value2 = "", num = 0) => {
742
+ state.consumed += value2;
743
+ state.index += num;
744
+ };
745
+ const append = (token) => {
746
+ state.output += token.output != null ? token.output : token.value;
747
+ consume(token.value);
748
+ };
749
+ const negate = () => {
750
+ let count = 1;
751
+ while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
752
+ advance();
753
+ state.start++;
754
+ count++;
755
+ }
756
+ if (count % 2 === 0) {
757
+ return false;
758
+ }
759
+ state.negated = true;
760
+ state.start++;
761
+ return true;
762
+ };
763
+ const increment = (type) => {
764
+ state[type]++;
765
+ stack.push(type);
766
+ };
767
+ const decrement = (type) => {
768
+ state[type]--;
769
+ stack.pop();
770
+ };
771
+ const push = (tok) => {
772
+ if (prev.type === "globstar") {
773
+ const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
774
+ const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
775
+ if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
776
+ state.output = state.output.slice(0, -prev.output.length);
777
+ prev.type = "star";
778
+ prev.value = "*";
779
+ prev.output = star;
780
+ state.output += prev.output;
781
+ }
782
+ }
783
+ if (extglobs.length && tok.type !== "paren") {
784
+ extglobs[extglobs.length - 1].inner += tok.value;
785
+ }
786
+ if (tok.value || tok.output) append(tok);
787
+ if (prev && prev.type === "text" && tok.type === "text") {
788
+ prev.output = (prev.output || prev.value) + tok.value;
789
+ prev.value += tok.value;
790
+ return;
791
+ }
792
+ tok.prev = prev;
793
+ tokens.push(tok);
794
+ prev = tok;
795
+ };
796
+ const extglobOpen = (type, value2) => {
797
+ const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
798
+ token.prev = prev;
799
+ token.parens = state.parens;
800
+ token.output = state.output;
801
+ const output = (opts.capture ? "(" : "") + token.open;
802
+ increment("parens");
803
+ push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
804
+ push({ type: "paren", extglob: true, value: advance(), output });
805
+ extglobs.push(token);
806
+ };
807
+ const extglobClose = (token) => {
808
+ let output = token.close + (opts.capture ? ")" : "");
809
+ let rest;
810
+ if (token.type === "negate") {
811
+ let extglobStar = star;
812
+ if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
813
+ extglobStar = globstar(opts);
814
+ }
815
+ if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
816
+ output = token.close = `)$))${extglobStar}`;
817
+ }
818
+ if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
819
+ const expression = parse2(rest, { ...options, fastpaths: false }).output;
820
+ output = token.close = `)${expression})${extglobStar})`;
821
+ }
822
+ if (token.prev.type === "bos") {
823
+ state.negatedExtglob = true;
824
+ }
825
+ }
826
+ push({ type: "paren", extglob: true, value, output });
827
+ decrement("parens");
828
+ };
829
+ if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
830
+ let backslashes = false;
831
+ let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
832
+ if (first === "\\") {
833
+ backslashes = true;
834
+ return m;
835
+ }
836
+ if (first === "?") {
837
+ if (esc) {
838
+ return esc + first + (rest ? QMARK.repeat(rest.length) : "");
839
+ }
840
+ if (index === 0) {
841
+ return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
842
+ }
843
+ return QMARK.repeat(chars.length);
844
+ }
845
+ if (first === ".") {
846
+ return DOT_LITERAL.repeat(chars.length);
847
+ }
848
+ if (first === "*") {
849
+ if (esc) {
850
+ return esc + first + (rest ? star : "");
851
+ }
852
+ return star;
853
+ }
854
+ return esc ? m : `\\${m}`;
855
+ });
856
+ if (backslashes === true) {
857
+ if (opts.unescape === true) {
858
+ output = output.replace(/\\/g, "");
859
+ } else {
860
+ output = output.replace(/\\+/g, (m) => {
861
+ return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
862
+ });
863
+ }
864
+ }
865
+ if (output === input && opts.contains === true) {
866
+ state.output = input;
867
+ return state;
868
+ }
869
+ state.output = utils.wrapOutput(output, state, options);
870
+ return state;
871
+ }
872
+ while (!eos()) {
873
+ value = advance();
874
+ if (value === "\0") {
875
+ continue;
876
+ }
877
+ if (value === "\\") {
878
+ const next = peek();
879
+ if (next === "/" && opts.bash !== true) {
880
+ continue;
881
+ }
882
+ if (next === "." || next === ";") {
883
+ continue;
884
+ }
885
+ if (!next) {
886
+ value += "\\";
887
+ push({ type: "text", value });
888
+ continue;
889
+ }
890
+ const match = /^\\+/.exec(remaining());
891
+ let slashes = 0;
892
+ if (match && match[0].length > 2) {
893
+ slashes = match[0].length;
894
+ state.index += slashes;
895
+ if (slashes % 2 !== 0) {
896
+ value += "\\";
897
+ }
898
+ }
899
+ if (opts.unescape === true) {
900
+ value = advance();
901
+ } else {
902
+ value += advance();
903
+ }
904
+ if (state.brackets === 0) {
905
+ push({ type: "text", value });
906
+ continue;
907
+ }
908
+ }
909
+ if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
910
+ if (opts.posix !== false && value === ":") {
911
+ const inner = prev.value.slice(1);
912
+ if (inner.includes("[")) {
913
+ prev.posix = true;
914
+ if (inner.includes(":")) {
915
+ const idx = prev.value.lastIndexOf("[");
916
+ const pre = prev.value.slice(0, idx);
917
+ const rest2 = prev.value.slice(idx + 2);
918
+ const posix3 = POSIX_REGEX_SOURCE[rest2];
919
+ if (posix3) {
920
+ prev.value = pre + posix3;
921
+ state.backtrack = true;
922
+ advance();
923
+ if (!bos.output && tokens.indexOf(prev) === 1) {
924
+ bos.output = ONE_CHAR;
925
+ }
926
+ continue;
927
+ }
928
+ }
929
+ }
930
+ }
931
+ if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
932
+ value = `\\${value}`;
933
+ }
934
+ if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
935
+ value = `\\${value}`;
936
+ }
937
+ if (opts.posix === true && value === "!" && prev.value === "[") {
938
+ value = "^";
939
+ }
940
+ prev.value += value;
941
+ append({ value });
942
+ continue;
943
+ }
944
+ if (state.quotes === 1 && value !== '"') {
945
+ value = utils.escapeRegex(value);
946
+ prev.value += value;
947
+ append({ value });
948
+ continue;
949
+ }
950
+ if (value === '"') {
951
+ state.quotes = state.quotes === 1 ? 0 : 1;
952
+ if (opts.keepQuotes === true) {
953
+ push({ type: "text", value });
954
+ }
955
+ continue;
956
+ }
957
+ if (value === "(") {
958
+ increment("parens");
959
+ push({ type: "paren", value });
960
+ continue;
961
+ }
962
+ if (value === ")") {
963
+ if (state.parens === 0 && opts.strictBrackets === true) {
964
+ throw new SyntaxError(syntaxError("opening", "("));
965
+ }
966
+ const extglob = extglobs[extglobs.length - 1];
967
+ if (extglob && state.parens === extglob.parens + 1) {
968
+ extglobClose(extglobs.pop());
969
+ continue;
970
+ }
971
+ push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
972
+ decrement("parens");
973
+ continue;
974
+ }
975
+ if (value === "[") {
976
+ if (opts.nobracket === true || !remaining().includes("]")) {
977
+ if (opts.nobracket !== true && opts.strictBrackets === true) {
978
+ throw new SyntaxError(syntaxError("closing", "]"));
979
+ }
980
+ value = `\\${value}`;
981
+ } else {
982
+ increment("brackets");
983
+ }
984
+ push({ type: "bracket", value });
985
+ continue;
986
+ }
987
+ if (value === "]") {
988
+ if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
989
+ push({ type: "text", value, output: `\\${value}` });
990
+ continue;
991
+ }
992
+ if (state.brackets === 0) {
993
+ if (opts.strictBrackets === true) {
994
+ throw new SyntaxError(syntaxError("opening", "["));
995
+ }
996
+ push({ type: "text", value, output: `\\${value}` });
997
+ continue;
998
+ }
999
+ decrement("brackets");
1000
+ const prevValue = prev.value.slice(1);
1001
+ if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
1002
+ value = `/${value}`;
1003
+ }
1004
+ prev.value += value;
1005
+ append({ value });
1006
+ if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
1007
+ continue;
1008
+ }
1009
+ const escaped = utils.escapeRegex(prev.value);
1010
+ state.output = state.output.slice(0, -prev.value.length);
1011
+ if (opts.literalBrackets === true) {
1012
+ state.output += escaped;
1013
+ prev.value = escaped;
1014
+ continue;
1015
+ }
1016
+ prev.value = `(${capture}${escaped}|${prev.value})`;
1017
+ state.output += prev.value;
1018
+ continue;
1019
+ }
1020
+ if (value === "{" && opts.nobrace !== true) {
1021
+ increment("braces");
1022
+ const open = {
1023
+ type: "brace",
1024
+ value,
1025
+ output: "(",
1026
+ outputIndex: state.output.length,
1027
+ tokensIndex: state.tokens.length
1028
+ };
1029
+ braces.push(open);
1030
+ push(open);
1031
+ continue;
1032
+ }
1033
+ if (value === "}") {
1034
+ const brace = braces[braces.length - 1];
1035
+ if (opts.nobrace === true || !brace) {
1036
+ push({ type: "text", value, output: value });
1037
+ continue;
1038
+ }
1039
+ let output = ")";
1040
+ if (brace.dots === true) {
1041
+ const arr = tokens.slice();
1042
+ const range = [];
1043
+ for (let i = arr.length - 1; i >= 0; i--) {
1044
+ tokens.pop();
1045
+ if (arr[i].type === "brace") {
1046
+ break;
1047
+ }
1048
+ if (arr[i].type !== "dots") {
1049
+ range.unshift(arr[i].value);
1050
+ }
1051
+ }
1052
+ output = expandRange(range, opts);
1053
+ state.backtrack = true;
1054
+ }
1055
+ if (brace.comma !== true && brace.dots !== true) {
1056
+ const out = state.output.slice(0, brace.outputIndex);
1057
+ const toks = state.tokens.slice(brace.tokensIndex);
1058
+ brace.value = brace.output = "\\{";
1059
+ value = output = "\\}";
1060
+ state.output = out;
1061
+ for (const t of toks) {
1062
+ state.output += t.output || t.value;
1063
+ }
1064
+ }
1065
+ push({ type: "brace", value, output });
1066
+ decrement("braces");
1067
+ braces.pop();
1068
+ continue;
1069
+ }
1070
+ if (value === "|") {
1071
+ if (extglobs.length > 0) {
1072
+ extglobs[extglobs.length - 1].conditions++;
1073
+ }
1074
+ push({ type: "text", value });
1075
+ continue;
1076
+ }
1077
+ if (value === ",") {
1078
+ let output = value;
1079
+ const brace = braces[braces.length - 1];
1080
+ if (brace && stack[stack.length - 1] === "braces") {
1081
+ brace.comma = true;
1082
+ output = "|";
1083
+ }
1084
+ push({ type: "comma", value, output });
1085
+ continue;
1086
+ }
1087
+ if (value === "/") {
1088
+ if (prev.type === "dot" && state.index === state.start + 1) {
1089
+ state.start = state.index + 1;
1090
+ state.consumed = "";
1091
+ state.output = "";
1092
+ tokens.pop();
1093
+ prev = bos;
1094
+ continue;
1095
+ }
1096
+ push({ type: "slash", value, output: SLASH_LITERAL });
1097
+ continue;
1098
+ }
1099
+ if (value === ".") {
1100
+ if (state.braces > 0 && prev.type === "dot") {
1101
+ if (prev.value === ".") prev.output = DOT_LITERAL;
1102
+ const brace = braces[braces.length - 1];
1103
+ prev.type = "dots";
1104
+ prev.output += value;
1105
+ prev.value += value;
1106
+ brace.dots = true;
1107
+ continue;
1108
+ }
1109
+ if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
1110
+ push({ type: "text", value, output: DOT_LITERAL });
1111
+ continue;
1112
+ }
1113
+ push({ type: "dot", value, output: DOT_LITERAL });
1114
+ continue;
1115
+ }
1116
+ if (value === "?") {
1117
+ const isGroup = prev && prev.value === "(";
1118
+ if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1119
+ extglobOpen("qmark", value);
1120
+ continue;
1121
+ }
1122
+ if (prev && prev.type === "paren") {
1123
+ const next = peek();
1124
+ let output = value;
1125
+ if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
1126
+ output = `\\${value}`;
1127
+ }
1128
+ push({ type: "text", value, output });
1129
+ continue;
1130
+ }
1131
+ if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
1132
+ push({ type: "qmark", value, output: QMARK_NO_DOT });
1133
+ continue;
1134
+ }
1135
+ push({ type: "qmark", value, output: QMARK });
1136
+ continue;
1137
+ }
1138
+ if (value === "!") {
1139
+ if (opts.noextglob !== true && peek() === "(") {
1140
+ if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
1141
+ extglobOpen("negate", value);
1142
+ continue;
1143
+ }
1144
+ }
1145
+ if (opts.nonegate !== true && state.index === 0) {
1146
+ negate();
1147
+ continue;
1148
+ }
1149
+ }
1150
+ if (value === "+") {
1151
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1152
+ extglobOpen("plus", value);
1153
+ continue;
1154
+ }
1155
+ if (prev && prev.value === "(" || opts.regex === false) {
1156
+ push({ type: "plus", value, output: PLUS_LITERAL });
1157
+ continue;
1158
+ }
1159
+ if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
1160
+ push({ type: "plus", value });
1161
+ continue;
1162
+ }
1163
+ push({ type: "plus", value: PLUS_LITERAL });
1164
+ continue;
1165
+ }
1166
+ if (value === "@") {
1167
+ if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1168
+ push({ type: "at", extglob: true, value, output: "" });
1169
+ continue;
1170
+ }
1171
+ push({ type: "text", value });
1172
+ continue;
1173
+ }
1174
+ if (value !== "*") {
1175
+ if (value === "$" || value === "^") {
1176
+ value = `\\${value}`;
1177
+ }
1178
+ const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
1179
+ if (match) {
1180
+ value += match[0];
1181
+ state.index += match[0].length;
1182
+ }
1183
+ push({ type: "text", value });
1184
+ continue;
1185
+ }
1186
+ if (prev && (prev.type === "globstar" || prev.star === true)) {
1187
+ prev.type = "star";
1188
+ prev.star = true;
1189
+ prev.value += value;
1190
+ prev.output = star;
1191
+ state.backtrack = true;
1192
+ state.globstar = true;
1193
+ consume(value);
1194
+ continue;
1195
+ }
1196
+ let rest = remaining();
1197
+ if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
1198
+ extglobOpen("star", value);
1199
+ continue;
1200
+ }
1201
+ if (prev.type === "star") {
1202
+ if (opts.noglobstar === true) {
1203
+ consume(value);
1204
+ continue;
1205
+ }
1206
+ const prior = prev.prev;
1207
+ const before = prior.prev;
1208
+ const isStart = prior.type === "slash" || prior.type === "bos";
1209
+ const afterStar = before && (before.type === "star" || before.type === "globstar");
1210
+ if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
1211
+ push({ type: "star", value, output: "" });
1212
+ continue;
1213
+ }
1214
+ const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
1215
+ const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
1216
+ if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
1217
+ push({ type: "star", value, output: "" });
1218
+ continue;
1219
+ }
1220
+ while (rest.slice(0, 3) === "/**") {
1221
+ const after = input[state.index + 4];
1222
+ if (after && after !== "/") {
1223
+ break;
1224
+ }
1225
+ rest = rest.slice(3);
1226
+ consume("/**", 3);
1227
+ }
1228
+ if (prior.type === "bos" && eos()) {
1229
+ prev.type = "globstar";
1230
+ prev.value += value;
1231
+ prev.output = globstar(opts);
1232
+ state.output = prev.output;
1233
+ state.globstar = true;
1234
+ consume(value);
1235
+ continue;
1236
+ }
1237
+ if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
1238
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1239
+ prior.output = `(?:${prior.output}`;
1240
+ prev.type = "globstar";
1241
+ prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
1242
+ prev.value += value;
1243
+ state.globstar = true;
1244
+ state.output += prior.output + prev.output;
1245
+ consume(value);
1246
+ continue;
1247
+ }
1248
+ if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
1249
+ const end = rest[1] !== void 0 ? "|$" : "";
1250
+ state.output = state.output.slice(0, -(prior.output + prev.output).length);
1251
+ prior.output = `(?:${prior.output}`;
1252
+ prev.type = "globstar";
1253
+ prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
1254
+ prev.value += value;
1255
+ state.output += prior.output + prev.output;
1256
+ state.globstar = true;
1257
+ consume(value + advance());
1258
+ push({ type: "slash", value: "/", output: "" });
1259
+ continue;
1260
+ }
1261
+ if (prior.type === "bos" && rest[0] === "/") {
1262
+ prev.type = "globstar";
1263
+ prev.value += value;
1264
+ prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
1265
+ state.output = prev.output;
1266
+ state.globstar = true;
1267
+ consume(value + advance());
1268
+ push({ type: "slash", value: "/", output: "" });
1269
+ continue;
1270
+ }
1271
+ state.output = state.output.slice(0, -prev.output.length);
1272
+ prev.type = "globstar";
1273
+ prev.output = globstar(opts);
1274
+ prev.value += value;
1275
+ state.output += prev.output;
1276
+ state.globstar = true;
1277
+ consume(value);
1278
+ continue;
1279
+ }
1280
+ const token = { type: "star", value, output: star };
1281
+ if (opts.bash === true) {
1282
+ token.output = ".*?";
1283
+ if (prev.type === "bos" || prev.type === "slash") {
1284
+ token.output = nodot + token.output;
1285
+ }
1286
+ push(token);
1287
+ continue;
1288
+ }
1289
+ if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
1290
+ token.output = value;
1291
+ push(token);
1292
+ continue;
1293
+ }
1294
+ if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
1295
+ if (prev.type === "dot") {
1296
+ state.output += NO_DOT_SLASH;
1297
+ prev.output += NO_DOT_SLASH;
1298
+ } else if (opts.dot === true) {
1299
+ state.output += NO_DOTS_SLASH;
1300
+ prev.output += NO_DOTS_SLASH;
1301
+ } else {
1302
+ state.output += nodot;
1303
+ prev.output += nodot;
1304
+ }
1305
+ if (peek() !== "*") {
1306
+ state.output += ONE_CHAR;
1307
+ prev.output += ONE_CHAR;
1308
+ }
1309
+ }
1310
+ push(token);
1311
+ }
1312
+ while (state.brackets > 0) {
1313
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
1314
+ state.output = utils.escapeLast(state.output, "[");
1315
+ decrement("brackets");
1316
+ }
1317
+ while (state.parens > 0) {
1318
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
1319
+ state.output = utils.escapeLast(state.output, "(");
1320
+ decrement("parens");
1321
+ }
1322
+ while (state.braces > 0) {
1323
+ if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
1324
+ state.output = utils.escapeLast(state.output, "{");
1325
+ decrement("braces");
1326
+ }
1327
+ if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
1328
+ push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
1329
+ }
1330
+ if (state.backtrack === true) {
1331
+ state.output = "";
1332
+ for (const token of state.tokens) {
1333
+ state.output += token.output != null ? token.output : token.value;
1334
+ if (token.suffix) {
1335
+ state.output += token.suffix;
1336
+ }
1337
+ }
1338
+ }
1339
+ return state;
1340
+ };
1341
+ parse2.fastpaths = (input, options) => {
1342
+ const opts = { ...options };
1343
+ const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1344
+ const len = input.length;
1345
+ if (len > max) {
1346
+ throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1347
+ }
1348
+ input = REPLACEMENTS[input] || input;
1349
+ const {
1350
+ DOT_LITERAL,
1351
+ SLASH_LITERAL,
1352
+ ONE_CHAR,
1353
+ DOTS_SLASH,
1354
+ NO_DOT,
1355
+ NO_DOTS,
1356
+ NO_DOTS_SLASH,
1357
+ STAR,
1358
+ START_ANCHOR
1359
+ } = constants.globChars(opts.windows);
1360
+ const nodot = opts.dot ? NO_DOTS : NO_DOT;
1361
+ const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
1362
+ const capture = opts.capture ? "" : "?:";
1363
+ const state = { negated: false, prefix: "" };
1364
+ let star = opts.bash === true ? ".*?" : STAR;
1365
+ if (opts.capture) {
1366
+ star = `(${star})`;
1367
+ }
1368
+ const globstar = (opts2) => {
1369
+ if (opts2.noglobstar === true) return star;
1370
+ return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
1371
+ };
1372
+ const create = (str) => {
1373
+ switch (str) {
1374
+ case "*":
1375
+ return `${nodot}${ONE_CHAR}${star}`;
1376
+ case ".*":
1377
+ return `${DOT_LITERAL}${ONE_CHAR}${star}`;
1378
+ case "*.*":
1379
+ return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1380
+ case "*/*":
1381
+ return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
1382
+ case "**":
1383
+ return nodot + globstar(opts);
1384
+ case "**/*":
1385
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
1386
+ case "**/*.*":
1387
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1388
+ case "**/.*":
1389
+ return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
1390
+ default: {
1391
+ const match = /^(.*?)\.(\w+)$/.exec(str);
1392
+ if (!match) return;
1393
+ const source2 = create(match[1]);
1394
+ if (!source2) return;
1395
+ return source2 + DOT_LITERAL + match[2];
1396
+ }
1397
+ }
1398
+ };
1399
+ const output = utils.removePrefix(input, state);
1400
+ let source = create(output);
1401
+ if (source && opts.strictSlashes !== true) {
1402
+ source += `${SLASH_LITERAL}?`;
1403
+ }
1404
+ return source;
1405
+ };
1406
+ module.exports = parse2;
1407
+ }
1408
+ });
1409
+
1410
+ // node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js
1411
+ var require_picomatch = __commonJS({
1412
+ "node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js"(exports, module) {
1413
+ var scan = require_scan();
1414
+ var parse2 = require_parse();
1415
+ var utils = require_utils();
1416
+ var constants = require_constants();
1417
+ var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
1418
+ var picomatch = (glob, options, returnState = false) => {
1419
+ if (Array.isArray(glob)) {
1420
+ const fns = glob.map((input) => picomatch(input, options, returnState));
1421
+ const arrayMatcher = (str) => {
1422
+ for (const isMatch of fns) {
1423
+ const state2 = isMatch(str);
1424
+ if (state2) return state2;
1425
+ }
1426
+ return false;
1427
+ };
1428
+ return arrayMatcher;
1429
+ }
1430
+ const isState = isObject(glob) && glob.tokens && glob.input;
1431
+ if (glob === "" || typeof glob !== "string" && !isState) {
1432
+ throw new TypeError("Expected pattern to be a non-empty string");
1433
+ }
1434
+ const opts = options || {};
1435
+ const posix3 = opts.windows;
1436
+ const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
1437
+ const state = regex.state;
1438
+ delete regex.state;
1439
+ let isIgnored = () => false;
1440
+ if (opts.ignore) {
1441
+ const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
1442
+ isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
1443
+ }
1444
+ const matcher = (input, returnObject = false) => {
1445
+ const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix: posix3 });
1446
+ const result = { glob, state, regex, posix: posix3, input, output, match, isMatch };
1447
+ if (typeof opts.onResult === "function") {
1448
+ opts.onResult(result);
1449
+ }
1450
+ if (isMatch === false) {
1451
+ result.isMatch = false;
1452
+ return returnObject ? result : false;
1453
+ }
1454
+ if (isIgnored(input)) {
1455
+ if (typeof opts.onIgnore === "function") {
1456
+ opts.onIgnore(result);
1457
+ }
1458
+ result.isMatch = false;
1459
+ return returnObject ? result : false;
1460
+ }
1461
+ if (typeof opts.onMatch === "function") {
1462
+ opts.onMatch(result);
1463
+ }
1464
+ return returnObject ? result : true;
1465
+ };
1466
+ if (returnState) {
1467
+ matcher.state = state;
1468
+ }
1469
+ return matcher;
1470
+ };
1471
+ picomatch.test = (input, regex, options, { glob, posix: posix3 } = {}) => {
1472
+ if (typeof input !== "string") {
1473
+ throw new TypeError("Expected input to be a string");
1474
+ }
1475
+ if (input === "") {
1476
+ return { isMatch: false, output: "" };
1477
+ }
1478
+ const opts = options || {};
1479
+ const format2 = opts.format || (posix3 ? utils.toPosixSlashes : null);
1480
+ let match = input === glob;
1481
+ let output = match && format2 ? format2(input) : input;
1482
+ if (match === false) {
1483
+ output = format2 ? format2(input) : input;
1484
+ match = output === glob;
1485
+ }
1486
+ if (match === false || opts.capture === true) {
1487
+ if (opts.matchBase === true || opts.basename === true) {
1488
+ match = picomatch.matchBase(input, regex, options, posix3);
1489
+ } else {
1490
+ match = regex.exec(output);
1491
+ }
1492
+ }
1493
+ return { isMatch: Boolean(match), match, output };
1494
+ };
1495
+ picomatch.matchBase = (input, glob, options) => {
1496
+ const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
1497
+ return regex.test(utils.basename(input));
1498
+ };
1499
+ picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
1500
+ picomatch.parse = (pattern, options) => {
1501
+ if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
1502
+ return parse2(pattern, { ...options, fastpaths: false });
1503
+ };
1504
+ picomatch.scan = (input, options) => scan(input, options);
1505
+ picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
1506
+ if (returnOutput === true) {
1507
+ return state.output;
1508
+ }
1509
+ const opts = options || {};
1510
+ const prepend = opts.contains ? "" : "^";
1511
+ const append = opts.contains ? "" : "$";
1512
+ let source = `${prepend}(?:${state.output})${append}`;
1513
+ if (state && state.negated === true) {
1514
+ source = `^(?!${source}).*$`;
1515
+ }
1516
+ const regex = picomatch.toRegex(source, options);
1517
+ if (returnState === true) {
1518
+ regex.state = state;
1519
+ }
1520
+ return regex;
1521
+ };
1522
+ picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
1523
+ if (!input || typeof input !== "string") {
1524
+ throw new TypeError("Expected a non-empty string");
1525
+ }
1526
+ let parsed = { negated: false, fastpaths: true };
1527
+ if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
1528
+ parsed.output = parse2.fastpaths(input, options);
1529
+ }
1530
+ if (!parsed.output) {
1531
+ parsed = parse2(input, options);
1532
+ }
1533
+ return picomatch.compileRe(parsed, options, returnOutput, returnState);
1534
+ };
1535
+ picomatch.toRegex = (source, options) => {
1536
+ try {
1537
+ const opts = options || {};
1538
+ return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
1539
+ } catch (err) {
1540
+ if (options && options.debug === true) throw err;
1541
+ return /$^/;
1542
+ }
1543
+ };
1544
+ picomatch.constants = constants;
1545
+ module.exports = picomatch;
1546
+ }
1547
+ });
1548
+
1549
+ // node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js
1550
+ var require_picomatch2 = __commonJS({
1551
+ "node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js"(exports, module) {
1552
+ var pico = require_picomatch();
1553
+ var utils = require_utils();
1554
+ function picomatch(glob, options, returnState = false) {
1555
+ if (options && (options.windows === null || options.windows === void 0)) {
1556
+ options = { ...options, windows: utils.isWindows() };
1557
+ }
1558
+ return pico(glob, options, returnState);
1559
+ }
1560
+ Object.assign(picomatch, pico);
1561
+ module.exports = picomatch;
1562
+ }
1563
+ });
1564
+
1565
+ // node_modules/.pnpm/semver@7.7.3/node_modules/semver/internal/constants.js
1566
+ var require_constants2 = __commonJS({
54
1567
  "node_modules/.pnpm/semver@7.7.3/node_modules/semver/internal/constants.js"(exports, module) {
55
1568
  var SEMVER_SPEC_VERSION = "2.0.0";
56
1569
  var MAX_LENGTH = 256;
@@ -96,7 +1609,7 @@ var require_re = __commonJS({
96
1609
  MAX_SAFE_COMPONENT_LENGTH,
97
1610
  MAX_SAFE_BUILD_LENGTH,
98
1611
  MAX_LENGTH
99
- } = require_constants();
1612
+ } = require_constants2();
100
1613
  var debug = require_debug();
101
1614
  exports = module.exports = {};
102
1615
  var re = exports.re = [];
@@ -222,7 +1735,7 @@ var require_identifiers = __commonJS({
222
1735
  var require_semver = __commonJS({
223
1736
  "node_modules/.pnpm/semver@7.7.3/node_modules/semver/classes/semver.js"(exports, module) {
224
1737
  var debug = require_debug();
225
- var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
1738
+ var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants2();
226
1739
  var { safeRe: re, t } = require_re();
227
1740
  var parseOptions = require_parse_options();
228
1741
  var { compareIdentifiers } = require_identifiers();
@@ -497,7 +2010,7 @@ var require_semver = __commonJS({
497
2010
  });
498
2011
 
499
2012
  // node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/parse.js
500
- var require_parse = __commonJS({
2013
+ var require_parse2 = __commonJS({
501
2014
  "node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/parse.js"(exports, module) {
502
2015
  var SemVer = require_semver();
503
2016
  var parse2 = (version, options, throwErrors = false) => {
@@ -520,7 +2033,7 @@ var require_parse = __commonJS({
520
2033
  // node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/valid.js
521
2034
  var require_valid = __commonJS({
522
2035
  "node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/valid.js"(exports, module) {
523
- var parse2 = require_parse();
2036
+ var parse2 = require_parse2();
524
2037
  var valid = (version, options) => {
525
2038
  const v = parse2(version, options);
526
2039
  return v ? v.version : null;
@@ -532,7 +2045,7 @@ var require_valid = __commonJS({
532
2045
  // node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/clean.js
533
2046
  var require_clean = __commonJS({
534
2047
  "node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/clean.js"(exports, module) {
535
- var parse2 = require_parse();
2048
+ var parse2 = require_parse2();
536
2049
  var clean = (version, options) => {
537
2050
  const s = parse2(version.trim().replace(/^[=v]+/, ""), options);
538
2051
  return s ? s.version : null;
@@ -567,7 +2080,7 @@ var require_inc = __commonJS({
567
2080
  // node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/diff.js
568
2081
  var require_diff = __commonJS({
569
2082
  "node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/diff.js"(exports, module) {
570
- var parse2 = require_parse();
2083
+ var parse2 = require_parse2();
571
2084
  var diff = (version1, version2) => {
572
2085
  const v1 = parse2(version1, null, true);
573
2086
  const v2 = parse2(version2, null, true);
@@ -637,7 +2150,7 @@ var require_patch = __commonJS({
637
2150
  // node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/prerelease.js
638
2151
  var require_prerelease = __commonJS({
639
2152
  "node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/prerelease.js"(exports, module) {
640
- var parse2 = require_parse();
2153
+ var parse2 = require_parse2();
641
2154
  var prerelease = (version, options) => {
642
2155
  const parsed = parse2(version, options);
643
2156
  return parsed && parsed.prerelease.length ? parsed.prerelease : null;
@@ -811,7 +2324,7 @@ var require_cmp = __commonJS({
811
2324
  var require_coerce = __commonJS({
812
2325
  "node_modules/.pnpm/semver@7.7.3/node_modules/semver/functions/coerce.js"(exports, module) {
813
2326
  var SemVer = require_semver();
814
- var parse2 = require_parse();
2327
+ var parse2 = require_parse2();
815
2328
  var { safeRe: re, t } = require_re();
816
2329
  var coerce = (version, options) => {
817
2330
  if (version instanceof SemVer) {
@@ -1045,7 +2558,7 @@ var require_range = __commonJS({
1045
2558
  tildeTrimReplace,
1046
2559
  caretTrimReplace
1047
2560
  } = require_re();
1048
- var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
2561
+ var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants2();
1049
2562
  var isNullSet = (c) => c.value === "<0.0.0-0";
1050
2563
  var isAny = (c) => c.value === "";
1051
2564
  var isSatisfiable = (comparators, options) => {
@@ -1844,10 +3357,10 @@ var require_subset = __commonJS({
1844
3357
  var require_semver2 = __commonJS({
1845
3358
  "node_modules/.pnpm/semver@7.7.3/node_modules/semver/index.js"(exports, module) {
1846
3359
  var internalRe = require_re();
1847
- var constants = require_constants();
3360
+ var constants = require_constants2();
1848
3361
  var SemVer = require_semver();
1849
3362
  var identifiers = require_identifiers();
1850
- var parse2 = require_parse();
3363
+ var parse2 = require_parse2();
1851
3364
  var valid = require_valid();
1852
3365
  var clean = require_clean();
1853
3366
  var inc = require_inc();
@@ -3055,13 +4568,13 @@ function vitePluginNextSwc(rootDir, nextConfigResolver) {
3055
4568
  // src/polyfills/promise-with-resolvers.ts
3056
4569
  if (typeof Promise.withResolvers === "undefined") {
3057
4570
  Promise.withResolvers = () => {
3058
- let resolve2;
4571
+ let resolve3;
3059
4572
  let reject;
3060
4573
  const promise = new Promise((res, rej) => {
3061
- resolve2 = res;
4574
+ resolve3 = res;
3062
4575
  reject = rej;
3063
4576
  });
3064
- return { promise, resolve: resolve2, reject };
4577
+ return { promise, resolve: resolve3, reject };
3065
4578
  };
3066
4579
  }
3067
4580
  var vitePluginNextDynamic = () => ({
@@ -3086,6 +4599,70 @@ var vitePluginNextDynamic = () => ({
3086
4599
  return null;
3087
4600
  }
3088
4601
  });
4602
+ var import_picomatch = __toESM(require_picomatch2());
4603
+ function isArray(arg) {
4604
+ return Array.isArray(arg);
4605
+ }
4606
+ function ensureArray(thing) {
4607
+ if (isArray(thing))
4608
+ return thing;
4609
+ if (thing == null)
4610
+ return [];
4611
+ return [thing];
4612
+ }
4613
+ var normalizePathRegExp = new RegExp(`\\${win32$1.sep}`, "g");
4614
+ var normalizePath = function normalizePath2(filename) {
4615
+ return filename.replace(normalizePathRegExp, posix$1.sep);
4616
+ };
4617
+ function getMatcherString(id, resolutionBase) {
4618
+ if (isAbsolute$1(id) || id.startsWith("**")) {
4619
+ return normalizePath(id);
4620
+ }
4621
+ const basePath = normalizePath(resolve$1("")).replace(/[-^$*+?.()|[\]{}]/g, "\\$&");
4622
+ return posix$1.join(basePath, normalizePath(id));
4623
+ }
4624
+ var createFilter2 = function createFilter3(include, exclude, options) {
4625
+ const getMatcher = (id) => id instanceof RegExp ? id : {
4626
+ test: (what) => {
4627
+ const pattern = getMatcherString(id);
4628
+ const fn = (0, import_picomatch.default)(pattern, { dot: true });
4629
+ const result = fn(what);
4630
+ return result;
4631
+ }
4632
+ };
4633
+ const includeMatchers = ensureArray(include).map(getMatcher);
4634
+ const excludeMatchers = ensureArray(exclude).map(getMatcher);
4635
+ if (!includeMatchers.length && !excludeMatchers.length)
4636
+ return (id) => typeof id === "string" && !id.includes("\0");
4637
+ return function result(id) {
4638
+ if (typeof id !== "string")
4639
+ return false;
4640
+ if (id.includes("\0"))
4641
+ return false;
4642
+ const pathId = normalizePath(id);
4643
+ for (let i = 0; i < excludeMatchers.length; ++i) {
4644
+ const matcher = excludeMatchers[i];
4645
+ if (matcher instanceof RegExp) {
4646
+ matcher.lastIndex = 0;
4647
+ }
4648
+ if (matcher.test(pathId))
4649
+ return false;
4650
+ }
4651
+ for (let i = 0; i < includeMatchers.length; ++i) {
4652
+ const matcher = includeMatchers[i];
4653
+ if (matcher instanceof RegExp) {
4654
+ matcher.lastIndex = 0;
4655
+ }
4656
+ if (matcher.test(pathId))
4657
+ return true;
4658
+ }
4659
+ return !includeMatchers.length;
4660
+ };
4661
+ };
4662
+ var reservedWords = "break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public";
4663
+ var builtins = "arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl";
4664
+ var forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(" "));
4665
+ forbiddenIdentifiers.add("");
3089
4666
  var require3 = createRequire(import.meta.url);
3090
4667
  var VITEST_PLUGIN_NAME = "vite-plugin-storybook-nextjs";
3091
4668
  var isVitestEnv = process.env.VITEST === "true";
@@ -3109,14 +4686,31 @@ var getAlias = (env) => ({
3109
4686
  });
3110
4687
 
3111
4688
  // src/plugins/next-image/plugin.ts
4689
+ var hasWarned = false;
4690
+ var warnOnce = (message) => {
4691
+ if (!hasWarned) {
4692
+ console.warn(`[vite-plugin-storybook-nextjs] ${message}`);
4693
+ hasWarned = true;
4694
+ }
4695
+ };
3112
4696
  var includePattern2 = /\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/;
3113
4697
  var excludeImporterPattern = /\.(css|scss|sass)$/;
3114
4698
  var virtualImage = "virtual:next-image";
3115
4699
  var virtualNextImage = "virtual:next/image";
3116
4700
  var virtualNextLegacyImage = "virtual:next/legacy/image";
3117
4701
  var require5 = createRequire(import.meta.url);
3118
- function vitePluginNextImage(nextConfigResolver) {
4702
+ function vitePluginNextImage(nextConfigResolver, options = {}) {
3119
4703
  let isBrowser = !isVitestEnv;
4704
+ let hasVitePluginSvgr = false;
4705
+ const postfixRE = /[?#].*$/s;
4706
+ const filter = createFilter2(
4707
+ [
4708
+ "**/*.{png,jpg,jpeg,gif,webp,avif,ico,bmp,svg}",
4709
+ "**/*.{png,jpg,jpeg,gif,webp,avif,ico,bmp,svg}?*",
4710
+ "**/*.{png,jpg,jpeg,gif,webp,avif,ico,bmp,svg}#*"
4711
+ ],
4712
+ options.excludeFiles
4713
+ );
3120
4714
  return {
3121
4715
  name: "vite-plugin-storybook-nextjs-image",
3122
4716
  enforce: "pre",
@@ -3124,6 +4718,9 @@ function vitePluginNextImage(nextConfigResolver) {
3124
4718
  if (config.test?.browser?.enabled === true) {
3125
4719
  isBrowser = true;
3126
4720
  }
4721
+ hasVitePluginSvgr = !!config.plugins?.some(
4722
+ (plugin) => plugin && typeof plugin === "object" && "name" in plugin && (plugin.name === "vite-plugin-svgr" || plugin.name.includes("svgr"))
4723
+ );
3127
4724
  return {
3128
4725
  resolve: {
3129
4726
  alias: getAlias(isBrowser ? "browser" : "node")
@@ -3135,9 +4732,24 @@ function vitePluginNextImage(nextConfigResolver) {
3135
4732
  if (queryA === "ignore") {
3136
4733
  return null;
3137
4734
  }
4735
+ const isSvg = /\.svg$/.test(source);
4736
+ if (isSvg && hasVitePluginSvgr && queryA === "react") {
4737
+ return null;
4738
+ }
4739
+ if (isSvg && hasVitePluginSvgr && !options.includeFiles && !options.excludeFiles) {
4740
+ warnOnce(
4741
+ dedent`Detected vite-plugin-svgr but you are not passing image include or exclude patterns to the nextjs-vite plugin. This may cause a conflict between the two plugins and issues with SVG files.
4742
+
4743
+ For more info and recommended configuration, see: https://github.com/storybookjs/vite-plugin-storybook-nextjs/blob/main/README.md#faq-includingexcluding-images`
4744
+ );
4745
+ }
3138
4746
  if (includePattern2.test(source) && !excludeImporterPattern.test(importer ?? "") && !importer?.startsWith(virtualImage)) {
3139
- const isAbsolute2 = posix.isAbsolute(id);
3140
- const imagePath = importer ? isAbsolute2 ? source : posix.join(posix.dirname(importer), source) : source;
4747
+ const isAbsolute3 = posix.isAbsolute(id);
4748
+ const imagePath = importer ? isAbsolute3 ? source : posix.join(posix.dirname(importer), source) : source;
4749
+ const pathForFilter = imagePath.replace(postfixRE, "");
4750
+ if (!filter(pathForFilter)) {
4751
+ return null;
4752
+ }
3141
4753
  return `${virtualImage}?${encode({ imagePath })}`;
3142
4754
  }
3143
4755
  if (id === "next/image" && importer !== virtualNextImage) {
@@ -3283,7 +4895,8 @@ var loadConfig = (
3283
4895
  nextServerConfig.default || nextServerConfig
3284
4896
  );
3285
4897
  function VitePlugin({
3286
- dir = process.cwd()
4898
+ dir = process.cwd(),
4899
+ image
3287
4900
  } = {}) {
3288
4901
  const resolvedDir = resolve(dir);
3289
4902
  const nextConfigResolver = Promise.withResolvers();
@@ -3410,7 +5023,7 @@ function VitePlugin({
3410
5023
  vitePluginNextFont(),
3411
5024
  vitePluginNextSwc(dir, nextConfigResolver),
3412
5025
  vitePluginNextEnv(dir, nextConfigResolver),
3413
- vitePluginNextImage(nextConfigResolver),
5026
+ vitePluginNextImage(nextConfigResolver, image),
3414
5027
  vitePluginNextMocks(),
3415
5028
  vitePluginNextDynamic()
3416
5029
  ];