ebuilds-shared 0.1.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.
Files changed (40) hide show
  1. package/README.md +69 -0
  2. package/dist/chunk-6DZX6EAA.mjs +37 -0
  3. package/dist/chunk-G4JQ2UQV.mjs +2878 -0
  4. package/dist/chunk-LATZ6U6A.js +2878 -0
  5. package/dist/chunk-MXO66M74.js +36 -0
  6. package/dist/chunk-OW2EL2VY.mjs +36 -0
  7. package/dist/chunk-QGM4M3NI.js +37 -0
  8. package/dist/chunk-QQPGJGSU.js +6916 -0
  9. package/dist/chunk-RRULL645.mjs +6916 -0
  10. package/dist/functionalComponent/index.d.mts +16 -0
  11. package/dist/functionalComponent/index.d.ts +16 -0
  12. package/dist/functionalComponent/index.js +25 -0
  13. package/dist/functionalComponent/index.mjs +25 -0
  14. package/dist/index-CVmrbYyU.d.mts +34 -0
  15. package/dist/index-CVmrbYyU.d.ts +34 -0
  16. package/dist/index.css +69 -0
  17. package/dist/index.d.mts +11 -0
  18. package/dist/index.d.ts +11 -0
  19. package/dist/index.js +65 -0
  20. package/dist/index.mjs +65 -0
  21. package/dist/stores/index.d.mts +294 -0
  22. package/dist/stores/index.d.ts +294 -0
  23. package/dist/stores/index.js +13 -0
  24. package/dist/stores/index.mjs +13 -0
  25. package/dist/styles/index.css +69 -0
  26. package/dist/styles/index.d.mts +2 -0
  27. package/dist/styles/index.d.ts +2 -0
  28. package/dist/uno-config/index.d.mts +8 -0
  29. package/dist/uno-config/index.d.ts +8 -0
  30. package/dist/uno-config/index.js +9 -0
  31. package/dist/uno-config/index.mjs +9 -0
  32. package/dist/utils/index.d.mts +157 -0
  33. package/dist/utils/index.d.ts +157 -0
  34. package/dist/utils/index.js +49 -0
  35. package/dist/utils/index.mjs +49 -0
  36. package/dist/vite-config/index.d.mts +31 -0
  37. package/dist/vite-config/index.d.ts +31 -0
  38. package/dist/vite-config/index.js +7 -0
  39. package/dist/vite-config/index.mjs +7 -0
  40. package/package.json +79 -0
@@ -0,0 +1,2878 @@
1
+ import {
2
+ __commonJS,
3
+ __require
4
+ } from "./chunk-6DZX6EAA.mjs";
5
+
6
+ // ../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js
7
+ var require_has_flag = __commonJS({
8
+ "../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js"(exports, module) {
9
+ "use strict";
10
+ module.exports = (flag, argv = process.argv) => {
11
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
12
+ const position = argv.indexOf(prefix + flag);
13
+ const terminatorPosition = argv.indexOf("--");
14
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
15
+ };
16
+ }
17
+ });
18
+
19
+ // ../node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js
20
+ var require_supports_color = __commonJS({
21
+ "../node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js"(exports, module) {
22
+ "use strict";
23
+ var os = __require("os");
24
+ var tty = __require("tty");
25
+ var hasFlag = require_has_flag();
26
+ var { env } = process;
27
+ var flagForceColor;
28
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
29
+ flagForceColor = 0;
30
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
31
+ flagForceColor = 1;
32
+ }
33
+ function envForceColor() {
34
+ if ("FORCE_COLOR" in env) {
35
+ if (env.FORCE_COLOR === "true") {
36
+ return 1;
37
+ }
38
+ if (env.FORCE_COLOR === "false") {
39
+ return 0;
40
+ }
41
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
42
+ }
43
+ }
44
+ function translateLevel(level) {
45
+ if (level === 0) {
46
+ return false;
47
+ }
48
+ return {
49
+ level,
50
+ hasBasic: true,
51
+ has256: level >= 2,
52
+ has16m: level >= 3
53
+ };
54
+ }
55
+ function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
56
+ const noFlagForceColor = envForceColor();
57
+ if (noFlagForceColor !== void 0) {
58
+ flagForceColor = noFlagForceColor;
59
+ }
60
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
61
+ if (forceColor === 0) {
62
+ return 0;
63
+ }
64
+ if (sniffFlags) {
65
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
66
+ return 3;
67
+ }
68
+ if (hasFlag("color=256")) {
69
+ return 2;
70
+ }
71
+ }
72
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
73
+ return 0;
74
+ }
75
+ const min = forceColor || 0;
76
+ if (env.TERM === "dumb") {
77
+ return min;
78
+ }
79
+ if (process.platform === "win32") {
80
+ const osRelease = os.release().split(".");
81
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
82
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
83
+ }
84
+ return 1;
85
+ }
86
+ if ("CI" in env) {
87
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
88
+ return 1;
89
+ }
90
+ return min;
91
+ }
92
+ if ("TEAMCITY_VERSION" in env) {
93
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
94
+ }
95
+ if (env.COLORTERM === "truecolor") {
96
+ return 3;
97
+ }
98
+ if ("TERM_PROGRAM" in env) {
99
+ const version2 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
100
+ switch (env.TERM_PROGRAM) {
101
+ case "iTerm.app":
102
+ return version2 >= 3 ? 3 : 2;
103
+ case "Apple_Terminal":
104
+ return 2;
105
+ }
106
+ }
107
+ if (/-256(color)?$/i.test(env.TERM)) {
108
+ return 2;
109
+ }
110
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
111
+ return 1;
112
+ }
113
+ if ("COLORTERM" in env) {
114
+ return 1;
115
+ }
116
+ return min;
117
+ }
118
+ function getSupportLevel(stream, options = {}) {
119
+ const level = supportsColor(stream, {
120
+ streamIsTTY: stream && stream.isTTY,
121
+ ...options
122
+ });
123
+ return translateLevel(level);
124
+ }
125
+ module.exports = {
126
+ supportsColor: getSupportLevel,
127
+ stdout: getSupportLevel({ isTTY: tty.isatty(1) }),
128
+ stderr: getSupportLevel({ isTTY: tty.isatty(2) })
129
+ };
130
+ }
131
+ });
132
+
133
+ // src/vite-config/index.ts
134
+ import { defineConfig, loadEnv } from "vite";
135
+
136
+ // ../node_modules/.pnpm/@vitejs+plugin-vue@5.2.4_vite@6.4.1_@types+node@22.19.1_jiti@2.6.1_less@4.4.2_sass-embedded@1_mycylw3mhm2x42z5uuy7cfcqh4/node_modules/@vitejs/plugin-vue/dist/index.mjs
137
+ import fs from "fs";
138
+ import { normalizePath as normalizePath$1, isCSSRequest, transformWithEsbuild, formatPostcssSourceMap, createFilter } from "vite";
139
+ import { shallowRef, computed } from "vue";
140
+ import { createRequire } from "module";
141
+ import path from "path";
142
+ import crypto from "crypto";
143
+ import require$$0 from "tty";
144
+ import require$$1 from "util";
145
+ var version = "5.2.4";
146
+ function resolveCompiler(root) {
147
+ const compiler = tryResolveCompiler(root) || tryResolveCompiler();
148
+ if (!compiler) {
149
+ throw new Error(
150
+ `Failed to resolve vue/compiler-sfc.
151
+ @vitejs/plugin-vue requires vue (>=3.2.25) to be present in the dependency tree.`
152
+ );
153
+ }
154
+ return compiler;
155
+ }
156
+ function tryResolveCompiler(root) {
157
+ const vueMeta = tryRequire("vue/package.json", root);
158
+ if (vueMeta && vueMeta.version.split(".")[0] >= 3) {
159
+ return tryRequire("vue/compiler-sfc", root);
160
+ }
161
+ }
162
+ var _require = createRequire(import.meta.url);
163
+ function tryRequire(id, from) {
164
+ try {
165
+ return from ? _require(_require.resolve(id, { paths: [from] })) : _require(id);
166
+ } catch (e) {
167
+ }
168
+ }
169
+ function parseVueRequest(id) {
170
+ const [filename, rawQuery] = id.split(`?`, 2);
171
+ const query = Object.fromEntries(new URLSearchParams(rawQuery));
172
+ if (query.vue != null) {
173
+ query.vue = true;
174
+ }
175
+ if (query.index != null) {
176
+ query.index = Number(query.index);
177
+ }
178
+ if (query.raw != null) {
179
+ query.raw = true;
180
+ }
181
+ if (query.url != null) {
182
+ query.url = true;
183
+ }
184
+ if (query.scoped != null) {
185
+ query.scoped = true;
186
+ }
187
+ return {
188
+ filename,
189
+ query
190
+ };
191
+ }
192
+ var cache = /* @__PURE__ */ new Map();
193
+ var hmrCache = /* @__PURE__ */ new Map();
194
+ var prevCache = /* @__PURE__ */ new Map();
195
+ function createDescriptor(filename, source, {
196
+ root,
197
+ isProduction,
198
+ sourceMap,
199
+ compiler,
200
+ template,
201
+ features
202
+ }, hmr = false) {
203
+ const { descriptor, errors } = compiler.parse(source, {
204
+ filename,
205
+ sourceMap,
206
+ templateParseOptions: template?.compilerOptions
207
+ });
208
+ const normalizedPath = normalizePath$1(path.relative(root, filename));
209
+ const componentIdGenerator = features?.componentIdGenerator;
210
+ if (componentIdGenerator === "filepath") {
211
+ descriptor.id = getHash(normalizedPath);
212
+ } else if (componentIdGenerator === "filepath-source") {
213
+ descriptor.id = getHash(normalizedPath + source);
214
+ } else if (typeof componentIdGenerator === "function") {
215
+ descriptor.id = componentIdGenerator(
216
+ normalizedPath,
217
+ source,
218
+ isProduction,
219
+ getHash
220
+ );
221
+ } else {
222
+ descriptor.id = getHash(normalizedPath + (isProduction ? source : ""));
223
+ }
224
+ (hmr ? hmrCache : cache).set(filename, descriptor);
225
+ return { descriptor, errors };
226
+ }
227
+ function getPrevDescriptor(filename) {
228
+ return prevCache.get(filename);
229
+ }
230
+ function invalidateDescriptor(filename, hmr = false) {
231
+ const _cache = hmr ? hmrCache : cache;
232
+ const prev = _cache.get(filename);
233
+ _cache.delete(filename);
234
+ if (prev) {
235
+ prevCache.set(filename, prev);
236
+ }
237
+ }
238
+ function getDescriptor(filename, options, createIfNotFound = true, hmr = false, code) {
239
+ const _cache = hmr ? hmrCache : cache;
240
+ if (_cache.has(filename)) {
241
+ return _cache.get(filename);
242
+ }
243
+ if (createIfNotFound) {
244
+ const { descriptor, errors } = createDescriptor(
245
+ filename,
246
+ code ?? fs.readFileSync(filename, "utf-8"),
247
+ options,
248
+ hmr
249
+ );
250
+ if (errors.length && !hmr) {
251
+ throw errors[0];
252
+ }
253
+ return descriptor;
254
+ }
255
+ }
256
+ function getSrcDescriptor(filename, query) {
257
+ if (query.scoped) {
258
+ return cache.get(`${filename}?src=${query.src}`);
259
+ }
260
+ return cache.get(filename);
261
+ }
262
+ function getTempSrcDescriptor(filename, query) {
263
+ return {
264
+ filename,
265
+ id: query.id || "",
266
+ styles: [
267
+ {
268
+ scoped: query.scoped,
269
+ loc: {
270
+ start: { line: 0, column: 0 }
271
+ }
272
+ }
273
+ ],
274
+ isTemp: true
275
+ };
276
+ }
277
+ function setSrcDescriptor(filename, entry, scoped) {
278
+ if (scoped) {
279
+ cache.set(`${filename}?src=${entry.id}`, entry);
280
+ return;
281
+ }
282
+ cache.set(filename, entry);
283
+ }
284
+ var hash = (
285
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins -- crypto.hash is supported in Node 21.7.0+, 20.12.0+
286
+ crypto.hash ?? ((algorithm, data, outputEncoding) => crypto.createHash(algorithm).update(data).digest(outputEncoding))
287
+ );
288
+ function getHash(text) {
289
+ return hash("sha256", text, "hex").substring(0, 8);
290
+ }
291
+ function slash(path3) {
292
+ const isExtendedLengthPath = path3.startsWith("\\\\?\\");
293
+ if (isExtendedLengthPath) {
294
+ return path3;
295
+ }
296
+ return path3.replace(/\\/g, "/");
297
+ }
298
+ function createRollupError(id, error) {
299
+ const { message, name, stack } = error;
300
+ const rollupError = {
301
+ id,
302
+ plugin: "vue",
303
+ message,
304
+ name,
305
+ stack
306
+ };
307
+ if ("code" in error && error.loc) {
308
+ rollupError.loc = {
309
+ file: id,
310
+ line: error.loc.start.line,
311
+ column: error.loc.start.column
312
+ };
313
+ }
314
+ return rollupError;
315
+ }
316
+ async function transformTemplateAsModule(code, descriptor, options, pluginContext, ssr, customElement) {
317
+ const result = compile(
318
+ code,
319
+ descriptor,
320
+ options,
321
+ pluginContext,
322
+ ssr,
323
+ customElement
324
+ );
325
+ let returnCode = result.code;
326
+ if (options.devServer && options.devServer.config.server.hmr !== false && !ssr && !options.isProduction) {
327
+ returnCode += `
328
+ import.meta.hot.accept(({ render }) => {
329
+ __VUE_HMR_RUNTIME__.rerender(${JSON.stringify(descriptor.id)}, render)
330
+ })`;
331
+ }
332
+ return {
333
+ code: returnCode,
334
+ map: result.map
335
+ };
336
+ }
337
+ function transformTemplateInMain(code, descriptor, options, pluginContext, ssr, customElement) {
338
+ const result = compile(
339
+ code,
340
+ descriptor,
341
+ options,
342
+ pluginContext,
343
+ ssr,
344
+ customElement
345
+ );
346
+ return {
347
+ ...result,
348
+ code: result.code.replace(
349
+ /\nexport (function|const) (render|ssrRender)/,
350
+ "\n$1 _sfc_$2"
351
+ )
352
+ };
353
+ }
354
+ function compile(code, descriptor, options, pluginContext, ssr, customElement) {
355
+ const filename = descriptor.filename;
356
+ resolveScript(descriptor, options, ssr, customElement);
357
+ const result = options.compiler.compileTemplate({
358
+ ...resolveTemplateCompilerOptions(descriptor, options, ssr),
359
+ source: code
360
+ });
361
+ if (result.errors.length) {
362
+ result.errors.forEach(
363
+ (error) => pluginContext.error(
364
+ typeof error === "string" ? { id: filename, message: error } : createRollupError(filename, error)
365
+ )
366
+ );
367
+ }
368
+ if (result.tips.length) {
369
+ result.tips.forEach(
370
+ (tip) => pluginContext.warn({
371
+ id: filename,
372
+ message: tip
373
+ })
374
+ );
375
+ }
376
+ return result;
377
+ }
378
+ function resolveTemplateCompilerOptions(descriptor, options, ssr) {
379
+ const block = descriptor.template;
380
+ if (!block) {
381
+ return;
382
+ }
383
+ const resolvedScript = getResolvedScript(descriptor, ssr);
384
+ const hasScoped = descriptor.styles.some((s) => s.scoped);
385
+ const { id, filename, cssVars } = descriptor;
386
+ let transformAssetUrls = options.template?.transformAssetUrls;
387
+ let assetUrlOptions;
388
+ if (transformAssetUrls === false) ;
389
+ else if (options.devServer) {
390
+ if (filename.startsWith(options.root)) {
391
+ const devBase = options.devServer.config.base;
392
+ assetUrlOptions = {
393
+ base: (options.devServer.config.server?.origin ?? "") + devBase + slash(path.relative(options.root, path.dirname(filename))),
394
+ includeAbsolute: !!devBase
395
+ };
396
+ }
397
+ } else {
398
+ assetUrlOptions = {
399
+ includeAbsolute: true
400
+ };
401
+ }
402
+ if (transformAssetUrls && typeof transformAssetUrls === "object") {
403
+ if (Object.values(transformAssetUrls).some((val) => Array.isArray(val))) {
404
+ transformAssetUrls = {
405
+ ...assetUrlOptions,
406
+ tags: transformAssetUrls
407
+ };
408
+ } else {
409
+ transformAssetUrls = { ...assetUrlOptions, ...transformAssetUrls };
410
+ }
411
+ } else {
412
+ transformAssetUrls = assetUrlOptions;
413
+ }
414
+ let preprocessOptions = block.lang && options.template?.preprocessOptions;
415
+ if (block.lang === "pug") {
416
+ preprocessOptions = {
417
+ doctype: "html",
418
+ ...preprocessOptions
419
+ };
420
+ }
421
+ const expressionPlugins = options.template?.compilerOptions?.expressionPlugins || [];
422
+ const lang = descriptor.scriptSetup?.lang || descriptor.script?.lang;
423
+ if (lang && /tsx?$/.test(lang) && !expressionPlugins.includes("typescript")) {
424
+ expressionPlugins.push("typescript");
425
+ }
426
+ return {
427
+ ...options.template,
428
+ // @ts-expect-error TODO remove when 3.6 is out
429
+ vapor: descriptor.vapor,
430
+ id,
431
+ ast: canReuseAST(options.compiler.version) ? descriptor.template?.ast : void 0,
432
+ filename,
433
+ scoped: hasScoped,
434
+ slotted: descriptor.slotted,
435
+ isProd: options.isProduction,
436
+ inMap: block.src ? void 0 : block.map,
437
+ ssr,
438
+ ssrCssVars: cssVars,
439
+ transformAssetUrls,
440
+ preprocessLang: block.lang === "html" ? void 0 : block.lang,
441
+ preprocessOptions,
442
+ compilerOptions: {
443
+ ...options.template?.compilerOptions,
444
+ scopeId: hasScoped ? `data-v-${id}` : void 0,
445
+ bindingMetadata: resolvedScript ? resolvedScript.bindings : void 0,
446
+ expressionPlugins,
447
+ sourceMap: options.sourceMap
448
+ }
449
+ };
450
+ }
451
+ function canReuseAST(version2) {
452
+ if (version2) {
453
+ const [_, minor, patch] = version2.split(".").map(Number);
454
+ if (minor >= 4 && patch >= 3) {
455
+ return true;
456
+ }
457
+ }
458
+ return false;
459
+ }
460
+ var clientCache = /* @__PURE__ */ new WeakMap();
461
+ var ssrCache = /* @__PURE__ */ new WeakMap();
462
+ var typeDepToSFCMap = /* @__PURE__ */ new Map();
463
+ function invalidateScript(filename) {
464
+ const desc = cache.get(filename);
465
+ if (desc) {
466
+ clientCache.delete(desc);
467
+ ssrCache.delete(desc);
468
+ }
469
+ }
470
+ function getResolvedScript(descriptor, ssr) {
471
+ return (ssr ? ssrCache : clientCache).get(descriptor);
472
+ }
473
+ function setResolvedScript(descriptor, script, ssr) {
474
+ (ssr ? ssrCache : clientCache).set(descriptor, script);
475
+ }
476
+ function clearScriptCache() {
477
+ clientCache = /* @__PURE__ */ new WeakMap();
478
+ ssrCache = /* @__PURE__ */ new WeakMap();
479
+ }
480
+ function isUseInlineTemplate(descriptor, options) {
481
+ return !options.devServer && !options.devToolsEnabled && !!descriptor.scriptSetup && !descriptor.template?.src;
482
+ }
483
+ var scriptIdentifier = `_sfc_main`;
484
+ function resolveScript(descriptor, options, ssr, customElement) {
485
+ if (!descriptor.script && !descriptor.scriptSetup) {
486
+ return null;
487
+ }
488
+ const cached = getResolvedScript(descriptor, ssr);
489
+ if (cached) {
490
+ return cached;
491
+ }
492
+ const resolved = options.compiler.compileScript(descriptor, {
493
+ ...options.script,
494
+ id: descriptor.id,
495
+ isProd: options.isProduction,
496
+ inlineTemplate: isUseInlineTemplate(descriptor, options),
497
+ templateOptions: resolveTemplateCompilerOptions(descriptor, options, ssr),
498
+ sourceMap: options.sourceMap,
499
+ genDefaultAs: canInlineMain(descriptor, options) ? scriptIdentifier : void 0,
500
+ customElement,
501
+ propsDestructure: options.features?.propsDestructure ?? options.script?.propsDestructure
502
+ });
503
+ if (!options.isProduction && resolved?.deps) {
504
+ for (const [key, sfcs] of typeDepToSFCMap) {
505
+ if (sfcs.has(descriptor.filename) && !resolved.deps.includes(key)) {
506
+ sfcs.delete(descriptor.filename);
507
+ }
508
+ }
509
+ for (const dep of resolved.deps) {
510
+ const existingSet = typeDepToSFCMap.get(dep);
511
+ if (!existingSet) {
512
+ typeDepToSFCMap.set(dep, /* @__PURE__ */ new Set([descriptor.filename]));
513
+ } else {
514
+ existingSet.add(descriptor.filename);
515
+ }
516
+ }
517
+ }
518
+ setResolvedScript(descriptor, resolved, ssr);
519
+ return resolved;
520
+ }
521
+ function canInlineMain(descriptor, options) {
522
+ if (descriptor.script?.src || descriptor.scriptSetup?.src) {
523
+ return false;
524
+ }
525
+ const lang = descriptor.script?.lang || descriptor.scriptSetup?.lang;
526
+ if (!lang || lang === "js") {
527
+ return true;
528
+ }
529
+ if (lang === "ts" && options.devServer) {
530
+ return true;
531
+ }
532
+ return false;
533
+ }
534
+ var comma = ",".charCodeAt(0);
535
+ var semicolon = ";".charCodeAt(0);
536
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
537
+ var intToChar = new Uint8Array(64);
538
+ var charToInt = new Uint8Array(128);
539
+ for (let i = 0; i < chars.length; i++) {
540
+ const c = chars.charCodeAt(i);
541
+ intToChar[i] = c;
542
+ charToInt[c] = i;
543
+ }
544
+ function decodeInteger(reader, relative) {
545
+ let value = 0;
546
+ let shift = 0;
547
+ let integer = 0;
548
+ do {
549
+ const c = reader.next();
550
+ integer = charToInt[c];
551
+ value |= (integer & 31) << shift;
552
+ shift += 5;
553
+ } while (integer & 32);
554
+ const shouldNegate = value & 1;
555
+ value >>>= 1;
556
+ if (shouldNegate) {
557
+ value = -2147483648 | -value;
558
+ }
559
+ return relative + value;
560
+ }
561
+ function encodeInteger(builder, num, relative) {
562
+ let delta = num - relative;
563
+ delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
564
+ do {
565
+ let clamped = delta & 31;
566
+ delta >>>= 5;
567
+ if (delta > 0)
568
+ clamped |= 32;
569
+ builder.write(intToChar[clamped]);
570
+ } while (delta > 0);
571
+ return num;
572
+ }
573
+ function hasMoreVlq(reader, max) {
574
+ if (reader.pos >= max)
575
+ return false;
576
+ return reader.peek() !== comma;
577
+ }
578
+ var bufLength = 1024 * 16;
579
+ var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? {
580
+ decode(buf) {
581
+ const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
582
+ return out.toString();
583
+ }
584
+ } : {
585
+ decode(buf) {
586
+ let out = "";
587
+ for (let i = 0; i < buf.length; i++) {
588
+ out += String.fromCharCode(buf[i]);
589
+ }
590
+ return out;
591
+ }
592
+ };
593
+ var StringWriter = class {
594
+ constructor() {
595
+ this.pos = 0;
596
+ this.out = "";
597
+ this.buffer = new Uint8Array(bufLength);
598
+ }
599
+ write(v) {
600
+ const { buffer } = this;
601
+ buffer[this.pos++] = v;
602
+ if (this.pos === bufLength) {
603
+ this.out += td.decode(buffer);
604
+ this.pos = 0;
605
+ }
606
+ }
607
+ flush() {
608
+ const { buffer, out, pos } = this;
609
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
610
+ }
611
+ };
612
+ var StringReader = class {
613
+ constructor(buffer) {
614
+ this.pos = 0;
615
+ this.buffer = buffer;
616
+ }
617
+ next() {
618
+ return this.buffer.charCodeAt(this.pos++);
619
+ }
620
+ peek() {
621
+ return this.buffer.charCodeAt(this.pos);
622
+ }
623
+ indexOf(char) {
624
+ const { buffer, pos } = this;
625
+ const idx = buffer.indexOf(char, pos);
626
+ return idx === -1 ? buffer.length : idx;
627
+ }
628
+ };
629
+ function decode(mappings) {
630
+ const { length } = mappings;
631
+ const reader = new StringReader(mappings);
632
+ const decoded = [];
633
+ let genColumn = 0;
634
+ let sourcesIndex = 0;
635
+ let sourceLine = 0;
636
+ let sourceColumn = 0;
637
+ let namesIndex = 0;
638
+ do {
639
+ const semi = reader.indexOf(";");
640
+ const line = [];
641
+ let sorted = true;
642
+ let lastCol = 0;
643
+ genColumn = 0;
644
+ while (reader.pos < semi) {
645
+ let seg;
646
+ genColumn = decodeInteger(reader, genColumn);
647
+ if (genColumn < lastCol)
648
+ sorted = false;
649
+ lastCol = genColumn;
650
+ if (hasMoreVlq(reader, semi)) {
651
+ sourcesIndex = decodeInteger(reader, sourcesIndex);
652
+ sourceLine = decodeInteger(reader, sourceLine);
653
+ sourceColumn = decodeInteger(reader, sourceColumn);
654
+ if (hasMoreVlq(reader, semi)) {
655
+ namesIndex = decodeInteger(reader, namesIndex);
656
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
657
+ } else {
658
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
659
+ }
660
+ } else {
661
+ seg = [genColumn];
662
+ }
663
+ line.push(seg);
664
+ reader.pos++;
665
+ }
666
+ if (!sorted)
667
+ sort(line);
668
+ decoded.push(line);
669
+ reader.pos = semi + 1;
670
+ } while (reader.pos <= length);
671
+ return decoded;
672
+ }
673
+ function sort(line) {
674
+ line.sort(sortComparator$1);
675
+ }
676
+ function sortComparator$1(a, b) {
677
+ return a[0] - b[0];
678
+ }
679
+ function encode(decoded) {
680
+ const writer = new StringWriter();
681
+ let sourcesIndex = 0;
682
+ let sourceLine = 0;
683
+ let sourceColumn = 0;
684
+ let namesIndex = 0;
685
+ for (let i = 0; i < decoded.length; i++) {
686
+ const line = decoded[i];
687
+ if (i > 0)
688
+ writer.write(semicolon);
689
+ if (line.length === 0)
690
+ continue;
691
+ let genColumn = 0;
692
+ for (let j = 0; j < line.length; j++) {
693
+ const segment = line[j];
694
+ if (j > 0)
695
+ writer.write(comma);
696
+ genColumn = encodeInteger(writer, segment[0], genColumn);
697
+ if (segment.length === 1)
698
+ continue;
699
+ sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
700
+ sourceLine = encodeInteger(writer, segment[2], sourceLine);
701
+ sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
702
+ if (segment.length === 4)
703
+ continue;
704
+ namesIndex = encodeInteger(writer, segment[4], namesIndex);
705
+ }
706
+ }
707
+ return writer.flush();
708
+ }
709
+ var schemeRegex = /^[\w+.-]+:\/\//;
710
+ var urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
711
+ var fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
712
+ function isAbsoluteUrl(input) {
713
+ return schemeRegex.test(input);
714
+ }
715
+ function isSchemeRelativeUrl(input) {
716
+ return input.startsWith("//");
717
+ }
718
+ function isAbsolutePath(input) {
719
+ return input.startsWith("/");
720
+ }
721
+ function isFileUrl(input) {
722
+ return input.startsWith("file:");
723
+ }
724
+ function isRelative(input) {
725
+ return /^[.?#]/.test(input);
726
+ }
727
+ function parseAbsoluteUrl(input) {
728
+ const match = urlRegex.exec(input);
729
+ return makeUrl(match[1], match[2] || "", match[3], match[4] || "", match[5] || "/", match[6] || "", match[7] || "");
730
+ }
731
+ function parseFileUrl(input) {
732
+ const match = fileRegex.exec(input);
733
+ const path3 = match[2];
734
+ return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path3) ? path3 : "/" + path3, match[3] || "", match[4] || "");
735
+ }
736
+ function makeUrl(scheme, user, host, port, path3, query, hash2) {
737
+ return {
738
+ scheme,
739
+ user,
740
+ host,
741
+ port,
742
+ path: path3,
743
+ query,
744
+ hash: hash2,
745
+ type: 7
746
+ };
747
+ }
748
+ function parseUrl(input) {
749
+ if (isSchemeRelativeUrl(input)) {
750
+ const url2 = parseAbsoluteUrl("http:" + input);
751
+ url2.scheme = "";
752
+ url2.type = 6;
753
+ return url2;
754
+ }
755
+ if (isAbsolutePath(input)) {
756
+ const url2 = parseAbsoluteUrl("http://foo.com" + input);
757
+ url2.scheme = "";
758
+ url2.host = "";
759
+ url2.type = 5;
760
+ return url2;
761
+ }
762
+ if (isFileUrl(input))
763
+ return parseFileUrl(input);
764
+ if (isAbsoluteUrl(input))
765
+ return parseAbsoluteUrl(input);
766
+ const url = parseAbsoluteUrl("http://foo.com/" + input);
767
+ url.scheme = "";
768
+ url.host = "";
769
+ url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
770
+ return url;
771
+ }
772
+ function stripPathFilename(path3) {
773
+ if (path3.endsWith("/.."))
774
+ return path3;
775
+ const index = path3.lastIndexOf("/");
776
+ return path3.slice(0, index + 1);
777
+ }
778
+ function mergePaths(url, base) {
779
+ normalizePath(base, base.type);
780
+ if (url.path === "/") {
781
+ url.path = base.path;
782
+ } else {
783
+ url.path = stripPathFilename(base.path) + url.path;
784
+ }
785
+ }
786
+ function normalizePath(url, type) {
787
+ const rel = type <= 4;
788
+ const pieces = url.path.split("/");
789
+ let pointer = 1;
790
+ let positive = 0;
791
+ let addTrailingSlash = false;
792
+ for (let i = 1; i < pieces.length; i++) {
793
+ const piece = pieces[i];
794
+ if (!piece) {
795
+ addTrailingSlash = true;
796
+ continue;
797
+ }
798
+ addTrailingSlash = false;
799
+ if (piece === ".")
800
+ continue;
801
+ if (piece === "..") {
802
+ if (positive) {
803
+ addTrailingSlash = true;
804
+ positive--;
805
+ pointer--;
806
+ } else if (rel) {
807
+ pieces[pointer++] = piece;
808
+ }
809
+ continue;
810
+ }
811
+ pieces[pointer++] = piece;
812
+ positive++;
813
+ }
814
+ let path3 = "";
815
+ for (let i = 1; i < pointer; i++) {
816
+ path3 += "/" + pieces[i];
817
+ }
818
+ if (!path3 || addTrailingSlash && !path3.endsWith("/..")) {
819
+ path3 += "/";
820
+ }
821
+ url.path = path3;
822
+ }
823
+ function resolve$1(input, base) {
824
+ if (!input && !base)
825
+ return "";
826
+ const url = parseUrl(input);
827
+ let inputType = url.type;
828
+ if (base && inputType !== 7) {
829
+ const baseUrl = parseUrl(base);
830
+ const baseType = baseUrl.type;
831
+ switch (inputType) {
832
+ case 1:
833
+ url.hash = baseUrl.hash;
834
+ // fall through
835
+ case 2:
836
+ url.query = baseUrl.query;
837
+ // fall through
838
+ case 3:
839
+ case 4:
840
+ mergePaths(url, baseUrl);
841
+ // fall through
842
+ case 5:
843
+ url.user = baseUrl.user;
844
+ url.host = baseUrl.host;
845
+ url.port = baseUrl.port;
846
+ // fall through
847
+ case 6:
848
+ url.scheme = baseUrl.scheme;
849
+ }
850
+ if (baseType > inputType)
851
+ inputType = baseType;
852
+ }
853
+ normalizePath(url, inputType);
854
+ const queryHash = url.query + url.hash;
855
+ switch (inputType) {
856
+ // This is impossible, because of the empty checks at the start of the function.
857
+ // case UrlType.Empty:
858
+ case 2:
859
+ case 3:
860
+ return queryHash;
861
+ case 4: {
862
+ const path3 = url.path.slice(1);
863
+ if (!path3)
864
+ return queryHash || ".";
865
+ if (isRelative(base || input) && !isRelative(path3)) {
866
+ return "./" + path3 + queryHash;
867
+ }
868
+ return path3 + queryHash;
869
+ }
870
+ case 5:
871
+ return url.path + queryHash;
872
+ default:
873
+ return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
874
+ }
875
+ }
876
+ function resolve(input, base) {
877
+ if (base && !base.endsWith("/"))
878
+ base += "/";
879
+ return resolve$1(input, base);
880
+ }
881
+ function stripFilename(path3) {
882
+ if (!path3)
883
+ return "";
884
+ const index = path3.lastIndexOf("/");
885
+ return path3.slice(0, index + 1);
886
+ }
887
+ var COLUMN$1 = 0;
888
+ function maybeSort(mappings, owned) {
889
+ const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
890
+ if (unsortedIndex === mappings.length)
891
+ return mappings;
892
+ if (!owned)
893
+ mappings = mappings.slice();
894
+ for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
895
+ mappings[i] = sortSegments(mappings[i], owned);
896
+ }
897
+ return mappings;
898
+ }
899
+ function nextUnsortedSegmentLine(mappings, start) {
900
+ for (let i = start; i < mappings.length; i++) {
901
+ if (!isSorted(mappings[i]))
902
+ return i;
903
+ }
904
+ return mappings.length;
905
+ }
906
+ function isSorted(line) {
907
+ for (let j = 1; j < line.length; j++) {
908
+ if (line[j][COLUMN$1] < line[j - 1][COLUMN$1]) {
909
+ return false;
910
+ }
911
+ }
912
+ return true;
913
+ }
914
+ function sortSegments(line, owned) {
915
+ if (!owned)
916
+ line = line.slice();
917
+ return line.sort(sortComparator);
918
+ }
919
+ function sortComparator(a, b) {
920
+ return a[COLUMN$1] - b[COLUMN$1];
921
+ }
922
+ function memoizedState() {
923
+ return {
924
+ lastKey: -1,
925
+ lastNeedle: -1,
926
+ lastIndex: -1
927
+ };
928
+ }
929
+ var TraceMap = class {
930
+ constructor(map, mapUrl) {
931
+ const isString = typeof map === "string";
932
+ if (!isString && map._decodedMemo)
933
+ return map;
934
+ const parsed = isString ? JSON.parse(map) : map;
935
+ const { version: version2, file, names, sourceRoot, sources, sourcesContent } = parsed;
936
+ this.version = version2;
937
+ this.file = file;
938
+ this.names = names || [];
939
+ this.sourceRoot = sourceRoot;
940
+ this.sources = sources;
941
+ this.sourcesContent = sourcesContent;
942
+ this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
943
+ const from = resolve(sourceRoot || "", stripFilename(mapUrl));
944
+ this.resolvedSources = sources.map((s) => resolve(s || "", from));
945
+ const { mappings } = parsed;
946
+ if (typeof mappings === "string") {
947
+ this._encoded = mappings;
948
+ this._decoded = void 0;
949
+ } else {
950
+ this._encoded = void 0;
951
+ this._decoded = maybeSort(mappings, isString);
952
+ }
953
+ this._decodedMemo = memoizedState();
954
+ this._bySources = void 0;
955
+ this._bySourceMemos = void 0;
956
+ }
957
+ };
958
+ function cast$2(map) {
959
+ return map;
960
+ }
961
+ function decodedMappings(map) {
962
+ var _a;
963
+ return (_a = cast$2(map))._decoded || (_a._decoded = decode(cast$2(map)._encoded));
964
+ }
965
+ function eachMapping(map, cb) {
966
+ const decoded = decodedMappings(map);
967
+ const { names, resolvedSources } = map;
968
+ for (let i = 0; i < decoded.length; i++) {
969
+ const line = decoded[i];
970
+ for (let j = 0; j < line.length; j++) {
971
+ const seg = line[j];
972
+ const generatedLine = i + 1;
973
+ const generatedColumn = seg[0];
974
+ let source = null;
975
+ let originalLine = null;
976
+ let originalColumn = null;
977
+ let name = null;
978
+ if (seg.length !== 1) {
979
+ source = resolvedSources[seg[1]];
980
+ originalLine = seg[2] + 1;
981
+ originalColumn = seg[3];
982
+ }
983
+ if (seg.length === 5)
984
+ name = names[seg[4]];
985
+ cb({
986
+ generatedLine,
987
+ generatedColumn,
988
+ source,
989
+ originalLine,
990
+ originalColumn,
991
+ name
992
+ });
993
+ }
994
+ }
995
+ }
996
+ var SetArray = class {
997
+ constructor() {
998
+ this._indexes = { __proto__: null };
999
+ this.array = [];
1000
+ }
1001
+ };
1002
+ function cast$1(set) {
1003
+ return set;
1004
+ }
1005
+ function get(setarr, key) {
1006
+ return cast$1(setarr)._indexes[key];
1007
+ }
1008
+ function put(setarr, key) {
1009
+ const index = get(setarr, key);
1010
+ if (index !== void 0)
1011
+ return index;
1012
+ const { array, _indexes: indexes } = cast$1(setarr);
1013
+ const length = array.push(key);
1014
+ return indexes[key] = length - 1;
1015
+ }
1016
+ var COLUMN = 0;
1017
+ var NO_NAME = -1;
1018
+ var GenMapping = class {
1019
+ constructor({ file, sourceRoot } = {}) {
1020
+ this._names = new SetArray();
1021
+ this._sources = new SetArray();
1022
+ this._sourcesContent = [];
1023
+ this._mappings = [];
1024
+ this.file = file;
1025
+ this.sourceRoot = sourceRoot;
1026
+ this._ignoreList = new SetArray();
1027
+ }
1028
+ };
1029
+ function cast(map) {
1030
+ return map;
1031
+ }
1032
+ function addMapping(map, mapping) {
1033
+ return addMappingInternal(false, map, mapping);
1034
+ }
1035
+ function toDecodedMap(map) {
1036
+ const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, _ignoreList: ignoreList2 } = cast(map);
1037
+ removeEmptyFinalLines(mappings);
1038
+ return {
1039
+ version: 3,
1040
+ file: map.file || void 0,
1041
+ names: names.array,
1042
+ sourceRoot: map.sourceRoot || void 0,
1043
+ sources: sources.array,
1044
+ sourcesContent,
1045
+ mappings,
1046
+ ignoreList: ignoreList2.array
1047
+ };
1048
+ }
1049
+ function toEncodedMap(map) {
1050
+ const decoded = toDecodedMap(map);
1051
+ return Object.assign(Object.assign({}, decoded), { mappings: encode(decoded.mappings) });
1052
+ }
1053
+ function fromMap(input) {
1054
+ const map = new TraceMap(input);
1055
+ const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot });
1056
+ putAll(cast(gen)._names, map.names);
1057
+ putAll(cast(gen)._sources, map.sources);
1058
+ cast(gen)._sourcesContent = map.sourcesContent || map.sources.map(() => null);
1059
+ cast(gen)._mappings = decodedMappings(map);
1060
+ if (map.ignoreList)
1061
+ putAll(cast(gen)._ignoreList, map.ignoreList);
1062
+ return gen;
1063
+ }
1064
+ function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) {
1065
+ const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names } = cast(map);
1066
+ const line = getLine(mappings, genLine);
1067
+ const index = getColumnIndex(line, genColumn);
1068
+ if (!source) {
1069
+ return insert(line, index, [genColumn]);
1070
+ }
1071
+ const sourcesIndex = put(sources, source);
1072
+ const namesIndex = name ? put(names, name) : NO_NAME;
1073
+ if (sourcesIndex === sourcesContent.length)
1074
+ sourcesContent[sourcesIndex] = content !== null && content !== void 0 ? content : null;
1075
+ return insert(line, index, name ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] : [genColumn, sourcesIndex, sourceLine, sourceColumn]);
1076
+ }
1077
+ function getLine(mappings, index) {
1078
+ for (let i = mappings.length; i <= index; i++) {
1079
+ mappings[i] = [];
1080
+ }
1081
+ return mappings[index];
1082
+ }
1083
+ function getColumnIndex(line, genColumn) {
1084
+ let index = line.length;
1085
+ for (let i = index - 1; i >= 0; index = i--) {
1086
+ const current = line[i];
1087
+ if (genColumn >= current[COLUMN])
1088
+ break;
1089
+ }
1090
+ return index;
1091
+ }
1092
+ function insert(array, index, value) {
1093
+ for (let i = array.length; i > index; i--) {
1094
+ array[i] = array[i - 1];
1095
+ }
1096
+ array[index] = value;
1097
+ }
1098
+ function removeEmptyFinalLines(mappings) {
1099
+ const { length } = mappings;
1100
+ let len = length;
1101
+ for (let i = len - 1; i >= 0; len = i, i--) {
1102
+ if (mappings[i].length > 0)
1103
+ break;
1104
+ }
1105
+ if (len < length)
1106
+ mappings.length = len;
1107
+ }
1108
+ function putAll(setarr, array) {
1109
+ for (let i = 0; i < array.length; i++)
1110
+ put(setarr, array[i]);
1111
+ }
1112
+ function addMappingInternal(skipable, map, mapping) {
1113
+ const { generated, source, original, name, content } = mapping;
1114
+ if (!source) {
1115
+ return addSegmentInternal(skipable, map, generated.line - 1, generated.column, null, null, null, null, null);
1116
+ }
1117
+ return addSegmentInternal(skipable, map, generated.line - 1, generated.column, source, original.line - 1, original.column, name, content);
1118
+ }
1119
+ function getDefaultExportFromCjs(x) {
1120
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1121
+ }
1122
+ var src = { exports: {} };
1123
+ var browser = { exports: {} };
1124
+ var ms;
1125
+ var hasRequiredMs;
1126
+ function requireMs() {
1127
+ if (hasRequiredMs) return ms;
1128
+ hasRequiredMs = 1;
1129
+ var s = 1e3;
1130
+ var m = s * 60;
1131
+ var h = m * 60;
1132
+ var d = h * 24;
1133
+ var w = d * 7;
1134
+ var y = d * 365.25;
1135
+ ms = function(val, options) {
1136
+ options = options || {};
1137
+ var type = typeof val;
1138
+ if (type === "string" && val.length > 0) {
1139
+ return parse(val);
1140
+ } else if (type === "number" && isFinite(val)) {
1141
+ return options.long ? fmtLong(val) : fmtShort(val);
1142
+ }
1143
+ throw new Error(
1144
+ "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
1145
+ );
1146
+ };
1147
+ function parse(str) {
1148
+ str = String(str);
1149
+ if (str.length > 100) {
1150
+ return;
1151
+ }
1152
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
1153
+ str
1154
+ );
1155
+ if (!match) {
1156
+ return;
1157
+ }
1158
+ var n = parseFloat(match[1]);
1159
+ var type = (match[2] || "ms").toLowerCase();
1160
+ switch (type) {
1161
+ case "years":
1162
+ case "year":
1163
+ case "yrs":
1164
+ case "yr":
1165
+ case "y":
1166
+ return n * y;
1167
+ case "weeks":
1168
+ case "week":
1169
+ case "w":
1170
+ return n * w;
1171
+ case "days":
1172
+ case "day":
1173
+ case "d":
1174
+ return n * d;
1175
+ case "hours":
1176
+ case "hour":
1177
+ case "hrs":
1178
+ case "hr":
1179
+ case "h":
1180
+ return n * h;
1181
+ case "minutes":
1182
+ case "minute":
1183
+ case "mins":
1184
+ case "min":
1185
+ case "m":
1186
+ return n * m;
1187
+ case "seconds":
1188
+ case "second":
1189
+ case "secs":
1190
+ case "sec":
1191
+ case "s":
1192
+ return n * s;
1193
+ case "milliseconds":
1194
+ case "millisecond":
1195
+ case "msecs":
1196
+ case "msec":
1197
+ case "ms":
1198
+ return n;
1199
+ default:
1200
+ return void 0;
1201
+ }
1202
+ }
1203
+ function fmtShort(ms2) {
1204
+ var msAbs = Math.abs(ms2);
1205
+ if (msAbs >= d) {
1206
+ return Math.round(ms2 / d) + "d";
1207
+ }
1208
+ if (msAbs >= h) {
1209
+ return Math.round(ms2 / h) + "h";
1210
+ }
1211
+ if (msAbs >= m) {
1212
+ return Math.round(ms2 / m) + "m";
1213
+ }
1214
+ if (msAbs >= s) {
1215
+ return Math.round(ms2 / s) + "s";
1216
+ }
1217
+ return ms2 + "ms";
1218
+ }
1219
+ function fmtLong(ms2) {
1220
+ var msAbs = Math.abs(ms2);
1221
+ if (msAbs >= d) {
1222
+ return plural(ms2, msAbs, d, "day");
1223
+ }
1224
+ if (msAbs >= h) {
1225
+ return plural(ms2, msAbs, h, "hour");
1226
+ }
1227
+ if (msAbs >= m) {
1228
+ return plural(ms2, msAbs, m, "minute");
1229
+ }
1230
+ if (msAbs >= s) {
1231
+ return plural(ms2, msAbs, s, "second");
1232
+ }
1233
+ return ms2 + " ms";
1234
+ }
1235
+ function plural(ms2, msAbs, n, name) {
1236
+ var isPlural = msAbs >= n * 1.5;
1237
+ return Math.round(ms2 / n) + " " + name + (isPlural ? "s" : "");
1238
+ }
1239
+ return ms;
1240
+ }
1241
+ var common;
1242
+ var hasRequiredCommon;
1243
+ function requireCommon() {
1244
+ if (hasRequiredCommon) return common;
1245
+ hasRequiredCommon = 1;
1246
+ function setup(env) {
1247
+ createDebug.debug = createDebug;
1248
+ createDebug.default = createDebug;
1249
+ createDebug.coerce = coerce;
1250
+ createDebug.disable = disable;
1251
+ createDebug.enable = enable;
1252
+ createDebug.enabled = enabled;
1253
+ createDebug.humanize = requireMs();
1254
+ createDebug.destroy = destroy;
1255
+ Object.keys(env).forEach((key) => {
1256
+ createDebug[key] = env[key];
1257
+ });
1258
+ createDebug.names = [];
1259
+ createDebug.skips = [];
1260
+ createDebug.formatters = {};
1261
+ function selectColor(namespace) {
1262
+ let hash2 = 0;
1263
+ for (let i = 0; i < namespace.length; i++) {
1264
+ hash2 = (hash2 << 5) - hash2 + namespace.charCodeAt(i);
1265
+ hash2 |= 0;
1266
+ }
1267
+ return createDebug.colors[Math.abs(hash2) % createDebug.colors.length];
1268
+ }
1269
+ createDebug.selectColor = selectColor;
1270
+ function createDebug(namespace) {
1271
+ let prevTime;
1272
+ let enableOverride = null;
1273
+ let namespacesCache;
1274
+ let enabledCache;
1275
+ function debug2(...args) {
1276
+ if (!debug2.enabled) {
1277
+ return;
1278
+ }
1279
+ const self = debug2;
1280
+ const curr = Number(/* @__PURE__ */ new Date());
1281
+ const ms2 = curr - (prevTime || curr);
1282
+ self.diff = ms2;
1283
+ self.prev = prevTime;
1284
+ self.curr = curr;
1285
+ prevTime = curr;
1286
+ args[0] = createDebug.coerce(args[0]);
1287
+ if (typeof args[0] !== "string") {
1288
+ args.unshift("%O");
1289
+ }
1290
+ let index = 0;
1291
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
1292
+ if (match === "%%") {
1293
+ return "%";
1294
+ }
1295
+ index++;
1296
+ const formatter = createDebug.formatters[format];
1297
+ if (typeof formatter === "function") {
1298
+ const val = args[index];
1299
+ match = formatter.call(self, val);
1300
+ args.splice(index, 1);
1301
+ index--;
1302
+ }
1303
+ return match;
1304
+ });
1305
+ createDebug.formatArgs.call(self, args);
1306
+ const logFn = self.log || createDebug.log;
1307
+ logFn.apply(self, args);
1308
+ }
1309
+ debug2.namespace = namespace;
1310
+ debug2.useColors = createDebug.useColors();
1311
+ debug2.color = createDebug.selectColor(namespace);
1312
+ debug2.extend = extend;
1313
+ debug2.destroy = createDebug.destroy;
1314
+ Object.defineProperty(debug2, "enabled", {
1315
+ enumerable: true,
1316
+ configurable: false,
1317
+ get: () => {
1318
+ if (enableOverride !== null) {
1319
+ return enableOverride;
1320
+ }
1321
+ if (namespacesCache !== createDebug.namespaces) {
1322
+ namespacesCache = createDebug.namespaces;
1323
+ enabledCache = createDebug.enabled(namespace);
1324
+ }
1325
+ return enabledCache;
1326
+ },
1327
+ set: (v) => {
1328
+ enableOverride = v;
1329
+ }
1330
+ });
1331
+ if (typeof createDebug.init === "function") {
1332
+ createDebug.init(debug2);
1333
+ }
1334
+ return debug2;
1335
+ }
1336
+ function extend(namespace, delimiter) {
1337
+ const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
1338
+ newDebug.log = this.log;
1339
+ return newDebug;
1340
+ }
1341
+ function enable(namespaces) {
1342
+ createDebug.save(namespaces);
1343
+ createDebug.namespaces = namespaces;
1344
+ createDebug.names = [];
1345
+ createDebug.skips = [];
1346
+ const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(" ", ",").split(",").filter(Boolean);
1347
+ for (const ns of split) {
1348
+ if (ns[0] === "-") {
1349
+ createDebug.skips.push(ns.slice(1));
1350
+ } else {
1351
+ createDebug.names.push(ns);
1352
+ }
1353
+ }
1354
+ }
1355
+ function matchesTemplate(search, template) {
1356
+ let searchIndex = 0;
1357
+ let templateIndex = 0;
1358
+ let starIndex = -1;
1359
+ let matchIndex = 0;
1360
+ while (searchIndex < search.length) {
1361
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
1362
+ if (template[templateIndex] === "*") {
1363
+ starIndex = templateIndex;
1364
+ matchIndex = searchIndex;
1365
+ templateIndex++;
1366
+ } else {
1367
+ searchIndex++;
1368
+ templateIndex++;
1369
+ }
1370
+ } else if (starIndex !== -1) {
1371
+ templateIndex = starIndex + 1;
1372
+ matchIndex++;
1373
+ searchIndex = matchIndex;
1374
+ } else {
1375
+ return false;
1376
+ }
1377
+ }
1378
+ while (templateIndex < template.length && template[templateIndex] === "*") {
1379
+ templateIndex++;
1380
+ }
1381
+ return templateIndex === template.length;
1382
+ }
1383
+ function disable() {
1384
+ const namespaces = [
1385
+ ...createDebug.names,
1386
+ ...createDebug.skips.map((namespace) => "-" + namespace)
1387
+ ].join(",");
1388
+ createDebug.enable("");
1389
+ return namespaces;
1390
+ }
1391
+ function enabled(name) {
1392
+ for (const skip of createDebug.skips) {
1393
+ if (matchesTemplate(name, skip)) {
1394
+ return false;
1395
+ }
1396
+ }
1397
+ for (const ns of createDebug.names) {
1398
+ if (matchesTemplate(name, ns)) {
1399
+ return true;
1400
+ }
1401
+ }
1402
+ return false;
1403
+ }
1404
+ function coerce(val) {
1405
+ if (val instanceof Error) {
1406
+ return val.stack || val.message;
1407
+ }
1408
+ return val;
1409
+ }
1410
+ function destroy() {
1411
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
1412
+ }
1413
+ createDebug.enable(createDebug.load());
1414
+ return createDebug;
1415
+ }
1416
+ common = setup;
1417
+ return common;
1418
+ }
1419
+ var hasRequiredBrowser;
1420
+ function requireBrowser() {
1421
+ if (hasRequiredBrowser) return browser.exports;
1422
+ hasRequiredBrowser = 1;
1423
+ (function(module, exports) {
1424
+ exports.formatArgs = formatArgs;
1425
+ exports.save = save;
1426
+ exports.load = load;
1427
+ exports.useColors = useColors;
1428
+ exports.storage = localstorage();
1429
+ exports.destroy = /* @__PURE__ */ (() => {
1430
+ let warned = false;
1431
+ return () => {
1432
+ if (!warned) {
1433
+ warned = true;
1434
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
1435
+ }
1436
+ };
1437
+ })();
1438
+ exports.colors = [
1439
+ "#0000CC",
1440
+ "#0000FF",
1441
+ "#0033CC",
1442
+ "#0033FF",
1443
+ "#0066CC",
1444
+ "#0066FF",
1445
+ "#0099CC",
1446
+ "#0099FF",
1447
+ "#00CC00",
1448
+ "#00CC33",
1449
+ "#00CC66",
1450
+ "#00CC99",
1451
+ "#00CCCC",
1452
+ "#00CCFF",
1453
+ "#3300CC",
1454
+ "#3300FF",
1455
+ "#3333CC",
1456
+ "#3333FF",
1457
+ "#3366CC",
1458
+ "#3366FF",
1459
+ "#3399CC",
1460
+ "#3399FF",
1461
+ "#33CC00",
1462
+ "#33CC33",
1463
+ "#33CC66",
1464
+ "#33CC99",
1465
+ "#33CCCC",
1466
+ "#33CCFF",
1467
+ "#6600CC",
1468
+ "#6600FF",
1469
+ "#6633CC",
1470
+ "#6633FF",
1471
+ "#66CC00",
1472
+ "#66CC33",
1473
+ "#9900CC",
1474
+ "#9900FF",
1475
+ "#9933CC",
1476
+ "#9933FF",
1477
+ "#99CC00",
1478
+ "#99CC33",
1479
+ "#CC0000",
1480
+ "#CC0033",
1481
+ "#CC0066",
1482
+ "#CC0099",
1483
+ "#CC00CC",
1484
+ "#CC00FF",
1485
+ "#CC3300",
1486
+ "#CC3333",
1487
+ "#CC3366",
1488
+ "#CC3399",
1489
+ "#CC33CC",
1490
+ "#CC33FF",
1491
+ "#CC6600",
1492
+ "#CC6633",
1493
+ "#CC9900",
1494
+ "#CC9933",
1495
+ "#CCCC00",
1496
+ "#CCCC33",
1497
+ "#FF0000",
1498
+ "#FF0033",
1499
+ "#FF0066",
1500
+ "#FF0099",
1501
+ "#FF00CC",
1502
+ "#FF00FF",
1503
+ "#FF3300",
1504
+ "#FF3333",
1505
+ "#FF3366",
1506
+ "#FF3399",
1507
+ "#FF33CC",
1508
+ "#FF33FF",
1509
+ "#FF6600",
1510
+ "#FF6633",
1511
+ "#FF9900",
1512
+ "#FF9933",
1513
+ "#FFCC00",
1514
+ "#FFCC33"
1515
+ ];
1516
+ function useColors() {
1517
+ if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
1518
+ return true;
1519
+ }
1520
+ if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
1521
+ return false;
1522
+ }
1523
+ let m;
1524
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
1525
+ typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
1526
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
1527
+ typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
1528
+ typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
1529
+ }
1530
+ function formatArgs(args) {
1531
+ args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
1532
+ if (!this.useColors) {
1533
+ return;
1534
+ }
1535
+ const c = "color: " + this.color;
1536
+ args.splice(1, 0, c, "color: inherit");
1537
+ let index = 0;
1538
+ let lastC = 0;
1539
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
1540
+ if (match === "%%") {
1541
+ return;
1542
+ }
1543
+ index++;
1544
+ if (match === "%c") {
1545
+ lastC = index;
1546
+ }
1547
+ });
1548
+ args.splice(lastC, 0, c);
1549
+ }
1550
+ exports.log = console.debug || console.log || (() => {
1551
+ });
1552
+ function save(namespaces) {
1553
+ try {
1554
+ if (namespaces) {
1555
+ exports.storage.setItem("debug", namespaces);
1556
+ } else {
1557
+ exports.storage.removeItem("debug");
1558
+ }
1559
+ } catch (error) {
1560
+ }
1561
+ }
1562
+ function load() {
1563
+ let r;
1564
+ try {
1565
+ r = exports.storage.getItem("debug");
1566
+ } catch (error) {
1567
+ }
1568
+ if (!r && typeof process !== "undefined" && "env" in process) {
1569
+ r = process.env.DEBUG;
1570
+ }
1571
+ return r;
1572
+ }
1573
+ function localstorage() {
1574
+ try {
1575
+ return localStorage;
1576
+ } catch (error) {
1577
+ }
1578
+ }
1579
+ module.exports = requireCommon()(exports);
1580
+ const { formatters } = module.exports;
1581
+ formatters.j = function(v) {
1582
+ try {
1583
+ return JSON.stringify(v);
1584
+ } catch (error) {
1585
+ return "[UnexpectedJSONParseError]: " + error.message;
1586
+ }
1587
+ };
1588
+ })(browser, browser.exports);
1589
+ return browser.exports;
1590
+ }
1591
+ var node = { exports: {} };
1592
+ var hasRequiredNode;
1593
+ function requireNode() {
1594
+ if (hasRequiredNode) return node.exports;
1595
+ hasRequiredNode = 1;
1596
+ (function(module, exports) {
1597
+ const tty = require$$0;
1598
+ const util = require$$1;
1599
+ exports.init = init;
1600
+ exports.log = log;
1601
+ exports.formatArgs = formatArgs;
1602
+ exports.save = save;
1603
+ exports.load = load;
1604
+ exports.useColors = useColors;
1605
+ exports.destroy = util.deprecate(
1606
+ () => {
1607
+ },
1608
+ "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
1609
+ );
1610
+ exports.colors = [6, 2, 3, 4, 5, 1];
1611
+ try {
1612
+ const supportsColor = require_supports_color();
1613
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
1614
+ exports.colors = [
1615
+ 20,
1616
+ 21,
1617
+ 26,
1618
+ 27,
1619
+ 32,
1620
+ 33,
1621
+ 38,
1622
+ 39,
1623
+ 40,
1624
+ 41,
1625
+ 42,
1626
+ 43,
1627
+ 44,
1628
+ 45,
1629
+ 56,
1630
+ 57,
1631
+ 62,
1632
+ 63,
1633
+ 68,
1634
+ 69,
1635
+ 74,
1636
+ 75,
1637
+ 76,
1638
+ 77,
1639
+ 78,
1640
+ 79,
1641
+ 80,
1642
+ 81,
1643
+ 92,
1644
+ 93,
1645
+ 98,
1646
+ 99,
1647
+ 112,
1648
+ 113,
1649
+ 128,
1650
+ 129,
1651
+ 134,
1652
+ 135,
1653
+ 148,
1654
+ 149,
1655
+ 160,
1656
+ 161,
1657
+ 162,
1658
+ 163,
1659
+ 164,
1660
+ 165,
1661
+ 166,
1662
+ 167,
1663
+ 168,
1664
+ 169,
1665
+ 170,
1666
+ 171,
1667
+ 172,
1668
+ 173,
1669
+ 178,
1670
+ 179,
1671
+ 184,
1672
+ 185,
1673
+ 196,
1674
+ 197,
1675
+ 198,
1676
+ 199,
1677
+ 200,
1678
+ 201,
1679
+ 202,
1680
+ 203,
1681
+ 204,
1682
+ 205,
1683
+ 206,
1684
+ 207,
1685
+ 208,
1686
+ 209,
1687
+ 214,
1688
+ 215,
1689
+ 220,
1690
+ 221
1691
+ ];
1692
+ }
1693
+ } catch (error) {
1694
+ }
1695
+ exports.inspectOpts = Object.keys(process.env).filter((key) => {
1696
+ return /^debug_/i.test(key);
1697
+ }).reduce((obj, key) => {
1698
+ const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
1699
+ return k.toUpperCase();
1700
+ });
1701
+ let val = process.env[key];
1702
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
1703
+ val = true;
1704
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
1705
+ val = false;
1706
+ } else if (val === "null") {
1707
+ val = null;
1708
+ } else {
1709
+ val = Number(val);
1710
+ }
1711
+ obj[prop] = val;
1712
+ return obj;
1713
+ }, {});
1714
+ function useColors() {
1715
+ return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
1716
+ }
1717
+ function formatArgs(args) {
1718
+ const { namespace: name, useColors: useColors2 } = this;
1719
+ if (useColors2) {
1720
+ const c = this.color;
1721
+ const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
1722
+ const prefix = ` ${colorCode};1m${name} \x1B[0m`;
1723
+ args[0] = prefix + args[0].split("\n").join("\n" + prefix);
1724
+ args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
1725
+ } else {
1726
+ args[0] = getDate() + name + " " + args[0];
1727
+ }
1728
+ }
1729
+ function getDate() {
1730
+ if (exports.inspectOpts.hideDate) {
1731
+ return "";
1732
+ }
1733
+ return (/* @__PURE__ */ new Date()).toISOString() + " ";
1734
+ }
1735
+ function log(...args) {
1736
+ return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + "\n");
1737
+ }
1738
+ function save(namespaces) {
1739
+ if (namespaces) {
1740
+ process.env.DEBUG = namespaces;
1741
+ } else {
1742
+ delete process.env.DEBUG;
1743
+ }
1744
+ }
1745
+ function load() {
1746
+ return process.env.DEBUG;
1747
+ }
1748
+ function init(debug2) {
1749
+ debug2.inspectOpts = {};
1750
+ const keys = Object.keys(exports.inspectOpts);
1751
+ for (let i = 0; i < keys.length; i++) {
1752
+ debug2.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
1753
+ }
1754
+ }
1755
+ module.exports = requireCommon()(exports);
1756
+ const { formatters } = module.exports;
1757
+ formatters.o = function(v) {
1758
+ this.inspectOpts.colors = this.useColors;
1759
+ return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
1760
+ };
1761
+ formatters.O = function(v) {
1762
+ this.inspectOpts.colors = this.useColors;
1763
+ return util.inspect(v, this.inspectOpts);
1764
+ };
1765
+ })(node, node.exports);
1766
+ return node.exports;
1767
+ }
1768
+ var hasRequiredSrc;
1769
+ function requireSrc() {
1770
+ if (hasRequiredSrc) return src.exports;
1771
+ hasRequiredSrc = 1;
1772
+ if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
1773
+ src.exports = requireBrowser();
1774
+ } else {
1775
+ src.exports = requireNode();
1776
+ }
1777
+ return src.exports;
1778
+ }
1779
+ var srcExports = requireSrc();
1780
+ var _debug = /* @__PURE__ */ getDefaultExportFromCjs(srcExports);
1781
+ var debug = _debug("vite:hmr");
1782
+ var directRequestRE = /(?:\?|&)direct\b/;
1783
+ async function handleHotUpdate({ file, modules, read }, options, customElement, typeDepModules) {
1784
+ const prevDescriptor = getDescriptor(file, options, false, true);
1785
+ if (!prevDescriptor) {
1786
+ return;
1787
+ }
1788
+ const content = await read();
1789
+ const { descriptor } = createDescriptor(file, content, options, true);
1790
+ let needRerender = false;
1791
+ const affectedModules = /* @__PURE__ */ new Set();
1792
+ const mainModule = getMainModule(modules);
1793
+ const templateModule = modules.find((m) => /type=template/.test(m.url));
1794
+ resolveScript(descriptor, options, false, customElement);
1795
+ const scriptChanged = hasScriptChanged(prevDescriptor, descriptor);
1796
+ if (scriptChanged) {
1797
+ affectedModules.add(getScriptModule(modules) || mainModule);
1798
+ }
1799
+ if (!isEqualBlock(descriptor.template, prevDescriptor.template)) {
1800
+ if (!scriptChanged) {
1801
+ setResolvedScript(
1802
+ descriptor,
1803
+ getResolvedScript(prevDescriptor, false),
1804
+ false
1805
+ );
1806
+ }
1807
+ affectedModules.add(templateModule);
1808
+ needRerender = true;
1809
+ }
1810
+ let didUpdateStyle = false;
1811
+ const prevStyles = prevDescriptor.styles || [];
1812
+ const nextStyles = descriptor.styles || [];
1813
+ if (prevDescriptor.cssVars.join("") !== descriptor.cssVars.join("")) {
1814
+ affectedModules.add(mainModule);
1815
+ }
1816
+ if (prevStyles.some((s) => s.scoped) !== nextStyles.some((s) => s.scoped)) {
1817
+ affectedModules.add(templateModule);
1818
+ affectedModules.add(mainModule);
1819
+ }
1820
+ for (let i = 0; i < nextStyles.length; i++) {
1821
+ const prev = prevStyles[i];
1822
+ const next = nextStyles[i];
1823
+ if (!prev || !isEqualBlock(prev, next)) {
1824
+ didUpdateStyle = true;
1825
+ const mod = modules.find(
1826
+ (m) => m.url.includes(`type=style&index=${i}`) && m.url.endsWith(`.${next.lang || "css"}`) && !directRequestRE.test(m.url)
1827
+ );
1828
+ if (mod) {
1829
+ affectedModules.add(mod);
1830
+ if (mod.url.includes("&inline")) {
1831
+ affectedModules.add(mainModule);
1832
+ }
1833
+ } else {
1834
+ affectedModules.add(mainModule);
1835
+ }
1836
+ }
1837
+ }
1838
+ if (prevStyles.length > nextStyles.length) {
1839
+ affectedModules.add(mainModule);
1840
+ }
1841
+ const prevCustoms = prevDescriptor.customBlocks || [];
1842
+ const nextCustoms = descriptor.customBlocks || [];
1843
+ if (prevCustoms.length !== nextCustoms.length) {
1844
+ affectedModules.add(mainModule);
1845
+ } else {
1846
+ for (let i = 0; i < nextCustoms.length; i++) {
1847
+ const prev = prevCustoms[i];
1848
+ const next = nextCustoms[i];
1849
+ if (!prev || !isEqualBlock(prev, next)) {
1850
+ const mod = modules.find(
1851
+ (m) => m.url.includes(`type=${prev.type}&index=${i}`)
1852
+ );
1853
+ if (mod) {
1854
+ affectedModules.add(mod);
1855
+ } else {
1856
+ affectedModules.add(mainModule);
1857
+ }
1858
+ }
1859
+ }
1860
+ }
1861
+ const updateType = [];
1862
+ if (needRerender) {
1863
+ updateType.push(`template`);
1864
+ if (!templateModule) {
1865
+ affectedModules.add(mainModule);
1866
+ } else if (mainModule && !affectedModules.has(mainModule)) {
1867
+ const styleImporters = [...mainModule.importers].filter(
1868
+ (m) => isCSSRequest(m.url)
1869
+ );
1870
+ styleImporters.forEach((m) => affectedModules.add(m));
1871
+ }
1872
+ }
1873
+ if (didUpdateStyle) {
1874
+ updateType.push(`style`);
1875
+ }
1876
+ if (updateType.length) {
1877
+ if (file.endsWith(".vue")) {
1878
+ invalidateDescriptor(file);
1879
+ } else {
1880
+ cache.set(file, descriptor);
1881
+ }
1882
+ debug(`[vue:update(${updateType.join("&")})] ${file}`);
1883
+ }
1884
+ return [...affectedModules, ...typeDepModules || []].filter(
1885
+ Boolean
1886
+ );
1887
+ }
1888
+ function isEqualBlock(a, b) {
1889
+ if (!a && !b) return true;
1890
+ if (!a || !b) return false;
1891
+ if (a.src && b.src && a.src === b.src) return true;
1892
+ if (a.content !== b.content) return false;
1893
+ const keysA = Object.keys(a.attrs);
1894
+ const keysB = Object.keys(b.attrs);
1895
+ if (keysA.length !== keysB.length) {
1896
+ return false;
1897
+ }
1898
+ return keysA.every((key) => a.attrs[key] === b.attrs[key]);
1899
+ }
1900
+ function isOnlyTemplateChanged(prev, next) {
1901
+ return !hasScriptChanged(prev, next) && prev.styles.length === next.styles.length && prev.styles.every((s, i) => isEqualBlock(s, next.styles[i])) && prev.customBlocks.length === next.customBlocks.length && prev.customBlocks.every((s, i) => isEqualBlock(s, next.customBlocks[i]));
1902
+ }
1903
+ function deepEqual(obj1, obj2, excludeProps = [], deepParentsOfObj1 = []) {
1904
+ if (typeof obj1 !== typeof obj2) {
1905
+ return false;
1906
+ }
1907
+ if (obj1 == null || obj2 == null || typeof obj1 !== "object" || deepParentsOfObj1.includes(obj1)) {
1908
+ return obj1 === obj2;
1909
+ }
1910
+ const keys1 = Object.keys(obj1);
1911
+ const keys2 = Object.keys(obj2);
1912
+ if (keys1.length !== keys2.length) {
1913
+ return false;
1914
+ }
1915
+ for (const key of keys1) {
1916
+ if (excludeProps.includes(key)) {
1917
+ continue;
1918
+ }
1919
+ if (!deepEqual(obj1[key], obj2[key], excludeProps, [
1920
+ ...deepParentsOfObj1,
1921
+ obj1
1922
+ ])) {
1923
+ return false;
1924
+ }
1925
+ }
1926
+ return true;
1927
+ }
1928
+ function isEqualAst(prev, next) {
1929
+ if (typeof prev === "undefined" || typeof next === "undefined") {
1930
+ return prev === next;
1931
+ }
1932
+ if (prev.length !== next.length) {
1933
+ return false;
1934
+ }
1935
+ for (let i = 0; i < prev.length; i++) {
1936
+ const prevNode = prev[i];
1937
+ const nextNode = next[i];
1938
+ if (
1939
+ // deep equal, but ignore start/end/loc/range/leadingComments/trailingComments/innerComments
1940
+ !deepEqual(prevNode, nextNode, [
1941
+ "start",
1942
+ "end",
1943
+ "loc",
1944
+ "range",
1945
+ "leadingComments",
1946
+ "trailingComments",
1947
+ "innerComments",
1948
+ // https://github.com/vuejs/core/issues/11923
1949
+ // avoid comparing the following properties of typeParameters
1950
+ // as it may be imported from 3rd lib and complex to compare
1951
+ "_ownerScope",
1952
+ "_resolvedReference",
1953
+ "_resolvedElements"
1954
+ ])
1955
+ ) {
1956
+ return false;
1957
+ }
1958
+ }
1959
+ return true;
1960
+ }
1961
+ function hasScriptChanged(prev, next) {
1962
+ const prevScript = getResolvedScript(prev, false);
1963
+ const nextScript = getResolvedScript(next, false);
1964
+ if (!isEqualBlock(prev.script, next.script) && !isEqualAst(prevScript?.scriptAst, nextScript?.scriptAst)) {
1965
+ return true;
1966
+ }
1967
+ if (!isEqualBlock(prev.scriptSetup, next.scriptSetup) && !isEqualAst(prevScript?.scriptSetupAst, nextScript?.scriptSetupAst)) {
1968
+ return true;
1969
+ }
1970
+ const prevResolvedScript = getResolvedScript(prev, false);
1971
+ const prevImports = prevResolvedScript?.imports;
1972
+ if (prevImports) {
1973
+ return !next.template || next.shouldForceReload(prevImports);
1974
+ }
1975
+ return false;
1976
+ }
1977
+ function getMainModule(modules) {
1978
+ return modules.filter((m) => !/type=/.test(m.url) || /type=script/.test(m.url)).sort((m1, m2) => {
1979
+ return m1.url.length - m2.url.length;
1980
+ })[0];
1981
+ }
1982
+ function getScriptModule(modules) {
1983
+ return modules.find((m) => /type=script.*&lang\.\w+$/.test(m.url));
1984
+ }
1985
+ function handleTypeDepChange(affectedComponents, { modules, server: { moduleGraph } }) {
1986
+ const affected = /* @__PURE__ */ new Set();
1987
+ for (const file of affectedComponents) {
1988
+ invalidateScript(file);
1989
+ const mods = moduleGraph.getModulesByFile(file);
1990
+ if (mods) {
1991
+ const arr = [...mods];
1992
+ affected.add(getScriptModule(arr) || getMainModule(arr));
1993
+ }
1994
+ }
1995
+ return [...modules, ...affected];
1996
+ }
1997
+ var EXPORT_HELPER_ID = "\0plugin-vue:export-helper";
1998
+ var helperCode = `
1999
+ export default (sfc, props) => {
2000
+ const target = sfc.__vccOpts || sfc;
2001
+ for (const [key, val] of props) {
2002
+ target[key] = val;
2003
+ }
2004
+ return target;
2005
+ }
2006
+ `;
2007
+ async function transformMain(code, filename, options, pluginContext, ssr, customElement) {
2008
+ const { devServer, isProduction, devToolsEnabled } = options;
2009
+ const prevDescriptor = getPrevDescriptor(filename);
2010
+ const { descriptor, errors } = createDescriptor(filename, code, options);
2011
+ if (fs.existsSync(filename)) {
2012
+ getDescriptor(
2013
+ filename,
2014
+ options,
2015
+ true,
2016
+ true,
2017
+ // for vue files, create descriptor from fs read to be consistent with
2018
+ // logic in handleHotUpdate()
2019
+ // for non vue files, e.g. md files in vitepress, we assume
2020
+ // `hmrContext.read` is overwritten so handleHotUpdate() is dealing with
2021
+ // post-transform code, so we populate the descriptor with post-transform
2022
+ // code here as well.
2023
+ filename.endsWith(".vue") ? void 0 : code
2024
+ );
2025
+ }
2026
+ if (errors.length) {
2027
+ errors.forEach(
2028
+ (error) => pluginContext.error(createRollupError(filename, error))
2029
+ );
2030
+ return null;
2031
+ }
2032
+ const attachedProps = [];
2033
+ const hasScoped = descriptor.styles.some((s) => s.scoped);
2034
+ const { code: scriptCode, map: scriptMap } = await genScriptCode(
2035
+ descriptor,
2036
+ options,
2037
+ pluginContext,
2038
+ ssr,
2039
+ customElement
2040
+ );
2041
+ const hasTemplateImport = descriptor.template && !isUseInlineTemplate(descriptor, options);
2042
+ let templateCode = "";
2043
+ let templateMap = void 0;
2044
+ if (hasTemplateImport) {
2045
+ ({ code: templateCode, map: templateMap } = await genTemplateCode(
2046
+ descriptor,
2047
+ options,
2048
+ pluginContext,
2049
+ ssr,
2050
+ customElement
2051
+ ));
2052
+ }
2053
+ if (hasTemplateImport) {
2054
+ attachedProps.push(
2055
+ ssr ? ["ssrRender", "_sfc_ssrRender"] : ["render", "_sfc_render"]
2056
+ );
2057
+ } else {
2058
+ if (prevDescriptor && !isEqualBlock(descriptor.template, prevDescriptor.template)) {
2059
+ attachedProps.push([ssr ? "ssrRender" : "render", "() => {}"]);
2060
+ }
2061
+ }
2062
+ const stylesCode = await genStyleCode(
2063
+ descriptor,
2064
+ pluginContext,
2065
+ customElement,
2066
+ attachedProps
2067
+ );
2068
+ const customBlocksCode = await genCustomBlockCode(descriptor, pluginContext);
2069
+ const output = [
2070
+ scriptCode,
2071
+ templateCode,
2072
+ stylesCode,
2073
+ customBlocksCode
2074
+ ];
2075
+ if (hasScoped) {
2076
+ attachedProps.push([`__scopeId`, JSON.stringify(`data-v-${descriptor.id}`)]);
2077
+ }
2078
+ if (devToolsEnabled || devServer && !isProduction) {
2079
+ attachedProps.push([
2080
+ `__file`,
2081
+ JSON.stringify(isProduction ? path.basename(filename) : filename)
2082
+ ]);
2083
+ }
2084
+ if (devServer && devServer.config.server.hmr !== false && !ssr && !isProduction) {
2085
+ output.push(`_sfc_main.__hmrId = ${JSON.stringify(descriptor.id)}`);
2086
+ output.push(
2087
+ `typeof __VUE_HMR_RUNTIME__ !== 'undefined' && __VUE_HMR_RUNTIME__.createRecord(_sfc_main.__hmrId, _sfc_main)`
2088
+ );
2089
+ output.push(
2090
+ `import.meta.hot.on('file-changed', ({ file }) => {`,
2091
+ ` __VUE_HMR_RUNTIME__.CHANGED_FILE = file`,
2092
+ `})`
2093
+ );
2094
+ if (prevDescriptor && isOnlyTemplateChanged(prevDescriptor, descriptor)) {
2095
+ output.push(
2096
+ `export const _rerender_only = __VUE_HMR_RUNTIME__.CHANGED_FILE === ${JSON.stringify(normalizePath$1(filename))}`
2097
+ );
2098
+ }
2099
+ output.push(
2100
+ `import.meta.hot.accept(mod => {`,
2101
+ ` if (!mod) return`,
2102
+ ` const { default: updated, _rerender_only } = mod`,
2103
+ ` if (_rerender_only) {`,
2104
+ ` __VUE_HMR_RUNTIME__.rerender(updated.__hmrId, updated.render)`,
2105
+ ` } else {`,
2106
+ ` __VUE_HMR_RUNTIME__.reload(updated.__hmrId, updated)`,
2107
+ ` }`,
2108
+ `})`
2109
+ );
2110
+ }
2111
+ if (ssr) {
2112
+ const normalizedFilename = normalizePath$1(
2113
+ path.relative(options.root, filename)
2114
+ );
2115
+ output.push(
2116
+ `import { useSSRContext as __vite_useSSRContext } from 'vue'`,
2117
+ `const _sfc_setup = _sfc_main.setup`,
2118
+ `_sfc_main.setup = (props, ctx) => {`,
2119
+ ` const ssrContext = __vite_useSSRContext()`,
2120
+ ` ;(ssrContext.modules || (ssrContext.modules = new Set())).add(${JSON.stringify(
2121
+ normalizedFilename
2122
+ )})`,
2123
+ ` return _sfc_setup ? _sfc_setup(props, ctx) : undefined`,
2124
+ `}`
2125
+ );
2126
+ }
2127
+ let resolvedMap = void 0;
2128
+ if (options.sourceMap) {
2129
+ if (templateMap) {
2130
+ const from = scriptMap ?? {
2131
+ file: filename,
2132
+ sourceRoot: "",
2133
+ version: 3,
2134
+ sources: [],
2135
+ sourcesContent: [],
2136
+ names: [],
2137
+ mappings: ""
2138
+ };
2139
+ const gen = fromMap(
2140
+ // version property of result.map is declared as string
2141
+ // but actually it is `3`
2142
+ from
2143
+ );
2144
+ const tracer = new TraceMap(
2145
+ // same above
2146
+ templateMap
2147
+ );
2148
+ const offset = (scriptCode.match(/\r?\n/g)?.length ?? 0) + 1;
2149
+ eachMapping(tracer, (m) => {
2150
+ if (m.source == null) return;
2151
+ addMapping(gen, {
2152
+ source: m.source,
2153
+ original: { line: m.originalLine, column: m.originalColumn },
2154
+ generated: {
2155
+ line: m.generatedLine + offset,
2156
+ column: m.generatedColumn
2157
+ }
2158
+ });
2159
+ });
2160
+ resolvedMap = toEncodedMap(gen);
2161
+ resolvedMap.sourcesContent = templateMap.sourcesContent;
2162
+ } else {
2163
+ resolvedMap = scriptMap;
2164
+ }
2165
+ }
2166
+ if (!attachedProps.length) {
2167
+ output.push(`export default _sfc_main`);
2168
+ } else {
2169
+ output.push(
2170
+ `import _export_sfc from '${EXPORT_HELPER_ID}'`,
2171
+ `export default /*#__PURE__*/_export_sfc(_sfc_main, [${attachedProps.map(([key, val]) => `['${key}',${val}]`).join(",")}])`
2172
+ );
2173
+ }
2174
+ let resolvedCode = output.join("\n");
2175
+ const lang = descriptor.scriptSetup?.lang || descriptor.script?.lang;
2176
+ if (lang && /tsx?$/.test(lang) && !descriptor.script?.src) {
2177
+ const { transformWithOxc } = await import("vite");
2178
+ if (transformWithOxc) {
2179
+ const { code: code2, map } = await transformWithOxc(
2180
+ resolvedCode,
2181
+ filename,
2182
+ {
2183
+ // #430 support decorators in .vue file
2184
+ // target can be overridden by oxc config target
2185
+ // @ts-ignore Rolldown-specific
2186
+ ...options.devServer?.config.oxc,
2187
+ lang: "ts",
2188
+ sourcemap: options.sourceMap
2189
+ },
2190
+ resolvedMap
2191
+ );
2192
+ resolvedCode = code2;
2193
+ resolvedMap = resolvedMap ? map : resolvedMap;
2194
+ } else {
2195
+ const { code: code2, map } = await transformWithEsbuild(
2196
+ resolvedCode,
2197
+ filename,
2198
+ {
2199
+ target: "esnext",
2200
+ charset: "utf8",
2201
+ // #430 support decorators in .vue file
2202
+ // target can be overridden by esbuild config target
2203
+ ...options.devServer?.config.esbuild,
2204
+ loader: "ts",
2205
+ sourcemap: options.sourceMap
2206
+ },
2207
+ resolvedMap
2208
+ );
2209
+ resolvedCode = code2;
2210
+ resolvedMap = resolvedMap ? map : resolvedMap;
2211
+ }
2212
+ }
2213
+ return {
2214
+ code: resolvedCode,
2215
+ map: resolvedMap || {
2216
+ mappings: ""
2217
+ },
2218
+ meta: {
2219
+ vite: {
2220
+ lang: descriptor.script?.lang || descriptor.scriptSetup?.lang || "js"
2221
+ }
2222
+ }
2223
+ };
2224
+ }
2225
+ async function genTemplateCode(descriptor, options, pluginContext, ssr, customElement) {
2226
+ const template = descriptor.template;
2227
+ const hasScoped = descriptor.styles.some((style) => style.scoped);
2228
+ if ((!template.lang || template.lang === "html") && !template.src) {
2229
+ return transformTemplateInMain(
2230
+ template.content,
2231
+ descriptor,
2232
+ options,
2233
+ pluginContext,
2234
+ ssr,
2235
+ customElement
2236
+ );
2237
+ } else {
2238
+ if (template.src) {
2239
+ await linkSrcToDescriptor(
2240
+ template.src,
2241
+ descriptor,
2242
+ pluginContext,
2243
+ hasScoped
2244
+ );
2245
+ }
2246
+ const src2 = template.src || descriptor.filename;
2247
+ const srcQuery = template.src ? hasScoped ? `&src=${descriptor.id}` : "&src=true" : "";
2248
+ const scopedQuery = hasScoped ? `&scoped=${descriptor.id}` : ``;
2249
+ const attrsQuery = attrsToQuery(template.attrs, "js", true);
2250
+ const query = `?vue&type=template${srcQuery}${scopedQuery}${attrsQuery}`;
2251
+ const request = JSON.stringify(src2 + query);
2252
+ const renderFnName = ssr ? "ssrRender" : "render";
2253
+ return {
2254
+ code: `import { ${renderFnName} as _sfc_${renderFnName} } from ${request}`,
2255
+ map: void 0
2256
+ };
2257
+ }
2258
+ }
2259
+ async function genScriptCode(descriptor, options, pluginContext, ssr, customElement) {
2260
+ const vaporFlag = descriptor.vapor ? "__vapor: true" : "";
2261
+ let scriptCode = `const ${scriptIdentifier} = { ${vaporFlag} }`;
2262
+ let map;
2263
+ const script = resolveScript(descriptor, options, ssr, customElement);
2264
+ if (script) {
2265
+ if (canInlineMain(descriptor, options)) {
2266
+ if (!options.compiler.version) {
2267
+ const userPlugins = options.script?.babelParserPlugins || [];
2268
+ const defaultPlugins = script.lang === "ts" ? userPlugins.includes("decorators") ? ["typescript"] : ["typescript", "decorators-legacy"] : [];
2269
+ scriptCode = options.compiler.rewriteDefault(
2270
+ script.content,
2271
+ scriptIdentifier,
2272
+ [...defaultPlugins, ...userPlugins]
2273
+ );
2274
+ } else {
2275
+ scriptCode = script.content;
2276
+ }
2277
+ map = script.map;
2278
+ } else {
2279
+ if (script.src) {
2280
+ await linkSrcToDescriptor(script.src, descriptor, pluginContext, false);
2281
+ }
2282
+ const src2 = script.src || descriptor.filename;
2283
+ const langFallback = script.src && path.extname(src2).slice(1) || "js";
2284
+ const attrsQuery = attrsToQuery(script.attrs, langFallback);
2285
+ const srcQuery = script.src ? `&src=true` : ``;
2286
+ const query = `?vue&type=script${srcQuery}${attrsQuery}`;
2287
+ const request = JSON.stringify(src2 + query);
2288
+ scriptCode = `import _sfc_main from ${request}
2289
+ export * from ${request}`;
2290
+ }
2291
+ }
2292
+ return {
2293
+ code: scriptCode,
2294
+ map
2295
+ };
2296
+ }
2297
+ async function genStyleCode(descriptor, pluginContext, customElement, attachedProps) {
2298
+ let stylesCode = ``;
2299
+ let cssModulesMap;
2300
+ if (descriptor.styles.length) {
2301
+ for (let i = 0; i < descriptor.styles.length; i++) {
2302
+ const style = descriptor.styles[i];
2303
+ if (style.src) {
2304
+ await linkSrcToDescriptor(
2305
+ style.src,
2306
+ descriptor,
2307
+ pluginContext,
2308
+ style.scoped
2309
+ );
2310
+ }
2311
+ const src2 = style.src || descriptor.filename;
2312
+ const attrsQuery = attrsToQuery(style.attrs, "css");
2313
+ const srcQuery = style.src ? style.scoped ? `&src=${descriptor.id}` : "&src=true" : "";
2314
+ const directQuery = customElement ? `&inline` : ``;
2315
+ const scopedQuery = style.scoped ? `&scoped=${descriptor.id}` : ``;
2316
+ const query = `?vue&type=style&index=${i}${srcQuery}${directQuery}${scopedQuery}`;
2317
+ const styleRequest = src2 + query + attrsQuery;
2318
+ if (style.module) {
2319
+ if (customElement) {
2320
+ throw new Error(
2321
+ `<style module> is not supported in custom elements mode.`
2322
+ );
2323
+ }
2324
+ const [importCode, nameMap] = genCSSModulesCode(
2325
+ i,
2326
+ styleRequest,
2327
+ style.module
2328
+ );
2329
+ stylesCode += importCode;
2330
+ Object.assign(cssModulesMap || (cssModulesMap = {}), nameMap);
2331
+ } else {
2332
+ if (customElement) {
2333
+ stylesCode += `
2334
+ import _style_${i} from ${JSON.stringify(
2335
+ styleRequest
2336
+ )}`;
2337
+ } else {
2338
+ stylesCode += `
2339
+ import ${JSON.stringify(styleRequest)}`;
2340
+ }
2341
+ }
2342
+ }
2343
+ if (customElement) {
2344
+ attachedProps.push([
2345
+ `styles`,
2346
+ `[${descriptor.styles.map((_, i) => `_style_${i}`).join(",")}]`
2347
+ ]);
2348
+ }
2349
+ }
2350
+ if (cssModulesMap) {
2351
+ const mappingCode = Object.entries(cssModulesMap).reduce(
2352
+ (code, [key, value]) => code + `"${key}":${value},
2353
+ `,
2354
+ "{\n"
2355
+ ) + "}";
2356
+ stylesCode += `
2357
+ const cssModules = ${mappingCode}`;
2358
+ attachedProps.push([`__cssModules`, `cssModules`]);
2359
+ }
2360
+ return stylesCode;
2361
+ }
2362
+ function genCSSModulesCode(index, request, moduleName) {
2363
+ const styleVar = `style${index}`;
2364
+ const exposedName = typeof moduleName === "string" ? moduleName : "$style";
2365
+ const moduleRequest = request.replace(/\.(\w+)$/, ".module.$1");
2366
+ return [
2367
+ `
2368
+ import ${styleVar} from ${JSON.stringify(moduleRequest)}`,
2369
+ { [exposedName]: styleVar }
2370
+ ];
2371
+ }
2372
+ async function genCustomBlockCode(descriptor, pluginContext) {
2373
+ let code = "";
2374
+ for (let index = 0; index < descriptor.customBlocks.length; index++) {
2375
+ const block = descriptor.customBlocks[index];
2376
+ if (block.src) {
2377
+ await linkSrcToDescriptor(block.src, descriptor, pluginContext, false);
2378
+ }
2379
+ const src2 = block.src || descriptor.filename;
2380
+ const attrsQuery = attrsToQuery(block.attrs, block.type);
2381
+ const srcQuery = block.src ? `&src=true` : ``;
2382
+ const query = `?vue&type=${block.type}&index=${index}${srcQuery}${attrsQuery}`;
2383
+ const request = JSON.stringify(src2 + query);
2384
+ code += `import block${index} from ${request}
2385
+ `;
2386
+ code += `if (typeof block${index} === 'function') block${index}(_sfc_main)
2387
+ `;
2388
+ }
2389
+ return code;
2390
+ }
2391
+ async function linkSrcToDescriptor(src2, descriptor, pluginContext, scoped) {
2392
+ const srcFile = (await pluginContext.resolve(src2, descriptor.filename))?.id || src2;
2393
+ setSrcDescriptor(srcFile.replace(/\?.*$/, ""), descriptor, scoped);
2394
+ }
2395
+ var ignoreList = [
2396
+ "id",
2397
+ "index",
2398
+ "src",
2399
+ "type",
2400
+ "lang",
2401
+ "module",
2402
+ "scoped",
2403
+ "generic"
2404
+ ];
2405
+ function attrsToQuery(attrs, langFallback, forceLangFallback = false) {
2406
+ let query = ``;
2407
+ for (const name in attrs) {
2408
+ const value = attrs[name];
2409
+ if (!ignoreList.includes(name)) {
2410
+ query += `&${encodeURIComponent(name)}${value ? `=${encodeURIComponent(value)}` : ``}`;
2411
+ }
2412
+ }
2413
+ if (langFallback || attrs.lang) {
2414
+ query += `lang` in attrs ? forceLangFallback ? `&lang.${langFallback}` : `&lang.${attrs.lang}` : `&lang.${langFallback}`;
2415
+ }
2416
+ return query;
2417
+ }
2418
+ async function transformStyle(code, descriptor, index, options, pluginContext, filename) {
2419
+ const block = descriptor.styles[index];
2420
+ const result = await options.compiler.compileStyleAsync({
2421
+ ...options.style,
2422
+ filename: descriptor.filename,
2423
+ id: `data-v-${descriptor.id}`,
2424
+ isProd: options.isProduction,
2425
+ source: code,
2426
+ scoped: block.scoped,
2427
+ ...options.cssDevSourcemap ? {
2428
+ postcssOptions: {
2429
+ map: {
2430
+ from: filename,
2431
+ inline: false,
2432
+ annotation: false
2433
+ }
2434
+ }
2435
+ } : {}
2436
+ });
2437
+ if (result.errors.length) {
2438
+ result.errors.forEach((error) => {
2439
+ if (error.line && error.column) {
2440
+ error.loc = {
2441
+ file: descriptor.filename,
2442
+ line: error.line + block.loc.start.line,
2443
+ column: error.column
2444
+ };
2445
+ }
2446
+ pluginContext.error(error);
2447
+ });
2448
+ return null;
2449
+ }
2450
+ const map = result.map ? await formatPostcssSourceMap(
2451
+ // version property of result.map is declared as string
2452
+ // but actually it is a number
2453
+ result.map,
2454
+ filename
2455
+ ) : { mappings: "" };
2456
+ return {
2457
+ code: result.code,
2458
+ map,
2459
+ meta: block.scoped && !descriptor.isTemp ? {
2460
+ vite: {
2461
+ cssScopeTo: [descriptor.filename, "default"]
2462
+ }
2463
+ } : void 0
2464
+ };
2465
+ }
2466
+ function vuePlugin(rawOptions = {}) {
2467
+ clearScriptCache();
2468
+ const options = shallowRef({
2469
+ isProduction: process.env.NODE_ENV === "production",
2470
+ compiler: null,
2471
+ // to be set in buildStart
2472
+ include: /\.vue$/,
2473
+ customElement: /\.ce\.vue$/,
2474
+ ...rawOptions,
2475
+ root: process.cwd(),
2476
+ sourceMap: true,
2477
+ cssDevSourcemap: false
2478
+ });
2479
+ const filter = computed(
2480
+ () => createFilter(options.value.include, options.value.exclude)
2481
+ );
2482
+ const customElementFilter = computed(() => {
2483
+ const customElement = options.value.features?.customElement || options.value.customElement;
2484
+ return typeof customElement === "boolean" ? () => customElement : createFilter(customElement);
2485
+ });
2486
+ let transformCachedModule = false;
2487
+ return {
2488
+ name: "vite:vue",
2489
+ api: {
2490
+ get options() {
2491
+ return options.value;
2492
+ },
2493
+ set options(value) {
2494
+ options.value = value;
2495
+ },
2496
+ version
2497
+ },
2498
+ handleHotUpdate(ctx) {
2499
+ ctx.server.ws.send({
2500
+ type: "custom",
2501
+ event: "file-changed",
2502
+ data: { file: normalizePath$1(ctx.file) }
2503
+ });
2504
+ if (options.value.compiler.invalidateTypeCache) {
2505
+ options.value.compiler.invalidateTypeCache(ctx.file);
2506
+ }
2507
+ let typeDepModules;
2508
+ const matchesFilter = filter.value(ctx.file);
2509
+ if (typeDepToSFCMap.has(ctx.file)) {
2510
+ typeDepModules = handleTypeDepChange(
2511
+ typeDepToSFCMap.get(ctx.file),
2512
+ ctx
2513
+ );
2514
+ if (!matchesFilter) return typeDepModules;
2515
+ }
2516
+ if (matchesFilter) {
2517
+ return handleHotUpdate(
2518
+ ctx,
2519
+ options.value,
2520
+ customElementFilter.value(ctx.file),
2521
+ typeDepModules
2522
+ );
2523
+ }
2524
+ },
2525
+ config(config) {
2526
+ const parseDefine = (v) => {
2527
+ try {
2528
+ return typeof v === "string" ? JSON.parse(v) : v;
2529
+ } catch (err) {
2530
+ return v;
2531
+ }
2532
+ };
2533
+ return {
2534
+ resolve: {
2535
+ dedupe: config.build?.ssr ? [] : ["vue"]
2536
+ },
2537
+ define: {
2538
+ __VUE_OPTIONS_API__: options.value.features?.optionsAPI ?? parseDefine(config.define?.__VUE_OPTIONS_API__) ?? true,
2539
+ __VUE_PROD_DEVTOOLS__: (options.value.features?.prodDevtools || parseDefine(config.define?.__VUE_PROD_DEVTOOLS__)) ?? false,
2540
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: (options.value.features?.prodHydrationMismatchDetails || parseDefine(
2541
+ config.define?.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__
2542
+ )) ?? false
2543
+ },
2544
+ ssr: {
2545
+ // @ts-ignore -- config.legacy.buildSsrCjsExternalHeuristics will be removed in Vite 5
2546
+ external: config.legacy?.buildSsrCjsExternalHeuristics ? ["vue", "@vue/server-renderer"] : []
2547
+ }
2548
+ };
2549
+ },
2550
+ configResolved(config) {
2551
+ options.value = {
2552
+ ...options.value,
2553
+ root: config.root,
2554
+ sourceMap: config.command === "build" ? !!config.build.sourcemap : true,
2555
+ cssDevSourcemap: config.css?.devSourcemap ?? false,
2556
+ isProduction: config.isProduction,
2557
+ devToolsEnabled: !!(options.value.features?.prodDevtools || config.define.__VUE_PROD_DEVTOOLS__ || !config.isProduction)
2558
+ };
2559
+ const _warn = config.logger.warn;
2560
+ config.logger.warn = (...args) => {
2561
+ const msg = args[0];
2562
+ if (msg.match(
2563
+ /\[lightningcss\] '(deep|slotted|global)' is not recognized as a valid pseudo-/
2564
+ )) {
2565
+ return;
2566
+ }
2567
+ _warn(...args);
2568
+ };
2569
+ transformCachedModule = config.command === "build" && options.value.sourceMap && config.build.watch != null;
2570
+ },
2571
+ shouldTransformCachedModule({ id }) {
2572
+ if (transformCachedModule && parseVueRequest(id).query.vue) {
2573
+ return true;
2574
+ }
2575
+ return false;
2576
+ },
2577
+ configureServer(server) {
2578
+ options.value.devServer = server;
2579
+ },
2580
+ buildStart() {
2581
+ const compiler = options.value.compiler = options.value.compiler || resolveCompiler(options.value.root);
2582
+ if (compiler.invalidateTypeCache) {
2583
+ options.value.devServer?.watcher.on("unlink", (file) => {
2584
+ compiler.invalidateTypeCache(file);
2585
+ });
2586
+ }
2587
+ },
2588
+ async resolveId(id) {
2589
+ if (id === EXPORT_HELPER_ID) {
2590
+ return id;
2591
+ }
2592
+ if (parseVueRequest(id).query.vue) {
2593
+ return id;
2594
+ }
2595
+ },
2596
+ load(id, opt) {
2597
+ if (id === EXPORT_HELPER_ID) {
2598
+ return helperCode;
2599
+ }
2600
+ const ssr = opt?.ssr === true;
2601
+ const { filename, query } = parseVueRequest(id);
2602
+ if (query.vue) {
2603
+ if (query.src) {
2604
+ return fs.readFileSync(filename, "utf-8");
2605
+ }
2606
+ const descriptor = getDescriptor(filename, options.value);
2607
+ let block;
2608
+ if (query.type === "script") {
2609
+ block = resolveScript(
2610
+ descriptor,
2611
+ options.value,
2612
+ ssr,
2613
+ customElementFilter.value(filename)
2614
+ );
2615
+ } else if (query.type === "template") {
2616
+ block = descriptor.template;
2617
+ } else if (query.type === "style") {
2618
+ block = descriptor.styles[query.index];
2619
+ } else if (query.index != null) {
2620
+ block = descriptor.customBlocks[query.index];
2621
+ }
2622
+ if (block) {
2623
+ return {
2624
+ code: block.content,
2625
+ map: block.map
2626
+ };
2627
+ }
2628
+ }
2629
+ },
2630
+ transform(code, id, opt) {
2631
+ const ssr = opt?.ssr === true;
2632
+ const { filename, query } = parseVueRequest(id);
2633
+ if (query.raw || query.url) {
2634
+ return;
2635
+ }
2636
+ if (!filter.value(filename) && !query.vue) {
2637
+ return;
2638
+ }
2639
+ if (!query.vue) {
2640
+ return transformMain(
2641
+ code,
2642
+ filename,
2643
+ options.value,
2644
+ this,
2645
+ ssr,
2646
+ customElementFilter.value(filename)
2647
+ );
2648
+ } else {
2649
+ const descriptor = query.src ? getSrcDescriptor(filename, query) || getTempSrcDescriptor(filename, query) : getDescriptor(filename, options.value);
2650
+ if (query.src) {
2651
+ this.addWatchFile(filename);
2652
+ }
2653
+ if (query.type === "template") {
2654
+ return transformTemplateAsModule(
2655
+ code,
2656
+ descriptor,
2657
+ options.value,
2658
+ this,
2659
+ ssr,
2660
+ customElementFilter.value(filename)
2661
+ );
2662
+ } else if (query.type === "style") {
2663
+ return transformStyle(
2664
+ code,
2665
+ descriptor,
2666
+ Number(query.index || 0),
2667
+ options.value,
2668
+ this,
2669
+ filename
2670
+ );
2671
+ }
2672
+ }
2673
+ }
2674
+ };
2675
+ }
2676
+
2677
+ // src/vite-config/plugin/autoImport/index.ts
2678
+ import AutoImport from "unplugin-auto-import/vite";
2679
+ import Components from "unplugin-vue-components/vite";
2680
+ import { AntDesignVueResolver, ElementPlusResolver } from "unplugin-vue-components/resolvers";
2681
+ var AutoImportDeps = () => {
2682
+ return [
2683
+ /* 自动导入配置
2684
+ - imports: 声明需要自动导入的模块(vue核心API和路由API)
2685
+ - dts: 生成的类型声明文件路径 */
2686
+ AutoImport({
2687
+ resolvers: [ElementPlusResolver()],
2688
+ imports: ["vue", "vue-router", "pinia"],
2689
+ dts: "types/auto-imports.d.ts",
2690
+ eslintrc: {
2691
+ enabled: true,
2692
+ filepath: "./.eslintrc-auto-import.json",
2693
+ globalsPropValue: true
2694
+ },
2695
+ // 排除某些文件
2696
+ exclude: ["**/node_modules/**", "**/dist/**"],
2697
+ // 包含模式
2698
+ include: [
2699
+ /\.[tj]sx?$/,
2700
+ // .ts, .tsx, .js, .jsx
2701
+ /\.vue$/,
2702
+ /\.vue\?vue/,
2703
+ // .vue
2704
+ /\.md$/
2705
+ // .md
2706
+ ]
2707
+ }),
2708
+ /* 组件自动注册配置
2709
+ - globs: 组件文件匹配模式
2710
+ - dts: 生成的组件类型声明文件路径 */
2711
+ Components({
2712
+ resolvers: [
2713
+ ElementPlusResolver({
2714
+ importStyle: "sass"
2715
+ // 使用 sass 样式
2716
+ }),
2717
+ AntDesignVueResolver({
2718
+ importStyle: false
2719
+ // css in js
2720
+ })
2721
+ ],
2722
+ globs: ["src/components/**/*.vue", "src/views/**/*.vue"],
2723
+ dts: "types/components.d.ts",
2724
+ // 允许子目录搜索
2725
+ deep: true,
2726
+ // 排除某些文件
2727
+ exclude: [/node_modules/, /\.git/],
2728
+ // 包含模式
2729
+ include: [/\.vue$/, /\.vue\?vue/]
2730
+ })
2731
+ ];
2732
+ };
2733
+
2734
+ // src/vite-config/plugin/index.ts
2735
+ import vueDevTools from "vite-plugin-vue-devtools";
2736
+ import UnoCSS from "unocss/vite";
2737
+ import { transformerDirectives, transformerVariantGroup } from "unocss";
2738
+ function createVitePlugins(plugins = [], showDevTools) {
2739
+ return [
2740
+ // vue 支持
2741
+ vuePlugin({
2742
+ template: {
2743
+ compilerOptions: {
2744
+ isCustomElement: (tag) => tag.startsWith("micro-app")
2745
+ }
2746
+ }
2747
+ }),
2748
+ // vue 开发者工具
2749
+ showDevTools && vueDevTools(),
2750
+ // css 原子化
2751
+ UnoCSS({
2752
+ transformers: [
2753
+ transformerDirectives(),
2754
+ // 启用 @apply 指令
2755
+ transformerVariantGroup()
2756
+ // 启用 hover:(bg-blue text-white) 语法
2757
+ ]
2758
+ }),
2759
+ // 自动按需引入依赖
2760
+ ...AutoImportDeps(),
2761
+ ...plugins
2762
+ ];
2763
+ }
2764
+
2765
+ // src/vite-config/resolve/index.ts
2766
+ import path2 from "path";
2767
+ var appRoot = process.cwd();
2768
+ var resolve_default = {
2769
+ alias: {
2770
+ "@": path2.resolve(appRoot, "src"),
2771
+ "#": path2.resolve(appRoot, "types")
2772
+ // '@monorepo/shared': path.resolve(appRoot, '../../shared/src'),
2773
+ // '@monorepo/msw-mocks': path.resolve(appRoot, '../../msw-mocks/src'),
2774
+ // '@monorepo/ebuilds-ui': path.resolve(appRoot, '../../ebuilds-ui')
2775
+ },
2776
+ extensions: [".js", ".ts", ".jsx", ".tsx", ".json", ".vue"]
2777
+ };
2778
+
2779
+ // src/vite-config/server/index.ts
2780
+ var dev_prefix = "/api";
2781
+ function convertProxyConfig(data, replaceFunction) {
2782
+ const result = {};
2783
+ for (let i = 0, len = data.length; i < len; i++) {
2784
+ const item = data[i];
2785
+ result[`${item.prefix}`] = {
2786
+ target: item.url,
2787
+ changeOrigin: true,
2788
+ // 启用origin头修改
2789
+ // 路径重写:移除请求路径中的统一前缀(如/api)
2790
+ rewrite: replaceFunction || ((path3) => path3.replace(new RegExp(`${dev_prefix}`), ""))
2791
+ };
2792
+ }
2793
+ return result;
2794
+ }
2795
+ function server_default(devPort = 5e3, proxyConfig, baseUrl = "/") {
2796
+ const API_PROXY = [{ prefix: dev_prefix, url: baseUrl }];
2797
+ let proxy = convertProxyConfig(API_PROXY);
2798
+ if (proxyConfig) {
2799
+ const { data, replaceFunction } = proxyConfig;
2800
+ proxy = convertProxyConfig(data, replaceFunction);
2801
+ }
2802
+ return {
2803
+ hmr: { overlay: false },
2804
+ port: devPort,
2805
+ open: false,
2806
+ cors: true,
2807
+ host: "0.0.0.0",
2808
+ proxy
2809
+ };
2810
+ }
2811
+
2812
+ // src/vite-config/build/index.ts
2813
+ var build_default = {
2814
+ /** 构建配置:设置 chunk 体积警告阈值为 1.5MB */
2815
+ // minify: false, // 禁用代码压缩
2816
+ sourcemap: true,
2817
+ // 生成源映射文件
2818
+ chunkSizeWarningLimit: 1500,
2819
+ rollupOptions: {
2820
+ output: {
2821
+ /**
2822
+ * 自定义模块分包策略
2823
+ * @param id - 模块的完整路径
2824
+ */
2825
+ manualChunks(id) {
2826
+ if (id.includes("node_modules")) {
2827
+ if (id.includes("lodash")) return "lodash";
2828
+ if (id.includes("moment")) return "moment";
2829
+ if (id.includes("unocss")) return "unocss";
2830
+ return "vendor";
2831
+ }
2832
+ },
2833
+ /** 入口文件命名规则:js目录/入口名.8位哈希.js */
2834
+ entryFileNames: `js/[name].[hash:8].js`,
2835
+ /** 静态资源文件命名规则:按类型目录/原名.8位哈希.扩展名 */
2836
+ assetFileNames: `[ext]/[name].[hash:8].[ext]`,
2837
+ /**
2838
+ * 非入口 chunk 文件命名规则
2839
+ * @param chunkInfo - 包含 chunk 元信息的配置对象
2840
+ * @returns {string} 基于父级目录结构的文件路径
2841
+ */
2842
+ chunkFileNames: (chunkInfo) => {
2843
+ const modulePath = chunkInfo.facadeModuleId?.split("/") || [];
2844
+ const fileName = modulePath[modulePath.length - 2] || "[name]";
2845
+ return `js/${fileName}/[name].[hash:8].js`;
2846
+ }
2847
+ }
2848
+ }
2849
+ };
2850
+
2851
+ // src/vite-config/index.ts
2852
+ function createBaseViteConfig(options) {
2853
+ return defineConfig((config) => {
2854
+ const env = loadEnv(config.mode, process.cwd(), "VITE_");
2855
+ const {
2856
+ port = 5e3,
2857
+ plugins = [],
2858
+ proxy,
2859
+ showDevTools = false,
2860
+ enableOptimizeDeps = true,
2861
+ baseUrl
2862
+ } = options;
2863
+ return {
2864
+ plugins: createVitePlugins(plugins, showDevTools),
2865
+ resolve: resolve_default,
2866
+ base: env.VITE_APP_PUBLIC_URL || "",
2867
+ server: server_default(port, proxy, baseUrl),
2868
+ build: build_default,
2869
+ optimizeDeps: {
2870
+ include: enableOptimizeDeps ? ["vue", "vue-router", "pinia", "axios", "element-plus", "echarts"] : []
2871
+ }
2872
+ };
2873
+ });
2874
+ }
2875
+
2876
+ export {
2877
+ createBaseViteConfig
2878
+ };